-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f49575
commit bf494c3
Showing
31 changed files
with
253 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/dashboard/src/customization/widgets/gauge/component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.gauge-widget-empty-state { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
} | ||
|
||
.gauge-widget-empty-state-message-container { | ||
align-items: center; | ||
display: flex; | ||
flex-direction: column; | ||
flex-grow: 1; | ||
justify-content: center; | ||
text-align: center; | ||
} |
105 changes: 105 additions & 0 deletions
105
packages/dashboard/src/customization/widgets/gauge/component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import pickBy from 'lodash/pickBy'; | ||
import { Gauge, useViewport } from '@iot-app-kit/react-components'; | ||
import { createWidgetRenderKey } from '../utils/createWidgetRenderKey'; | ||
import type { DashboardState } from '~/store/state'; | ||
import type { GaugeWidget } from '../types'; | ||
import { Box } from '@cloudscape-design/components'; | ||
import { useQueries } from '~/components/dashboard/queryContext'; | ||
import { isDefined } from '~/util/isDefined'; | ||
|
||
import WidgetTile from '~/components/widgets/tile'; | ||
import { useChartSize } from '~/hooks/useChartSize'; | ||
import './component.css'; | ||
|
||
const GaugeWidgetComponent: React.FC<GaugeWidget> = (widget) => { | ||
const { viewport } = useViewport(); | ||
const dashboardSignificantDigits = useSelector( | ||
(state: DashboardState) => state.significantDigits | ||
); | ||
|
||
const { | ||
styleSettings, | ||
queryConfig, | ||
showUnit, | ||
showName, | ||
thresholds, | ||
significantDigits: widgetSignificantDigits, | ||
yMin, | ||
yMax, | ||
} = widget.properties; | ||
|
||
const queries = useQueries(queryConfig.query); | ||
const key = createWidgetRenderKey(widget.id); | ||
const chartSize = useChartSize(widget); | ||
|
||
const shouldShowEmptyState = queries.length === 0; | ||
|
||
if (shouldShowEmptyState) { | ||
return ( | ||
<WidgetTile widget={widget}> | ||
<GaugeWidgetEmptyStateComponent /> | ||
</WidgetTile> | ||
); | ||
} | ||
|
||
const settings = pickBy( | ||
{ | ||
yMin, | ||
yMax, | ||
showName, | ||
showUnit, | ||
}, | ||
isDefined | ||
); | ||
|
||
const significantDigits = | ||
widgetSignificantDigits ?? dashboardSignificantDigits; | ||
|
||
const size = { width: chartSize.width - 8, height: chartSize.height - 8 }; | ||
|
||
return ( | ||
<WidgetTile widget={widget} key={key}> | ||
<Gauge | ||
size={size} | ||
query={queries[0]} | ||
viewport={viewport} | ||
styles={styleSettings} | ||
settings={settings} | ||
thresholds={thresholds} | ||
significantDigits={significantDigits} | ||
/> | ||
</WidgetTile> | ||
); | ||
}; | ||
|
||
const GaugeWidgetEmptyStateComponent: React.FC = () => { | ||
return ( | ||
<div className='gauge-widget-empty-state'> | ||
<Box variant='strong' color='text-status-inactive' margin='s'> | ||
Gauge | ||
</Box> | ||
|
||
<div className='gauge-widget-empty-state-message-container'> | ||
<Box | ||
variant='strong' | ||
color='text-status-inactive' | ||
margin={{ horizontal: 's' }} | ||
> | ||
No properties or alarms | ||
</Box> | ||
|
||
<Box | ||
variant='p' | ||
color='text-status-inactive' | ||
margin={{ bottom: 's', horizontal: 's' }} | ||
> | ||
Add a property or alarm to populate Gauge | ||
</Box> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GaugeWidgetComponent; |
12 changes: 12 additions & 0 deletions
12
packages/dashboard/src/customization/widgets/gauge/gauge-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
packages/dashboard/src/customization/widgets/gauge/gauge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
packages/dashboard/src/customization/widgets/gauge/icon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { default as GaugeSvg } from './gauge.svg'; | ||
import { default as GaugeSvgDark } from './gauge-dark.svg'; | ||
import WidgetIcon from '../components/widgetIcon'; | ||
|
||
const GaugeIcon = () => { | ||
return ( | ||
<WidgetIcon widget='gauge' defaultIcon={GaugeSvg} darkIcon={GaugeSvgDark} /> | ||
); | ||
}; | ||
|
||
export default GaugeIcon; |
33 changes: 33 additions & 0 deletions
33
packages/dashboard/src/customization/widgets/gauge/plugin.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import GaugeWidgetComponent from './component'; | ||
import GaugeIcon from './icon'; | ||
import type { DashboardPlugin } from '~/customization/api'; | ||
import type { GaugeWidget } from '../types'; | ||
import { WIDGET_INITIAL_HEIGHT, WIDGET_INITIAL_WIDTH } from '../constants'; | ||
|
||
export const gaugePlugin: DashboardPlugin = { | ||
install: ({ registerWidget }) => { | ||
registerWidget<GaugeWidget>('gauge', { | ||
render: (widget) => <GaugeWidgetComponent {...widget} />, | ||
componentLibrary: { | ||
name: 'Gauge', | ||
icon: GaugeIcon, | ||
}, | ||
properties: () => ({ | ||
queryConfig: { | ||
source: 'iotsitewise', | ||
query: undefined, | ||
}, | ||
showName: true, | ||
showUnit: true, | ||
yMin: 0, | ||
yMax: 100, | ||
thresholds: [], | ||
}), | ||
initialSize: { | ||
height: WIDGET_INITIAL_HEIGHT, | ||
width: WIDGET_INITIAL_WIDTH, | ||
}, | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+3.18 KB
(120%)
...s/e2e/tests/anomaly/anomaly.spec.ts-snapshots/anomaly-chart-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+252 Bytes
(100%)
...tests/anomaly/anomaly.spec.ts-snapshots/anomaly-chart-error-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1010 Bytes
(110%)
...omaly.spec.ts-snapshots/anomaly-chart-hidden-axis-timestamp-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+4.31 KB
(120%)
...s/chart/chart.spec.ts-snapshots/line-chart-default-settings-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-228 Bytes
(99%)
.../tests/gauge/gauge.spec.ts-snapshots/gauge-default-settings-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-228 Bytes
(99%)
...e/tests/gauge/gauge.spec.ts-snapshots/gauge-default-settings-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.26 KB
(110%)
...e/tests/gauge/gauge.spec.ts-snapshots/gauge-hidden-settings-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.26 KB
(110%)
...2e/tests/gauge/gauge.spec.ts-snapshots/gauge-hidden-settings-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.74 KB
(110%)
...e/tests/gauge/gauge.spec.ts-snapshots/gauge-with-thresholds-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.74 KB
(110%)
...2e/tests/gauge/gauge.spec.ts-snapshots/gauge-with-thresholds-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.81 KB
(130%)
...ts/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-default-settings-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+397 Bytes
(120%)
...nts/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-hidden-settings-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+5.57 KB
(130%)
...nts/e2e/tests/kpi/kpi.spec.ts-snapshots/kpi-with-thresholds-chromium-darwin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.