mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-06-28 05:25:11 +00:00
Improved the app menu
This commit is contained in:
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -16,8 +16,8 @@
|
||||
export let hostKey;
|
||||
export let dbKey;
|
||||
export let collKey;
|
||||
export let tab = 'find';
|
||||
|
||||
let tab = 'find';
|
||||
let find;
|
||||
|
||||
$: if (collection) {
|
||||
|
@ -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;
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
export let host;
|
||||
export let hostKey;
|
||||
|
||||
let tab = 'status';
|
||||
export let tab = 'status';
|
||||
|
||||
$: if (host) {
|
||||
host.hostKey = hostKey;
|
||||
|
@ -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);
|
||||
|
||||
</script>
|
||||
|
||||
<div class="tree">
|
||||
@ -34,17 +60,20 @@
|
||||
hostKey={activeHostKey}
|
||||
dbKey={activeDbKey}
|
||||
collKey={activeCollKey}
|
||||
bind:tab={collTab}
|
||||
/>
|
||||
{:else if activeDbKey}
|
||||
<DatabaseView
|
||||
database={$hostTree[activeHostKey]?.databases[activeDbKey]}
|
||||
hostKey={activeHostKey}
|
||||
dbKey={activeDbKey}
|
||||
bind:tab={dbTab}
|
||||
/>
|
||||
{:else if activeHostKey}
|
||||
<HostView
|
||||
host={$hostTree[activeHostKey]}
|
||||
hostKey={activeHostKey}
|
||||
bind:tab={hostTab}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
|
Reference in New Issue
Block a user