Skip to content

Commit

Permalink
feat(plugins): migrating graphite query editor to new model
Browse files Browse the repository at this point in the history
  • Loading branch information
torkelo committed Feb 2, 2016
1 parent efdd4a6 commit 822c8f1
Show file tree
Hide file tree
Showing 29 changed files with 1,946 additions and 2,035 deletions.
2 changes: 1 addition & 1 deletion public/app/core/directives/plugin_component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function pluginDirectiveLoader($compile, datasourceSrv) {
name: 'metrics-query-editor-' + ds.meta.id,
bindings: {target: "=", panelCtrl: "=", datasource: "="},
attrs: {"target": "target", "panel-ctrl": "ctrl", datasource: "datasource"},
Component: dsModule.MetricsQueryEditor
Component: dsModule.QueryCtrl
};
});
});
Expand Down
10 changes: 10 additions & 0 deletions public/app/features/dashboard/dashboardSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ function (angular, $, _, moment) {
moment.utc(date).fromNow();
};

p.getNextQueryLetter = function(panel) {
var letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

return _.find(letters, function(refId) {
return _.every(panel.targets, function(other) {
return other.refId !== refId;
});
});
};

p._updateSchema = function(old) {
var i, j, k;
var oldVersion = this.schemaVersion;
Expand Down
2 changes: 1 addition & 1 deletion public/app/features/panel/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ define([
'./panel_directive',
'./solo_panel_ctrl',
'./panel_loader',
'./query_editor',
'./query_ctrl',
'./panel_editor_tab',
], function () {});
4 changes: 2 additions & 2 deletions public/app/features/panel/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import config from 'app/core/config';
import {PanelCtrl} from './panel_ctrl';
import {MetricsPanelCtrl} from './metrics_panel_ctrl';
import {PanelDirective} from './panel_directive';
import {QueryEditorCtrl} from './query_editor';
import {QueryCtrl} from './query_ctrl';

export {
PanelCtrl,
MetricsPanelCtrl,
PanelDirective,
QueryEditorCtrl,
QueryCtrl,
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import angular from 'angular';
import _ from 'lodash';

export class QueryEditorCtrl {
export class QueryCtrl {
target: any;
datasource: any;
panelCtrl: any;
Expand All @@ -27,22 +27,26 @@ export class QueryEditorCtrl {
});
}

removeDataQuery(query) {
this.panel.targets = _.without(this.panel.targets, query);
removeQuery() {
this.panel.targets = _.without(this.panel.targets, this.target);
this.panelCtrl.refresh();
};

duplicateDataQuery(query) {
var clone = angular.copy(query);
duplicateQuery() {
var clone = angular.copy(this.target);
clone.refId = this.getNextQueryLetter();
this.panel.targets.push(clone);
}

moveDataQuery(direction) {
moveQuery(direction) {
var index = _.indexOf(this.panel.targets, this.target);
_.move(this.panel.targets, index, index + direction);
}

refresh() {
this.panelCtrl.refresh();
}

toggleHideQuery() {
this.target.hide = !this.target.hide;
this.panelCtrl.refresh();
Expand Down
3 changes: 0 additions & 3 deletions public/app/plugins/datasource/graphite/datasource.d.ts

This file was deleted.

296 changes: 0 additions & 296 deletions public/app/plugins/datasource/graphite/datasource.js

This file was deleted.

Loading

0 comments on commit 822c8f1

Please sign in to comment.