awslabs / iot-app-kit

A development library for creating web applications to visualize industrial data
Apache License 2.0
119 stars 61 forks source link

feat(react-components): useAlarms hook #2973

Closed hwandersman closed 2 months ago

hwandersman commented 2 months ago

Overview

Introducing the useAlarms hook that takes a list of alarm requests and outputs a a construct AlarmData for each alarm in the response.

This differs from our original design in the following ways:

The useAlarms hook right now just fetches the asset or assetModel alarm info for each request. In the future we will add the following:

  1. Fetch latest alarm property data for state, type, source
  2. Fetch IoT Events alarm models for each alarm
  3. Fetch state and threshold history

Verifying Changes

Added a storybook story and wrote unit tests

Scene Composer

For scene-composer package changes specifically, you can preview the component in the published storybook artifact. To do this, wait for the Publish Storybook action to complete below.

To run the storybook build locally, you need a local static web server:

npm install -g httpserver
cd <Extracted Zip Directory>
httpserver

Then open the website http://localhost:8080 to run the doc site.

Legal

This project is available under the Apache 2.0 License.

jmbuss commented 2 months ago

Discussed various comments, will create a follow-up PR for them. Going to merge now to unblock development of the resource explorer variant for alarms.