Skip to content

Commit a7d7f31

Browse files
committed
Merge branch 'master' of github.com:grafana/grafana
2 parents 16847fd + 28e7f0f commit a7d7f31

File tree

10 files changed

+64
-20
lines changed

10 files changed

+64
-20
lines changed

docs/sources/reference/table_panel.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ page_keywords: grafana, table, panel, documentation
99
<img src="/img/v2/table-panel.png">
1010

1111
The new table panel is very flexible, supporting both multiple modes for time series as well as for
12-
table, annotation and raw JSON data. It also provides date formating and value formating and coloring options.
12+
table, annotation and raw JSON data. It also provides date formatting and value formatting and coloring options.
1313

1414
To view table panels in action and test different configurations with sample data, check out the [Table Panel Showcase in the Grafana Playground](http://play.grafana.org/dashboard/db/table-panel-showcase).
1515

@@ -21,7 +21,7 @@ The table panel has many ways to manipulate your data for optimal presentation.
2121

2222
1. `Data`: Control how your query is transformed into a table.
2323
2. `Table Display`: Table display options.
24-
3. `Column Styles`: Column value formating and display options.
24+
3. `Column Styles`: Column value formatting and display options.
2525

2626
## Data to Table
2727

public/app/core/utils/kbn.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ function($, _) {
399399
// Volume
400400
kbn.valueFormats.litre = kbn.formatBuilders.decimalSIPrefix('L');
401401
kbn.valueFormats.mlitre = kbn.formatBuilders.decimalSIPrefix('L', -1);
402+
kbn.valueFormats.m3 = kbn.formatBuilders.decimalSIPrefix('m3');
402403

403404
// Time
404405
kbn.valueFormats.hertz = kbn.formatBuilders.decimalSIPrefix('Hz');
@@ -626,8 +627,9 @@ function($, _) {
626627
{
627628
text: 'volume',
628629
submenu: [
629-
{text: 'millilitre', value: 'mlitre'},
630-
{text: 'litre', value: 'litre' },
630+
{text: 'millilitre', value: 'mlitre'},
631+
{text: 'litre', value: 'litre' },
632+
{text: 'cubic metre', value: 'm3' },
631633
]
632634
},
633635
{

public/app/features/dashboard/dashboardSrv.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,22 @@ function (angular, $, _, moment) {
214214
};
215215

216216
p.formatDate = function(date, format) {
217-
if (!moment.isMoment(date)) {
218-
date = moment(date);
219-
}
220-
217+
date = moment.isMoment(date) ? date : moment(date);
221218
format = format || 'YYYY-MM-DD HH:mm:ss';
222219

223220
return this.timezone === 'browser' ?
224221
moment(date).format(format) :
225222
moment.utc(date).format(format);
226223
};
227224

225+
p.getRelativeTime = function(date) {
226+
date = moment.isMoment(date) ? date : moment(date);
227+
228+
return this.timezone === 'browser' ?
229+
moment(date).fromNow() :
230+
moment.utc(date).fromNow();
231+
};
232+
228233
p._updateSchema = function(old) {
229234
var i, j, k;
230235
var oldVersion = this.schemaVersion;

public/app/features/dashboard/partials/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ <h5>Rows settings</h5>
117117
<div ng-if="editor.index == 4">
118118
<div class="editor-row">
119119
<div class="tight-form-section">
120-
<h5>Info</h5>
120+
<h5>Dashboard info</h5>
121121
<div class="tight-form">
122122
<ul class="tight-form-list">
123123
<li class="tight-form-item" style="width: 120px">

public/app/features/panel/panel_helper.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ function (angular, _, $, kbn, dateMath, rangeUtil) {
5959
scope.resolution = Math.ceil($(window).width() * (scope.panel.span / 12));
6060
}
6161

62-
scope.interval = kbn.calculateInterval(scope.range, scope.resolution, scope.panel.interval);
62+
var panelInterval = scope.panel.interval;
63+
var datasourceInterval = (scope.datasource || {}).interval;
64+
scope.interval = kbn.calculateInterval(scope.range, scope.resolution, panelInterval || datasourceInterval);
6365
};
6466

6567
this.applyPanelTimeOverrides = function(scope) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
2626
this.timeField = datasource.jsonData.timeField;
2727
this.esVersion = datasource.jsonData.esVersion;
2828
this.indexPattern = new IndexPattern(datasource.index, datasource.jsonData.interval);
29+
this.interval = datasource.jsonData.timeInterval;
2930
this.queryBuilder = new ElasticQueryBuilder({
3031
timeField: this.timeField,
3132
esVersion: this.esVersion,

public/app/plugins/datasource/elasticsearch/partials/config.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div ng-include="httpConfigPartialSrc"></div>
22
<br>
33

4-
<h5>Elastic search details</h5>
4+
<h5>Elasticsearch details</h5>
55

66
<div class="tight-form">
77
<ul class="tight-form-list">
@@ -42,3 +42,22 @@ <h5>Elastic search details</h5>
4242
</ul>
4343
<div class="clearfix"></div>
4444
</div>
45+
</div>
46+
47+
<h5>Default query settings</h5>
48+
49+
<div class="tight-form last">
50+
<ul class="tight-form-list">
51+
<li class="tight-form-item" style="width: 200px">
52+
Group by time interval
53+
</li>
54+
<li>
55+
<input type="text" class="input-medium tight-form-input input-xlarge" ng-model="current.jsonData.timeInterval"
56+
spellcheck='false' placeholder="example: >10s">
57+
</li>
58+
<li class="tight-form-item">
59+
<i class="fa fa-question-circle" bs-tooltip="'Set a low limit by having a greater sign: example: >10s'" data-placement="right"></i>
60+
</li>
61+
</ul>
62+
<div class="clearfix"></div>
63+
</div>

public/app/plugins/datasource/graphite/gfunc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ function (_, $) {
279279

280280
addFuncDef({
281281
name: 'sortByName',
282-
category: categories.Special
282+
category: categories.Special,
283+
params: [{ name: "natural", type: "select", options: ["true", "false"], optional: true }],
284+
defaultParams: ["false"]
283285
});
284286

285287
addFuncDef({

public/app/plugins/datasource/graphite/partials/query.editor.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
<li class="tight-form-item small" ng-show="target.datasource">
99
<em>{{target.datasource}}</em>
1010
</li>
11+
<li class="tight-form-item">
12+
<a class="pointer" tabindex="1" ng-click="toggleEditorMode()">
13+
<i class="fa fa-pencil"></i>
14+
</a>
15+
</li>
1116
<li class="tight-form-item">
1217
<div class="dropdown">
1318
<a class="pointer dropdown-toggle" data-toggle="dropdown" tabindex="1">
@@ -49,7 +54,9 @@
4954
</li>
5055
</ul>
5156

52-
<input type="text" class="tight-form-clear-input span10" ng-model="target.target" give-focus="target.textEditor" spellcheck='false' ng-model-onblur ng-change="get_data()" ng-show="target.textEditor"></input>
57+
<span style="display: block; overflow: hidden;">
58+
<input type="text" class="tight-form-clear-input" style="width: 100%;" ng-model="target.target" give-focus="target.textEditor" spellcheck='false' ng-model-onblur ng-change="get_data()" ng-show="target.textEditor"></input>
59+
</span>
5360

5461
<ul class="tight-form-list" role="menu" ng-hide="target.textEditor">
5562
<li ng-repeat="segment in segments" role="menuitem">

public/app/plugins/panels/graph/graph.tooltip.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ function ($) {
3131
return j - 1;
3232
};
3333

34-
this.showTooltip = function(title, innerHtml, pos) {
35-
var body = '<div class="graph-tooltip small"><div class="graph-tooltip-time">'+ title + '</div> ' ;
34+
this.showTooltip = function(absoluteTime, relativeTime, innerHtml, pos) {
35+
var body = '<div class="graph-tooltip small"><div class="graph-tooltip-time">'+ absoluteTime + '<br>(' + relativeTime + ')</div> ' ;
3636
body += innerHtml + '</div>';
3737
$tooltip.html(body).place_tt(pos.pageX + 20, pos.pageY);
3838
};
@@ -106,7 +106,7 @@ function ($) {
106106
var plot = elem.data().plot;
107107
var plotData = plot.getData();
108108
var seriesList = getSeriesFn();
109-
var group, value, timestamp, hoverInfo, i, series, seriesHtml;
109+
var group, value, absoluteTime, relativeTime, hoverInfo, i, series, seriesHtml;
110110

111111
if(dashboard.sharedCrosshair){
112112
scope.appEvent('setCrosshair', { pos: pos, scope: scope });
@@ -122,7 +122,9 @@ function ($) {
122122
var seriesHoverInfo = self.getMultiSeriesPlotHoverInfo(plotData, pos);
123123

124124
seriesHtml = '';
125-
timestamp = dashboard.formatDate(seriesHoverInfo.time);
125+
126+
relativeTime = dashboard.getRelativeTime(seriesHoverInfo.time);
127+
absoluteTime = dashboard.formatDate(seriesHoverInfo.time);
126128

127129
for (i = 0; i < seriesHoverInfo.length; i++) {
128130
hoverInfo = seriesHoverInfo[i];
@@ -132,6 +134,7 @@ function ($) {
132134
}
133135

134136
series = seriesList[i];
137+
135138
value = series.formatValue(hoverInfo.value);
136139

137140
seriesHtml += '<div class="graph-tooltip-list-item"><div class="graph-tooltip-series-name">';
@@ -140,7 +143,7 @@ function ($) {
140143
plot.highlight(i, hoverInfo.hoverIndex);
141144
}
142145

143-
self.showTooltip(timestamp, seriesHtml, pos);
146+
self.showTooltip(absoluteTime, relativeTime, seriesHtml, pos);
144147
}
145148
// single series tooltip
146149
else if (item) {
@@ -156,10 +159,13 @@ function ($) {
156159
}
157160

158161
value = series.formatValue(value);
159-
timestamp = dashboard.formatDate(item.datapoint[0]);
162+
163+
relativeTime = dashboard.getRelativeTime(item.datapoint[0]);
164+
absoluteTime = dashboard.formatDate(item.datapoint[0]);
165+
160166
group += '<div class="graph-tooltip-value">' + value + '</div>';
161167

162-
self.showTooltip(timestamp, group, pos);
168+
self.showTooltip(absoluteTime, relativeTime, group, pos);
163169
}
164170
// no hit
165171
else {

0 commit comments

Comments
 (0)