From cd58059a21506bed836439e713c08ce7e278c3fe Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Thu, 14 Nov 2024 14:18:17 +0000 Subject: [PATCH 1/2] fix results tab --- src/classes/insightsConnection.ts | 10 +++++++--- src/services/resultsPanelProvider.ts | 23 +++++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/classes/insightsConnection.ts b/src/classes/insightsConnection.ts index 7f2a71cd..6283ba47 100644 --- a/src/classes/insightsConnection.ts +++ b/src/classes/insightsConnection.ts @@ -65,7 +65,7 @@ export class InsightsConnection { if (token) { await this.getConfig(); await this.getMeta(); - await this.getScratchpadQuery(""); + await this.getScratchpadQuery("", undefined, false, true); } }); return this.connected; @@ -398,9 +398,13 @@ export class InsightsConnection { query: string, context?: string, isPython?: boolean, + isStarting?: boolean, ): Promise { if (this.connected && this.connEndpoints) { const isTableView = ext.isResultsTabVisible; + const queryMsg = isStarting + ? "Starting scratchpad..." + : "Query is executing..."; const scratchpadURL = new url.URL( this.connEndpoints.scratchpad.scratchpad, this.node.details.server, @@ -451,7 +455,7 @@ export class InsightsConnection { kdbOutputLog(`User cancelled the Scrathpad execution.`, "WARNING"); }); - progress.report({ message: "Query is executing..." }); + progress.report({ message: queryMsg }); const spRes = await axios .post(scratchpadURL.toString(), body, { headers, @@ -472,7 +476,7 @@ export class InsightsConnection { kdbOutputLog(`[SCRATCHPAD] Status: ${response.status}`, "INFO"); if (!response.data.error) { if (isTableView) { - if (this.insightsVersion && this.insightsVersion >= 1.11) { + if (this.insightsVersion && this.insightsVersion >= 1.12) { response.data = JSON.parse( response.data.data, ) as StructuredTextResults; diff --git a/src/services/resultsPanelProvider.ts b/src/services/resultsPanelProvider.ts index 243e91b2..902f85a4 100644 --- a/src/services/resultsPanelProvider.ts +++ b/src/services/resultsPanelProvider.ts @@ -55,7 +55,7 @@ export class KdbResultsViewProvider implements WebviewViewProvider { char: "text", symbol: "text", string: "text", - date: "date", + date: "text", time: "time", timestamp: "datetime", timespan: "text", @@ -159,7 +159,8 @@ export class KdbResultsViewProvider implements WebviewViewProvider { const sanitizedKey = this.sanitizeString(key); const type = results.meta[key]; const headerTooltip = type; - const cellDataType = this.kdbToAgGridCellType(type); + const cellDataType = + type != undefined ? this.kdbToAgGridCellType(type) : undefined; return { field: sanitizedKey, headerName: sanitizedKey, @@ -229,6 +230,7 @@ export class KdbResultsViewProvider implements WebviewViewProvider { rowData = this.updatedExtractRowData(results); columnDefs = this.updatedExtractColumnDefs(results); } else { + results = isInsights ? results.data : results; const queryResult = isInsights ? results.rows : results; if (Array.isArray(queryResult[0])) { if (typeof queryResult[0][0] === "object") { @@ -246,12 +248,21 @@ export class KdbResultsViewProvider implements WebviewViewProvider { rowData = queryResult; } + rowData = rowData.map((row: any) => { + const newRow = { ...row }; + Object.keys(newRow).forEach((key) => { + if (typeof newRow[key] === "object" && newRow[key] !== null) { + newRow[key] = newRow[key].toString(); + } + }); + return newRow; + }); + if (isInsights) { results.rows = rowData; - columnDefs = this.generateCoumnDefs(results, isInsights); - } else { - columnDefs = this.generateCoumnDefs(rowData, isInsights); } + + columnDefs = this.generateCoumnDefs(results, isInsights); } if ( @@ -406,7 +417,7 @@ export class KdbResultsViewProvider implements WebviewViewProvider { function restoreColumnWidths(columnWidths) { if (!gridApi || !columnWidths) return; - gridApi.applyColumnState({state: columnWidths, applyOrder: true,}); + gridApi.applyColumnState({state: columnWidths, }); } window.addEventListener('message', event => { From 184a058c43c2d0ca10c2a78ad3c553170a696c87 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Thu, 14 Nov 2024 14:38:00 +0000 Subject: [PATCH 2/2] fix tests --- test/suite/panels.test.ts | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/test/suite/panels.test.ts b/test/suite/panels.test.ts index 684a2e57..c03b9b99 100644 --- a/test/suite/panels.test.ts +++ b/test/suite/panels.test.ts @@ -186,11 +186,13 @@ describe("WebPanels", () => { describe("convertToGrid()", () => { it("should convert results to grid format for insights", () => { const results = { - rows: [ - { prop1: "value1", prop2: "value2" }, - { prop1: "value3", prop2: "value4" }, - ], - meta: { prop1: "type1", prop2: "type2" }, + data: { + rows: [ + { prop1: "value1", prop2: "value2" }, + { prop1: "value3", prop2: "value4" }, + ], + meta: { prop1: "type1", prop2: "type2" }, + }, }; const expectedOutput = JSON.stringify({ @@ -244,8 +246,10 @@ describe("WebPanels", () => { it("should convert results to grid format with empty rows", () => { const results = { - rows: [], - meta: { prop1: "type1", prop2: "type2" }, + data: { + rows: [], + meta: { prop1: "type1", prop2: "type2" }, + }, }; const expectedOutput = JSON.stringify({ @@ -296,11 +300,13 @@ describe("WebPanels", () => { it("should convert results to grid format when queryResult[0] is an array of objects", () => { const results = { - rows: [ - [{ sym: "a" }, { sym: "b" }, { sym: "c" }], - [{ val: 1 }, { val: 2 }, { val: 3 }], - ], - meta: { sym: "type1", val: "type2" }, + data: { + rows: [ + [{ sym: "a" }, { sym: "b" }, { sym: "c" }], + [{ val: 1 }, { val: 2 }, { val: 3 }], + ], + meta: { sym: "type1", val: "type2" }, + }, }; const expectedOutput = JSON.stringify({ @@ -355,8 +361,7 @@ describe("WebPanels", () => { it("should convert results to grid format when queryResult[0] is an array of non-objects", () => { const results = { - rows: [[1, 2, 3]], - meta: { value: "type1" }, + data: { rows: [[1, 2, 3]], meta: { value: "type1" } }, }; const expectedOutput = JSON.stringify({ @@ -367,7 +372,7 @@ describe("WebPanels", () => { flex: 1, minWidth: 100, }, - rowData: [{ index: 1, value: [1, 2, 3] }], + rowData: [{ index: 1, value: "1,2,3" }], columnDefs: [ { field: "index", headerName: "Index", cellDataType: "number" }, {