30 lines
1.5 KiB
Svelte
30 lines
1.5 KiB
Svelte
<!-- SPDX-License-Identifier: CPAL-1.0
|
|
- Copyright (c) 2026 Marek Novák. Part of Ianitor, under the Common Public Attribution
|
|
- License 1.0: see LICENSE (its Exhibit A is this file's notice). -->
|
|
<script lang="ts">
|
|
// Handoff §2.4: the engine chip (click 1 of the switch). On the main screen's header on a
|
|
// desktop, in the top bar on a phone (§2.16).
|
|
import { Icon } from "@ianitor/ui";
|
|
import { app } from "../lib/app.svelte";
|
|
|
|
const o = $derived(app.overview);
|
|
const engineName = $derived(o?.engine.running === "caddy" ? "Caddy" : "Pingora");
|
|
const engineLabel = $derived(
|
|
o?.engine.state === "switching" ? "Engine: switching" : `Engine: ${engineName}${o?.engine.state === "stopped" ? ", not answering" : ""}. Change engine`,
|
|
);
|
|
</script>
|
|
|
|
{#if o}
|
|
<button type="button" class="ia-engine" data-engine-chip aria-haspopup="dialog" aria-expanded={app.panel?.kind === "engine"} aria-label={engineLabel}
|
|
onclick={() => (app.panel = app.panel?.kind === "engine" ? null : { kind: "engine" })}>
|
|
{#if o.engine.state === "switching"}<Icon name="clock" /> Engine Switching…{:else}
|
|
<span class="ia-status" data-s={o.engine.state === "stopped" ? "down" : "healthy"}><span class="ia-dot"></span></span>
|
|
<small class="desktop">Engine</small> {engineName}{#if o.engine.running === "caddy"} <small>(fallback)</small>{/if}{/if}
|
|
<Icon name="chevron" />
|
|
</button>
|
|
{/if}
|
|
|
|
<style>
|
|
@media (max-width: 719.98px) { .desktop { display: none; } }
|
|
</style>
|