Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
corteggiano committed Sep 19, 2024
1 parent a6c7527 commit 3e5612d
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ import { getPlugin } from '@iot-app-kit/core';
import { ResourceExplorerFooter } from '../footer/footer';
import { createNonNullableList } from '~/helpers/lists/createNonNullableList';
import { DashboardWidget } from '~/types';
import { AlarmExplorer, AlarmExplorerProps, AssetResource, useGetConfigValue } from '@iot-app-kit/react-components';
import {
AlarmExplorer,
AlarmExplorerProps,
AssetResource,
useGetConfigValue,
} from '@iot-app-kit/react-components';
import { useAssetsForAssetModel } from './assetsForAssetModelSelect/useAssetsForAssetModel/useAssetsForAssetModel';
import { ExpandableSection } from '@cloudscape-design/components';
import { ExpandableSectionHeading } from '../components/expandableSectionHeading';
Expand Down Expand Up @@ -71,7 +76,8 @@ export const AssetModelDataStreamExplorer = ({
({ id }) => id === assetIds?.at(0)
);

const { assetModels, updateAssetModels, uppdateAssetAlarmModels } = useModelBasedQuerySelection();
const { assetModels, updateAssetModels, uppdateAssetAlarmModels } =
useModelBasedQuerySelection();

const { propertyIds } = getAssetModelQueryInformation(assetModels);

Expand Down Expand Up @@ -150,9 +156,9 @@ export const AssetModelDataStreamExplorer = ({
createAlarmModelQuery({
assetModelId: selectedAssetModel[0].assetModelId,
assetId: selectedAsset?.at(0)?.assetId,
alarms: selectedAlarms
alarms: selectedAlarms,
})
)
);
}
};

