Skip to content

Commit

Permalink
Merge pull request #31 from Jalle19/tweaks
Browse files Browse the repository at this point in the history
Power factor formatting, fix navigating directly to /configuration
  • Loading branch information
Jalle19 authored Oct 21, 2023
2 parents 212ad95 + 5d7a84c commit a3cfecb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/http/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>([
['.html', 'text/html'],
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion webif/src/routes/MainsPower.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script>
import { mainSensorDataStore} from '../lib/stores'
import { formatPf } from '../lib/format'
</script>

<div class="mains-power-cards">
Expand All @@ -11,7 +12,7 @@
<span>{data.apparentPower}VA</span>
{/if}
{#if data.powerFactor }
<span>pf {data.powerFactor}</span>
<span>pf {formatPf(data.powerFactor)}</span>
{/if}
</div>
{/each}
Expand Down

0 comments on commit a3cfecb

Please sign in to comment.