Skip to content

Commit

Permalink
Merge pull request #297 from KxSystems/KXI-45385
Browse files Browse the repository at this point in the history
KXI-45385 fixes for multiple scratchpad
  • Loading branch information
Philip-Carneiro-KX authored May 14, 2024
2 parents 9af96e5 + 2a04ba8 commit c0c7834
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 101 deletions.
19 changes: 13 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -438,6 +432,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": [
Expand Down
15 changes: 6 additions & 9 deletions resources/python-active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 6 additions & 9 deletions resources/python-connected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 6 additions & 9 deletions resources/python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 11 additions & 5 deletions resources/scratchpad-active.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions resources/scratchpad-connected.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions resources/scratchpad.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 19 additions & 40 deletions src/classes/insightsConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export class InsightsConnection {
}
}

public async pingInsights(): Promise<boolean> {
public async pingInsights(): Promise<boolean | undefined> {
if (this.connected) {
const pingURL = new url.URL(
ext.insightsServiceGatewayUrls.ping,
Expand All @@ -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;
});
}
}
}
Loading

0 comments on commit c0c7834

Please sign in to comment.