Commit adfb87e8 by Torkel Ödegaard

Merge branch 'develop' into alexanderzobnin-feat-9932

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