1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Zenity dialogs

This commit is contained in:
Romein van Buren 2023-02-20 21:04:01 +01:00
parent bab7f44ec3
commit bd18b54842
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
20 changed files with 176 additions and 429 deletions

View File

@ -5,7 +5,7 @@
import input from '$lib/actions/input'; import input from '$lib/actions/input';
import busy from '$lib/stores/busy'; import busy from '$lib/stores/busy';
import { connections } from '$lib/stores/connections'; import { connections } from '$lib/stores/connections';
import { Hosts, RenameCollection } from '$wails/go/app/App'; import { EnterText, Hosts, RenameCollection } from '$wails/go/app/App';
import { EventsOn } from '$wails/runtime/runtime'; import { EventsOn } from '$wails/runtime/runtime';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import CollectionDetail from './collection/index.svelte'; import CollectionDetail from './collection/index.svelte';
@ -19,8 +19,6 @@
export let activeCollKey = ''; export let activeCollKey = '';
let hostTree; let hostTree;
let newDb;
let newColl;
let showHostDetail = false; let showHostDetail = false;
let hostDetailKey = ''; let hostDetailKey = '';
@ -44,9 +42,11 @@
showHostDetail = true; showHostDetail = true;
} }
function createDatabase() { async function createDatabase() {
$connections[activeHostKey].databases[newDb.name] = { collections: {} }; const name = await EnterText('Create a database', 'Enter the database name. Note: databases in MongoDB do not exist until they have a collection and an item. Your new database will not persist on the server; fill it to have it created.');
newDb = undefined; if (name) {
$connections[activeHostKey].databases[name] = { collections: {} };
}
} }
function openEditCollModal(collKey) { function openEditCollModal(collKey) {
@ -66,9 +66,11 @@
busy.end(); busy.end();
} }
function createCollection() { async function createCollection() {
$connections[activeHostKey].databases[activeDbKey].collections[newColl.name] = {}; const name = await EnterText('Create a collection', 'Note: collections in MongoDB do not exist until they have at least one item. Your new collection will not persist on the server; fill it to have it created.');
newColl = undefined; if (name) {
$connections[activeHostKey].databases[activeDbKey].collections[name] = {};
}
} }
function exportCollection(collKey) { function exportCollection(collKey) {
@ -92,8 +94,8 @@
} }
EventsOn('CreateHost', createHost); EventsOn('CreateHost', createHost);
EventsOn('CreateDatabase', () => newDb = {}); EventsOn('CreateDatabase', createDatabase);
EventsOn('CreateCollection', () => newColl = {}); EventsOn('CreateCollection', createCollection);
onMount(getHosts); onMount(getHosts);
</script> </script>
@ -105,8 +107,8 @@
bind:activeDbKey bind:activeDbKey
bind:this={hostTree} bind:this={hostTree}
on:newHost={createHost} on:newHost={createHost}
on:newDatabase={() => newDb = {}} on:newDatabase={createDatabase}
on:newCollection={() => newColl = {}} on:newCollection={createCollection}
on:editHost={e => editHost(e.detail)} on:editHost={e => editHost(e.detail)}
on:renameCollection={e => openEditCollModal(e.detail)} on:renameCollection={e => openEditCollModal(e.detail)}
on:exportCollection={e => exportCollection(e.detail)} on:exportCollection={e => exportCollection(e.detail)}
@ -131,42 +133,6 @@
<Export bind:info={exportInfo} {hosts} /> <Export bind:info={exportInfo} {hosts} />
{#if newDb}
<Modal bind:show={newDb}>
<p><strong>Create a database</strong></p>
<Hint>
Note: databases in MongoDB do not exist until they have a collection and an item. Your new database will not persist on the server; fill it to have it created.
</Hint>
<form on:submit|preventDefault={createDatabase}>
<label class="field">
<input type="text" spellcheck="false" bind:value={newDb.name} use:input={{ autofocus: true }} placeholder="New collection name" />
</label>
<p class="modal-actions">
<button class="btn create" type="submit" disabled={!newDb.name?.trim()}>Create database</button>
<button class="btn secondary" type="button" on:click={() => newDb = undefined}>Cancel</button>
</p>
</form>
</Modal>
{/if}
{#if newColl}
<Modal bind:show={newColl}>
<p><strong>Create a collection</strong></p>
<Hint>
Note: collections in MongoDB do not exist until they have at least one item. Your new collection will not persist on the server; fill it to have it created.
</Hint>
<form on:submit|preventDefault={createCollection}>
<label class="field">
<input type="text" spellcheck="false" bind:value={newColl.name} use:input={{ autofocus: true }} placeholder="New collection name" />
</label>
<p class="modal-actions">
<button class="btn create" type="submit" disabled={!newColl.name?.trim()}>Create collection</button>
<button class="btn secondary" type="button" on:click={() => newColl = undefined}>Cancel</button>
</p>
</form>
</Modal>
{/if}
{#if collToRename} {#if collToRename}
<Modal bind:show={collToRename} width="400px"> <Modal bind:show={collToRename} width="400px">
<form class="rename" on:submit|preventDefault={renameCollection}> <form class="rename" on:submit|preventDefault={renameCollection}>
@ -184,11 +150,6 @@
{/if} {/if}
<style> <style>
.modal-actions {
display: flex;
justify-content: space-between;
}
.tree { .tree {
padding: 0.5rem; padding: 0.5rem;
background-color: #fff; background-color: #fff;

View File

@ -19,6 +19,8 @@ export function DropDatabase(arg1:string,arg2:string):Promise<boolean>;
export function DropIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise<boolean>; export function DropIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise<boolean>;
export function EnterText(arg1:string,arg2:string):Promise<string>;
export function Environment():Promise<app.EnvironmentInfo>; export function Environment():Promise<app.EnvironmentInfo>;
export function FindItems(arg1:string,arg2:string,arg3:string,arg4:string):Promise<app.QueryResult>; export function FindItems(arg1:string,arg2:string,arg3:string,arg4:string):Promise<app.QueryResult>;

View File

@ -30,6 +30,10 @@ export function DropIndex(arg1, arg2, arg3, arg4) {
return window['go']['app']['App']['DropIndex'](arg1, arg2, arg3, arg4); return window['go']['app']['App']['DropIndex'](arg1, arg2, arg3, arg4);
} }
export function EnterText(arg1, arg2) {
return window['go']['app']['App']['EnterText'](arg1, arg2);
}
export function Environment() { export function Environment() {
return window['go']['app']['App']['Environment'](); return window['go']['app']['App']['Environment']();
} }

13
go.mod
View File

@ -10,6 +10,14 @@ require (
go.mongodb.org/mongo-driver v1.11.1 go.mongodb.org/mongo-driver v1.11.1
) )
require (
github.com/akavel/rsrc v0.10.2 // indirect
github.com/dchest/jsmin v0.0.0-20220218165748-59f39799265f // indirect
github.com/josephspurrier/goversioninfo v1.4.0 // indirect
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 // indirect
golang.org/x/image v0.4.0 // indirect
)
require ( require (
github.com/bep/debounce v1.2.1 // indirect github.com/bep/debounce v1.2.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-ole/go-ole v1.2.6 // indirect
@ -27,6 +35,7 @@ require (
github.com/mattn/go-colorable v0.1.11 // indirect github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-isatty v0.0.14 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/ncruces/zenity v0.10.6
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
@ -44,9 +53,9 @@ require (
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.5.0 // indirect golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.3.7 // indirect golang.org/x/text v0.7.0 // indirect
) )
// replace github.com/wailsapp/wails/v2 v2.3.1 => /Users/romeinvanburen/go/pkg/mod // replace github.com/wailsapp/wails/v2 v2.3.1 => /Users/romeinvanburen/go/pkg/mod

35
go.sum
View File

@ -1,8 +1,12 @@
github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY= github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/jsmin v0.0.0-20220218165748-59f39799265f h1:OGqDDftRTwrvUoL6pOG7rYTmWsTCvyEWFsMjg+HcOaA=
github.com/dchest/jsmin v0.0.0-20220218165748-59f39799265f/go.mod h1:Dv9D0NUlAsaQcGQZa5kc5mqR9ua72SmA8VXi4cd+cBw=
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 h1:jFEK/SA/7E8lg9T33+y8D4Z0I782+bbiEjmyyklRzRQ= github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 h1:jFEK/SA/7E8lg9T33+y8D4Z0I782+bbiEjmyyklRzRQ=
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6/go.mod h1:/WeFVhhxMOGypVKS0w8DUJxUBbHypnWkUVnW7p5c9Pw= github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6/go.mod h1:/WeFVhhxMOGypVKS0w8DUJxUBbHypnWkUVnW7p5c9Pw=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
@ -21,6 +25,8 @@ github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
github.com/josephspurrier/goversioninfo v1.4.0 h1:Puhl12NSHUSALHSuzYwPYQkqa2E1+7SrtAPJorKK0C8=
github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
@ -48,6 +54,8 @@ github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/ncruces/zenity v0.10.6 h1:lA5SupAxxDSEL4BkaLBkv2LJrh2YxJkbEBxwrF0awXY=
github.com/ncruces/zenity v0.10.6/go.mod h1:Mp6EUzPkII5A30OSUN/zfEVYOZ3196Fzvq1ba+qyxRk=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 h1:acNfDZXmm28D2Yg/c3ALnZStzNaZMSagpbr96vY6Zjc= github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 h1:acNfDZXmm28D2Yg/c3ALnZStzNaZMSagpbr96vY6Zjc=
@ -56,6 +64,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844 h1:GranzK4hv1/pqTIhMTXt2X8MmMOuH3hMeUR0o9SP5yc=
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844/go.mod h1:T1TLSfyWVBRXVGzWd0o9BI4kfoO9InEgfQe4NV3mLz8=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/samber/lo v1.27.1 h1:sTXwkRiIFIQG+G0HeAvOEnGjqWeWtI9cg5/n51KrxPg= github.com/samber/lo v1.27.1 h1:sTXwkRiIFIQG+G0HeAvOEnGjqWeWtI9cg5/n51KrxPg=
@ -87,18 +97,30 @@ github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCO
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.11.1 h1:QP0znIRTuL0jf1oBQoAoM0C6ZJfBK4kx0Uumtv1A7w8= go.mongodb.org/mongo-driver v1.11.1 h1:QP0znIRTuL0jf1oBQoAoM0C6ZJfBK4kx0Uumtv1A7w8=
go.mongodb.org/mongo-driver v1.11.1/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8= go.mongodb.org/mongo-driver v1.11.1/go.mod h1:s7p5vEtfbeR1gYi6pnj3c3/urpbLv2T5Sfd6Rp2HBB8=
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/image v0.4.0 h1:x1RWAiZIvERqkltrFjtQP1ycmiR5pmhjtCfVOtdURuQ=
golang.org/x/image v0.4.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -109,13 +131,22 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View File

@ -11,6 +11,7 @@ import (
"github.com/garraflavatra/rolens/internal/open_file" "github.com/garraflavatra/rolens/internal/open_file"
"github.com/gen2brain/beeep" "github.com/gen2brain/beeep"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/menu" "github.com/wailsapp/wails/v2/pkg/menu"
"github.com/wailsapp/wails/v2/pkg/menu/keys" "github.com/wailsapp/wails/v2/pkg/menu/keys"
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
@ -87,31 +88,16 @@ func (a *App) Environment() EnvironmentInfo {
} }
func (a *App) PurgeLogDirectory() { func (a *App) PurgeLogDirectory() {
sure, _ := wailsRuntime.MessageDialog(a.ctx, wailsRuntime.MessageDialogOptions{ err := zenity.Question("Are you sure you want to remove all logfiles?", zenity.Title("Confirm"), zenity.WarningIcon)
Title: "Confirm", if err == zenity.ErrCanceled {
Message: "Are you sure you want to remove all logfiles?",
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
Type: wailsRuntime.WarningDialog,
})
if sure != "Yes" {
return return
} }
err := os.RemoveAll(a.Env.LogDirectory) err = os.RemoveAll(a.Env.LogDirectory)
if err == nil { if err == nil {
wailsRuntime.MessageDialog(a.ctx, wailsRuntime.MessageDialogOptions{ zenity.Info("Successfully purged log directory.", zenity.InfoIcon)
Title: "Successfully purged log directory.",
Type: wailsRuntime.InfoDialog,
})
} else { } else {
wailsRuntime.MessageDialog(a.ctx, wailsRuntime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Encountered an error while purging log directory."), zenity.WarningIcon)
Title: "Encountered an error while purging log directory.",
Message: err.Error(),
Type: wailsRuntime.WarningDialog,
})
} }
} }
@ -165,14 +151,9 @@ func (a *App) OpenDirectory(id, title string) string {
} }
wailsRuntime.LogInfo(a.ctx, fmt.Sprintf("Opening directory ('%v')", title)) wailsRuntime.LogInfo(a.ctx, fmt.Sprintf("Opening directory ('%v')", title))
dir, err := zenity.SelectFile(zenity.Title(title), zenity.Directory())
dir, err := wailsRuntime.OpenDirectoryDialog(a.ctx, wailsRuntime.OpenDialogOptions{ if err != nil && err != zenity.ErrCanceled {
Title: title,
CanCreateDirectories: true,
TreatPackagesAsDirectories: false,
})
if err != nil {
wailsRuntime.LogWarning(a.ctx, "Encountered an error while opening directory:") wailsRuntime.LogWarning(a.ctx, "Encountered an error while opening directory:")
wailsRuntime.LogWarning(a.ctx, err.Error()) wailsRuntime.LogWarning(a.ctx, err.Error())
wailsRuntime.MessageDialog(a.ctx, wailsRuntime.MessageDialogOptions{ wailsRuntime.MessageDialog(a.ctx, wailsRuntime.MessageDialogOptions{
@ -186,6 +167,20 @@ func (a *App) OpenDirectory(id, title string) string {
return dir return dir
} }
func (a *App) EnterText(title, info string) string {
println("wertyuijhgfd")
input, err := zenity.Entry(info, zenity.Title(title))
if err == zenity.ErrCanceled {
return ""
} else if err != nil {
zenity.Info(err.Error(), zenity.Title("Encountered an error!"), zenity.ErrorIcon)
return ""
} else {
return input
}
}
func (a *App) Beep() { func (a *App) Beep() {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
return return

View File

@ -6,6 +6,7 @@ import (
"os" "os"
"path" "path"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
) )
@ -46,11 +47,7 @@ func (a *App) Settings() Settings {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Cannot unmarshal settings.json:") runtime.LogWarning(a.ctx, "Cannot unmarshal settings.json:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info("Could not retrieve application settings, using defaults!", zenity.Title("Information"), zenity.WarningIcon)
Type: runtime.ErrorDialog,
Title: "Could not retrieve application settings, using defaults!",
Message: err.Error(),
})
} }
return s return s
} }
@ -62,11 +59,7 @@ func (a *App) UpdateSettings(jsonData string) Settings {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Malformed JSON for settings file:") runtime.LogError(a.ctx, "Malformed JSON for settings file:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Malformed JSON",
Message: err.Error(),
})
return s return s
} }
@ -74,11 +67,7 @@ func (a *App) UpdateSettings(jsonData string) Settings {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not marshal settings into JSON:") runtime.LogError(a.ctx, "Could not marshal settings into JSON:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not marshal settings into JSON",
Message: err.Error(),
})
return s return s
} }
@ -87,11 +76,7 @@ func (a *App) UpdateSettings(jsonData string) Settings {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not update host list:") runtime.LogError(a.ctx, "Could not update host list:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not update host list"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not update host list",
Message: err.Error(),
})
} }
return s return s

