better start/stop buttons

This commit is contained in:
Will Greenberg
2025-04-14 15:52:51 -07:00
parent d9c58129ff
commit c4b2c3bbe2
4 changed files with 32 additions and 42 deletions
@@ -8,9 +8,9 @@
let { entries, current_entry }: Props = $props(); let { entries, current_entry }: Props = $props();
</script> </script>
<table> <table class="table-auto border">
<thead> <thead class="p-2">
<tr> <tr class="bg-gray-300 p-2 m-2">
<th scope="col">Name</th> <th scope="col">Name</th>
<th scope="col">Date Started</th> <th scope="col">Date Started</th>
<th scope="col">Date of Last Message</th> <th scope="col">Date of Last Message</th>
@@ -29,13 +29,3 @@
{/each} {/each}
</tbody> </tbody>
</table> </table>
<style>
table {
@apply table-auto border;
}
th {
@apply bg-gray-300 p-2;
}
</style>
@@ -7,29 +7,17 @@
current: boolean; current: boolean;
} = $props(); } = $props();
let row_class = current ? "current" : ""; // bg-gray-100
// bg-green-300
let row_color = current ? "bg-green-300" : "even:bg-gray-100";
</script> </script>
<tr> <tr class="{row_color} border-b">
<th scope='row'>{entry.name}</th> <th class="font-bold p-2 border-b bg-blue-100" scope='row'>{entry.name}</th>
<td>{entry.start_time}</td> <td class="p-2">{entry.start_time}</td>
<td>{entry.last_message_time}</td> <td class="p-2">{entry.last_message_time}</td>
<td>{entry.qmdl_size_bytes}</td> <td class="p-2">{entry.qmdl_size_bytes}</td>
<td><DownloadLink url={entry.getPcapUrl()} text="pcap" /></td> <td class="p-2"><DownloadLink url={entry.getPcapUrl()} text="pcap" /></td>
<td><DownloadLink url={entry.getQmdlUrl()} text="qmdl" /></td> <td class="p-2"><DownloadLink url={entry.getQmdlUrl()} text="qmdl" /></td>
<td><AnalysisStatus analysis_status={entry.analysis_status} entry={entry} /></td> <td class="p-2"><AnalysisStatus analysis_status={entry.analysis_status} entry={entry} /></td>
</tr> </tr>
<style>
th {
@apply font-bold p-2 border-b bg-blue-100;
}
td {
@apply p-2 border-b;
}
tr {
@apply even:bg-gray-100;
}
</style>
@@ -1,23 +1,35 @@
<script lang="ts"> <script lang="ts">
import { req } from "$lib/utils.svelte"; import { req } from "$lib/utils.svelte";
let { currently_recording }: { let { server_is_recording: currently_recording }: {
currently_recording: boolean; server_is_recording: boolean;
} = $props(); } = $props();
let client_set_recording = $state(currently_recording);
let waiting_for_server = $derived(client_set_recording !== currently_recording);
async function start_recording() { async function start_recording() {
await req('POST', '/api/start-recording'); await req('POST', '/api/start-recording');
client_set_recording = true;
} }
async function stop_recording() { async function stop_recording() {
await req('POST', '/api/stop-recording'); await req('POST', '/api/stop-recording');
client_set_recording = false;
} }
const stop_recording_classes = "bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded-full";
const start_recording_classes = "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full";
</script> </script>
<div> <div>
{#if currently_recording} {#if waiting_for_server}
<button onclick={stop_recording}>Stop Recording</button> <button class={currently_recording ? stop_recording_classes : start_recording_classes}>
{currently_recording ? "Stopping..." : "Starting..."}
</button>
{:else if currently_recording}
<button class={stop_recording_classes} onclick={stop_recording}>Stop Recording</button>
{:else} {:else}
<button onclick={start_recording}>Start Recording</button> <button class={start_recording_classes} onclick={start_recording}>Start Recording</button>
{/if} {/if}
</div> </div>
+1 -1
View File
@@ -33,7 +33,7 @@
<div class="p-8"> <div class="p-8">
{#if loaded} {#if loaded}
<RecordingControls currently_recording={recording} /> <RecordingControls server_is_recording={recording} />
<ManifestTable entries={entries} current_entry={current_entry} /> <ManifestTable entries={entries} current_entry={current_entry} />
{:else} {:else}
<p>Loading...</p> <p>Loading...</p>