From 9a3e40c4ffad32b630960ed732d7f1646c71599c Mon Sep 17 00:00:00 2001 From: ecmel Date: Wed, 8 May 2024 12:43:01 +0300 Subject: [PATCH] small fixes --- src/commands/workspaceCommand.ts | 2 +- src/services/dataSourceEditorProvider.ts | 7 +-- src/webview/components/kdbDataSourceView.ts | 61 ++++++++++----------- 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/src/commands/workspaceCommand.ts b/src/commands/workspaceCommand.ts index 43c437ac..cba97155 100644 --- a/src/commands/workspaceCommand.ts +++ b/src/commands/workspaceCommand.ts @@ -124,7 +124,7 @@ async function waitForConnection(label: string) { } else if (count < 5) { retry(); } else { - reject(`Can not connect to ${label}`); + reject(new Error(`Can not connect to ${label}`)); } }, 50); }; diff --git a/src/services/dataSourceEditorProvider.ts b/src/services/dataSourceEditorProvider.ts index b81c3839..e7b23cb5 100644 --- a/src/services/dataSourceEditorProvider.ts +++ b/src/services/dataSourceEditorProvider.ts @@ -153,12 +153,7 @@ export class DataSourceEditorProvider implements CustomTextEditorProvider { if (text.trim().length === 0) { return {}; } - - try { - return JSON.parse(text); - } catch (error) { - throw error; - } + return JSON.parse(text); } private updateTextDocument(document: TextDocument, json: unknown) { diff --git a/src/webview/components/kdbDataSourceView.ts b/src/webview/components/kdbDataSourceView.ts index 6fe4a59d..0af794e3 100644 --- a/src/webview/components/kdbDataSourceView.ts +++ b/src/webview/components/kdbDataSourceView.ts @@ -11,10 +11,9 @@ * specific language governing permissions and limitations under the License. */ -import { LitElement, html } from "lit"; +import { LitElement, html, css } from "lit"; import { repeat } from "lit/directives/repeat.js"; import { customElement } from "lit/decorators.js"; -import { css } from "lit"; import { Agg, DataSourceFiles, @@ -93,37 +92,35 @@ export class KdbDataSourceView extends LitElement { message = (event: MessageEvent) => { const msg = event.data; - switch (msg.command) { - case DataSourceCommand.Update: - this.servers = msg.servers; - this.selectedServer = msg.selectedServer; - this.isInsights = msg.isInsights; - this.isMetaLoaded = !!msg.insightsMeta.dap; - this.insightsMeta = msg.insightsMeta; - const ds = msg.dataSourceFile; - this.selectedType = ds.dataSource.selectedType; - this.selectedApi = ds.dataSource.api.selectedApi; - this.selectedTable = ds.dataSource.api.table; - this.startTS = ds.dataSource.api.startTS; - this.endTS = ds.dataSource.api.endTS; - this.fill = ds.dataSource.api.fill; - this.temporality = ds.dataSource.api.temporality; - this.qsqlTarget = ds.dataSource.qsql.selectedTarget; - this.qsql = ds.dataSource.qsql.query; - this.sql = ds.dataSource.sql.query; - const optional = ds.dataSource.api.optional; - if (optional) { - this.filled = optional.filled; - this.temporal = optional.temporal; - this.filters = optional.filters; - this.labels = optional.labels; - this.sorts = optional.sorts; - this.aggs = optional.aggs; - this.groups = optional.groups; - } - break; + if (msg.command === DataSourceCommand.Update) { + this.servers = msg.servers; + this.selectedServer = msg.selectedServer; + this.isInsights = msg.isInsights; + this.isMetaLoaded = !!msg.insightsMeta.dap; + this.insightsMeta = msg.insightsMeta; + const ds = msg.dataSourceFile; + this.selectedType = ds.dataSource.selectedType; + this.selectedApi = ds.dataSource.api.selectedApi; + this.selectedTable = ds.dataSource.api.table; + this.startTS = ds.dataSource.api.startTS; + this.endTS = ds.dataSource.api.endTS; + this.fill = ds.dataSource.api.fill; + this.temporality = ds.dataSource.api.temporality; + this.qsqlTarget = ds.dataSource.qsql.selectedTarget; + this.qsql = ds.dataSource.qsql.query; + this.sql = ds.dataSource.sql.query; + const optional = ds.dataSource.api.optional; + if (optional) { + this.filled = optional.filled; + this.temporal = optional.temporal; + this.filters = optional.filters; + this.labels = optional.labels; + this.sorts = optional.sorts; + this.aggs = optional.aggs; + this.groups = optional.groups; + } + this.requestUpdate(); } - this.requestUpdate(); }; get data(): DataSourceFiles {