diff --git a/src/components/Panel.tsx b/src/components/Panel.tsx index 9a1eb2d..36d538b 100644 --- a/src/components/Panel.tsx +++ b/src/components/Panel.tsx @@ -24,7 +24,6 @@ export function Panel({ options, data, width, height, timeRange, onChangeTimeRan const podContainerRef = useRef(null); const podContainer = useMemo(() => { - const chartClickHandler = (event: React.MouseEvent) => { event.preventDefault(); if (options.gauge.link === undefined || options.gauge.link === '') { @@ -39,10 +38,7 @@ export function Panel({ options, data, width, height, timeRange, onChangeTimeRan if (options.visualizationType === Pod.BAR) { containerHeight = height - 20; } - if ( - options.visualizationType === Pod.GAUGE && - options.gauge.additionalInfo.display - ) { + if (options.visualizationType === Pod.GAUGE && options.gauge.additionalInfo.display) { containerHeight = height - options.gauge.additionalInfo.size - 8; } @@ -97,19 +93,21 @@ export function Panel({ options, data, width, height, timeRange, onChangeTimeRan } } - additionalInfo =
- {additionalInfoConfig.prefix} {value !== undefined ? formatValue(value, additionalInfoConfig) : '-'} -
+ additionalInfo = ( +
+ {additionalInfoConfig.prefix} {value !== undefined ? formatValue(value, additionalInfoConfig) : '-'} +
+ ); } return (
diff --git a/src/models/options/gaugeOptions.ts b/src/models/options/gaugeOptions.ts index 9b7ccd4..0049b38 100644 --- a/src/models/options/gaugeOptions.ts +++ b/src/models/options/gaugeOptions.ts @@ -92,7 +92,11 @@ export class GaugeOptions { // check each condition and return false if something goes wrong for (let [conditionIdx, metric] of icon.metrics.entries()) { - const value = getLastMetricValue(this.grafanaSeriesList, metric, `Icon ${iconIdx + 1}, Condition ${conditionIdx + 1}`); + const value = getLastMetricValue( + this.grafanaSeriesList, + metric, + `Icon ${iconIdx + 1}, Condition ${conditionIdx + 1}` + ); if (value === null || value === undefined) { // TODO: may be throw an error return false; diff --git a/src/types.ts b/src/types.ts index bdd344b..4ca1d01 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,7 +23,7 @@ export interface PanelOptions { prefix: string; unit: string; decimals: number; - } + }; }; } diff --git a/src/utils.ts b/src/utils.ts index f4d63ef..be25040 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,7 +7,7 @@ import TimeSeries from 'grafana/app/core/time_series2'; import * as _ from 'lodash'; -export function formatValue(value: number, options: { unit?: string, decimals?: number }): string { +export function formatValue(value: number, options: { unit?: string; decimals?: number }): string { const suffix = getValueFormat(options.unit)(0)?.suffix || ''; const decimals = _.isNumber(options.decimals) ? options.decimals : 2; return `${value.toFixed(decimals)} ${suffix}`; @@ -24,7 +24,7 @@ export function getGrafanaSeriesList(grafanaData: PanelData, timeRange: TimeRang export function getLastMetricValue( grafanaSeriesList: TimeSeries[], metricName: string | undefined, - optionName: string, + optionName: string ): number | null { // optionName -> helper in Error, mb use option path instead const filteredSeries = filterMetricListByAlias(grafanaSeriesList, metricName, optionName); @@ -34,7 +34,7 @@ export function getLastMetricValue( } export function filterMetricListByAlias(list: any[], alias: string | undefined, option: string): any[] { - console.log(list) + console.log(list); const filteredSeries = _.filter(list, (serie) => serie.alias === alias); if (filteredSeries.length === 0) { throw new Error(`${option}: Can't find metric for ${alias} name.`);