From fc76b63198a3fb7205101e94bc09d45b373d8783 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Tue, 14 May 2024 11:34:16 +0100 Subject: [PATCH 1/4] fix icons --- package.json | 13 +++++++++++++ resources/python-active.svg | 15 ++++++--------- resources/python-connected.svg | 15 ++++++--------- resources/python.svg | 15 ++++++--------- resources/scratchpad-active.svg | 16 +++++++++++----- resources/scratchpad-connected.svg | 19 ++++++++++++------- resources/scratchpad.svg | 19 ++++++++++++------- 7 files changed, 66 insertions(+), 46 deletions(-) diff --git a/package.json b/package.json index 2c8fa746..4f7ed8e2 100644 --- a/package.json +++ b/package.json @@ -438,6 +438,19 @@ "light": "./resources/scratchpad.svg" }, "configuration": "./language-configuration.json" + }, + { + "id": "json", + "aliases": [ + "json" + ], + "extensions": [ + ".kdb.json" + ], + "icon": { + "dark": "./resources/datasource.svg", + "light": "./resources/datasource.svg" + } } ], "grammars": [ diff --git a/resources/python-active.svg b/resources/python-active.svg index bf29def0..f2c4ff07 100644 --- a/resources/python-active.svg +++ b/resources/python-active.svg @@ -1,9 +1,6 @@ - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/resources/python-connected.svg b/resources/python-connected.svg index cb7d72bd..79122228 100644 --- a/resources/python-connected.svg +++ b/resources/python-connected.svg @@ -1,9 +1,6 @@ - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/resources/python.svg b/resources/python.svg index 5fc48a4e..703b1e9d 100644 --- a/resources/python.svg +++ b/resources/python.svg @@ -1,9 +1,6 @@ - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/resources/scratchpad-active.svg b/resources/scratchpad-active.svg index 062ae3a4..764e49ae 100644 --- a/resources/scratchpad-active.svg +++ b/resources/scratchpad-active.svg @@ -1,9 +1,15 @@ - + + d="m 14.09818,21.625617 h -1.713937 v -5.816824 c -0.766393,1.076529 -1.867216,1.614665 -3.3024605,1.614665 -1.5327963,0 -2.717222,-0.538136 -3.5532955,-1.614665 C 4.8178289,14.85664 4.4625,13.607722 4.4625,12.062105 4.4625,10.199072 4.9432392,8.7362615 5.9047127,7.6736448 6.7407809,6.7628303 7.820711,6.307436 9.1444772,6.307436 c 1.4631188,0 2.6057578,0.5726986 3.4278878,1.7181214 V 6.5558283 H 14.09818 Z M 9.3744011,7.9013484 c -0.9336077,0 -1.6930434,0.3726012 -2.2782809,1.1178165 C 6.5248078,9.7505709 6.239145,10.72349 6.239145,11.937895 c 0,1.255823 0.3274635,2.242538 0.9823778,2.960135 0.5573745,0.620968 1.2819782,0.931554 2.1737851,0.931554 0.9057311,0 1.6303231,-0.351913 2.1737721,-1.055751 0.54345,-0.703812 0.815163,-1.649124 0.815163,-2.835938 0,-1.311008 -0.306558,-2.3391269 -0.919671,-3.0843292 C 10.921123,8.2187499 10.224408,7.9013485 9.3744011,7.9013484 Z" + fill="#20A233" + id="path1" + style="stroke-width:1.28342" /> + d="m 16.046893,2.3743828 h 0.585249 c 0.975357,1.1454137 1.706905,2.4771336 2.194732,3.9951449 0.473707,1.4490276 0.710626,2.9808355 0.710626,4.5954623 0,1.600817 -0.236919,3.111936 -0.710626,4.533344 -0.487827,1.490432 -1.219375,2.78758 -2.194732,3.891702 h -0.585249 l -0.564345,-0.434693 c 0.78033,-1.159309 1.365568,-2.346084 1.755739,-3.560452 0.459821,-1.435268 0.689809,-2.918782 0.689809,-4.450604 0,-1.4214201 -0.174287,-2.773832 -0.522607,-4.0572476 C 16.973531,5.3414219 16.332542,3.9821051 15.482548,2.8090872 Z" + fill="#20A233" + id="path2" + style="stroke-width:1.28342" /> \ No newline at end of file diff --git a/resources/scratchpad-connected.svg b/resources/scratchpad-connected.svg index 99db245c..bfd203d1 100644 --- a/resources/scratchpad-connected.svg +++ b/resources/scratchpad-connected.svg @@ -1,9 +1,14 @@ - + + d="m 14.09818,21.625617 h -1.713937 v -5.816824 c -0.766393,1.076529 -1.867216,1.614665 -3.3024605,1.614665 -1.5327963,0 -2.717222,-0.538136 -3.5532955,-1.614665 C 4.8178289,14.85664 4.4625,13.607722 4.4625,12.062105 4.4625,10.199072 4.9432392,8.7362615 5.9047127,7.6736448 6.7407809,6.7628303 7.820711,6.307436 9.1444772,6.307436 c 1.4631188,0 2.6057578,0.5726986 3.4278878,1.7181214 V 6.5558283 H 14.09818 Z M 9.3744011,7.9013484 c -0.9336077,0 -1.6930434,0.3726012 -2.2782809,1.1178165 C 6.5248078,9.7505709 6.239145,10.72349 6.239145,11.937895 c 0,1.255823 0.3274635,2.242538 0.9823778,2.960135 0.5573745,0.620968 1.2819782,0.931554 2.1737851,0.931554 0.9057311,0 1.6303231,-0.351913 2.1737721,-1.055751 0.54345,-0.703812 0.815163,-1.649124 0.815163,-2.835938 0,-1.311008 -0.306558,-2.3391269 -0.919671,-3.0843292 C 10.921123,8.2187499 10.224408,7.9013485 9.3744011,7.9013484 Z" + fill="#BC8401" + id="path1" + style="stroke-width:1.28342" /> - - \ No newline at end of file + d="m 16.046893,2.3743828 h 0.585249 c 0.975357,1.1454137 1.706905,2.4771336 2.194732,3.9951449 0.473707,1.4490276 0.710626,2.9808355 0.710626,4.5954623 0,1.600817 -0.236919,3.111936 -0.710626,4.533344 -0.487827,1.490432 -1.219375,2.78758 -2.194732,3.891702 h -0.585249 l -0.564345,-0.434693 c 0.78033,-1.159309 1.365568,-2.346084 1.755739,-3.560452 0.459821,-1.435268 0.689809,-2.918782 0.689809,-4.450604 0,-1.4214201 -0.174287,-2.773832 -0.522607,-4.0572476 C 16.973531,5.3414219 16.332542,3.9821051 15.482548,2.8090872 Z" + fill="#BC8401" + id="path2" + style="stroke-width:1.28342" /> + \ No newline at end of file diff --git a/resources/scratchpad.svg b/resources/scratchpad.svg index fb00e730..5e5553ad 100644 --- a/resources/scratchpad.svg +++ b/resources/scratchpad.svg @@ -1,9 +1,14 @@ - + + d="m 14.09818,21.625617 h -1.713937 v -5.816824 c -0.766393,1.076529 -1.867216,1.614665 -3.3024605,1.614665 -1.5327963,0 -2.717222,-0.538136 -3.5532955,-1.614665 C 4.8178289,14.85664 4.4625,13.607722 4.4625,12.062105 4.4625,10.199072 4.9432392,8.7362615 5.9047127,7.6736448 6.7407809,6.7628303 7.820711,6.307436 9.1444772,6.307436 c 1.4631188,0 2.6057578,0.5726986 3.4278878,1.7181214 V 6.5558283 H 14.09818 Z M 9.3744011,7.9013484 c -0.9336077,0 -1.6930434,0.3726012 -2.2782809,1.1178165 C 6.5248078,9.7505709 6.239145,10.72349 6.239145,11.937895 c 0,1.255823 0.3274635,2.242538 0.9823778,2.960135 0.5573745,0.620968 1.2819782,0.931554 2.1737851,0.931554 0.9057311,0 1.6303231,-0.351913 2.1737721,-1.055751 0.54345,-0.703812 0.815163,-1.649124 0.815163,-2.835938 0,-1.311008 -0.306558,-2.3391269 -0.919671,-3.0843292 C 10.921123,8.2187499 10.224408,7.9013485 9.3744011,7.9013484 Z" + fill="#8f8f8f" + id="path1" + style="stroke-width:1.28342" /> - - \ No newline at end of file + d="m 16.046893,2.3743828 h 0.585249 c 0.975357,1.1454137 1.706905,2.4771336 2.194732,3.9951449 0.473707,1.4490276 0.710626,2.9808355 0.710626,4.5954623 0,1.600817 -0.236919,3.111936 -0.710626,4.533344 -0.487827,1.490432 -1.219375,2.78758 -2.194732,3.891702 h -0.585249 l -0.564345,-0.434693 c 0.78033,-1.159309 1.365568,-2.346084 1.755739,-3.560452 0.459821,-1.435268 0.689809,-2.918782 0.689809,-4.450604 0,-1.4214201 -0.174287,-2.773832 -0.522607,-4.0572476 C 16.973531,5.3414219 16.332542,3.9821051 15.482548,2.8090872 Z" + fill="#8f8f8f" + id="path2" + style="stroke-width:1.28342" /> + \ No newline at end of file From c7810034a7e62fe84fe43dd2f18bab6bad078f58 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Tue, 14 May 2024 11:58:22 +0100 Subject: [PATCH 2/4] remove obsolete command from list --- package.json | 6 ------ 1 file changed, 6 deletions(-) diff --git a/package.json b/package.json index 4f7ed8e2..66fe45b5 100644 --- a/package.json +++ b/package.json @@ -333,12 +333,6 @@ "command": "kdb.datasource.import.ds", "title": "Import Datasource from old format" }, - { - "category": "KX", - "command": "kdb.terminal.run", - "title": "Run q file in a new q instance", - "icon": "$(debug-alt)" - }, { "category": "KX", "command": "kdb.terminal.start", From 73acf6ddb123e70bce5e938d3c3f03a75e7a3327 Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Tue, 14 May 2024 13:09:53 +0100 Subject: [PATCH 3/4] rehidrate insights conns --- src/classes/insightsConnection.ts | 59 ++++++++---------------- src/services/connectionManagerService.ts | 29 ++++++++++-- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/classes/insightsConnection.ts b/src/classes/insightsConnection.ts index f46466b7..eff20086 100644 --- a/src/classes/insightsConnection.ts +++ b/src/classes/insightsConnection.ts @@ -430,7 +430,7 @@ export class InsightsConnection { } } - public async pingInsights(): Promise { + public async pingInsights(): Promise { if (this.connected) { const pingURL = new url.URL( ext.insightsServiceGatewayUrls.ping, @@ -454,45 +454,24 @@ export class InsightsConnection { labels: {}, }; - return await window.withProgress( - { - location: ProgressLocation.Notification, - cancellable: false, - }, - async (progress, token) => { - token.onCancellationRequested(() => { - ext.outputChannel.appendLine("User cancelled the ping request."); - return false; - }); - - progress.report({ message: "Pinging insights..." }); - - const res = await axios - .request({ - method: "post", - url: pingURL.toString(), - data: body, - headers: { Authorization: `Bearer ${userToken.accessToken}` }, - timeout: 1000, - }) - .then((response: any) => { - console.log(response); - Telemetry.sendEvent("Insights.Pinged"); - return true; - }) - .catch((error: any) => { - console.log(error); - window.showErrorMessage( - `The Insights connection: ${this.connLabel} cannot be reached, the connection closed.`, - ); - return false; - }); - - return res; - }, - ); - } else { - return false; + return await axios + .request({ + method: "post", + url: pingURL.toString(), + data: body, + headers: { Authorization: `Bearer ${userToken.accessToken}` }, + timeout: 1000, + }) + .then((_response: any) => { + Telemetry.sendEvent("Insights.Pinged"); + return true; + }) + .catch((_error: any) => { + window.showErrorMessage( + `The Insights connection: ${this.connLabel} cannot be reached, the connection closed.`, + ); + return false; + }); } } } diff --git a/src/services/connectionManagerService.ts b/src/services/connectionManagerService.ts index 23592651..496abf5b 100644 --- a/src/services/connectionManagerService.ts +++ b/src/services/connectionManagerService.ts @@ -121,7 +121,8 @@ export class ConnectionManagementService { refreshDataSourcesPanel(); } if (ext.connectedConnectionList.length === 1) { - this.startMonitoringConn(); + this.startMonitoringNetworkConn(); + this.rehidrateInsightsConnections(); } } @@ -325,7 +326,9 @@ export class ConnectionManagementService { } } - public async checkInsightsConnectionIsAlive(): Promise { + public async checkInsightsConnectionIsAlive( + whoTriggered: string, + ): Promise { const checks = ext.connectedConnectionList.map(async (connection) => { if (connection instanceof InsightsConnection) { const res = await connection.pingInsights(); @@ -335,11 +338,15 @@ export class ConnectionManagementService { } }); await Promise.all(checks); - this.startMonitoringConn(); + if (whoTriggered === "networkMonitoring") { + this.startMonitoringNetworkConn(); + } else { + this.rehidrateInsightsConnections(); + } } /* istanbul ignore next */ - public async startMonitoringConn() { + public async startMonitoringNetworkConn(): Promise { let previousNetworkState = os.networkInterfaces(); const intervalId = setInterval(() => { const currentNetworkState = os.networkInterfaces(); @@ -349,11 +356,23 @@ export class ConnectionManagementService { ) { clearInterval(intervalId); previousNetworkState = currentNetworkState; - this.checkInsightsConnectionIsAlive(); + this.checkInsightsConnectionIsAlive("networkMonitoring"); } if (ext.connectedConnectionList.length === 0) { clearInterval(intervalId); } }, 2000); } + + /* istanbul ignore next */ + public async rehidrateInsightsConnections(): Promise { + const intervalConns = setInterval(() => { + if (ext.connectedConnectionList.length > 0) { + clearInterval(intervalConns); + this.checkInsightsConnectionIsAlive("rehidrateConnections"); + } else { + clearInterval(intervalConns); + } + }, 60000); + } } From 2a04ba8fe3c121a6a81022a626ef5f001c8911fa Mon Sep 17 00:00:00 2001 From: Philip Carneiro Date: Tue, 14 May 2024 13:13:00 +0100 Subject: [PATCH 4/4] fix tests --- test/suite/services.test.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/suite/services.test.ts b/test/suite/services.test.ts index ed3305a8..595eb94f 100644 --- a/test/suite/services.test.ts +++ b/test/suite/services.test.ts @@ -1042,19 +1042,25 @@ describe("connectionManagerService", () => { it("should not call pingInsights if connection is not an instance of InsightsConnection", async () => { ext.connectedConnectionList.push(localConn); - await connectionManagerService.checkInsightsConnectionIsAlive(); + await connectionManagerService.checkInsightsConnectionIsAlive( + "networkMonitoring", + ); sinon.assert.notCalled(pingInsightsStub); }); it("should not call pingInsights if there is no connection connected", async () => { - await connectionManagerService.checkInsightsConnectionIsAlive(); + await connectionManagerService.checkInsightsConnectionIsAlive( + "networkMonitoring", + ); sinon.assert.notCalled(pingInsightsStub); }); it("should call pingInsights if connection is an instance of InsightsConnection", async () => { ext.connectedConnectionList.push(insightsConn); pingInsightsStub.resolves(true); - await connectionManagerService.checkInsightsConnectionIsAlive(); + await connectionManagerService.checkInsightsConnectionIsAlive( + "rehidrateConn", + ); sinon.assert.calledOnce(pingInsightsStub); sinon.assert.notCalled(disconnectStub); }); @@ -1062,7 +1068,9 @@ describe("connectionManagerService", () => { it("should call disconnect if pingInsights returns false", async () => { ext.connectedConnectionList.push(insightsConn); pingInsightsStub.resolves(false); - await connectionManagerService.checkInsightsConnectionIsAlive(); + await connectionManagerService.checkInsightsConnectionIsAlive( + "networkMonitoring", + ); sinon.assert.calledOnce(pingInsightsStub); sinon.assert.calledOnce(disconnectStub); });