From 353539fbd48c7901895a49b3a29acb7fd7d8d50f Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Mon, 11 Jul 2022 15:02:27 +0200 Subject: [PATCH] Fix circular dependency Signed-off-by: Romein van Buren --- gui/dashboard/app.svelte | 48 ++--------------------------------- gui/dashboard/index.js | 18 ------------- gui/dashboard/settings.svelte | 2 +- gui/dashboard/stores.js | 18 +++++++++++++ 4 files changed, 21 insertions(+), 65 deletions(-) create mode 100644 gui/dashboard/stores.js diff --git a/gui/dashboard/app.svelte b/gui/dashboard/app.svelte index 68bc3aa..797c0f8 100644 --- a/gui/dashboard/app.svelte +++ b/gui/dashboard/app.svelte @@ -10,11 +10,6 @@ let servicesUp = {}; let servicesDown = {}; let servicesUnknown = {}; - let servicesInCluster = {}; - let servicesInClusterUnknown = {}; - const clusters = JSON.parse('__CLUSTERS__'); - const clusterKeys = clusters ? Object.keys(clusters) : false; - let currentClusterIndex = -1; let loading = true; let lock = false; @@ -68,39 +63,6 @@ } } }); - - $: if (clusterKeys?.length && !loading) { - function nextCluster() { - lock = true; - currentClusterIndex++; - - if (currentClusterIndex >= clusterKeys.length) { - currentClusterIndex = 0; - } - - const inClusterTemp = {}; - const inClusterTempUnknown = {}; - const currentClusterKey = clusterKeys[currentClusterIndex]; - - for (const [ id, s ] of Object.entries(services)) { - if (s.cluster === currentClusterKey) { - if (!s.lastBeat || !s.lastBeat.date) { - inClusterTempUnknown[id] = s; - } - else { - inClusterTemp[id] = s; - } - } - } - - servicesInCluster = inClusterTemp; - servicesInClusterUnknown = inClusterTempUnknown; - lock = false; - } - - nextCluster(); - setInterval(() => nextCluster, 10_000); - } @@ -112,14 +74,8 @@ {#if !loading} - - {#if !clusterKeys?.length} - - - {:else} - - - {/if} + + {:else} loading {/if} diff --git a/gui/dashboard/index.js b/gui/dashboard/index.js index 68a1638..b4d6b13 100644 --- a/gui/dashboard/index.js +++ b/gui/dashboard/index.js @@ -1,21 +1,3 @@ -import { get, writable } from 'svelte/store'; import App from './app.svelte'; new App({ target: document.body }); - -function createSettingsStore() { - const s = writable(0); - - function updateStorage(val) { - window.localStorage.setItem('statusdash', JSON.stringify(val)); - s.set(val); - } - - return { - subscribe: s.subscribe, - set: val => updateStorage(val), - update: val => updateStorage({ ...get(s), val }), - }; -} - -export const settings = createSettingsStore(); diff --git a/gui/dashboard/settings.svelte b/gui/dashboard/settings.svelte index 6e54a97..3cb06ff 100644 --- a/gui/dashboard/settings.svelte +++ b/gui/dashboard/settings.svelte @@ -1,6 +1,6 @@