2022-07-08 12:50:15 +00:00
|
|
|
<script>
|
2022-07-08 15:17:17 +00:00
|
|
|
import { onMount } from 'svelte';
|
2022-07-11 09:20:44 +00:00
|
|
|
import TileRawValue from './tile-rawvalue.svelte';
|
2022-07-08 15:17:17 +00:00
|
|
|
|
2022-07-11 09:20:44 +00:00
|
|
|
let lastUpdated = new Date();
|
|
|
|
let lastUpdatedFormatted = '';
|
|
|
|
let services = {};
|
|
|
|
let loading = true;
|
|
|
|
|
|
|
|
$:console.log(services);
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
const ws = new WebSocket('ws://__SERVER__/statusdashboard/socket');
|
|
|
|
|
|
|
|
ws.onmessage = async evt => {
|
|
|
|
const data = JSON.parse(evt.data || '""');
|
|
|
|
|
|
|
|
switch (data.cmd) {
|
|
|
|
case 'time':
|
|
|
|
lastUpdated = new Date(data.time);
|
|
|
|
lastUpdatedFormatted = lastUpdated.toLocaleTimeString('en-GB', {
|
|
|
|
timeStyle: 'short',
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'data':
|
|
|
|
services = data.data;
|
|
|
|
loading = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2022-07-08 12:50:15 +00:00
|
|
|
</script>
|
|
|
|
|
2022-07-08 15:17:17 +00:00
|
|
|
<div class="center">
|
|
|
|
<div class="ratio">
|
2022-07-11 09:20:44 +00:00
|
|
|
<div class="tiles">
|
|
|
|
<TileRawValue title="Last updated" value={lastUpdatedFormatted} />
|
2022-07-08 15:17:17 +00:00
|
|
|
|
2022-07-11 09:20:44 +00:00
|
|
|
{#if !loading}
|
|
|
|
{#each Object.entries(services) as [ id, service ] (id)}
|
|
|
|
{@const isDown = service.lastBeat.down}
|
|
|
|
<TileRawValue
|
|
|
|
title={service.name.en}
|
|
|
|
value={isDown ? 'down' : 'up'}
|
|
|
|
color={isDown ? 'red' : 'green'}
|
|
|
|
/>
|
|
|
|
{/each}
|
|
|
|
{:else}
|
|
|
|
loading
|
|
|
|
{/if}
|
|
|
|
</div>
|
2022-07-08 15:17:17 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-07-08 12:50:15 +00:00
|
|
|
|
|
|
|
<style>
|
2022-07-09 11:10:08 +00:00
|
|
|
:global(html), :global(body) {
|
2022-07-09 09:12:39 +00:00
|
|
|
--tile-bg: #181818;
|
2022-07-11 09:20:44 +00:00
|
|
|
--red: red;
|
|
|
|
--green: green;
|
|
|
|
--radius: 10px;
|
|
|
|
--cols: 4;
|
|
|
|
--rows: 3;
|
2022-07-08 12:50:15 +00:00
|
|
|
|
|
|
|
background-color: #000;
|
|
|
|
color: #fff;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
2022-07-08 15:17:17 +00:00
|
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
.center {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
width: 100vw;
|
|
|
|
height: 100vh;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ratio {
|
|
|
|
height: 56.25vw;
|
|
|
|
left: 50%;
|
|
|
|
max-height: 100vh;
|
|
|
|
max-width: 177.77778vh;
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
transform: translate(-50%,-50%);
|
|
|
|
width: 100vw;
|
2022-07-08 12:50:15 +00:00
|
|
|
}
|
2022-07-11 09:20:44 +00:00
|
|
|
|
|
|
|
.tiles {
|
|
|
|
margin: 1rem;
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(var(--cols), 1fr);
|
|
|
|
grid-template-rows: repeat(var(--rows), 1fr);
|
|
|
|
gap: 1rem;
|
|
|
|
justify-items: stretch;
|
|
|
|
}
|
2022-07-08 12:50:15 +00:00
|
|
|
</style>
|