From ea77b4fc1a5630bb57c9b3165acca957baefd981 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Fri, 9 Dec 2022 15:41:42 +0100 Subject: [PATCH] view profile data --- packages/web/src/tabs/ServerSummaryTab.svelte | 24 +++++++++++++++---- .../dbgate-plugin-mongo/src/backend/driver.js | 6 +++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/web/src/tabs/ServerSummaryTab.svelte b/packages/web/src/tabs/ServerSummaryTab.svelte index 20dfca6d..c826eac8 100644 --- a/packages/web/src/tabs/ServerSummaryTab.svelte +++ b/packages/web/src/tabs/ServerSummaryTab.svelte @@ -5,14 +5,30 @@ import ObjectListControl from '../elements/ObjectListControl.svelte'; import { apiCall } from '../utility/api'; import formatFileSize from '../utility/formatFileSize'; + import openNewTab from '../utility/openNewTab'; export let conid; let refreshToken = 0; - async function callAction(command, row) { - await apiCall('server-connections/summary-command', { conid, refreshToken, command, row }); - refreshToken += 1; + async function runAction(action, row) { + const { command, openQuery } = action; + if (command) { + await apiCall('server-connections/summary-command', { conid, refreshToken, command, row }); + refreshToken += 1; + } + if (openQuery) { + openNewTab({ + title: action.tabTitle || row.name, + icon: 'img query-data', + tabComponent: 'QueryDataTab', + props: { + conid, + database: row.name, + sql: openQuery, + }, + }); + } } @@ -36,7 +52,7 @@ {#if index > 0} | {/if} - callAction(action.command, row)}>{action.header} + runAction(action, row)}>{action.header} {/each} diff --git a/plugins/dbgate-plugin-mongo/src/backend/driver.js b/plugins/dbgate-plugin-mongo/src/backend/driver.js index b69ff7e5..fbc2f6de 100644 --- a/plugins/dbgate-plugin-mongo/src/backend/driver.js +++ b/plugins/dbgate-plugin-mongo/src/backend/driver.js @@ -403,6 +403,7 @@ const driver = { { fieldName: 'setProfile', columnType: 'actions', + header: 'Profiling actions', actions: [ { header: 'Off', @@ -416,6 +417,11 @@ const driver = { header: 'All', command: 'profileAll', }, + { + header: 'View', + openQuery: "db['system.profile'].find()", + tabTitle: 'Profile data', + }, ], }, ],