View File

@ -3,6 +3,7 @@ package app
import ( import (
"fmt" "fmt"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
) )
@ -18,11 +19,7 @@ func (a *App) OpenCollection(hostKey, dbKey, collKey string) (result bson.M) {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not retrieve collection stats for "+collKey) runtime.LogWarning(a.ctx, "Could not retrieve collection stats for "+collKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not get stats"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not retrieve collection stats for " + collKey,
Message: err.Error(),
})
return nil return nil
} }
@ -45,11 +42,7 @@ func (a *App) RenameCollection(hostKey, dbKey, collKey, newCollKey string) bool
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not rename collection "+collKey) runtime.LogWarning(a.ctx, "Could not rename collection "+collKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while renaming collection"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not rename " + collKey,
Message: err.Error(),
})
return false return false
} }
@ -58,15 +51,8 @@ func (a *App) RenameCollection(hostKey, dbKey, collKey, newCollKey string) bool
} }
func (a *App) TruncateCollection(hostKey, dbKey, collKey string) bool { func (a *App) TruncateCollection(hostKey, dbKey, collKey string) bool {
sure, _ := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ err := zenity.Question("Are you sure you want to remove all items from "+collKey+"?", zenity.Title("Confirm"), zenity.WarningIcon)
Title: "Confirm", if err == zenity.ErrCanceled {
Message: "Are you sure you want to remove all items from " + collKey + "?",
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
Type: runtime.WarningDialog,
})
if sure != "Yes" {
return false return false
} }
@ -79,11 +65,7 @@ func (a *App) TruncateCollection(hostKey, dbKey, collKey string) bool {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not truncate collection "+collKey) runtime.LogWarning(a.ctx, "Could not truncate collection "+collKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while truncating collection"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not truncate " + collKey,
Message: err.Error(),
})
return false return false
} }
@ -92,15 +74,8 @@ func (a *App) TruncateCollection(hostKey, dbKey, collKey string) bool {
} }
func (a *App) DropCollection(hostKey, dbKey, collKey string) bool { func (a *App) DropCollection(hostKey, dbKey, collKey string) bool {
sure, _ := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ err := zenity.Question("Are you sure you want to drop "+collKey+"?", zenity.Title("Confirm"), zenity.WarningIcon)
Title: "Confirm", if err == zenity.ErrCanceled {
Message: "Are you sure you want to drop " + collKey + "?",
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
Type: runtime.WarningDialog,
})
if sure != "Yes" {
return false return false
} }
@ -113,11 +88,7 @@ func (a *App) DropCollection(hostKey, dbKey, collKey string) bool {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not drop collection "+collKey) runtime.LogWarning(a.ctx, "Could not drop collection "+collKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while dropping collection"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not drop " + collKey,
Message: err.Error(),
})
return false return false
} }

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
@ -15,11 +16,7 @@ func (a *App) Aggregate(hostKey, dbKey, collKey, pipelineJson, settingsJson stri
if err := json.Unmarshal([]byte(settingsJson), &settings); err != nil { if err := json.Unmarshal([]byte(settingsJson), &settings); err != nil {
runtime.LogError(a.ctx, "Could not parse aggregation settings:") runtime.LogError(a.ctx, "Could not parse aggregation settings:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Couldn't parse aggregation settings"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Couldn't parse aggregation settings",
Message: err.Error(),
})
return return
} }
@ -27,11 +24,7 @@ func (a *App) Aggregate(hostKey, dbKey, collKey, pipelineJson, settingsJson stri
if err := bson.UnmarshalExtJSON([]byte(pipelineJson), true, &pipeline); err != nil { if err := bson.UnmarshalExtJSON([]byte(pipelineJson), true, &pipeline); err != nil {
runtime.LogWarning(a.ctx, "Could not parse aggregation pipeline:") runtime.LogWarning(a.ctx, "Could not parse aggregation pipeline:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Couldn't parse aggregation pipeline"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Couldn't parse aggregation pipeline",
Message: err.Error(),
})
return return
} }
@ -46,11 +39,7 @@ func (a *App) Aggregate(hostKey, dbKey, collKey, pipelineJson, settingsJson stri
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not get aggregation cursor:") runtime.LogWarning(a.ctx, "Could not get aggregation cursor:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Couldn't get aggregation cursor"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Couldn't get aggregation cursor",
Message: err.Error(),
})
return return
} }
@ -58,11 +47,7 @@ func (a *App) Aggregate(hostKey, dbKey, collKey, pipelineJson, settingsJson stri
if err := cursor.All(ctx, &results); err != nil { if err := cursor.All(ctx, &results); err != nil {
runtime.LogInfo(a.ctx, "Error while running aggregation pipeline:") runtime.LogInfo(a.ctx, "Error while running aggregation pipeline:")
runtime.LogInfo(a.ctx, err.Error()) runtime.LogInfo(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while running aggregation pipeline"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Error while running aggregation pipeline",
Message: err.Error(),
})
return return
} }

