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