mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 23:45:59 +00:00
SYNC: auto-detect charts is disabled by default #1145
This commit is contained in:
committed by
Diflow
parent
a10fe6994a
commit
9bff8608c1
@@ -146,7 +146,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
executeQuery_meta: true,
|
||||
async executeQuery({ sesid, sql, autoCommit, limitRows, frontMatter }) {
|
||||
async executeQuery({ sesid, sql, autoCommit, autoDetectCharts, limitRows, frontMatter }) {
|
||||
const session = this.opened.find(x => x.sesid == sesid);
|
||||
if (!session) {
|
||||
throw new Error('Invalid session');
|
||||
@@ -154,7 +154,7 @@ module.exports = {
|
||||
|
||||
logger.info({ sesid, sql }, 'Processing query');
|
||||
this.dispatchMessage(sesid, 'Query execution started');
|
||||
session.subprocess.send({ msgtype: 'executeQuery', sql, autoCommit, limitRows, frontMatter });
|
||||
session.subprocess.send({ msgtype: 'executeQuery', sql, autoCommit, autoDetectCharts, limitRows, frontMatter });
|
||||
|
||||
return { state: 'ok' };
|
||||
},
|
||||
|
||||
@@ -117,7 +117,7 @@ async function handleExecuteControlCommand({ command }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleExecuteQuery({ sql, autoCommit, limitRows, frontMatter }) {
|
||||
async function handleExecuteQuery({ sql, autoCommit, autoDetectCharts, limitRows, frontMatter }) {
|
||||
lastActivity = new Date().getTime();
|
||||
|
||||
await waitConnected();
|
||||
@@ -146,7 +146,16 @@ async function handleExecuteQuery({ sql, autoCommit, limitRows, frontMatter }) {
|
||||
...driver.getQuerySplitterOptions('stream'),
|
||||
returnRichInfo: true,
|
||||
})) {
|
||||
await handleQueryStream(dbhan, driver, queryStreamInfoHolder, sqlItem, undefined, limitRows, frontMatter);
|
||||
await handleQueryStream(
|
||||
dbhan,
|
||||
driver,
|
||||
queryStreamInfoHolder,
|
||||
sqlItem,
|
||||
undefined,
|
||||
limitRows,
|
||||
frontMatter,
|
||||
autoDetectCharts
|
||||
);
|
||||
// const handler = new StreamHandler(resultIndex);
|
||||
// const stream = await driver.stream(systemConnection, sqlItem, handler);
|
||||
// handler.stream = stream;
|
||||
|
||||
@@ -14,13 +14,9 @@ class QueryStreamTableWriter {
|
||||
this.currentChangeIndex = 1;
|
||||
this.initializedFile = false;
|
||||
this.sesid = sesid;
|
||||
// if (isProApp()) {
|
||||
// this.chartProcessor = new ChartProcessor();
|
||||
// }
|
||||
this.chartProcessor = new ChartProcessor();
|
||||
}
|
||||
|
||||
initializeFromQuery(structure, resultIndex, chartDefinition) {
|
||||
initializeFromQuery(structure, resultIndex, chartDefinition, autoDetectCharts = false) {
|
||||
this.jslid = crypto.randomUUID();
|
||||
this.currentFile = path.join(jsldir(), `${this.jslid}.jsonl`);
|
||||
fs.writeFileSync(
|
||||
@@ -34,8 +30,8 @@ class QueryStreamTableWriter {
|
||||
this.writeCurrentStats(false, false);
|
||||
this.resultIndex = resultIndex;
|
||||
this.initializedFile = true;
|
||||
if (isProApp() && chartDefinition) {
|
||||
this.chartProcessor = new ChartProcessor([chartDefinition]);
|
||||
if (isProApp() && (chartDefinition || autoDetectCharts)) {
|
||||
this.chartProcessor = chartDefinition ? new ChartProcessor([chartDefinition]) : new ChartProcessor();
|
||||
}
|
||||
process.send({ msgtype: 'recordset', jslid: this.jslid, resultIndex, sesid: this.sesid });
|
||||
}
|
||||
@@ -138,12 +134,14 @@ class StreamHandler {
|
||||
startLine,
|
||||
sesid = undefined,
|
||||
limitRows = undefined,
|
||||
frontMatter = undefined
|
||||
frontMatter = undefined,
|
||||
autoDetectCharts = false
|
||||
) {
|
||||
this.recordset = this.recordset.bind(this);
|
||||
this.startLine = startLine;
|
||||
this.sesid = sesid;
|
||||
this.frontMatter = frontMatter;
|
||||
this.autoDetectCharts = autoDetectCharts;
|
||||
this.limitRows = limitRows;
|
||||
this.rowsLimitOverflow = false;
|
||||
this.row = this.row.bind(this);
|
||||
@@ -177,7 +175,8 @@ class StreamHandler {
|
||||
this.currentWriter.initializeFromQuery(
|
||||
Array.isArray(columns) ? { columns } : columns,
|
||||
this.queryStreamInfoHolder.resultIndex,
|
||||
this.frontMatter?.[`chart-${this.queryStreamInfoHolder.resultIndex + 1}`]
|
||||
this.frontMatter?.[`chart-${this.queryStreamInfoHolder.resultIndex + 1}`],
|
||||
this.autoDetectCharts
|
||||
);
|
||||
this.queryStreamInfoHolder.resultIndex += 1;
|
||||
this.rowCounter = 0;
|
||||
@@ -252,7 +251,8 @@ function handleQueryStream(
|
||||
sqlItem,
|
||||
sesid = undefined,
|
||||
limitRows = undefined,
|
||||
frontMatter = undefined
|
||||
frontMatter = undefined,
|
||||
autoDetectCharts = false
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const start = sqlItem.trimStart || sqlItem.start;
|
||||
@@ -262,7 +262,8 @@ function handleQueryStream(
|
||||
start && start.line,
|
||||
sesid,
|
||||
limitRows,
|
||||
frontMatter
|
||||
frontMatter,
|
||||
autoDetectCharts
|
||||
);
|
||||
driver.stream(dbhan, sqlItem.text, handler);
|
||||
});
|
||||
|
||||
@@ -233,6 +233,8 @@
|
||||
'icon upload': 'mdi mdi-upload',
|
||||
'icon limit': 'mdi mdi-car-speed-limiter',
|
||||
|
||||
'icon chart': 'mdi mdi-chart-bar',
|
||||
|
||||
'img ok': 'mdi mdi-check-circle color-icon-green',
|
||||
'img ok-inv': 'mdi mdi-check-circle color-icon-inv-green',
|
||||
'img alert': 'mdi mdi-alert-circle color-icon-blue',
|
||||
|
||||
@@ -80,6 +80,7 @@
|
||||
label: `Result ${index + 1}`,
|
||||
isResult: true,
|
||||
component: JslDataGrid,
|
||||
resultIndex: info.resultIndex,
|
||||
props: { jslid: info.jslid, driver, onOpenChart: () => handleOpenChart(info.resultIndex) },
|
||||
}))),
|
||||
...charts.map((info, index) => ({
|
||||
@@ -144,6 +145,21 @@
|
||||
}
|
||||
onSetFrontMatterField?.('selected-chart', resultIndex + 1);
|
||||
}
|
||||
|
||||
export function openCurrentChart() {
|
||||
const currentIndex = domTabs.getValue();
|
||||
console.log('Current index:', currentIndex);
|
||||
const currentTab = allTabs[currentIndex];
|
||||
console.log('Current tab:', currentTab);
|
||||
if (currentTab?.isChart) {
|
||||
return;
|
||||
}
|
||||
const resultIndex = currentTab?.resultIndex;
|
||||
console.log('Result index:', resultIndex);
|
||||
if (resultIndex != null) {
|
||||
handleOpenChart(resultIndex);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<TabControl
|
||||
|
||||
@@ -156,6 +156,7 @@
|
||||
import { getIntSettingsValue } from '../settings/settingsTools';
|
||||
import RowsLimitModal from '../modals/RowsLimitModal.svelte';
|
||||
import _ from 'lodash';
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
|
||||
export let tabid;
|
||||
export let conid;
|
||||
@@ -209,6 +210,8 @@
|
||||
let isInTransaction = false;
|
||||
let isAutocommit = false;
|
||||
let splitterInitialValue = undefined;
|
||||
let autoDetectCharts = false;
|
||||
let domResultTabs;
|
||||
|
||||
const queryRowsLimitLocalStorageKey = `tabdata_limitRows_${tabid}`;
|
||||
function getInitialRowsLimit() {
|
||||
@@ -393,6 +396,7 @@
|
||||
autoCommit: driver?.implicitTransactions && isAutocommit,
|
||||
limitRows: queryRowsLimit ? queryRowsLimit : undefined,
|
||||
frontMatter,
|
||||
autoDetectCharts,
|
||||
});
|
||||
}
|
||||
await apiCall('query-history/write', {
|
||||
@@ -727,6 +731,7 @@
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="2">
|
||||
<ResultTabs
|
||||
bind:this={domResultTabs}
|
||||
tabs={[{ label: 'Messages', slot: 0 }]}
|
||||
{sessionId}
|
||||
{executeNumber}
|
||||
@@ -846,6 +851,30 @@
|
||||
data-testid="QueryTab_rollbackTransactionButton"
|
||||
hideDisabled
|
||||
/>
|
||||
|
||||
{#if isProApp() && visibleResultTabs && !busy}
|
||||
<ToolStripButton
|
||||
icon="icon chart"
|
||||
on:click={() => {
|
||||
domResultTabs?.openCurrentChart();
|
||||
}}
|
||||
>
|
||||
Open chart</ToolStripButton
|
||||
>
|
||||
{/if}
|
||||
{#if isProApp() && !visibleResultTabs}
|
||||
<ToolStripButton
|
||||
icon="icon chart"
|
||||
on:click={() => {
|
||||
autoDetectCharts = !autoDetectCharts;
|
||||
}}
|
||||
>
|
||||
Detect chart<FontIcon
|
||||
icon={autoDetectCharts ? 'icon checkbox-marked' : 'icon checkbox-blank'}
|
||||
padLeft
|
||||
/></ToolStripButton
|
||||
>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</ToolStripContainer>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user