View File

@ -3,6 +3,7 @@ package app
import ( import (
"encoding/json" "encoding/json"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
mongoOptions "go.mongodb.org/mongo-driver/mongo/options" mongoOptions "go.mongodb.org/mongo-driver/mongo/options"
@ -29,11 +30,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse find form:") runtime.LogError(a.ctx, "Could not parse find form:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse form"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Couldn't parse form",
Message: err.Error(),
})
return out return out
} }
@ -51,11 +48,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogInfo(a.ctx, "Invalid find query:") runtime.LogInfo(a.ctx, "Invalid find query:")
runtime.LogInfo(a.ctx, err.Error()) runtime.LogInfo(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Invalid query"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Invalid query",
Message: err.Error(),
})
return out return out
} }
@ -63,11 +56,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogInfo(a.ctx, "Invalid find projection:") runtime.LogInfo(a.ctx, "Invalid find projection:")
runtime.LogInfo(a.ctx, err.Error()) runtime.LogInfo(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Invalid projection"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Invalid projection",
Message: err.Error(),
})
return out return out
} }
@ -75,11 +64,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogInfo(a.ctx, "Invalid find sort:") runtime.LogInfo(a.ctx, "Invalid find sort:")
runtime.LogInfo(a.ctx, err.Error()) runtime.LogInfo(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Invalid sort"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Invalid sort",
Message: err.Error(),
})
return out return out
} }
@ -94,11 +79,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while counting documents:") runtime.LogWarning(a.ctx, "Encountered an error while counting documents:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while counting docs"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while counting documents",
Message: err.Error(),
})
return out return out
} }
@ -106,11 +87,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing query:") runtime.LogWarning(a.ctx, "Encountered an error while performing query:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while querying"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while performing query",
Message: err.Error(),
})
return out return out
} }
@ -121,11 +98,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing query:") runtime.LogWarning(a.ctx, "Encountered an error while performing query:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while querying"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while performing query",
Message: err.Error(),
})
return out return out
} }
@ -136,11 +109,7 @@ func (a *App) FindItems(hostKey, dbKey, collKey, formJson string) QueryResult {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Failed to marshal find BSON:") runtime.LogError(a.ctx, "Failed to marshal find BSON:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Failed to marshal JSON"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Failed to marshal BSON",
Message: err.Error(),
})
return out return out
} }
out.Results = append(out.Results, string(marshalled)) out.Results = append(out.Results, string(marshalled))

