diff --git a/control/frontend/src/lib/components/NumberSettingInput.svelte b/control/frontend/src/lib/components/NumberSettingInput.svelte new file mode 100644 index 0000000..70c0213 --- /dev/null +++ b/control/frontend/src/lib/components/NumberSettingInput.svelte @@ -0,0 +1,66 @@ + + +
+ + + +
diff --git a/control/frontend/src/lib/ts/stores/displays.ts b/control/frontend/src/lib/ts/stores/displays.ts index 6cb1544..14c1835 100755 --- a/control/frontend/src/lib/ts/stores/displays.ts +++ b/control/frontend/src/lib/ts/stores/displays.ts @@ -13,6 +13,7 @@ import { delete_and_deselect_unique_files_from_display } from './files'; import { db } from '../database'; import { dev } from '$app/environment'; import { remove_display_from_loading_displays } from '../main'; +import { preview_settings } from './ui_behavior'; export const local_displays: Writable = writable([]); @@ -117,7 +118,13 @@ export async function get_display_by_id(display_id: string): Promise 0) { - retry_count -= 1; + if (settings.mode !== 'always') retry_count -= 1; const new_blob = await get_screenshot(display.ip); if (!new_blob) { @@ -149,7 +156,7 @@ export async function screenshot_loop(display_id: string, initial_retry_count: n retry_count = initial_retry_count; } - await new Promise((resolve) => setTimeout(resolve, 2000)); // sleep 2s + await new Promise((resolve) => setTimeout(resolve, retry_seconds * 1000)); // sleep } display.preview.currently_updating = false; diff --git a/control/frontend/src/lib/ts/stores/ui_behavior.ts b/control/frontend/src/lib/ts/stores/ui_behavior.ts index 3712f77..8ad84c7 100644 --- a/control/frontend/src/lib/ts/stores/ui_behavior.ts +++ b/control/frontend/src/lib/ts/stores/ui_behavior.ts @@ -1,4 +1,5 @@ import { writable, type Writable } from 'svelte/store'; +import type { NumberSetting } from '../types'; export const dnd_flip_duration_ms = 300; @@ -23,6 +24,30 @@ export const current_height: Writable> = writable = writable(false); export const is_display_drag: Writable = writable(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 = writable(null); export function change_height(key: 'display' | 'file', factor: number) { diff --git a/control/frontend/src/lib/ts/types.ts b/control/frontend/src/lib/ts/types.ts index 336e762..dca3aaf 100755 --- a/control/frontend/src/lib/ts/types.ts +++ b/control/frontend/src/lib/ts/types.ts @@ -141,6 +141,13 @@ export type PopupContent = { closable?: boolean; }; +export type NumberSetting = { + max: number, + min: number, + now: number, + step: number +} + export type DisplayStatus = 'host_offline' | 'app_offline' | 'app_online' | null; export function to_display_status(value: string): DisplayStatus { diff --git a/control/frontend/src/routes/+page.svelte b/control/frontend/src/routes/+page.svelte index 322dc27..78326ce 100644 --- a/control/frontend/src/routes/+page.svelte +++ b/control/frontend/src/routes/+page.svelte @@ -1,5 +1,18 @@