@@ -88,7 +88,7 @@
diff --git a/public/app/plugins/datasource/prometheus/datasource.ts b/public/app/plugins/datasource/prometheus/datasource.ts
index f1c58f6a61d..cbd7b1ba24b 100644
--- a/public/app/plugins/datasource/prometheus/datasource.ts
+++ b/public/app/plugins/datasource/prometheus/datasource.ts
@@ -256,23 +256,14 @@ export function PrometheusDatasource(instanceSettings, $q, backendSrv, templateS
return this.renderTemplate(options.legendFormat, labelData) || '{}';
};
- this.renderTemplate = function(format, data) {
- var originalSettings = _.templateSettings;
- _.templateSettings = {
- interpolate: /\{\{(.+?)\}\}/g
- };
-
- var template = _.template(templateSrv.replace(format));
- var result;
- try {
- result = template(data);
- } catch (e) {
- result = null;
- }
-
- _.templateSettings = originalSettings;
-
- return result;
+ this.renderTemplate = function(aliasPattern, aliasData) {
+ var aliasRegex = /\{\{\s*(.+?)\s*\}\}/g;
+ return aliasPattern.replace(aliasRegex, function(match, g1) {
+ if (aliasData[g1]) {
+ return aliasData[g1];
+ }
+ return g1;
+ });
};
this.getOriginalMetricName = function(labelData) {
diff --git a/public/app/plugins/datasource/prometheus/query_ctrl.ts b/public/app/plugins/datasource/prometheus/query_ctrl.ts
index 94340804988..92cec328d87 100644
--- a/public/app/plugins/datasource/prometheus/query_ctrl.ts
+++ b/public/app/plugins/datasource/prometheus/query_ctrl.ts
@@ -58,6 +58,10 @@ class PrometheusQueryCtrl extends QueryCtrl {
updateLink() {
var range = this.panelCtrl.range;
+ if (!range) {
+ return;
+ }
+
var rangeDiff = Math.ceil((range.to.valueOf() - range.from.valueOf()) / 1000);
var endTime = range.to.utc().format('YYYY-MM-DD HH:mm');
var expr = {
diff --git a/public/app/plugins/panel/graph/graph.js b/public/app/plugins/panel/graph/graph.js
index 562bf71c947..86ad3b5f025 100755
--- a/public/app/plugins/panel/graph/graph.js
+++ b/public/app/plugins/panel/graph/graph.js
@@ -66,7 +66,7 @@ function (angular, $, moment, _, kbn, GraphTooltip) {
function getLegendHeight(panelHeight) {
if (!panel.legend.show || panel.legend.rightSide) {
- return 2;
+ return 0;
}
if (panel.legend.alignAsTable) {
diff --git a/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts b/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
index dfce4031772..d00c90ae6a1 100644
--- a/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
+++ b/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
@@ -22,8 +22,8 @@ describe('GraphCtrl', function() {
describe('msResolution with second resolution timestamps', function() {
beforeEach(function() {
var data = [
- { target: 'test.cpu1', datapoints: [[1234567890, 45], [1234567899, 60]]},
- { target: 'test.cpu2', datapoints: [[1236547890, 55], [1234456709, 90]]}
+ { target: 'test.cpu1', datapoints: [[45, 1234567890], [60, 1234567899]]},
+ { target: 'test.cpu2', datapoints: [[55, 1236547890], [90, 1234456709]]}
];
ctx.ctrl.panel.tooltip.msResolution = false;
ctx.ctrl.onDataReceived(data);
@@ -37,8 +37,8 @@ describe('GraphCtrl', function() {
describe('msResolution with millisecond resolution timestamps', function() {
beforeEach(function() {
var data = [
- { target: 'test.cpu1', datapoints: [[1234567890000, 45], [1234567899000, 60]]},
- { target: 'test.cpu2', datapoints: [[1236547890001, 55], [1234456709000, 90]]}
+ { target: 'test.cpu1', datapoints: [[45, 1234567890000], [60, 1234567899000]]},
+ { target: 'test.cpu2', datapoints: [[55, 1236547890001], [90, 1234456709000]]}
];
ctx.ctrl.panel.tooltip.msResolution = false;
ctx.ctrl.onDataReceived(data);
@@ -52,8 +52,8 @@ describe('GraphCtrl', function() {
describe('msResolution with millisecond resolution timestamps but with trailing zeroes', function() {
beforeEach(function() {
var data = [
- { target: 'test.cpu1', datapoints: [[1234567890000, 45], [1234567899000, 60]]},
- { target: 'test.cpu2', datapoints: [[1236547890000, 55], [1234456709000, 90]]}
+ { target: 'test.cpu1', datapoints: [[45, 1234567890000], [60, 1234567899000]]},
+ { target: 'test.cpu2', datapoints: [[55, 1236547890000], [90, 1234456709000]]}
];
ctx.ctrl.panel.tooltip.msResolution = false;
ctx.ctrl.onDataReceived(data);
@@ -67,9 +67,9 @@ describe('GraphCtrl', function() {
describe('msResolution with millisecond resolution timestamps in one of the series', function() {
beforeEach(function() {
var data = [
- { target: 'test.cpu1', datapoints: [[1234567890000, 45], [1234567899000, 60]]},
- { target: 'test.cpu2', datapoints: [[1236547890010, 55], [1234456709000, 90]]},
- { target: 'test.cpu3', datapoints: [[1236547890000, 65], [1234456709000, 120]]}
+ { target: 'test.cpu1', datapoints: [[45, 1234567890000], [60, 1234567899000]]},
+ { target: 'test.cpu2', datapoints: [[55, 1236547890010], [90, 1234456709000]]},
+ { target: 'test.cpu3', datapoints: [[65, 1236547890000], [120, 1234456709000]]}
];
ctx.ctrl.panel.tooltip.msResolution = false;
ctx.ctrl.onDataReceived(data);
diff --git a/public/app/plugins/panel/singlestat/module.html b/public/app/plugins/panel/singlestat/module.html
index 599e8724159..75a35374566 100644
--- a/public/app/plugins/panel/singlestat/module.html
+++ b/public/app/plugins/panel/singlestat/module.html
@@ -1,4 +1,3 @@
-
diff --git a/public/app/plugins/panel/singlestat/module.ts b/public/app/plugins/panel/singlestat/module.ts
index de272478fbc..59da49ca3d5 100644
--- a/public/app/plugins/panel/singlestat/module.ts
+++ b/public/app/plugins/panel/singlestat/module.ts
@@ -325,6 +325,9 @@ class SingleStatCtrl extends MetricsPanelCtrl {
}
function addGauge() {
+ var width = elem.width();
+ var height = elem.height();
+
ctrl.invalidGaugeRange = false;
if (panel.gauge.minValue > panel.gauge.maxValue) {
ctrl.invalidGaugeRange = true;
@@ -332,8 +335,6 @@ class SingleStatCtrl extends MetricsPanelCtrl {
}
var plotCanvas = $('
');
- var width = elem.width();
- var height = elem.height();
var plotCss = {
top: '10px',
margin: 'auto',
diff --git a/public/sass/_variables.dark.scss b/public/sass/_variables.dark.scss
index bf78bd496a3..047e50faa73 100644
--- a/public/sass/_variables.dark.scss
+++ b/public/sass/_variables.dark.scss
@@ -269,3 +269,7 @@ $checkboxImageUrl: '../img/checkbox.png';
$card-background: linear-gradient(135deg, #2f2f2f, #262626);
$card-background-hover: linear-gradient(135deg, #343434, #262626);
$card-shadow: -1px -1px 0 0 hsla(0, 0%, 100%, .1), 1px 1px 0 0 rgba(0, 0, 0, .3);
+
+// footer
+$footer-link-color: $gray-1;
+$footer-link-hover: $gray-4;
diff --git a/public/sass/_variables.light.scss b/public/sass/_variables.light.scss
index 1494f59a2fd..4e389166cef 100644
--- a/public/sass/_variables.light.scss
+++ b/public/sass/_variables.light.scss
@@ -293,3 +293,7 @@ $checkboxImageUrl: '../img/checkbox_white.png';
$card-background: linear-gradient(135deg, $gray-5, $gray-6);
$card-background-hover: linear-gradient(135deg, $gray-6, $gray-7);
$card-shadow: -1px -1px 0 0 hsla(0, 0%, 100%, .1), 1px 1px 0 0 rgba(0, 0, 0, .1);
+
+// footer
+$footer-link-color: $gray-3;
+$footer-link-hover: $dark-5;
diff --git a/public/sass/components/_footer.scss b/public/sass/components/_footer.scss
index 9f2674980b0..8f3b9186d15 100644
--- a/public/sass/components/_footer.scss
+++ b/public/sass/components/_footer.scss
@@ -1,9 +1,38 @@
-.grafana-version-info {
- position: absolute;
- bottom: 2px;
- left: 3px;
- font-size: 80%;
- color: darken($gray-1, 25%);
- a { color: darken($gray-1, 25%); }
+.page-dashboard .footer {
+ display: none;
}
+.footer {
+ color: $footer-link-color;
+ padding: 5rem 0 1rem 0;
+ font-size: $font-size-xs;
+ width: 98%; /* was causing horiz scrollbars - need to examine */
+
+ a {
+ color: $footer-link-color;
+
+ &:hover {
+ color: $footer-link-hover;
+ }
+ }
+
+ ul {
+ list-style: none;
+ }
+
+ li {
+ display: inline-block;
+ padding-right: 2px;
+ &:after {
+ content: ' | ';
+ padding-left: 2px;
+ }
+ }
+
+ li:last-child {
+ &:after {
+ padding-left: 0;
+ content: '';
+ }
+ }
+}
diff --git a/public/sass/components/_panel_singlestat.scss b/public/sass/components/_panel_singlestat.scss
index fac2f716674..48d0a29f4b8 100644
--- a/public/sass/components/_panel_singlestat.scss
+++ b/public/sass/components/_panel_singlestat.scss
@@ -5,7 +5,6 @@
}
.singlestat-panel-value-container {
- padding: 20px;
display: table-cell;
vertical-align: middle;
text-align: center;
diff --git a/public/sass/layout/_page.scss b/public/sass/layout/_page.scss
index 8de65053888..6203f4be083 100644
--- a/public/sass/layout/_page.scss
+++ b/public/sass/layout/_page.scss
@@ -4,7 +4,7 @@
}
.main-view {
- height: 100%;
+ // height: 100%; REMOVED FOR FOOTER TRW
}
.page-container {
diff --git a/public/test/core/time_series_specs.js b/public/test/core/time_series_specs.js
index 9d273c86b94..034e872e2f1 100644
--- a/public/test/core/time_series_specs.js
+++ b/public/test/core/time_series_specs.js
@@ -56,7 +56,7 @@ define([
});
});
- describe('can detect if serie contains ms precision', function() {
+ describe('can detect if series contains ms precision', function() {
var fakedata;
beforeEach(function() {
@@ -64,13 +64,13 @@ define([
});
it('missing datapoint with ms precision', function() {
- fakedata.datapoints[0] = [1234567890000, 1337];
+ fakedata.datapoints[0] = [1337, 1234567890000];
series = new TimeSeries(fakedata);
expect(series.isMsResolutionNeeded()).to.be(false);
});
it('contains datapoint with ms precision', function() {
- fakedata.datapoints[0] = [1236547890001, 1337];
+ fakedata.datapoints[0] = [1337, 1236547890001];
series = new TimeSeries(fakedata);
expect(series.isMsResolutionNeeded()).to.be(true);
});
diff --git a/public/test/core/utils/kbn_specs.js b/public/test/core/utils/kbn_specs.js
index 7e75e880546..0a2ad165253 100644
--- a/public/test/core/utils/kbn_specs.js
+++ b/public/test/core/utils/kbn_specs.js
@@ -147,5 +147,11 @@ define([
var str = kbn.calculateInterval(range, 1000, '>10s');
expect(str).to.be('20m');
});
+
+ it('10s 900 resolution and user low limit in ms', function() {
+ var range = { from: dateMath.parse('now-10s'), to: dateMath.parse('now') };
+ var str = kbn.calculateInterval(range, 900, '>15ms');
+ expect(str).to.be('15ms');
+ });
});
});
diff --git a/public/test/specs/dashboardViewStateSrv-specs.js b/public/test/specs/dashboardViewStateSrv-specs.js
index b33c7156392..202a43670b1 100644
--- a/public/test/specs/dashboardViewStateSrv-specs.js
+++ b/public/test/specs/dashboardViewStateSrv-specs.js
@@ -5,8 +5,20 @@ define([
describe('when updating view state', function() {
var viewState, location;
+ var timeSrv = {};
+ var templateSrv = {};
+ var contextSrv = {
+ user: {
+ orgId: 19
+ }
+ };
beforeEach(module('grafana.services'));
+ beforeEach(module(function($provide) {
+ $provide.value('timeSrv', timeSrv);
+ $provide.value('templateSrv', templateSrv);
+ $provide.value('contextSrv', contextSrv);
+ }));
beforeEach(inject(function(dashboardViewStateSrv, $location, $rootScope) {
$rootScope.onAppEvent = function() {};
@@ -17,9 +29,9 @@ define([
describe('to fullscreen true and edit true', function() {
it('should update querystring and view state', function() {
- var updateState = { fullscreen: true, edit: true, panelId: 1 };
+ var updateState = {fullscreen: true, edit: true, panelId: 1};
viewState.update(updateState);
- expect(location.search()).to.eql(updateState);
+ expect(location.search()).to.eql({fullscreen: true, edit: true, panelId: 1, org: 19});
expect(viewState.dashboard.meta.fullscreen).to.be(true);
expect(viewState.state.fullscreen).to.be(true);
});
@@ -29,7 +41,7 @@ define([
it('should remove params from query string', function() {
viewState.update({fullscreen: true, panelId: 1, edit: true});
viewState.update({fullscreen: false});
- expect(location.search()).to.eql({});
+ expect(location.search()).to.eql({org: 19});
expect(viewState.dashboard.meta.fullscreen).to.be(false);
expect(viewState.state.fullscreen).to.be(null);
});
diff --git a/public/test/specs/templateSrv-specs.js b/public/test/specs/templateSrv-specs.js
index fd7247cbd81..a592cc7a152 100644
--- a/public/test/specs/templateSrv-specs.js
+++ b/public/test/specs/templateSrv-specs.js
@@ -141,8 +141,8 @@ define([
});
it('slash should be properly escaped in regex format', function() {
- var result = _templateSrv.formatValue('Gi3/14', 'regex');
- expect(result).to.be('Gi3\\/14');
+ var result = _templateSrv.formatValue('Gi3/14', 'regex');
+ expect(result).to.be('Gi3\\/14');
});
});
@@ -200,6 +200,15 @@ define([
expect(contains).to.be(true);
});
+ it('should find it when part of segment', function() {
+ var contains = _templateSrv.containsVariable('metrics.$env.$group-*', 'group');
+ expect(contains).to.be(true);
+ });
+
+ it('should find it its the only thing', function() {
+ var contains = _templateSrv.containsVariable('$env', 'env');
+ expect(contains).to.be(true);
+ });
});
describe('updateTemplateData with simple value', function() {
diff --git a/public/test/specs/templateValuesSrv-specs.js b/public/test/specs/templateValuesSrv-specs.js
index 2edcd03da9a..7a8d8c1fccb 100644
--- a/public/test/specs/templateValuesSrv-specs.js
+++ b/public/test/specs/templateValuesSrv-specs.js
@@ -126,6 +126,80 @@ define([
});
});
+ describeUpdateVariable('query variable with multi select and new options does not contain some selected values', function(scenario) {
+ scenario.setup(function() {
+ scenario.variable = {
+ type: 'query',
+ query: '',
+ name: 'test',
+ current: {
+ value: ['val1', 'val2', 'val3'],
+ text: 'val1 + val2 + val3'
+ }
+ };
+ scenario.queryResult = [{text: 'val2'}, {text: 'val3'}];
+ });
+
+ it('should update current value', function() {
+ expect(scenario.variable.current.value).to.eql(['val2', 'val3']);
+ expect(scenario.variable.current.text).to.eql('val2 + val3');
+ });
+ });
+
+ describeUpdateVariable('query variable with multi select and new options does not contain any selected values', function(scenario) {
+ scenario.setup(function() {
+ scenario.variable = {
+ type: 'query',
+ query: '',
+ name: 'test',
+ current: {
+ value: ['val1', 'val2', 'val3'],
+ text: 'val1 + val2 + val3'
+ }
+ };
+ scenario.queryResult = [{text: 'val5'}, {text: 'val6'}];
+ });
+
+ it('should update current value with first one', function() {
+ expect(scenario.variable.current.value).to.eql('val5');
+ expect(scenario.variable.current.text).to.eql('val5');
+ });
+ });
+
+ describeUpdateVariable('query variable with multi select and $__all selected', function(scenario) {
+ scenario.setup(function() {
+ scenario.variable = {
+ type: 'query',
+ query: '',
+ name: 'test',
+ includeAll: true,
+ current: {
+ value: ['$__all'],
+ text: 'All'
+ }
+ };
+ scenario.queryResult = [{text: 'val5'}, {text: 'val6'}];
+ });
+
+ it('should keep current All value', function() {
+ expect(scenario.variable.current.value).to.eql(['$__all']);
+ expect(scenario.variable.current.text).to.eql('All');
+ });
+ });
+
+ describeUpdateVariable('query variable with numeric results', function(scenario) {
+ scenario.setup(function() {
+ scenario.variable = { type: 'query', query: '', name: 'test', current: {} };
+ scenario.queryResult = [{text: 12, value: 12}];
+ });
+
+ it('should set current value to first option', function() {
+ expect(scenario.variable.current.value).to.be('12');
+ expect(scenario.variable.options[0].value).to.be('12');
+ expect(scenario.variable.options[0].text).to.be('12');
+ });
+ });
+
describeUpdateVariable('interval variable without auto', function(scenario) {
scenario.setup(function() {
scenario.variable = { type: 'interval', query: '1s,2h,5h,1d', name: 'test' };
diff --git a/public/views/index.html b/public/views/index.html
index c4bffae5019..70981fb7784 100644
--- a/public/views/index.html
+++ b/public/views/index.html
@@ -39,6 +39,41 @@