View File

@ -6,6 +6,7 @@ import (
"os" "os"
"path" "path"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
) )
@ -63,10 +64,7 @@ func (a *App) SaveQuery(jsonData string) string {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Add query: malformed form") runtime.LogError(a.ctx, "Add query: malformed form")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Malformed JSON",
})
return "" return ""
} }
@ -74,10 +72,7 @@ func (a *App) SaveQuery(jsonData string) string {
queries[query.Name] = query queries[query.Name] = query
err = updateQueryFile(a, queries) err = updateQueryFile(a, queries)
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not update query list"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not update query list",
})
return "" return ""
} }
@ -88,10 +83,7 @@ func (a *App) RemoveQuery(queryName string) {
queries := a.SavedQueries() queries := a.SavedQueries()
delete(queries, queryName) delete(queries, queryName)
if err := updateQueryFile(a, queries); err != nil { if err := updateQueryFile(a, queries); err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not update query list"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not update query list",
})
} }
} }
@ -101,19 +93,13 @@ func (a *App) UpdateQueries(jsonData string) bool {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Update queries: malformed form") runtime.LogError(a.ctx, "Update queries: malformed form")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Malformed JSON"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Malformed JSON",
})
return false return false
} }
err = updateQueryFile(a, queries) err = updateQueryFile(a, queries)
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not save queries"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not save queries",
})
return false return false
} }

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"math" "math"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
@ -21,11 +22,7 @@ func (a *App) GetIndexes(hostKey, dbKey, collKey string) []bson.M {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while creating index cursor:") runtime.LogWarning(a.ctx, "Encountered an error while creating index cursor:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while creating cursor"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while creating index cursor",
Message: err.Error(),
})
return nil return nil
} }
@ -34,11 +31,7 @@ func (a *App) GetIndexes(hostKey, dbKey, collKey string) []bson.M {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while executing index cursor:") runtime.LogWarning(a.ctx, "Encountered an error while executing index cursor:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while running cursor"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while executing index cursor",
Message: err.Error(),
})
return nil return nil
} }
@ -70,11 +63,7 @@ func (a *App) CreateIndex(hostKey, dbKey, collKey, jsonData string) string {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse index JSON:") runtime.LogError(a.ctx, "Could not parse index JSON:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Couldn't parse JSON",
Message: err.Error(),
})
return "" return ""
} }
@ -104,11 +93,7 @@ func (a *App) CreateIndex(hostKey, dbKey, collKey, jsonData string) string {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while creating index:") runtime.LogWarning(a.ctx, "Encountered an error while creating index:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while creating index"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Error while creating index",
Message: err.Error(),
})
return "" return ""
} }
@ -126,11 +111,7 @@ func (a *App) DropIndex(hostKey, dbKey, collKey, indexName string) bool {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Encountered an error while creating index drop cursor:") runtime.LogError(a.ctx, "Encountered an error while creating index drop cursor:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while creating drop cursor"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while creating index cursor",
Message: err.Error(),
})
return false return false
} }

