mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
parent
a1ee679042
commit
75bcf86a31
1 changed files with 4 additions and 2 deletions
|
@ -26,7 +26,8 @@ export const useFetchDashboards = (): {
|
||||||
const fetchLocalDashboards = async () => {
|
const fetchLocalDashboards = async () => {
|
||||||
const filenames = window.__VMUI_PREDEFINED_DASHBOARDS__;
|
const filenames = window.__VMUI_PREDEFINED_DASHBOARDS__;
|
||||||
if (!filenames?.length) return [];
|
if (!filenames?.length) return [];
|
||||||
return await Promise.all(filenames.map(async f => importModule(f)));
|
const dashboards = await Promise.all(filenames.map(async f => importModule(f)));
|
||||||
|
setDashboards((prevDash) => [...dashboards, ...prevDash]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchRemoteDashboards = async () => {
|
const fetchRemoteDashboards = async () => {
|
||||||
|
@ -45,19 +46,20 @@ export const useFetchDashboards = (): {
|
||||||
}
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
} else {
|
} else {
|
||||||
|
await fetchLocalDashboards();
|
||||||
setError(resp.error);
|
setError(resp.error);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
if (e instanceof Error) setError(`${e.name}: ${e.message}`);
|
if (e instanceof Error) setError(`${e.name}: ${e.message}`);
|
||||||
|
await fetchLocalDashboards();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (appModeEnable) return;
|
if (appModeEnable) return;
|
||||||
setDashboards([]);
|
setDashboards([]);
|
||||||
fetchLocalDashboards().then(d => d.length && setDashboards((prevDash) => [...d, ...prevDash]));
|
|
||||||
fetchRemoteDashboards();
|
fetchRemoteDashboards();
|
||||||
}, [serverUrl]);
|
}, [serverUrl]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue