mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 13:07:58 +00:00
Implement logs autoreload
This commit is contained in:
parent
1f8984766b
commit
49d5022027
@ -4,6 +4,7 @@
|
|||||||
import ObjectViewer from '$components/objectviewer.svelte';
|
import ObjectViewer from '$components/objectviewer.svelte';
|
||||||
import input from '$lib/actions/input';
|
import input from '$lib/actions/input';
|
||||||
import { BrowserOpenURL } from '$wails/runtime/runtime';
|
import { BrowserOpenURL } from '$wails/runtime/runtime';
|
||||||
|
import { onDestroy } from 'svelte';
|
||||||
|
|
||||||
export let host;
|
export let host;
|
||||||
|
|
||||||
@ -15,9 +16,17 @@
|
|||||||
let copySucceeded = false;
|
let copySucceeded = false;
|
||||||
let autoReloadInterval = 0;
|
let autoReloadInterval = 0;
|
||||||
let objectViewerData;
|
let objectViewerData;
|
||||||
|
let interval;
|
||||||
$: filter && refresh();
|
$: filter && refresh();
|
||||||
$: busy = !logs && !error && 'Requesting logs…';
|
$: busy = !logs && !error && 'Requesting logs…';
|
||||||
|
|
||||||
|
$: if (autoReloadInterval) {
|
||||||
|
if (interval) {
|
||||||
|
clearInterval(interval);
|
||||||
|
}
|
||||||
|
interval = setInterval(refresh, autoReloadInterval * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
let _logs = [];
|
let _logs = [];
|
||||||
({ logs: _logs, total, error } = await host.getLogs(filter));
|
({ logs: _logs, total, error } = await host.getLogs(filter));
|
||||||
@ -44,6 +53,12 @@
|
|||||||
copySucceeded = true;
|
copySucceeded = true;
|
||||||
setTimeout(() => copySucceeded = false, 1500);
|
setTimeout(() => copySucceeded = false, 1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onDestroy(() => {
|
||||||
|
if (interval) {
|
||||||
|
clearInterval(interval);
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
|
Loading…
Reference in New Issue
Block a user