Skip to content

Commit 741b735

Browse files
committed
Merge branch 'v3.1.x' of github.com:grafana/grafana into v3.1.x
2 parents c4e7a3a + 89dc3b8 commit 741b735

File tree

127 files changed

+5989
-13399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+5989
-13399
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"tests"
1414
],
1515
"dependencies": {
16-
"jquery": "~2.1.4",
16+
"jquery": "~2.2.4",
1717
"angular": "~1.5.3",
1818
"angular-route": "~1.5.3",
1919
"angular-mocks": "~1.5.3",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"company": "Coding Instinct AB"
55
},
66
"name": "grafana",
7-
"version": "3.1.0",
7+
"version": "3.1.1",
88
"repository": {
99
"type": "git",
1010
"url": "http://github.com/grafana/grafana.git"

public/app/core/routes/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function setupAngularRoutes($routeProvider, $locationProvider) {
3030
.when('/dashboard-solo/:type/:slug', {
3131
templateUrl: 'public/app/features/panel/partials/soloPanel.html',
3232
controller : 'SoloPanelCtrl',
33+
reloadOnSearch: false,
3334
pageClass: 'page-dashboard',
3435
})
3536
.when('/dashboard/new', {

public/app/features/dashboard/dashboardSrv.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ function (angular, $, _, moment) {
1616
data = {};
1717
}
1818

19-
if (!data.id && data.version) {
20-
data.schemaVersion = data.version;
21-
}
22-
2319
this.id = data.id || null;
2420
this.title = data.title || 'No Title';
2521
this.autoUpdate = data.autoUpdate;

public/app/features/dashboard/timeSrv.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ define([
1313
module.service('timeSrv', function($rootScope, $timeout, $routeParams, timer) {
1414
var self = this;
1515

16+
$rootScope.$on('zoom-out', function(e, factor) { self.zoomOut(factor); });
17+
1618
this.init = function(dashboard) {
1719
timer.cancel_all();
1820

@@ -137,6 +139,24 @@ define([
137139
return {from: from, to: to};
138140
};
139141

142+
this.zoomOut = function(factor) {
143+
var range = this.timeRange();
144+
145+
var timespan = (range.to.valueOf() - range.from.valueOf());
146+
var center = range.to.valueOf() - timespan/2;
147+
148+
var to = (center + (timespan*factor)/2);
149+
var from = (center - (timespan*factor)/2);
150+
151+
if (to > Date.now() && range.to <= Date.now()) {
152+
var offset = to - Date.now();
153+
from = from - offset;
154+
to = Date.now();
155+
}
156+
157+
this.setTime({from: moment.utc(from), to: moment.utc(to) });
158+
};
159+
140160
});
141161

142162
});

public/app/features/dashboard/timepicker/timepicker.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export class TimePickerCtrl {
2929
constructor(private $scope, private $rootScope, private timeSrv) {
3030
$scope.ctrl = this;
3131

32-
$rootScope.onAppEvent('zoom-out', () => this.zoom(2), $scope);
3332
$rootScope.onAppEvent('shift-time-forward', () => this.move(1), $scope);
3433
$rootScope.onAppEvent('shift-time-backward', () => this.move(-1), $scope);
3534
$rootScope.onAppEvent('refresh', () => this.init(), $scope);
@@ -72,21 +71,7 @@ export class TimePickerCtrl {
7271
}
7372

7473
zoom(factor) {
75-
var range = this.timeSrv.timeRange();
76-
77-
var timespan = (range.to.valueOf() - range.from.valueOf());
78-
var center = range.to.valueOf() - timespan/2;
79-
80-
var to = (center + (timespan*factor)/2);
81-
var from = (center - (timespan*factor)/2);
82-
83-
if (to > Date.now() && range.to <= Date.now()) {
84-
var offset = to - Date.now();
85-
from = from - offset;
86-
to = Date.now();
87-
}
88-
89-
this.timeSrv.setTime({from: moment.utc(from), to: moment.utc(to) });
74+
this.$rootScope.appEvent('zoom-out', 2);
9075
}
9176

9277
move(direction) {

public/app/features/dashboard/viewStateSrv.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,12 @@ function (angular, _, $) {
107107
this.dashboard.meta.fullscreen = this.state.fullscreen;
108108

109109
if (!this.state.fullscreen) {
110-
this.state.panelId = null;
111110
this.state.fullscreen = null;
112111
this.state.edit = null;
112+
// clear panel id unless in solo mode
113+
if (!this.dashboard.meta.soloMode) {
114+
this.state.panelId = null;
115+
}
113116
}
114117

115118
$location.search(this.serializeToUrl());
@@ -193,11 +196,13 @@ function (angular, _, $) {
193196
var self = this;
194197
self.panelScopes.push(panelScope);
195198

196-
if (self.state.panelId === panelScope.ctrl.panel.id) {
197-
if (self.state.edit) {
198-
panelScope.ctrl.editPanel();
199-
} else {
200-
panelScope.ctrl.viewPanel();
199+
if (!self.dashboard.meta.soloMode) {
200+
if (self.state.panelId === panelScope.ctrl.panel.id) {
201+
if (self.state.edit) {
202+
panelScope.ctrl.editPanel();
203+
} else {
204+
panelScope.ctrl.viewPanel();
205+
}
201206
}
202207
}
203208

public/app/features/panel/solo_panel_ctrl.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ function (angular, $) {
1717
var params = $location.search();
1818
panelId = parseInt(params.panelId);
1919

20-
// add fullscreen param;
21-
params.fullscreen = true;
22-
$location.search(params);
20+
$scope.onAppEvent("dashboard-initialized", $scope.initPanelScope);
2321

2422
dashboardLoaderSrv.loadDashboard($routeParams.type, $routeParams.slug).then(function(result) {
23+
result.meta.soloMode = true;
2524
$scope.initDashboard(result, $scope);
2625
});
27-
28-
$scope.onAppEvent("dashboard-initialized", $scope.initPanelScope);
2926
};
3027

3128
$scope.initPanelScope = function() {

public/app/features/templating/templateValuesSrv.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function (angular, _, kbn) {
1010

1111
module.service('templateValuesSrv', function($q, $rootScope, datasourceSrv, $location, templateSrv, timeSrv) {
1212
var self = this;
13+
this.variableLock = {};
1314

1415
function getNoneOption() { return { text: 'None', value: '', isNone: true }; }
1516

@@ -90,6 +91,8 @@ function (angular, _, kbn) {
9091
} else {
9192
lock.resolve();
9293
}
94+
}).finally(function() {
95+
delete self.variableLock[variable.name];
9396
});
9497
};
9598

@@ -124,7 +127,7 @@ function (angular, _, kbn) {
124127
templateSrv.setGrafanaVariable('$__auto_interval', interval);
125128
};
126129

127-
this.setVariableValue = function(variable, option, initPhase) {
130+
this.setVariableValue = function(variable, option) {
128131
variable.current = angular.copy(option);
129132

130133
if (_.isArray(variable.current.text)) {
@@ -134,13 +137,7 @@ function (angular, _, kbn) {
134137
self.selectOptionsForCurrentValue(variable);
135138
templateSrv.updateTemplateData();
136139

137-
// on first load, variable loading is ordered to ensure
138-
// that parents are updated before children.
139-
if (initPhase) {
140-
return $q.when();
141-
}
142-
143-
return self.updateOptionsInChildVariables(variable);
140+
return this.updateOptionsInChildVariables(variable);
144141
};
145142

146143
this.variableUpdated = function(variable) {
@@ -149,6 +146,11 @@ function (angular, _, kbn) {
149146
};
150147

151148
this.updateOptionsInChildVariables = function(updatedVariable) {
149+
// if there is a variable lock ignore cascading update because we are in a boot up scenario
150+
if (self.variableLock[updatedVariable.name]) {
151+
return $q.when();
152+
}
153+
152154
var promises = _.map(self.variables, function(otherVariable) {
153155
if (otherVariable === updatedVariable) {
154156
return;

public/app/plugins/datasource/elasticsearch/datasource.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,8 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
205205
};
206206

207207
function escapeForJson(value) {
208-
return value
209-
.replace(/\s/g, '\\ ')
210-
.replace(/\"/g, '\\"');
211-
}
212-
213-
function luceneThenJsonFormat(value) {
214-
return escapeForJson(templateSrv.luceneFormat(value));
208+
var luceneQuery = JSON.stringify(value);
209+
return luceneQuery.substr(1, luceneQuery.length - 2);
215210
}
216211

217212
this.getFields = function(query) {
@@ -256,7 +251,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
256251
var header = this.getQueryHeader('count', range.from, range.to);
257252
var esQuery = angular.toJson(this.queryBuilder.getTermsQuery(queryDef));
258253

259-
esQuery = esQuery.replace("$lucene_query", escapeForJson(queryDef.query || '*'));
254+
esQuery = esQuery.replace("$lucene_query", escapeForJson(queryDef.query));
260255
esQuery = esQuery.replace(/\$timeFrom/g, range.from.valueOf());
261256
esQuery = esQuery.replace(/\$timeTo/g, range.to.valueOf());
262257
esQuery = header + '\n' + esQuery + '\n';
@@ -270,8 +265,9 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
270265
};
271266

272267
this.metricFindQuery = function(query) {
273-
query = templateSrv.replace(query, {}, luceneThenJsonFormat);
274268
query = angular.fromJson(query);
269+
query.query = templateSrv.replace(query.query || '*', {}, 'lucene');
270+
275271
if (!query) {
276272
return $q.when([]);
277273
}

public/app/plugins/datasource/graphite/datasource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function GraphiteDatasource(instanceSettings, $q, backendSrv, templateSrv
4040
};
4141

4242
if (options.panelId) {
43-
httpOptions.requestId = 'panel' + options.panelId;
43+
httpOptions.requestId = this.name + '.panelId.' + options.panelId;
4444
}
4545

4646
return this.doGraphiteRequest(httpOptions).then(this.convertDataPointsToMs);

public/app/plugins/datasource/graphite/specs/datasource_specs.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {GraphiteDatasource} from "../datasource";
55

66
describe('graphiteDatasource', function() {
77
var ctx = new helpers.ServiceTestContext();
8-
var instanceSettings: any = {url: ['']};
8+
var instanceSettings: any = {url: [''], name: 'graphiteProd'};
99

1010
beforeEach(angularMocks.module('grafana.core'));
1111
beforeEach(angularMocks.module('grafana.services'));
@@ -24,9 +24,10 @@ describe('graphiteDatasource', function() {
2424

2525
describe('When querying influxdb with one target using query editor target spec', function() {
2626
var query = {
27-
rangeRaw: { from: 'now-1h', to: 'now' },
28-
targets: [{ target: 'prod1.count' }, {target: 'prod2.count'}],
29-
maxDataPoints: 500,
27+
panelId: 3,
28+
rangeRaw: { from: 'now-1h', to: 'now' },
29+
targets: [{ target: 'prod1.count' }, {target: 'prod2.count'}],
30+
maxDataPoints: 500,
3031
};
3132

3233
var results;
@@ -46,6 +47,10 @@ describe('graphiteDatasource', function() {
4647
expect(requestOptions.url).to.be('/render');
4748
});
4849

50+
it('should set unique requestId', function() {
51+
expect(requestOptions.requestId).to.be('graphiteProd.panelId.3');
52+
});
53+
4954
it('should query correctly', function() {
5055
var params = requestOptions.data.split('&');
5156
expect(params).to.contain('target=prod1.count');

public/app/plugins/datasource/prometheus/dashboards/prometheus_stats.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
"valueName": "current"
168168
},
169169
{
170-
"content": "<img src=\"http://prometheus.io/assets/prometheus_logo_grey.svg\" alt=\"Prometheus logo\" style=\"height: 40px;\">\n<span style=\"font-family: 'Open Sans', 'Helvetica Neue', Helvetica; font-size: 25px;vertical-align: text-top;color: #bbbfc2;margin-left: 10px;\">Prometheus</span>\n\n<p style=\"margin-top: 10px;\">You're using Prometheus, an open-source systems monitoring and alerting toolkit originally built at SoundCloud. For more information, check out the <a href=\"http://www.grafana.org/\">Grafana</a> and <a href=\"http://prometheus.io/\">Prometheus</a> projects.</p>",
170+
"content": "<img src=\"public/app/plugins/datasource/prometheus/img/prometheus_logo.svg\" alt=\"Prometheus logo\" style=\"height: 40px;\">\n<span style=\"font-family: 'Open Sans', 'Helvetica Neue', Helvetica; font-size: 25px;vertical-align: text-top;color: #bbbfc2;margin-left: 10px;\">Prometheus</span>\n\n<p style=\"margin-top: 10px;\">You're using Prometheus, an open-source systems monitoring and alerting toolkit originally built at SoundCloud. For more information, check out the <a href=\"http://www.grafana.org/\">Grafana</a> and <a href=\"http://prometheus.io/\">Prometheus</a> projects.</p>",
171171
"editable": true,
172172
"error": false,
173173
"id": 9,

public/app/plugins/panel/graph/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class GraphCtrl extends MetricsPanelCtrl {
157157
}
158158

159159
zoomOut(evt) {
160-
this.publishAppEvent('zoom-out', evt);
160+
this.publishAppEvent('zoom-out', 2);
161161
}
162162

163163
onDataSnapshotLoad(snapshotData) {

public/vendor/jquery/.bower.json

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,25 @@
11
{
22
"name": "jquery",
3-
"version": "2.1.4",
43
"main": "dist/jquery.js",
54
"license": "MIT",
65
"ignore": [
7-
"**/.*",
8-
"build",
9-
"dist/cdn",
10-
"speed",
11-
"test",
12-
"*.md",
13-
"AUTHORS.txt",
14-
"Gruntfile.js",
156
"package.json"
167
],
17-
"devDependencies": {
18-
"sizzle": "2.1.1-jquery.2.1.2",
19-
"requirejs": "2.1.10",
20-
"qunit": "1.14.0",
21-
"sinon": "1.8.1"
22-
},
238
"keywords": [
249
"jquery",
2510
"javascript",
11+
"browser",
2612
"library"
2713
],
28-
"homepage": "https://github.com/jquery/jquery",
29-
"_release": "2.1.4",
14+
"homepage": "https://github.com/jquery/jquery-dist",
15+
"version": "2.2.4",
16+
"_release": "2.2.4",
3017
"_resolution": {
3118
"type": "version",
32-
"tag": "2.1.4",
33-
"commit": "7751e69b615c6eca6f783a81e292a55725af6b85"
19+
"tag": "2.2.4",
20+
"commit": "c0185ab7c75aab88762c5aae780b9d83b80eda72"
3421
},
35-
"_source": "git://github.com/jquery/jquery.git",
36-
"_target": "~2.1.4",
37-
"_originalSource": "jquery",
38-
"_direct": true
22+
"_source": "https://github.com/jquery/jquery-dist.git",
23+
"_target": "~2.2.4",
24+
"_originalSource": "jquery"
3925
}

0 commit comments

Comments
 (0)