View File

@ -3,6 +3,7 @@ package app
import ( import (
"strings" "strings"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
) )
@ -19,11 +20,7 @@ func (a *App) InsertItems(hostKey, dbKey, collKey, jsonData string) interface{}
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse insert JSON:") runtime.LogError(a.ctx, "Could not parse insert JSON:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Couldn't parse JSON",
Message: err.Error(),
})
return nil return nil
} }
@ -37,11 +34,7 @@ func (a *App) InsertItems(hostKey, dbKey, collKey, jsonData string) interface{}
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing insert:") runtime.LogWarning(a.ctx, "Encountered an error while performing insert:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while performing insert"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while performing query",
Message: err.Error(),
})
return nil return nil
} }

View File

@ -3,6 +3,7 @@ package app
import ( import (
"strings" "strings"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
@ -14,15 +15,8 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
jsonData = strings.TrimSpace(jsonData) jsonData = strings.TrimSpace(jsonData)
if len(jsonData) == 0 { if len(jsonData) == 0 {
sure, _ := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ err := zenity.Question("Are you sure you want to drop all items in "+collKey+"?", zenity.Title("Confirm"), zenity.WarningIcon)
Title: "Confirm", if err == zenity.ErrCanceled {
Message: "Are you sure you want to drop all items in " + collKey + "?",
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
Type: runtime.WarningDialog,
})
if sure != "Yes" {
return 0 return 0
} }
} else { } else {
@ -30,11 +24,7 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse remove query:") runtime.LogError(a.ctx, "Could not parse remove query:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Couldn't parse JSON",
Message: err.Error(),
})
return 0 return 0
} }
} }
@ -57,11 +47,7 @@ func (a *App) RemoveItems(hostKey, dbKey, collKey, jsonData string, many bool) i
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing remove:") runtime.LogWarning(a.ctx, "Encountered an error while performing remove:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while performing remove"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while removing items",
Message: err.Error(),
})
return 0 return 0
} }
@ -82,11 +68,8 @@ func (a *App) RemoveItemById(hostKey, dbKey, collKey, itemId string) bool {
if err != nil && err != mongo.ErrNoDocuments { if err != nil && err != mongo.ErrNoDocuments {
runtime.LogWarning(a.ctx, "Encountered an error while performing remove by id:") runtime.LogWarning(a.ctx, "Encountered an error while performing remove by id:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while performing remove"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while removing item" + itemId,
Message: err.Error(),
})
return false return false
} }

