added support to coustom where conditions

parent 69b91892
......@@ -64,4 +64,4 @@ function (angular) {
});
});
\ No newline at end of file
});
......@@ -74,7 +74,23 @@
function
</li>
<li>
<select class="input-medium grafana-target-segment-input" ng-change="get_data()" ng-model="target.function" ng-options="f for f in ['mean', 'sum', 'min', 'max', 'median', 'derivative', 'stddev']" ></select>
<select class="input-medium grafana-target-segment-input"
ng-change="get_data()"
ng-model="target.function"
ng-options="f for f in functions" ></select>
</li>
<li class="grafana-target-segment">
condition
</li>
<li>
<input type="text"
class="input-medium grafana-target-segment-input"
ng-model="target.condition"
placeholder="value condition"
spellcheck='false'
bs-typeahead="listColumns"
data-min-length=0
ng-blur="get_data()">
</li>
<li class="grafana-target-segment">
group by time
......
......@@ -30,12 +30,16 @@ function (angular, _, kbn) {
return [];
}
var template = "select [[func]]([[column]]) from [[series]] where [[timeFilter]] group by time([[interval]]) order asc";
// var template = "select [[func]]([[column]]) as [[column]]_[[func]] from [[series]] where [[timeFilter]] group by time([[interval]]) order asc";
var template = "select [[func]]([[column]]) from [[series]] where [[condition]] [[timeFilter]] group by time([[interval]]) order asc";
target.condition_joined = (target.condition !== undefined ? target.condition + ' AND ' : '');
var templateData = {
series: target.series,
column: target.column,
func: target.function,
condition: target.condition_joined,
timeFilter: getTimeFilter(options),
interval: target.interval || options.interval
};
......@@ -96,6 +100,12 @@ function (angular, _, kbn) {
function handleInfluxQueryResponse(results) {
var output = [];
var getKey = function (str) {
var key1 = str.split(' where ');
var key2 = key1[1].split(' AND ');
return (key2[0] !== key1[1] ? '.' + key2[0] : '');
}
_.each(results.data, function(series) {
var timeCol = series.columns.indexOf('time');
......@@ -106,7 +116,7 @@ function (angular, _, kbn) {
console.log("series:"+series.name + ": "+series.points.length + " points");
var target = series.name + "." + column;
var target = series.name + "." + column + getKey(results.config.params.q);
var datapoints = [];
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