Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with large results #426

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/services/resultsPanelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
}
}

convertToGrid(results: any, isInsights: boolean): string {
convertToGrid(results: any, isInsights: boolean): any {
const queryResult = isInsights ? results.rows : results;

const columnDefs = this.generateCoumnDefs(results, isInsights);
Expand All @@ -199,7 +199,7 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
if (rowData.length > 0) {
ext.resultPanelCSV = this.convertToCsv(rowData).join("\n");
}
return JSON.stringify({
return {
defaultColDef: {
sortable: true,
resizable: true,
Expand All @@ -217,7 +217,7 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
suppressContextMenu: true,
suppressDragLeaveHidesColumns: true,
tooltipShowDelay: 200,
});
};
}

isVisible(): boolean {
Expand Down Expand Up @@ -266,7 +266,7 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
]);
const nonce = getNonce();
let result = "";
let gridOptionsString = "";
let gridOptions = undefined;

let isGrid = false;
if (typeof queryResult === "string" || typeof queryResult === "number") {
Expand All @@ -278,11 +278,11 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
: "<p>No results to show</p>";
} else if (queryResult) {
isGrid = true;
gridOptionsString = this.convertToGrid(queryResult, !!isInsights);
gridOptions = this.convertToGrid(queryResult, !!isInsights);
}

result =
gridOptionsString === ""
gridOptions === undefined
? result !== ""
? result
: "<p>No results to show</p>"
Expand Down Expand Up @@ -317,7 +317,7 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
document.addEventListener('DOMContentLoaded', () => {
if(${isGrid}){
const gridDiv = document.getElementById('grid');
const obj = JSON.parse('${gridOptionsString}');
const obj = ${JSON.stringify(gridOptions)};
const gridApi = agGrid.createGrid(gridDiv, obj);
document.getElementById("results").scrollIntoView();
}
Expand Down
7 changes: 4 additions & 3 deletions test/suite/panels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe("WebPanels", () => {
stub.get(() => insightsConn);

const output = resultsPanel.convertToGrid(results, true);
assert.equal(output, expectedOutput);
assert.equal(JSON.stringify(output), expectedOutput);

// Restore the stub
stub.restore();
Expand Down Expand Up @@ -277,7 +277,7 @@ describe("WebPanels", () => {
stub.get(() => insightsConn);

const output = resultsPanel.convertToGrid(results, true);
assert.equal(output, expectedOutput);
assert.equal(JSON.stringify(output), expectedOutput);

// Restore the stub
stub.restore();
Expand Down Expand Up @@ -416,11 +416,12 @@ describe("WebPanels", () => {
{ id: 1, test: "test1" },
{ id: 2, test: "test2" },
];
const expectedOutput = `"rowData":[{"id":1,"test":"test1"},{"id":2,"test":"test2"}],"columnDefs":[{"field":"id","headerName":"id"},{"field":"test","headerName":"test"}]`;
const expectedOutput = `agGrid.createGrid(gridDiv, obj)`;
const stub = sinon
.stub(resultsPanel, "convertToGrid")
.returns(expectedOutput);
const actualOutput = resultsPanel["_getWebviewContent"](input);
console.log(actualOutput);
assert.strictEqual(typeof actualOutput, "string");
assert.ok(actualOutput.includes(expectedOutput));
stub.restore();
Expand Down