refactor(control): move display_status_to_info to utils

This commit is contained in:
E44
2025-11-21 22:09:30 +01:00
parent 5b891ae64c
commit 408ffc3e22
4 changed files with 18 additions and 17 deletions
@@ -1,5 +1,6 @@
<script lang="ts">
import { display_status_to_info, type DisplayStatus } from "../ts/types";
import { type DisplayStatus } from "../ts/types";
import { display_status_to_info } from "../ts/utils";
let { selected, status, className = "" } = $props<{
selected: boolean;
+3 -2
View File
@@ -6,7 +6,7 @@
import DisplayView from '../components/DisplayView.svelte';
import SplashScreen from './../../../../shared/splash_screen.html?raw';
import PopUp from '../components/PopUp.svelte';
import { display_status_to_info, type PopupContent } from '../ts/types';
import { type PopupContent } from '../ts/types';
import TextInput from '../components/TextInput.svelte';
import {
add_display,
@@ -21,6 +21,7 @@
import { ping_ip } from '../ts/api_handler';
import { onMount } from 'svelte';
import { on_start } from '../ts/main';
import { display_status_to_info } from '../ts/utils';
const ip_regex =
/^(?:(?:10|127)\.(?:25[0-5]|2[0-4]\d|1?\d?\d)\.(?:25[0-5]|2[0-4]\d|1?\d?\d)\.(?:25[0-5]|2[0-4]\d|1?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|1?\d?\d)\.(?:25[0-5]|2[0-4]\d|1?\d?\d)|172\.(?:1[6-9]|2\d|3[0-1])\.(?:25[0-5]|2[0-4]\d|1?\d?\d)\.(?:25[0-5]|2[0-4]\d|1?\d?\d))$/;
@@ -222,7 +223,7 @@
</style>
<main class="bg-stone-900 h-dvh w-dvw text-stone-200 px-4 py-2 gap-2 grid grid-rows-[3rem_auto]">
{@html SplashScreen}
<!-- {@html SplashScreen} -->
<div class="w-[calc(100dvw-(8*var(--spacing)))] flex justify-between">
<span class="text-4xl font-bold content-center pl-1"> PLG MuDiCS </span>
-13
View File
@@ -87,16 +87,3 @@ export function to_display_status(value: string): DisplayStatus {
? (value as DisplayStatus)
: null;
}
export function display_status_to_info(status: DisplayStatus): string {
switch (status) {
case 'app_online':
return 'Online';
case 'app_offline':
return 'Lädt';
case 'host_offline':
return 'Offline';
case null:
return '???';
}
}
+13 -1
View File
@@ -1,4 +1,4 @@
import type { FolderElement, SupportedFileType } from "./types";
import type { DisplayStatus, FolderElement, SupportedFileType } from "./types";
import supported_file_types_json from './../../../../shared/supported_file_types.json';
const supported_file_types: Record<string, SupportedFileType> = supported_file_types_json as Record<string, SupportedFileType>;
@@ -67,3 +67,15 @@ export function is_valid_name(input: string): boolean {
return /^[\p{L}\p{N}\p{M}\-_.+,()[\]{}@!§$%&=~^ ]+$/u.test(input);
}
export function display_status_to_info(status: DisplayStatus): string {
switch (status) {
case 'app_online':
return 'Online';
case 'app_offline':
return 'Lädt';
case 'host_offline':
return 'Offline';
case null:
return '???';
}
}