diff --git a/App/FeatureSet/Dashboard/src/Components/Dashboard/Components/DashboardChartComponent.tsx b/App/FeatureSet/Dashboard/src/Components/Dashboard/Components/DashboardChartComponent.tsx index 7854fb2e41..28c613a0bf 100644 --- a/App/FeatureSet/Dashboard/src/Components/Dashboard/Components/DashboardChartComponent.tsx +++ b/App/FeatureSet/Dashboard/src/Components/Dashboard/Components/DashboardChartComponent.tsx @@ -182,9 +182,9 @@ const DashboardChartComponentElement: FunctionComponent = ( const numberOfCharts: number = queryConfigs.length || 1; // Account for widget-level header and per-chart overhead (title + legend + padding) - const hasWidgetHeader: boolean = !!( + const hasWidgetHeader: boolean = Boolean( props.component.arguments.chartTitle || - props.component.arguments.chartDescription + props.component.arguments.chartDescription, ); const widgetHeaderHeight: number = hasWidgetHeader ? 50 : 0; // Each chart section: pt-5(20) + title(20) + legend(24) + pb-4(16) = ~80px overhead @@ -215,22 +215,19 @@ const DashboardChartComponentElement: FunctionComponent = ( }; const chartMetricViewData: MetricViewData = { - queryConfigs: queryConfigs.map( - (config: MetricQueryConfigData) => { - return { - ...config, - metricAliasData: { - metricVariable: - config.metricAliasData?.metricVariable || undefined, - title: config.metricAliasData?.title || undefined, - description: config.metricAliasData?.description || undefined, - legend: config.metricAliasData?.legend || undefined, - legendUnit: config.metricAliasData?.legendUnit || undefined, - }, - chartType: config.chartType || getMetricChartType(), - }; - }, - ), + queryConfigs: queryConfigs.map((config: MetricQueryConfigData) => { + return { + ...config, + metricAliasData: { + metricVariable: config.metricAliasData?.metricVariable || undefined, + title: config.metricAliasData?.title || undefined, + description: config.metricAliasData?.description || undefined, + legend: config.metricAliasData?.legend || undefined, + legendUnit: config.metricAliasData?.legendUnit || undefined, + }, + chartType: config.chartType || getMetricChartType(), + }; + }), startAndEndDate: RangeStartAndEndDateTimeUtil.getStartAndEndDate( props.dashboardStartAndEndDate, ), diff --git a/App/FeatureSet/Dashboard/src/Components/Dashboard/DashboardTemplateCard.tsx b/App/FeatureSet/Dashboard/src/Components/Dashboard/DashboardTemplateCard.tsx index 887d0772ab..cfc11a6b2f 100644 --- a/App/FeatureSet/Dashboard/src/Components/Dashboard/DashboardTemplateCard.tsx +++ b/App/FeatureSet/Dashboard/src/Components/Dashboard/DashboardTemplateCard.tsx @@ -25,9 +25,15 @@ const DashboardTemplateCard: FunctionComponent = ( }} >
- +
-

{props.title}

+

+ {props.title} +

{props.description}

diff --git a/App/FeatureSet/Dashboard/src/Components/Metrics/MetricCharts.tsx b/App/FeatureSet/Dashboard/src/Components/Metrics/MetricCharts.tsx index 9a5ce5f175..194487bddb 100644 --- a/App/FeatureSet/Dashboard/src/Components/Metrics/MetricCharts.tsx +++ b/App/FeatureSet/Dashboard/src/Components/Metrics/MetricCharts.tsx @@ -70,8 +70,7 @@ const MetricCharts: FunctionComponent = ( continue; } - let xAxisAggregationType: XAxisAggregateType = - XAxisAggregateType.Average; + let xAxisAggregationType: XAxisAggregateType = XAxisAggregateType.Average; if ( queryConfig.metricQueryData.filterData.aggegationType === @@ -171,9 +170,7 @@ const MetricCharts: FunctionComponent = ( // Resolve the unit for formatting const metricType: MetricType | undefined = props.metricTypes.find( (m: MetricType) => { - return ( - m.name === queryConfig.metricQueryData.filterData.metricName - ); + return m.name === queryConfig.metricQueryData.filterData.metricName; }, ); const unit: string = diff --git a/App/FeatureSet/Dashboard/src/Components/Metrics/MetricQueryConfig.tsx b/App/FeatureSet/Dashboard/src/Components/Metrics/MetricQueryConfig.tsx index aecd24e14d..104670dca1 100644 --- a/App/FeatureSet/Dashboard/src/Components/Metrics/MetricQueryConfig.tsx +++ b/App/FeatureSet/Dashboard/src/Components/Metrics/MetricQueryConfig.tsx @@ -63,9 +63,7 @@ const MetricGraphConfig: FunctionComponent = ( "Avg"; // Remove a single attribute filter - const handleRemoveAttribute: (key: string) => void = ( - key: string, - ): void => { + const handleRemoveAttribute: (key: string) => void = (key: string): void => { if (!attributes) { return; } @@ -187,51 +185,52 @@ const MetricGraphConfig: FunctionComponent = ( ); }; - const getAttributeChips: () => ReactElement | null = (): ReactElement | null => { - if (!attributes || activeAttributeCount === 0) { - return null; - } + const getAttributeChips: () => ReactElement | null = + (): ReactElement | null => { + if (!attributes || activeAttributeCount === 0) { + return null; + } - return ( -
- - Filtered by: - - {Object.entries(attributes).map( - ([key, value]: [string, string | number | boolean]) => { - return ( - - {key}: - {String(value)} - - - ); - }, - )} - {activeAttributeCount > 1 && ( - - )} -
- ); - }; + {key}: + {String(value)} + + + ); + }, + )} + {activeAttributeCount > 1 && ( + + )} + + ); + }; const getContent: () => ReactElement = (): ReactElement => { return ( @@ -352,9 +351,7 @@ const MetricGraphConfig: FunctionComponent = ( Warning Threshold { props.onBlur?.(); @@ -376,9 +373,7 @@ const MetricGraphConfig: FunctionComponent = ( Critical Threshold { props.onBlur?.(); diff --git a/App/FeatureSet/Dashboard/src/Components/Metrics/MetricView.tsx b/App/FeatureSet/Dashboard/src/Components/Metrics/MetricView.tsx index c7c22bbf6b..9aebdfa7f2 100644 --- a/App/FeatureSet/Dashboard/src/Components/Metrics/MetricView.tsx +++ b/App/FeatureSet/Dashboard/src/Components/Metrics/MetricView.tsx @@ -108,9 +108,9 @@ const MetricView: FunctionComponent = ( const [isPageLoading, setIsPageLoading] = useState(false); const [pageError, setPageError] = useState(""); - const [telemetryAttributes, setTelemetryAttributes] = useState< - Array - >([]); + const [telemetryAttributes, setTelemetryAttributes] = useState>( + [], + ); const [telemetryAttributesLoaded, setTelemetryAttributesLoaded] = useState(false); const [telemetryAttributesLoading, setTelemetryAttributesLoading] = @@ -456,9 +456,7 @@ const MetricView: FunctionComponent = ( {!isMetricResultsLoading && !metricResultsError && (
= (): ReactElement => { }, ]} > - {showTemplateModal && ( + {showTemplateModal ? ( = (): ReactElement => { )}
+ ) : ( + <> )} @@ -138,8 +140,14 @@ const Dashboards: FunctionComponent = (): ReactElement => { placeholder: "Description", }, ]} - onBeforeCreate={async (item: Dashboard, _miscDataProps: JSONObject): Promise => { - if (selectedTemplate && selectedTemplate !== DashboardTemplateType.Blank) { + onBeforeCreate={async ( + item: Dashboard, + _miscDataProps: JSONObject, + ): Promise => { + if ( + selectedTemplate && + selectedTemplate !== DashboardTemplateType.Blank + ) { const templateConfig: DashboardViewConfig | null = getTemplateConfig(selectedTemplate); if (templateConfig) { diff --git a/App/FeatureSet/PublicDashboard/src/Pages/DashboardView/DashboardVariableSelector.tsx b/App/FeatureSet/PublicDashboard/src/Pages/DashboardView/DashboardVariableSelector.tsx index f5b5a3753a..ef400fd4ae 100644 --- a/App/FeatureSet/PublicDashboard/src/Pages/DashboardView/DashboardVariableSelector.tsx +++ b/App/FeatureSet/PublicDashboard/src/Pages/DashboardView/DashboardVariableSelector.tsx @@ -17,18 +17,19 @@ const DashboardVariableSelector: FunctionComponent = ( - {variable.options && variable.options.length > 0 ? ( + {variable.customListValues ? ( ) => { - props.onVariableValueChange(variable.id!, e.target.value); + props.onVariableValueChange(variable.id, e.target.value); }} /> )} diff --git a/App/FeatureSet/PublicDashboard/src/Pages/DashboardView/DashboardViewPage.tsx b/App/FeatureSet/PublicDashboard/src/Pages/DashboardView/DashboardViewPage.tsx index 851279b41c..27561c83da 100644 --- a/App/FeatureSet/PublicDashboard/src/Pages/DashboardView/DashboardViewPage.tsx +++ b/App/FeatureSet/PublicDashboard/src/Pages/DashboardView/DashboardViewPage.tsx @@ -7,7 +7,6 @@ import React, { useState, } from "react"; import DashboardCanvas from "../../Components/DashboardCanvas"; -import DashboardMode from "Common/Types/Dashboard/DashboardMode"; import DashboardViewConfig, { AutoRefreshInterval, getAutoRefreshIntervalInMs, @@ -370,19 +369,21 @@ const DashboardViewPage: FunctionComponent = ( onDashboardViewConfigChange={(_config: DashboardViewConfig) => { // Read-only in public view }} - dashboardMode={DashboardMode.View} + isEditMode={false} selectedComponentId={null} - onComponentSelected={(_id: ObjectID | null) => { + onComponentSelected={(_id: ObjectID) => { // No selection in public view }} - dashboardTotalWidth={dashboardTotalWidth} - startAndEndDate={startAndEndDate} - onStartAndEndDateChange={(newRange: RangeStartAndEndDateTime) => { - setTimeRangeStack([...timeRangeStack, startAndEndDate]); - setStartAndEndDate(newRange); + onComponentUnselected={() => { + // No unselection in public view + }} + currentTotalDashboardWidthInPx={dashboardTotalWidth} + dashboardStartAndEndDate={startAndEndDate} + metrics={{ + metricTypes: [], + telemetryAttributes: [], }} refreshTick={refreshTick} - dashboardVariables={dashboardVariables} /> diff --git a/Common/Types/Dashboard/DashboardTemplates.ts b/Common/Types/Dashboard/DashboardTemplates.ts index 47e2f8fdce..c47350529c 100644 --- a/Common/Types/Dashboard/DashboardTemplates.ts +++ b/Common/Types/Dashboard/DashboardTemplates.ts @@ -63,7 +63,7 @@ interface MetricConfig { legendUnit?: string; } -function buildMetricQueryConfig(config: MetricConfig): object { +function buildMetricQueryConfig(config: MetricConfig): Record { return { metricAliasData: { metricVariable: "a", @@ -82,7 +82,7 @@ function buildMetricQueryConfig(config: MetricConfig): object { }; } -function buildMetricQueryData(config: MetricConfig): object { +function buildMetricQueryData(config: MetricConfig): Record { return { metricQueryData: { filterData: { @@ -497,10 +497,7 @@ function createMonitorDashboardConfig(): DashboardViewConfig { return { _type: ObjectType.DashboardViewConfig, components, - heightInDashboardUnits: Math.max( - DashboardSize.heightInDashboardUnits, - 13, - ), + heightInDashboardUnits: Math.max(DashboardSize.heightInDashboardUnits, 13), }; } @@ -739,10 +736,7 @@ function createIncidentDashboardConfig(): DashboardViewConfig { return { _type: ObjectType.DashboardViewConfig, components, - heightInDashboardUnits: Math.max( - DashboardSize.heightInDashboardUnits, - 20, - ), + heightInDashboardUnits: Math.max(DashboardSize.heightInDashboardUnits, 20), }; } @@ -950,10 +944,7 @@ function createKubernetesDashboardConfig(): DashboardViewConfig { return { _type: ObjectType.DashboardViewConfig, components, - heightInDashboardUnits: Math.max( - DashboardSize.heightInDashboardUnits, - 16, - ), + heightInDashboardUnits: Math.max(DashboardSize.heightInDashboardUnits, 16), }; } diff --git a/Common/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx b/Common/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx index 193590713a..dac4aa412c 100644 --- a/Common/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +++ b/Common/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx @@ -978,10 +978,7 @@ const AreaChart: React.ForwardRefExoticComponent< ); })} {props.referenceLines?.map( - ( - refLine: ChartReferenceLineProps, - refIndex: number, - ) => { + (refLine: ChartReferenceLineProps, refIndex: number) => { return ( { + (refLine: ChartReferenceLineProps, refIndex: number) => { return ( { + (refLine: ChartReferenceLineProps, refIndex: number) => { return ( = ({ strokeLinejoin="round" d="M5.636 7.636l1.414 1.414" /> - +