import { IconBrandSpeedtest, IconReload, IconSettings, } from '@tabler/icons-solidjs' import { For, Show, createMemo, createSignal, onMount } from 'solid-js' import { twMerge } from 'tailwind-merge' import { Button, Collapse, ProxiesSettingsModal, ProxyNodeCard, ProxyNodePreview, RenderInTwoColumns, SubscriptionInfo, } from '~/components' import { filterProxiesByAvailability, sortProxiesByOrderingType, } from '~/helpers' import { useI18n } from '~/i18n' import { formatTimeFromNow, hideUnAvailableProxies, proxiesOrderingType, useProxies, } from '~/signals' enum ActiveTab { proxyProviders = 'proxyProviders', proxies = 'proxies', } export default () => { let proxiesSettingsModalRef: HTMLDialogElement | undefined const [t] = useI18n() const { fetchProxies, proxies, selectProxyInGroup, latencyMap, proxyProviders, updateProviderByProviderName, updateAllProvider, proxyGroupLatencyTest, proxyProviderLatencyTest, collapsedMap, setCollapsedMap, proxyGroupLatencyTestingMap, proxyProviderLatencyTestingMap, isAllProviderUpdating, updatingMap, } = useProxies() onMount(fetchProxies) const onProxyGroupLatencyTestClick = async ( e: MouseEvent, groupName: string, ) => { e.stopPropagation() void proxyGroupLatencyTest(groupName) } const onProxyProviderLatencyTestClick = ( e: MouseEvent, providerName: string, ) => { e.stopPropagation() void proxyProviderLatencyTest(providerName) } const onUpdateProxyProviderClick = (e: MouseEvent, providerName: string) => { e.stopPropagation() void updateProviderByProviderName(providerName) } const onUpdateAllProviderClick = async (e: MouseEvent) => { e.stopPropagation() void updateAllProvider() } const [activeTab, setActiveTab] = createSignal(ActiveTab.proxies) const tabs = () => [ { type: ActiveTab.proxies, name: t('proxies'), count: proxies().length, }, { type: ActiveTab.proxyProviders, name: t('proxyProviders'), count: proxyProviders().length, }, ] return (
{(tab) => ( )}
{(proxyGroup) => { const sortedProxyNames = createMemo(() => filterProxiesByAvailability( sortProxiesByOrderingType( proxyGroup.all ?? [], latencyMap(), proxiesOrderingType(), ), latencyMap(), hideUnAvailableProxies(), ), ) const title = ( <>
{proxyGroup.name}
{proxyGroup.all?.length}
{proxyGroup.type}{' '} {proxyGroup.now?.length > 0 && ` :: ${proxyGroup.now}`}
) return ( setCollapsedMap(proxyGroup.name, val)} > {(proxyName) => ( void selectProxyInGroup(proxyGroup, proxyName) } /> )} ) }}
{(proxyProvider) => { const sortedProxyNames = createMemo(() => sortProxiesByOrderingType( proxyProvider.proxies.map((i) => i.name) ?? [], latencyMap(), proxiesOrderingType(), ), ) const title = ( <>
{proxyProvider.name}
{proxyProvider.proxies.length}
{proxyProvider.vehicleType} :: {t('updated')}{' '} {formatTimeFromNow(proxyProvider.updatedAt)}
) return ( setCollapsedMap(proxyProvider.name, val) } > {(proxyName) => } ) }}
(proxiesSettingsModalRef = el)} /> ) }