feat(PingServices): add cache refresh option to fetchPingServices function and update tooltip for manual refresh
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 4m3s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 4m3s
This commit is contained in:
@@ -488,7 +488,8 @@ async function getPingServices(req, res) {
|
|||||||
const cacheKey = cacheSeconds > 0
|
const cacheKey = cacheSeconds > 0
|
||||||
? PING_SERVICES_CACHE_KEY_PREFIX + (viaRouter ? 'router' : 'web') + '_' + String(serverId || '').replace(/[^a-zA-Z0-9.-]/g, '_') + '_' + String(gatewayIp || '').replace(/[^a-zA-Z0-9.]/g, '_')
|
? PING_SERVICES_CACHE_KEY_PREFIX + (viaRouter ? 'router' : 'web') + '_' + String(serverId || '').replace(/[^a-zA-Z0-9.-]/g, '_') + '_' + String(gatewayIp || '').replace(/[^a-zA-Z0-9.]/g, '_')
|
||||||
: null;
|
: null;
|
||||||
if (cacheKey) {
|
const skipCache = ['1', 'true', 'yes'].includes(String(req.query?.refresh || req.query?.nocache || '').toLowerCase());
|
||||||
|
if (cacheKey && !skipCache) {
|
||||||
try {
|
try {
|
||||||
const raw = await readS3TextObject(cacheKey).catch(() => null);
|
const raw = await readS3TextObject(cacheKey).catch(() => null);
|
||||||
if (raw?.body) {
|
if (raw?.body) {
|
||||||
|
|||||||
@@ -304,9 +304,9 @@ function Dashboard() {
|
|||||||
return () => { cancelled = true; };
|
return () => { cancelled = true; };
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function fetchPingServices() {
|
function fetchPingServices(forceRefresh = false) {
|
||||||
setPingLoading(true);
|
setPingLoading(true);
|
||||||
api.get('/ping-services')
|
api.get('/ping-services', { params: forceRefresh ? { refresh: 1 } : {} })
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
const next = data && typeof data === 'object' ? data : null;
|
const next = data && typeof data === 'object' ? data : null;
|
||||||
setPingServices((current) => {
|
setPingServices((current) => {
|
||||||
@@ -370,11 +370,11 @@ function Dashboard() {
|
|||||||
{/* Пинг до сервисов (список из настроек / Пинг сервисов) */}
|
{/* Пинг до сервисов (список из настроек / Пинг сервисов) */}
|
||||||
<div className="d-flex align-items-center justify-content-between mb-2">
|
<div className="d-flex align-items-center justify-content-between mb-2">
|
||||||
<h3 className="mb-0">Пинг сервисов</h3>
|
<h3 className="mb-0">Пинг сервисов</h3>
|
||||||
<Tooltip content="Обновить замеры пинга (история и тренд накапливаются)">
|
<Tooltip content="Принудительно обновить пинг (без учёта кэша), история и тренд накапливаются">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-outline-primary btn-sm"
|
className="btn btn-outline-primary btn-sm"
|
||||||
onClick={() => fetchPingServices()}
|
onClick={() => fetchPingServices(true)}
|
||||||
disabled={pingLoading}
|
disabled={pingLoading}
|
||||||
>
|
>
|
||||||
<IconRefresh className={pingLoading ? 'spin me-1' : 'me-1'} size={16} />
|
<IconRefresh className={pingLoading ? 'spin me-1' : 'me-1'} size={16} />
|
||||||
|
|||||||
Reference in New Issue
Block a user