Dashboard (WIP)

Signed-off-by: Romein van Buren <romein@vburen.nl>
This commit is contained in:
Romein van Buren 2022-07-08 11:28:44 +02:00
parent 002df5cfb1
commit d691ca7f85
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
7 changed files with 86 additions and 1 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ node_modules
config.custom.js
config.temp.js
package-lock.json
/gui/dashboard/build/

22
builddashboard.js Normal file
View File

@ -0,0 +1,22 @@
'use strict';
const { build: viteBuild } = require('vite');
const { svelte } = require('@sveltejs/vite-plugin-svelte');
module.exports = () => viteBuild({
root: __dirname + '/gui/dashboard',
base: '.',
plugins: [ svelte() ],
build: {
rollupOptions: {
output: {
assetFileNames: '[hash].[ext]',
entryFileNames: '[hash].js',
chunkFileNames: '[hash].js',
},
},
outDir: __dirname + '/gui/dashboard/build',
},
});
module.exports();

1
gui/dashboard/app.svelte Normal file
View File

@ -0,0 +1 @@
<h1>here comes the dashboard</h1>

12
gui/dashboard/index.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Status dashboard</title>
</head>
<body>
<div id="outlet"></div>
<script type="module" src="./index.js"></script>
</body>
</html>

7
gui/dashboard/index.js Normal file
View File

@ -0,0 +1,7 @@
import App from './app.svelte';
const app = new App({
target: document.getElementById('outlet'),
});
export default app;

View File

@ -2,6 +2,8 @@
const { fork } = require('child_process');
const { processOutage } = require('./lib/processoutage');
const buildDashboard = require('./builddashboard');
const fs = require('fs').promises;
const guiCluster = 'web service status';
const icons = {
@ -117,13 +119,14 @@ module.exports = {
},
},
init: ({ server, settings }) => {
init: async ({ server, settings }) => {
settings.autotestInterval = Number(settings.autotestInterval);
if (Number.isNaN(settings.autotestInterval)) {
server.warn('status: settings.autotestInterval is not a number. Using default value 10.');
settings.autotestInterval = 10;
}
await buildDashboard();
return true;
},
@ -529,6 +532,15 @@ module.exports = {
},
},
{ route: '/statusdashboard',
method: 'get',
handler: async (req, res) => {
res.send(
(await fs.readFile(__dirname + '/gui/dashboard/build/index.html')).toString()
);
},
},
],
};

30
package.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "status",
"version": "1.0.0",
"description": "Display status dashboard",
"main": "index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"build": "node builddashboard"
},
"repository": {
"type": "git",
"url": "git+https://github.com/smartyellow/status.git"
},
"keywords": [
"status"
],
"author": "Romein van Buren",
"license": "MIT",
"bugs": {
"url": "https://github.com/smartyellow/status/issues"
},
"homepage": "https://github.com/smartyellow/status#readme",
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.49",
"svelte": "^3.49.0",
"vite": "^2.9.13"
}
}