mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 13:37:59 +00:00
Fix circular dependency
Signed-off-by: Romein van Buren <romein@vburen.nl>
This commit is contained in:
parent
276b7e48af
commit
353539fbd4
@ -10,11 +10,6 @@
|
|||||||
let servicesUp = {};
|
let servicesUp = {};
|
||||||
let servicesDown = {};
|
let servicesDown = {};
|
||||||
let servicesUnknown = {};
|
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 loading = true;
|
||||||
let lock = false;
|
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);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Settings />
|
<Settings />
|
||||||
@ -112,14 +74,8 @@
|
|||||||
|
|
||||||
{#if !loading}
|
{#if !loading}
|
||||||
<Tiles services={servicesDown} color="red" value="down" />
|
<Tiles services={servicesDown} color="red" value="down" />
|
||||||
|
<Tiles services={servicesUp} color="green" value="up" />
|
||||||
{#if !clusterKeys?.length}
|
<Tiles services={servicesUnknown} color="grey" value="no data" />
|
||||||
<Tiles services={servicesUp} color="green" value="up" />
|
|
||||||
<Tiles services={servicesUnknown} color="grey" value="no data" />
|
|
||||||
{:else}
|
|
||||||
<Tiles services={servicesInCluster} color="green" value="up" />
|
|
||||||
<Tiles services={servicesInClusterUnknown} color="grey" value="no data" />
|
|
||||||
{/if}
|
|
||||||
{:else}
|
{:else}
|
||||||
loading
|
loading
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -1,21 +1,3 @@
|
|||||||
import { get, writable } from 'svelte/store';
|
|
||||||
import App from './app.svelte';
|
import App from './app.svelte';
|
||||||
|
|
||||||
new App({ target: document.body });
|
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();
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import Modal from './modal.svelte';
|
import Modal from './modal.svelte';
|
||||||
import { settings } from './index';
|
import { settings } from './stores';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
|
|
||||||
|
18
gui/dashboard/stores.js
Normal file
18
gui/dashboard/stores.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { get, writable } from 'svelte/store';
|
||||||
|
|
||||||
|
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();
|
Loading…
Reference in New Issue
Block a user