mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 17:07:08 +00:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 63c7cea4ca | |||
| 0e87ca3ae1 | |||
| d61ef0fe94 | |||
| 5d1f3e2d20 | |||
| 6dfb29bbd1 | |||
| 49410bf372 | |||
| 5d22f62a6e | |||
| a31080c602 | |||
| ea3cbcb8c6 | |||
| a0cf45c8dc | |||
| 97d2608adf | |||
| 36d2887247 | |||
| 1e9148bff2 | |||
| 346e511bb4 | |||
| 54e10b98e2 | |||
| 83eaf34475 | |||
| b251e8951f | |||
| 31cb614958 | |||
| 8fb9f5b9db | |||
| d13fd347ac | |||
| 922b47bd1e | |||
| b57ea762bf | |||
| c171706d96 | |||
| 6d5aa9041f | |||
| c2d9a2b049 | |||
| f84a7c0520 | |||
| 7f6891ecff | |||
| d63fc5cac4 | |||
| 12f4ec7d6c |
Generated
+28
-28
@@ -9,40 +9,40 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@thisux/sveltednd": "^0.0.20",
|
"@thisux/sveltednd": "^0.0.20",
|
||||||
"@tiptap/core": "^3.11.0",
|
"@tiptap/core": "^3.15.3",
|
||||||
"@tiptap/extension-highlight": "^3.11.0",
|
"@tiptap/extension-highlight": "^3.15.3",
|
||||||
"@tiptap/extension-text-style": "^3.11.0",
|
"@tiptap/extension-text-style": "^3.15.3",
|
||||||
"@tiptap/extensions": "^3.11.0",
|
"@tiptap/extensions": "^3.15.3",
|
||||||
"@tiptap/pm": "^3.11.0",
|
"@tiptap/pm": "^3.15.3",
|
||||||
"@tiptap/starter-kit": "^3.11.0",
|
"@tiptap/starter-kit": "^3.15.3",
|
||||||
"dexie": "^4.2.1",
|
"dexie": "^4.2.1",
|
||||||
"lucide-svelte": "^0.545.0",
|
"lucide-svelte": "^0.545.0",
|
||||||
"svelte-splitpanes": "^8.0.9"
|
"svelte-splitpanes": "^8.0.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.2.5",
|
"@eslint/compat": "^1.4.1",
|
||||||
"@eslint/js": "^9.18.0",
|
"@eslint/js": "^9.39.2",
|
||||||
"@playwright/test": "1.56.1",
|
"@playwright/test": "1.56.1",
|
||||||
"@sveltejs/adapter-auto": "^6.0.0",
|
"@sveltejs/adapter-auto": "^6.1.1",
|
||||||
"@sveltejs/adapter-static": "^3.0.9",
|
"@sveltejs/adapter-static": "^3.0.10",
|
||||||
"@sveltejs/kit": "^2.22.0",
|
"@sveltejs/kit": "^2.49.3",
|
||||||
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
"@sveltejs/vite-plugin-svelte": "^6.2.3",
|
||||||
"@tailwindcss/vite": "^4.0.0",
|
"@tailwindcss/vite": "^4.1.18",
|
||||||
"@tiptap/extension-placeholder": "^3.11.0",
|
"@tiptap/extension-placeholder": "^3.15.3",
|
||||||
"eslint": "^9.18.0",
|
"eslint": "^9.39.2",
|
||||||
"eslint-config-prettier": "^10.0.1",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-svelte": "^3.0.0",
|
"eslint-plugin-svelte": "^3.14.0",
|
||||||
"globals": "^16.0.0",
|
"globals": "^16.5.0",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.7.4",
|
||||||
"prettier-plugin-svelte": "^3.3.3",
|
"prettier-plugin-svelte": "^3.4.1",
|
||||||
"sass-embedded": "^1.93.3",
|
"sass-embedded": "^1.97.2",
|
||||||
"svelte": "^5.0.0",
|
"svelte": "^5.46.1",
|
||||||
"svelte-check": "^4.3.5",
|
"svelte-check": "^4.3.5",
|
||||||
"svelte-dnd-action": "^0.9.65",
|
"svelte-dnd-action": "^0.9.69",
|
||||||
"tailwindcss": "^4.0.0",
|
"tailwindcss": "^4.1.18",
|
||||||
"typescript": "^5.0.0",
|
"typescript": "^5.9.3",
|
||||||
"typescript-eslint": "^8.20.0",
|
"typescript-eslint": "^8.52.0",
|
||||||
"vite": "^7.0.4"
|
"vite": "^7.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@bufbuild/protobuf": {
|
"node_modules/@bufbuild/protobuf": {
|
||||||
|
|||||||
@@ -12,6 +12,14 @@
|
|||||||
--color-stone-850: oklch(0.242 0.0065 45.171);
|
--color-stone-850: oklch(0.242 0.0065 45.171);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
@apply text-blue-300 underline;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
@apply text-blue-400;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
&.space {
|
&.space {
|
||||||
@apply px-4;
|
@apply px-4;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
} else {
|
} else {
|
||||||
$pinned_display_id = display_id_object.id;
|
$pinned_display_id = display_id_object.id;
|
||||||
}
|
}
|
||||||
await screenshot_loop(display_id_object.id);
|
screenshot_loop(display_id_object.id);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
type Inode,
|
type Inode,
|
||||||
get_file_primary_key,
|
get_file_primary_key,
|
||||||
type FileOnDisplay,
|
type FileOnDisplay,
|
||||||
type FileLoadingData
|
type CompleteFileLoadingData
|
||||||
} from '$lib/ts/types';
|
} from '$lib/ts/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
import RefreshPlay from '../svgs/RefreshPlay.svelte';
|
import RefreshPlay from '../svgs/RefreshPlay.svelte';
|
||||||
import { get_file_size_display_string, get_file_type } from '$lib/ts/utils';
|
import { get_file_size_display_string, get_file_type } from '$lib/ts/utils';
|
||||||
import { open_file } from '$lib/ts/api_handler';
|
import { open_file } from '$lib/ts/api_handler';
|
||||||
import { run_on_all_selected_displays } from '$lib/ts/stores/displays';
|
import { get_display_by_id, run_on_all_selected_displays } from '$lib/ts/stores/displays';
|
||||||
import { get_thumbnail_url } from '$lib/ts/stores/thumbnails';
|
import { get_thumbnail_url } from '$lib/ts/stores/thumbnails';
|
||||||
import { liveQuery, type Observable } from 'dexie';
|
import { liveQuery, type Observable } from 'dexie';
|
||||||
import { db } from '$lib/ts/database';
|
import { db } from '$lib/ts/database';
|
||||||
@@ -45,12 +45,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
let loading_data:
|
let loading_data:
|
||||||
| Observable<{
|
| Observable<CompleteFileLoadingData>
|
||||||
is_loading: boolean;
|
|
||||||
total_percentage: number;
|
|
||||||
total_seconds_until_finish: number;
|
|
||||||
display_data: FileLoadingData[];
|
|
||||||
}>
|
|
||||||
| undefined = $state();
|
| undefined = $state();
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
const d = $selected_display_ids;
|
const d = $selected_display_ids;
|
||||||
@@ -197,12 +192,7 @@
|
|||||||
async function get_loading_data(
|
async function get_loading_data(
|
||||||
file_primary_key: string,
|
file_primary_key: string,
|
||||||
selected_display_ids: string[]
|
selected_display_ids: string[]
|
||||||
): Promise<{
|
): Promise<CompleteFileLoadingData> {
|
||||||
is_loading: boolean;
|
|
||||||
total_percentage: number;
|
|
||||||
total_seconds_until_finish: number;
|
|
||||||
display_data: FileLoadingData[];
|
|
||||||
}> {
|
|
||||||
const file_on_display_data: FileOnDisplay[] = await db.files_on_display
|
const file_on_display_data: FileOnDisplay[] = await db.files_on_display
|
||||||
.where('file_primary_key')
|
.where('file_primary_key')
|
||||||
.equals(file_primary_key)
|
.equals(file_primary_key)
|
||||||
@@ -225,7 +215,17 @@
|
|||||||
if (!is_loading) is_loading = true;
|
if (!is_loading) is_loading = true;
|
||||||
percentage_sum += fod.loading_data.percentage;
|
percentage_sum += fod.loading_data.percentage;
|
||||||
total_seconds_until_finish += fod.loading_data.seconds_until_finish;
|
total_seconds_until_finish += fod.loading_data.seconds_until_finish;
|
||||||
display_data.push(fod.loading_data);
|
const display = await get_display_by_id(fod.display_id);
|
||||||
|
if (!display) continue;
|
||||||
|
const display_data_element = {
|
||||||
|
loading_data: fod.loading_data,
|
||||||
|
display_name: display.name
|
||||||
|
};
|
||||||
|
if (fod.loading_data.type === 'sync_download') {
|
||||||
|
display_data.unshift(display_data_element); // insert sync_download element at beginning
|
||||||
|
} else {
|
||||||
|
display_data.push(display_data_element);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
percentage_sum += 100;
|
percentage_sum += 100;
|
||||||
}
|
}
|
||||||
@@ -303,12 +303,10 @@
|
|||||||
class="{get_main_classes()} relative transition-colors duration-200 gap-4 flex flex-row justify-between group w-full min-w-0"
|
class="{get_main_classes()} relative transition-colors duration-200 gap-4 flex flex-row justify-between group w-full min-w-0"
|
||||||
>
|
>
|
||||||
{#if $loading_data?.is_loading}
|
{#if $loading_data?.is_loading}
|
||||||
<!-- <div class="pointer-events-none absolute inset-0"> -->
|
|
||||||
<div
|
<div
|
||||||
class="absolute pointer-events-none inset-y-0 left-0 transition-[width] duration-200 bg-stone-600 rounded-r-lg"
|
class="absolute pointer-events-none inset-y-0 left-0 transition-[width] duration-200 bg-stone-600 rounded-r-lg"
|
||||||
style={`width: ${$loading_data.total_percentage}%;`}
|
style={`width: ${Math.min($loading_data.total_percentage, 100)}%;`}
|
||||||
></div>
|
></div>
|
||||||
<!-- </div> -->
|
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex flex-row gap-2 min-w-0 w-full z-10">
|
<div class="flex flex-row gap-2 min-w-0 w-full z-10">
|
||||||
<div class="aspect-square rounded-md flex justify-center items-center">
|
<div class="aspect-square rounded-md flex justify-center items-center">
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { NumberSetting } from '$lib/ts/types';
|
||||||
|
import { ChevronDown, ChevronUp, Minus, Plus } from 'lucide-svelte';
|
||||||
|
import Button from './Button.svelte';
|
||||||
|
|
||||||
|
let {
|
||||||
|
number_setting,
|
||||||
|
on_change,
|
||||||
|
className = '',
|
||||||
|
disabled = false,
|
||||||
|
}: {
|
||||||
|
number_setting: NumberSetting;
|
||||||
|
on_change: (new_value: number) => void;
|
||||||
|
className?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
} = $props();
|
||||||
|
|
||||||
|
let el: HTMLInputElement | null = null;
|
||||||
|
|
||||||
|
function increase() {
|
||||||
|
if (!el) return;
|
||||||
|
el.stepUp();
|
||||||
|
el.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
on_change(Number(el.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
function decrease() {
|
||||||
|
if (!el) return;
|
||||||
|
el.stepDown();
|
||||||
|
el.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
|
on_change(Number(el.value));
|
||||||
|
}
|
||||||
|
|
||||||
|
function on_blur() {
|
||||||
|
if (!el) return;
|
||||||
|
let value = Number(el.value);
|
||||||
|
if (value > number_setting.max) value = number_setting.max;
|
||||||
|
else if (value < number_setting.min) value = number_setting.min;
|
||||||
|
el.value = String(value);
|
||||||
|
on_change(value);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex flex-row {className}">
|
||||||
|
<Button click_function={increase} className="rounded-r-none" disabled={disabled}>
|
||||||
|
<ChevronUp />
|
||||||
|
</Button>
|
||||||
|
<input
|
||||||
|
bind:this={el}
|
||||||
|
class="bg-stone-700 focus:bg-stone-550 focus:outline-none transition-colors duration-200 py-2 px-4 w-15 text-center
|
||||||
|
{disabled ? 'text-stone-500 cursor-not-allowed' : 'hover:bg-stone-600'}
|
||||||
|
[appearance:textfield]
|
||||||
|
[&::-webkit-outer-spin-button]:appearance-none
|
||||||
|
[&::-webkit-inner-spin-button]:appearance-none"
|
||||||
|
type="number"
|
||||||
|
disabled={disabled}
|
||||||
|
max={number_setting.max}
|
||||||
|
min={number_setting.min}
|
||||||
|
value={number_setting.now}
|
||||||
|
step={number_setting.step}
|
||||||
|
onblur={on_blur}
|
||||||
|
/>
|
||||||
|
<Button click_function={decrease} className="rounded-l-none" disabled={disabled}>
|
||||||
|
<ChevronDown />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
@@ -9,6 +9,9 @@ import {
|
|||||||
} from './types';
|
} from './types';
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
import { get_sanitized_file_url } from './utils';
|
import { get_sanitized_file_url } from './utils';
|
||||||
|
import { online_displays } from './stores/displays';
|
||||||
|
import { get } from 'svelte/store';
|
||||||
|
import { update_display_status } from './main';
|
||||||
|
|
||||||
export async function get_screenshot(ip: string): Promise<Blob | null> {
|
export async function get_screenshot(ip: string): Promise<Blob | null> {
|
||||||
const options = { method: 'PATCH' };
|
const options = { method: 'PATCH' };
|
||||||
@@ -36,7 +39,7 @@ export async function send_keyboard_input(
|
|||||||
await request_display(ip, '/keyboardInput', options);
|
await request_display(ip, '/keyboardInput', options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function show_html(ip: string, html: string) {
|
export async function show_html(ip: string, html: string): Promise<void> {
|
||||||
const options = {
|
const options = {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: { 'content-type': 'application/json' },
|
headers: { 'content-type': 'application/json' },
|
||||||
@@ -72,6 +75,7 @@ export async function get_file_data(
|
|||||||
const json_response = raw_response.json as ShellCommandResponse;
|
const json_response = raw_response.json as ShellCommandResponse;
|
||||||
if (json_response.exitCode === 0 && json_response.stdout.trim() === '') return [];
|
if (json_response.exitCode === 0 && json_response.stdout.trim() === '') return [];
|
||||||
if (handle_shell_error(ip, json_response, command, true)) return null;
|
if (handle_shell_error(ip, json_response, command, true)) return null;
|
||||||
|
if (json_response.stdout.trim() === '') return null;
|
||||||
|
|
||||||
const response: FileInfo[] = json_response.stdout
|
const response: FileInfo[] = json_response.stdout
|
||||||
.trim()
|
.trim()
|
||||||
@@ -109,16 +113,8 @@ export async function get_file_tree_data(ip: string, path: string): Promise<Tree
|
|||||||
return tree_element?.contents || null;
|
return tree_element?.contents || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function create_folders(
|
export async function create_path(ip: string, path: string): Promise<void> {
|
||||||
ip: string,
|
const command = `mkdir -p ".${path}"`;
|
||||||
path: string,
|
|
||||||
folder_names: string[]
|
|
||||||
): Promise<void> {
|
|
||||||
let command = `cd ".${path}"`;
|
|
||||||
|
|
||||||
for (const part of folder_names) {
|
|
||||||
command += ` && mkdir "${part}" && cd "${part}/"`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const raw_response = await run_shell_command(ip, command);
|
const raw_response = await run_shell_command(ip, command);
|
||||||
if (!raw_response.ok || !raw_response.json) return;
|
if (!raw_response.ok || !raw_response.json) return;
|
||||||
@@ -195,14 +191,30 @@ async function request_display(
|
|||||||
supress_error_handling_http_codes: number[] = []
|
supress_error_handling_http_codes: number[] = []
|
||||||
): Promise<RequestResponse> {
|
): Promise<RequestResponse> {
|
||||||
const url = `http://${ip}:1323/api${api_route}`;
|
const url = `http://${ip}:1323/api${api_route}`;
|
||||||
return await request(url, options, supress_error_handling_http_codes);
|
|
||||||
|
const current_online_displays = get(online_displays);
|
||||||
|
if (!current_online_displays.map((d) => d.ip).includes(ip)) return { ok: false };
|
||||||
|
|
||||||
|
const response = await request(url, options, supress_error_handling_http_codes);
|
||||||
|
if (!response.ok && response.http_code === 408) {
|
||||||
|
// Network error -> device possibly not longer online -> test status and throw no error if its offline
|
||||||
|
const possible_displays = current_online_displays.filter((d) => d.ip === ip);
|
||||||
|
for (const display of possible_displays) {
|
||||||
|
const current_status = await update_display_status(display);
|
||||||
|
if (current_status === 'app_online') {
|
||||||
|
console.error(`No response from ${url}`)
|
||||||
|
notifications.push('error', "Netzwerk-Fehler bei API-Anfrage", `${url}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function request_control(
|
async function request_control(
|
||||||
api_route: string,
|
api_route: string,
|
||||||
options: { method: string; headers?: Record<string, string>; body?: string }
|
options: { method: string; headers?: Record<string, string>; body?: string }
|
||||||
): Promise<RequestResponse> {
|
): Promise<RequestResponse> {
|
||||||
const url = `http://127.0.0.1:8080/api${api_route}`;
|
const url = `${dev ? 'http://127.0.0.1:8080' : window.location.origin}/api${api_route}`;
|
||||||
return await request(url, options);
|
return await request(url, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,12 +254,17 @@ async function request(
|
|||||||
error_description += '\nCould not parse error description';
|
error_description += '\nCould not parse error description';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifications.push('error', `Fehler ${response.status} bei API-Anfrage`, error_description);
|
notifications.push(
|
||||||
|
'error',
|
||||||
|
`Fehler bei API-Anfrage`,
|
||||||
|
`\nHTTP: ${response.status}\n${error_description}`
|
||||||
|
);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (error instanceof TypeError && /fetch|NetworkError/i.test(error.message)) {
|
if (error instanceof TypeError && /fetch|NetworkError/i.test(error.message)) {
|
||||||
if (dev) {
|
if (dev) {
|
||||||
console.warn('Request failed - Is the targeted device online?');
|
console.warn('Request failed - Is the targeted device online?');
|
||||||
}
|
}
|
||||||
|
return { ok: false, http_code: 408 };
|
||||||
} else {
|
} else {
|
||||||
console.error(url, error);
|
console.error(url, error);
|
||||||
notifications.push('error', `Fataler Fehler bei API-Anfrage`, `${url}\nFehler: ${error}`);
|
notifications.push('error', `Fataler Fehler bei API-Anfrage`, `${url}\nFehler: ${error}`);
|
||||||
@@ -276,12 +293,11 @@ function handle_shell_error(
|
|||||||
console.error(shell_response);
|
console.error(shell_response);
|
||||||
notifications.push(
|
notifications.push(
|
||||||
'error',
|
'error',
|
||||||
`Fehler ${shell_response.exitCode} in API-Shell`,
|
`Fehler in API-Shell`,
|
||||||
`${ip}\n${shell_command}\nFehler: ${shell_response.stderr}`
|
`${ip}\n${shell_command}\nFehler (${shell_response.exitCode}): ${shell_response.stderr}`
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (shell_response.stdout.trim() === '') return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { db } from './database';
|
import { db } from './database';
|
||||||
import { get_display_by_id } from './stores/displays';
|
import { get_display_by_id } from './stores/displays';
|
||||||
import {
|
import {
|
||||||
get_current_folder_elements,
|
|
||||||
create_path_on_all_selected_displays,
|
create_path_on_all_selected_displays,
|
||||||
|
get_folder_elements,
|
||||||
get_file_by_id,
|
get_file_by_id,
|
||||||
remove_all_files_without_display,
|
remove_all_files_without_display,
|
||||||
remove_file_from_display_recusively
|
remove_file_from_display_recusively
|
||||||
@@ -32,7 +32,7 @@ export async function add_upload(
|
|||||||
await create_path_on_all_selected_displays(current_file_path, selected_display_ids);
|
await create_path_on_all_selected_displays(current_file_path, selected_display_ids);
|
||||||
|
|
||||||
const used_file_names: string[] = await (
|
const used_file_names: string[] = await (
|
||||||
await get_current_folder_elements(current_file_path, selected_display_ids)
|
await get_folder_elements(current_file_path, selected_display_ids)
|
||||||
).map((e) => e.name);
|
).map((e) => e.name);
|
||||||
|
|
||||||
for (const file of file_list) {
|
for (const file of file_list) {
|
||||||
@@ -89,13 +89,32 @@ export async function add_upload(
|
|||||||
await start_task_processing();
|
await start_task_processing();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function add_sync(selected_file_id: string, selected_display_ids: string[]) {
|
export async function add_sync_recursively(
|
||||||
|
selected_file_id: string,
|
||||||
|
selected_display_ids: string[]
|
||||||
|
) {
|
||||||
const file_data = await find_file_data_on_active_selected_display(
|
const file_data = await find_file_data_on_active_selected_display(
|
||||||
selected_file_id,
|
selected_file_id,
|
||||||
selected_display_ids
|
selected_display_ids
|
||||||
);
|
);
|
||||||
if (!file_data) return console.warn('Sync canceled: no file_data');
|
if (!file_data) return console.warn('Sync canceled: no file_data');
|
||||||
|
|
||||||
|
if (file_data.file.type === 'inode/directory') {
|
||||||
|
const new_path = file_data.file.path + file_data.file.name + '/';
|
||||||
|
const elements_in_folder = await get_folder_elements(new_path, selected_display_ids);
|
||||||
|
if (elements_in_folder.length === 0) {
|
||||||
|
await create_path_on_all_selected_displays(new_path, selected_display_ids);
|
||||||
|
} else {
|
||||||
|
for (const el of elements_in_folder) {
|
||||||
|
await add_sync_recursively(get_file_primary_key(el), selected_display_ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return; // cannot sync folder
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file_data.short_displays_without_file.length === 0) return; // file is present on all selected displays
|
||||||
|
await create_path_on_all_selected_displays(file_data.file.path, selected_display_ids);
|
||||||
|
|
||||||
tasks.push({
|
tasks.push({
|
||||||
data: {
|
data: {
|
||||||
type: 'sync',
|
type: 'sync',
|
||||||
@@ -117,18 +136,21 @@ export async function add_sync(selected_file_id: string, selected_display_ids: s
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const display_ids_without_file = file_data.short_displays_without_file.map((d) => d.id);
|
const display_ids_without_file = file_data.short_displays_without_file.map((d) => d.id);
|
||||||
await db.files_on_display
|
const new_file_loading_data: FileLoadingData = {
|
||||||
.where('file_primary_key')
|
|
||||||
.equals(selected_file_id)
|
|
||||||
.filter((e) => display_ids_without_file.includes(e.display_id))
|
|
||||||
.modify({
|
|
||||||
loading_data: {
|
|
||||||
type: 'sync_upload',
|
type: 'sync_upload',
|
||||||
percentage: 0,
|
percentage: 0,
|
||||||
bytes_per_second: 0,
|
bytes_per_second: 0,
|
||||||
seconds_until_finish: -1
|
seconds_until_finish: -1
|
||||||
}
|
};
|
||||||
});
|
const new_fods: FileOnDisplay[] = display_ids_without_file.map((display_id) => ({
|
||||||
|
display_id,
|
||||||
|
file_primary_key: selected_file_id,
|
||||||
|
date_created: new Date(),
|
||||||
|
loading_data: new_file_loading_data
|
||||||
|
}));
|
||||||
|
console.log("TEST", new_fods)
|
||||||
|
await db.files_on_display.bulkPut(new_fods);
|
||||||
|
|
||||||
await start_task_processing();
|
await start_task_processing();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +269,10 @@ export async function sync(task: FileTransferTask) {
|
|||||||
}
|
}
|
||||||
await writable.close();
|
await writable.close();
|
||||||
|
|
||||||
|
await db.files_on_display.update([task.display.id, task.file_primary_key], {
|
||||||
|
loading_data: null
|
||||||
|
});
|
||||||
|
|
||||||
// 02 - send downloaded file to every destination_display
|
// 02 - send downloaded file to every destination_display
|
||||||
const temp_file = await file_handle.getFile();
|
const temp_file = await file_handle.getFile();
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,71 @@
|
|||||||
import { screenshot_loop } from './stores/displays';
|
import { screenshot_loop } from './stores/displays';
|
||||||
import { ping_ip } from './api_handler';
|
import { ping_ip } from './api_handler';
|
||||||
import type { Display } from './types';
|
import type { Display, DisplayStatus } from './types';
|
||||||
import { update_folder_elements_recursively } from './stores/files';
|
import { update_folder_elements_recursively } from './stores/files';
|
||||||
import { db } from './database';
|
import { db } from './database';
|
||||||
|
|
||||||
const update_display_status_interval_seconds = 20;
|
const update_display_status_interval_seconds = 20;
|
||||||
|
const update_display_loading_status_interval_seconds = 2;
|
||||||
|
|
||||||
export async function on_start() {
|
const loading_display_ids: string[] = [];
|
||||||
|
|
||||||
|
export async function on_app_start() {
|
||||||
await db.files.clear();
|
await db.files.clear();
|
||||||
await db.files_on_display.clear();
|
await db.files_on_display.clear();
|
||||||
await update_all_display_status();
|
await db.displays
|
||||||
await setInterval(update_all_display_status, update_display_status_interval_seconds * 1000);
|
.toCollection()
|
||||||
|
.modify({ status: null, preview: { currently_updating: false, url: null } });
|
||||||
|
await update_all_display_status(false);
|
||||||
|
await setInterval(
|
||||||
|
() => update_all_display_status(false),
|
||||||
|
update_display_status_interval_seconds * 1000
|
||||||
|
);
|
||||||
|
await setInterval(
|
||||||
|
() => update_all_display_status(true),
|
||||||
|
update_display_loading_status_interval_seconds * 1000
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update_all_display_status() {
|
async function update_all_display_status(only_loading_displays: boolean) {
|
||||||
const all_displays: Display[] = await db.displays.toArray();
|
const not_loading_displays: Display[] = await db.displays
|
||||||
for (const display of all_displays) {
|
.filter((d) =>
|
||||||
|
only_loading_displays
|
||||||
|
? loading_display_ids.includes(d.id)
|
||||||
|
: !loading_display_ids.includes(d.id)
|
||||||
|
)
|
||||||
|
.toArray();
|
||||||
|
for (const display of not_loading_displays) {
|
||||||
|
await update_display_status(display);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function update_display_status(display: Display): Promise<DisplayStatus> {
|
||||||
const new_status = await ping_ip(display.ip);
|
const new_status = await ping_ip(display.ip);
|
||||||
if (new_status === null && display.status !== null) continue;
|
if (new_status === null && display.status !== null) return null;
|
||||||
if (new_status === 'app_online' && display.status !== 'app_online') {
|
if (new_status !== display.status) {
|
||||||
|
// status change
|
||||||
|
if (new_status === 'app_offline') {
|
||||||
|
loading_display_ids.push(display.id);
|
||||||
|
} else {
|
||||||
|
remove_display_from_loading_displays(display.id);
|
||||||
|
if (new_status === 'app_online') {
|
||||||
on_display_start(display);
|
on_display_start(display);
|
||||||
}
|
}
|
||||||
if (new_status !== display.status) {
|
}
|
||||||
display.status = new_status;
|
display.status = new_status;
|
||||||
await db.displays.put(display); // save
|
await db.displays.put(display); // save
|
||||||
}
|
}
|
||||||
|
return new_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove_display_from_loading_displays(display_id: string) {
|
||||||
|
const index = loading_display_ids.indexOf(display_id);
|
||||||
|
if (index !== -1) {
|
||||||
|
loading_display_ids.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function on_display_start(display: Display) {
|
async function on_display_start(display: Display) {
|
||||||
await update_folder_elements_recursively(display, '/');
|
await update_folder_elements_recursively(display, '/');
|
||||||
await screenshot_loop(display.id);
|
screenshot_loop(display.id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,17 @@ import { get_screenshot } from '../api_handler';
|
|||||||
import { delete_and_deselect_unique_files_from_display } from './files';
|
import { delete_and_deselect_unique_files_from_display } from './files';
|
||||||
import { db } from '../database';
|
import { db } from '../database';
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
|
import { remove_display_from_loading_displays } from '../main';
|
||||||
|
import { preview_settings } from './ui_behavior';
|
||||||
|
import { liveQuery } from 'dexie';
|
||||||
|
|
||||||
|
export const online_displays: Writable<Display[]> = writable<Display[]>([]);
|
||||||
|
|
||||||
|
export const online_displays_sub = liveQuery(() =>
|
||||||
|
db.displays.where('status').equals('app_online').toArray()
|
||||||
|
).subscribe((value) => {
|
||||||
|
online_displays.set(value);
|
||||||
|
});
|
||||||
|
|
||||||
export const local_displays: Writable<DisplayIdGroup[]> = writable<DisplayIdGroup[]>([]);
|
export const local_displays: Writable<DisplayIdGroup[]> = writable<DisplayIdGroup[]>([]);
|
||||||
|
|
||||||
@@ -25,8 +36,8 @@ export async function add_display(
|
|||||||
mac: string | null,
|
mac: string | null,
|
||||||
name: string,
|
name: string,
|
||||||
status: DisplayStatus
|
status: DisplayStatus
|
||||||
) {
|
): Promise<Display | null> {
|
||||||
if (await is_display_name_taken(name)) return;
|
if (await is_display_name_taken(name)) return null;
|
||||||
const new_id = get_uuid();
|
const new_id = get_uuid();
|
||||||
const group = await db.display_groups.toCollection().first();
|
const group = await db.display_groups.toCollection().first();
|
||||||
let group_id: string;
|
let group_id: string;
|
||||||
@@ -38,7 +49,7 @@ export async function add_display(
|
|||||||
}
|
}
|
||||||
const element_count_in_group = (await db.displays.where('group_id').equals(group_id).toArray())
|
const element_count_in_group = (await db.displays.where('group_id').equals(group_id).toArray())
|
||||||
.length;
|
.length;
|
||||||
await db.displays.put({
|
const display = {
|
||||||
id: new_id,
|
id: new_id,
|
||||||
ip,
|
ip,
|
||||||
mac,
|
mac,
|
||||||
@@ -47,7 +58,9 @@ export async function add_display(
|
|||||||
group_id: group_id,
|
group_id: group_id,
|
||||||
name,
|
name,
|
||||||
status
|
status
|
||||||
});
|
};
|
||||||
|
await db.displays.put(display);
|
||||||
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function edit_display_data(
|
export async function edit_display_data(
|
||||||
@@ -55,11 +68,19 @@ export async function edit_display_data(
|
|||||||
ip: string,
|
ip: string,
|
||||||
mac: string | null,
|
mac: string | null,
|
||||||
name: string
|
name: string
|
||||||
) {
|
): Promise<Display | null> {
|
||||||
let display = await db.displays.get(display_id);
|
let display = await db.displays.get(display_id);
|
||||||
if (!display) return;
|
if (!display) return null;
|
||||||
display = { ...display, ip: ip, mac: mac, name: name };
|
display = {
|
||||||
|
...display,
|
||||||
|
ip: ip,
|
||||||
|
mac: mac,
|
||||||
|
name,
|
||||||
|
preview: { currently_updating: false, url: null }
|
||||||
|
};
|
||||||
await db.displays.put(display); // save
|
await db.displays.put(display); // save
|
||||||
|
screenshot_loop(display.id);
|
||||||
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function remove_display(display_id: string) {
|
export async function remove_display(display_id: string) {
|
||||||
@@ -71,6 +92,7 @@ export async function remove_display(display_id: string) {
|
|||||||
if (group_id && (await db.displays.where('group_id').equals(group_id).toArray()).length === 0) {
|
if (group_id && (await db.displays.where('group_id').equals(group_id).toArray()).length === 0) {
|
||||||
await db.display_groups.delete(group_id); // delete empty group
|
await db.display_groups.delete(group_id); // delete empty group
|
||||||
}
|
}
|
||||||
|
await remove_display_from_loading_displays(display_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function all_displays_of_group_selected(
|
export async function all_displays_of_group_selected(
|
||||||
@@ -112,7 +134,14 @@ export async function get_display_by_id(display_id: string): Promise<Display | n
|
|||||||
return (await db.displays.get(display_id)) ?? null;
|
return (await db.displays.get(display_id)) ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function screenshot_loop(display_id: string, initial_retry_count: number = 5) {
|
export function screenshot_loop(display_id: string) {
|
||||||
|
setTimeout(async () => {
|
||||||
|
let settings = get(preview_settings);
|
||||||
|
if (settings.mode === 'never') return;
|
||||||
|
|
||||||
|
const initial_retry_count = settings.retry_count.now;
|
||||||
|
const retry_seconds = get(preview_settings).retry_seconds.now;
|
||||||
|
|
||||||
const display = await db.displays.get(display_id);
|
const display = await db.displays.get(display_id);
|
||||||
if (!display || display.preview.currently_updating) return;
|
if (!display || display.preview.currently_updating) return;
|
||||||
|
|
||||||
@@ -123,9 +152,14 @@ export async function screenshot_loop(display_id: string, initial_retry_count: n
|
|||||||
|
|
||||||
let retry_count = initial_retry_count;
|
let retry_count = initial_retry_count;
|
||||||
while (retry_count > 0) {
|
while (retry_count > 0) {
|
||||||
retry_count -= 1;
|
settings = get(preview_settings);
|
||||||
|
if (settings.mode === 'never') break;
|
||||||
|
if (settings.mode !== 'always') retry_count -= 1;
|
||||||
|
|
||||||
const new_blob = await get_screenshot(display.ip);
|
const new_blob = await get_screenshot(display.ip);
|
||||||
|
settings = get(preview_settings);
|
||||||
|
if (settings.mode === 'never') break;
|
||||||
|
|
||||||
if (!new_blob) {
|
if (!new_blob) {
|
||||||
display.preview = { currently_updating: false, url: null };
|
display.preview = { currently_updating: false, url: null };
|
||||||
await db.displays.update(display.id, { preview: display.preview });
|
await db.displays.update(display.id, { preview: display.preview });
|
||||||
@@ -144,11 +178,16 @@ export async function screenshot_loop(display_id: string, initial_retry_count: n
|
|||||||
retry_count = initial_retry_count;
|
retry_count = initial_retry_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // sleep 2s
|
await new Promise((resolve) => setTimeout(resolve, retry_seconds * 1000)); // sleep
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.mode === 'never') {
|
||||||
|
await db.displays.update(display.id, { preview: { currently_updating: false, url: null } });
|
||||||
|
} else {
|
||||||
display.preview.currently_updating = false;
|
display.preview.currently_updating = false;
|
||||||
await db.displays.update(display.id, { preview: display.preview });
|
await db.displays.update(display.id, { preview: display.preview });
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function run_on_all_selected_displays(
|
export async function run_on_all_selected_displays(
|
||||||
@@ -167,7 +206,7 @@ export async function run_on_all_selected_displays(
|
|||||||
if (!display || (ignore_offline && display.status === 'host_offline')) return;
|
if (!display || (ignore_offline && display.status === 'host_offline')) return;
|
||||||
await run_function(display);
|
await run_function(display);
|
||||||
if (update_screenshot_afterwards) {
|
if (update_screenshot_afterwards) {
|
||||||
await screenshot_loop(display.id);
|
screenshot_loop(display.id);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -192,7 +231,7 @@ export async function update_local_displays() {
|
|||||||
|
|
||||||
export async function update_db_displays() {
|
export async function update_db_displays() {
|
||||||
local_displays.update((groups) => groups.filter((g) => g.displays.length !== 0));
|
local_displays.update((groups) => groups.filter((g) => g.displays.length !== 0));
|
||||||
const filtered_local_display_groups = get(local_displays)
|
const filtered_local_display_groups = get(local_displays);
|
||||||
const db_display_group_ids = (await db.display_groups.toArray()).map((group) => group.id);
|
const db_display_group_ids = (await db.display_groups.toArray()).map((group) => group.id);
|
||||||
const local_display_group_ids = filtered_local_display_groups.map((group) => group.id);
|
const local_display_group_ids = filtered_local_display_groups.map((group) => group.id);
|
||||||
|
|
||||||
@@ -230,6 +269,16 @@ export function set_new_display_order(display_id_group_id: string, new_data: Dis
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function no_active_display_selected(
|
||||||
|
selected_display_ids: string[],
|
||||||
|
online_displays: Display[]
|
||||||
|
) {
|
||||||
|
const online_and_selected_displays = online_displays.filter((d) =>
|
||||||
|
selected_display_ids.includes(d.id)
|
||||||
|
);
|
||||||
|
return online_and_selected_displays.length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (dev) {
|
if (dev) {
|
||||||
setTimeout(add_testing_displays, 0);
|
setTimeout(add_testing_displays, 0);
|
||||||
async function add_testing_displays() {
|
async function add_testing_displays() {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from '../types';
|
} from '../types';
|
||||||
import { get_display_by_id } from './displays';
|
import { get_display_by_id } from './displays';
|
||||||
import { is_selected, select, selected_display_ids, selected_file_ids } from './select';
|
import { is_selected, select, selected_display_ids, selected_file_ids } from './select';
|
||||||
import { create_folders, get_file_data, get_file_tree_data } from '../api_handler';
|
import { create_path, get_file_data, get_file_tree_data } from '../api_handler';
|
||||||
import { deactivate_old_thumbnail_urls, generate_thumbnail } from './thumbnails';
|
import { deactivate_old_thumbnail_urls, generate_thumbnail } from './thumbnails';
|
||||||
import { db } from '../database';
|
import { db } from '../database';
|
||||||
|
|
||||||
@@ -47,7 +47,10 @@ export async function delete_and_deselect_unique_files_from_display(display_id:
|
|||||||
await remove_all_files_without_display();
|
await remove_all_files_without_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function remove_file_from_display_recusively(display_id: string, file_primary_key: string) {
|
export async function remove_file_from_display_recusively(
|
||||||
|
display_id: string,
|
||||||
|
file_primary_key: string
|
||||||
|
) {
|
||||||
const found = await db.files_on_display.get([display_id, file_primary_key]);
|
const found = await db.files_on_display.get([display_id, file_primary_key]);
|
||||||
if (!found) return;
|
if (!found) return;
|
||||||
select(selected_file_ids, file_primary_key, 'deselect');
|
select(selected_file_ids, file_primary_key, 'deselect');
|
||||||
@@ -130,12 +133,11 @@ async function get_display_ids_where_file_is_missing(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get_displays_where_path_exists(
|
export async function get_displays_where_path_not_exists(
|
||||||
path: string,
|
path: string,
|
||||||
selected_display_ids: string[],
|
selected_display_ids: string[]
|
||||||
invert: boolean
|
|
||||||
): Promise<Display[]> {
|
): Promise<Display[]> {
|
||||||
if (path === '/') return [];
|
if (path === '/') return await db.displays.where('id').anyOf(selected_display_ids).toArray();
|
||||||
const last_path_part =
|
const last_path_part =
|
||||||
path
|
path
|
||||||
.slice(0, path.length - 1)
|
.slice(0, path.length - 1)
|
||||||
@@ -148,8 +150,7 @@ export async function get_displays_where_path_exists(
|
|||||||
.equals(last_path_part)
|
.equals(last_path_part)
|
||||||
.filter((inode) => inode.path === path_without_last_part && inode.type === 'inode/directory')
|
.filter((inode) => inode.path === path_without_last_part && inode.type === 'inode/directory')
|
||||||
.first();
|
.first();
|
||||||
if (!folders_of_current_path)
|
if (!folders_of_current_path) return [];
|
||||||
return await db.displays.where('id').anyOf(selected_display_ids).toArray();
|
|
||||||
const folder_primary_key = get_file_primary_key(folders_of_current_path);
|
const folder_primary_key = get_file_primary_key(folders_of_current_path);
|
||||||
|
|
||||||
const display_ids_with_folder = (
|
const display_ids_with_folder = (
|
||||||
@@ -157,11 +158,7 @@ export async function get_displays_where_path_exists(
|
|||||||
).map((fod) => fod.display_id);
|
).map((fod) => fod.display_id);
|
||||||
|
|
||||||
const display_ids = selected_display_ids.filter((display_id) => {
|
const display_ids = selected_display_ids.filter((display_id) => {
|
||||||
if (invert) {
|
|
||||||
return !display_ids_with_folder.includes(display_id);
|
return !display_ids_with_folder.includes(display_id);
|
||||||
} else {
|
|
||||||
return display_ids_with_folder.includes(display_id);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return (await db.displays.bulkGet(display_ids)).filter((e) => e !== undefined);
|
return (await db.displays.bulkGet(display_ids)).filter((e) => e !== undefined);
|
||||||
@@ -313,8 +310,8 @@ function get_folder_elements_difference(
|
|||||||
return { deleted: only_in_old, new: only_in_new };
|
return { deleted: only_in_old, new: only_in_new };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get_current_folder_elements(
|
export async function get_folder_elements(
|
||||||
current_file_path: string,
|
file_path: string,
|
||||||
selected_display_ids: string[]
|
selected_display_ids: string[]
|
||||||
): Promise<Inode[]> {
|
): Promise<Inode[]> {
|
||||||
const existing_file_keys_on_selected_displays: [string, string, number, string][] = (
|
const existing_file_keys_on_selected_displays: [string, string, number, string][] = (
|
||||||
@@ -323,7 +320,7 @@ export async function get_current_folder_elements(
|
|||||||
const existing_files_on_selected_displays_in_path: Inode[] = await db.files
|
const existing_files_on_selected_displays_in_path: Inode[] = await db.files
|
||||||
.where('[path+name+size+type]')
|
.where('[path+name+size+type]')
|
||||||
.anyOf(existing_file_keys_on_selected_displays)
|
.anyOf(existing_file_keys_on_selected_displays)
|
||||||
.filter((e) => e.path === current_file_path)
|
.filter((e) => e.path === file_path)
|
||||||
.toArray();
|
.toArray();
|
||||||
|
|
||||||
return sort_files(existing_files_on_selected_displays_in_path);
|
return sort_files(existing_files_on_selected_displays_in_path);
|
||||||
@@ -404,31 +401,24 @@ export async function create_path_on_all_selected_displays(
|
|||||||
path: string,
|
path: string,
|
||||||
selected_display_ids: string[]
|
selected_display_ids: string[]
|
||||||
) {
|
) {
|
||||||
const path_parts = path
|
const displays_without_path = await get_displays_where_path_not_exists(
|
||||||
.slice(1, path.length - 1)
|
path,
|
||||||
.split('/')
|
selected_display_ids
|
||||||
.filter((e) => e.length !== 0);
|
);
|
||||||
let remaining_display_ids = [...selected_display_ids];
|
if (displays_without_path.length === 0) return;
|
||||||
|
for (const display of displays_without_path) {
|
||||||
const getDisplaysForPath = async (currentPath: string): Promise<Display[]> => {
|
await create_path(display.ip, path);
|
||||||
if (currentPath === '/') {
|
|
||||||
const displays = await db.displays.bulkGet(remaining_display_ids);
|
|
||||||
return displays.filter((d): d is Display => !!d);
|
|
||||||
}
|
}
|
||||||
return get_displays_where_path_exists(currentPath, remaining_display_ids, false);
|
setTimeout(async () => {
|
||||||
};
|
for (const display of displays_without_path) {
|
||||||
|
const changed_paths = await get_changed_directory_paths(display, '/');
|
||||||
for (let depth = path_parts.length; depth >= 0 && remaining_display_ids.length; depth--) {
|
if (!changed_paths) continue;
|
||||||
const currentPath = depth === 0 ? '/' : `/${path_parts.slice(0, depth).join('/')}/`;
|
console.debug('Update file system from', display.name, ':', changed_paths);
|
||||||
|
for (const path of changed_paths) {
|
||||||
const displays = await getDisplaysForPath(currentPath);
|
await update_folder_elements_recursively(display, path);
|
||||||
if (!displays.length) continue;
|
|
||||||
|
|
||||||
for (const display of displays) {
|
|
||||||
await create_folders(display.ip, currentPath, path_parts.slice(depth));
|
|
||||||
remaining_display_ids = remaining_display_ids.filter((id) => id !== display.id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get_date_mapping(file_primary_key: string): Promise<Record<string, Date>> {
|
export async function get_date_mapping(file_primary_key: string): Promise<Record<string, Date>> {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { writable, type Writable } from 'svelte/store';
|
import { writable, type Writable } from 'svelte/store';
|
||||||
|
import type { NumberSetting } from '../types';
|
||||||
|
|
||||||
export const dnd_flip_duration_ms = 300;
|
export const dnd_flip_duration_ms = 300;
|
||||||
|
|
||||||
@@ -23,6 +24,30 @@ export const current_height: Writable<Record<string, number>> = writable<Record<
|
|||||||
export const is_group_drag: Writable<boolean> = writable<boolean>(false);
|
export const is_group_drag: Writable<boolean> = writable<boolean>(false);
|
||||||
export const is_display_drag: Writable<boolean> = writable<boolean>(false);
|
export const is_display_drag: Writable<boolean> = writable<boolean>(false);
|
||||||
|
|
||||||
|
export const preview_settings: Writable<{
|
||||||
|
mode: 'never' | 'normal' | 'always';
|
||||||
|
retry_seconds: NumberSetting;
|
||||||
|
retry_count: NumberSetting;
|
||||||
|
}> = writable<{
|
||||||
|
mode: 'never' | 'normal' | 'always';
|
||||||
|
retry_seconds: NumberSetting;
|
||||||
|
retry_count: NumberSetting;
|
||||||
|
}>({
|
||||||
|
mode: 'normal',
|
||||||
|
retry_seconds: {
|
||||||
|
max: 10,
|
||||||
|
min: 0.5,
|
||||||
|
now: 2,
|
||||||
|
step: 0.5
|
||||||
|
},
|
||||||
|
retry_count: {
|
||||||
|
max: 10,
|
||||||
|
min: 1,
|
||||||
|
now: 5,
|
||||||
|
step: 1
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export const pinned_display_id: Writable<string | null> = writable<string | null>(null);
|
export const pinned_display_id: Writable<string | null> = writable<string | null>(null);
|
||||||
|
|
||||||
export function change_height(key: 'display' | 'file', factor: number) {
|
export function change_height(key: 'display' | 'file', factor: number) {
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ export type FileLoadingData = {
|
|||||||
seconds_until_finish: number;
|
seconds_until_finish: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type CompleteFileLoadingData = {
|
||||||
|
is_loading: boolean;
|
||||||
|
total_percentage: number;
|
||||||
|
total_seconds_until_finish: number;
|
||||||
|
display_data: { loading_data: FileLoadingData; display_name: string }[];
|
||||||
|
};
|
||||||
|
|
||||||
export type Inode = {
|
export type Inode = {
|
||||||
path: string;
|
path: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -134,6 +141,13 @@ export type PopupContent = {
|
|||||||
closable?: boolean;
|
closable?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type NumberSetting = {
|
||||||
|
max: number,
|
||||||
|
min: number,
|
||||||
|
now: number,
|
||||||
|
step: number
|
||||||
|
}
|
||||||
|
|
||||||
export type DisplayStatus = 'host_offline' | 'app_offline' | 'app_online' | null;
|
export type DisplayStatus = 'host_offline' | 'app_offline' | 'app_online' | null;
|
||||||
|
|
||||||
export function to_display_status(value: string): DisplayStatus {
|
export function to_display_status(value: string): DisplayStatus {
|
||||||
|
|||||||
@@ -1,25 +1,42 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Monitor, Plus, Radio, Settings, Trash2, Menu } from 'lucide-svelte';
|
import {
|
||||||
|
Monitor,
|
||||||
|
Plus,
|
||||||
|
Radio,
|
||||||
|
Settings,
|
||||||
|
Trash2,
|
||||||
|
Menu,
|
||||||
|
ChevronDown,
|
||||||
|
icons,
|
||||||
|
SquareCheckBig,
|
||||||
|
Square,
|
||||||
|
X,
|
||||||
|
Info
|
||||||
|
} from 'lucide-svelte';
|
||||||
import Button from '$lib/components/Button.svelte';
|
import Button from '$lib/components/Button.svelte';
|
||||||
import FileView from './FileView.svelte';
|
import FileView from './FileView.svelte';
|
||||||
import ControlView from './ControlView.svelte';
|
import ControlView from './ControlView.svelte';
|
||||||
import DisplayView from './DisplayView.svelte';
|
import DisplayView from './DisplayView.svelte';
|
||||||
import PopUp from '$lib/components/PopUp.svelte';
|
import PopUp from '$lib/components/PopUp.svelte';
|
||||||
import { type PopupContent } from '$lib/ts/types';
|
import { type Display, type PopupContent } from '$lib/ts/types';
|
||||||
import TextInput from '$lib/components/TextInput.svelte';
|
import TextInput from '$lib/components/TextInput.svelte';
|
||||||
import {
|
import {
|
||||||
add_display,
|
add_display,
|
||||||
edit_display_data,
|
edit_display_data,
|
||||||
get_display_by_id,
|
get_display_by_id,
|
||||||
is_display_name_taken,
|
is_display_name_taken,
|
||||||
remove_display
|
remove_display,
|
||||||
|
screenshot_loop
|
||||||
} from '$lib/ts/stores/displays';
|
} from '$lib/ts/stores/displays';
|
||||||
import { notifications } from '$lib/ts/stores/notification';
|
import { notifications } from '$lib/ts/stores/notification';
|
||||||
import { ping_ip } from '$lib/ts/api_handler';
|
import { ping_ip } from '$lib/ts/api_handler';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { on_start } from '$lib/ts/main';
|
import { on_app_start, update_display_status } from '$lib/ts/main';
|
||||||
import { display_status_to_info } from '$lib/ts/utils';
|
import { display_status_to_info } from '$lib/ts/utils';
|
||||||
import HighlightedText from '$lib/components/HighlightedText.svelte';
|
import HighlightedText from '$lib/components/HighlightedText.svelte';
|
||||||
|
import { preview_settings } from '$lib/ts/stores/ui_behavior';
|
||||||
|
import NumberSettingInput from '$lib/components/NumberSettingInput.svelte';
|
||||||
|
import { db } from '$lib/ts/database';
|
||||||
|
|
||||||
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))$/;
|
||||||
@@ -55,11 +72,40 @@
|
|||||||
const ip = text_inputs_valid.ip.value;
|
const ip = text_inputs_valid.ip.value;
|
||||||
const mac = text_inputs_valid.mac.value === '' ? null : text_inputs_valid.mac.value;
|
const mac = text_inputs_valid.mac.value === '' ? null : text_inputs_valid.mac.value;
|
||||||
const name = text_inputs_valid.name.value;
|
const name = text_inputs_valid.name.value;
|
||||||
|
let display: Display | null = null;
|
||||||
if (!!existing_display_id) {
|
if (!!existing_display_id) {
|
||||||
await edit_display_data(existing_display_id, ip, mac, name);
|
display = await edit_display_data(existing_display_id, ip, mac, name);
|
||||||
} else {
|
} else {
|
||||||
const status = await ping_ip(text_inputs_valid.ip.value);
|
const status = await ping_ip(text_inputs_valid.ip.value);
|
||||||
await add_display(ip, mac, name, status);
|
display = await add_display(ip, mac, name, status);
|
||||||
|
}
|
||||||
|
if (!!display) {
|
||||||
|
await update_display_status(display);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_display_preview_mode(mode: 'never' | 'normal' | 'always') {
|
||||||
|
switch (mode) {
|
||||||
|
case 'never':
|
||||||
|
return 'Nie';
|
||||||
|
case 'normal':
|
||||||
|
return 'Normal';
|
||||||
|
case 'always':
|
||||||
|
return 'Dauerhaft';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function change_preview_mode(mode: 'never' | 'normal' | 'always') {
|
||||||
|
$preview_settings.mode = mode;
|
||||||
|
if (mode === 'never') {
|
||||||
|
await db.displays
|
||||||
|
.toCollection()
|
||||||
|
.modify({ preview: { currently_updating: false, url: null } });
|
||||||
|
} else {
|
||||||
|
const display_ids = (await db.displays.toArray()).map((d) => d.id);
|
||||||
|
for (const display_id of display_ids) {
|
||||||
|
screenshot_loop(display_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +118,7 @@
|
|||||||
popup_content = {
|
popup_content = {
|
||||||
open: true,
|
open: true,
|
||||||
snippet: display_popup,
|
snippet: display_popup,
|
||||||
title: 'Neuen Bildschirm hinzufügen',
|
title: 'Neuen Bildschirm Hinzufügen',
|
||||||
title_icon: Monitor,
|
title_icon: Monitor,
|
||||||
title_class: '!text-xl',
|
title_class: '!text-xl',
|
||||||
window_class: 'w-3xl',
|
window_class: 'w-3xl',
|
||||||
@@ -80,6 +126,18 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const show_settings_popup = () => {
|
||||||
|
popup_content = {
|
||||||
|
open: true,
|
||||||
|
snippet: settings_popup,
|
||||||
|
title: 'Einstellungen',
|
||||||
|
title_icon: Settings,
|
||||||
|
title_class: '!text-xl',
|
||||||
|
window_class: 'w-3xl',
|
||||||
|
closable: true
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const show_remove_display_popup = async (display_id: string) => {
|
const show_remove_display_popup = async (display_id: string) => {
|
||||||
remove_display_name = (await get_display_by_id(display_id))?.name || '?';
|
remove_display_name = (await get_display_by_id(display_id))?.name || '?';
|
||||||
popup_content = {
|
popup_content = {
|
||||||
@@ -112,9 +170,63 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
onMount(on_start);
|
onMount(on_app_start);
|
||||||
|
|
||||||
|
const show_about_popup = () => {
|
||||||
|
popup_content = {
|
||||||
|
open: true,
|
||||||
|
snippet: about_popup,
|
||||||
|
title: 'Über PLG MuDiCS',
|
||||||
|
title_icon: Info,
|
||||||
|
title_class: '!text-xl',
|
||||||
|
closable: true
|
||||||
|
};
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{#snippet about_popup(_: string)}
|
||||||
|
<div class="px-2">
|
||||||
|
<h3 class="text-lg font-bold mt-4">Entwickler</h3>
|
||||||
|
<p>
|
||||||
|
<a target="_blank" class="link" href="https://github.com/programmer-44">E44</a>
|
||||||
|
<a target="_blank" class="link" href="https://codeberg.org/2mal3">2mal3</a>,
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h3 class="text-lg font-bold mt-4">Lizenz</h3>
|
||||||
|
<a
|
||||||
|
target="_blank"
|
||||||
|
class="link"
|
||||||
|
href="https://github.com/PLG-Development/PLG-MuDiCS/blob/main/LICENSE.txt"
|
||||||
|
>
|
||||||
|
GNU Affero General Public License v3 (AGPL-3.0)
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<h3 class="text-lg font-bold mt-4">Verwendete Bibliotheken</h3>
|
||||||
|
<ul class="list-disc list-inside">
|
||||||
|
<li><a target="_blank" href="https://svelte.dev/" class="link">Svelte & SvelteKit</a></li>
|
||||||
|
<li><a target="_blank" href="https://tailwindcss.com/" class="link">TailwindCSS</a></li>
|
||||||
|
<li><a target="_blank" href="https://lucide.dev/" class="link">Lucide Icons</a></li>
|
||||||
|
<li><a target="_blank" href="https://tiptap.dev/" class="link">Tiptap</a></li>
|
||||||
|
<li><a target="_blank" href="https://dexie.org/" class="link">Dexie.js</a></li>
|
||||||
|
<li>
|
||||||
|
<a target="_blank" href="https://github.com/orefalo/svelte-splitpanes" class="link"
|
||||||
|
>svelte-splitpanes</a
|
||||||
|
>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a target="_blank" href="https://github.com/thisux/sveltednd" class="link"
|
||||||
|
>@thisux/sveltednd</a
|
||||||
|
>
|
||||||
|
</li>
|
||||||
|
<li><a target="_blank" href="https://echo.labstack.com/" class="link">Echo</a></li>
|
||||||
|
<li><a target="_blank" href="https://github.com/mdlayher/wol" class="link">wol</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end pt-2">
|
||||||
|
<Button click_function={popup_close_function} className="px-4">Schließen</Button>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
{#snippet remove_display_popup(display_id: string)}
|
{#snippet remove_display_popup(display_id: string)}
|
||||||
<div class="max-w-prose px-2">
|
<div class="max-w-prose px-2">
|
||||||
Soll der Bildschirm <HighlightedText>{remove_display_name}</HighlightedText> wirklich gelöscht werden?
|
Soll der Bildschirm <HighlightedText>{remove_display_name}</HighlightedText> wirklich gelöscht werden?
|
||||||
@@ -221,6 +333,52 @@
|
|||||||
</div>
|
</div>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
|
{#snippet settings_popup()}
|
||||||
|
<div class="flex flex-col gap-2 pl-1">
|
||||||
|
<span class="font-bold text-lg">Vorschau-Verhalten</span>
|
||||||
|
<div class="flex flex-col gap-2 ml-2">
|
||||||
|
<span class="text-stone-400 text-sm max-w-prose"
|
||||||
|
>Die Vorschau eines Bildschirms ist das Bild, welches links neben dem Display-Namen zu sehen
|
||||||
|
ist. Es zeigt relativ aktuell das an, was auf dem jeweiligen Bildschirm zu sehen ist.</span
|
||||||
|
>
|
||||||
|
<div class="flex flex-row justify-between items-center">
|
||||||
|
<span>Aktualisierungs-Verhalten</span>
|
||||||
|
<Button
|
||||||
|
className="gap-3 pl-4 pr-3 w-35"
|
||||||
|
menu_options={(['never', 'normal', 'always'] as const).map((mode) => ({
|
||||||
|
icon: mode === $preview_settings.mode ? SquareCheckBig : Square,
|
||||||
|
name: get_display_preview_mode(mode),
|
||||||
|
on_select: async () => await change_preview_mode(mode)
|
||||||
|
}))}>{get_display_preview_mode($preview_settings.mode)} <ChevronDown /></Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row justify-between items-center">
|
||||||
|
<span>Intervall zwischen den Aktualisierungs-Anfragen</span>
|
||||||
|
<NumberSettingInput
|
||||||
|
disabled={$preview_settings.mode === 'never'}
|
||||||
|
number_setting={$preview_settings.retry_seconds}
|
||||||
|
on_change={(new_value: number) => {
|
||||||
|
$preview_settings.retry_seconds.now = new_value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row justify-between items-center max-w-full gap-8">
|
||||||
|
<span class="">Anzahl der änderungslosen Aktualisierungen bis pausiert wird</span>
|
||||||
|
<NumberSettingInput
|
||||||
|
disabled={$preview_settings.mode !== 'normal'}
|
||||||
|
number_setting={$preview_settings.retry_count}
|
||||||
|
on_change={(new_value: number) => {
|
||||||
|
$preview_settings.retry_count.now = new_value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-end pt-4">
|
||||||
|
<Button click_function={popup_close_function} className="px-4">Schließen</Button>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
<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]">
|
||||||
<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>
|
||||||
@@ -230,8 +388,18 @@
|
|||||||
menu_options={[
|
menu_options={[
|
||||||
{
|
{
|
||||||
icon: Plus,
|
icon: Plus,
|
||||||
name: 'Neuen Bildschirm hinzufügen',
|
name: 'Neuen Bildschirm Hinzufügen',
|
||||||
on_select: show_new_display_popup
|
on_select: show_new_display_popup
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: Settings,
|
||||||
|
name: 'Einstellungen',
|
||||||
|
on_select: show_settings_popup
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: Info,
|
||||||
|
name: 'Über',
|
||||||
|
on_select: show_about_popup
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -9,18 +9,31 @@
|
|||||||
Presentation,
|
Presentation,
|
||||||
SquareTerminal,
|
SquareTerminal,
|
||||||
TextAlignStart,
|
TextAlignStart,
|
||||||
TrafficCone
|
TrafficCone,
|
||||||
|
Globe
|
||||||
} from 'lucide-svelte';
|
} from 'lucide-svelte';
|
||||||
import Button from '$lib/components/Button.svelte';
|
import Button from '$lib/components/Button.svelte';
|
||||||
import PopUp from '$lib/components/PopUp.svelte';
|
import PopUp from '$lib/components/PopUp.svelte';
|
||||||
import type { PopupContent } from '$lib/ts/types';
|
import type { PopupContent } from '$lib/ts/types';
|
||||||
import KeyInput from './KeyInput.svelte';
|
import KeyInput from './KeyInput.svelte';
|
||||||
import { send_keyboard_input, show_blackscreen, shutdown, startup } from '$lib/ts/api_handler';
|
import {
|
||||||
import { get_display_by_id, run_on_all_selected_displays } from '$lib/ts/stores/displays';
|
send_keyboard_input,
|
||||||
|
show_blackscreen,
|
||||||
|
shutdown,
|
||||||
|
startup,
|
||||||
|
show_html
|
||||||
|
} from '$lib/ts/api_handler';
|
||||||
|
import {
|
||||||
|
get_display_by_id,
|
||||||
|
no_active_display_selected,
|
||||||
|
online_displays,
|
||||||
|
run_on_all_selected_displays
|
||||||
|
} from '$lib/ts/stores/displays';
|
||||||
import { selected_display_ids } from '$lib/ts/stores/select';
|
import { selected_display_ids } from '$lib/ts/stores/select';
|
||||||
import TipTapInput from './TipTapInput.svelte';
|
import TipTapInput from './TipTapInput.svelte';
|
||||||
import { db } from '$lib/ts/database';
|
import { db } from '$lib/ts/database';
|
||||||
import { liveQuery, type Observable } from 'dexie';
|
import { liveQuery, type Observable } from 'dexie';
|
||||||
|
import TextInput from '$lib/components/TextInput.svelte';
|
||||||
|
|
||||||
let all_display_states: Observable<'on' | 'off' | 'mixed'> | undefined = $state();
|
let all_display_states: Observable<'on' | 'off' | 'mixed'> | undefined = $state();
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
@@ -43,7 +56,7 @@
|
|||||||
popup_content = {
|
popup_content = {
|
||||||
open: true,
|
open: true,
|
||||||
snippet: send_keys_popup,
|
snippet: send_keys_popup,
|
||||||
title: 'Tastatur-Eingaben durchgeben',
|
title: 'Tastatur-Eingaben Senden',
|
||||||
title_icon: Keyboard,
|
title_icon: Keyboard,
|
||||||
closable: true
|
closable: true
|
||||||
};
|
};
|
||||||
@@ -53,13 +66,24 @@
|
|||||||
popup_content = {
|
popup_content = {
|
||||||
open: true,
|
open: true,
|
||||||
snippet: text_popup,
|
snippet: text_popup,
|
||||||
title: 'Text anzeigen',
|
title: 'Text Anzeigen',
|
||||||
title_icon: TextAlignStart,
|
title_icon: TextAlignStart,
|
||||||
closable: true,
|
closable: true,
|
||||||
window_class: 'size-full'
|
window_class: 'size-full'
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const show_website_popup = () => {
|
||||||
|
popup_content = {
|
||||||
|
open: true,
|
||||||
|
snippet: website_popup,
|
||||||
|
title: 'Webseite Anzeigen',
|
||||||
|
window_class: 'w-xl',
|
||||||
|
title_icon: Globe,
|
||||||
|
closable: true
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
async function all_state(selected_display_ids: string[]): Promise<'on' | 'off' | 'mixed'> {
|
async function all_state(selected_display_ids: string[]): Promise<'on' | 'off' | 'mixed'> {
|
||||||
const selected_displays = await Promise.all(
|
const selected_displays = await Promise.all(
|
||||||
selected_display_ids.map(async (id) => await get_display_by_id(id))
|
selected_display_ids.map(async (id) => await get_display_by_id(id))
|
||||||
@@ -74,11 +98,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ask_shutdonw() {
|
async function ask_shutdown() {
|
||||||
popup_content = {
|
popup_content = {
|
||||||
open: true,
|
open: true,
|
||||||
snippet: ask_shutdonw_popup,
|
snippet: ask_shutdown_popup,
|
||||||
title: 'PC Herunterfahren',
|
title: 'Bildschirm Herunterfahren',
|
||||||
title_icon: PowerOff,
|
title_icon: PowerOff,
|
||||||
closable: true
|
closable: true
|
||||||
};
|
};
|
||||||
@@ -88,7 +112,7 @@
|
|||||||
popup_content.open = false;
|
popup_content.open = false;
|
||||||
await run_on_all_selected_displays((d) => {
|
await run_on_all_selected_displays((d) => {
|
||||||
shutdown(d.ip); // no await here because we want to be fast
|
shutdown(d.ip); // no await here because we want to be fast
|
||||||
db.displays.update(d.id, { status: 'app_offline' });
|
db.displays.update(d.id, { status: 'app_offline', preview: { currently_updating: false, url: null} });
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,9 +140,52 @@
|
|||||||
10
|
10
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
let website_url = $state('');
|
||||||
|
let website_url_valid = $state(false);
|
||||||
|
|
||||||
|
function validate_website_url(url: string): [boolean, string] {
|
||||||
|
if (url === '') return [true, ''];
|
||||||
|
const regex = /^https?:\/\/[\w\-]+(\.[\w\-]+)+([\w\-\._~:/?#\[\]@!$&'\(\)\*\+,;=.])*/;
|
||||||
|
if (regex.test(url)) {
|
||||||
|
return [true, ''];
|
||||||
|
}
|
||||||
|
return [false, 'Ungültige URL'];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function send_website() {
|
||||||
|
popup_content.open = false;
|
||||||
|
await run_on_all_selected_displays((d) =>
|
||||||
|
show_html(d.ip, `<iframe src="${website_url}"></iframe>`)
|
||||||
|
);
|
||||||
|
website_url = '';
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#snippet ask_shutdonw_popup()}
|
{#snippet website_popup()}
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
<TextInput
|
||||||
|
title="URL (mit http:// oder https://)"
|
||||||
|
placeholder="https://example.com"
|
||||||
|
bind:current_value={website_url}
|
||||||
|
bind:current_valid={website_url_valid}
|
||||||
|
is_valid_function={validate_website_url}
|
||||||
|
enter_mode="submit"
|
||||||
|
enter_function={send_website}
|
||||||
|
/>
|
||||||
|
<div class="flex flex-row justify-end gap-2">
|
||||||
|
<Button className="button space font-bold" click_function={popup_close_function}>
|
||||||
|
Abbrechen
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
click_function={send_website}
|
||||||
|
disabled={!website_url_valid || website_url === ''}
|
||||||
|
className="button success space">Anzeigen</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
{#snippet ask_shutdown_popup()}
|
||||||
<p>Bist du sicher, dass du alle ausgewählten Displays herunterfahren möchtest?</p>
|
<p>Bist du sicher, dass du alle ausgewählten Displays herunterfahren möchtest?</p>
|
||||||
|
|
||||||
<div class="flex flex-row justify-end gap-2">
|
<div class="flex flex-row justify-end gap-2">
|
||||||
@@ -146,7 +213,7 @@
|
|||||||
|
|
||||||
<div class="grid grid-rows-[2.5rem_auto] bg-stone-800 rounded-2xl min-w-0">
|
<div class="grid grid-rows-[2.5rem_auto] bg-stone-800 rounded-2xl min-w-0">
|
||||||
<div class="text-xl font-bold pl-3 content-center bg-stone-700 rounded-t-2xl truncate min-w-0">
|
<div class="text-xl font-bold pl-3 content-center bg-stone-700 rounded-t-2xl truncate min-w-0">
|
||||||
Bildschirme steuern
|
Bildschirme Steuern
|
||||||
</div>
|
</div>
|
||||||
<div class="relative flex flex-col gap-2 p-2 overflow-auto">
|
<div class="relative flex flex-col gap-2 p-2 overflow-auto">
|
||||||
<div class="flex flex-row justify-between gap-2">
|
<div class="flex flex-row justify-between gap-2">
|
||||||
@@ -155,7 +222,7 @@
|
|||||||
<Button
|
<Button
|
||||||
title="Vorherige Folie (Pfeil nach Links)"
|
title="Vorherige Folie (Pfeil nach Links)"
|
||||||
className="px-9"
|
className="px-9"
|
||||||
disabled={$selected_display_ids.length === 0}
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
click_function={async () => {
|
click_function={async () => {
|
||||||
await send_single_key_press('VK_LEFT');
|
await send_single_key_press('VK_LEFT');
|
||||||
}}><ArrowBigLeft /></Button
|
}}><ArrowBigLeft /></Button
|
||||||
@@ -163,7 +230,7 @@
|
|||||||
<Button
|
<Button
|
||||||
title="Nächste Folie (Pfeil nach Rechts)"
|
title="Nächste Folie (Pfeil nach Rechts)"
|
||||||
className="px-9"
|
className="px-9"
|
||||||
disabled={$selected_display_ids.length === 0}
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
click_function={async () => {
|
click_function={async () => {
|
||||||
await send_single_key_press('VK_RIGHT');
|
await send_single_key_press('VK_RIGHT');
|
||||||
}}><ArrowBigRight /></Button
|
}}><ArrowBigRight /></Button
|
||||||
@@ -172,13 +239,20 @@
|
|||||||
|
|
||||||
<Button
|
<Button
|
||||||
className="px-3 flex gap-3 w-75 justify-normal"
|
className="px-3 flex gap-3 w-75 justify-normal"
|
||||||
disabled={$selected_display_ids.length === 0}
|
click_function={show_text_popup}
|
||||||
click_function={show_text_popup}><TextAlignStart /> Text anzeigen</Button
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
|
><TextAlignStart /> Text Anzeigen</Button
|
||||||
>
|
>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className="px-3 flex gap-3 w-75 justify-normal"
|
className="px-3 flex gap-3 w-75 justify-normal"
|
||||||
disabled={$selected_display_ids.length === 0}
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
|
click_function={show_website_popup}><Globe /> Webseite Anzeigen</Button
|
||||||
|
>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
className="px-3 flex gap-3 w-75 justify-normal"
|
||||||
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
click_function={async () => {
|
click_function={async () => {
|
||||||
await run_on_all_selected_displays((d) => show_blackscreen(d.ip));
|
await run_on_all_selected_displays((d) => show_blackscreen(d.ip));
|
||||||
}}><Presentation />Blackout</Button
|
}}><Presentation />Blackout</Button
|
||||||
@@ -186,38 +260,40 @@
|
|||||||
|
|
||||||
<div class="flex flex-row justify-normal">
|
<div class="flex flex-row justify-normal">
|
||||||
<Button className="rounded-r-none pl-3 flex gap-3 grow w-65 justify-normal" disabled>
|
<Button className="rounded-r-none pl-3 flex gap-3 grow w-65 justify-normal" disabled>
|
||||||
<TrafficCone /> Fallback-Bild anzeigen
|
<TrafficCone /> Fallback-Bild Anzeigen
|
||||||
</Button>
|
</Button>
|
||||||
<Button className="rounded-l-none flex grow-0 w-10" disabled><ChevronDown /></Button>
|
<Button className="rounded-l-none flex grow-0 w-10" disabled><ChevronDown /></Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className="px-3 flex gap-3 w-75 justify-normal"
|
className="px-3 flex gap-3 w-75 justify-normal"
|
||||||
disabled={$selected_display_ids.length === 0}
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
click_function={show_send_keys_popup}><Keyboard /> Tastatur-Eingaben durchgeben</Button
|
click_function={show_send_keys_popup}><Keyboard /> Tastatur-Eingaben Senden</Button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-2 justify-between">
|
<div class="flex flex-col gap-2 justify-between">
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<Button
|
<Button
|
||||||
className="px-3 flex gap-3 w-full xl:w-75 justify-normal"
|
className="px-3 flex gap-3 w-full xl:w-75 justify-normal"
|
||||||
disabled={$all_display_states === 'on' || $selected_display_ids.length === 0}
|
disabled={$all_display_states === 'on' ||
|
||||||
|
no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
click_function={startup_action}
|
click_function={startup_action}
|
||||||
>
|
>
|
||||||
<Power /> PC hochfahren
|
<Power /> Bildschirm Hochfahren
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className="px-3 flex gap-3 w-full xl:w-75 justify-normal"
|
className="px-3 flex gap-3 w-full xl:w-75 justify-normal"
|
||||||
disabled={$all_display_states === 'off' || $selected_display_ids.length === 0}
|
disabled={$all_display_states === 'off' ||
|
||||||
click_function={ask_shutdonw}
|
no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
|
click_function={ask_shutdown}
|
||||||
>
|
>
|
||||||
<PowerOff /> PC herunterfahren</Button
|
<PowerOff /> Bildschirm Herunterfahren</Button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<Button className="px-3 flex gap-3 w-full xl:w-75 justify-normal" disabled>
|
<Button className="px-3 flex gap-3 w-full xl:w-75 justify-normal" disabled>
|
||||||
<SquareTerminal />
|
<SquareTerminal />
|
||||||
Shell-Befehl ausführen
|
Shell-Befehl Ausführen
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -218,7 +218,7 @@
|
|||||||
class="min-w-40 px-4 rounded-xl cursor-pointer duration-200 transition-colors bg-stone-600"
|
class="min-w-40 px-4 rounded-xl cursor-pointer duration-200 transition-colors bg-stone-600"
|
||||||
onclick={async () => await toggle_all_selected_displays($display_groups)}
|
onclick={async () => await toggle_all_selected_displays($display_groups)}
|
||||||
>
|
>
|
||||||
<span>{$all_groups_selected || false ? 'Alle abwählen' : 'Alle auswählen'}</span>
|
<span>{$all_groups_selected || false ? 'Alle Abwählen' : 'Alle Auswählen'}</span>
|
||||||
</button>
|
</button>
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -17,11 +17,11 @@
|
|||||||
import { selected_display_ids, selected_file_ids } from '$lib/ts/stores/select';
|
import { selected_display_ids, selected_file_ids } from '$lib/ts/stores/select';
|
||||||
import {
|
import {
|
||||||
current_file_path,
|
current_file_path,
|
||||||
get_current_folder_elements,
|
get_folder_elements,
|
||||||
get_file_by_id,
|
get_file_by_id,
|
||||||
run_for_selected_files_on_selected_displays,
|
run_for_selected_files_on_selected_displays,
|
||||||
update_current_folder_on_selected_displays,
|
update_current_folder_on_selected_displays,
|
||||||
get_displays_where_path_exists,
|
get_displays_where_path_not_exists,
|
||||||
create_folder_on_all_selected_displays
|
create_folder_on_all_selected_displays
|
||||||
} from '$lib/ts/stores/files';
|
} from '$lib/ts/stores/files';
|
||||||
import { slide } from 'svelte/transition';
|
import { slide } from 'svelte/transition';
|
||||||
@@ -37,7 +37,8 @@
|
|||||||
import { delete_files, rename_file } from '$lib/ts/api_handler';
|
import { delete_files, rename_file } from '$lib/ts/api_handler';
|
||||||
import HighlightedText from '$lib/components/HighlightedText.svelte';
|
import HighlightedText from '$lib/components/HighlightedText.svelte';
|
||||||
import { liveQuery, type Observable } from 'dexie';
|
import { liveQuery, type Observable } from 'dexie';
|
||||||
import { download_file, add_upload } from '$lib/ts/file_transfer_handler';
|
import { download_file, add_upload, add_sync_recursively } from '$lib/ts/file_transfer_handler';
|
||||||
|
import { no_active_display_selected, online_displays } from '$lib/ts/stores/displays';
|
||||||
|
|
||||||
let current_name: string = $state('');
|
let current_name: string = $state('');
|
||||||
let current_valid: boolean = $state(false);
|
let current_valid: boolean = $state(false);
|
||||||
@@ -52,15 +53,15 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
const path = $current_file_path,
|
const path = $current_file_path,
|
||||||
display_ids = $selected_display_ids;
|
display_ids = $selected_display_ids;
|
||||||
current_folder_elements = liveQuery(() => get_current_folder_elements(path, display_ids));
|
current_folder_elements = liveQuery(() => get_folder_elements(path, display_ids));
|
||||||
});
|
});
|
||||||
let one_file_selected: Observable<boolean> | undefined = $state();
|
let one_file_selected: Observable<boolean> | undefined = $state();
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
const s = $selected_file_ids;
|
const s = $selected_file_ids;
|
||||||
one_file_selected = liveQuery(async () => {
|
one_file_selected = liveQuery(async () => {
|
||||||
return s.length === 1 && (await get_file_by_id(s[0]))?.type !== 'inode/directory';
|
return s.length === 1 && (await get_file_by_id(s[0]))?.type !== 'inode/directory';
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
let popup_content: PopupContent = $state({
|
let popup_content: PopupContent = $state({
|
||||||
open: false,
|
open: false,
|
||||||
@@ -128,7 +129,7 @@
|
|||||||
current_name = '';
|
current_name = '';
|
||||||
current_valid = false;
|
current_valid = false;
|
||||||
display_names_where_path_does_not_exist = (
|
display_names_where_path_does_not_exist = (
|
||||||
await get_displays_where_path_exists($current_file_path, $selected_display_ids, true)
|
await get_displays_where_path_not_exists($current_file_path, $selected_display_ids)
|
||||||
).map((display) => display.name);
|
).map((display) => display.name);
|
||||||
popup_content = {
|
popup_content = {
|
||||||
open: true,
|
open: true,
|
||||||
@@ -148,6 +149,21 @@
|
|||||||
closable: true
|
closable: true
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function sync_selected_files(
|
||||||
|
selected_file_ids: string[],
|
||||||
|
selected_display_ids: string[],
|
||||||
|
current_folder_elements: Inode[]
|
||||||
|
) {
|
||||||
|
if (selected_file_ids.length === 0 && current_folder_elements.length > 0) {
|
||||||
|
selected_file_ids = current_folder_elements.map((inode) => get_file_primary_key(inode));
|
||||||
|
}
|
||||||
|
if (selected_file_ids.length === 0) return;
|
||||||
|
// Mit For-Schleife über ausgewählte Elemente gehen
|
||||||
|
for (const file_id of selected_file_ids) {
|
||||||
|
await add_sync_recursively(file_id, selected_display_ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#snippet new_folder_popup()}
|
{#snippet new_folder_popup()}
|
||||||
@@ -232,7 +248,7 @@
|
|||||||
<span class="text-stone-400 px-1"
|
<span class="text-stone-400 px-1"
|
||||||
>{`${$selected_file_ids.length === 1 ? 'Folgendes Objekt' : `Folgende ${$selected_file_ids.length} Objekte`} löschen? (Wiederherstellung nicht möglich)`}</span
|
>{`${$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-auto h-full min-h-0 grow-0">
|
<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}
|
||||||
<InodeElement {file} not_interactable />
|
<InodeElement {file} not_interactable />
|
||||||
{/each}
|
{/each}
|
||||||
@@ -270,7 +286,7 @@
|
|||||||
<div class="bg-stone-800 h-full rounded-2xl grid grid-rows-[2.5rem_1fr] min-h-0">
|
<div class="bg-stone-800 h-full rounded-2xl grid grid-rows-[2.5rem_1fr] min-h-0">
|
||||||
<div class="bg-stone-700 flex justify-between w-full p-1 rounded-t-2xl min-w-0 gap-2">
|
<div class="bg-stone-700 flex justify-between w-full p-1 rounded-t-2xl min-w-0 gap-2">
|
||||||
<span class="text-xl font-bold pl-2 content-center truncate min-w-0">
|
<span class="text-xl font-bold pl-2 content-center truncate min-w-0">
|
||||||
Dateien anzeigen und verwalten
|
Dateien Anzeigen und Verwalten
|
||||||
</span>
|
</span>
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<Button
|
<Button
|
||||||
@@ -306,7 +322,7 @@
|
|||||||
title="Neuen Ordner erstellen (Neuen Ordner mit ausgewählten Objekten erstellen)"
|
title="Neuen Ordner erstellen (Neuen Ordner mit ausgewählten Objekten erstellen)"
|
||||||
className="px-3 flex"
|
className="px-3 flex"
|
||||||
click_function={show_new_folder_popup}
|
click_function={show_new_folder_popup}
|
||||||
disabled={$selected_display_ids.length === 0}><FolderPlus /></Button
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}><FolderPlus /></Button
|
||||||
>
|
>
|
||||||
<div class="border border-stone-700 my-1"></div>
|
<div class="border border-stone-700 my-1"></div>
|
||||||
<Button
|
<Button
|
||||||
@@ -315,19 +331,26 @@
|
|||||||
click_function={() => {
|
click_function={() => {
|
||||||
if (file_input) file_input.click();
|
if (file_input) file_input.click();
|
||||||
}}
|
}}
|
||||||
disabled={$selected_display_ids.length === 0}><Upload /></Button
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}><Upload /></Button
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
title="Ausgewählte Datei herunterladen"
|
title="Ausgewählte Datei herunterladen"
|
||||||
className="px-3 flex"
|
className="px-3 flex"
|
||||||
click_function={() => (download_file($selected_file_ids[0], $selected_display_ids))}
|
click_function={async () =>
|
||||||
|
await download_file($selected_file_ids[0], $selected_display_ids)}
|
||||||
disabled={!$one_file_selected}><Download /></Button
|
disabled={!$one_file_selected}><Download /></Button
|
||||||
>
|
>
|
||||||
<div class="border border-stone-700 my-1"></div>
|
<div class="border border-stone-700 my-1"></div>
|
||||||
<Button
|
<Button
|
||||||
title="Aktuellen Ordner / Ausgewählte Datei(en) zwischen Bildschirmen synchronisieren"
|
title="Aktuellen Ordner / Ausgewählte Datei(en) zwischen Bildschirmen synchronisieren"
|
||||||
className="px-3 flex gap-3"
|
className="px-3 flex gap-3"
|
||||||
disabled={$selected_display_ids.length === 0}
|
click_function={async () =>
|
||||||
|
await sync_selected_files(
|
||||||
|
$selected_file_ids,
|
||||||
|
$selected_display_ids,
|
||||||
|
$current_folder_elements ?? []
|
||||||
|
)}
|
||||||
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
><RefreshCcw />
|
><RefreshCcw />
|
||||||
<span class="hidden 2xl:flex">Synchronisieren</span>
|
<span class="hidden 2xl:flex">Synchronisieren</span>
|
||||||
</Button>
|
</Button>
|
||||||
@@ -341,7 +364,7 @@
|
|||||||
<Button
|
<Button
|
||||||
title="Ausgewählte Datei(en) einfügen"
|
title="Ausgewählte Datei(en) einfügen"
|
||||||
className="px-3 flex"
|
className="px-3 flex"
|
||||||
disabled={$selected_display_ids.length === 0}
|
disabled={no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
>
|
>
|
||||||
<ClipboardPaste />
|
<ClipboardPaste />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -365,7 +388,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="min-h-0 h-full overflow-y-auto overflow-x-hidden bg-stone-750 rounded-xl">
|
<div class="min-h-0 h-full overflow-y-auto overflow-x-hidden bg-stone-750 rounded-xl">
|
||||||
<div class="flex flex-col gap-2 p-2 min-h-0 max-w-full">
|
<div class="flex flex-col gap-2 p-2 min-h-0 max-w-full">
|
||||||
{#if $selected_display_ids.length === 0}
|
{#if no_active_display_selected($selected_display_ids, $online_displays)}
|
||||||
<span class="text-stone-450 px-10 py-6 leading-relaxed text-center">
|
<span class="text-stone-450 px-10 py-6 leading-relaxed text-center">
|
||||||
Es sind keine Bildschirme ausgewählt.
|
Es sind keine Bildschirme ausgewählt.
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -210,7 +210,7 @@
|
|||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button click_function={show_text} className="w-full font-bold">Text anzeigen</Button>
|
<Button click_function={show_text} className="w-full font-bold">Text Anzeigen</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
err = shared.OpenBrowserWindow("http://localhost:"+port, false)
|
err = shared.OpenBrowserWindow("http://localhost:"+port, false, "control")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to open browser window", "error", err)
|
slog.Error("Failed to open browser window", "error", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ func main() {
|
|||||||
// the order is important, the open browser command exitsts as soon as the winodw is closed
|
// the order is important, the open browser command exitsts as soon as the winodw is closed
|
||||||
// and since its the last action in the main go func all other goroutines (e.g. the webserver) are killed
|
// and since its the last action in the main go func all other goroutines (e.g. the webserver) are killed
|
||||||
go web.StartWebServer(shared.Version, port)
|
go web.StartWebServer(shared.Version, port)
|
||||||
err = shared.OpenBrowserWindow("http://localhost:"+port, true)
|
err = shared.OpenBrowserWindow("http://localhost:"+port, true, "display")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to open browser window", "error", err)
|
slog.Error("Failed to open browser window", "error", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -8,19 +8,25 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func OpenBrowserWindow(url string, fullscreen bool) error {
|
func OpenBrowserWindow(url string, fullscreen bool, profile string) error {
|
||||||
bins := []string{"chromium", "chromium-browser"}
|
bins := []string{"chromium", "chromium-browser"}
|
||||||
|
|
||||||
home, err := os.UserHomeDir()
|
home, err := os.UserHomeDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to determine user home directory: %w", err)
|
return fmt.Errorf("unable to determine user home directory: %w", err)
|
||||||
}
|
}
|
||||||
browserProfileDirPath := filepath.Join(home, ".local", "share", "plg-mudics", "browser")
|
browserProfileDirPath := filepath.Join(home, ".local", "share", "plg-mudics", fmt.Sprintf("browser-%s", profile))
|
||||||
if err := os.MkdirAll(browserProfileDirPath, os.ModePerm); err != nil {
|
if err := os.MkdirAll(browserProfileDirPath, os.ModePerm); err != nil {
|
||||||
return fmt.Errorf("failed to create local config directory: %w", err)
|
return fmt.Errorf("failed to create local config directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
args := []string{fmt.Sprintf("--app=%s", url), "--autoplay-policy=no-user-gesture-required", fmt.Sprintf("--user-data-dir=%s", browserProfileDirPath)}
|
args := []string{
|
||||||
|
fmt.Sprintf("--app=%s", url),
|
||||||
|
"--autoplay-policy=no-user-gesture-required",
|
||||||
|
fmt.Sprintf("--user-data-dir=%s", browserProfileDirPath),
|
||||||
|
"--allow-running-insecure-content",
|
||||||
|
"--disable-features=XFrameOptions",
|
||||||
|
}
|
||||||
if fullscreen {
|
if fullscreen {
|
||||||
args = append(args, "--start-fullscreen")
|
args = append(args, "--start-fullscreen")
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
v0.0.13
|
v0.0.16
|
||||||
|
|||||||
Reference in New Issue
Block a user