began work on filtering overhaul
This commit is contained in:
@@ -1,14 +1,6 @@
|
||||
<div ng-controller='filtering' ng-init="init()">
|
||||
|
||||
<div class='filtering-container'>
|
||||
|
||||
<div ng-repeat="filter in filter.templateParameters" class="small filter-panel-filter">
|
||||
<div>
|
||||
<i class="filter-action pointer icon-remove" bs-tooltip="'Remove'" ng-click="remove(filter)"></i>
|
||||
<i class="filter-action pointer icon-edit" ng-hide="filter.editing" bs-tooltip="'Edit'" ng-click="filter.editing = true"></i>
|
||||
</div>
|
||||
|
||||
<div ng-hide="filter.editing" style="margin-right: 45px;">
|
||||
<ul class="unstyled">
|
||||
<li ng-if="filter.name" class="dropdown">
|
||||
{{filter.name}} :
|
||||
@@ -22,29 +14,35 @@
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="submenu-control-edit">
|
||||
<i class="icon-cog pointer" config-modal="app/panels/filtering/editor.html" bs-tooltip="'Edit'" ></i>
|
||||
</div>
|
||||
|
||||
<form ng-show="filter.editing">
|
||||
<ul class="unstyled">
|
||||
<li>
|
||||
<strong>name</strong>:<br/>
|
||||
<input type='text' ng-model="filter.name">
|
||||
</li>
|
||||
<li>
|
||||
<strong>filter.query</strong>:<br/>
|
||||
<input type='text' ng-model="filter.query">
|
||||
</li>
|
||||
<li>
|
||||
<label for="includeAll">Include all:</label>
|
||||
<input id="includeAll" type='checkbox' ng-model="filter.includeAll">
|
||||
</li>
|
||||
</ul>
|
||||
<div>
|
||||
<input type="submit" value="Update" ng-click="applyFilter(filter)" class="filter-apply btn btn-success btn-mini" bs-tooltip="'Update and refresh'"/>
|
||||
<button ng-click="filter.editing=undefined" class="filter-apply btn btn-mini" bs-tooltip="'Save without refresh'">Close</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<i class="pointer icon-plus-sign add-filter-action" ng-click="add()" bs-tooltip="'Add metric filter / param'" data-placement="right"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <form ng-show="filter.editing"> -->
|
||||
<!-- <ul class="unstyled"> -->
|
||||
<!-- <li> -->
|
||||
<!-- <strong>name</strong>:<br/> -->
|
||||
<!-- <input type='text' ng-model="filter.name"> -->
|
||||
<!-- </li> -->
|
||||
<!-- <li> -->
|
||||
<!-- <strong>filter.query</strong>:<br/> -->
|
||||
<!-- <input type='text' ng-model="filter.query"> -->
|
||||
<!-- </li> -->
|
||||
<!-- <li> -->
|
||||
<!-- <label for="includeAll">Include all:</label> -->
|
||||
<!-- <input id="includeAll" type='checkbox' ng-model="filter.includeAll"> -->
|
||||
<!-- </li> -->
|
||||
<!-- </ul> -->
|
||||
<!-- <div> -->
|
||||
<!-- <input type="submit" value="Update" ng-click="applyFilter(filter)" class="filter-apply btn btn-success btn-mini" bs-tooltip="'Update and refresh'"/> -->
|
||||
<!-- <button ng-click="filter.editing=undefined" class="filter-apply btn btn-mini" bs-tooltip="'Save without refresh'">Close</button> -->
|
||||
<!-- </div> -->
|
||||
<!-- </form> -->
|
||||
<!-- </div> -->
|
||||
<!-- <i class="pointer icon-plus-sign add-filter-action" ng-click="add()" bs-tooltip="'Add metric filter / param'" data-placement="right"></i> -->
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,6 @@ define([
|
||||
|
||||
module.service('annotationsSrv', function(datasourceSrv, $q, alertSrv, $rootScope) {
|
||||
var promiseCached;
|
||||
var annotationPanel;
|
||||
var list = [];
|
||||
var timezone;
|
||||
|
||||
@@ -23,8 +22,7 @@ define([
|
||||
};
|
||||
|
||||
this.getAnnotations = function(filterSrv, rangeUnparsed, dashboard) {
|
||||
annotationPanel = _.findWhere(dashboard.pulldowns, { type: 'annotations' });
|
||||
if (!annotationPanel.enable) {
|
||||
if (!dashboard.annotations.enable) {
|
||||
return $q.when(null);
|
||||
}
|
||||
|
||||
@@ -33,7 +31,7 @@ define([
|
||||
}
|
||||
|
||||
timezone = dashboard.timezone;
|
||||
var annotations = _.where(annotationPanel.annotations, { enable: true });
|
||||
var annotations = _.where(dashboard.annotations.list, { enable: true });
|
||||
|
||||
var promises = _.map(annotations, function(annotation) {
|
||||
var datasource = datasourceSrv.get(annotation.datasource);
|
||||
|
||||
@@ -27,10 +27,10 @@ function (angular, $, kbn, _, moment) {
|
||||
this.timezone = data.timezone || 'browser';
|
||||
this.editable = data.editble || true;
|
||||
this.rows = data.rows || [];
|
||||
this.pulldowns = data.pulldowns || [];
|
||||
this.nav = data.nav || [];
|
||||
this.time = data.time || { from: 'now-6h', to: 'now' };
|
||||
this.templating = data.templating || { list: [] };
|
||||
this.templating = data.templating || { list: [], enable: false };
|
||||
this.annotations = data.annotations || { list: [], enable: false};
|
||||
this.refresh = data.refresh;
|
||||
this.version = data.version || 0;
|
||||
|
||||
@@ -38,14 +38,6 @@ function (angular, $, kbn, _, moment) {
|
||||
this.nav.push({ type: 'timepicker' });
|
||||
}
|
||||
|
||||
if (!_.findWhere(this.pulldowns, {type: 'filtering'})) {
|
||||
this.pulldowns.push({ type: 'filtering', enable: false });
|
||||
}
|
||||
|
||||
if (!_.findWhere(this.pulldowns, {type: 'annotations'})) {
|
||||
this.pulldowns.push({ type: 'annotations', enable: false });
|
||||
}
|
||||
|
||||
this.updateSchema(data);
|
||||
}
|
||||
|
||||
@@ -147,9 +139,9 @@ function (angular, $, kbn, _, moment) {
|
||||
p.updateSchema = function(old) {
|
||||
var oldVersion = this.version;
|
||||
var panelUpgrades = [];
|
||||
this.version = 4;
|
||||
this.version = 5;
|
||||
|
||||
if (oldVersion === 4) {
|
||||
if (oldVersion === 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -224,6 +216,21 @@ function (angular, $, kbn, _, moment) {
|
||||
});
|
||||
}
|
||||
|
||||
if (oldVersion < 5) {
|
||||
// move pulldowns to new schema
|
||||
var filtering = _.findWhere(old.pulldowns, { type: 'filtering' });
|
||||
var annotations = _.findWhere(old.pulldowns, { type: 'annotations' });
|
||||
if (filtering) {
|
||||
this.templating.enable = filtering.enable;
|
||||
}
|
||||
if (annotations) {
|
||||
this.annotations = {
|
||||
list: annotations.annotations,
|
||||
enable: annotations.enable
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (panelUpgrades.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ define([
|
||||
it('should have default properties', function() {
|
||||
expect(model.rows.length).to.be(0);
|
||||
expect(model.nav.length).to.be(1);
|
||||
expect(model.pulldowns.length).to.be(2);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -91,6 +90,17 @@ define([
|
||||
beforeEach(inject(function(dashboardSrv) {
|
||||
model = dashboardSrv.create({
|
||||
services: { filter: { time: { from: 'now-1d', to: 'now'}, list: [1] }},
|
||||
pulldowns: [
|
||||
{
|
||||
type: 'filtering',
|
||||
enable: true
|
||||
},
|
||||
{
|
||||
type: 'annotations',
|
||||
enable: true,
|
||||
annotations: [{name: 'old'}]
|
||||
}
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
panels: [
|
||||
@@ -140,8 +150,15 @@ define([
|
||||
expect(graph.seriesOverrides[0].yaxis).to.be(2);
|
||||
});
|
||||
|
||||
it('should move pulldowns to new schema', function() {
|
||||
expect(model.templating.enable).to.be(true);
|
||||
expect(model.annotations.enable).to.be(true);
|
||||
expect(model.annotations.list[0].name).to.be('old');
|
||||
});
|
||||
|
||||
|
||||
it('dashboard schema version should be set to latest', function() {
|
||||
expect(model.version).to.be(4);
|
||||
expect(model.version).to.be(5);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user