From f31a118fb6a4817b185f13070c2d2ed0b433c56a Mon Sep 17 00:00:00 2001 From: E44 <129310925+programmer-44@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:18:49 +0100 Subject: [PATCH] add new monitor popup finished --- control/frontend/src/components/PopUp.svelte | 90 ++++++----- .../frontend/src/components/TextInput.svelte | 70 +++++++++ control/frontend/src/routes/+page.svelte | 143 ++++++++++++++++-- control/frontend/src/tailwind.config.js | 20 +++ control/frontend/src/ts/stores/displays.ts | 13 +- control/frontend/src/ts/types.ts | 11 +- 6 files changed, 296 insertions(+), 51 deletions(-) create mode 100644 control/frontend/src/components/TextInput.svelte diff --git a/control/frontend/src/components/PopUp.svelte b/control/frontend/src/components/PopUp.svelte index de93b25..af453cd 100644 --- a/control/frontend/src/components/PopUp.svelte +++ b/control/frontend/src/components/PopUp.svelte @@ -1,51 +1,69 @@ -
+{#if content.open} + +
+ +
e.stopPropagation()} > -
- {title} +
+
+ {#if content.title_icon} + {@const Icon = content.title_icon} + + {/if} +
+ {content.title} +
+
+
+ {#if content.closable} + + {/if} +
-
- {#if title_icon} - {@const Icon = title_icon} - - {/if} +
+ {@render content.snippet()}
-
- {@render children()} -
-
+{/if} diff --git a/control/frontend/src/components/TextInput.svelte b/control/frontend/src/components/TextInput.svelte new file mode 100644 index 0000000..a4a4575 --- /dev/null +++ b/control/frontend/src/components/TextInput.svelte @@ -0,0 +1,70 @@ + + +
+
+
+ {title}: +
+ {#if is_valid_function && focussed} +
+ {current_info} +
+ {/if} +
+ { + focussed = true; + }} + onfocusout={() => { + focussed = false; + }} + class="{bg} focus:{focus_bg} outline-none py-2 px-3 rounded-xl transition-all duration-100 {get_highlighting_string()}" + {placeholder} + /> +
diff --git a/control/frontend/src/routes/+page.svelte b/control/frontend/src/routes/+page.svelte index cbf12b7..c1a0b40 100644 --- a/control/frontend/src/routes/+page.svelte +++ b/control/frontend/src/routes/+page.svelte @@ -1,26 +1,147 @@ +{#snippet add_new_display()} + { + return input.length === 0 || input.length > 50 + ? [false, 'Ungültige Länge'] + : is_display_name_taken(input) + ? [false, 'Name bereits verwendet'] + : [true, 'Gültiger Name']; + }} + /> +
+ { + return ip_regex.test(input) + ? [true, 'Gültige IP-Adresse'] + : [false, 'Ungültige IP-Adresse']; + }} + className="grow" + /> +
+ +
+
+ { + return input === '' + ? [true, 'Keine MAC-Adresse (WOL deaktiviert)'] + : mac_regex.test(input) + ? [true, 'Gültige MAC-Adresse'] + : [false, 'Ungültige MAC-Adresse']; + }} + /> +
+ +
+{/snippet} +
PLG MuDiCS -
@@ -33,7 +154,5 @@
- + diff --git a/control/frontend/src/tailwind.config.js b/control/frontend/src/tailwind.config.js index 5de1f28..d4187ee 100644 --- a/control/frontend/src/tailwind.config.js +++ b/control/frontend/src/tailwind.config.js @@ -61,6 +61,26 @@ module.exports = { 'active:bg-stone-900', 'active:bg-stone-950', + 'focus:bg-stone-50', + 'focus:bg-stone-100', + 'focus:bg-stone-150', + 'focus:bg-stone-200', + 'focus:bg-stone-250', + 'focus:bg-stone-300', + 'focus:bg-stone-350', + 'focus:bg-stone-400', + 'focus:bg-stone-450', + 'focus:bg-stone-500', + 'focus:bg-stone-550', + 'focus:bg-stone-600', + 'focus:bg-stone-650', + 'focus:bg-stone-700', + 'focus:bg-stone-750', + 'focus:bg-stone-800', + 'focus:bg-stone-850', + 'focus:bg-stone-900', + 'focus:bg-stone-950', + 'text-stone-50', 'text-stone-150', 'text-stone-200', diff --git a/control/frontend/src/ts/stores/displays.ts b/control/frontend/src/ts/stores/displays.ts index 2205dfd..39164e1 100644 --- a/control/frontend/src/ts/stores/displays.ts +++ b/control/frontend/src/ts/stores/displays.ts @@ -10,7 +10,14 @@ export const displays: Writable = writable([{ }]); -function add_display(ip: string, mac: string, name: string, status: string) { +export function is_display_name_taken(name: string): boolean { + const display_groups = get(displays); + return display_groups.some(group => + group.data.some(display => display.name.trim().toLowerCase() === name.trim().toLowerCase()) + ); +} + +export function add_display(ip: string, mac: string|null, name: string, status: string) { displays.update((displays: DisplayGroup[]) => { displays[0].data.push({ id: get_uuid(), ip, preview_url: null, preview_timeout_id: null, mac, name, status }); return displays; @@ -123,6 +130,8 @@ export async function update_screenshot(display_id: string, check_type: "first_c + + add_testing_displays(); function add_testing_displays() { // const names = ["Vorne Rechts", "Vorne Links", "Vorne Mitte", "Fernseher Rechts", "Fernseher Bühne", "UIUIUIUIUIUIUISEHRLANGERTEXT DER IST WIRKLICH LANG, DER TEXT, so lang, dass er wirklich nirgendswo hinpasst, nichtmal da oben /\\"]; @@ -130,6 +139,6 @@ function add_testing_displays() { // add_display("127.0.0.1", "00:1A:2B:3C:4D:5E", name, "Offline"); // } - add_display("127.0.0.1", "00:1A:2B:3C:4D:5E", "PC", "Offline"); + // add_display("127.0.0.1", "00:1A:2B:3C:4D:5E", "PC", "Offline"); // add_display("192.168.178.111", "D4:81:D7:C0:DF:3C", "Laptop", "Online"); } \ No newline at end of file diff --git a/control/frontend/src/ts/types.ts b/control/frontend/src/ts/types.ts index 50a7f96..410b398 100644 --- a/control/frontend/src/ts/types.ts +++ b/control/frontend/src/ts/types.ts @@ -60,7 +60,7 @@ export type Display = { ip: string; preview_url: string | null; preview_timeout_id: number | null; - mac: string; + mac: string|null; name: string; status: string; } @@ -77,4 +77,13 @@ export type MenuOption = { class?: string; on_select?: () => void; disabled?: boolean; +} + +export type PopupContent = { + open: boolean; + snippet: any; + title: string; + title_class?: string; + title_icon?: typeof X | null; + closable?: boolean; } \ No newline at end of file