diff --git a/frontend/src/components/grid-items.svelte b/frontend/src/components/grid-items.svelte index e93b0a6..b1a5b36 100644 --- a/frontend/src/components/grid-items.svelte +++ b/frontend/src/components/grid-items.svelte @@ -13,6 +13,7 @@ export let level = 0; export let striped = true; export let hideObjectIndicators = false; + export let hideChildrenToggles = false; const dispatch = createEventDispatcher(); let childrenOpen = {}; @@ -105,17 +106,19 @@ class:selected={!activePath[level + 1] && activePath.every(k => path.includes(k) || k === item[key]) && (activePath[level] === item[key])} class:striped > - - {#if item.children?.length} - - {/if} - + {#if !hideChildrenToggles} + + {#if item.children?.length} + + {/if} + + {/if}
diff --git a/frontend/src/components/grid.svelte b/frontend/src/components/grid.svelte index 06ac59b..9888510 100644 --- a/frontend/src/components/grid.svelte +++ b/frontend/src/components/grid.svelte @@ -8,8 +8,9 @@ export let key = 'id'; export let activePath = []; export let striped = true; - export let hideObjectIndicators = false; export let showHeaders = false; + export let hideObjectIndicators = false; + export let hideChildrenToggles = false;
@@ -28,8 +29,12 @@ {#if showHeaders && columns.some(col => col.title)} - + {#if !hideChildrenToggles} + + {/if} + + {#each columns as column} {column.title || ''} {/each} @@ -44,6 +49,7 @@ {key} {striped} {hideObjectIndicators} + {hideChildrenToggles} bind:activePath on:select on:trigger diff --git a/frontend/src/organisms/connection/export/dumpinfo.svelte b/frontend/src/organisms/connection/export/dumpinfo.svelte new file mode 100644 index 0000000..728c497 --- /dev/null +++ b/frontend/src/organisms/connection/export/dumpinfo.svelte @@ -0,0 +1,129 @@ + + + +
+
+ +
+
+
+ ({ id, name: hosts[id]?.name })), + ]} + on:select={e => selectHost(e.detail?.itemKey)} + /> +
+
+ ({ id, name: id })) + : [] + ), + ]} + on:select={e => selectDatabase(e.detail?.itemKey)} + /> +
+
+ ({ id, name: id })) + : [] + ), + ]} + on:select={e => selectCollection(e.detail?.itemKey)} + /> +
+
+
+
+ + diff --git a/frontend/src/organisms/connection/export/exportinfo.svelte b/frontend/src/organisms/connection/export/exportinfo.svelte new file mode 100644 index 0000000..5f85575 --- /dev/null +++ b/frontend/src/organisms/connection/export/exportinfo.svelte @@ -0,0 +1,3 @@ + diff --git a/frontend/src/organisms/connection/hosttree.svelte b/frontend/src/organisms/connection/hosttree.svelte index 73c9d76..c37c2e4 100644 --- a/frontend/src/organisms/connection/hosttree.svelte +++ b/frontend/src/organisms/connection/hosttree.svelte @@ -101,6 +101,9 @@ name: collKey, icon: 'list', menu: [ + { label: 'Export collection (JSON/CSV, mongoexport)…', fn: () => dispatch('exportCollection', collKey) }, + { label: 'Dump collection (BSON, mongodump)…', fn: () => dispatch('dumpCollection', collKey) }, + { separator: true }, { label: 'Rename collection…', fn: () => dispatch('renameCollection', collKey) }, { label: 'Truncate collection…', fn: () => truncateCollection(dbKey, collKey) }, { label: 'Drop collection…', fn: () => dropCollection(dbKey, collKey) }, diff --git a/frontend/src/organisms/connection/index.svelte b/frontend/src/organisms/connection/index.svelte index dac4019..b24e4ff 100644 --- a/frontend/src/organisms/connection/index.svelte +++ b/frontend/src/organisms/connection/index.svelte @@ -9,6 +9,8 @@ import HostDetail from './hostdetail.svelte'; import Icon from '../../components/icon.svelte'; import { EventsOn } from '../../../wailsjs/runtime/runtime'; + import ExportInfo from './export/exportinfo.svelte'; + import DumpInfo from './export/dumpinfo.svelte'; export let hosts = {}; export let activeHostKey = ''; @@ -25,6 +27,9 @@ let collToRename = ''; let newCollKey = ''; + let exportInfo; + let dumpInfo; + async function getHosts() { hosts = await Hosts(); } @@ -54,7 +59,6 @@ async function renameCollection() { busy.start(); - console.log(newCollKey); const ok = await RenameCollection(activeHostKey, activeDbKey, collToRename, newCollKey); if (ok) { activeCollKey = newCollKey; @@ -73,6 +77,22 @@ busy.end(); } + function exportCollection(collKey) { + exportInfo = { + hostKey: activeHostKey, + dbKey: activeDbKey, + collKeys: [ collKey ], + }; + } + + function dumpCollection(collKey) { + dumpInfo = { + hostKey: activeHostKey, + dbKey: activeDbKey, + collKeys: [ collKey ], + }; + } + EventsOn('CreateHost', createHost); EventsOn('CreateDatabase', () => newDb = {}); EventsOn('CreateCollection', () => newColl = {}); @@ -91,6 +111,8 @@ on:newCollection={() => newColl = {}} on:editHost={e => editHost(e.detail)} on:renameCollection={e => openEditCollModal(e.detail)} + on:exportCollection={e => exportCollection(e.detail)} + on:dumpCollection={e => dumpCollection(e.detail)} />
@@ -108,6 +130,9 @@ {hosts} /> + + + {#if newDb}

Create a database

diff --git a/frontend/src/stores.js b/frontend/src/stores.js index 49ae2eb..7a44862 100644 --- a/frontend/src/stores.js +++ b/frontend/src/stores.js @@ -1,6 +1,5 @@ import { writable } from 'svelte/store'; -import { Environment } from '../wailsjs/runtime/runtime'; -import { Settings, UpdateSettings, UpdateViewStore, Views } from '../wailsjs/go/app/App'; +import { Environment, Settings, UpdateSettings, UpdateViewStore, Views } from '../wailsjs/go/app/App'; export const busy = (() => { const { update, subscribe } = writable(0); @@ -57,6 +56,7 @@ export const environment = (() => { const reload = async() => { const newEnv = await Environment(); set(newEnv); + console.log(newEnv); return newEnv; }; diff --git a/frontend/wailsjs/go/app/App.d.ts b/frontend/wailsjs/go/app/App.d.ts index 25166fd..4a52f99 100755 --- a/frontend/wailsjs/go/app/App.d.ts +++ b/frontend/wailsjs/go/app/App.d.ts @@ -15,6 +15,8 @@ export function DropDatabase(arg1:string,arg2:string):Promise; export function DropIndex(arg1:string,arg2:string,arg3:string,arg4:string):Promise; +export function Environment():Promise; + export function FindItems(arg1:string,arg2:string,arg3:string,arg4:string):Promise; export function GetIndexes(arg1:string,arg2:string,arg3:string):Promise>; diff --git a/frontend/wailsjs/go/app/App.js b/frontend/wailsjs/go/app/App.js index ec49617..eb44945 100755 --- a/frontend/wailsjs/go/app/App.js +++ b/frontend/wailsjs/go/app/App.js @@ -22,6 +22,10 @@ export function DropIndex(arg1, arg2, arg3, arg4) { return window['go']['app']['App']['DropIndex'](arg1, arg2, arg3, arg4); } +export function Environment() { + return window['go']['app']['App']['Environment'](); +} + export function FindItems(arg1, arg2, arg3, arg4) { return window['go']['app']['App']['FindItems'](arg1, arg2, arg3, arg4); } diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts index e2c38dd..fdb09d1 100755 --- a/frontend/wailsjs/go/models.ts +++ b/frontend/wailsjs/go/models.ts @@ -1,5 +1,25 @@ export namespace app { + export class EnvironmentInfo { + arch: string; + buildType: string; + platform: string; + hasMongoExport: boolean; + hasMongoDump: boolean; + + static createFrom(source: any = {}) { + return new EnvironmentInfo(source); + } + + constructor(source: any = {}) { + if ('string' === typeof source) source = JSON.parse(source); + this.arch = source["arch"]; + this.buildType = source["buildType"]; + this.platform = source["platform"]; + this.hasMongoExport = source["hasMongoExport"]; + this.hasMongoDump = source["hasMongoDump"]; + } + } export class Settings { defaultLimit: number; defaultSort: string; diff --git a/internal/app/app_environment.go b/internal/app/app_environment.go new file mode 100644 index 0000000..f1bec17 --- /dev/null +++ b/internal/app/app_environment.go @@ -0,0 +1,37 @@ +package app + +import ( + "os/exec" + + "github.com/wailsapp/wails/v2/pkg/runtime" +) + +type EnvironmentInfo struct { + Arch string `json:"arch"` + BuildType string `json:"buildType"` + Platform string `json:"platform"` + + HasMongoExport bool `json:"hasMongoExport"` + HasMongoDump bool `json:"hasMongoDump"` +} + +var env EnvironmentInfo +var envKnown = false + +func (a *App) Environment() EnvironmentInfo { + if !envKnown { + wailsEnv := runtime.Environment(a.ctx) + env.Arch = wailsEnv.Arch + env.BuildType = wailsEnv.BuildType + env.Platform = wailsEnv.Platform + + _, err := exec.LookPath("mongodump") + env.HasMongoDump = err == nil + + _, err = exec.LookPath("mongoexport") + env.HasMongoExport = err == nil + + envKnown = true + } + return env +}