From 89d9a921361aee8c52b61312d17748e63380d266 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Mon, 16 Jan 2023 16:56:16 +0100 Subject: [PATCH] Tweaked some options --- frontend/src/app.svelte | 193 +++++++++++---------- frontend/src/components/contextmenu.svelte | 1 + frontend/src/components/modal.svelte | 6 +- frontend/src/style.css | 6 +- main.go | 35 +++- 5 files changed, 145 insertions(+), 96 deletions(-) diff --git a/frontend/src/app.svelte b/frontend/src/app.svelte index 4b64222..7ab9a58 100644 --- a/frontend/src/app.svelte +++ b/frontend/src/app.svelte @@ -12,6 +12,7 @@ const connections = {}; let hosts = {}; + let environment; let activeHostKey = ''; let activeDbKey = ''; @@ -104,102 +105,117 @@ } onMount(() => { + window.runtime.Environment().then(e => environment = e); Hosts().then(h => hosts = h); }); -
- openConnection(e.detail)} bind:modalOpen={addressBarModalOpen} /> +
+ {#if environment} + {#if environment.platform === 'darwin'} +
+ {/if} - {#if host && connection} -
- ({ - id: dbKey, - collCount: Object.keys(connection.databases[dbKey].collections || {}).length || '', - children: Object.keys(connection.databases[dbKey].collections).map(collKey => ({ - id: collKey, - menu: [ { label: `Drop ${collKey}`, fn: () => dropCollection(dbKey, collKey) } ], - })).sort((a, b) => a.id.localeCompare(b)) || [], - menu: [ { label: `Drop ${dbKey}`, fn: () => dropDatabase(dbKey) } ], - }))} - actions={[ - { icon: 'reload', fn: reload }, - { icon: '+', fn: evt => { - if (activeDbKey) { - contextMenu.show(evt, [ - { label: 'New database', fn: () => newDb = {} }, - { label: 'New collection', fn: () => newColl = {} }, - ]); - } - else { - newDb = {}; - } - } }, - { icon: '-', fn: evt => { - if (activeCollKey) { - contextMenu.show(evt, [ - { label: 'Drop database', fn: () => dropDatabase(activeDbKey) }, - { label: 'Drop collection', fn: () => dropCollection(activeDbKey, activeCollKey) }, - ]); - } - else { - dropDatabase(activeDbKey); - } - }, disabled: !activeDbKey }, - ]} - bind:activeKey={activeDbKey} - bind:activeChildKey={activeCollKey} - on:select={e => openDatabase(e.detail)} - on:selectChild={e => openCollection(e.detail)} - /> -
+
+ openConnection(e.detail)} bind:modalOpen={addressBarModalOpen} /> -
- -
- {:else} - + {#if host && connection} +
+ ({ + id: dbKey, + collCount: Object.keys(connection.databases[dbKey].collections || {}).length || '', + children: Object.keys(connection.databases[dbKey].collections).map(collKey => ({ + id: collKey, + menu: [ { label: `Drop ${collKey}`, fn: () => dropCollection(dbKey, collKey) } ], + })).sort((a, b) => a.id.localeCompare(b)) || [], + menu: [ { label: `Drop ${dbKey}`, fn: () => dropDatabase(dbKey) } ], + }))} + actions={[ + { icon: 'reload', fn: reload }, + { icon: '+', fn: evt => { + if (activeDbKey) { + contextMenu.show(evt, [ + { label: 'New database', fn: () => newDb = {} }, + { label: 'New collection', fn: () => newColl = {} }, + ]); + } + else { + newDb = {}; + } + } }, + { icon: '-', fn: evt => { + if (activeCollKey) { + contextMenu.show(evt, [ + { label: 'Drop database', fn: () => dropDatabase(activeDbKey) }, + { label: 'Drop collection', fn: () => dropCollection(activeDbKey, activeCollKey) }, + ]); + } + else { + dropDatabase(activeDbKey); + } + }, disabled: !activeDbKey }, + ]} + bind:activeKey={activeDbKey} + bind:activeChildKey={activeCollKey} + on:select={e => openDatabase(e.detail)} + on:selectChild={e => openCollection(e.detail)} + /> +
+ +
+ +
+ {:else} + + {/if} +
+ + {#if newDb} + +

Create a database

+

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.

+
+ + +
+
+ {/if} + + {#if newColl} + +

Create a collections

+

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.

+
+ + +
+
+ {/if} + + {#key $contextMenu} + + {/key} {/if} -
- -{#if newDb} - -

Create a database

-

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.

-
- - -
-
-{/if} - -{#if newColl} - -

Create a collections

-

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.

-
- - -
-
-{/if} - -{#key $contextMenu} - -{/key} +