View File

@ -3,6 +3,7 @@ package app
import ( import (
"encoding/json" "encoding/json"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
@ -25,11 +26,7 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse update form:") runtime.LogError(a.ctx, "Could not parse update form:")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse form"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Couldn't parse form",
Message: err.Error(),
})
return 0 return 0
} }
@ -47,11 +44,7 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
runtime.LogWarning(a.ctx, "Invalid update query:") runtime.LogWarning(a.ctx, "Invalid update query:")
runtime.LogWarning(a.ctx, form.Query) runtime.LogWarning(a.ctx, form.Query)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Invalid update query"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Invalid update query",
Message: err.Error(),
})
return 0 return 0
} }
@ -64,11 +57,7 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
runtime.LogWarning(a.ctx, "Invalid update parameter value:") runtime.LogWarning(a.ctx, "Invalid update parameter value:")
runtime.LogWarning(a.ctx, param.Value) runtime.LogWarning(a.ctx, param.Value)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Invalid update query"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Invalid update query",
Message: err.Error(),
})
return 0 return 0
} }
} }
@ -85,11 +74,7 @@ func (a *App) UpdateItems(hostKey, dbKey, collKey string, formJson string) int64
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Encountered an error while performing update:") runtime.LogWarning(a.ctx, "Encountered an error while performing update:")
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while performing update"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Encountered an error while updating items",
Message: err.Error(),
})
return 0 return 0
} }

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"time" "time"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
@ -14,21 +15,14 @@ import (
func (a *App) connectToHost(hostKey string) (*mongo.Client, context.Context, func(), error) { func (a *App) connectToHost(hostKey string) (*mongo.Client, context.Context, func(), error) {
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not retrieve hosts",
})
return nil, nil, nil, errors.New("could not retrieve hosts") return nil, nil, nil, errors.New("could not retrieve hosts")
} }
h := hosts[hostKey] h := hosts[hostKey]
if len(h.URI) == 0 { if len(h.URI) == 0 {
runtime.LogInfo(a.ctx, "Invalid URI (len == 0) for host "+hostKey) runtime.LogInfo(a.ctx, "Invalid URI (len == 0) for host "+hostKey)
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info("You haven't specified a valid uri for the selected host.", zenity.Title("Invalid query"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Invalid uri",
Message: "You haven't specified a valid uri for the selected host.",
})
return nil, nil, nil, errors.New("invalid uri") return nil, nil, nil, errors.New("invalid uri")
} }
@ -37,11 +31,7 @@ func (a *App) connectToHost(hostKey string) (*mongo.Client, context.Context, fun
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not connect to host "+hostKey) runtime.LogWarning(a.ctx, "Could not connect to host "+hostKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while connecting to "+h.Name), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not connect to " + h.Name,
Message: err.Error(),
})
return nil, nil, nil, errors.New("could not establish a connection with " + h.Name) return nil, nil, nil, errors.New("could not establish a connection with " + h.Name)
} }
@ -62,11 +52,7 @@ func (a *App) OpenConnection(hostKey string) (databases []string) {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not retrieve database names for host "+hostKey) runtime.LogWarning(a.ctx, "Could not retrieve database names for host "+hostKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while getting databases"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not retrieve database list",
Message: err.Error(),
})
return nil return nil
} }
defer close() defer close()

