mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-07-20 06:28:04 +00:00
Display sb stats generated by dbStats
command (#15)
This commit is contained in:
@ -15,7 +15,7 @@
|
||||
export let collection;
|
||||
export let hostKey;
|
||||
export let dbKey;
|
||||
export let collectionKey;
|
||||
export let collKey;
|
||||
|
||||
let tab = 'find';
|
||||
let find;
|
||||
@ -25,10 +25,10 @@
|
||||
$: if (collection) {
|
||||
collection.hostKey = hostKey;
|
||||
collection.dbKey = dbKey;
|
||||
collection.key = collectionKey;
|
||||
collection.key = collKey;
|
||||
}
|
||||
|
||||
$: if (hostKey || dbKey || collectionKey) {
|
||||
$: if (hostKey || dbKey || collKey) {
|
||||
tab = 'find';
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="collection" class:empty={!collection}>
|
||||
<div class="view" class:empty={!collection}>
|
||||
{#if collection}
|
||||
{#key collection}
|
||||
<TabBar tabs={[
|
||||
@ -85,12 +85,12 @@
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.collection {
|
||||
.view {
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template: auto 1fr / 1fr;
|
||||
}
|
||||
.collection.empty {
|
||||
.view.empty {
|
||||
grid-template: 1fr / 1fr;
|
||||
}
|
||||
|
||||
|
60
frontend/src/organisms/connection/database/index.svelte
Normal file
60
frontend/src/organisms/connection/database/index.svelte
Normal file
@ -0,0 +1,60 @@
|
||||
<script>
|
||||
import BlankState from '$components/blankstate.svelte';
|
||||
import TabBar from '$components/tabbar.svelte';
|
||||
import { EventsOn } from '$wails/runtime/runtime';
|
||||
import Stats from './stats.svelte';
|
||||
|
||||
export let database;
|
||||
export let hostKey;
|
||||
export let dbKey;
|
||||
|
||||
let tab = 'stats';
|
||||
|
||||
$: if (database) {
|
||||
database.hostKey = hostKey;
|
||||
database.dbKey = dbKey;
|
||||
}
|
||||
|
||||
$: if (hostKey || dbKey) {
|
||||
tab = 'stats';
|
||||
}
|
||||
|
||||
EventsOn('OpenStatsTab', name => (tab = name || tab));
|
||||
</script>
|
||||
|
||||
<div class="view" class:empty={!database}>
|
||||
{#if database}
|
||||
{#key database}
|
||||
<TabBar tabs={[ { key: 'stats', icon: 'chart', title: 'Stats' } ]} bind:selectedKey={tab} />
|
||||
<div class="container">
|
||||
{#if tab === 'stats'} <Stats {database} />
|
||||
{/if}
|
||||
</div>
|
||||
{/key}
|
||||
{:else}
|
||||
<BlankState label="Select a database to continue" />
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.view {
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template: auto 1fr / 1fr;
|
||||
}
|
||||
.view.empty {
|
||||
grid-template: 1fr / 1fr;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 0.5rem;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
overflow: auto;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.container > :global(*) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
45
frontend/src/organisms/connection/database/stats.svelte
Normal file
45
frontend/src/organisms/connection/database/stats.svelte
Normal file
@ -0,0 +1,45 @@
|
||||
<script>
|
||||
import Icon from '$components/icon.svelte';
|
||||
import ObjectGrid from '$components/objectgrid.svelte';
|
||||
|
||||
export let database;
|
||||
|
||||
let copySucceeded = false;
|
||||
|
||||
async function copy() {
|
||||
const json = JSON.stringify(collection.stats, undefined, '\t');
|
||||
await navigator.clipboard.writeText(json);
|
||||
copySucceeded = true;
|
||||
setTimeout(() => copySucceeded = false, 1500);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="stats">
|
||||
<!-- <CodeExample code="db.stats()" /> -->
|
||||
|
||||
<div class="grid">
|
||||
<ObjectGrid data={database.stats} />
|
||||
</div>
|
||||
|
||||
<div class="buttons">
|
||||
<button class="btn secondary" on:click={copy}>
|
||||
<Icon name={copySucceeded ? 'check' : 'clipboard'} />
|
||||
Copy JSON
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.stats {
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
grid-template: 1fr auto / 1fr;
|
||||
}
|
||||
|
||||
.stats .grid {
|
||||
overflow: auto;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
</style>
|
@ -62,9 +62,10 @@
|
||||
|
||||
async function openDatabase(dbKey) {
|
||||
const progress = startProgress(`Opening database "${dbKey}"…`);
|
||||
const collections = await OpenDatabase(activeHostKey, dbKey);
|
||||
const { collections, stats } = await OpenDatabase(activeHostKey, dbKey);
|
||||
activeDbKey = dbKey;
|
||||
activeCollKey = '';
|
||||
$connections[activeHostKey].databases[dbKey].stats = stats;
|
||||
|
||||
for (const collKey of collections || []) {
|
||||
$connections[activeHostKey].databases[dbKey].collections[collKey] =
|
||||
|
@ -5,7 +5,8 @@
|
||||
import { EnterText } from '$wails/go/ui/UI';
|
||||
import { EventsOn } from '$wails/runtime/runtime';
|
||||
import { onMount } from 'svelte';
|
||||
import CollectionDetail from './collection/index.svelte';
|
||||
import DatabaseView from './database/index.svelte';
|
||||
import CollectionView from './collection/index.svelte';
|
||||
import DumpInfo from './dump.svelte';
|
||||
import HostDetail from './hostdetail.svelte';
|
||||
import HostTree from './hosttree.svelte';
|
||||
@ -110,12 +111,20 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<CollectionDetail
|
||||
collection={$connections[activeHostKey]?.databases[activeDbKey]?.collections?.[activeCollKey]}
|
||||
hostKey={activeHostKey}
|
||||
dbKey={activeDbKey}
|
||||
collectionKey={activeCollKey}
|
||||
/>
|
||||
{#if activeCollKey}
|
||||
<CollectionView
|
||||
collection={$connections[activeHostKey]?.databases[activeDbKey]?.collections?.[activeCollKey]}
|
||||
hostKey={activeHostKey}
|
||||
dbKey={activeDbKey}
|
||||
collKey={activeCollKey}
|
||||
/>
|
||||
{:else if activeDbKey}
|
||||
<DatabaseView
|
||||
database={$connections[activeHostKey]?.databases[activeDbKey]}
|
||||
hostKey={activeHostKey}
|
||||
dbKey={activeDbKey}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<HostDetail
|
||||
bind:show={showHostDetail}
|
||||
|
Reference in New Issue
Block a user