mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
refactor(control): move display_status_to_info to utils
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<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<{
|
let { selected, status, className = "" } = $props<{
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import DisplayView from '../components/DisplayView.svelte';
|
import DisplayView from '../components/DisplayView.svelte';
|
||||||
import SplashScreen from './../../../../shared/splash_screen.html?raw';
|
import SplashScreen from './../../../../shared/splash_screen.html?raw';
|
||||||
import PopUp from '../components/PopUp.svelte';
|
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 TextInput from '../components/TextInput.svelte';
|
||||||
import {
|
import {
|
||||||
add_display,
|
add_display,
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
import { ping_ip } from '../ts/api_handler';
|
import { ping_ip } from '../ts/api_handler';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { on_start } from '../ts/main';
|
import { on_start } from '../ts/main';
|
||||||
|
import { display_status_to_info } from '../ts/utils';
|
||||||
|
|
||||||
const ip_regex =
|
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))$/;
|
/^(?:(?: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>
|
</style>
|
||||||
|
|
||||||
<main class="bg-stone-900 h-dvh w-dvw text-stone-200 px-4 py-2 gap-2 grid grid-rows-[3rem_auto]">
|
<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">
|
<div class="w-[calc(100dvw-(8*var(--spacing)))] flex justify-between">
|
||||||
<span class="text-4xl font-bold content-center pl-1"> PLG MuDiCS </span>
|
<span class="text-4xl font-bold content-center pl-1"> PLG MuDiCS </span>
|
||||||
|
|||||||
@@ -87,16 +87,3 @@ export function to_display_status(value: string): DisplayStatus {
|
|||||||
? (value as DisplayStatus)
|
? (value as DisplayStatus)
|
||||||
: null;
|
: 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 '???';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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';
|
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>;
|
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);
|
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 '???';
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user