View File

@ -1,6 +1,7 @@
package app package app
import ( import (
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
) )
@ -15,11 +16,7 @@ func (a *App) OpenDatabase(hostKey, dbKey string) (collections []string) {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not retrieve collection list for db "+dbKey) runtime.LogWarning(a.ctx, "Could not retrieve collection list for db "+dbKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while getting collections"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not retrieve collection list for " + dbKey,
Message: err.Error(),
})
return nil return nil
} }
@ -28,15 +25,8 @@ func (a *App) OpenDatabase(hostKey, dbKey string) (collections []string) {
} }
func (a *App) DropDatabase(hostKey, dbKey string) bool { func (a *App) DropDatabase(hostKey, dbKey string) bool {
sure, _ := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ err := zenity.Question("Are you sure you want to drop "+dbKey+"?", zenity.Title("Confirm"), zenity.WarningIcon)
Title: "Confirm", if err == zenity.ErrCanceled {
Message: "Are you sure you want to drop " + dbKey + "?",
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
Type: runtime.WarningDialog,
})
if sure != "Yes" {
return false return false
} }
@ -49,11 +39,7 @@ func (a *App) DropDatabase(hostKey, dbKey string) bool {
if err != nil { if err != nil {
runtime.LogWarning(a.ctx, "Could not drop db "+dbKey) runtime.LogWarning(a.ctx, "Could not drop db "+dbKey)
runtime.LogWarning(a.ctx, err.Error()) runtime.LogWarning(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while dropping database"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not drop " + dbKey,
Message: err.Error(),
})
return false return false
} }

View File

@ -7,6 +7,7 @@ import (
"path" "path"
"strings" "strings"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
) )
@ -32,21 +33,13 @@ func (a *App) PerformExport(jsonData string) bool {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not unmarshal export form") runtime.LogError(a.ctx, "Could not unmarshal export form")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not unmarshal JSON",
Message: err.Error(),
})
return false return false
} }
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Could not retrieve hosts",
Message: err.Error(),
})
return false return false
} }
host := hosts[info.HostKey] host := hosts[info.HostKey]
@ -58,10 +51,7 @@ func (a *App) PerformExport(jsonData string) bool {
case FileTypeDump: case FileTypeDump:
if !a.Env.HasMongoDump { if !a.Env.HasMongoDump {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info("You need to install mongodump to perform a dump.", zenity.Title("Additional software required"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "You need to install mongodump to perform a dump.",
})
return false return false
} }
@ -92,11 +82,7 @@ func (a *App) PerformExport(jsonData string) bool {
} }
default: default:
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(fmt.Sprintf("File type '%v' is not known.", info.FileType), zenity.Title("Unrecognised file type"), zenity.ErrorIcon)
Type: runtime.ErrorDialog,
Title: "Unrecognised export file type",
Message: string(info.FileType),
})
return false return false
} }

View File

