2023-09-15 23:43:55 +08:00
|
|
|
import { useI18n } from '@solid-primitives/i18n'
|
2023-09-19 00:35:58 +08:00
|
|
|
import { IconX } from '@tabler/icons-solidjs'
|
2023-09-15 23:43:55 +08:00
|
|
|
import { For } from 'solid-js'
|
2023-09-19 00:35:58 +08:00
|
|
|
import { Button, ConfigTitle } from '~/components'
|
2023-09-15 23:43:55 +08:00
|
|
|
import { MODAL, PROXIES_ORDERING_TYPE, PROXIES_PREVIEW_TYPE } from '~/constants'
|
|
|
|
import {
|
|
|
|
autoCloseConns,
|
2023-09-15 23:56:14 +08:00
|
|
|
hideUnAvailableProxies,
|
2023-09-15 23:43:55 +08:00
|
|
|
latencyTestTimeoutDuration,
|
|
|
|
proxiesOrderingType,
|
|
|
|
proxiesPreviewType,
|
|
|
|
setAutoCloseConns,
|
2023-09-15 23:56:14 +08:00
|
|
|
setHideUnAvailableProxies,
|
2023-09-15 23:43:55 +08:00
|
|
|
setLatencyTestTimeoutDuration,
|
|
|
|
setProxiesOrderingType,
|
|
|
|
setProxiesPreviewType,
|
|
|
|
setUrlForLatencyTest,
|
|
|
|
urlForLatencyTest,
|
|
|
|
} from '~/signals'
|
|
|
|
|
|
|
|
export const ProxiesSettingsModal = () => {
|
2023-09-19 00:35:58 +08:00
|
|
|
const modalID = MODAL.PROXIES_SETTINGS
|
2023-09-15 23:43:55 +08:00
|
|
|
const [t] = useI18n()
|
|
|
|
|
|
|
|
return (
|
2023-09-19 00:35:58 +08:00
|
|
|
<dialog id={modalID} class="modal modal-bottom sm:modal-middle">
|
2023-09-15 23:43:55 +08:00
|
|
|
<div class="modal-box flex flex-col gap-4">
|
2023-09-19 00:35:58 +08:00
|
|
|
<div class="sticky top-0 z-50 flex items-center justify-end">
|
|
|
|
<Button
|
|
|
|
class="btn-circle btn-sm"
|
|
|
|
onClick={() => {
|
|
|
|
const modal = document.querySelector(
|
|
|
|
`#${modalID}`,
|
|
|
|
) as HTMLDialogElement | null
|
|
|
|
|
|
|
|
modal?.close()
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<IconX size={20} />
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
|
2023-09-15 23:43:55 +08:00
|
|
|
<div>
|
|
|
|
<ConfigTitle withDivider>{t('autoCloseConns')}</ConfigTitle>
|
|
|
|
|
|
|
|
<div class="flex w-full justify-center">
|
|
|
|
<input
|
|
|
|
class="toggle"
|
|
|
|
type="checkbox"
|
|
|
|
checked={autoCloseConns()}
|
|
|
|
onChange={(e) => setAutoCloseConns(e.target.checked)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex flex-col">
|
|
|
|
<ConfigTitle withDivider>{t('urlForLatencyTest')}</ConfigTitle>
|
|
|
|
|
|
|
|
<input
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
value={urlForLatencyTest()}
|
|
|
|
onChange={(e) => setUrlForLatencyTest(e.target.value)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<ConfigTitle withDivider>
|
|
|
|
{t('latencyTestTimeoutDuration')} ({t('ms')})
|
|
|
|
</ConfigTitle>
|
|
|
|
|
|
|
|
<input
|
|
|
|
type="number"
|
|
|
|
class="input input-bordered w-full"
|
|
|
|
value={latencyTestTimeoutDuration()}
|
|
|
|
onChange={(e) =>
|
|
|
|
setLatencyTestTimeoutDuration(Number(e.target.value))
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<ConfigTitle withDivider>{t('proxiesSorting')}</ConfigTitle>
|
|
|
|
|
|
|
|
<select
|
|
|
|
class="select select-bordered w-full"
|
|
|
|
value={proxiesOrderingType()}
|
|
|
|
onChange={(e) =>
|
|
|
|
setProxiesOrderingType(e.target.value as PROXIES_ORDERING_TYPE)
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<For each={Object.values(PROXIES_ORDERING_TYPE)}>
|
|
|
|
{(value) => (
|
|
|
|
<option class="flex items-center gap-2" value={value}>
|
|
|
|
{t(value)}
|
|
|
|
</option>
|
|
|
|
)}
|
|
|
|
</For>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
|
2023-09-15 23:56:14 +08:00
|
|
|
<div>
|
|
|
|
<ConfigTitle withDivider>{t('hideUnAvailableProxies')}</ConfigTitle>
|
|
|
|
|
|
|
|
<div class="flex w-full justify-center">
|
|
|
|
<input
|
|
|
|
class="toggle"
|
|
|
|
type="checkbox"
|
|
|
|
checked={hideUnAvailableProxies()}
|
|
|
|
onChange={(e) => setHideUnAvailableProxies(e.target.checked)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-09-15 23:43:55 +08:00
|
|
|
<div>
|
|
|
|
<ConfigTitle withDivider>{t('proxiesPreviewType')}</ConfigTitle>
|
|
|
|
|
|
|
|
<select
|
|
|
|
class="select select-bordered w-full"
|
|
|
|
value={proxiesPreviewType()}
|
|
|
|
onChange={(e) =>
|
|
|
|
setProxiesPreviewType(e.target.value as PROXIES_PREVIEW_TYPE)
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<For each={Object.values(PROXIES_PREVIEW_TYPE)}>
|
|
|
|
{(value) => <option value={value}>{t(value)}</option>}
|
|
|
|
</For>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<form method="dialog" class="modal-backdrop">
|
|
|
|
<button />
|
|
|
|
</form>
|
|
|
|
</dialog>
|
|
|
|
)
|
|
|
|
}
|