Skip to content

Commit 4e23a57

Browse files
Merge pull request #514 from KxSystems/rc-philip-fixes
Fixes for bugs found by Peter
2 parents 1e88763 + 49ed85d commit 4e23a57

File tree

3 files changed

+78
-19
lines changed

3 files changed

+78
-19
lines changed

src/services/resultsPanelProvider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,19 @@ export class KdbResultsViewProvider implements WebviewViewProvider {
499499
maxConcurrentDatasourceRequests: 1,
500500
infiniteInitialRowCount: 10000,
501501
maxBlocksInCache: 10,
502+
overlayNoRowsTemplate: '<span class="ag-overlay-loading-center">No results to show</span>',
502503
datasource: {
503504
rowCount: undefined,
504505
getRows: function(params) {
505506
showOverlay();
506507
const results = message.results;
507508
setTimeout(() => {
508509
const lastRow = results.length;
510+
if (lastRow === 0) {
511+
gridApi.showNoRowsOverlay();
512+
} else {
513+
gridApi.hideOverlay();
514+
}
509515
const rowsThisPage = results.slice(params.startRow, params.endRow);
510516
params.successCallback(rowsThisPage, lastRow);
511517
hideOverlay();

src/webview/components/kdbNewConnectionView.ts

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export class KdbNewConnectionView extends LitElement {
6363
isBundledQ: boolean = true;
6464
oldAlias: string = "";
6565
editAuth: boolean = false;
66+
renderId: string = "";
6667
private isModalOpen = false;
6768
private _connectionData: EditConnectionMessage | undefined = undefined;
6869
private readonly vscode = acquireVsCodeApi();
@@ -144,7 +145,6 @@ export class KdbNewConnectionView extends LitElement {
144145

145146
handleMessage(event: { data: any }) {
146147
const message = event.data;
147-
console.log(message);
148148
if (message.command === "editConnection") {
149149
this.connectionData = message.data;
150150
this.labels = message.labels;
@@ -397,15 +397,12 @@ export class KdbNewConnectionView extends LitElement {
397397
}
398398

399399
renderLblDropdownOptions(pos: number) {
400-
console.log(this.labels);
401400
return html`
402401
<sl-option> No Label Selected </sl-option>
403402
${repeat(
404403
this.lblNamesList,
405404
(lbl) => lbl,
406405
(lbl) => {
407-
console.log(lbl.name);
408-
console.log(lbl.name === this.labels[pos]);
409406
return html`
410407
<sl-option .value="${encodeURIComponent(lbl.name)}">
411408
<span>
@@ -749,7 +746,13 @@ export class KdbNewConnectionView extends LitElement {
749746
return html`<div>No connection found to be edited</div>`;
750747
}
751748
this.isBundledQ = this.connectionData.connType === ConnectionType.BundledQ;
752-
this.oldAlias = this.connectionData.serverName;
749+
if (
750+
this.renderId === "" ||
751+
this.oldAlias !== this.connectionData.serverName
752+
) {
753+
this.oldAlias = this.connectionData.serverName;
754+
this.renderId = "";
755+
}
753756
const connTypeName = this.defineConnTypeName(this.connectionData.connType);
754757
this.serverType =
755758
this.connectionData.connType === ConnectionType.Insights
@@ -813,9 +816,14 @@ export class KdbNewConnectionView extends LitElement {
813816
if (!this.connectionData) {
814817
return html`<div>No connection found to be edited</div>`;
815818
}
816-
this.bundledServer.serverAlias = "local";
817-
this.bundledServer.serverPort = this.connectionData.port ?? "";
818-
this.bundledServer.serverName = this.connectionData.serverAddress;
819+
820+
if (this.renderId === "") {
821+
this.renderId = this.generateRenderId();
822+
this.bundledServer.serverAlias = "local";
823+
this.bundledServer.serverPort = this.connectionData.port ?? "";
824+
this.bundledServer.serverName = this.connectionData.serverAddress;
825+
}
826+
819827
return html`
820828
<div class="col">
821829
<div class="row">
@@ -839,11 +847,16 @@ export class KdbNewConnectionView extends LitElement {
839847
if (!this.connectionData) {
840848
return html`<div>No connection found to be edited</div>`;
841849
}
842-
this.kdbServer.serverAlias = this.connectionData.serverName;
843-
this.kdbServer.serverPort = this.connectionData.port ?? "";
844-
this.kdbServer.serverName = this.connectionData.serverAddress;
845-
this.kdbServer.auth = this.connectionData.auth ?? false;
846-
this.kdbServer.tls = this.connectionData.tls ?? false;
850+
851+
if (this.renderId === "") {
852+
this.renderId = this.generateRenderId();
853+
this.kdbServer.serverAlias = this.connectionData.serverName;
854+
this.kdbServer.serverPort = this.connectionData.port ?? "";
855+
this.kdbServer.serverName = this.connectionData.serverAddress;
856+
this.kdbServer.auth = this.connectionData.auth ?? false;
857+
this.kdbServer.tls = this.connectionData.tls ?? false;
858+
}
859+
847860
return html`
848861
<div class="col">
849862
<div class="row">
@@ -926,9 +939,14 @@ export class KdbNewConnectionView extends LitElement {
926939
if (!this.connectionData) {
927940
return html`<div>No connection found to be edited</div>`;
928941
}
929-
this.insightsServer.alias = this.connectionData.serverName;
930-
this.insightsServer.server = this.connectionData.serverAddress;
931-
this.insightsServer.realm = this.connectionData.realm ?? "";
942+
943+
if (this.renderId === "") {
944+
this.renderId = this.generateRenderId();
945+
this.insightsServer.alias = this.connectionData.serverName;
946+
this.insightsServer.server = this.connectionData.serverAddress;
947+
this.insightsServer.realm = this.connectionData.realm ?? "";
948+
}
949+
932950
return html`
933951
<div class="col">
934952
<div class="row">
@@ -1042,6 +1060,13 @@ export class KdbNewConnectionView extends LitElement {
10421060
});
10431061
}
10441062
}
1063+
1064+
private generateRenderId(): string {
1065+
let counter = 0;
1066+
const timestamp = Date.now().toString(36);
1067+
const uniqueCounter = (counter++).toString(36);
1068+
return `render-${timestamp}-${uniqueCounter}`;
1069+
}
10451070
}
10461071

10471072
declare global {

test/suite/webview.test.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,18 +682,31 @@ describe("KdbNewConnectionView", () => {
682682
});
683683

684684
it("should set isBundledQ to true and return correct HTML when connType is 0", () => {
685-
view.connectionData = { connType: 0, serverName: "testServer" };
685+
view.connectionData = { connType: 0, serverName: "local" };
686686

687687
const result = view.renderEditConnectionForm();
688688
assert.strictEqual(view.isBundledQ, true);
689-
assert.strictEqual(view.oldAlias, "testServer");
689+
assert.strictEqual(view.oldAlias, "local");
690690
assert.strictEqual(view.serverType, ServerType.KDB);
691691
assert.strictEqual(result.values[1].includes("Bundled q"), true);
692692
});
693693

694-
it("should set isBundledQ to false and return correct HTML when connType is 1", () => {
694+
it("should set MyQ to false and return correct HTML when connType is 1 and render is filled", () => {
695695
view.connectionData = { connType: 1, serverName: "testServer" };
696+
view.oldAlias = "testServer";
697+
view.renderId = "test";
698+
const result = view.renderEditConnectionForm();
699+
700+
assert.strictEqual(view.isBundledQ, false);
701+
assert.strictEqual(view.oldAlias, "testServer");
702+
assert.strictEqual(view.serverType, ServerType.KDB);
703+
assert.strictEqual(result.values[1].includes("My q"), true);
704+
});
696705

706+
it("should set MyQ to false and return correct HTML when connType is 1", () => {
707+
view.connectionData = { connType: 1, serverName: "testServer" };
708+
view.oldAlias = "";
709+
view.renderId = "";
697710
const result = view.renderEditConnectionForm();
698711

699712
assert.strictEqual(view.isBundledQ, false);
@@ -702,8 +715,23 @@ describe("KdbNewConnectionView", () => {
702715
assert.strictEqual(result.values[1].includes("My q"), true);
703716
});
704717

718+
it("should set serverType to INSIGHTS and return correct HTML when connType is 2 and render is filled", () => {
719+
view.connectionData = { connType: 2, serverName: "testServer" };
720+
view.oldAlias = "testServer";
721+
view.renderId = "test";
722+
723+
const result = view.renderEditConnectionForm();
724+
725+
assert.strictEqual(view.isBundledQ, false);
726+
assert.strictEqual(view.oldAlias, "testServer");
727+
assert.strictEqual(view.serverType, ServerType.INSIGHTS);
728+
assert.strictEqual(result.values[1].includes("Insights"), true);
729+
});
730+
705731
it("should set serverType to INSIGHTS and return correct HTML when connType is 2", () => {
706732
view.connectionData = { connType: 2, serverName: "testServer" };
733+
view.oldAlias = "";
734+
view.renderId = "";
707735

708736
const result = view.renderEditConnectionForm();
709737

0 commit comments

Comments
 (0)