Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(custom): add graphWidgetWidth to allow for custom widths in CustomMetricGroup objects #517

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/common/widget/size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const DefaultLogWidgetHeight = 7;
/**
* Suggests the best widget width, given the total number of widgets.
* The main point is to make widgets as wide as possible, while saving vertical space and minimizing number of gaps.
*
* @param numTotalWidgets total number of widgets to be placed
*/
export function recommendedWidgetWidth(numTotalWidgets: number) {
Expand Down
25 changes: 17 additions & 8 deletions lib/monitoring/custom/CustomMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ export interface CustomMetricGroup {
* @see {GraphWidgetProps.setPeriodToTimeRange}
*/
readonly graphWidgetSetPeriodToTimeRange?: boolean;
/**
* Width of graph widget. Note that widgets will overflow into new rows if the summed width
* exceeds 24.
*
* @default - Automatically calculcated width, generally as wide as possible considering all metrics' widgets.
*/
readonly graphWidgetWidth?: number;
/**
* @deprecated use addToSummaryDashboard. addToSummaryDashboard will take precedence over important.
* @see addToSummaryDashboard
Expand Down Expand Up @@ -207,17 +214,20 @@ export interface CustomMetricGroup {
export interface CustomMonitoringProps extends BaseMonitoringProps {
/**
* optional description of the whole section, in markdown
* @default no description
*
* @default - no description
*/
readonly description?: string;
/**
* optional height of the description widget, so the content fits
* @default minimum height (should fit one or two lines of text)
*
* @default - minimum height (should fit one or two lines of text)
*/
readonly descriptionWidgetHeight?: number;
/**
* height override
* @default default height
* Height override.
*
* @default - default height
*/
readonly height?: number;
/**
Expand Down Expand Up @@ -380,9 +390,6 @@ export class CustomMonitoring extends Monitoring {
summary: boolean
) {
const widgets: IWidget[] = [];
const metricGroupWidgetWidth = recommendedWidgetWidth(
annotatedGroups.length
);
const metricGroupWidgetHeightDefault = summary
? DefaultSummaryWidgetHeight
: DefaultGraphWidgetHeight;
Expand Down Expand Up @@ -416,7 +423,9 @@ export class CustomMonitoring extends Monitoring {

const graphWidgetProps: GraphWidgetProps = {
title,
width: metricGroupWidgetWidth,
width:
annotatedGroup.metricGroup.graphWidgetWidth ??
recommendedWidgetWidth(annotatedGroups.length),
height: metricGroupWidgetHeight,
left,
right,
Expand Down
2 changes: 2 additions & 0 deletions test/monitoring/custom/CustomMonitoring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test("snapshot test", () => {
{
title: "DummyGroup1",
addToSummaryDashboard: true,
graphWidgetWidth: 6,
metrics: [
// regular metric
new Metric({ metricName: "DummyMetric1", namespace, dimensionsMap }),
Expand Down Expand Up @@ -75,6 +76,7 @@ test("snapshot test", () => {
{
title: "DummyGroup2",
graphWidgetType: GraphWidgetType.BAR,
graphWidgetWidth: 2,
metrics: [
// regular metric
new Metric({ metricName: "DummyMetric10", namespace, dimensionsMap }),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading