mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 17:07:08 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ea7ff3ce0 | |||
| a827a3e588 | |||
| 9284a8f72a | |||
| d969c041d0 | |||
| 0a9d3af3eb | |||
| b6150fdab0 | |||
| b6c637649f | |||
| a7582851b4 | |||
| 919bba7c2e | |||
| 64b8fcffe2 |
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { get_shifted_color } from '$lib/ts/stores/ui_behavior';
|
||||
import type { MenuOption } from '$lib/ts/types';
|
||||
import type { Snippet } from 'svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
let {
|
||||
@@ -26,7 +27,7 @@
|
||||
menu_options?: MenuOption[];
|
||||
menu_class?: string;
|
||||
div_class?: string;
|
||||
children?: any;
|
||||
children: Snippet;
|
||||
} = $props();
|
||||
|
||||
let menu_shown = $state(false);
|
||||
@@ -158,14 +159,14 @@
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>
|
||||
{#each menu_options as option}
|
||||
{#each menu_options as option, i (i)}
|
||||
<button
|
||||
disabled={option.disabled ?? false}
|
||||
class="bg-white/15 {option.disabled
|
||||
? 'text-stone-500 cursor-not-allowed'
|
||||
: 'hover:bg-white/35 active:bg-white/60 cursor-pointer ' +
|
||||
option.class} rounded-lg p-2 transition-colors duration-200 select-none flex flex-row gap-2 items-center"
|
||||
onclick={async (e) => {
|
||||
onclick={async () => {
|
||||
if (option.on_select) await option.on_select();
|
||||
close_menu();
|
||||
}}
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
import {
|
||||
dnd_flip_duration_ms,
|
||||
get_selectable_color_classes,
|
||||
is_display_drag,
|
||||
is_group_drag
|
||||
is_display_drag
|
||||
} from '$lib/ts/stores/ui_behavior';
|
||||
import { cubicOut } from 'svelte/easing';
|
||||
import { flip } from 'svelte/animate';
|
||||
import DisplayObject from './DisplayObject.svelte';
|
||||
import {
|
||||
all_displays_of_group_selected,
|
||||
@@ -18,10 +15,9 @@
|
||||
} from '$lib/ts/stores/displays';
|
||||
import DNDGrip from '$lib/components/DNDGrip.svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
import type { Display, DisplayIdGroup, MenuOption } from '$lib/ts/types';
|
||||
import type { DisplayIdGroup, MenuOption } from '$lib/ts/types';
|
||||
import { selected_display_ids } from '$lib/ts/stores/select';
|
||||
import { liveQuery, type Observable } from 'dexie';
|
||||
import { onMount } from 'svelte';
|
||||
import { get_uuid } from '$lib/ts/utils';
|
||||
|
||||
let {
|
||||
@@ -30,7 +26,7 @@
|
||||
close_pinned_display
|
||||
}: {
|
||||
display_id_group: DisplayIdGroup;
|
||||
get_display_menu_options: (display_id: string) => MenuOption[];
|
||||
get_display_menu_options: (display_id: string, display_version: string|undefined) => MenuOption[];
|
||||
close_pinned_display: () => void;
|
||||
} = $props();
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import DNDGrip from '$lib/components/DNDGrip.svelte';
|
||||
import { Menu, Pin, PinOff, VideoOff } from 'lucide-svelte';
|
||||
import OnlineState from './OnlineState.svelte';
|
||||
import type { Display, DisplayIdObject, MenuOption } from '$lib/ts/types';
|
||||
import type { DisplayIdObject, MenuOption } from '$lib/ts/types';
|
||||
import { is_selected, select, selected_display_ids } from '$lib/ts/stores/select';
|
||||
import { get_display_by_id, screenshot_loop } from '$lib/ts/stores/displays';
|
||||
import { change_file_path, current_file_path } from '$lib/ts/stores/files';
|
||||
@@ -20,7 +20,7 @@
|
||||
close_pinned_display
|
||||
}: {
|
||||
display_id_object: DisplayIdObject;
|
||||
get_display_menu_options: (display_id: string) => MenuOption[];
|
||||
get_display_menu_options: (display_id: string, display_version: string|undefined) => MenuOption[];
|
||||
close_pinned_display: () => void;
|
||||
} = $props();
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
click_function={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
menu_options={get_display_menu_options(display_id_object.id)}
|
||||
menu_options={get_display_menu_options(display_id_object.id, $display?.version)}
|
||||
>
|
||||
<Menu />
|
||||
</Button>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
|
||||
let {
|
||||
children,
|
||||
bg = 'bg-stone-750',
|
||||
fg = 'text-stone-200',
|
||||
className = ''
|
||||
}: {
|
||||
children: any;
|
||||
children: Snippet;
|
||||
bg?: string;
|
||||
fg?: string;
|
||||
className?: string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { ArrowRight, Ban, FileIcon, Folder, Play, Triangle, TriangleAlert } from 'lucide-svelte';
|
||||
import { ArrowRight, Ban, FileIcon, Folder, Play, TriangleAlert } from 'lucide-svelte';
|
||||
import {
|
||||
current_height,
|
||||
get_selectable_color_classes,
|
||||
@@ -10,7 +10,6 @@
|
||||
supported_file_type_icon,
|
||||
type Inode,
|
||||
get_file_primary_key,
|
||||
type FileOnDisplay,
|
||||
type FileTransferTask,
|
||||
is_folder
|
||||
} from '$lib/ts/types';
|
||||
@@ -18,7 +17,6 @@
|
||||
import {
|
||||
is_selected,
|
||||
select,
|
||||
selected_display_ids,
|
||||
selected_file_ids
|
||||
} from '$lib/ts/stores/select';
|
||||
import {
|
||||
@@ -32,13 +30,11 @@
|
||||
import { get_file_size_display_string, get_file_type } from '$lib/ts/utils';
|
||||
import { open_file } from '$lib/ts/api_handler';
|
||||
import {
|
||||
get_display_by_id,
|
||||
run_on_all_selected_displays,
|
||||
selected_online_display_ids
|
||||
} from '$lib/ts/stores/displays';
|
||||
import { get_thumbnail_url } from '$lib/ts/stores/thumbnails';
|
||||
import { liveQuery, type Observable } from 'dexie';
|
||||
import { db } from '$lib/ts/database';
|
||||
import { add_sync_recursively, file_transfer_tasks } from '$lib/ts/file_transfer_handler';
|
||||
|
||||
let { file, not_interactable = false }: { file: Inode; not_interactable?: boolean } = $props();
|
||||
@@ -64,8 +60,8 @@
|
||||
file_size = liveQuery(() => get_size_recursively(f));
|
||||
});
|
||||
|
||||
let file_transfer_task: FileTransferTask | null = $derived(
|
||||
$file_transfer_tasks.hasOwnProperty(file_primary_key)
|
||||
let file_transfer_task_list: FileTransferTask[] | null = $derived(
|
||||
Object.hasOwn($file_transfer_tasks, file_primary_key)
|
||||
? $file_transfer_tasks[file_primary_key]
|
||||
: null
|
||||
);
|
||||
@@ -73,7 +69,7 @@
|
||||
let loading_finished = $state(false);
|
||||
let previous_loading_state = $state(false);
|
||||
$effect(() => {
|
||||
const ftt = file_transfer_task;
|
||||
const ftt = file_transfer_task_list;
|
||||
if (previous_loading_state && !ftt) {
|
||||
loading_finished = true;
|
||||
setTimeout(() => (loading_finished = false), 200);
|
||||
@@ -145,7 +141,7 @@
|
||||
|
||||
function get_grayed_out_text_color_strings(is_selected: boolean): string {
|
||||
if (not_interactable) return 'text-stone-400';
|
||||
if (!!file_transfer_task) return 'text-white/20';
|
||||
if (file_transfer_task_list) return 'text-white/20';
|
||||
const color = is_selected ? 'text-stone-600' : 'text-stone-400';
|
||||
const factor = is_selected ? -1 : 1;
|
||||
return `${color} group-hover:${get_shifted_color(color, factor * 100)} group-active:${get_shifted_color(color, factor * 150)}`;
|
||||
@@ -153,14 +149,14 @@
|
||||
|
||||
function get_grayed_out_border_color_strings(is_selected: boolean): string {
|
||||
if (not_interactable) return 'border-stone-550';
|
||||
if (!!file_transfer_task) return 'border-white/10';
|
||||
if (file_transfer_task_list) return 'border-white/10';
|
||||
const color = is_selected ? 'border-stone-450' : 'border-stone-550';
|
||||
const factor = is_selected ? 1 : 1;
|
||||
return `${color} group-hover:${get_shifted_color(color, factor * 100)} group-active:${get_shifted_color(color, factor * 150)}`;
|
||||
}
|
||||
|
||||
function onclick(e: Event) {
|
||||
if (not_interactable || !!file_transfer_task) return;
|
||||
if (not_interactable || file_transfer_task_list) return;
|
||||
select(selected_file_ids, file_primary_key, 'toggle');
|
||||
e.stopPropagation();
|
||||
}
|
||||
@@ -184,7 +180,7 @@
|
||||
|
||||
if (loading_finished) {
|
||||
out += 'bg-stone-500 text-white/30';
|
||||
} else if (!!file_transfer_task) {
|
||||
} else if (file_transfer_task_list) {
|
||||
out += 'bg-stone-700 text-white/30';
|
||||
} else {
|
||||
out += get_selectable_color_classes(
|
||||
@@ -200,7 +196,7 @@
|
||||
|
||||
if (not_interactable) {
|
||||
out += ' rounded-lg';
|
||||
} else if (!!file_transfer_task) {
|
||||
} else if (file_transfer_task_list) {
|
||||
out += ' rounded-r-lg';
|
||||
} else {
|
||||
out += ' rounded-r-lg cursor-pointer';
|
||||
@@ -209,7 +205,16 @@
|
||||
return out;
|
||||
}
|
||||
|
||||
function get_total_percentage(ftt: FileTransferTask): number {
|
||||
function get_total_percentage(ftt_list: FileTransferTask[]): number {
|
||||
let percentage_sum = 0;
|
||||
for (const ftt of ftt_list) {
|
||||
percentage_sum += get_percentage(ftt);
|
||||
}
|
||||
return Math.round(percentage_sum / ftt_list.length);
|
||||
}
|
||||
|
||||
|
||||
function get_percentage(ftt: FileTransferTask): number {
|
||||
let total_percentage: number;
|
||||
if (ftt.data.type === 'upload') {
|
||||
total_percentage = ftt.loading_data.percentage;
|
||||
@@ -316,10 +321,10 @@
|
||||
{onclick}
|
||||
class="{get_main_classes()} relative transition-colors duration-200 gap-4 flex flex-row justify-between group w-full min-w-0"
|
||||
>
|
||||
{#if !!file_transfer_task}
|
||||
{#if !!file_transfer_task_list}
|
||||
<div
|
||||
class="absolute pointer-events-none inset-y-0 left-0 transition-[width] duration-400 bg-stone-600 rounded-r-lg"
|
||||
style={`width: ${get_total_percentage(file_transfer_task)}%;`}
|
||||
style={`width: ${get_total_percentage(file_transfer_task_list)}%;`}
|
||||
></div>
|
||||
{/if}
|
||||
<div class="flex flex-row gap-2 min-w-0 w-full z-10">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { NumberSetting } from '$lib/ts/types';
|
||||
import { ChevronDown, ChevronUp, Minus, Plus } from 'lucide-svelte';
|
||||
import { ChevronDown, ChevronUp } from 'lucide-svelte';
|
||||
import Button from './Button.svelte';
|
||||
|
||||
let {
|
||||
|
||||
@@ -186,15 +186,21 @@ export async function get_thumbnail_blob(ip: string, path_to_file: string): Prom
|
||||
return raw_response.blob;
|
||||
}
|
||||
|
||||
export async function ping_ip(ip: string): Promise<DisplayStatus> {
|
||||
export async function ping_ip(ip: string): Promise<{ status: DisplayStatus; version?: string }> {
|
||||
const raw_response = await request_control(`/ping?ip=${ip}`, { method: 'GET' });
|
||||
if (!raw_response.ok || !raw_response.json) return null;
|
||||
if (!raw_response.ok || !raw_response.json) return { status: null };
|
||||
|
||||
const status = raw_response.json.status;
|
||||
if (typeof status === 'string') {
|
||||
return to_display_status(status);
|
||||
const raw_status = raw_response.json.status;
|
||||
if (typeof raw_status === 'string') {
|
||||
const status = to_display_status(raw_status);
|
||||
const version = raw_response.json.version;
|
||||
if (typeof version === 'string') {
|
||||
return { status, version };
|
||||
} else {
|
||||
return { status };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return { status: null };
|
||||
}
|
||||
|
||||
async function request_display(
|
||||
|
||||
@@ -28,12 +28,23 @@ const START_LOADING_DATA = {
|
||||
seconds_until_finish: -1
|
||||
};
|
||||
|
||||
export const file_transfer_tasks: Writable<Record<string, FileTransferTask>> = writable<
|
||||
Record<string, FileTransferTask>
|
||||
export const file_transfer_tasks: Writable<Record<string, FileTransferTask[]>> = writable<
|
||||
Record<string, FileTransferTask[]>
|
||||
>({});
|
||||
|
||||
let is_processing: boolean = false;
|
||||
|
||||
function add_file_transfer_task(file_primary_key: string, new_task: FileTransferTask) {
|
||||
file_transfer_tasks.update((tasks) => {
|
||||
if (Object.hasOwn(tasks, file_primary_key)) {
|
||||
tasks[file_primary_key].push(new_task);
|
||||
return tasks;
|
||||
} else {
|
||||
return { ...tasks, [file_primary_key]: [new_task] };
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export async function add_upload(
|
||||
file_list: FileList,
|
||||
selected_display_ids: string[],
|
||||
@@ -59,7 +70,7 @@ export async function add_upload(
|
||||
};
|
||||
const file_primary_key = get_file_primary_key(db_file);
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(file_transfer_tasks, file_primary_key))
|
||||
if (Object.hasOwn(file_transfer_tasks, file_primary_key))
|
||||
return show_already_in_tasks_error(db_file, 'upload'); // file is already in task
|
||||
|
||||
await db.files.put(db_file);
|
||||
@@ -89,10 +100,7 @@ export async function add_upload(
|
||||
loading_data: START_LOADING_DATA,
|
||||
bytes_total: file.size
|
||||
};
|
||||
file_transfer_tasks.update((tasks) => ({
|
||||
...tasks,
|
||||
[file_primary_key]: new_task
|
||||
}));
|
||||
add_file_transfer_task(file_primary_key, new_task);
|
||||
});
|
||||
|
||||
await Promise.all(upload_task_promises);
|
||||
@@ -146,10 +154,7 @@ export async function add_sync_recursively(
|
||||
bytes_total: file_data.file.size
|
||||
};
|
||||
|
||||
file_transfer_tasks.update((tasks) => ({
|
||||
...tasks,
|
||||
[selected_file_id]: new_task
|
||||
}));
|
||||
add_file_transfer_task(selected_file_id, new_task);
|
||||
|
||||
const display_ids_without_file = file_data.short_displays_without_file.map((d) => d.id);
|
||||
const new_fods: FileOnDisplay[] = display_ids_without_file.map((display_id) => ({
|
||||
@@ -230,15 +235,19 @@ function generate_valid_file_name(original_file_name: string, used_file_names: s
|
||||
return name;
|
||||
}
|
||||
|
||||
async function upload(file_primary_key: string, task: FileTransferTask): Promise<void> {
|
||||
async function upload(
|
||||
file_primary_key: string,
|
||||
task: FileTransferTask,
|
||||
list_index: number
|
||||
): Promise<void> {
|
||||
const task_data = task.data;
|
||||
if (task_data.type !== 'upload' || !task_data.file)
|
||||
return console.warn('Task cancelled: wrong task type:', task);
|
||||
|
||||
await upload_file_via_xhr(file_primary_key, task, task_data.file);
|
||||
await upload_file_via_xhr(file_primary_key, list_index, task, task_data.file);
|
||||
}
|
||||
|
||||
export async function sync(file_primary_key: string, task: FileTransferTask) {
|
||||
export async function sync(file_primary_key: string, task: FileTransferTask, list_index: number) {
|
||||
if (task.data.type !== 'sync') return console.warn('Task cancelled: wrong task type:', task);
|
||||
|
||||
const hasOPFS =
|
||||
@@ -273,18 +282,24 @@ export async function sync(file_primary_key: string, task: FileTransferTask) {
|
||||
if (done) break;
|
||||
if (!value) continue;
|
||||
|
||||
update_current_loading_data(file_primary_key, value.byteLength, start_time);
|
||||
update_current_loading_data(file_primary_key, list_index, value.byteLength, start_time);
|
||||
await writable.write(value);
|
||||
}
|
||||
await writable.close();
|
||||
|
||||
finish_loading_data(file_primary_key);
|
||||
finish_loading_data(file_primary_key, list_index);
|
||||
|
||||
// 02 - send downloaded file to every destination_display
|
||||
const temp_file = await file_handle.getFile();
|
||||
|
||||
for (const current_short_display of task.data.destination_display_data) {
|
||||
await upload_file_via_xhr(file_primary_key, task, temp_file, current_short_display.display);
|
||||
await upload_file_via_xhr(
|
||||
file_primary_key,
|
||||
list_index,
|
||||
task,
|
||||
temp_file,
|
||||
current_short_display.display
|
||||
);
|
||||
}
|
||||
|
||||
await dir.removeEntry(temp_name);
|
||||
@@ -292,7 +307,11 @@ export async function sync(file_primary_key: string, task: FileTransferTask) {
|
||||
// open file, if required
|
||||
if (task.data.open_file_afterwards_on_display_ids.length !== 0) {
|
||||
const path_to_file = task.path + task.file_name;
|
||||
await run_on_all_selected_displays((d) => open_file(d.ip, path_to_file), true, task.data.open_file_afterwards_on_display_ids);
|
||||
await run_on_all_selected_displays(
|
||||
(d) => open_file(d.ip, path_to_file),
|
||||
true,
|
||||
task.data.open_file_afterwards_on_display_ids
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
show_general_error(file_primary_key, task, String(e));
|
||||
@@ -336,24 +355,37 @@ async function start_task_loop() {
|
||||
while (Object.keys(get(file_transfer_tasks)).length > 0) {
|
||||
const tasks = get(file_transfer_tasks);
|
||||
const current_file_id = Object.keys(tasks)[0];
|
||||
const current_task = tasks[current_file_id];
|
||||
if (current_task.data.type === 'upload') {
|
||||
await upload(current_file_id, current_task);
|
||||
} else if (current_task.data.type === 'sync') {
|
||||
await sync(current_file_id, current_task);
|
||||
}
|
||||
const current_task_list = tasks[current_file_id];
|
||||
|
||||
file_transfer_tasks.update((all_tasks) => {
|
||||
const next = { ...all_tasks };
|
||||
delete next[current_file_id];
|
||||
return next;
|
||||
});
|
||||
for (const [list_index, current_task] of current_task_list.entries()) {
|
||||
if (current_task.data.type === 'upload') {
|
||||
await upload(current_file_id, current_task, list_index);
|
||||
} else if (current_task.data.type === 'sync') {
|
||||
await sync(current_file_id, current_task, list_index);
|
||||
}
|
||||
delete_current_task_if_needed(current_file_id);
|
||||
}
|
||||
}
|
||||
is_processing = false;
|
||||
}
|
||||
|
||||
function delete_current_task_if_needed(current_file_id: string) {
|
||||
file_transfer_tasks.update((all_tasks) => {
|
||||
const next = { ...all_tasks };
|
||||
const current_tasks = next[current_file_id];
|
||||
if (current_tasks.length !== 1) {
|
||||
if (current_tasks.find((t) => t.loading_data.percentage !== 100)) {
|
||||
return next; // not all tasks are finished -> do nothing
|
||||
}
|
||||
}
|
||||
delete next[current_file_id];
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
async function upload_file_via_xhr(
|
||||
file_primary_key: string,
|
||||
list_index: number,
|
||||
task: FileTransferTask,
|
||||
current_file: File,
|
||||
destination_short_display: ShortDisplay | null = null
|
||||
@@ -373,6 +405,7 @@ async function upload_file_via_xhr(
|
||||
const apply = async () => {
|
||||
update_current_loading_data(
|
||||
file_primary_key,
|
||||
list_index,
|
||||
e.loaded,
|
||||
start_time,
|
||||
destination_short_display ? destination_short_display.id : null
|
||||
@@ -392,6 +425,7 @@ async function upload_file_via_xhr(
|
||||
// set loading_data to 100%
|
||||
finish_loading_data(
|
||||
file_primary_key,
|
||||
list_index,
|
||||
destination_short_display ? destination_short_display.id : null
|
||||
);
|
||||
// Generate Thumbnail if not done already
|
||||
@@ -416,38 +450,43 @@ async function upload_file_via_xhr(
|
||||
|
||||
function finish_loading_data(
|
||||
file_primary_key: string,
|
||||
list_index: number,
|
||||
destination_display_id: string | null = null
|
||||
) {
|
||||
file_transfer_tasks.update((tasks) => {
|
||||
const task = tasks[file_primary_key];
|
||||
const current_loading_data = {
|
||||
percentage: 100,
|
||||
bytes_per_second: 0,
|
||||
seconds_until_finish: 0
|
||||
};
|
||||
const new_task_list = tasks[file_primary_key].map((task, index) =>
|
||||
index === list_index
|
||||
? get_updated_task(current_loading_data, destination_display_id, task)
|
||||
: task
|
||||
);
|
||||
|
||||
return {
|
||||
...tasks,
|
||||
[file_primary_key]: get_updated_task(current_loading_data, destination_display_id, task)
|
||||
[file_primary_key]: new_task_list
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function update_current_loading_data(
|
||||
file_primary_key: string,
|
||||
list_index: number,
|
||||
current_bytes: number,
|
||||
start_time: Date,
|
||||
destination_display_id: string | null = null
|
||||
) {
|
||||
file_transfer_tasks.update((tasks) => {
|
||||
const task = tasks[file_primary_key];
|
||||
const task = tasks[file_primary_key][list_index];
|
||||
if (!task) return tasks;
|
||||
|
||||
const current_percentage = Math.min(
|
||||
task.bytes_total > 0 ? Math.round((current_bytes / task.bytes_total) * 100) : 1,
|
||||
99
|
||||
);
|
||||
|
||||
const prognosed_data = get_prognosed_data(start_time, current_bytes, task.bytes_total);
|
||||
|
||||
const current_loading_data: FileLoadingData = {
|
||||
@@ -456,9 +495,15 @@ function update_current_loading_data(
|
||||
seconds_until_finish: prognosed_data.seconds_until_finish
|
||||
};
|
||||
|
||||
const new_task_list = tasks[file_primary_key].map((task, index) =>
|
||||
index === list_index
|
||||
? get_updated_task(current_loading_data, destination_display_id, task)
|
||||
: task
|
||||
);
|
||||
|
||||
return {
|
||||
...tasks,
|
||||
[file_primary_key]: get_updated_task(current_loading_data, destination_display_id, task)
|
||||
[file_primary_key]: new_task_list
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,22 +40,26 @@ async function update_all_display_status(only_loading_displays: boolean) {
|
||||
}
|
||||
|
||||
export async function update_display_status(display: Display): Promise<DisplayStatus> {
|
||||
const new_status = await ping_ip(display.ip);
|
||||
if (new_status === null && display.status !== null) return null;
|
||||
if (new_status !== display.status) {
|
||||
const resp = await ping_ip(display.ip);
|
||||
if (resp.version && display.version !== resp.version) {
|
||||
display.version = resp.version;
|
||||
await db.displays.put(display); // save
|
||||
}
|
||||
if (resp.status === null && display.status !== null) return null;
|
||||
if (resp.status !== display.status) {
|
||||
// status change
|
||||
if (new_status === 'app_offline') {
|
||||
if (resp.status === 'app_offline') {
|
||||
loading_display_ids.push(display.id);
|
||||
} else {
|
||||
remove_display_from_loading_displays(display.id);
|
||||
if (new_status === 'app_online') {
|
||||
if (resp.status === 'app_online') {
|
||||
on_display_start(display);
|
||||
}
|
||||
}
|
||||
display.status = new_status;
|
||||
display.status = resp.status;
|
||||
await db.displays.put(display); // save
|
||||
}
|
||||
return new_status;
|
||||
return resp.status;
|
||||
}
|
||||
|
||||
export function remove_display_from_loading_displays(display_id: string) {
|
||||
|
||||
@@ -96,6 +96,7 @@ export type Display = {
|
||||
group_id: string;
|
||||
name: string;
|
||||
status: DisplayStatus;
|
||||
version?: string;
|
||||
};
|
||||
|
||||
export type DisplayGroup = {
|
||||
@@ -127,8 +128,8 @@ export type MenuOption = {
|
||||
|
||||
export type PopupContent = {
|
||||
open: boolean;
|
||||
snippet: Snippet<[any]> | Snippet<[]> | Snippet | null | any;
|
||||
snippet_arg?: any;
|
||||
snippet: Snippet<[string]> | Snippet<[]> | null;
|
||||
snippet_arg?: string;
|
||||
title?: string;
|
||||
title_class?: string;
|
||||
title_icon?: typeof X | null;
|
||||
|
||||
@@ -100,7 +100,7 @@ export function display_status_to_info(status: DisplayStatus): string {
|
||||
return 'Lädt';
|
||||
case 'host_offline':
|
||||
return 'Offline';
|
||||
case null:
|
||||
default:
|
||||
return '???';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
</svelte:head>
|
||||
|
||||
{#if !dev}
|
||||
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
||||
{@html versionSplashScreen}
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
Trash2,
|
||||
Menu,
|
||||
ChevronDown,
|
||||
icons,
|
||||
SquareCheckBig,
|
||||
Square,
|
||||
X,
|
||||
Info
|
||||
} from 'lucide-svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
@@ -37,6 +35,7 @@
|
||||
import { preview_settings } from '$lib/ts/stores/ui_behavior';
|
||||
import NumberSettingInput from '$lib/components/NumberSettingInput.svelte';
|
||||
import { db } from '$lib/ts/database';
|
||||
import version from './../../../../shared/version.txt?raw';
|
||||
|
||||
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))$/;
|
||||
@@ -72,13 +71,13 @@
|
||||
const mac = text_inputs_valid.mac.value === '' ? null : text_inputs_valid.mac.value;
|
||||
const name = text_inputs_valid.name.value;
|
||||
let display: Display | null = null;
|
||||
if (!!existing_display_id) {
|
||||
if (existing_display_id) {
|
||||
display = await edit_display_data(existing_display_id, ip, mac, name);
|
||||
} else {
|
||||
const status = await ping_ip(text_inputs_valid.ip.value);
|
||||
display = await add_display(ip, mac, name, status);
|
||||
}
|
||||
if (!!display) {
|
||||
if (display) {
|
||||
await update_display_status(display);
|
||||
}
|
||||
}
|
||||
@@ -178,8 +177,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
|
||||
{#snippet about_popup(_: string)}
|
||||
<div class="px-2">
|
||||
<p>
|
||||
{version}
|
||||
</p>
|
||||
<h3 class="text-lg font-bold mt-4">Entwickler</h3>
|
||||
<p>
|
||||
<a target="_blank" class="link" href="https://github.com/programmer-44">E44</a>,
|
||||
@@ -249,7 +252,7 @@
|
||||
title="Anzeigename"
|
||||
placeholder="z.B. Beamer vorne links"
|
||||
is_valid_function={async (input: string) => {
|
||||
if (!!existing_display_id) {
|
||||
if (existing_display_id) {
|
||||
if (input === (await get_display_by_id(existing_display_id))?.name)
|
||||
return [true, 'Gültiger Name'];
|
||||
}
|
||||
@@ -313,7 +316,7 @@
|
||||
{/if}
|
||||
<Button
|
||||
disabled={!all_text_inputs_valid()}
|
||||
className="{!!existing_display_id ? 'px-4' : 'pl-3 pr-4 gap-2'} font-bold"
|
||||
className="{existing_display_id ? 'px-4' : 'pl-3 pr-4 gap-2'} font-bold"
|
||||
bg="bg-stone-650"
|
||||
click_function={async () => {
|
||||
await finalize_add_edit_display(existing_display_id);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
show_blackscreen,
|
||||
shutdown,
|
||||
startup,
|
||||
show_html,
|
||||
open_website
|
||||
} from '$lib/ts/api_handler';
|
||||
import {
|
||||
@@ -135,7 +134,7 @@
|
||||
|
||||
function validate_website_url(url: string): [boolean, string] {
|
||||
if (url === '') return [true, ''];
|
||||
const regex = /^https?:\/\/[\w\-]+(\.[\w\-]+)+([\w\-\._~:/?#\[\]@!$&'\(\)\*\+,;=.])*/;
|
||||
const regex = /^https?:\/\/[\w-]+(\.[\w-]+)+([\w\-._~:/?#[\]@!$&'()*+,;=.])*/;
|
||||
if (regex.test(url)) {
|
||||
return [true, ''];
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { fade, scale } from 'svelte/transition';
|
||||
import { fade } from 'svelte/transition';
|
||||
import {
|
||||
all_displays_of_group_selected,
|
||||
get_display_by_id,
|
||||
@@ -21,16 +21,13 @@
|
||||
import { type Display, type DisplayGroup, type MenuOption } from '$lib/ts/types';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import OnlineState from '../lib/components/OnlineState.svelte';
|
||||
import { Menu, Pencil, PinOff, Trash2, VideoOff, ZoomIn, ZoomOut } from 'lucide-svelte';
|
||||
import { History, Menu, Pencil, PinOff, Trash2, VideoOff, ZoomIn, ZoomOut } from 'lucide-svelte';
|
||||
import { selected_display_ids } from '$lib/ts/stores/select';
|
||||
import { dragHandleZone } from 'svelte-dnd-action';
|
||||
import DisplayGroupObject from '../lib/components/DisplayGroupObject.svelte';
|
||||
import { Pane, Splitpanes } from 'svelte-splitpanes';
|
||||
import { Pane, Splitpanes, type IPaneSizingEvent } from 'svelte-splitpanes';
|
||||
import HighlightedText from '$lib/components/HighlightedText.svelte';
|
||||
import { liveQuery, type Observable } from 'dexie';
|
||||
import { onMount } from 'svelte';
|
||||
import { flip } from 'svelte/animate';
|
||||
import { cubicOut } from 'svelte/easing';
|
||||
|
||||
let {
|
||||
handle_display_deletion,
|
||||
@@ -71,8 +68,13 @@
|
||||
pinned_pane_size = 0;
|
||||
}
|
||||
|
||||
function get_display_menu_options(display_id: string): MenuOption[] {
|
||||
function get_display_menu_options(display_id: string, display_version: string|undefined): MenuOption[] {
|
||||
return [
|
||||
{
|
||||
icon: History,
|
||||
name: display_version ?? "Version unbekannt",
|
||||
disabled: true,
|
||||
},
|
||||
{
|
||||
icon: Pencil,
|
||||
name: 'Bildschirm bearbeiten',
|
||||
@@ -110,7 +112,7 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
function handle_splitpane_resize(e: any) {
|
||||
function handle_splitpane_resize(e: CustomEvent<IPaneSizingEvent[]>) {
|
||||
if (e.detail[0].size === 0) {
|
||||
$pinned_display_id = null;
|
||||
pinned_pane_size = last_pinned_pane_size;
|
||||
@@ -168,7 +170,7 @@
|
||||
click_function={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
menu_options={get_display_menu_options($pinned_display_id)}
|
||||
menu_options={get_display_menu_options($pinned_display_id, $pinned_display?.version)}
|
||||
>
|
||||
<Menu />
|
||||
</Button>
|
||||
@@ -225,7 +227,7 @@
|
||||
title="Bildschirme größer darstellen"
|
||||
className="aspect-square p-1.5! pr-1! rounded-r-none"
|
||||
bg="bg-stone-600"
|
||||
disabled={!Boolean(next_height_step_size('display', $current_height, 1))}
|
||||
disabled={!next_height_step_size('display', $current_height, 1)}
|
||||
click_function={() => {
|
||||
change_height('display', 1);
|
||||
}}
|
||||
@@ -236,7 +238,7 @@
|
||||
title="Bildschirme kleiner darstellen"
|
||||
className="aspect-square p-1.5! pl-1! rounded-l-none"
|
||||
bg="bg-stone-600"
|
||||
disabled={!Boolean(next_height_step_size('display', $current_height, -1))}
|
||||
disabled={!next_height_step_size('display', $current_height, -1)}
|
||||
click_function={() => {
|
||||
change_height('display', -1);
|
||||
}}
|
||||
|
||||
@@ -59,9 +59,10 @@
|
||||
$effect(() => {
|
||||
const s = $selected_file_ids;
|
||||
one_file_selected = liveQuery(async () => {
|
||||
if (s.length !== 1) return false
|
||||
const inode = await get_file_by_id(s[0]);
|
||||
if (!inode) return false;
|
||||
return s.length === 1 && !is_folder(inode);
|
||||
return !is_folder(inode);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,7 +79,7 @@
|
||||
const results = await Promise.all(selected_file_ids.map((id) => get_file_by_id(id)));
|
||||
return results.filter((element) => element !== null);
|
||||
} catch (e: unknown) {
|
||||
console.error('Error on generating selected_files');
|
||||
console.error('Error on generating selected_files', e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -172,7 +173,7 @@
|
||||
> existiert nicht auf {display_names_where_path_does_not_exist.length === 1
|
||||
? 'dem Bildschirm'
|
||||
: 'den Bildschirmen'}
|
||||
{#each display_names_where_path_does_not_exist as display_name, i}
|
||||
{#each display_names_where_path_does_not_exist as display_name, i (i)}
|
||||
{#if i !== 0}
|
||||
,
|
||||
{/if}
|
||||
@@ -247,7 +248,7 @@
|
||||
>{`${$selected_file_ids.length === 1 ? 'Folgendes Objekt' : `Folgende ${$selected_file_ids.length} Objekte`} löschen? (Wiederherstellung nicht möglich)`}</span
|
||||
>
|
||||
<div class="flex flex-col gap-2 overflow-y-auto h-full min-h-0 grow-0">
|
||||
{#each $selected_files || [] as file}
|
||||
{#each $selected_files || [] as file, i (i)}
|
||||
<InodeElement {file} not_interactable />
|
||||
{/each}
|
||||
</div>
|
||||
@@ -294,7 +295,7 @@
|
||||
title="Dateien größer darstellen"
|
||||
className="aspect-square p-1.5! pr-1! rounded-r-none"
|
||||
bg="bg-stone-600"
|
||||
disabled={!Boolean(next_height_step_size('file', $current_height, 1))}
|
||||
disabled={!next_height_step_size('file', $current_height, 1)}
|
||||
click_function={() => {
|
||||
change_height('file', 1);
|
||||
}}
|
||||
@@ -305,7 +306,7 @@
|
||||
title="Dateien kleiner darstellen"
|
||||
className="aspect-square p-1.5! pl-1! rounded-l-none"
|
||||
bg="bg-stone-600"
|
||||
disabled={!Boolean(next_height_step_size('file', $current_height, -1))}
|
||||
disabled={!next_height_step_size('file', $current_height, -1)}
|
||||
click_function={() => {
|
||||
change_height('file', -1);
|
||||
}}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { fade } from 'svelte/transition';
|
||||
import { run_on_all_selected_displays } from '$lib/ts/stores/displays';
|
||||
import { send_keyboard_input } from '$lib/ts/api_handler';
|
||||
import { ArrowDownToLine, ArrowUpFromLine, Grid2x2, Grid2X2, Option } from 'lucide-svelte';
|
||||
import { ArrowDownToLine, ArrowUpFromLine, Grid2x2, Option } from 'lucide-svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
import { onDestroy } from 'svelte';
|
||||
import { add_to_keyboard_queue } from '$lib/ts/utils';
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
Highlighter,
|
||||
Italic,
|
||||
PaintBucket,
|
||||
QrCode,
|
||||
Strikethrough
|
||||
} from 'lucide-svelte';
|
||||
import Button from '$lib/components/Button.svelte';
|
||||
@@ -149,7 +148,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
{#each Object.values(color_states) as color_state}
|
||||
{#each Object.values(color_states) as color_state, i (i)}
|
||||
<input type="color" bind:this={color_state.el} bind:value={color_state.value} class="hidden" />
|
||||
{/each}
|
||||
|
||||
@@ -163,9 +162,9 @@
|
||||
|
||||
<div class="flex flex-col gap-2 justify-between">
|
||||
<div class="flex flex-col gap-2">
|
||||
{#each text_edit_options as edit_row}
|
||||
{#each text_edit_options as edit_row, i (i)}
|
||||
<div class="flex flex-row gap-1">
|
||||
{#each edit_row as option}
|
||||
{#each edit_row as option, j (j)}
|
||||
<div class="flex flex-row">
|
||||
<button
|
||||
title={option.title}
|
||||
|
||||
+26
-3
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -83,17 +84,39 @@ func pingRoute(ctx echo.Context) error {
|
||||
return ctx.JSON(http.StatusOK, PingResponse{Status: "host_offline"})
|
||||
}
|
||||
|
||||
conn, err := net.DialTimeout("tcp", ip+":1323", 5*time.Second)
|
||||
client := http.Client{
|
||||
Timeout: 5 * time.Second,
|
||||
}
|
||||
|
||||
resp, err := client.Get("http://" + ip + ":1323/api/ping")
|
||||
if err != nil {
|
||||
return ctx.JSON(http.StatusOK, PingResponse{Status: "app_offline"})
|
||||
}
|
||||
conn.Close()
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return ctx.JSON(http.StatusOK, PingResponse{Status: "app_offline"})
|
||||
}
|
||||
|
||||
return ctx.JSON(http.StatusOK, PingResponse{Status: "app_online"})
|
||||
var appPing AppPingResponse
|
||||
if err := json.NewDecoder(resp.Body).Decode(&appPing); err != nil {
|
||||
return ctx.JSON(http.StatusOK, PingResponse{
|
||||
Status: "app_offline",
|
||||
})
|
||||
}
|
||||
|
||||
return ctx.JSON(http.StatusOK, PingResponse{
|
||||
Status: "app_online",
|
||||
Version: appPing.Version,
|
||||
})
|
||||
}
|
||||
|
||||
type AppPingResponse struct {
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
type PingResponse struct {
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func TakeScreenshot() (string, error) {
|
||||
tempFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("screenshot_%d.png", time.Now().Unix()))
|
||||
tempFilePath := filepath.Join(os.TempDir(), fmt.Sprintf("screenshot_%d.jpg", time.Now().Unix()))
|
||||
|
||||
cmds := []*exec.Cmd{
|
||||
exec.Command("gnome-screenshot", "-f", tempFilePath),
|
||||
|
||||
+1
-1
@@ -194,7 +194,7 @@ func downloadFileRoute(ctx echo.Context) error {
|
||||
|
||||
slog.Info("Serving file for download", "path", fullPath)
|
||||
|
||||
return ctx.File(fullPath)
|
||||
return ctx.Attachment(fullPath, filepath.Base(fullPath))
|
||||
}
|
||||
|
||||
func openFileRoute(ctx echo.Context) error {
|
||||
|
||||
+40
-13
@@ -170,15 +170,8 @@
|
||||
|
||||
<span id="version-label" aria-label="Version">%%APP-VERSION%%</span>
|
||||
|
||||
<div class="fade-in">
|
||||
<div
|
||||
class="cursor-x"
|
||||
style="
|
||||
position: absolute;
|
||||
left: calc(50cqw + var(--mouse-start-x));
|
||||
top: calc(50cqh + var(--mouse-start-y));
|
||||
"
|
||||
>
|
||||
<div class="fade-in cursor-layer" aria-hidden="true">
|
||||
<div class="cursor-x">
|
||||
<svg class="cursor-y" width="50" height="50" viewBox="0 0 24 24">
|
||||
<g
|
||||
stroke="#ffffff"
|
||||
@@ -223,8 +216,6 @@
|
||||
|
||||
--mouse-size: 50px;
|
||||
--mouse-bounce-delay: 5s;
|
||||
--mouse-start-x: calc((35 * 100vw) / 1920);
|
||||
--mouse-start-y: calc((60 * 100vh) / 1080);
|
||||
|
||||
--dur-x: 16s;
|
||||
--dur-y: 9s;
|
||||
@@ -254,8 +245,12 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 9999;
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
|
||||
width: 100dvw;
|
||||
height: 100dvh;
|
||||
overflow: hidden;
|
||||
|
||||
container: splash / size;
|
||||
|
||||
animation-name: splash-fade;
|
||||
animation-duration: 1s;
|
||||
@@ -342,7 +337,23 @@
|
||||
animation: start-button-hover-press 1s ease-in-out 450ms forwards;
|
||||
}
|
||||
|
||||
.cursor-layer {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
|
||||
--mouse-start-x: calc(100cqw * 35 / 1920);
|
||||
--mouse-start-y: calc(100cqh * 60 / 1080);
|
||||
}
|
||||
|
||||
.cursor-x {
|
||||
position: absolute;
|
||||
left: calc(50cqw + var(--mouse-start-x));
|
||||
top: calc(50cqh + var(--mouse-start-y));
|
||||
width: var(--mouse-size);
|
||||
height: var(--mouse-size);
|
||||
|
||||
animation-name: move-mouse, mouse-bounceX;
|
||||
animation-duration: 1s, var(--dur-x);
|
||||
animation-delay: 0s, var(--mouse-bounce-delay);
|
||||
@@ -354,6 +365,10 @@
|
||||
}
|
||||
|
||||
.cursor-y {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
|
||||
animation-name: mouse-bounceY;
|
||||
animation-duration: var(--dur-y);
|
||||
animation-delay: var(--mouse-bounce-delay);
|
||||
@@ -364,6 +379,10 @@
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.cursor-y * {
|
||||
vector-effect: non-scaling-stroke;
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
to {
|
||||
opacity: 1;
|
||||
@@ -398,6 +417,10 @@
|
||||
calc(50cqw - var(--mouse-size) - var(--mouse-start-x))
|
||||
);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes mouse-bounceY {
|
||||
@@ -414,6 +437,10 @@
|
||||
calc(50cqh - var(--mouse-size) - var(--mouse-start-y))
|
||||
);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes start-button-hover-press {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
v0.1.4
|
||||
v0.1.5
|
||||
Reference in New Issue
Block a user