mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
add Keyboard Input, improve PopUp, improve general code
This commit is contained in:
@@ -7,10 +7,21 @@ export async function get_screenshot(ip: string) {
|
||||
return await request_display(ip, '/takeScreenshot', options);
|
||||
}
|
||||
|
||||
export async function open_file(ip: string, path_to_file: string): Promise<boolean> {
|
||||
export async function open_file(ip: string, path_to_file: string): Promise<void> {
|
||||
const options = { method: 'PATCH', headers: { 'content-type': 'application/octet-stream' } };
|
||||
const raw_response = await request_display(ip, `/file${path_to_file}`, options);
|
||||
return !!raw_response;
|
||||
await request_display(ip, `/file${path_to_file}`, options);
|
||||
}
|
||||
|
||||
export async function send_keyboard_input(ip: string, key: string): Promise<void> {
|
||||
const options = {
|
||||
method: 'PATCH',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
key: key,
|
||||
}),
|
||||
};
|
||||
console.log(options)
|
||||
await request_display(ip, '/keyboardInput', options);
|
||||
}
|
||||
|
||||
export async function get_file_data(ip: string, path: string): Promise<FolderElement[]> {
|
||||
|
||||
@@ -156,6 +156,18 @@ export async function update_displays_with_map(update_function: (display: Displa
|
||||
displays.set(updated_groups);
|
||||
}
|
||||
|
||||
export async function run_on_all_selected_displays(run_function: ((ip: string, ...args: any[]) => void | Promise<void>), update_screenshot_afterwards: boolean, ...args: any[]) {
|
||||
for (const display_id of get(selected_display_ids)) {
|
||||
const display_ip = get_display_by_id(display_id, get(displays))?.ip;
|
||||
if (display_ip) {
|
||||
await run_function(display_ip, ...args)
|
||||
if (update_screenshot_afterwards) {
|
||||
await update_screenshot(display_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ function createNotifications() {
|
||||
|
||||
function push(type: "error" | "success" | "info", title: string, message: string = "", className: string = "") {
|
||||
const id = Date.now();
|
||||
const duration = type === "error" ? 8000 : 4000;
|
||||
const duration = type === "error" ? 16000 : 4000;
|
||||
update((n) => [...n, { id, title, message, duration, className, type }]);
|
||||
setTimeout(() => {
|
||||
update((n) => n.filter((x) => x.id !== id));
|
||||
|
||||
Reference in New Issue
Block a user