1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-06-28 05:25:11 +00:00

Removed Zenity dependency

This commit is contained in:
2023-12-22 15:26:29 +01:00
parent 208db82ba7
commit ef9318576a
16 changed files with 59 additions and 195 deletions

View File

@ -1,12 +1,12 @@
<script>
import { OpenDirectory } from '$wails/go/ui/UI.js';
import { ChooseDirectory } from '$wails/go/app/App.js';
export let value = '';
export let id = '';
export let title = 'Choose a directory';
async function selectDir() {
value = await OpenDirectory(title) || value;
value = await ChooseDirectory(title) || value;
}
</script>

View File

@ -1,27 +0,0 @@
import { StartProgressBar, StopProgressBar } from '$wails/go/ui/UI.js';
let taskCounter = 0;
export function startProgress(taskDescription = 'Loading…') {
const taskIndex = ++taskCounter;
let started = false;
const debouncer = setTimeout(() => {
StartProgressBar(taskIndex, taskDescription);
started = true;
}, 150);
const task = {
id: taskIndex,
description: taskDescription,
end: () => {
clearTimeout(debouncer);
if (started) {
StopProgressBar(taskIndex);
}
},
};
return task;
}

View File

@ -1,5 +1,4 @@
import dialogs from '$lib/dialogs.js';
import { startProgress } from '$lib/progress.js';
import { get, writable } from 'svelte/store';
import applicationInited from './inited.js';
import queries from './queries.js';
@ -40,7 +39,10 @@ async function refresh() {
const hosts = await Hosts();
const hostTree = getValue();
for (const [ hostKey, hostDetails ] of Object.entries(hosts)) {
for (const [
hostKey,
hostDetails,
] of Object.entries(hosts)) {
hostTree[hostKey] = hostTree[hostKey] || {};
const host = hostTree[hostKey];
host.key = hostKey;
@ -70,7 +72,10 @@ async function refresh() {
host.databases[dbKey] = host.databases[dbKey] || {};
}
for (const [ dbKey, database ] of Object.entries(host.databases)) {
for (const [
dbKey,
database,
] of Object.entries(host.databases)) {
if (!database.new && !dbNames.includes(dbKey)) {
delete host.databases[dbKey];
continue;
@ -95,7 +100,10 @@ async function refresh() {
database.collections[collKey] = database.collections[collKey] || {};
}
for (const [ collKey, collection ] of Object.entries(database.collections)) {
for (const [
collKey,
collection,
] of Object.entries(database.collections)) {
if (!collection.new && !collNames.includes(collKey)) {
delete database.collections[collKey];
continue;
@ -121,13 +129,8 @@ async function refresh() {
collection.rename = async function() {
const newCollKey = await dialogs.enterText('Rename collection', `Enter a new name for collection ${collKey}.`, collKey);
if (newCollKey && (newCollKey !== collKey)) {
const progress = startProgress(
`Renaming collection "${collKey}" to "${newCollKey}"…`
);
const ok = await RenameCollection(hostKey, dbKey, collKey, newCollKey);
await database.open();
progress.end();
return ok;
}
};

View File

@ -6,7 +6,6 @@
import input from '$lib/actions/input.js';
import dialogs from '$lib/dialogs.js';
import { deepClone } from '$lib/objects.js';
import { startProgress } from '$lib/progress.js';
import applicationSettings from '$lib/stores/settings.js';
import views from '$lib/stores/views.js';
import { convertLooseJson, stringCouldBeID } from '$lib/strings.js';
@ -178,7 +177,6 @@
}
async function saveDocument(event) {
const progress = startProgress('Performing update…');
const success = await UpdateFoundDocument(
collection.hostKey,
collection.dbKey,
@ -191,8 +189,6 @@
objectViewerSuccessMessage = 'Document has been saved!';
submitQuery();
}
progress.end();
}
$: collection && refresh();
@ -344,7 +340,10 @@
<div>
<label class="field inline">
<select bind:value={collection.viewKey}>
{#each Object.entries(viewsForCollection) as [ key, view ]}
{#each Object.entries(viewsForCollection) as [
key,
view,
]}
<option value={key}>{view.name}</option>
{/each}
</select>
@ -412,7 +411,15 @@
{/if}
<datalist id="limits">
{#each [ 1, 5, 10, 25, 50, 100, 200 ] as value}
{#each [
1,
5,
10,
25,
50,
100,
200,
] as value}
<option {value} />
{/each}
</datalist>

View File

@ -2,7 +2,6 @@
import DirectoryChooser from '$components/editors/directorychooser.svelte';
import Grid from '$components/grid/grid.svelte';
import Modal from '$components/modal.svelte';
import { startProgress } from '$lib/progress.js';
import hostTree from '$lib/stores/hosttree.js';
import applicationSettings from '$lib/stores/settings.js';
import { OpenConnection, OpenDatabase } from '$wails/go/app/App.js';
@ -23,7 +22,6 @@
info.collKeys = [];
if (hostKey) {
const progress = startProgress(`Opening connection to host "${hostKey}"`);
const databases = await OpenConnection(hostKey);
if (databases && !$hostTree[hostKey]) {
@ -32,8 +30,6 @@
$hostTree[hostKey].databases[dbKey] = $hostTree[hostKey].databases[dbKey] || { collections: {} };
});
}
progress.end();
}
}
@ -42,14 +38,11 @@
info.dbKey = dbKey;
if (dbKey) {
const progress = startProgress(`Opening database "${dbKey}"`);
const collections = await OpenDatabase(info.hostKey, dbKey);
for (const collKey of collections?.sort() || []) {
$hostTree[info.hostKey].databases[dbKey].collections[collKey] = {};
}
progress.end();
}
}

2
frontend/wailsjs/go/app/App.d.ts generated vendored
View File

@ -12,6 +12,8 @@ export function Aggregate(arg1:string,arg2:string,arg3:string,arg4:string,arg5:s
export function AskConfirmation(arg1:string):Promise<boolean>;
export function ChooseDirectory(arg1:string):Promise<string>;
export function CountItems(arg1:string,arg2:string,arg3:string,arg4:string):Promise<app.CountItemsResult>;
export function CreateIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise<string>;

View File

@ -14,6 +14,10 @@ export function AskConfirmation(arg1) {
return window['go']['app']['App']['AskConfirmation'](arg1);
}
export function ChooseDirectory(arg1) {
return window['go']['app']['App']['ChooseDirectory'](arg1);
}
export function CountItems(arg1, arg2, arg3, arg4) {
return window['go']['app']['App']['CountItems'](arg1, arg2, arg3, arg4);
}

6
frontend/wailsjs/go/ui/UI.d.ts generated vendored
View File

@ -4,12 +4,6 @@ import {context} from '../models';
export function Beep():Promise<void>;
export function OpenDirectory(arg1:string):Promise<string>;
export function Reveal(arg1:string):Promise<void>;
export function StartProgressBar(arg1:number,arg2:string):Promise<void>;
export function Startup(arg1:context.Context):Promise<void>;
export function StopProgressBar(arg1:number):Promise<void>;

View File

@ -6,22 +6,10 @@ export function Beep() {
return window['go']['ui']['UI']['Beep']();
}
export function OpenDirectory(arg1) {
return window['go']['ui']['UI']['OpenDirectory'](arg1);
}
export function Reveal(arg1) {
return window['go']['ui']['UI']['Reveal'](arg1);
}
export function StartProgressBar(arg1, arg2) {
return window['go']['ui']['UI']['StartProgressBar'](arg1, arg2);
}
export function Startup(arg1) {
return window['go']['ui']['UI']['Startup'](arg1);
}
export function StopProgressBar(arg1) {
return window['go']['ui']['UI']['StopProgressBar'](arg1);
}