@ -8,6 +8,7 @@ import (
"path" "path"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
) )
@ -56,10 +57,7 @@ func (a *App) Hosts() (map[string]Host, error) {
func (a *App) AddHost(jsonData string) error { func (a *App) AddHost(jsonData string) error {
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while retrieving hosts"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not retrieve hosts",
})
return errors.New("could not retrieve existing host list") return errors.New("could not retrieve existing host list")
} }
@ -68,10 +66,7 @@ func (a *App) AddHost(jsonData string) error {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Add host: malformed form") runtime.LogError(a.ctx, "Add host: malformed form")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Malformed JSON",
})
return errors.New("invalid JSON") return errors.New("invalid JSON")
} }
@ -79,20 +74,14 @@ func (a *App) AddHost(jsonData string) error {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Add host: failed to generate a UUID") runtime.LogError(a.ctx, "Add host: failed to generate a UUID")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while generating UUID"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Failed to generate a UUID",
})
return errors.New("could not generate a UUID") return errors.New("could not generate a UUID")
} }
hosts[id.String()] = newHost hosts[id.String()] = newHost
err = updateHostsFile(a, hosts) err = updateHostsFile(a, hosts)
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while updating host list"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not update host list",
})
return errors.New("could not update host list") return errors.New("could not update host list")
} }
@ -102,10 +91,7 @@ func (a *App) AddHost(jsonData string) error {
func (a *App) UpdateHost(hostKey string, jsonData string) error { func (a *App) UpdateHost(hostKey string, jsonData string) error {
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while getting hosts"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not retrieve hosts",
})
return errors.New("could not retrieve existing host list") return errors.New("could not retrieve existing host list")
} }
@ -114,20 +100,14 @@ func (a *App) UpdateHost(hostKey string, jsonData string) error {
if err != nil { if err != nil {
runtime.LogError(a.ctx, "Could not parse update host JSON") runtime.LogError(a.ctx, "Could not parse update host JSON")
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Malformed JSON",
})
return errors.New("invalid JSON") return errors.New("invalid JSON")
} }
hosts[hostKey] = host hosts[hostKey] = host
err = updateHostsFile(a, hosts) err = updateHostsFile(a, hosts)
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while updating hosts"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not update host list",
})
return errors.New("could not update host list") return errors.New("could not update host list")
} }
@ -137,22 +117,12 @@ func (a *App) UpdateHost(hostKey string, jsonData string) error {
func (a *App) RemoveHost(key string) error { func (a *App) RemoveHost(key string) error {
hosts, err := a.Hosts() hosts, err := a.Hosts()
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while retrieving hosts"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not retrieve hosts",
})
return errors.New("could not retrieve existing host list") return errors.New("could not retrieve existing host list")
} }
sure, _ := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ err = zenity.Question("Are you sure you want to remove "+hosts[key].Name+"?", zenity.Title("Confirm"), zenity.WarningIcon)
Title: "Confirm", if err == zenity.ErrCanceled {
Message: "Are you sure you want to remove " + hosts[key].Name + "?",
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
Type: runtime.WarningDialog,
})
if sure != "Yes" {
return errors.New("operation aborted") return errors.New("operation aborted")
} }
@ -160,10 +130,7 @@ func (a *App) RemoveHost(key string) error {
err = updateHostsFile(a, hosts) err = updateHostsFile(a, hosts)
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while updating hosts"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not update host list",
})
return errors.New("could not update host list") return errors.New("could not update host list")
} }
return nil return nil

View File

@ -7,6 +7,7 @@ import (
"os" "os"
"path" "path"
"github.com/ncruces/zenity"
"github.com/wailsapp/wails/v2/pkg/runtime" "github.com/wailsapp/wails/v2/pkg/runtime"
) )
@ -100,19 +101,13 @@ func (a *App) UpdateViewStore(jsonData string) error {
var viewStore ViewStore var viewStore ViewStore
err := json.Unmarshal([]byte(jsonData), &viewStore) err := json.Unmarshal([]byte(jsonData), &viewStore)
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Could not parse JSON"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Malformed JSON",
})
return errors.New("invalid JSON") return errors.New("invalid JSON")
} }
err = updateViewStore(a, viewStore) err = updateViewStore(a, viewStore)
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while updating view store"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not update view store",
})
return errors.New("could not update view store") return errors.New("could not update view store")
} }
@ -122,22 +117,12 @@ func (a *App) UpdateViewStore(jsonData string) error {
func (a *App) RemoveView(viewKey string) error { func (a *App) RemoveView(viewKey string) error {
views, err := a.Views() views, err := a.Views()
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while getting views"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not retrieve views",
})
return errors.New("could not retrieve existing view store") return errors.New("could not retrieve existing view store")
} }
sure, _ := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ err = zenity.Question("Are you sure you want to remove "+views[viewKey].Name+"?", zenity.Title("Confirm"), zenity.WarningIcon)
Title: "Confirm", if err == zenity.ErrCanceled {
Message: "Are you sure you want to remove " + views[viewKey].Name + "?",
Buttons: []string{"Yes", "No"},
DefaultButton: "Yes",
CancelButton: "No",
Type: runtime.WarningDialog,
})
if sure != "Yes" {
return errors.New("operation aborted") return errors.New("operation aborted")
} }
@ -145,10 +130,7 @@ func (a *App) RemoveView(viewKey string) error {
err = updateViewStore(a, views) err = updateViewStore(a, views)
if err != nil { if err != nil {
runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{ zenity.Info(err.Error(), zenity.Title("Error while updating view store"), zenity.ErrorIcon)
Type: runtime.InfoDialog,
Title: "Could not update view store",
})
return errors.New("could not update view store") return errors.New("could not update view store")
} }
return nil return nil