Skip to content

Commit

Permalink
feat: sitewise components use query and provider (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
boweihan authored Feb 11, 2022
1 parent 83b100f commit 80cf5d4
Show file tree
Hide file tree
Showing 37 changed files with 1,021 additions and 908 deletions.
142 changes: 55 additions & 87 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* It contains typing information for all components that exist in this project.
*/
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { AnyDataStreamQuery, AssetSummaryQuery, AssetTreeSubscription, DataStream, IoTAppKitSession, SiteWiseAssetTreeQuery, StyleSettingsMap, TimeSeriesDataRequest, TimeSeriesDataRequestSettings } from "@iot-app-kit/core";
import { MinimalViewPortConfig } from "@synchro-charts/core";
import { AssetSummaryQuery, AssetTreeSubscription, IoTAppKit, Provider, SiteWiseAssetTreeQuery, SiteWiseTimeSeriesDataProvider, StyleSettingsMap, TimeSeriesData, TimeSeriesQuery } from "@iot-app-kit/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";
import { MinimalViewPortConfig } from "@synchro-charts/core";
export namespace Components {
interface IotAssetDetails {
"query": AssetSummaryQuery;
Expand All @@ -20,42 +20,28 @@ export namespace Components {
"subscription": AssetTreeSubscription;
}
interface IotBarChart {
"appKitSession": IoTAppKitSession;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": AnyDataStreamQuery[];
"settings": TimeSeriesDataRequestSettings | undefined;
"query": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotConnector {
"appKitSession": IoTAppKitSession;
"queries": AnyDataStreamQuery[];
"renderFunc": ({ dataStreams }: { dataStreams: DataStream[] }) => unknown;
"request": TimeSeriesDataRequest;
"styleSettings": StyleSettingsMap | undefined;
}
interface IotKpi {
"appKitSession": IoTAppKitSession;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": AnyDataStreamQuery[];
"settings": TimeSeriesDataRequestSettings | undefined;
"query": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotLineChart {
"appKitSession": IoTAppKitSession;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": AnyDataStreamQuery[];
"settings": TimeSeriesDataRequestSettings | undefined;
"query": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings": StyleSettingsMap | undefined;
"styles": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotResourceExplorer {
"appKitSession": IoTAppKitSession;
"appKit": IoTAppKit;
"columnDefinitions"?: ColumnDefinition<SitewiseAssetResource>[];
"empty"?: EmptyStateProps;
"filterEnabled": boolean;
Expand All @@ -71,42 +57,40 @@ export namespace Components {
interface IotResourceExplorerDemo {
}
interface IotScatterChart {
"appKitSession": IoTAppKitSession;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": AnyDataStreamQuery[];
"settings": TimeSeriesDataRequestSettings | undefined;
"query": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotStatusGrid {
"appKitSession": IoTAppKitSession;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": AnyDataStreamQuery[];
"settings": TimeSeriesDataRequestSettings | undefined;
"query": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotStatusTimeline {
"appKitSession": IoTAppKitSession;
"appKit": IoTAppKit;
"isEditing": boolean | undefined;
"queries": AnyDataStreamQuery[];
"settings": TimeSeriesDataRequestSettings | undefined;
"query": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotTable {
"appKitSession": IoTAppKitSession;
"queries": AnyDataStreamQuery[];
"settings": TimeSeriesDataRequestSettings | undefined;
"appKit": IoTAppKit;
"query": TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings": StyleSettingsMap | undefined;
"viewport": MinimalViewPortConfig;
"widgetId": string;
}
interface IotTestRoutes {
}
interface IotTimeSeriesConnector {
"initialViewport": MinimalViewPortConfig;
"provider": Provider<TimeSeriesData>;
"renderFunc": (data: TimeSeriesData) => void;
"styleSettings": StyleSettingsMap | undefined;
}
interface IotTreeTable {
"ariaLabels": TableProps.AriaLabels<unknown>;
"collectionOptions": UseTreeCollection<unknown>;
Expand All @@ -128,7 +112,7 @@ export namespace Components {
interface IotTreeTableDemo {
}
interface SitewiseResourceExplorer {
"appKitSession": IoTAppKitSession;
"appKit": IoTAppKit;
"columnDefinitions": ColumnDefinition<any>[];
"empty"?: EmptyStateProps;
"filterEnabled": boolean;
Expand Down Expand Up @@ -163,12 +147,6 @@ declare global {
prototype: HTMLIotBarChartElement;
new (): HTMLIotBarChartElement;
};
interface HTMLIotConnectorElement extends Components.IotConnector, HTMLStencilElement {
}
var HTMLIotConnectorElement: {
prototype: HTMLIotConnectorElement;
new (): HTMLIotConnectorElement;
};
interface HTMLIotKpiElement extends Components.IotKpi, HTMLStencilElement {
}
var HTMLIotKpiElement: {
Expand Down Expand Up @@ -223,6 +201,12 @@ declare global {
prototype: HTMLIotTestRoutesElement;
new (): HTMLIotTestRoutesElement;
};
interface HTMLIotTimeSeriesConnectorElement extends Components.IotTimeSeriesConnector, HTMLStencilElement {
}
var HTMLIotTimeSeriesConnectorElement: {
prototype: HTMLIotTimeSeriesConnectorElement;
new (): HTMLIotTimeSeriesConnectorElement;
};
interface HTMLIotTreeTableElement extends Components.IotTreeTable, HTMLStencilElement {
}
var HTMLIotTreeTableElement: {
Expand Down Expand Up @@ -251,7 +235,6 @@ declare global {
"iot-asset-details": HTMLIotAssetDetailsElement;
"iot-asset-tree-demo": HTMLIotAssetTreeDemoElement;
"iot-bar-chart": HTMLIotBarChartElement;
"iot-connector": HTMLIotConnectorElement;
"iot-kpi": HTMLIotKpiElement;
"iot-line-chart": HTMLIotLineChartElement;
"iot-resource-explorer": HTMLIotResourceExplorerElement;
Expand All @@ -261,6 +244,7 @@ declare global {
"iot-status-timeline": HTMLIotStatusTimelineElement;
"iot-table": HTMLIotTableElement;
"iot-test-routes": HTMLIotTestRoutesElement;
"iot-time-series-connector": HTMLIotTimeSeriesConnectorElement;
"iot-tree-table": HTMLIotTreeTableElement;
"iot-tree-table-demo": HTMLIotTreeTableDemoElement;
"sitewise-resource-explorer": HTMLSitewiseResourceExplorerElement;
Expand All @@ -276,42 +260,28 @@ declare namespace LocalJSX {
"subscription"?: AssetTreeSubscription;
}
interface IotBarChart {
"appKitSession"?: IoTAppKitSession;
"appKit"?: IoTAppKit;
"isEditing"?: boolean | undefined;
"queries"?: AnyDataStreamQuery[];
"settings"?: TimeSeriesDataRequestSettings | undefined;
"query"?: TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport"?: MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotConnector {
"appKitSession"?: IoTAppKitSession;
"queries"?: AnyDataStreamQuery[];
"renderFunc"?: ({ dataStreams }: { dataStreams: DataStream[] }) => unknown;
"request"?: TimeSeriesDataRequest;
"styleSettings"?: StyleSettingsMap | undefined;
}
interface IotKpi {
"appKitSession"?: IoTAppKitSession;
"appKit"?: IoTAppKit;
"isEditing"?: boolean | undefined;
"queries"?: AnyDataStreamQuery[];
"settings"?: TimeSeriesDataRequestSettings | undefined;
"query"?: TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport"?: MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotLineChart {
"appKitSession"?: IoTAppKitSession;
"appKit"?: IoTAppKit;
"isEditing"?: boolean | undefined;
"queries"?: AnyDataStreamQuery[];
"settings"?: TimeSeriesDataRequestSettings | undefined;
"query"?: TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings"?: StyleSettingsMap | undefined;
"styles"?: StyleSettingsMap | undefined;
"viewport"?: MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotResourceExplorer {
"appKitSession"?: IoTAppKitSession;
"appKit"?: IoTAppKit;
"columnDefinitions"?: ColumnDefinition<SitewiseAssetResource>[];
"empty"?: EmptyStateProps;
"filterEnabled"?: boolean;
Expand All @@ -327,42 +297,40 @@ declare namespace LocalJSX {
interface IotResourceExplorerDemo {
}
interface IotScatterChart {
"appKitSession"?: IoTAppKitSession;
"appKit"?: IoTAppKit;
"isEditing"?: boolean | undefined;
"queries"?: AnyDataStreamQuery[];
"settings"?: TimeSeriesDataRequestSettings | undefined;
"query"?: TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport"?: MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotStatusGrid {
"appKitSession"?: IoTAppKitSession;
"appKit"?: IoTAppKit;
"isEditing"?: boolean | undefined;
"queries"?: AnyDataStreamQuery[];
"settings"?: TimeSeriesDataRequestSettings | undefined;
"query"?: TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport"?: MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotStatusTimeline {
"appKitSession"?: IoTAppKitSession;
"appKit"?: IoTAppKit;
"isEditing"?: boolean | undefined;
"queries"?: AnyDataStreamQuery[];
"settings"?: TimeSeriesDataRequestSettings | undefined;
"query"?: TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport"?: MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotTable {
"appKitSession"?: IoTAppKitSession;
"queries"?: AnyDataStreamQuery[];
"settings"?: TimeSeriesDataRequestSettings | undefined;
"appKit"?: IoTAppKit;
"query"?: TimeSeriesQuery<SiteWiseTimeSeriesDataProvider>;
"styleSettings"?: StyleSettingsMap | undefined;
"viewport"?: MinimalViewPortConfig;
"widgetId"?: string;
}
interface IotTestRoutes {
}
interface IotTimeSeriesConnector {
"initialViewport"?: MinimalViewPortConfig;
"provider"?: Provider<TimeSeriesData>;
"renderFunc"?: (data: TimeSeriesData) => void;
"styleSettings"?: StyleSettingsMap | undefined;
}
interface IotTreeTable {
"ariaLabels"?: TableProps.AriaLabels<unknown>;
"collectionOptions": UseTreeCollection<unknown>;
Expand All @@ -384,7 +352,7 @@ declare namespace LocalJSX {
interface IotTreeTableDemo {
}
interface SitewiseResourceExplorer {
"appKitSession"?: IoTAppKitSession;
"appKit"?: IoTAppKit;
"columnDefinitions"?: ColumnDefinition<any>[];
"empty"?: EmptyStateProps;
"filterEnabled"?: boolean;
Expand All @@ -403,7 +371,6 @@ declare namespace LocalJSX {
"iot-asset-details": IotAssetDetails;
"iot-asset-tree-demo": IotAssetTreeDemo;
"iot-bar-chart": IotBarChart;
"iot-connector": IotConnector;
"iot-kpi": IotKpi;
"iot-line-chart": IotLineChart;
"iot-resource-explorer": IotResourceExplorer;
Expand All @@ -413,6 +380,7 @@ declare namespace LocalJSX {
"iot-status-timeline": IotStatusTimeline;
"iot-table": IotTable;
"iot-test-routes": IotTestRoutes;
"iot-time-series-connector": IotTimeSeriesConnector;
"iot-tree-table": IotTreeTable;
"iot-tree-table-demo": IotTreeTableDemo;
"sitewise-resource-explorer": SitewiseResourceExplorer;
Expand All @@ -426,7 +394,6 @@ declare module "@stencil/core" {
"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-connector": LocalJSX.IotConnector & JSXBase.HTMLAttributes<HTMLIotConnectorElement>;
"iot-kpi": LocalJSX.IotKpi & JSXBase.HTMLAttributes<HTMLIotKpiElement>;
"iot-line-chart": LocalJSX.IotLineChart & JSXBase.HTMLAttributes<HTMLIotLineChartElement>;
"iot-resource-explorer": LocalJSX.IotResourceExplorer & JSXBase.HTMLAttributes<HTMLIotResourceExplorerElement>;
Expand All @@ -436,6 +403,7 @@ declare module "@stencil/core" {
"iot-status-timeline": LocalJSX.IotStatusTimeline & JSXBase.HTMLAttributes<HTMLIotStatusTimelineElement>;
"iot-table": LocalJSX.IotTable & JSXBase.HTMLAttributes<HTMLIotTableElement>;
"iot-test-routes": LocalJSX.IotTestRoutes & JSXBase.HTMLAttributes<HTMLIotTestRoutesElement>;
"iot-time-series-connector": LocalJSX.IotTimeSeriesConnector & JSXBase.HTMLAttributes<HTMLIotTimeSeriesConnectorElement>;
"iot-tree-table": LocalJSX.IotTreeTable & JSXBase.HTMLAttributes<HTMLIotTreeTableElement>;
"iot-tree-table-demo": LocalJSX.IotTreeTableDemo & JSXBase.HTMLAttributes<HTMLIotTreeTableDemoElement>;
"sitewise-resource-explorer": LocalJSX.SitewiseResourceExplorer & JSXBase.HTMLAttributes<HTMLSitewiseResourceExplorerElement>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
AssetPropertyValueQuery,
} from '@iot-app-kit/core';
import { AssetPropertyValue, AssetSummary, DescribeAssetModelResponse } from '@aws-sdk/client-iotsitewise';
import { AssetModelProperty } from '@aws-sdk/client-iotsitewise/dist-types/models/models_0';

@Component({
tag: 'iot-asset-details',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { newSpecPage } from '@stencil/core/testing';
import { MinimalLiveViewport } from '@synchro-charts/core';
import { IotBarChart } from './iot-bar-chart';
import { Components } from '../../components.d';
import { initialize, SiteWiseDataStreamQuery } from '@iot-app-kit/core';
import { initialize, query, SiteWiseDataStreamQuery } from '@iot-app-kit/core';
import { createMockSource } from '../../testing/createMockSource';
import { DATA_STREAM } from '../../testing/mockWidgetProperties';
import { IotConnector } from '../iot-connector/iot-connector';
import { IotTimeSeriesConnector } from '../iot-time-series-connector.ts/iot-time-series-connector';
import { CustomHTMLElement } from '../../testing/types';
import { update } from '../../testing/update';

Expand All @@ -14,26 +14,34 @@ const viewport: MinimalLiveViewport = {
};

const barChartSpecPage = async (propOverrides: Partial<Components.IotBarChart> = {}) => {
const appKitSession = initialize({ registerDataSources: false }).session();
appKitSession.registerDataSource(createMockSource([DATA_STREAM]));
const appKit = initialize({
registerDataSources: false,
awsCredentials: { accessKeyId: 'test', secretAccessKey: 'test' },
awsRegion: 'test',
});
appKit.registerTimeSeriesDataSource(createMockSource([DATA_STREAM]));

const page = await newSpecPage({
components: [IotBarChart, IotConnector],
components: [IotBarChart, IotTimeSeriesConnector],
html: '<div></div>',
supportsShadowDom: false,
});
const barChart = page.doc.createElement('iot-bar-chart') as CustomHTMLElement<Components.IotBarChart>;
const props: Partial<Components.IotBarChart> = {
appKitSession,
appKit,
widgetId: 'test-bar-chart-widget',
isEditing: false,
queries: [
{
source: 'test-mock',
assets: [{ assetId: 'some-asset-id', properties: [{ propertyId: 'some-property-id' }] }],
} as SiteWiseDataStreamQuery,
],
viewport,
query: query.iotsitewise.timeSeriesData({
queries: [
{
source: 'test-mock',
assets: [{ assetId: 'some-asset-id', properties: [{ propertyId: 'some-property-id' }] }],
} as SiteWiseDataStreamQuery,
],
request: {
viewport,
},
}),
...propOverrides,
};
update(barChart, props);
Expand Down
Loading

0 comments on commit 80cf5d4

Please sign in to comment.