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 filenames = window.__VMUI_PREDEFINED_DASHBOARDS__;
|
||||
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 () => {
|
||||
|
@ -45,19 +46,20 @@ export const useFetchDashboards = (): {
|
|||
}
|
||||
setIsLoading(false);
|
||||
} else {
|
||||
await fetchLocalDashboards();
|
||||
setError(resp.error);
|
||||
setIsLoading(false);
|
||||
}
|
||||
} catch (e) {
|
||||
setIsLoading(false);
|
||||
if (e instanceof Error) setError(`${e.name}: ${e.message}`);
|
||||
await fetchLocalDashboards();
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (appModeEnable) return;
|
||||
setDashboards([]);
|
||||
fetchLocalDashboards().then(d => d.length && setDashboards((prevDash) => [...d, ...prevDash]));
|
||||
fetchRemoteDashboards();
|
||||
}, [serverUrl]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue