Skip to content

Commit 7b7d081

Browse files
LaxenadeDanny Zhao
andauthored
feat(widget): add TABLE widget type (#638)
Closes #550 Add support for `TableWidget` in dashboards. --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_ Co-authored-by: Danny Zhao <zikangz@amazon.com>
1 parent eee9581 commit 7b7d081

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

API.md

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/common/widget/types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
GraphWidgetView,
55
IWidget,
66
SingleValueWidget,
7+
TableWidget,
78
} from "aws-cdk-lib/aws-cloudwatch";
89

910
export enum GraphWidgetType {
@@ -12,6 +13,7 @@ export enum GraphWidgetType {
1213
PIE = "Pie",
1314
SINGLE_VALUE = "SingleValue",
1415
STACKED_AREA = "StackedArea",
16+
TABLE = "Table",
1517
}
1618

1719
/**
@@ -52,6 +54,12 @@ export function createGraphWidget(
5254
stacked: true,
5355
});
5456

57+
case GraphWidgetType.TABLE:
58+
return new TableWidget({
59+
...props,
60+
metrics: [...(props.left ?? []), ...(props.right ?? [])],
61+
});
62+
5563
default:
5664
throw new Error(`Unsupported graph type: ${type}`);
5765
}

test/monitoring/custom/CustomMonitoring.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ test("snapshot test", () => {
188188
new Metric({ metricName: "DummyMetric41", namespace, dimensionsMap }),
189189
],
190190
},
191+
{
192+
title: "DummyGroup5",
193+
graphWidgetType: GraphWidgetType.TABLE,
194+
metrics: [
195+
new Metric({ metricName: "DummyMetric50", namespace, dimensionsMap }),
196+
new Metric({ metricName: "DummyMetric51", namespace, dimensionsMap }),
197+
],
198+
},
191199
],
192200
useCreatedAlarms: {
193201
consume(alarms) {

test/monitoring/custom/__snapshots__/CustomMonitoring.test.ts.snap

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)