Expand Down Expand Up @@ -183,50 +189,59 @@ export const AssetModelDataStreamExplorer = ({
<HorizontalDivider />
</Box>

{
alarmsFeatureOn ?
(
<>
<ExpandableSection
headerText={<ExpandableSectionHeading headerText='Data Streams' />}
defaultExpanded
>
<AssetModelPropertiesExplorer
{...assetModelPropertiesExplorerProps}
/>
</ExpandableSection>
<ExpandableSection
headerText={
<ExpandableSectionHeading headerText='Alarm Data Streams' />
}
>
<AlarmExplorer
iotSiteWiseClient={iotSiteWiseClient}
parameters={selectedAsset.length > 0 ? selectedAsset : selectedAssetModel}
selectionMode={correctSelectionMode}
onSelectAlarm={setSelectedAlarms}
selectedAlarms={selectedAlarms}
tableSettings={{
isFilterEnabled: true,
isUserSettingsEnabled: true,
}}
ariaLabels={{
resizerRoleDescription: 'Resize button',
itemSelectionLabel: ({ selectedItems }, modeledDataStream) =>
alarmSelectionLabel([...selectedItems], modeledDataStream),
}}
description='Select an alarm to add to a selected widget'
timeZone={timeZone}
significantDigits={significantDigits}
/>
</ExpandableSection>
</>
) : (
{alarmsFeatureOn ? (
<>
<ExpandableSection
headerText={
<ExpandableSectionHeading headerText='Data Streams' />
}
defaultExpanded
>
<AssetModelPropertiesExplorer
{...assetModelPropertiesExplorerProps}
/>
)
}
</ExpandableSection>
<ExpandableSection
headerText={
<ExpandableSectionHeading headerText='Alarm Data Streams' />
}
>
<AlarmExplorer
iotSiteWiseClient={iotSiteWiseClient}
parameters={
selectedAsset.length > 0
? selectedAsset
: selectedAssetModel
}
selectionMode={correctSelectionMode}
onSelectAlarm={setSelectedAlarms}
selectedAlarms={selectedAlarms}
tableSettings={{
isFilterEnabled: true,
isUserSettingsEnabled: true,
}}
ariaLabels={{
resizerRoleDescription: 'Resize button',
itemSelectionLabel: (
{ selectedItems },
modeledDataStream
) =>
alarmSelectionLabel(
[...selectedItems],
modeledDataStream
),
}}
description='Select an alarm to add to a selected widget'
timeZone={timeZone}
significantDigits={significantDigits}
/>
</ExpandableSection>
</>
) : (
<AssetModelPropertiesExplorer
{...assetModelPropertiesExplorerProps}
/>
)}

<ResourceExplorerFooter
addDisabled={addButtonDisabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ export const createAlarmModelQuery = ({
alarms,
}: {
assetModelId: string;
alarms: NonNullable<AlarmExplorerProps['selectedAlarms']>
alarms: NonNullable<AlarmExplorerProps['selectedAlarms']>;
assetId?: string;
}): SiteWiseAlarmAssetModelQuery['alarmModels'] => [
{
assetModelId: assetModelId,
assetIds: assetId ? [assetId] : [],
alarmComponents: alarms.map(({ assetCompositeModelId }) => ({ assetCompositeModelId })),
alarmComponents: alarms.map(({ assetCompositeModelId }) => ({
assetCompositeModelId,
})),
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { QueryConfigWidget, isQueryWidget } from './findModelBasedQueryWidgets';
import { QueryProperties } from '~/customization/widgets/types';
import { isJust, maybeWithDefault } from '~/util/maybe';
import { noop } from 'lodash';
import { AssetModelQuery } from '@iot-app-kit/source-iotsitewise';
import {
AssetModelQuery,
AlarmAssetModelQuery,
} from '@iot-app-kit/source-iotsitewise';
import { styledQueryWidgetOnDrop } from '~/components/queryEditor/useQuery';
import { assignDefaultStyles } from '~/customization/widgets/utils/assignDefaultStyleSettings';
import { IoTSiteWiseDataStreamQuery } from '~/types';
import { AlarmAssetModelQuery } from '@iot-app-kit/source-iotsitewise';

const mergeAssetModelProperties = (
currentQuery: QueryConfigWidget['properties']['queryConfig']['query'],
Expand Down Expand Up @@ -49,7 +51,8 @@ const mergeAlarmModelCompositeModelIds = (
)
?.alarmComponents.find(
(currentAlarmModelAlarm) =>
currentAlarmModelAlarm.assetCompositeModelId === alarm.assetCompositeModelId
currentAlarmModelAlarm.assetCompositeModelId ===
alarm.assetCompositeModelId
);
return {
...currentAlarm,
Expand Down Expand Up @@ -102,7 +105,7 @@ export const useModelBasedQuerySelection = () => {
alarmModels: mergeAlarmModelCompositeModelIds(
compositeWidgetForAggregationInformation.properties.queryConfig
.query,
updatedAlarmModels
updatedAlarmModels
),
},
compositeWidgetForAggregationInformation
Expand All @@ -118,7 +121,6 @@ export const useModelBasedQuerySelection = () => {
},
},
};

} else {
const styledProperties = assignDefaultStyles({
...compositeWidgetForAggregationInformation,
Expand All @@ -132,7 +134,7 @@ export const useModelBasedQuerySelection = () => {
alarmModels: mergeAlarmModelCompositeModelIds(
compositeWidgetForAggregationInformation.properties.queryConfig
.query,
updatedAlarmModels
updatedAlarmModels
),
},
},
Expand All @@ -145,7 +147,7 @@ export const useModelBasedQuerySelection = () => {

setProperties(updatedProperties);
};

const updateAssetModels = (
updatedAssetModels: AssetModelQuery[] | undefined
) => {
Expand Down Expand Up @@ -183,7 +185,6 @@ export const useModelBasedQuerySelection = () => {
},
},
};

} else {
const styledProperties = assignDefaultStyles({
...compositeWidgetForAggregationInformation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { fontSizeHeadingL } from '@cloudscape-design/design-tokens';

export const ExpandableSectionHeading = ({ headerText }: { headerText: string }) => (
<h3 style={{ margin: 0, fontSize: fontSizeHeadingL }}>{headerText}</h3>
);
export const ExpandableSectionHeading = ({
headerText,
}: {
headerText: string;
}) => <h3 style={{ margin: 0, fontSize: fontSizeHeadingL }}>{headerText}</h3>;
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ export const ModeledExplorer = ({
isUserSettingsEnabled: true,
}}
isAssetPropertyDisabled={(item) =>
isModeledPropertyInvalid(
item.dataType,
selectedWidgets.at(0)?.type
)
isModeledPropertyInvalid(item.dataType, selectedWidgets.at(0)?.type)
}
ariaLabels={{
resizerRoleDescription: 'Resize button',
Expand Down Expand Up @@ -141,14 +138,16 @@ export const ModeledExplorer = ({
: `Deselect asset ${asset.name}`,
}}
/>
{selectedAssets.length > 0 && (
alarmsFeatureOn ?
(<>
{selectedAssets.length > 0 &&
(alarmsFeatureOn ? (
<>
<ExpandableSection
headerText={<ExpandableSectionHeading headerText='Data Streams' />}
headerText={
<ExpandableSectionHeading headerText='Data Streams' />
}
defaultExpanded
>
{ AssetExplorerComponent }
{AssetExplorerComponent}
</ExpandableSection>
<ExpandableSection
headerText={
Expand All @@ -175,9 +174,10 @@ export const ModeledExplorer = ({
significantDigits={significantDigits}
/>
</ExpandableSection>
</>) :
</>
) : (
AssetExplorerComponent
)}
))}
<ResourceExplorerFooter
addDisabled={addButtonDisabled}
onReset={resetPropertiesAndAlarms}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const LineScatterChartWidgetComponent: React.FC<LineScatterChartWidget> = (
} = widget.properties;

const query = queryConfig.query;
console.log(query)
console.log(query);
const queries = useQueries(query);

const mappedQuery = assetModelQueryToSiteWiseAssetQuery(query);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { AlarmAssetModelQuery, SiteWiseAlarmQuery } from "@iot-app-kit/source-iotsitewise";
import { SiteWiseQueryConfig } from "../types";
import uniq from "lodash/uniq";
import unionBy from "lodash/unionBy";
import {
AlarmAssetModelQuery,
SiteWiseAlarmQuery,
} from '@iot-app-kit/source-iotsitewise';
import { SiteWiseQueryConfig } from '../types';
import uniq from 'lodash/uniq';
import unionBy from 'lodash/unionBy';

type AlarmModelQueryWithAssetId = Required<AlarmAssetModelQuery>;
const alarmModelWithAssetId = (
Expand Down Expand Up @@ -29,7 +32,11 @@ const combineAlarms = (
if (foundA && foundB) {
return {
...foundA,
alarmComponents: unionBy(foundA.alarmComponents, foundB.alarmComponents, 'assetCompositeModelId'),
alarmComponents: unionBy(
foundA.alarmComponents,
foundB.alarmComponents,
'assetCompositeModelId'
),
};
}

Expand Down

0 comments on commit 3e5612d

Please sign in to comment.