mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
edit and delete display added
This commit is contained in:
@@ -11,19 +11,44 @@ export const displays: Writable<DisplayGroup[]> = writable<DisplayGroup[]>([{
|
||||
|
||||
|
||||
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())
|
||||
);
|
||||
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) {
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
export function edit_display_data(display_id: string, ip: string, mac: string | null, name: string) {
|
||||
displays.update((display_groups) =>
|
||||
display_groups.map((group) => ({
|
||||
...group,
|
||||
data: group.data.map((display) => {
|
||||
if (display.id !== display_id) return display;
|
||||
return { ...display, ip: ip, mac: mac, name: name };
|
||||
}),
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
export function remove_display(display_id: string) {
|
||||
console.log(display_id);
|
||||
displays.update((displays: DisplayGroup[]) => {
|
||||
displays = displays.map(display_group => ({
|
||||
...display_group,
|
||||
data: display_group.data.filter(display => display.id !== display_id)
|
||||
}));
|
||||
return displays;
|
||||
});
|
||||
|
||||
// TODO remove ID from Files usw.
|
||||
}
|
||||
|
||||
export function all_displays_of_group_selected(display_group: DisplayGroup, current_selected_displays: string[]) {
|
||||
if (display_group.data.length === 0) return false;
|
||||
for (const display of display_group.data) {
|
||||
@@ -139,6 +164,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");
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { FileBox, FileImage, FileVideoCamera, ImagePlay, type X } from "lucide-svelte";
|
||||
import type { Snippet } from "svelte";
|
||||
|
||||
export type SupportedFileType = {
|
||||
display_name:
|
||||
@@ -60,7 +61,7 @@ export type Display = {
|
||||
ip: string;
|
||||
preview_url: string | null;
|
||||
preview_timeout_id: number | null;
|
||||
mac: string|null;
|
||||
mac: string | null;
|
||||
name: string;
|
||||
status: string;
|
||||
}
|
||||
@@ -81,7 +82,8 @@ export type MenuOption = {
|
||||
|
||||
export type PopupContent = {
|
||||
open: boolean;
|
||||
snippet: any;
|
||||
snippet: Snippet<[string]> | null;
|
||||
snippet_arg?: string;
|
||||
title: string;
|
||||
title_class?: string;
|
||||
title_icon?: typeof X | null;
|
||||
|
||||
Reference in New Issue
Block a user