diff --git a/CHANGELOG.md b/CHANGELOG.md
index fed9079..7a17b57 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
* Improved error logging and dialogs.
* Fixed host editing bug.
* Made table headers stick to the top.
+* Improved the application menu.
## [v0.2.1]
diff --git a/frontend/src/lib/stores/hosttree.js b/frontend/src/lib/stores/hosttree.js
index 0f8f0ab..244773f 100644
--- a/frontend/src/lib/stores/hosttree.js
+++ b/frontend/src/lib/stores/hosttree.js
@@ -150,21 +150,15 @@ async function refresh() {
};
collection.truncate = async function() {
- const progress = startProgress(`Truncating collection "${collKey}"…`);
await TruncateCollection(hostKey, dbKey, collKey);
await refresh();
- progress.end();
};
collection.drop = async function() {
- const progress = startProgress(`Dropping collection "${collKey}"…`);
const success = await DropCollection(hostKey, dbKey, collKey);
-
if (success) {
await refresh();
}
-
- progress.end();
};
collection.getIndexes = async function() {
@@ -187,9 +181,7 @@ async function refresh() {
};
index.drop = async function() {
- const progress = startProgress(`Dropping index ${index.name}…`);
const hasBeenDropped = await DropIndex(hostKey, dbKey, collKey, index.name);
- progress.end();
return hasBeenDropped;
};
@@ -208,14 +200,10 @@ async function refresh() {
return new Promise(resolve => {
dialog.$on('create', async event => {
- const progress = startProgress('Creating index…');
const newIndexName = await CreateIndex(collection.hostKey, collection.dbKey, collection.key, JSON.stringify(event.detail.index));
-
if (newIndexName) {
dialog.$close();
}
-
- progress.end();
resolve(newIndexName);
});
});
diff --git a/frontend/src/organisms/connection/collection/index.svelte b/frontend/src/organisms/connection/collection/index.svelte
index a9a9aaf..0d82563 100644
--- a/frontend/src/organisms/connection/collection/index.svelte
+++ b/frontend/src/organisms/connection/collection/index.svelte
@@ -16,8 +16,8 @@
export let hostKey;
export let dbKey;
export let collKey;
+ export let tab = 'find';
- let tab = 'find';
let find;
$: if (collection) {
diff --git a/frontend/src/organisms/connection/database/index.svelte b/frontend/src/organisms/connection/database/index.svelte
index 982ba12..c5f13ea 100644
--- a/frontend/src/organisms/connection/database/index.svelte
+++ b/frontend/src/organisms/connection/database/index.svelte
@@ -7,8 +7,7 @@
export let database;
export let hostKey;
export let dbKey;
-
- let tab = 'stats';
+ export let tab = 'stats';
$: if (database) {
database.hostKey = hostKey;
diff --git a/frontend/src/organisms/connection/host/index.svelte b/frontend/src/organisms/connection/host/index.svelte
index de71c01..9c13e1e 100644
--- a/frontend/src/organisms/connection/host/index.svelte
+++ b/frontend/src/organisms/connection/host/index.svelte
@@ -7,8 +7,7 @@
export let host;
export let hostKey;
-
- let tab = 'status';
+ export let tab = 'status';
$: if (host) {
host.hostKey = hostKey;
diff --git a/frontend/src/organisms/connection/index.svelte b/frontend/src/organisms/connection/index.svelte
index 87ee18c..3a5a94a 100644
--- a/frontend/src/organisms/connection/index.svelte
+++ b/frontend/src/organisms/connection/index.svelte
@@ -2,12 +2,16 @@
import Icon from '$components/icon.svelte';
import hostTree from '$lib/stores/hosttree';
import sharedState from '$lib/stores/sharedstate';
+ import { EventsOn } from '$wails/runtime/runtime';
import CollectionView from './collection/index.svelte';
import DatabaseView from './database/index.svelte';
import HostView from './host/index.svelte';
import HostTree from './hosttree.svelte';
let path = [];
+ let hostTab = '';
+ let dbTab = '';
+ let collTab = '';
$: activeHostKey = path[0];
$: activeDbKey = path[1];
@@ -16,6 +20,28 @@
$: sharedState.currentHost.set(activeHostKey);
$: sharedState.currentDb.set(activeDbKey);
$: sharedState.currentColl.set(activeCollKey);
+
+ EventsOn('ui.host.new', () => hostTree.newHost());
+ EventsOn('ui.host.edit', () => $hostTree[activeHostKey]?.edit());
+ EventsOn('ui.host.remove', () => $hostTree[activeHostKey]?.remove());
+ EventsOn('ui.host.tab', tab => {
+ path = path.slice(0, 1);
+ hostTab = tab;
+ });
+
+ EventsOn('ui.db.new', () => $hostTree[activeHostKey]?.newDatabase());
+ EventsOn('ui.db.dump', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.dump());
+ EventsOn('ui.db.drop', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.drop());
+ EventsOn('ui.db.tab', tab => {
+ path = path.slice(0, 2);
+ dbTab = tab;
+ });
+
+ EventsOn('ui.coll.new', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.newCollection());
+ EventsOn('ui.coll.truncate', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.collections[activeCollKey]?.truncate());
+ EventsOn('ui.coll.drop', () => $hostTree[activeHostKey]?.databases[activeDbKey]?.collections[activeCollKey]?.drop());
+ EventsOn('ui.coll.tab', tab => collTab = tab);
+
@@ -34,17 +60,20 @@
hostKey={activeHostKey}
dbKey={activeDbKey}
collKey={activeCollKey}
+ bind:tab={collTab}
/>
{:else if activeDbKey}
{:else if activeHostKey}
{/if}
diff --git a/internal/app/app_menu.go b/internal/app/app_menu.go
index f9d57ce..68477ec 100644
--- a/internal/app/app_menu.go
+++ b/internal/app/app_menu.go
@@ -14,7 +14,7 @@ func menuCallbackEmit(a *App, eventName string, data ...interface{}) func(cd *me
}
}
-func menuCallbackURL(a *App, url string) func(cd *menu.CallbackData) {
+func menuCallbackOpenURL(a *App, url string) func(cd *menu.CallbackData) {
return func(cd *menu.CallbackData) {
wailsRuntime.BrowserOpenURL(a.ctx, url)
}
@@ -32,38 +32,62 @@ func (a *App) Menu() *menu.Menu {
aboutMenu.AddText("Open log directory…", nil, func(cd *menu.CallbackData) { a.ui.Reveal(a.Env.LogDirectory) })
aboutMenu.AddText("Purge logs…", nil, func(cd *menu.CallbackData) { a.PurgeLogDirectory() })
aboutMenu.AddSeparator()
- aboutMenu.AddText("Quit Rolens", keys.CmdOrCtrl("q"), func(cd *menu.CallbackData) { wailsRuntime.Quit(a.ctx) })
-
- fileMenu := appMenu.AddSubmenu("File")
- fileMenu.AddText("New host…", keys.CmdOrCtrl("y"), menuCallbackEmit(a, "CreateHost"))
- fileMenu.AddSeparator()
- fileMenu.AddText("Stats", keys.Combo("h", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuCallbackEmit(a, "OpenCollectionTab", "stats"))
- fileMenu.AddText("Find", keys.Combo("f", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuCallbackEmit(a, "OpenCollectionTab", "find"))
- fileMenu.AddText("Insert", keys.Combo("i", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuCallbackEmit(a, "OpenCollectionTab", "insert"))
- fileMenu.AddText("Update", keys.Combo("u", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuCallbackEmit(a, "OpenCollectionTab", "update"))
- fileMenu.AddText("Remove", keys.Combo("r", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuCallbackEmit(a, "OpenCollectionTab", "remove"))
- fileMenu.AddText("Indexes", keys.Combo("x", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuCallbackEmit(a, "OpenCollectionTab", "indexes"))
- fileMenu.AddText("Aggregate", keys.Combo("a", keys.CmdOrCtrlKey, keys.OptionOrAltKey), menuCallbackEmit(a, "OpenCollectionTab", "aggregate"))
if runtime.GOOS == "darwin" {
- appMenu.Append(menu.EditMenu())
+ aboutMenu.AddText("Minimize", keys.CmdOrCtrl("M"), func(cd *menu.CallbackData) { wailsRuntime.WindowMinimise(a.ctx) })
+ aboutMenu.AddText("Hide Rolens", keys.CmdOrCtrl("H"), func(cd *menu.CallbackData) { wailsRuntime.WindowHide(a.ctx) })
+ aboutMenu.AddSeparator()
- windowMenu := appMenu.AddSubmenu("Window")
- windowMenu.AddText("Minimize", keys.CmdOrCtrl("M"), func(cd *menu.CallbackData) { wailsRuntime.WindowMinimise(a.ctx) })
- windowMenu.AddText("Hide", keys.CmdOrCtrl("H"), func(cd *menu.CallbackData) { wailsRuntime.WindowMinimise(a.ctx) })
+ appMenu.Append(menu.EditMenu())
}
+ aboutMenu.AddText("Quit Rolens", keys.CmdOrCtrl("q"), func(cd *menu.CallbackData) { wailsRuntime.Quit(a.ctx) })
+
+ hostMenu := appMenu.AddSubmenu("Host")
+ hostMenu.AddText("New…", nil, menuCallbackEmit(a, "ui.host.new"))
+ hostMenu.AddText("Edit host…", nil, menuCallbackEmit(a, "ui.host.edit"))
+ hostMenu.AddSeparator()
+ hostMenu.AddText("Server status", nil, menuCallbackEmit(a, "ui.host.tab", "status"))
+ hostMenu.AddText("System info", nil, menuCallbackEmit(a, "ui.host.tab", "systemInfo"))
+ hostMenu.AddText("Shell", nil, menuCallbackEmit(a, "ui.host.tab", "shell"))
+ hostMenu.AddSeparator()
+ hostMenu.AddText("Remove host…", nil, menuCallbackEmit(a, "ui.host.remove"))
+
+ dbMenu := appMenu.AddSubmenu("Database")
+ dbMenu.AddText("New…", nil, menuCallbackEmit(a, "ui.db.new"))
+ dbMenu.AddSeparator()
+ dbMenu.AddText("Database statistics", nil, menuCallbackEmit(a, "ui.db.tab", "stats"))
+ dbMenu.AddText("Shell", nil, menuCallbackEmit(a, "ui.db.tab", "shell"))
+ dbMenu.AddSeparator()
+ dbMenu.AddText("Dump…", nil, menuCallbackEmit(a, "ui.db.dump"))
+ dbMenu.AddText("Drop…", nil, menuCallbackEmit(a, "ui.db.drop"))
+
+ collMenu := appMenu.AddSubmenu("Collection")
+ collMenu.AddText("New…", nil, menuCallbackEmit(a, "ui.coll.new"))
+ collMenu.AddSeparator()
+ collMenu.AddText("Collection statistics", nil, menuCallbackEmit(a, "ui.coll.tab", "stats"))
+ collMenu.AddText("Find", nil, menuCallbackEmit(a, "ui.coll.tab", "find"))
+ collMenu.AddText("Insert", nil, menuCallbackEmit(a, "ui.coll.tab", "insert"))
+ collMenu.AddText("Update", nil, menuCallbackEmit(a, "ui.coll.tab", "update"))
+ collMenu.AddText("Remove", nil, menuCallbackEmit(a, "ui.coll.tab", "remove"))
+ collMenu.AddText("Indexes", nil, menuCallbackEmit(a, "ui.coll.tab", "indexes"))
+ collMenu.AddText("Aggregate", nil, menuCallbackEmit(a, "ui.coll.tab", "aggregate"))
+ collMenu.AddText("Shell", nil, menuCallbackEmit(a, "ui.coll.tab", "shell"))
+ collMenu.AddSeparator()
+ collMenu.AddText("Truncate…", nil, menuCallbackEmit(a, "ui.coll.truncate"))
+ collMenu.AddText("Drop…", nil, menuCallbackEmit(a, "ui.coll.drop"))
+
helpMenu := appMenu.AddSubmenu("Help")
- helpMenu.AddText("User guide", nil, menuCallbackURL(a, "https://garraflavatra.github.io/rolens/user-guide/"))
- helpMenu.AddText("Website", nil, menuCallbackURL(a, "https://garraflavatra.github.io/rolens/"))
- helpMenu.AddText("Discussion board", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens/discussions"))
+ helpMenu.AddText("User guide", nil, menuCallbackOpenURL(a, "https://garraflavatra.github.io/rolens/user-guide/"))
+ helpMenu.AddText("Website", nil, menuCallbackOpenURL(a, "https://garraflavatra.github.io/rolens/"))
+ helpMenu.AddText("Discussion board", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens/discussions"))
helpMenu.AddSeparator()
- helpMenu.AddText("Report a problem", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens/issues/new"))
- helpMenu.AddText("Ask a question", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens/discussions/new?category=questions"))
+ helpMenu.AddText("Report a problem", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens/issues/new"))
+ helpMenu.AddText("Ask a question", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens/discussions/new?category=questions"))
helpMenu.AddSeparator()
- helpMenu.AddText("Star Rolens on GitHub", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens"))
- helpMenu.AddText("Changelog", nil, menuCallbackURL(a, "https://garraflavatra.github.io/rolens/development/changelog/"))
- helpMenu.AddText("License", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens/blob/main/LICENSE"))
+ helpMenu.AddText("Star Rolens on GitHub", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens"))
+ helpMenu.AddText("Changelog", nil, menuCallbackOpenURL(a, "https://garraflavatra.github.io/rolens/development/changelog/"))
+ helpMenu.AddText("License", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens/blob/main/LICENSE"))
return appMenu
}