From f76337efc769c0b2f399b7275395a00abf03e363 Mon Sep 17 00:00:00 2001 From: 2mal3 <56305732+2mal3@users.noreply.github.com> Date: Tue, 6 Jan 2026 19:41:15 +0100 Subject: [PATCH] feat(control): startup button --- control/frontend/src/lib/ts/api_handler.ts | 10 +++++++++- control/frontend/src/routes/ControlView.svelte | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/control/frontend/src/lib/ts/api_handler.ts b/control/frontend/src/lib/ts/api_handler.ts index e698932..59a44d7 100755 --- a/control/frontend/src/lib/ts/api_handler.ts +++ b/control/frontend/src/lib/ts/api_handler.ts @@ -199,7 +199,7 @@ async function request_control( api_route: string, options: { method: string; headers?: Record; body?: string } ): Promise { - const url = `${window.location.origin}/api${api_route}`; + const url = `http://127.0.0.1:8080/api${api_route}`; return await request(url, options); } @@ -296,3 +296,11 @@ async function run_shell_command(ip: string, command: string): Promise { await run_shell_command(ip, 'shutdown -h now'); } + +export async function startup(mac: string): Promise { + await request_control(`/wakeOnLan`, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ mac_address: mac }) + }); +} diff --git a/control/frontend/src/routes/ControlView.svelte b/control/frontend/src/routes/ControlView.svelte index 5aaaa9e..ce666b1 100644 --- a/control/frontend/src/routes/ControlView.svelte +++ b/control/frontend/src/routes/ControlView.svelte @@ -15,7 +15,7 @@ import PopUp from '$lib/components/PopUp.svelte'; import type { PopupContent } from '$lib/ts/types'; import KeyInput from './KeyInput.svelte'; - import { send_keyboard_input, show_blackscreen, shutdown } from '$lib/ts/api_handler'; + import { send_keyboard_input, show_blackscreen, shutdown, startup } from '$lib/ts/api_handler'; 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'; @@ -84,6 +84,18 @@ db.displays.update(d.id, { status: 'app_offline' }); }, false); } + + async function startup_action() { + await run_on_all_selected_displays( + async (d) => { + if (!d.mac) return; + startup(d.mac); // no await here because we want to be fast + db.displays.update(d.id, { status: 'app_offline' }); + }, + false, + false + ); + } {#snippet ask_shutdonw_popup()} @@ -169,6 +181,7 @@