Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(alarms): add alarm resource explorer #2993

Merged
merged 1 commit into from
Sep 19, 2024
Merged

Conversation

jmbuss
Copy link
Contributor

@jmbuss jmbuss commented Sep 16, 2024

Overview

Adds an Alarm resource explorer which uses the useAlarms hook to display a table of alarms from either asset or asset model parameters.

Note: Some of the tests for the explorers are commented out. They will be revisited in a following PR once the asset property values hooks part useAlarms are completed and stable.

image image image image image image

Legal

This project is available under the Apache 2.0 License.

@jmbuss jmbuss force-pushed the feat/alarm-resource-explorer branch 2 times, most recently from a7c6948 to 9bfa678 Compare September 16, 2024 22:32
@jmbuss jmbuss marked this pull request as ready for review September 16, 2024 22:34
@jmbuss jmbuss force-pushed the feat/alarm-resource-explorer branch 2 times, most recently from 4891063 to 57a355f Compare September 16, 2024 23:00
@hwandersman
Copy link
Contributor

Can you add some screenshots for the alarm table + showing the latest alarm data?

}

try {
const { stateName } = JSON.parse(alarmStateJSON);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a type-safe JSON parse with a cast to an internal type that matches the expected state value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a library we are using for this? Otherwise I can make a safeParse function

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know of any good external libraries, we should write one if it's not too much of a headache

if (ALARM_STATUS[stateName as UpperCaseStateName] != null) {
normalizedStateName = ALARM_STATUS[stateName as UpperCaseStateName];
} else {
normalizedStateName = stateName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we setting an unknown state? We should probably log/throw an error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually copied this from the existing alarms functionality in source-iotsitewise. I had assumed there was some legacy complication that we wanted to be able to display something atleast

@jmbuss jmbuss force-pushed the feat/alarm-resource-explorer branch from 57a355f to ed8b9db Compare September 17, 2024 19:02
@jmbuss jmbuss requested a review from hwandersman September 17, 2024 19:03
assetCompositeModelId: compositeModelId,
assetId,
assetModelId,
sourcePropertyId: source?.property.id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be inputPropertyName --> alarmData.inputProperty[0].name

We don't need to show the alarm source propertyId

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see, this is the wrong "source". haha.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is exactly why I renamed "sourceProperty" to "inputProperty" cause it's easy to mess that up :)

@jmbuss jmbuss force-pushed the feat/alarm-resource-explorer branch from ed8b9db to afa319a Compare September 17, 2024 20:59
hwandersman
hwandersman previously approved these changes Sep 17, 2024
@jmbuss jmbuss force-pushed the feat/alarm-resource-explorer branch from afa319a to 2004b44 Compare September 19, 2024 15:47
@jmbuss jmbuss merged commit be320bc into rc Sep 19, 2024
20 checks passed
@jmbuss jmbuss deleted the feat/alarm-resource-explorer branch September 19, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants