mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
mongo summary improved
This commit is contained in:
parent
ceea1a9047
commit
e6ac878b74
@ -42,32 +42,32 @@
|
||||
{clickable}
|
||||
on:clickrow
|
||||
>
|
||||
<svelte:fragment slot="-1" let:row>
|
||||
<slot name="name" {row} />
|
||||
<svelte:fragment slot="-1" let:row let:col>
|
||||
<slot name="name" {row} {col} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="0" let:row>
|
||||
<slot name="0" {row} />
|
||||
<svelte:fragment slot="0" let:row let:col>
|
||||
<slot name="0" {row} {col} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="1" let:row>
|
||||
<slot name="1" {row} />
|
||||
<svelte:fragment slot="1" let:row let:col>
|
||||
<slot name="1" {row} {col} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="2" let:row>
|
||||
<slot name="2" {row} />
|
||||
<svelte:fragment slot="2" let:row let:col>
|
||||
<slot name="2" {row} {col} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="3" let:row>
|
||||
<slot name="3" {row} />
|
||||
<svelte:fragment slot="3" let:row let:col>
|
||||
<slot name="3" {row} {col} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="4" let:row>
|
||||
<slot name="4" {row} />
|
||||
<svelte:fragment slot="4" let:row let:col>
|
||||
<slot name="4" {row} {col} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="5" let:row>
|
||||
<slot name="5" {row} />
|
||||
<svelte:fragment slot="5" let:row let:col>
|
||||
<slot name="5" {row} {col} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="6" let:row>
|
||||
<slot name="6" {row} />
|
||||
<svelte:fragment slot="6" let:row let:col>
|
||||
<slot name="6" {row} {col} />
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="7" let:row>
|
||||
<slot name="7" {row} />
|
||||
<svelte:fragment slot="7" let:row let:col>
|
||||
<slot name="7" {row} {col} />
|
||||
</svelte:fragment>
|
||||
</TableControl>
|
||||
</div>
|
||||
|
@ -86,17 +86,17 @@
|
||||
{:else if col.formatter}
|
||||
{col.formatter(row)}
|
||||
{:else if col.slot != null}
|
||||
{#if col.slot == -1}<slot name="-1" {row} {index} />
|
||||
{:else if col.slot == 0}<slot name="0" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 1}<slot name="1" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 2}<slot name="2" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 3}<slot name="3" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 4}<slot name="4" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 5}<slot name="5" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 6}<slot name="6" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 7}<slot name="7" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 8}<slot name="8" {row} {index} {...rowProps} />
|
||||
{:else if col.slot == 9}<slot name="9" {row} {index} {...rowProps} />
|
||||
{#if col.slot == -1}<slot name="-1" {row} {col} {index} />
|
||||
{:else if col.slot == 0}<slot name="0" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 1}<slot name="1" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 2}<slot name="2" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 3}<slot name="3" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 4}<slot name="4" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 5}<slot name="5" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 6}<slot name="6" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 7}<slot name="7" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 8}<slot name="8" {row} {col} {index} {...rowProps} />
|
||||
{:else if col.slot == 9}<slot name="9" {row} {col} {index} {...rowProps} />
|
||||
{/if}
|
||||
{:else}
|
||||
{row[col.fieldName] || ''}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
import ObjectListControl from '../elements/ObjectListControl.svelte';
|
||||
import { apiCall } from '../utility/api';
|
||||
import formatFileSize from '../utility/formatFileSize';
|
||||
|
||||
export let conid;
|
||||
|
||||
@ -13,11 +14,30 @@
|
||||
{#await apiCall('server-connections/server-summary', { conid, refreshToken })}
|
||||
<LoadingInfo message="Loading server details" wrapper />
|
||||
{:then summary}
|
||||
<ObjectListControl
|
||||
collection={summary.databases}
|
||||
hideDisplayName
|
||||
title="Databases"
|
||||
emptyMessage={'No databases'}
|
||||
columns={summary.columns}
|
||||
/>
|
||||
<div class="wrapper">
|
||||
<ObjectListControl
|
||||
collection={summary.databases}
|
||||
hideDisplayName
|
||||
title={`Databases (${summary.databases.length})`}
|
||||
emptyMessage={'No databases'}
|
||||
columns={summary.columns.map(col => ({
|
||||
...col,
|
||||
slot: col.dataType == 'bytes' ? 1 : null,
|
||||
}))}
|
||||
>
|
||||
<svelte:fragment slot="1" let:row let:col>{formatFileSize(row?.[col.fieldName])}</svelte:fragment>
|
||||
</ObjectListControl>
|
||||
</div>
|
||||
{/await}
|
||||
|
||||
<style>
|
||||
.wrapper {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: var(--theme-bg-0);
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
@ -354,6 +354,21 @@ const driver = {
|
||||
|
||||
async serverSummary(pool) {
|
||||
const res = await pool.__getDatabase().admin().listDatabases();
|
||||
const profiling = await Promise.all(res.databases.map((x) => pool.db(x.name).command({ profile: -1 })));
|
||||
|
||||
function formatProfiling(info) {
|
||||
switch (info.was) {
|
||||
case 0:
|
||||
return 'No profiling';
|
||||
case 1:
|
||||
return `Filtered (>${info.slowms} ms)`;
|
||||
case 2:
|
||||
'Profile all';
|
||||
default:
|
||||
return '???';
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
columns: [
|
||||
{
|
||||
@ -366,8 +381,16 @@ const driver = {
|
||||
dataType: 'bytes',
|
||||
header: 'Size',
|
||||
},
|
||||
{
|
||||
fieldName: 'profiling',
|
||||
dataType: 'string',
|
||||
header: 'Profiling',
|
||||
},
|
||||
],
|
||||
databases: res.databases,
|
||||
databases: res.databases.map((db, i) => ({
|
||||
...db,
|
||||
profiling: formatProfiling(profiling[i]),
|
||||
})),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user