GaugeMigrations.ts 996 B

123456789101112131415161718192021222324252627
  1. import { PanelModel, sharedSingleStatPanelChangedHandler, sharedSingleStatMigrationHandler } from '@grafana/ui';
  2. import { GaugeOptions } from './types';
  3. // This is called when the panel first loads
  4. export const gaugePanelMigrationHandler = (panel: PanelModel<GaugeOptions>): Partial<GaugeOptions> => {
  5. return sharedSingleStatMigrationHandler(panel);
  6. };
  7. // This is called when the panel changes from another panel
  8. export const gaugePanelChangedHandler = (
  9. options: Partial<GaugeOptions> | any,
  10. prevPluginId: string,
  11. prevOptions: any
  12. ) => {
  13. // This handles most config changes
  14. const opts = sharedSingleStatPanelChangedHandler(options, prevPluginId, prevOptions) as GaugeOptions;
  15. // Changing from angular singlestat
  16. if (prevPluginId === 'singlestat' && prevOptions.angular) {
  17. const gauge = prevOptions.angular.gauge;
  18. if (gauge) {
  19. opts.showThresholdMarkers = gauge.thresholdMarkers;
  20. opts.showThresholdLabels = gauge.thresholdLabels;
  21. }
  22. }
  23. return opts;
  24. };