From 28121df1288bd18aa65ecbbe4e7c27812eeed892 Mon Sep 17 00:00:00 2001 From: 2mal3 <56305732+2mal3@users.noreply.github.com> Date: Mon, 5 Jan 2026 21:31:57 +0100 Subject: [PATCH] feat(control): hide unusable power options --- .../frontend/src/routes/ControlView.svelte | 39 ++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/control/frontend/src/routes/ControlView.svelte b/control/frontend/src/routes/ControlView.svelte index 82ce815..fcff2f5 100644 --- a/control/frontend/src/routes/ControlView.svelte +++ b/control/frontend/src/routes/ControlView.svelte @@ -16,7 +16,7 @@ import type { PopupContent } from '$lib/ts/types'; import KeyInput from './KeyInput.svelte'; import { send_keyboard_input, show_blackscreen } from '$lib/ts/api_handler'; - import { run_on_all_selected_displays } from '$lib/ts/stores/displays'; + import { get_display_by_id, run_on_all_selected_displays } from '$lib/ts/stores/displays'; import { selected_display_ids } from '$lib/ts/stores/select'; import TipTapInput from './TipTapInput.svelte'; @@ -51,6 +51,20 @@ window_class: 'size-full' }; }; + + async function all_state(selected_display_ids: string[]): Promise<'on' | 'off' | 'mixed'> { + const selected_displays = await Promise.all( + selected_display_ids.map(async (id) => await get_display_by_id(id)) + ); + const selected_display_states = selected_displays.map((display) => display?.status ?? ''); + if (selected_display_states.every((state) => state === 'app_online')) { + return 'on'; + } else if (selected_display_states.every((state) => state !== 'app_online')) { + return 'off'; + } else { + return 'mixed'; + } + } {#snippet send_keys_popup()} @@ -121,14 +135,21 @@