Update cycle count regularly
This commit is contained in:
parent
dd23a96d86
commit
b24df8b0d8
4 changed files with 46 additions and 9 deletions
35
ui/src/components/CycleCounter.svelte
Normal file
35
ui/src/components/CycleCounter.svelte
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<script>
|
||||
import { createEventDispatcher, onMount, onDestroy } from 'svelte';
|
||||
|
||||
export let begins = null;
|
||||
export let ends;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let interval;
|
||||
onMount(() => {
|
||||
if (!begins) {
|
||||
interval = setInterval(() => {
|
||||
begins = new Date();
|
||||
if (begins > ends) {
|
||||
dispatch("reload")
|
||||
}
|
||||
}, 15000);
|
||||
begins = new Date();
|
||||
}
|
||||
});
|
||||
onDestroy(() => {
|
||||
if (interval) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
});
|
||||
|
||||
export { className as class };
|
||||
let className = 'text-muted';
|
||||
</script>
|
||||
|
||||
{#if begins && ends}
|
||||
<span class="{className}">
|
||||
(dans {Math.trunc((ends.getTime()-begins.getTime())/5400000)} cycles + {Math.trunc(((ends.getTime()-begins.getTime())%5400000)/60000)} min)
|
||||
</span>
|
||||
{/if}
|
||||
Loading…
Add table
Add a link
Reference in a new issue