Commit adfb87e8 by Torkel Ödegaard

Merge branch 'develop' into alexanderzobnin-feat-9932

parents 517c454f df2d49da
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
"@types/enzyme": "^2.8.9", "@types/enzyme": "^2.8.9",
"@types/jest": "^21.1.4", "@types/jest": "^21.1.4",
"@types/node": "^8.0.31", "@types/node": "^8.0.31",
"@types/react": "^16.0.5", "@types/react": "^16.0.25",
"@types/react-dom": "^15.5.4", "@types/react-dom": "^16.0.3",
"angular-mocks": "^1.6.6", "angular-mocks": "^1.6.6",
"autoprefixer": "^6.4.0", "autoprefixer": "^6.4.0",
"awesome-typescript-loader": "^3.2.3", "awesome-typescript-loader": "^3.2.3",
...@@ -128,8 +128,8 @@ ...@@ -128,8 +128,8 @@
"ngreact": "^0.4.1", "ngreact": "^0.4.1",
"perfect-scrollbar": "^1.2.0", "perfect-scrollbar": "^1.2.0",
"prop-types": "^15.6.0", "prop-types": "^15.6.0",
"react": "^16.0.0", "react": "^16.1.1",
"react-dom": "^16.0.0", "react-dom": "^16.1.1",
"react-grid-layout": "^0.16.0", "react-grid-layout": "^0.16.0",
"react-sizeme": "^2.3.6", "react-sizeme": "^2.3.6",
"remarkable": "^1.7.1", "remarkable": "^1.7.1",
......
...@@ -3,14 +3,12 @@ import 'app/core/services/backend_srv'; ...@@ -3,14 +3,12 @@ import 'app/core/services/backend_srv';
describe('backend_srv', function() { describe('backend_srv', function() {
var _backendSrv; var _backendSrv;
var _http;
var _httpBackend; var _httpBackend;
beforeEach(angularMocks.module('grafana.core')); beforeEach(angularMocks.module('grafana.core'));
beforeEach(angularMocks.module('grafana.services')); beforeEach(angularMocks.module('grafana.services'));
beforeEach(angularMocks.inject(function ($httpBackend, $http, backendSrv) { beforeEach(angularMocks.inject(function ($httpBackend, $http, backendSrv) {
_httpBackend = $httpBackend; _httpBackend = $httpBackend;
_http = $http;
_backendSrv = backendSrv; _backendSrv = backendSrv;
})); }));
......
...@@ -84,12 +84,10 @@ describe("DateMath", () => { ...@@ -84,12 +84,10 @@ describe("DateMath", () => {
describe('rounding', () => { describe('rounding', () => {
var now; var now;
var anchored;
beforeEach(() => { beforeEach(() => {
clock = sinon.useFakeTimers(unix); clock = sinon.useFakeTimers(unix);
now = moment(); now = moment();
anchored = moment(anchor);
}); });
_.each(spans, (span) => { _.each(spans, (span) => {
......
...@@ -210,7 +210,6 @@ export class AlertTabCtrl { ...@@ -210,7 +210,6 @@ export class AlertTabCtrl {
} }
let firstTarget; let firstTarget;
var fixed = false;
let foundTarget = null; let foundTarget = null;
for (var condition of this.alert.conditions) { for (var condition of this.alert.conditions) {
...@@ -232,7 +231,6 @@ export class AlertTabCtrl { ...@@ -232,7 +231,6 @@ export class AlertTabCtrl {
if (firstTarget) { if (firstTarget) {
condition.query.params[0] = firstTarget.refId; condition.query.params[0] = firstTarget.refId;
foundTarget = firstTarget; foundTarget = firstTarget;
fixed = true;
} else { } else {
this.error = "Could not find any metric queries"; this.error = "Could not find any metric queries";
} }
......
...@@ -10,6 +10,7 @@ export class DashboardListCtrl { ...@@ -10,6 +10,7 @@ export class DashboardListCtrl {
navModel: any; navModel: any;
canDelete = false; canDelete = false;
canMove = false; canMove = false;
hasFilters = false;
selectAllChecked = false; selectAllChecked = false;
starredFilterOptions = [{text: 'Filter by Starred', disabled: true}, {text: 'Yes'}, {text: 'No'}]; starredFilterOptions = [{text: 'Filter by Starred', disabled: true}, {text: 'Yes'}, {text: 'No'}];
selectedStarredFilter: any; selectedStarredFilter: any;
...@@ -17,7 +18,7 @@ export class DashboardListCtrl { ...@@ -17,7 +18,7 @@ export class DashboardListCtrl {
/** @ngInject */ /** @ngInject */
constructor(private backendSrv, navModelSrv, private $q, private searchSrv: SearchSrv) { constructor(private backendSrv, navModelSrv, private $q, private searchSrv: SearchSrv) {
this.navModel = navModelSrv.getNav('dashboards', 'dashboards'); this.navModel = navModelSrv.getNav('dashboards', 'dashboards');
this.query = {query: '', mode: 'tree', tag: []}; this.query = {query: '', mode: 'tree', tag: [], starred: false};
this.selectedStarredFilter = this.starredFilterOptions[0]; this.selectedStarredFilter = this.starredFilterOptions[0];
this.getDashboards().then(() => { this.getDashboards().then(() => {
...@@ -35,6 +36,7 @@ export class DashboardListCtrl { ...@@ -35,6 +36,7 @@ export class DashboardListCtrl {
this.canMove = false; this.canMove = false;
this.canDelete = false; this.canDelete = false;
this.selectAllChecked = false; this.selectAllChecked = false;
this.hasFilters = this.query.query.length > 0 || this.query.tag.length > 0 || this.query.starred;
if (!result) { if (!result) {
this.sections = []; this.sections = [];
...@@ -194,4 +196,11 @@ export class DashboardListCtrl { ...@@ -194,4 +196,11 @@ export class DashboardListCtrl {
this.selectionChanged(); this.selectionChanged();
} }
clearFilters() {
this.query.query = '';
this.query.tag = [];
this.query.starred = false;
this.getDashboards();
}
} }
...@@ -9,8 +9,7 @@ export class FolderPickerCtrl { ...@@ -9,8 +9,7 @@ export class FolderPickerCtrl {
labelClass: string; labelClass: string;
onChange: any; onChange: any;
rootName = 'Root'; rootName = 'Root';
folder: any;
private folder: any;
/** @ngInject */ /** @ngInject */
constructor(private backendSrv) { constructor(private backendSrv) {
......
...@@ -32,6 +32,18 @@ ...@@ -32,6 +32,18 @@
</span> </span>
</div> </div>
<div class="gf-form">
<div class="gf-form-button-row"
ng-show="ctrl.hasFilters">
<button
type="button"
class="btn gf-form-button btn-inverse btn-small"
ng-click="ctrl.clearFilters()">
<i class="fa fa-close"></i> Clear current search query and filters
</button>
</div>
</div>
<div class="gf-form-group"> <div class="gf-form-group">
<div class="gf-form-button-row"> <div class="gf-form-button-row">
<button type="button" <button type="button"
......
...@@ -124,6 +124,10 @@ describe('DashboardListCtrl', () => { ...@@ -124,6 +124,10 @@ describe('DashboardListCtrl', () => {
expect(ctrl.canDelete).toBeFalsy(); expect(ctrl.canDelete).toBeFalsy();
}); });
it('should have active filters', () => {
expect(ctrl.hasFilters).toBeTruthy();
});
describe('when select all is checked', () => { describe('when select all is checked', () => {
beforeEach(() => { beforeEach(() => {
ctrl.selectAllChecked = true; ctrl.selectAllChecked = true;
...@@ -143,6 +147,16 @@ describe('DashboardListCtrl', () => { ...@@ -143,6 +147,16 @@ describe('DashboardListCtrl', () => {
it('should enable delete button', () => { it('should enable delete button', () => {
expect(ctrl.canDelete).toBeTruthy(); expect(ctrl.canDelete).toBeTruthy();
}); });
describe('when clearing filters', () => {
beforeEach(() => {
return ctrl.clearFilters();
});
it('should reset query filter', () => {
expect(ctrl.query.query).toEqual('');
});
});
}); });
}); });
...@@ -155,6 +169,20 @@ describe('DashboardListCtrl', () => { ...@@ -155,6 +169,20 @@ describe('DashboardListCtrl', () => {
expect(ctrl.sections.length).toEqual(1); expect(ctrl.sections.length).toEqual(1);
expect(ctrl.query.tag[0]).toEqual('test'); expect(ctrl.query.tag[0]).toEqual('test');
}); });
it('should have active filters', () => {
expect(ctrl.hasFilters).toBeTruthy();
});
describe('when clearing filters', () => {
beforeEach(() => {
return ctrl.clearFilters();
});
it('should reset tag filter', () => {
expect(ctrl.query.tag.length).toEqual(0);
});
});
}); });
describe('with starred filter', () => { describe('with starred filter', () => {
...@@ -169,6 +197,20 @@ describe('DashboardListCtrl', () => { ...@@ -169,6 +197,20 @@ describe('DashboardListCtrl', () => {
expect(ctrl.sections.length).toEqual(1); expect(ctrl.sections.length).toEqual(1);
expect(ctrl.query.starred).toEqual(true); expect(ctrl.query.starred).toEqual(true);
}); });
it('should have active filters', () => {
expect(ctrl.hasFilters).toBeTruthy();
});
describe('when clearing filters', () => {
beforeEach(() => {
return ctrl.clearFilters();
});
it('should reset starred filter', () => {
expect(ctrl.query.starred).toEqual(false);
});
});
}); });
}); });
......
import {describe, beforeEach} from 'test/lib/common'; import {describe, beforeEach, expect} from 'test/lib/common';
import {DashboardSrv} from '../dashboard_srv'; import {DashboardSrv} from '../dashboard_srv';
...@@ -9,4 +9,7 @@ describe('dashboardSrv', function() { ...@@ -9,4 +9,7 @@ describe('dashboardSrv', function() {
_dashboardSrv = new DashboardSrv({}, {}, {}); _dashboardSrv = new DashboardSrv({}, {}, {});
}); });
it("should do something", () => {
expect(_dashboardSrv).not.to.be(null);
});
}); });
...@@ -51,10 +51,8 @@ describe('given dashboard with panel repeat in horizontal direction', function() ...@@ -51,10 +51,8 @@ describe('given dashboard with panel repeat in horizontal direction', function()
}); });
describe('After a second iteration', function() { describe('After a second iteration', function() {
var repeatedPanelAfterIteration1;
beforeEach(function() { beforeEach(function() {
repeatedPanelAfterIteration1 = dashboard.panels[1];
dashboard.panels[0].fill = 10; dashboard.panels[0].fill = 10;
dashboard.processRepeats(); dashboard.processRepeats();
}); });
......
...@@ -5,7 +5,6 @@ import 'app/features/dashboard/dashboard_srv'; ...@@ -5,7 +5,6 @@ import 'app/features/dashboard/dashboard_srv';
describe("unsavedChangesSrv", function() { describe("unsavedChangesSrv", function() {
var _unsavedChangesSrv; var _unsavedChangesSrv;
var _dashboardSrv; var _dashboardSrv;
var _location;
var _contextSrvStub = { isEditor: true }; var _contextSrvStub = { isEditor: true };
var _rootScope; var _rootScope;
var tracker; var tracker;
...@@ -22,7 +21,6 @@ describe("unsavedChangesSrv", function() { ...@@ -22,7 +21,6 @@ describe("unsavedChangesSrv", function() {
beforeEach(angularMocks.inject(function(unsavedChangesSrv, $location, $rootScope, dashboardSrv) { beforeEach(angularMocks.inject(function(unsavedChangesSrv, $location, $rootScope, dashboardSrv) {
_unsavedChangesSrv = unsavedChangesSrv; _unsavedChangesSrv = unsavedChangesSrv;
_dashboardSrv = dashboardSrv; _dashboardSrv = dashboardSrv;
_location = $location;
_rootScope = $rootScope; _rootScope = $rootScope;
})); }));
......
...@@ -9,7 +9,6 @@ class PlaylistSrv { ...@@ -9,7 +9,6 @@ class PlaylistSrv {
private dashboards: any; private dashboards: any;
private index: number; private index: number;
private interval: any; private interval: any;
private playlistId: number;
private startUrl: string; private startUrl: string;
public isPlaying: boolean; public isPlaying: boolean;
...@@ -65,7 +64,6 @@ class PlaylistSrv { ...@@ -65,7 +64,6 @@ class PlaylistSrv {
this.startUrl = window.location.href; this.startUrl = window.location.href;
this.index = 0; this.index = 0;
this.playlistId = playlistId;
this.isPlaying = true; this.isPlaying = true;
if (this.$routeParams.kiosk) { if (this.$routeParams.kiosk) {
...@@ -84,7 +82,6 @@ class PlaylistSrv { ...@@ -84,7 +82,6 @@ class PlaylistSrv {
stop() { stop() {
this.index = 0; this.index = 0;
this.isPlaying = false; this.isPlaying = false;
this.playlistId = 0;
if (this.cancelPromise) { if (this.cancelPromise) {
this.$timeout.cancel(this.cancelPromise); this.$timeout.cancel(this.cancelPromise);
......
...@@ -12,7 +12,6 @@ export class TemplateSrv { ...@@ -12,7 +12,6 @@ export class TemplateSrv {
private index = {}; private index = {};
private grafanaVariables = {}; private grafanaVariables = {};
private builtIns = {}; private builtIns = {};
private filters = {};
constructor() { constructor() {
this.builtIns['__interval'] = {text: '1s', value: '1s'}; this.builtIns['__interval'] = {text: '1s', value: '1s'};
...@@ -26,7 +25,6 @@ export class TemplateSrv { ...@@ -26,7 +25,6 @@ export class TemplateSrv {
updateTemplateData() { updateTemplateData() {
this.index = {}; this.index = {};
this.filters = {};
for (var i = 0; i < this.variables.length; i++) { for (var i = 0; i < this.variables.length; i++) {
var variable = this.variables[i]; var variable = this.variables[i];
......
...@@ -166,8 +166,6 @@ describe('CloudWatchDatasource', function() { ...@@ -166,8 +166,6 @@ describe('CloudWatchDatasource', function() {
}); });
describe('When performing CloudWatch query for extended statistics', function() { describe('When performing CloudWatch query for extended statistics', function() {
var requestParams;
var query = { var query = {
range: { from: 'now-1h', to: 'now' }, range: { from: 'now-1h', to: 'now' },
rangeRaw: { from: 1483228800, to: 1483232400 }, rangeRaw: { from: 1483228800, to: 1483232400 },
...@@ -212,7 +210,6 @@ describe('CloudWatchDatasource', function() { ...@@ -212,7 +210,6 @@ describe('CloudWatchDatasource', function() {
beforeEach(function() { beforeEach(function() {
ctx.backendSrv.datasourceRequest = function(params) { ctx.backendSrv.datasourceRequest = function(params) {
requestParams = params.data;
return ctx.$q.when({data: response}); return ctx.$q.when({data: response});
}; };
}); });
......
...@@ -112,13 +112,11 @@ describe('ElasticDatasource', function() { ...@@ -112,13 +112,11 @@ describe('ElasticDatasource', function() {
}); });
describe('When getting fields', function() { describe('When getting fields', function() {
var requestOptions;
beforeEach(function() { beforeEach(function() {
createDatasource({url: 'http://es.com', index: 'metricbeat'}); createDatasource({url: 'http://es.com', index: 'metricbeat'});
ctx.backendSrv.datasourceRequest = function(options) { ctx.backendSrv.datasourceRequest = function(options) {
requestOptions = options;
return ctx.$q.when({data: { return ctx.$q.when({data: {
metricbeat: { metricbeat: {
mappings: { mappings: {
......
...@@ -167,9 +167,7 @@ Lexer.prototype = { ...@@ -167,9 +167,7 @@ Lexer.prototype = {
this.from = this.char; this.from = this.char;
// Move to the next non-space character. // Move to the next non-space character.
var start;
if (/\s/.test(this.peek())) { if (/\s/.test(this.peek())) {
start = this.char;
while (/\s/.test(this.peek())) { while (/\s/.test(this.peek())) {
this.from += 1; this.from += 1;
......
...@@ -35,6 +35,7 @@ describe('opentsdb', function() { ...@@ -35,6 +35,7 @@ describe('opentsdb', function() {
expect(requestOptions.url).to.be('/api/suggest'); expect(requestOptions.url).to.be('/api/suggest');
expect(requestOptions.params.type).to.be('metrics'); expect(requestOptions.params.type).to.be('metrics');
expect(requestOptions.params.q).to.be('pew'); expect(requestOptions.params.q).to.be('pew');
expect(results).not.to.be(null);
}); });
it('tag_names(cpu) should generate lookup query', function() { it('tag_names(cpu) should generate lookup query', function() {
......
...@@ -228,6 +228,7 @@ describe('PrometheusDatasource', function() { ...@@ -228,6 +228,7 @@ describe('PrometheusDatasource', function() {
); );
}); });
}); });
describe('When resultFormat is table and instant = true', function() { describe('When resultFormat is table and instant = true', function() {
var results; var results;
var urlExpected = 'proxied/api/v1/query?query=' + var urlExpected = 'proxied/api/v1/query?query=' +
...@@ -248,11 +249,17 @@ describe('PrometheusDatasource', function() { ...@@ -248,11 +249,17 @@ describe('PrometheusDatasource', function() {
}] }]
} }
}; };
beforeEach(function () { beforeEach(function () {
ctx.$httpBackend.expect('GET', urlExpected).respond(response); ctx.$httpBackend.expect('GET', urlExpected).respond(response);
ctx.ds.query(query).then(function (data) { results = data; }); ctx.ds.query(query).then(function (data) { results = data; });
ctx.$httpBackend.flush(); ctx.$httpBackend.flush();
}); });
it("should return result", () => {
expect(results).not.to.be(null);
});
it('should return table model', function() { it('should return table model', function() {
var table = ctx.ds.transformMetricDataToTable(response.data.result); var table = ctx.ds.transformMetricDataToTable(response.data.result);
expect(table.type).to.be('table'); expect(table.type).to.be('table');
......
...@@ -4,8 +4,8 @@ describe('Graph DataProcessor', function() { ...@@ -4,8 +4,8 @@ describe('Graph DataProcessor', function() {
var panel: any = { var panel: any = {
xaxis: {} xaxis: {}
}; };
var processor = new DataProcessor(panel); var processor = new DataProcessor(panel);
var seriesList;
describe('Given default xaxis options and query that returns docs', () => { describe('Given default xaxis options and query that returns docs', () => {
...@@ -14,7 +14,7 @@ describe('Graph DataProcessor', function() { ...@@ -14,7 +14,7 @@ describe('Graph DataProcessor', function() {
panel.xaxis.name = 'hostname'; panel.xaxis.name = 'hostname';
panel.xaxis.values = []; panel.xaxis.values = [];
seriesList = processor.getSeriesList({ processor.getSeriesList({
dataList: [ dataList: [
{ {
type: 'docs', type: 'docs',
......
...@@ -34,7 +34,6 @@ export class ThresholdManager { ...@@ -34,7 +34,6 @@ export class ThresholdManager {
var handleElem = $(evt.currentTarget).parents(".alert-handle-wrapper"); var handleElem = $(evt.currentTarget).parents(".alert-handle-wrapper");
var handleIndex = $(evt.currentTarget).data("handleIndex"); var handleIndex = $(evt.currentTarget).data("handleIndex");
var isMoving = false;
var lastY = null; var lastY = null;
var posTop; var posTop;
var plot = this.plot; var plot = this.plot;
...@@ -53,7 +52,6 @@ export class ThresholdManager { ...@@ -53,7 +52,6 @@ export class ThresholdManager {
} }
function stopped() { function stopped() {
isMoving = false;
// calculate graph level // calculate graph level
var graphValue = plot.c2p({left: 0, top: posTop}).y; var graphValue = plot.c2p({left: 0, top: posTop}).y;
graphValue = parseInt(graphValue.toFixed(0)); graphValue = parseInt(graphValue.toFixed(0));
...@@ -70,7 +68,6 @@ export class ThresholdManager { ...@@ -70,7 +68,6 @@ export class ThresholdManager {
}); });
} }
isMoving = true;
lastY = null; lastY = null;
posTop = handleElem.position().top; posTop = handleElem.position().top;
......
...@@ -100,9 +100,8 @@ export class HeatmapCtrl extends MetricsPanelCtrl { ...@@ -100,9 +100,8 @@ export class HeatmapCtrl extends MetricsPanelCtrl {
scaledDecimals: number; scaledDecimals: number;
/** @ngInject */ /** @ngInject */
constructor($scope, $injector, private $rootScope, timeSrv) { constructor($scope, $injector, timeSrv) {
super($scope, $injector); super($scope, $injector);
this.$rootScope = $rootScope;
this.timeSrv = timeSrv; this.timeSrv = timeSrv;
this.selectionActivated = false; this.selectionActivated = false;
......
...@@ -13,10 +13,10 @@ config = merge(common, { ...@@ -13,10 +13,10 @@ config = merge(common, {
fs: 'empty' fs: 'empty'
}, },
plugins: [ plugins: [
// new webpack.SourceMapDevToolPlugin({ new webpack.SourceMapDevToolPlugin({
// filename: null, // if no value is provided the sourcemap is inlined filename: null, // if no value is provided the sourcemap is inlined
// test: /\.(ts|js)($|\?)/i // process .js and .ts files only test: /\.(ts|js)($|\?)/i // process .js and .ts files only
// }) })
] ]
}); });
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment