From fc5ed25f8386bb269425beb13a0bf08df477d252 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Thu, 19 Sep 2024 19:24:03 +0000 Subject: [PATCH 1/6] chore(release): 3.14.0 [skip ci] ## [3.14.0](https://github.com/ni/systemlink-grafana-plugins/compare/v3.13.0...v3.14.0) (2024-09-19) ### Features * **asset:** add calibration forecast property only row formatting ([#68](https://github.com/ni/systemlink-grafana-plugins/issues/68)) ([162d782](https://github.com/ni/systemlink-grafana-plugins/commit/162d7826c9219ccfc1fc807aae2a61ea0b6b031d)) --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4916911..e14fbd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.14.0](https://github.com/ni/systemlink-grafana-plugins/compare/v3.13.0...v3.14.0) (2024-09-19) + + +### Features + +* **asset:** add calibration forecast property only row formatting ([#68](https://github.com/ni/systemlink-grafana-plugins/issues/68)) ([162d782](https://github.com/ni/systemlink-grafana-plugins/commit/162d7826c9219ccfc1fc807aae2a61ea0b6b031d)) + ## [3.13.0](https://github.com/ni/systemlink-grafana-plugins/compare/v3.12.1...v3.13.0) (2024-09-11) diff --git a/package-lock.json b/package-lock.json index ce477c4..ef2df3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "systemlink-grafana-plugins", - "version": "3.13.0", + "version": "3.14.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "systemlink-grafana-plugins", - "version": "3.13.0", + "version": "3.14.0", "license": "Apache-2.0", "dependencies": { "@emotion/css": "^11.1.3", diff --git a/package.json b/package.json index 40a5ad7..5d4b02d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "systemlink-grafana-plugins", - "version": "3.13.0", + "version": "3.14.0", "description": "Plugins for visualizing data from SystemLink services", "private": true, "scripts": { From cf0438e91d661d98b60578f7adbcc438a886dbe3 Mon Sep 17 00:00:00 2001 From: "NI\\akerezsi" Date: Mon, 30 Sep 2024 02:41:25 +0300 Subject: [PATCH 2/6] Added column descriptor as column name processor --- .../AssetCalibrationDataSource.test.ts | 103 +++++++++--------- .../AssetCalibrationDataSource.ts | 12 +- .../AssetCalibrationDataSource.test.ts.snap | 76 +++++++++++-- src/datasources/asset-calibration/types.ts | 18 ++- 4 files changed, 147 insertions(+), 62 deletions(-) diff --git a/src/datasources/asset-calibration/AssetCalibrationDataSource.test.ts b/src/datasources/asset-calibration/AssetCalibrationDataSource.test.ts index 0effd8c..4e61cd4 100644 --- a/src/datasources/asset-calibration/AssetCalibrationDataSource.test.ts +++ b/src/datasources/asset-calibration/AssetCalibrationDataSource.test.ts @@ -13,6 +13,7 @@ import { AssetCalibrationQuery, AssetCalibrationTimeBasedGroupByType, CalibrationForecastResponse, + ColumnDescriptorType, } from "./types"; let datastore: AssetCalibrationDataSource, backendServer: MockProxy @@ -23,83 +24,83 @@ beforeEach(() => { const monthGroupCalibrationForecastResponseMock: CalibrationForecastResponse = { - calibrationForecast: { - columns: [ - { name: "Month", values: ["2022-01-01T00:00:00.0000000Z", "2022-02-01T00:00:00.0000000Z", "2022-03-01T00:00:00.0000000Z"] }, - { name: "Assets", values: [1, 0, 3] }, - ] - } + calibrationForecast: { + columns: [ + { name: "", values: ["2022-01-01T00:00:00.0000000Z", "2022-02-01T00:00:00.0000000Z", "2022-03-01T00:00:00.0000000Z"], columnDescriptors: [{ value: "Month", type: ColumnDescriptorType.Time }] }, + { name: "", values: [1, 0, 3], columnDescriptors: [{ value: "Assets", type: ColumnDescriptorType.Count }] } + ] + } } -const weekGroupCalibrationForecastResponseMock: CalibrationForecastResponse = +const dayGroupCalibrationForecastResponseMock: CalibrationForecastResponse = { - calibrationForecast: { - columns: [ - { name: "Day", values: ["2022-01-01T00:00:00.0000000Z", "2022-01-02T00:00:00.0000000Z", "2022-01-03T00:00:00.0000000Z"] }, - { name: "Assets", values: [1, 2, 2] }, - ] - } + calibrationForecast: { + columns: [ + { name: "", values: ["2022-01-01T00:00:00.0000000Z", "2022-01-02T00:00:00.0000000Z", "2022-01-03T00:00:00.0000000Z"], columnDescriptors: [{ value: "Day", type: ColumnDescriptorType.Time }] }, + { name: "", values: [1, 2, 2], columnDescriptors: [{ value: "Assets", type: ColumnDescriptorType.Count }] } + ] + } } -const dayGroupCalibrationForecastResponseMock: CalibrationForecastResponse = +const weekGroupCalibrationForecastResponseMock: CalibrationForecastResponse = { - calibrationForecast: { - columns: [ - { name: "Week", values: ["2022-01-03T00:00:00.0000000Z", "2022-01-10T00:00:00.0000000Z", "2022-01-17T00:00:00.0000000Z"] }, - { name: "Assets", values: [1, 2, 2] }, - ] - } + calibrationForecast: { + columns: [ + { name: "", values: ["2022-01-03T00:00:00.0000000Z", "2022-01-10T00:00:00.0000000Z", "2022-01-17T00:00:00.0000000Z"], columnDescriptors: [{ value: "Week", type: ColumnDescriptorType.Time }] }, + { name: "", values: [1, 2, 2], columnDescriptors: [{ value: "Assets", type: ColumnDescriptorType.Count }] } + ] + } } const locationGroupCalibrationForecastResponseMock: CalibrationForecastResponse = { - calibrationForecast: { - columns: [ - { name: "Location1", values: [1] }, - { name: "Location2", values: [2] }, - { name: "Location3", values: [3] }, - ] - } + calibrationForecast: { + columns: [ + { name: "", values: [1], columnDescriptors: [{ value: "Location1", type: ColumnDescriptorType.StringValue }] }, + { name: "", values: [2], columnDescriptors: [{ value: "Location2", type: ColumnDescriptorType.StringValue }] }, + { name: "", values: [3], columnDescriptors: [{ value: "Location3", type: ColumnDescriptorType.StringValue }] } + ] + } } const modelGroupCalibrationForecastResponseMock: CalibrationForecastResponse = { - calibrationForecast: { - columns: [ - { name: "Model1", values: [1] }, - { name: "Model2", values: [2] }, - ] - } + calibrationForecast: { + columns: [ + { name: "", values: [1], columnDescriptors: [{ value: "Model1", type: ColumnDescriptorType.StringValue }] }, + { name: "", values: [2], columnDescriptors: [{ value: "Model2", type: ColumnDescriptorType.StringValue }] } + ] + } } const emptyGroupCalibrationForecastResponseMock: CalibrationForecastResponse = { - calibrationForecast: { - columns: [ - ] - } + calibrationForecast: { + columns: [ + ] + } } const modelLocationGroupCalibrationForecastResponseMock: CalibrationForecastResponse = { - calibrationForecast: { - columns: [ - { name: "Model1 - Localtion1", values: [1] }, - { name: "Model2 - Localtion1", values: [2] }, - ] - } + calibrationForecast: { + columns: [ + { name: "", values: [1], columnDescriptors: [{ value: "Model1", type: ColumnDescriptorType.StringValue }, { value: "Localtion1", type: ColumnDescriptorType.StringValue }] }, + { name: "", values: [2], columnDescriptors: [{ value: "Model2", type: ColumnDescriptorType.StringValue }, { value: "Localtion1", type: ColumnDescriptorType.StringValue }] } + ] + } } const monthLocationGroupCalibrationForecastResponseMock: CalibrationForecastResponse = { - calibrationForecast: { - columns: [ - { name: "Month", values: ["2022-01-01T00:00:00.0000000Z", "2022-02-01T00:00:00.0000000Z", "2022-03-01T00:00:00.0000000Z"] }, - { name: "Location1", values: [1, 2, 3] }, - { name: "Location2", values: [2, 4, 1] }, - { name: "Location3", values: [4, 3, 1] }, - ] - } + calibrationForecast: { + columns: [ + { name: "", values: ["2022-01-01T00:00:00.0000000Z", "2022-02-01T00:00:00.0000000Z", "2022-03-01T00:00:00.0000000Z"], columnDescriptors: [{ value: "Month", type: ColumnDescriptorType.Time }] }, + { name: "", values: [1, 2, 3], columnDescriptors: [{ value: "Location1", type: ColumnDescriptorType.StringValue }] }, + { name: "", values: [2, 4, 1], columnDescriptors: [{ value: "Location2", type: ColumnDescriptorType.StringValue }] }, + { name: "", values: [4, 3, 1], columnDescriptors: [{ value: "Location3", type: ColumnDescriptorType.StringValue }] } + ] + } } const monthBasedCalibrationForecastQueryMock: AssetCalibrationQuery = { diff --git a/src/datasources/asset-calibration/AssetCalibrationDataSource.ts b/src/datasources/asset-calibration/AssetCalibrationDataSource.ts index 249b95b..8849b22 100644 --- a/src/datasources/asset-calibration/AssetCalibrationDataSource.ts +++ b/src/datasources/asset-calibration/AssetCalibrationDataSource.ts @@ -14,6 +14,7 @@ import { AssetModel, AssetsResponse, CalibrationForecastResponse, + FieldDTOWithDescriptor, } from './types'; import { SystemMetadata } from "../system/types"; import { defaultOrderBy, defaultProjection } from "../system/constants"; @@ -61,6 +62,7 @@ export class AssetCalibrationDataSource extends DataSourceBase { + field.name = this.createColumnNameFromDrescriptor(field as FieldDTOWithDescriptor); switch (field.name) { case AssetCalibrationForecastKey.Day: field.values = field.values!.map(this.formatDateForDay) @@ -83,13 +85,19 @@ export class AssetCalibrationDataSource extends DataSourceBase descriptor.value).join(' - '); + } + formatDateForDay(date: string): string { return new Date(date).toISOString().split('T')[0]; } diff --git a/src/datasources/asset-calibration/__snapshots__/AssetCalibrationDataSource.test.ts.snap b/src/datasources/asset-calibration/__snapshots__/AssetCalibrationDataSource.test.ts.snap index 6a01cfe..97985a7 100644 --- a/src/datasources/asset-calibration/__snapshots__/AssetCalibrationDataSource.test.ts.snap +++ b/src/datasources/asset-calibration/__snapshots__/AssetCalibrationDataSource.test.ts.snap @@ -5,14 +5,26 @@ exports[`queries asset calibration forecast with day groupBy 1`] = ` { "fields": [ { - "name": "Week", + "columnDescriptors": [ + { + "type": "Time", + "value": "Day", + }, + ], + "name": "Day", "values": [ - "2022-01-03 : 2022-01-09", - "2022-01-10 : 2022-01-16", - "2022-01-17 : 2022-01-23", + "2022-01-01", + "2022-01-02", + "2022-01-03", ], }, { + "columnDescriptors": [ + { + "type": "Count", + "value": "Assets", + }, + ], "name": "Assets", "values": [ 1, @@ -31,6 +43,12 @@ exports[`queries asset calibration forecast with month groupBy 1`] = ` { "fields": [ { + "columnDescriptors": [ + { + "type": "Time", + "value": "Month", + }, + ], "name": "Month", "values": [ "January 2022", @@ -39,6 +57,12 @@ exports[`queries asset calibration forecast with month groupBy 1`] = ` ], }, { + "columnDescriptors": [ + { + "type": "Count", + "value": "Assets", + }, + ], "name": "Assets", "values": [ 1, @@ -57,14 +81,26 @@ exports[`queries asset calibration forecast with week groupBy 1`] = ` { "fields": [ { - "name": "Day", + "columnDescriptors": [ + { + "type": "Time", + "value": "Week", + }, + ], + "name": "Week", "values": [ - "2022-01-01", - "2022-01-02", - "2022-01-03", + "2022-01-03 : 2022-01-09", + "2022-01-10 : 2022-01-16", + "2022-01-17 : 2022-01-23", ], }, { + "columnDescriptors": [ + { + "type": "Count", + "value": "Assets", + }, + ], "name": "Assets", "values": [ 1, @@ -157,6 +193,12 @@ exports[`queries calibration forecast with month and location groupBy 1`] = ` { "fields": [ { + "columnDescriptors": [ + { + "type": "Time", + "value": "Month", + }, + ], "name": "Month", "values": [ "January 2022", @@ -165,6 +207,12 @@ exports[`queries calibration forecast with month and location groupBy 1`] = ` ], }, { + "columnDescriptors": [ + { + "type": "StringValue", + "value": "Location1", + }, + ], "name": "Location1", "values": [ 1, @@ -173,6 +221,12 @@ exports[`queries calibration forecast with month and location groupBy 1`] = ` ], }, { + "columnDescriptors": [ + { + "type": "StringValue", + "value": "Location2", + }, + ], "name": "Location2", "values": [ 2, @@ -181,6 +235,12 @@ exports[`queries calibration forecast with month and location groupBy 1`] = ` ], }, { + "columnDescriptors": [ + { + "type": "StringValue", + "value": "Location3", + }, + ], "name": "Location3", "values": [ 4, diff --git a/src/datasources/asset-calibration/types.ts b/src/datasources/asset-calibration/types.ts index 4d3e0fc..c479cb3 100644 --- a/src/datasources/asset-calibration/types.ts +++ b/src/datasources/asset-calibration/types.ts @@ -141,5 +141,21 @@ export enum AssetFilterProperties { } export interface CalibrationForecastModel { - columns: FieldDTO[], + columns: FieldDTOWithDescriptor[], +} + +export interface FieldDTOWithDescriptor extends FieldDTO { + columnDescriptors: ColumnDescriptor[] +} + +export interface ColumnDescriptor { + value: string + type: string +} + +export enum ColumnDescriptorType { + Time = "Time", + Count = "Count", + StringValue = "StringValue", + MinionId = "MinionId", } From 973a790538248c98a809a313dfbd9bb895fbcb88 Mon Sep 17 00:00:00 2001 From: "NI\\akerezsi" Date: Mon, 30 Sep 2024 10:17:16 +0300 Subject: [PATCH 3/6] Addressing comments --- src/datasources/asset-calibration/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datasources/asset-calibration/types.ts b/src/datasources/asset-calibration/types.ts index c479cb3..7e07760 100644 --- a/src/datasources/asset-calibration/types.ts +++ b/src/datasources/asset-calibration/types.ts @@ -150,7 +150,7 @@ export interface FieldDTOWithDescriptor extends FieldDTO { export interface ColumnDescriptor { value: string - type: string + type: ColumnDescriptorType } export enum ColumnDescriptorType { From 88f13769cfb5b2e548754cc1696ecc4b341f83af Mon Sep 17 00:00:00 2001 From: "NI\\akerezsi" Date: Mon, 30 Sep 2024 10:19:29 +0300 Subject: [PATCH 4/6] renamed typo on method name --- .../asset-calibration/AssetCalibrationDataSource.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/datasources/asset-calibration/AssetCalibrationDataSource.ts b/src/datasources/asset-calibration/AssetCalibrationDataSource.ts index 8849b22..1d2d11f 100644 --- a/src/datasources/asset-calibration/AssetCalibrationDataSource.ts +++ b/src/datasources/asset-calibration/AssetCalibrationDataSource.ts @@ -62,7 +62,7 @@ export class AssetCalibrationDataSource extends DataSourceBase { - field.name = this.createColumnNameFromDrescriptor(field as FieldDTOWithDescriptor); + field.name = this.createColumnNameFromDescriptor(field as FieldDTOWithDescriptor); switch (field.name) { case AssetCalibrationForecastKey.Day: field.values = field.values!.map(this.formatDateForDay) @@ -85,7 +85,7 @@ export class AssetCalibrationDataSource extends DataSourceBase descriptor.value).join(' - '); } From 335978be21a3777f4e78ceaa9e6b66db668d0b53 Mon Sep 17 00:00:00 2001 From: "NI\\akerezsi" Date: Mon, 30 Sep 2024 10:21:04 +0300 Subject: [PATCH 5/6] Test value typo --- .../asset-calibration/AssetCalibrationDataSource.test.ts | 4 ++-- .../__snapshots__/AssetCalibrationDataSource.test.ts.snap | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/datasources/asset-calibration/AssetCalibrationDataSource.test.ts b/src/datasources/asset-calibration/AssetCalibrationDataSource.test.ts index 4e61cd4..f86a1d1 100644 --- a/src/datasources/asset-calibration/AssetCalibrationDataSource.test.ts +++ b/src/datasources/asset-calibration/AssetCalibrationDataSource.test.ts @@ -85,8 +85,8 @@ const modelLocationGroupCalibrationForecastResponseMock: CalibrationForecastResp { calibrationForecast: { columns: [ - { name: "", values: [1], columnDescriptors: [{ value: "Model1", type: ColumnDescriptorType.StringValue }, { value: "Localtion1", type: ColumnDescriptorType.StringValue }] }, - { name: "", values: [2], columnDescriptors: [{ value: "Model2", type: ColumnDescriptorType.StringValue }, { value: "Localtion1", type: ColumnDescriptorType.StringValue }] } + { name: "", values: [1], columnDescriptors: [{ value: "Model1", type: ColumnDescriptorType.StringValue }, { value: "Location1", type: ColumnDescriptorType.StringValue }] }, + { name: "", values: [2], columnDescriptors: [{ value: "Model2", type: ColumnDescriptorType.StringValue }, { value: "Location1", type: ColumnDescriptorType.StringValue }] } ] } } diff --git a/src/datasources/asset-calibration/__snapshots__/AssetCalibrationDataSource.test.ts.snap b/src/datasources/asset-calibration/__snapshots__/AssetCalibrationDataSource.test.ts.snap index 97985a7..cb730c4 100644 --- a/src/datasources/asset-calibration/__snapshots__/AssetCalibrationDataSource.test.ts.snap +++ b/src/datasources/asset-calibration/__snapshots__/AssetCalibrationDataSource.test.ts.snap @@ -147,8 +147,8 @@ exports[`queries calibration forecast with model and location groupBy 1`] = ` { "name": "Group", "values": [ - "Model1 - Localtion1", - "Model2 - Localtion1", + "Model1 - Location1", + "Model2 - Location1", ], }, { From 5dc3aaf86d3135c9247175d55378422139964192 Mon Sep 17 00:00:00 2001 From: "NI\\akerezsi" Date: Mon, 30 Sep 2024 10:38:23 +0300 Subject: [PATCH 6/6] Revert empty line changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3dffa85..91b0565 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [3.14.0](https://github.com/ni/systemlink-grafana-plugins/compare/v3.13.0...v3.14.0) (2024-09-24) + ### Features * **asset:** add calibration forecast property only row formatting ([#68](https://github.com/ni/systemlink-grafana-plugins/issues/68)) ([162d782](https://github.com/ni/systemlink-grafana-plugins/commit/162d7826c9219ccfc1fc807aae2a61ea0b6b031d))