2019-10-31 04:48:05 -05:00
|
|
|
import { sharedSingleStatPanelChangedHandler, sharedSingleStatMigrationHandler } from '@grafana/ui';
|
|
|
|
import { PanelModel } from '@grafana/data';
|
2019-05-04 03:08:48 -05:00
|
|
|
import { GaugeOptions } from './types';
|
|
|
|
|
2019-08-18 17:01:07 -05:00
|
|
|
// This is called when the panel first loads
|
|
|
|
export const gaugePanelMigrationHandler = (panel: PanelModel<GaugeOptions>): Partial<GaugeOptions> => {
|
|
|
|
return sharedSingleStatMigrationHandler(panel);
|
|
|
|
};
|
|
|
|
|
|
|
|
// This is called when the panel changes from another panel
|
|
|
|
export const gaugePanelChangedHandler = (
|
2020-03-13 02:27:16 -05:00
|
|
|
panel: PanelModel<Partial<GaugeOptions>> | any,
|
2019-08-18 17:01:07 -05:00
|
|
|
prevPluginId: string,
|
|
|
|
prevOptions: any
|
|
|
|
) => {
|
|
|
|
// This handles most config changes
|
2020-03-13 02:27:16 -05:00
|
|
|
const opts = sharedSingleStatPanelChangedHandler(panel, prevPluginId, prevOptions) as GaugeOptions;
|
2019-08-18 17:01:07 -05:00
|
|
|
|
|
|
|
// Changing from angular singlestat
|
|
|
|
if (prevPluginId === 'singlestat' && prevOptions.angular) {
|
|
|
|
const gauge = prevOptions.angular.gauge;
|
|
|
|
if (gauge) {
|
|
|
|
opts.showThresholdMarkers = gauge.thresholdMarkers;
|
|
|
|
opts.showThresholdLabels = gauge.thresholdLabels;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return opts;
|
2019-05-04 03:08:48 -05:00
|
|
|
};
|