mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix for annotation promise clearing, bug introduced last week when merging react panels step1
This commit is contained in:
@@ -1,25 +1,32 @@
|
|||||||
import './editor_ctrl';
|
// Libaries
|
||||||
|
|
||||||
import angular from 'angular';
|
import angular from 'angular';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
// Components
|
||||||
|
import './editor_ctrl';
|
||||||
import coreModule from 'app/core/core_module';
|
import coreModule from 'app/core/core_module';
|
||||||
|
|
||||||
|
// Utils & Services
|
||||||
import { makeRegions, dedupAnnotations } from './events_processing';
|
import { makeRegions, dedupAnnotations } from './events_processing';
|
||||||
|
|
||||||
|
// Types
|
||||||
|
import { DashboardModel } from '../dashboard/dashboard_model';
|
||||||
|
|
||||||
export class AnnotationsSrv {
|
export class AnnotationsSrv {
|
||||||
globalAnnotationsPromise: any;
|
globalAnnotationsPromise: any;
|
||||||
alertStatesPromise: any;
|
alertStatesPromise: any;
|
||||||
datasourcePromises: any;
|
datasourcePromises: any;
|
||||||
|
|
||||||
/** @ngInject */
|
/** @ngInject */
|
||||||
constructor(private $rootScope, private $q, private datasourceSrv, private backendSrv, private timeSrv) {
|
constructor(private $rootScope, private $q, private datasourceSrv, private backendSrv, private timeSrv) {}
|
||||||
$rootScope.onAppEvent('refresh', this.clearCache.bind(this), $rootScope);
|
|
||||||
$rootScope.onAppEvent('dashboard-initialized', this.clearCache.bind(this), $rootScope);
|
|
||||||
}
|
|
||||||
|
|
||||||
clearCache() {
|
init(dashboard: DashboardModel) {
|
||||||
this.globalAnnotationsPromise = null;
|
// clear promises on refresh events
|
||||||
this.alertStatesPromise = null;
|
dashboard.on('refresh', () => {
|
||||||
this.datasourcePromises = null;
|
this.globalAnnotationsPromise = null;
|
||||||
|
this.alertStatesPromise = null;
|
||||||
|
this.datasourcePromises = null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getAnnotations(options) {
|
getAnnotations(options) {
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
|
// Utils
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
|
import appEvents from 'app/core/app_events';
|
||||||
import coreModule from 'app/core/core_module';
|
import coreModule from 'app/core/core_module';
|
||||||
|
|
||||||
|
// Services
|
||||||
|
import { AnnotationsSrv } from '../annotations/annotations_srv';
|
||||||
|
|
||||||
|
// Types
|
||||||
import { DashboardModel } from './dashboard_model';
|
import { DashboardModel } from './dashboard_model';
|
||||||
import { PanelModel } from './panel_model';
|
import { PanelModel } from './panel_model';
|
||||||
|
|
||||||
@@ -21,6 +27,7 @@ export class DashboardCtrl {
|
|||||||
private dashboardSrv,
|
private dashboardSrv,
|
||||||
private unsavedChangesSrv,
|
private unsavedChangesSrv,
|
||||||
private dashboardViewStateSrv,
|
private dashboardViewStateSrv,
|
||||||
|
private annotationsSrv: AnnotationsSrv,
|
||||||
public playlistSrv
|
public playlistSrv
|
||||||
) {
|
) {
|
||||||
// temp hack due to way dashboards are loaded
|
// temp hack due to way dashboards are loaded
|
||||||
@@ -49,6 +56,7 @@ export class DashboardCtrl {
|
|||||||
// init services
|
// init services
|
||||||
this.timeSrv.init(dashboard);
|
this.timeSrv.init(dashboard);
|
||||||
this.alertingSrv.init(dashboard, data.alerts);
|
this.alertingSrv.init(dashboard, data.alerts);
|
||||||
|
this.annotationsSrv.init(dashboard);
|
||||||
|
|
||||||
// template values service needs to initialize completely before
|
// template values service needs to initialize completely before
|
||||||
// the rest of the dashboard can load
|
// the rest of the dashboard can load
|
||||||
@@ -72,7 +80,7 @@ export class DashboardCtrl {
|
|||||||
this.keybindingSrv.setupDashboardBindings(this.$scope, dashboard);
|
this.keybindingSrv.setupDashboardBindings(this.$scope, dashboard);
|
||||||
this.setWindowTitleAndTheme();
|
this.setWindowTitleAndTheme();
|
||||||
|
|
||||||
this.$scope.appEvent('dashboard-initialized', dashboard);
|
appEvents.emit('dashboard-initialized', dashboard);
|
||||||
})
|
})
|
||||||
.catch(this.onInitFailed.bind(this, 'Dashboard init failed', true));
|
.catch(this.onInitFailed.bind(this, 'Dashboard init failed', true));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export class SoloPanelCtrl {
|
|||||||
const params = $location.search();
|
const params = $location.search();
|
||||||
panelId = parseInt(params.panelId, 10);
|
panelId = parseInt(params.panelId, 10);
|
||||||
|
|
||||||
$scope.onAppEvent('dashboard-initialized', $scope.initPanelScope);
|
appEvents.on('dashboard-initialized', $scope.initPanelScope);
|
||||||
|
|
||||||
// if no uid, redirect to new route based on slug
|
// if no uid, redirect to new route based on slug
|
||||||
if (!($routeParams.type === 'script' || $routeParams.type === 'snapshot') && !$routeParams.uid) {
|
if (!($routeParams.type === 'script' || $routeParams.type === 'snapshot') && !$routeParams.uid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user