Skip to content

Commit

Permalink
feat: Refactor Asset Tree to use the new Query/Provider system (#62)
Browse files Browse the repository at this point in the history
## Overview
Refactor the SiteWise Asset Tree types to use the new Query/Provider mechanism.
* AssetTreeSubscription is replaced by a Provider that give the same expand/collapse functionality to the component.
* Removed the asset tree demo as it was put in just as an explainer and we don't intend to ship it.
Will follow up with the work to make asset details similarly functional.
* Remove the AssetDetailsView
  • Loading branch information
gareth-amazon authored Feb 22, 2022
1 parent f9e3d31 commit cccbe61
Show file tree
Hide file tree
Showing 23 changed files with 243 additions and 440 deletions.
36 changes: 3 additions & 33 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@
* It contains typing information for all components that exist in this project.
*/
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { AssetSummaryQuery, AssetTreeSubscription, IoTAppKit, Provider, SiteWiseAssetTreeQuery, SiteWiseTimeSeriesDataProvider, StyleSettingsMap, TimeSeriesData, TimeSeriesDataRequestSettings, TimeSeriesQuery } from "@iot-app-kit/core";
import { IoTAppKit, Provider, SiteWiseAssetTreeQuery, SiteWiseTimeSeriesDataProvider, StyleSettingsMap, TimeSeriesData, TimeSeriesDataRequestSettings, TimeSeriesQuery } from "@iot-app-kit/core";
import { Annotations, MinimalViewPortConfig } from "@synchro-charts/core";
import { ColumnDefinition, FilterTexts, ResourceExplorerQuery, SitewiseAssetResource } from "./components/iot-resource-explorer/types";
import { TableProps } from "@awsui/components-react/table";
import { EmptyStateProps, ITreeNode, UseTreeCollection } from "@iot-app-kit/related-table";
import { NonCancelableCustomEvent } from "@awsui/components-react";
export namespace Components {
interface IotAssetDetails {
"query": AssetSummaryQuery;
}
interface IotAssetTreeDemo {
"query": SiteWiseAssetTreeQuery;
"subscription": AssetTreeSubscription;
}
interface IotBarChart {
"annotations": Annotations;
"appKit": IoTAppKit;
Expand Down Expand Up @@ -144,24 +137,13 @@ export namespace Components {
"query": SiteWiseAssetTreeQuery;
"selectionType"?: TableProps.SelectionType;
"sortingEnabled": boolean;
"widgetId": string;
"wrapLines": boolean;
}
interface TestingGround {
}
}
declare global {
interface HTMLIotAssetDetailsElement extends Components.IotAssetDetails, HTMLStencilElement {
}
var HTMLIotAssetDetailsElement: {
prototype: HTMLIotAssetDetailsElement;
new (): HTMLIotAssetDetailsElement;
};
interface HTMLIotAssetTreeDemoElement extends Components.IotAssetTreeDemo, HTMLStencilElement {
}
var HTMLIotAssetTreeDemoElement: {
prototype: HTMLIotAssetTreeDemoElement;
new (): HTMLIotAssetTreeDemoElement;
};
interface HTMLIotBarChartElement extends Components.IotBarChart, HTMLStencilElement {
}
var HTMLIotBarChartElement: {
Expand Down Expand Up @@ -253,8 +235,6 @@ declare global {
new (): HTMLTestingGroundElement;
};
interface HTMLElementTagNameMap {
"iot-asset-details": HTMLIotAssetDetailsElement;
"iot-asset-tree-demo": HTMLIotAssetTreeDemoElement;
"iot-bar-chart": HTMLIotBarChartElement;
"iot-kpi": HTMLIotKpiElement;
"iot-line-chart": HTMLIotLineChartElement;
Expand All @@ -273,13 +253,6 @@ declare global {
}
}
declare namespace LocalJSX {
interface IotAssetDetails {
"query"?: AssetSummaryQuery;
}
interface IotAssetTreeDemo {
"query"?: SiteWiseAssetTreeQuery;
"subscription"?: AssetTreeSubscription;
}
interface IotBarChart {
"annotations"?: Annotations;
"appKit": IoTAppKit;
Expand Down Expand Up @@ -405,13 +378,12 @@ declare namespace LocalJSX {
"query"?: SiteWiseAssetTreeQuery;
"selectionType"?: TableProps.SelectionType;
"sortingEnabled"?: boolean;
"widgetId"?: string;
"wrapLines"?: boolean;
}
interface TestingGround {
}
interface IntrinsicElements {
"iot-asset-details": IotAssetDetails;
"iot-asset-tree-demo": IotAssetTreeDemo;
"iot-bar-chart": IotBarChart;
"iot-kpi": IotKpi;
"iot-line-chart": IotLineChart;
Expand All @@ -433,8 +405,6 @@ export { LocalJSX as JSX };
declare module "@stencil/core" {
export namespace JSX {
interface IntrinsicElements {
"iot-asset-details": LocalJSX.IotAssetDetails & JSXBase.HTMLAttributes<HTMLIotAssetDetailsElement>;
"iot-asset-tree-demo": LocalJSX.IotAssetTreeDemo & JSXBase.HTMLAttributes<HTMLIotAssetTreeDemoElement>;
"iot-bar-chart": LocalJSX.IotBarChart & JSXBase.HTMLAttributes<HTMLIotBarChartElement>;
"iot-kpi": LocalJSX.IotKpi & JSXBase.HTMLAttributes<HTMLIotKpiElement>;
"iot-line-chart": LocalJSX.IotLineChart & JSXBase.HTMLAttributes<HTMLIotLineChartElement>;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { initialize, IoTAppKitInitInputs, createMockSiteWiseSDK } from '@iot-app-kit/core';
import {
initialize,
IoTAppKitInitInputs,
createMockSiteWiseSDK,
query as siteWiseQuery,
SiteWiseAssetTreeQuery,
} from '@iot-app-kit/core';
import { newSpecPage } from '@stencil/core/testing';
import { IotResourceExplorer } from './iot-resource-explorer';
import { Components } from '../../components.d';
import { CustomHTMLElement } from '../../testing/types';
import { update } from '../../testing/update';
import { ResourceExplorerQuery } from './types';
import flushPromises from 'flush-promises';
import { mocklistAssetsResponse } from '../../testing/mocks/data/listAssetsResponse';
import { mockSiteWiseSDK } from '../../testing/mocks/siteWiseSDK';
Expand All @@ -23,7 +28,7 @@ const resourceExplorerSpec = async (
html: '<div></div>',
supportsShadowDom: false,
});
const query: ResourceExplorerQuery = { source: 'site-wise', rootAssetId: undefined };
const query: SiteWiseAssetTreeQuery = siteWiseQuery.iotsitewise.assetTree.fromRoot();
const resourceExplorer = page.doc.createElement(
'iot-resource-explorer'
) as CustomHTMLElement<Components.IotResourceExplorer>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Component, h, Prop } from '@stencil/core';
import { IoTAppKit } from '@iot-app-kit/core';
import { IoTAppKit, isSiteWiseAssetTreeQuery } from '@iot-app-kit/core';
import { ColumnDefinition, SitewiseAssetResource } from './types';
import { EmptyStateProps } from '@iot-app-kit/related-table';
import { isSiteWiseQuery } from './utils';
import { TableProps } from '@awsui/components-react/table';
import { ResourceExplorerQuery, FilterTexts } from './types';
import { NonCancelableCustomEvent } from '@awsui/components-react';
Expand Down Expand Up @@ -53,7 +52,7 @@ export class IotResourceExplorer {
];

render() {
if (isSiteWiseQuery(this.query)) {
if (isSiteWiseAssetTreeQuery(this.query)) {
return (
<sitewise-resource-explorer
appKit={this.appKit}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { initialize, IoTAppKitInitInputs, createMockSiteWiseSDK } from '@iot-app-kit/core';
import { initialize, IoTAppKitInitInputs, createMockSiteWiseSDK, SiteWiseAssetTreeQuery } from '@iot-app-kit/core';
import * as core from '@iot-app-kit/core';
import { newSpecPage } from '@stencil/core/testing';
import { SitewiseResourceExplorer } from './sitewise-resource-explorer';
Expand Down Expand Up @@ -34,7 +34,7 @@ const sitewiseResourceExplorerSpec = async (
html: '<div></div>',
supportsShadowDom: false,
});
const query: core.SiteWiseAssetTreeQuery = { rootAssetId: undefined };
const query: SiteWiseAssetTreeQuery = new SiteWiseAssetTreeQuery();
const sitewiseResourceExplorer = page.doc.createElement(
'sitewise-resource-explorer'
) as CustomHTMLElement<Components.SitewiseResourceExplorer>;
Expand Down
Loading

0 comments on commit cccbe61

Please sign in to comment.