From a84b1498a39126e91a9beb2e41d1e61bbe9a911d Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Fri, 26 May 2023 17:21:39 +0200 Subject: [PATCH] First commit in a long time --- frontend/src/lib/progress.js | 16 ++ frontend/src/lib/stores/busy.js | 33 ---- .../collection/components/export.svelte | 61 ++++++ .../connection/collection/find.svelte | 14 +- .../connection/collection/remove.svelte | 1 - .../connection/collection/stats.svelte | 1 - .../connection/collection/update.svelte | 1 - frontend/src/organisms/connection/dump.svelte | 10 +- .../src/organisms/connection/hosttree.svelte | 26 +-- .../src/organisms/connection/index.svelte | 6 +- frontend/wailsjs/go/app/App.d.ts | 2 + frontend/wailsjs/go/app/App.js | 4 + frontend/wailsjs/go/ui/UI.d.ts | 4 +- frontend/wailsjs/go/ui/UI.js | 8 +- internal/app/collection_find_export.go | 178 ++++++++++++++++++ internal/ui/progress.go | 35 ++-- internal/ui/ui.go | 8 +- 17 files changed, 321 insertions(+), 87 deletions(-) create mode 100644 frontend/src/lib/progress.js delete mode 100644 frontend/src/lib/stores/busy.js create mode 100644 frontend/src/organisms/connection/collection/components/export.svelte create mode 100644 internal/app/collection_find_export.go diff --git a/frontend/src/lib/progress.js b/frontend/src/lib/progress.js new file mode 100644 index 0000000..311a44a --- /dev/null +++ b/frontend/src/lib/progress.js @@ -0,0 +1,16 @@ +import { StartProgressBar, StopProgressBar } from '$wails/go/ui/UI'; + +let taskCounter = 0; + +export function startProgress(taskDescription = 'Loading…') { + const taskIndex = ++taskCounter; + StartProgressBar(taskIndex, taskDescription); + + const task = { + id: taskIndex, + description: taskDescription, + end: () => StopProgressBar(taskIndex), + }; + + return task; +} diff --git a/frontend/src/lib/stores/busy.js b/frontend/src/lib/stores/busy.js deleted file mode 100644 index caf6655..0000000 --- a/frontend/src/lib/stores/busy.js +++ /dev/null @@ -1,33 +0,0 @@ -import { StartProgressBar, StopProgressBar } from '$wails/go/ui/UI'; -import { writable } from 'svelte/store'; - -const { update, subscribe } = writable(0); - -let timer; -let progressBarShown = false; -subscribe(isBusy => { - if (isBusy) { - document.body.classList.add('busy'); - if (!progressBarShown) { - progressBarShown = true; - timer = setTimeout(() => StartProgressBar(''), 100); - } - } - else { - if (timer) { - clearTimeout(timer); - timer = undefined; - } - progressBarShown = false; - document.body.classList.remove('busy'); - StopProgressBar(); - } -}); - -const busy = { - start: () => update(v => ++v), - end: () => update(v => --v), - subscribe, -}; - -export default busy; diff --git a/frontend/src/organisms/connection/collection/components/export.svelte b/frontend/src/organisms/connection/collection/components/export.svelte new file mode 100644 index 0000000..2cbee99 --- /dev/null +++ b/frontend/src/organisms/connection/collection/components/export.svelte @@ -0,0 +1,61 @@ + + + +
+ + + +
+
+ + diff --git a/frontend/src/organisms/connection/collection/find.svelte b/frontend/src/organisms/connection/collection/find.svelte index 045235b..5c9dd1a 100644 --- a/frontend/src/organisms/connection/collection/find.svelte +++ b/frontend/src/organisms/connection/collection/find.svelte @@ -1,19 +1,18 @@ diff --git a/frontend/src/organisms/connection/index.svelte b/frontend/src/organisms/connection/index.svelte index 2c924dd..1a969f2 100644 --- a/frontend/src/organisms/connection/index.svelte +++ b/frontend/src/organisms/connection/index.svelte @@ -1,5 +1,5 @@