mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 13:07:58 +00:00
Improved the app menu
This commit is contained in:
parent
5191086d74
commit
9acb89205d
@ -5,6 +5,7 @@
|
|||||||
* Improved error logging and dialogs.
|
* Improved error logging and dialogs.
|
||||||
* Fixed host editing bug.
|
* Fixed host editing bug.
|
||||||
* Made table headers stick to the top.
|
* Made table headers stick to the top.
|
||||||
|
* Improved the application menu.
|
||||||
|
|
||||||
## [v0.2.1]
|
## [v0.2.1]
|
||||||
|
|
||||||
|
@ -150,21 +150,15 @@ async function refresh() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
collection.truncate = async function() {
|
collection.truncate = async function() {
|
||||||
const progress = startProgress(`Truncating collection "${collKey}"…`);
|
|
||||||
await TruncateCollection(hostKey, dbKey, collKey);
|
await TruncateCollection(hostKey, dbKey, collKey);
|
||||||
await refresh();
|
await refresh();
|
||||||
progress.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
collection.drop = async function() {
|
collection.drop = async function() {
|
||||||
const progress = startProgress(`Dropping collection "${collKey}"…`);
|
|
||||||
const success = await DropCollection(hostKey, dbKey, collKey);
|
const success = await DropCollection(hostKey, dbKey, collKey);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
await refresh();
|
await refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.end();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
collection.getIndexes = async function() {
|
collection.getIndexes = async function() {
|
||||||
@ -187,9 +181,7 @@ async function refresh() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
index.drop = async function() {
|
index.drop = async function() {
|
||||||
const progress = startProgress(`Dropping index ${index.name}…`);
|
|
||||||
const hasBeenDropped = await DropIndex(hostKey, dbKey, collKey, index.name);
|
const hasBeenDropped = await DropIndex(hostKey, dbKey, collKey, index.name);
|
||||||
progress.end();
|
|
||||||
return hasBeenDropped;
|
return hasBeenDropped;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -208,14 +200,10 @@ async function refresh() {
|
|||||||
|
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
dialog.$on('create', async event => {
|
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));
|
const newIndexName = await CreateIndex(collection.hostKey, collection.dbKey, collection.key, JSON.stringify(event.detail.index));
|
||||||
|
|
||||||
if (newIndexName) {
|
if (newIndexName) {
|
||||||
dialog.$close();
|
dialog.$close();
|
||||||
}
|
}
|
||||||
|
|
||||||
progress.end();
|
|
||||||
resolve(newIndexName);
|
resolve(newIndexName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
export let hostKey;
|
export let hostKey;
|
||||||
export let dbKey;
|
export let dbKey;
|
||||||
export let collKey;
|
export let collKey;
|
||||||
|
export let tab = 'find';
|
||||||
|
|
||||||
let tab = 'find';
|
|
||||||
let find;
|
let find;
|
||||||
|
|
||||||
$: if (collection) {
|
$: if (collection) {
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
export let database;
|
export let database;
|
||||||
export let hostKey;
|
export let hostKey;
|
||||||
export let dbKey;
|
export let dbKey;
|
||||||
|
export let tab = 'stats';
|
||||||
let tab = 'stats';
|
|
||||||
|
|
||||||
$: if (database) {
|
$: if (database) {
|
||||||
database.hostKey = hostKey;
|
database.hostKey = hostKey;
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
|
|
||||||
export let host;
|
export let host;
|
||||||
export let hostKey;
|
export let hostKey;
|
||||||
|
export let tab = 'status';
|
||||||
let tab = 'status';
|
|
||||||
|
|
||||||
$: if (host) {
|
$: if (host) {
|
||||||
host.hostKey = hostKey;
|
host.hostKey = hostKey;
|
||||||
|
@ -2,12 +2,16 @@
|
|||||||
import Icon from '$components/icon.svelte';
|
import Icon from '$components/icon.svelte';
|
||||||
import hostTree from '$lib/stores/hosttree';
|
import hostTree from '$lib/stores/hosttree';
|
||||||
import sharedState from '$lib/stores/sharedstate';
|
import sharedState from '$lib/stores/sharedstate';
|
||||||
|
import { EventsOn } from '$wails/runtime/runtime';
|
||||||
import CollectionView from './collection/index.svelte';
|
import CollectionView from './collection/index.svelte';
|
||||||
import DatabaseView from './database/index.svelte';
|
import DatabaseView from './database/index.svelte';
|
||||||
import HostView from './host/index.svelte';
|
import HostView from './host/index.svelte';
|
||||||
import HostTree from './hosttree.svelte';
|
import HostTree from './hosttree.svelte';
|
||||||
|
|
||||||
let path = [];
|
let path = [];
|
||||||
|
let hostTab = '';
|
||||||
|
let dbTab = '';
|
||||||
|
let collTab = '';
|
||||||
|
|
||||||
$: activeHostKey = path[0];
|
$: activeHostKey = path[0];
|
||||||
$: activeDbKey = path[1];
|
$: activeDbKey = path[1];
|
||||||
@ -16,6 +20,28 @@
|
|||||||
$: sharedState.currentHost.set(activeHostKey);
|
$: sharedState.currentHost.set(activeHostKey);
|
||||||
$: sharedState.currentDb.set(activeDbKey);
|
$: sharedState.currentDb.set(activeDbKey);
|
||||||
$: sharedState.currentColl.set(activeCollKey);
|
$: 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);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="tree">
|
<div class="tree">
|
||||||
@ -34,17 +60,20 @@
|
|||||||
hostKey={activeHostKey}
|
hostKey={activeHostKey}
|
||||||
dbKey={activeDbKey}
|
dbKey={activeDbKey}
|
||||||
collKey={activeCollKey}
|
collKey={activeCollKey}
|
||||||
|
bind:tab={collTab}
|
||||||
/>
|
/>
|
||||||
{:else if activeDbKey}
|
{:else if activeDbKey}
|
||||||
<DatabaseView
|
<DatabaseView
|
||||||
database={$hostTree[activeHostKey]?.databases[activeDbKey]}
|
database={$hostTree[activeHostKey]?.databases[activeDbKey]}
|
||||||
hostKey={activeHostKey}
|
hostKey={activeHostKey}
|
||||||
dbKey={activeDbKey}
|
dbKey={activeDbKey}
|
||||||
|
bind:tab={dbTab}
|
||||||
/>
|
/>
|
||||||
{:else if activeHostKey}
|
{:else if activeHostKey}
|
||||||
<HostView
|
<HostView
|
||||||
host={$hostTree[activeHostKey]}
|
host={$hostTree[activeHostKey]}
|
||||||
hostKey={activeHostKey}
|
hostKey={activeHostKey}
|
||||||
|
bind:tab={hostTab}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
@ -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) {
|
return func(cd *menu.CallbackData) {
|
||||||
wailsRuntime.BrowserOpenURL(a.ctx, url)
|
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("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.AddText("Purge logs…", nil, func(cd *menu.CallbackData) { a.PurgeLogDirectory() })
|
||||||
aboutMenu.AddSeparator()
|
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" {
|
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")
|
appMenu.Append(menu.EditMenu())
|
||||||
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) })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 := appMenu.AddSubmenu("Help")
|
||||||
helpMenu.AddText("User guide", nil, menuCallbackURL(a, "https://garraflavatra.github.io/rolens/user-guide/"))
|
helpMenu.AddText("User guide", nil, menuCallbackOpenURL(a, "https://garraflavatra.github.io/rolens/user-guide/"))
|
||||||
helpMenu.AddText("Website", nil, menuCallbackURL(a, "https://garraflavatra.github.io/rolens/"))
|
helpMenu.AddText("Website", nil, menuCallbackOpenURL(a, "https://garraflavatra.github.io/rolens/"))
|
||||||
helpMenu.AddText("Discussion board", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens/discussions"))
|
helpMenu.AddText("Discussion board", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens/discussions"))
|
||||||
helpMenu.AddSeparator()
|
helpMenu.AddSeparator()
|
||||||
helpMenu.AddText("Report a problem", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens/issues/new"))
|
helpMenu.AddText("Report a problem", nil, menuCallbackOpenURL(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("Ask a question", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens/discussions/new?category=questions"))
|
||||||
helpMenu.AddSeparator()
|
helpMenu.AddSeparator()
|
||||||
helpMenu.AddText("Star Rolens on GitHub", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens"))
|
helpMenu.AddText("Star Rolens on GitHub", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens"))
|
||||||
helpMenu.AddText("Changelog", nil, menuCallbackURL(a, "https://garraflavatra.github.io/rolens/development/changelog/"))
|
helpMenu.AddText("Changelog", nil, menuCallbackOpenURL(a, "https://garraflavatra.github.io/rolens/development/changelog/"))
|
||||||
helpMenu.AddText("License", nil, menuCallbackURL(a, "https://github.com/garraflavatra/rolens/blob/main/LICENSE"))
|
helpMenu.AddText("License", nil, menuCallbackOpenURL(a, "https://github.com/garraflavatra/rolens/blob/main/LICENSE"))
|
||||||
|
|
||||||
return appMenu
|
return appMenu
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user