mirror of
https://github.com/smartyellow/status.git
synced 2024-11-25 12:39:30 +01:00
Svelte dashboard foundation
Signed-off-by: Romein van Buren <romein@vburen.nl>
This commit is contained in:
parent
d691ca7f85
commit
b265f5565a
@ -2,10 +2,11 @@
|
||||
|
||||
const { build: viteBuild } = require('vite');
|
||||
const { svelte } = require('@sveltejs/vite-plugin-svelte');
|
||||
const fs = require('fs').promises;
|
||||
|
||||
module.exports = () => viteBuild({
|
||||
const build = (prefix = '') => viteBuild({
|
||||
root: __dirname + '/gui/dashboard',
|
||||
base: '.',
|
||||
base: `${prefix}/statusdashboard/asset/`,
|
||||
plugins: [ svelte() ],
|
||||
build: {
|
||||
rollupOptions: {
|
||||
@ -19,4 +20,7 @@ module.exports = () => viteBuild({
|
||||
},
|
||||
});
|
||||
|
||||
module.exports();
|
||||
const cleanup = () => fs.rmdir(__dirname + '/gui/dashboard/build');
|
||||
|
||||
module.exports = { build, cleanup };
|
||||
build();
|
17
index.js
17
index.js
@ -2,8 +2,7 @@
|
||||
|
||||
const { fork } = require('child_process');
|
||||
const { processOutage } = require('./lib/processoutage');
|
||||
const buildDashboard = require('./builddashboard');
|
||||
const fs = require('fs').promises;
|
||||
const dashboard = require('./dashboard');
|
||||
|
||||
const guiCluster = 'web service status';
|
||||
const icons = {
|
||||
@ -126,7 +125,8 @@ module.exports = {
|
||||
settings.autotestInterval = 10;
|
||||
}
|
||||
|
||||
await buildDashboard();
|
||||
await dashboard.cleanup();
|
||||
await dashboard.build(server.settings.prefix);
|
||||
return true;
|
||||
},
|
||||
|
||||
@ -535,9 +535,14 @@ module.exports = {
|
||||
{ route: '/statusdashboard',
|
||||
method: 'get',
|
||||
handler: async (req, res) => {
|
||||
res.send(
|
||||
(await fs.readFile(__dirname + '/gui/dashboard/build/index.html')).toString()
|
||||
);
|
||||
res.sendFile(__dirname + '/gui/dashboard/build/index.html');
|
||||
},
|
||||
},
|
||||
|
||||
{ route: '/statusdashboard/asset/:file',
|
||||
method: 'get',
|
||||
handler: async (req, res) => {
|
||||
res.sendFile(__dirname + `/gui/dashboard/build/${req.params[0]}`);
|
||||
},
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user