From 1397de444ba2497569f103fe356a6442a1d0f07b Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Sat, 21 Oct 2023 20:28:35 +0300 Subject: [PATCH 1/2] Use formatPf in main power cards too --- webif/src/routes/MainsPower.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webif/src/routes/MainsPower.svelte b/webif/src/routes/MainsPower.svelte index c716336..61b38a2 100644 --- a/webif/src/routes/MainsPower.svelte +++ b/webif/src/routes/MainsPower.svelte @@ -1,5 +1,6 @@
@@ -11,7 +12,7 @@ {data.apparentPower}VA {/if} {#if data.powerFactor } - pf {data.powerFactor} + pf {formatPf(data.powerFactor)} {/if}
{/each} From 5d7a84cd56f0179142386f72ea82f12d6493af21 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Sat, 21 Oct 2023 20:40:18 +0300 Subject: [PATCH 2/2] Handle routes in the web server --- src/http/server.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/http/server.ts b/src/http/server.ts index 97b8d12..08082f8 100644 --- a/src/http/server.ts +++ b/src/http/server.ts @@ -4,6 +4,7 @@ import { IncomingMessage, RequestListener, ServerResponse } from 'http' import { promises as fsPromisified } from 'fs' const basePath = __dirname + '/../../webif/build' +const webRoutes = ['/', '/configuration'] const mimeTypes = new Map([ ['.html', 'text/html'], @@ -36,9 +37,9 @@ const resolveFilePath = (reqUrl: string | undefined): string => { reqUrl = reqUrl?.substring(0, reqUrl?.indexOf('?')) } - // "Convert" to file path + // "Convert" routes to file path let filePath - if (!reqUrl || reqUrl === '/') { + if (!reqUrl || webRoutes.includes(reqUrl)) { filePath = '/index.html' } else { filePath = reqUrl