mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-07-04 01:23:42 -04:00
Update Flag handling
Status now shows readable flag names Updated Power display Added more missing Journal events
This commit is contained in:
@ -2,9 +2,12 @@
|
||||
import { onMount } from "svelte";
|
||||
import { statusStore } from "./stores/Status.store";
|
||||
import connection from "./stores/Connection.store";
|
||||
import { StatusFlags, StatusFlags2 } from "../types/api/enums";
|
||||
import { FocusStatus, StatusFlags, StatusFlags2 } from "../types/api/enums";
|
||||
import type JournalBase from "../types/api/JournalBase";
|
||||
import { slide } from "svelte/transition";
|
||||
import { fly, scale, slide } from "svelte/transition";
|
||||
import { getEnumFlags, getEnumNameFromValue, getEnumNamesFromFlag, getEnumPairsFromValue } from "../types/flags";
|
||||
import type Status from "../types/api/Status";
|
||||
import { HubConnectionState } from "@microsoft/signalr";
|
||||
|
||||
const x: string | null = $state(null);
|
||||
|
||||
@ -16,7 +19,11 @@
|
||||
let alert: JournalBase[] = $state([]);
|
||||
|
||||
onMount(async () => {
|
||||
await $connection.start();
|
||||
|
||||
if ($connection.state === HubConnectionState.Disconnected)
|
||||
{
|
||||
await $connection.start();
|
||||
}
|
||||
|
||||
loading = false;
|
||||
|
||||
@ -36,9 +43,9 @@
|
||||
change.push(last[i] - last[i - 1]);
|
||||
}
|
||||
|
||||
const avg = change.reduce((a, b) => a + b, 0) / change.length;
|
||||
const avg = change.length ? change.reduce((a, b) => a + b, 0) / change.length : 0;
|
||||
const max = 32;
|
||||
if ($statusStore.fuel?.fuelMain) {
|
||||
if ($statusStore.fuel?.fuelMain && avg) {
|
||||
timeToMax = (max - $statusStore.fuel?.fuelMain) / avg;
|
||||
}
|
||||
|
||||
@ -57,9 +64,15 @@
|
||||
});
|
||||
|
||||
if (!$statusStore.pips) {
|
||||
statusStore.set(
|
||||
await (await fetch("http://localhost:5000/api/status")).json()
|
||||
);
|
||||
const value = (await (
|
||||
await fetch("http://localhost:5000/api/status")
|
||||
).json()) as Status;
|
||||
|
||||
console.log(value);
|
||||
|
||||
statusStore.set({
|
||||
...value,
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@ -88,33 +101,33 @@
|
||||
>
|
||||
<div class="power">
|
||||
<div class="sys">
|
||||
{#each [...Array($statusStore?.pips?.sys ?? 0)] as sys}
|
||||
<div class="pip" transition:slide></div>
|
||||
{/each}
|
||||
<div>{$statusStore?.pips?.sys ?? "?"}</div>
|
||||
<div>Sys</div>
|
||||
</div>
|
||||
<div class="eng">
|
||||
{#each [...Array($statusStore?.pips?.eng ?? 0)] as eng}
|
||||
<div class="pip" transition:slide></div>
|
||||
{#each [...Array($statusStore?.pips?.sys ?? 0)].map((_,i) => i) as sys (sys)}
|
||||
<div class="pip" transition:scale|global ></div>
|
||||
{/each}
|
||||
<div>{$statusStore?.pips?.eng ?? "?"}</div>
|
||||
</div>
|
||||
<div class="eng">
|
||||
<div>{$statusStore?.pips?.eng ?? "?"}</div>
|
||||
<div>Eng</div>
|
||||
</div>
|
||||
<div class="wep">
|
||||
{#each [...Array($statusStore?.pips?.wep ?? 0)] as wep}
|
||||
<div class="pip" transition:slide></div>
|
||||
{#each [...Array($statusStore?.pips?.eng ?? 0)].map((_,i) => i) as eng (eng)}
|
||||
<div class="pip" transition:scale|global></div>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="wep">
|
||||
<div>{$statusStore?.pips?.wep ?? "?"}</div>
|
||||
<div>Wep</div>
|
||||
<div>Wep</div>
|
||||
{#each [...Array($statusStore?.pips?.wep ?? 0)].map((_,i) => i) as wep (wep)}
|
||||
<div class="pip" transition:scale|global></div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<span>dest?: {$statusStore?.destination?.name}</span>
|
||||
<span>gui focus: {$statusStore.guiFocus}</span>
|
||||
<span>gui focus: {getEnumNameFromValue(FocusStatus, $statusStore.guiFocus!)}</span>
|
||||
<span>cargo: {$statusStore.cargo}</span>
|
||||
<span>flag1: {$statusStore.flags}</span>
|
||||
<span>flag2: {$statusStore.flags2}</span>
|
||||
<span>flag1: {getEnumNamesFromFlag(StatusFlags, $statusStore.flags!)}</span>
|
||||
<span>flag2: {getEnumNamesFromFlag(StatusFlags2, $statusStore.flags2!)}</span>
|
||||
{:else}
|
||||
<span>No data :(</span>
|
||||
{/if}
|
||||
@ -133,7 +146,7 @@
|
||||
div {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
flex-direction: column-reverse;
|
||||
align-items: center;
|
||||
div.pip {
|
||||
min-width: 2vw;
|
||||
|
Reference in New Issue
Block a user