Skip to content

Commit

Permalink
fix(assets): fix display for assets in global variable (#123)
Browse files Browse the repository at this point in the history
Co-authored-by: NI\akerezsi <alex.kerezsi@ni.com>
  • Loading branch information
kkerezsi and alexkerezsini authored Feb 10, 2025
1 parent 3a9dc69 commit 7408f7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/datasources/asset/AssetDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,12 @@ export class AssetDataSource extends DataSourceBase<AssetQuery, AssetDataSourceO
}

private getAssetNameForMetricQuery(asset: AssetModel): MetricFindValue {

const vendor = asset.vendorName ? asset.vendorName : asset.vendorNumber;
const model = asset.modelName ? asset.modelName : asset.modelNumber;
const serial = asset.serialNumber;
const assetIdentifier = `Vendor: ${vendor} - Model: ${model} - Serial: ${serial}`;

const assetName = !asset.name ? assetIdentifier : `${asset.name} (${assetIdentifier})`;
const assetValue = `Assets.${vendor}.${model}.${asset.serialNumber}`
const assetName = !asset.name ? `${serial}` : `${asset.name} (${serial})`;
const assetValue = `Assets.${vendor}.${model}.${serial}`

return { text: assetName, value: assetValue };
}
Expand Down
12 changes: 6 additions & 6 deletions src/datasources/asset/__snapshots__/AssetDataSource.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
exports[`queries metricFindQuery returns default identifiers when asset name is not present 1`] = `
[
{
"text": "Vendor: National Instruments - Model: sbRIO-9629 - Serial: 01FE20D1",
"text": "01FE20D1",
"value": "Assets.National Instruments.sbRIO-9629.01FE20D1",
},
{
"text": "Vendor: 3333 - Model: 1111 - Serial: 2222",
"text": "2222",
"value": "Assets.3333.1111.2222",
},
]
Expand All @@ -16,19 +16,19 @@ exports[`queries metricFindQuery returns default identifiers when asset name is
exports[`queries metricFindQuery returns name/alias when asset name field is present 1`] = `
[
{
"text": "NI-sbRIO-9629-01FE20D1 (Vendor: National Instruments - Model: sbRIO-9629 - Serial: 01FE20D1)",
"text": "NI-sbRIO-9629-01FE20D1 (01FE20D1)",
"value": "Assets.National Instruments.sbRIO-9629.01FE20D1",
},
{
"text": "Conn0_AI (Vendor: National Instruments - Model: AI 0-15 - Serial: 01FE20D1)",
"text": "Conn0_AI (01FE20D1)",
"value": "Assets.National Instruments.AI 0-15.01FE20D1",
},
{
"text": "Conn0_AO (Vendor: National Instruments - Model: AO 0-3 - Serial: 01FE20D1)",
"text": "Conn0_AO (01FE20D1)",
"value": "Assets.National Instruments.AO 0-3.01FE20D1",
},
{
"text": "Conn0_DIO0-3 (Vendor: National Instruments - Model: DIO 0-3 - Serial: 01FE20D1)",
"text": "Conn0_DIO0-3 (01FE20D1)",
"value": "Assets.National Instruments.DIO 0-3.01FE20D1",
},
]
Expand Down

0 comments on commit 7408f7e

Please sign in to comment.