From f57f9137c7a7e789d9c0d850ee05d6aabfa49061 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Mon, 11 Jul 2022 13:15:39 +0200 Subject: [PATCH] More dashboard fixes Signed-off-by: Romein van Buren --- dashboard/socket.js | 2 +- gui/dashboard/app.css | 1 + gui/dashboard/app.svelte | 15 ++++++++++---- gui/dashboard/tile-rawvalue.svelte | 3 ++- gui/dashboard/tile.svelte | 33 +++++++++++++++++++++++------- gui/dashboard/tiles.svelte | 8 +++++--- index.js | 5 +++++ 7 files changed, 51 insertions(+), 16 deletions(-) diff --git a/dashboard/socket.js b/dashboard/socket.js index 88ed900..3a5b64f 100644 --- a/dashboard/socket.js +++ b/dashboard/socket.js @@ -35,7 +35,7 @@ async function createDashboardSocket(server) { const lastBeat = heartbeats.find(h => h.webservice === s.id); mappedServices[s.id] = { name: s.name, - lastBeat: lastBeat, + lastBeat: lastBeat || {}, }; } diff --git a/gui/dashboard/app.css b/gui/dashboard/app.css index 6c76784..855af77 100644 --- a/gui/dashboard/app.css +++ b/gui/dashboard/app.css @@ -1,6 +1,7 @@ html, body { --body-bg: #000; --tile-bg: #181818; + --grey: grey; --red: red; --green: green; --radius: 10px; diff --git a/gui/dashboard/app.svelte b/gui/dashboard/app.svelte index 036901c..6725b2a 100644 --- a/gui/dashboard/app.svelte +++ b/gui/dashboard/app.svelte @@ -1,5 +1,4 @@ - +
{value}
diff --git a/gui/dashboard/tile.svelte b/gui/dashboard/tile.svelte index a1a15c5..a4c5c82 100644 --- a/gui/dashboard/tile.svelte +++ b/gui/dashboard/tile.svelte @@ -2,22 +2,31 @@ export let title; export let subtitle; export let color; + export let date;
- {#if title || subtitle} + {#if title || subtitle || date}
- {#if title} -
{title}
- {/if} +
+ {#if title} +
{title}
+ {/if} - {#if subtitle} -
{subtitle}
+ {#if subtitle} +
{subtitle}
+ {/if} +
+ + {#if date} +
{date.toLocaleTimeString('en-GB', { + timeStyle: 'short', + })}
{/if}
{/if} - +
diff --git a/gui/dashboard/tiles.svelte b/gui/dashboard/tiles.svelte index c625d87..67d132c 100644 --- a/gui/dashboard/tiles.svelte +++ b/gui/dashboard/tiles.svelte @@ -2,13 +2,15 @@ import TileRawValue from './tile-rawvalue.svelte'; export let services; + export let color; + export let value; {#each Object.entries(services) as [ id, service ] (id)} - {@const isDown = service.lastBeat.down} {/each} diff --git a/index.js b/index.js index 84ae197..b9f4c0c 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,7 @@ const { processOutage } = require('./lib/processoutage'); const buildDashboard = require('./dashboard/build'); const createDashboardSocket = require('./dashboard/socket'); const { minifyHtml } = require('core/strings'); +const { readFile } = require('fs/promises'); const guiCluster = 'web service status'; const icons = { @@ -533,6 +534,9 @@ module.exports = { try { if (!renderedDashboard) { renderedDashboard = await buildDashboard(server); + renderedDashboard.globalCss = await readFile( + __dirname + '/gui/dashboard/app.css' + ); } const dashboardHtml = minifyHtml(` @@ -542,6 +546,7 @@ module.exports = { Web service status dashboard +