Commit 2f58aa28 by Torkel Ödegaard

Review and small refactoring of PR #331

parent 66db99fa
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
- Added rounding for graphites from and to time range filters - Added rounding for graphites from and to time range filters
for very short absolute ranges (Issue #320) for very short absolute ranges (Issue #320)
- Increased resolution for graphite datapoints (maxDataPoints), now equal to panel pixel width. (Closes #5) - Increased resolution for graphite datapoints (maxDataPoints), now equal to panel pixel width. (Closes #5)
- Improvement to influxdb query editor, can now add where clause and alias (Issue #331, thanks @mavimo)
# 1.5.3 (2014-04-17) # 1.5.3 (2014-04-17)
- Add support for async scripted dashboards (Issue #274) - Add support for async scripted dashboards (Issue #274)
......
...@@ -41,33 +41,23 @@ ...@@ -41,33 +41,23 @@
</li> </li>
</ul> </ul>
<input type="text"
class="grafana-target-text-input span10"
ng-model="target.query"
placeholder="select ..."
focus-me="target.rawQuery"
spellcheck='false'
data-min-length=0 data-items=100
ng-model-onblur
ng-blur="get_data()"
ng-show="target.rawQuery">
<ul class="grafana-segment-list" role="menu"> <ul class="grafana-segment-list" role="menu" ng-hide="target.rawQuery">
<li ng-show="target.rawQuery"> <li class="grafana-target-segment">
<input type="text"
class="input-large grafana-target-segment-input span10"
ng-model="target.query"
placeholder="select ..."
data-min-length=0 data-items=100
ng-blur="get_data()">
</li>
<li class="grafana-target-segment" ng-hide="target.rawQuery">
label
</li>
<li ng-hide="target.rawQuery">
<input type="text"
class="input-small grafana-target-segment-input"
ng-model="target.label"
spellcheck='false'
placeholder="label"
ng-blur="seriesBlur()">
</li>
<li class="grafana-target-segment" ng-hide="target.rawQuery">
from series from series
</li> </li>
<li ng-hide="target.rawQuery"> <li>
<input type="text" <input type="text"
class="input-small grafana-target-segment-input" class="input-small grafana-target-segment-input"
ng-model="target.series" ng-model="target.series"
...@@ -78,11 +68,11 @@ ...@@ -78,11 +68,11 @@
ng-blur="seriesBlur()"> ng-blur="seriesBlur()">
</li> </li>
<li class="grafana-target-segment" ng-hide="target.rawQuery"> <li class="grafana-target-segment">
select select
</li> </li>
<li ng-hide="target.rawQuery"> <li>
<input type="text" <input type="text"
class="input-small grafana-target-segment-input" class="input-small grafana-target-segment-input"
ng-model="target.column" ng-model="target.column"
...@@ -93,23 +83,23 @@ ...@@ -93,23 +83,23 @@
ng-blur="get_data()"> ng-blur="get_data()">
</li> </li>
<li class="grafana-target-segment" ng-hide="target.rawQuery"> <li class="grafana-target-segment">
function function
</li> </li>
<li ng-hide="target.rawQuery"> <li>
<select class="input-small grafana-target-segment-input" <select class="input-small grafana-target-segment-input"
ng-change="get_data()" ng-change="get_data()"
ng-model="target.function" ng-model="target.function"
ng-options="f for f in functions" ></select> ng-options="f for f in functions" ></select>
</li> </li>
<li ng-hide="target.rawQuery"> <li>
<a class="grafana-target-segment" <a class="grafana-target-segment"
ng-click="target.condiction_filter = !target.condiction_filter; get_data();" ng-click="target.condiction_filter = !target.condiction_filter; get_data();"
role="menuitem"> role="menuitem">
<i class="icon-filter"></i> <i class="icon-filter"></i>
</a> </a>
</li> </li>
<li ng-hide="target.rawQuery" ng-show="target.condiction_filter"> <li ng-show="target.condiction_filter">
<select class="input-small grafana-target-segment-input" <select class="input-small grafana-target-segment-input"
ng-change="get_data()" ng-change="get_data()"
ng-model="target.condition_add" ng-model="target.condition_add"
...@@ -122,7 +112,7 @@ ...@@ -122,7 +112,7 @@
bs-typeahead="listColumns" bs-typeahead="listColumns"
data-min-length=0 data-min-length=0
ng-blur="get_data()"> ng-blur="get_data()">
<select class="input-small grafana-target-segment-input" <select class="input-mini grafana-target-segment-input"
ng-change="get_data()" ng-change="get_data()"
ng-model="target.condition_op" ng-model="target.condition_op"
ng-options="f for f in operators" ></select> ng-options="f for f in operators" ></select>
...@@ -134,11 +124,11 @@ ...@@ -134,11 +124,11 @@
data-min-length=0 data-min-length=0
ng-blur="get_data()"> ng-blur="get_data()">
</li> </li>
<li class="grafana-target-segment" ng-hide="target.rawQuery"> <li class="grafana-target-segment">
group by time group by time
</li> </li>
<li ng-hide="target.rawQuery"> <li>
<input type="text" <input type="text"
class="input-mini grafana-target-segment-input" class="input-mini grafana-target-segment-input"
ng-model="target.interval" ng-model="target.interval"
...@@ -147,6 +137,19 @@ ...@@ -147,6 +137,19 @@
spellcheck='false' spellcheck='false'
ng-model-onblur ng-change="get_data()" > ng-model-onblur ng-change="get_data()" >
</li> </li>
<li class="grafana-target-segment">
alias as
</li>
<li>
<input type="text"
class="input-small grafana-target-segment-input"
ng-model="target.alias"
spellcheck='false'
placeholder="alias"
ng-blur="seriesBlur()">
</li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>
......
...@@ -82,7 +82,7 @@ function (angular, _, kbn) { ...@@ -82,7 +82,7 @@ function (angular, _, kbn) {
target.query = query; target.query = query;
} }
return this.doInfluxRequest(query, target.label).then(handleInfluxQueryResponse); return this.doInfluxRequest(query, target.alias).then(handleInfluxQueryResponse);
}, this); }, this);
...@@ -121,7 +121,7 @@ function (angular, _, kbn) { ...@@ -121,7 +121,7 @@ function (angular, _, kbn) {
}); });
} }
InfluxDatasource.prototype.doInfluxRequest = function(query, label) { InfluxDatasource.prototype.doInfluxRequest = function(query, alias) {
var _this = this; var _this = this;
var deferred = $q.defer(); var deferred = $q.defer();
...@@ -142,7 +142,7 @@ function (angular, _, kbn) { ...@@ -142,7 +142,7 @@ function (angular, _, kbn) {
}; };
return $http(options).success(function (data) { return $http(options).success(function (data) {
data.label = label; data.alias = alias;
deferred.resolve(data); deferred.resolve(data);
}); });
}, 10); }, 10);
...@@ -161,7 +161,7 @@ function (angular, _, kbn) { ...@@ -161,7 +161,7 @@ function (angular, _, kbn) {
return; return;
} }
var target = data.label || series.name + "." + column; var target = data.alias || series.name + "." + column;
var datapoints = []; var datapoints = [];
for(var i = 0; i < series.points.length; i++) { for(var i = 0; i < series.points.length; i++) {
......
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