Skip to content

Commit 2ec08e6

Browse files
author
3aa49ec6bfc910647fa1c5a013e48eef
committed
Some UI enhancements
1 parent c607ebb commit 2ec08e6

File tree

11 files changed

+55
-53
lines changed

11 files changed

+55
-53
lines changed

src/website/src/app.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ select {
2424

2525
button {
2626
@apply bg-blue-500 hover:bg-blue-700 text-white font-bold py-1 px-4 rounded;
27+
}
28+
29+
body {
30+
@apply p-2
2731
}

src/website/src/routes/+layout.svelte

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
<script>
22
import '../app.css';
3+
const iconPath = '/favicon-16x16.png';
4+
const iconPathLg = '/favicon-32x32.png';
35
</script>
46

7+
<svelte:head>
8+
<link rel="icon" type="image/svg" href={iconPath} />
9+
</svelte:head>
10+
11+
<div class="inline-flex p-1" >
12+
<img src={iconPathLg} alt="icon" class="rounded"/>
13+
<h1 class="pl-2">node-teslausb</h1>
14+
</div>
15+
16+
517
<slot />

src/website/src/routes/+page.svelte

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -71,44 +71,44 @@
7171
</script>
7272

7373
<div class="p-5">
74-
75-
<h1>node-teslausb</h1>
76-
77-
<h2>Log Files</h2>
78-
{#if finishedApiCalls == true}
79-
{#if logFiles.length == 0}
80-
<p>No log files found.</p>
74+
<h2>Log Files</h2>
75+
{#if finishedApiCalls == true}
76+
{#if logFiles.length == 0}
77+
<p>No log files found.</p>
78+
{:else}
79+
<ul class="list-disc">
80+
{#each logFiles as logFile}
81+
<li><a href={`/viewLog/${logFile}`}>{logFile}</a></li>
82+
{/each}
83+
</ul>
84+
{/if}
8185
{:else}
82-
<ul class="list-disc">
83-
{#each logFiles as logFile}
84-
<li><a href={`/viewLog/${logFile}`}>{logFile}</a></li>
85-
{/each}
86-
</ul>
86+
<p>Loading...</p>
8787
{/if}
88-
{:else}
89-
<p>Loading...</p>
90-
{/if}
91-
92-
{#if finishedApiCalls}
93-
<h2>Lock Chimes</h2>
94-
{#if lockChimes.length == 0}
95-
<p>No lock chimes found.</p>
96-
{:else}
97-
<select bind:value={selectedUrl}>
98-
{#each lockChimes as lockChime}
99-
<option value={lockChime.url}>{lockChime.title}</option>
100-
{/each}
101-
</select>
102-
<button on:click={installLockChime}>Install</button>
103-
{/if}
104-
<div class="text-sm pt-1">
105-
Visit <a href="https://teslapro.hu/lockchimes/">https://teslapro.hu/lockchimes/</a> to listen to lock sounds before installing.
106-
<p class="pt-2">
107-
<i>Note: currently, installation will happen within 2 minutes if no data is being synced. Otherwise it will run once the sync finishes.</i>
108-
</p>
109-
</div>
110-
{/if}
11188

89+
{#if finishedApiCalls}
90+
<h2>Lock Chimes</h2>
91+
{#if lockChimes.length == 0}
92+
<p>No lock chimes found.</p>
93+
{:else}
94+
<select bind:value={selectedUrl}>
95+
{#each lockChimes as lockChime}
96+
<option value={lockChime.url}>{lockChime.title}</option>
97+
{/each}
98+
</select>
99+
<button on:click={installLockChime}>Install</button>
100+
{/if}
101+
<div class="text-sm pt-1">
102+
Visit <a href="https://teslapro.hu/lockchimes/">https://teslapro.hu/lockchimes/</a> to listen
103+
to lock sounds before installing.
104+
<p class="pt-2">
105+
<i
106+
>Note: currently, installation will happen within 2 minutes if no data is being synced.
107+
Otherwise it will run once the sync finishes.</i
108+
>
109+
</p>
110+
</div>
111+
{/if}
112112
</div>
113113
<!-- <p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
114114

src/website/src/routes/api/lockChimes/+server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ async function readableStreamToBuffer(readable: ReadableStream<Uint8Array>): Pro
6767
const reader = readable.getReader();
6868
const chunks: Uint8Array[] = [];
6969

70+
//eslint-disable-next-line no-constant-condition
7071
while (true) {
7172
const { done, value } = await reader.read();
7273
if (done) break;
@@ -78,8 +79,9 @@ async function readableStreamToBuffer(readable: ReadableStream<Uint8Array>): Pro
7879

7980
export async function GET({ request }) {
8081
const lockChimes = await getLockChimes();
82+
const sortedLockChimes = lockChimes.sort((a, b) => a.title.localeCompare(b.title));
8183
// const logNames = Object.keys(logNameToPathMapping);
82-
return json(lockChimes);
84+
return json(sortedLockChimes);
8385
}
8486

8587
export const POST: RequestHandler = async (event: RequestEvent) => {
39.1 KB
Loading
130 KB
Loading
34.7 KB
Loading

src/website/static/favicon-16x16.png

769 Bytes
Loading

src/website/static/favicon-32x32.png

2.06 KB
Loading

src/worker/configure/index.js

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,6 @@ const setPermissions = (accessLevel = 755, path = '/etc/rc.local') => {
2020
});
2121
};
2222

23-
const executeBashCommand = (command) => {
24-
exec(command, (error, stdout, stderr) => {
25-
if (error) {
26-
console.error(`Error: ${error.message}`);
27-
return;
28-
}
29-
30-
if (stderr) {
31-
console.error(`stderr: ${stderr}`);
32-
return;
33-
}
34-
35-
console.log(`stdout: ${stdout}`);
36-
});
37-
}
38-
3923
const addDtOverlayToBootConfig = () => {
4024
const bootConfigPath = '/boot/config.txt';
4125

src/worker/modules/bash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { exec } from 'child_process';
66
export const executeBashCommand = async (command, outputToConsole = true) => {
77
try {
88
const { stdout, stderr } = await util.promisify(exec)(command);
9-
if (outputToConsole) {
9+
if (stdout && outputToConsole) {
1010
logWithTimestamp(`stdout: ${stdout}`);
1111
}
1212

0 commit comments

Comments
 (0)