|
|
@@ -5,6 +5,7 @@ import Remarkable from 'remarkable';
|
|
|
// Services & utils
|
|
|
import coreModule from 'app/core/core_module';
|
|
|
import config from 'app/core/config';
|
|
|
+import { Emitter } from 'app/core/utils/emitter';
|
|
|
|
|
|
// Types
|
|
|
import { DashboardModel } from '../dashboard/dashboard_model';
|
|
|
@@ -25,6 +26,7 @@ export class MetricsTabCtrl {
|
|
|
hasQueryHelp: boolean;
|
|
|
helpHtml: string;
|
|
|
queryOptions: any;
|
|
|
+ events: Emitter;
|
|
|
|
|
|
/** @ngInject */
|
|
|
constructor($scope, private $sce, datasourceSrv, private backendSrv) {
|
|
|
@@ -39,6 +41,10 @@ export class MetricsTabCtrl {
|
|
|
this.datasources = datasourceSrv.getMetricSources();
|
|
|
this.panelDsValue = this.panelCtrl.panel.datasource;
|
|
|
|
|
|
+ // addded here as old query controller expects this on panelCtrl but
|
|
|
+ // they are getting MetricsTabCtrl instead
|
|
|
+ this.events = this.panel.events;
|
|
|
+
|
|
|
for (const ds of this.datasources) {
|
|
|
if (ds.value === this.panelDsValue) {
|
|
|
this.datasourceInstance = ds;
|
|
|
@@ -48,7 +54,7 @@ export class MetricsTabCtrl {
|
|
|
this.addQueryDropdown = { text: 'Add Query', value: null, fake: true };
|
|
|
|
|
|
// update next ref id
|
|
|
- this.panelCtrl.nextRefId = this.dashboard.getNextQueryLetter(this.panel);
|
|
|
+ this.nextRefId = this.dashboard.getNextQueryLetter(this.panel);
|
|
|
this.updateDatasourceOptions();
|
|
|
}
|
|
|
|
|
|
@@ -112,10 +118,6 @@ export class MetricsTabCtrl {
|
|
|
this.addQueryDropdown = { text: 'Add Query', value: null, fake: true };
|
|
|
}
|
|
|
|
|
|
- addQuery() {
|
|
|
- this.panelCtrl.addQuery({ isNew: true });
|
|
|
- }
|
|
|
-
|
|
|
toggleHelp() {
|
|
|
this.optionsOpen = false;
|
|
|
this.queryTroubleshooterOpen = false;
|
|
|
@@ -138,6 +140,35 @@ export class MetricsTabCtrl {
|
|
|
this.optionsOpen = false;
|
|
|
this.queryTroubleshooterOpen = !this.queryTroubleshooterOpen;
|
|
|
}
|
|
|
+
|
|
|
+ addQuery(query?) {
|
|
|
+ query = query || {};
|
|
|
+ query.refId = this.dashboard.getNextQueryLetter(this.panel);
|
|
|
+ query.isNew = true;
|
|
|
+
|
|
|
+ this.panel.targets.push(query);
|
|
|
+ this.nextRefId = this.dashboard.getNextQueryLetter(this.panel);
|
|
|
+ }
|
|
|
+
|
|
|
+ refresh() {
|
|
|
+ this.panel.refresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ this.panel.render();
|
|
|
+ }
|
|
|
+
|
|
|
+ removeQuery(target) {
|
|
|
+ const index = _.indexOf(this.panel.targets, target);
|
|
|
+ this.panel.targets.splice(index, 1);
|
|
|
+ this.nextRefId = this.dashboard.getNextQueryLetter(this.panel);
|
|
|
+ this.panel.refresh();
|
|
|
+ }
|
|
|
+
|
|
|
+ moveQuery(target, direction) {
|
|
|
+ const index = _.indexOf(this.panel.targets, target);
|
|
|
+ _.move(this.panel.targets, index, index + direction);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/** @ngInject */
|