feat(PingServices): add caching functionality for ping service results and enhance settings modal for cache duration configuration
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m41s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m41s
This commit is contained in:
@@ -26,6 +26,7 @@ export default function SettingsModal({ open, onClose }) {
|
||||
const [pingServicesSource, setPingServicesSource] = useState('web');
|
||||
const [pingServicesServerId, setPingServicesServerId] = useState('');
|
||||
const [pingServicesGatewayIp, setPingServicesGatewayIp] = useState('');
|
||||
const [pingServicesCacheSeconds, setPingServicesCacheSeconds] = useState('');
|
||||
const [serversList, setServersList] = useState([]);
|
||||
|
||||
const routerServersForPing = useMemo(() => {
|
||||
@@ -58,6 +59,7 @@ export default function SettingsModal({ open, onClose }) {
|
||||
setPingServicesSource(String(data?.pingServicesSource || 'web').toLowerCase() === 'router' ? 'router' : 'web');
|
||||
setPingServicesServerId(String(data?.pingServicesServerId || '').trim());
|
||||
setPingServicesGatewayIp(String(data?.pingServicesGatewayIp || '').trim());
|
||||
setPingServicesCacheSeconds(data?.pingServicesCacheSeconds != null ? String(data.pingServicesCacheSeconds) : '');
|
||||
const e = settingsRes?.headers?.etag || settingsRes?.headers?.ETag || '';
|
||||
setEtag(e ? String(e) : '');
|
||||
setServersList(Array.isArray(serversRes?.data) ? serversRes.data : []);
|
||||
@@ -126,6 +128,7 @@ export default function SettingsModal({ open, onClose }) {
|
||||
pingServicesSource: pingServicesSource === 'router' ? 'router' : 'web',
|
||||
pingServicesServerId: String(pingServicesServerId || '').trim(),
|
||||
pingServicesGatewayIp: String(pingServicesGatewayIp || '').trim(),
|
||||
pingServicesCacheSeconds: Math.max(0, parseInt(pingServicesCacheSeconds, 10) || 0),
|
||||
};
|
||||
const payload = {
|
||||
settings: mergedSettings,
|
||||
@@ -265,6 +268,19 @@ export default function SettingsModal({ open, onClose }) {
|
||||
«Веб» — задержка до 8.8.8.8, 1.1.1.1 и др. с сервера. «Роутер» — пинг через выбранный MikroTik (jumphost).
|
||||
</div>
|
||||
</div>
|
||||
<div className="mb-2">
|
||||
<FormField
|
||||
label="Время кеширования пингов (сек)"
|
||||
name="pingServicesCacheSeconds"
|
||||
type="number"
|
||||
value={pingServicesCacheSeconds}
|
||||
onChange={setPingServicesCacheSeconds}
|
||||
placeholder="0"
|
||||
helpText="0 — без кеша. Результаты пинга до Google, Cloudflare и др. будут кешироваться на указанное число секунд."
|
||||
disabled={loading || saving}
|
||||
min={0}
|
||||
/>
|
||||
</div>
|
||||
{pingServicesSource === 'router' && (
|
||||
<div className="row g-2">
|
||||
<div className="col-md-6">
|
||||
|
||||
Reference in New Issue
Block a user