Skip to content

Commit

Permalink
fix(alarms): fix for asset-model alarms in kpi
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbuss authored and fpauer committed Oct 4, 2024
1 parent 4a78c3a commit b444ef3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export const useModelBasedQuery = () => {
() => (firstWidget?.properties.queryConfig.query?.assetModels ?? []).at(0),
[firstWidget]
);
const alarmAssetModel = useMemo(
() => (firstWidget?.properties.queryConfig.query?.alarmModels ?? []).at(0),
[firstWidget]
);

const updateModelBasedWidgets = useCallback(
(updatedWidgets: QueryConfigWidget[]) => {
Expand Down Expand Up @@ -100,8 +104,8 @@ export const useModelBasedQuery = () => {
);

return {
assetModelId: assetModel?.assetModelId,
assetIds: assetModel?.assetIds,
assetModelId: assetModel?.assetModelId ?? alarmAssetModel?.assetModelId,
assetIds: assetModel?.assetIds ?? alarmAssetModel?.assetIds,
hasModelBasedQuery: hasModelBasedQueryWidgets,
modelBasedWidgets,
updateModelBasedWidgets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const assignDefaults = (
properties = [],
assetModels = [],
alarms = [],
alarmModels = [],
}: IoTSiteWiseDataStreamQuery,
resAndAggr: { aggregation?: AggregateType; resolution?: string },
getId: () => string = uuid
Expand Down Expand Up @@ -45,6 +46,7 @@ const assignDefaults = (
})),
})),
alarms,
alarmModels,
requestSettings: {
...resAndAggr,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { filterDataStreamsForAlarm } from './filterDatastreamsForAlarm';

import { useTimeSeriesData } from '../../../useTimeSeriesData';

const alarmDataAsComparable = ({ inputProperty }: AlarmData) =>
inputProperty?.map(({ property }) => property.id);
const alarmDataAsComparable = ({ inputProperty, assetId }: AlarmData) =>
inputProperty?.map(({ property }) => ({ assetId, propertyId: property.id }));

export const useInputPropertyTimeSeriesData = ({
alarms,
Expand Down

0 comments on commit b444ef3

Please sign in to comment.