Skip to content

Commit

Permalink
Enhance DashboardValueComponent and DashboardTextComponent for improv…
Browse files Browse the repository at this point in the history
…ed layout and error handling; add metric query configuration and adjust title height calculation
  • Loading branch information
simlarsen committed Dec 2, 2024
1 parent 12fc986 commit c7c6a54
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 6 additions & 0 deletions Common/Utils/Dashboard/Components/DashboardValueComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export default class DashboardValueComponentUtil extends DashboardBaseComponentU
minWidthInDashboardUnits: 1,
arguments: {
title: "",
metricQueryConfig: {
metricQueryData: {
filterData: {},
groupBy: undefined,
},
},
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface ComponentProps extends DashboardBaseComponentProps {
const DashboardTextComponentElement: FunctionComponent<ComponentProps> = (
props: ComponentProps,
): ReactElement => {
const textClassName: string = `truncate ${props.component.arguments.isBold ? "font-medium" : ""} ${props.component.arguments.isItalic ? "italic" : ""} ${props.component.arguments.isUnderline ? "underline" : ""}`;
const textClassName: string = `m-auto truncate ${props.component.arguments.isBold ? "font-medium" : ""} ${props.component.arguments.isItalic ? "italic" : ""} ${props.component.arguments.isUnderline ? "underline" : ""}`;
const textHeightInxPx: number = props.dashboardComponentHeightInPx * 0.5;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const DashboardValueComponent: FunctionComponent<ComponentProps> = (
!metricViewData.startAndEndDate?.endValue
) {
setIsLoading(false);
setError("Please select a valid start and end date.");
return;
}

Expand All @@ -60,7 +59,6 @@ const DashboardValueComponent: FunctionComponent<ComponentProps> = (
.length === 0
) {
setIsLoading(false);
setError("Please select a metric. Click here to add a metric.");
return;
}

Expand All @@ -71,9 +69,6 @@ const DashboardValueComponent: FunctionComponent<ComponentProps> = (
?.aggegationType
) {
setIsLoading(false);
setError(
"Please select an Aggregation Type. Click here to add a Aggregation Type.",
);
return;
}
setAggregationType(
Expand Down Expand Up @@ -149,25 +144,25 @@ const DashboardValueComponent: FunctionComponent<ComponentProps> = (
}

const valueHeightInPx: number = props.dashboardComponentHeightInPx * 0.4;
const titleHeightInPx: number = props.dashboardComponentHeightInPx * 0.1;
const titleHeightInPx: number = props.dashboardComponentHeightInPx * 0.13;

return (
<div className="w-full text-center">
<div className="w-full text-center h-full m-auto">
<div
style={{
fontSize: titleHeightInPx > 0 ? `${titleHeightInPx}px` : "",
}}
className="text-center text-sm text-semibold"
className="text-center text-bold mb-1 truncate"
>
{props.component.arguments.title || ""}
{props.component.arguments.title || " "}
</div>
<div
className="text-center text-lg text-semibold"
className="text-center text-semibold truncate"
style={{
fontSize: valueHeightInPx > 0 ? `${valueHeightInPx}px` : "",
}}
>
{aggregatedValue || "-"}
{aggregatedValue || "0"}
</div>
</div>
);
Expand Down

0 comments on commit c7c6a54

Please sign in to comment.