Added conditions management

parent 72ab721f
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
<li ng-hide="target.rawQuery"> <li ng-hide="target.rawQuery">
<input type="text" <input type="text"
class="input-medium grafana-target-segment-input" class="input-small grafana-target-segment-input"
ng-model="target.series" ng-model="target.series"
spellcheck='false' spellcheck='false'
bs-typeahead="listSeries" bs-typeahead="listSeries"
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<li ng-hide="target.rawQuery"> <li ng-hide="target.rawQuery">
<input type="text" <input type="text"
class="input-medium grafana-target-segment-input" class="input-small grafana-target-segment-input"
ng-model="target.column" ng-model="target.column"
placeholder="value column" placeholder="value column"
spellcheck='false' spellcheck='false'
...@@ -85,25 +85,43 @@ ...@@ -85,25 +85,43 @@
function function
</li> </li>
<li ng-hide="target.rawQuery"> <li ng-hide="target.rawQuery">
<select class="input-medium 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 class="grafana-target-segment"> <li ng-hide="target.rawQuery">
condition <a class="grafana-target-segment"
ng-click="target.condiction_filter = !target.condiction_filter; get_data();"
role="menuitem">
<i class="icon-filter"></i>
</a>
</li> </li>
<li> <li ng-hide="target.rawQuery" ng-show="target.condiction_filter">
<select class="input-small grafana-target-segment-input"
ng-change="get_data()"
ng-model="target.condition_add"
ng-options="f for f in ['and', 'or']" ></select>
<input type="text" <input type="text"
class="input-medium grafana-target-segment-input" class="input-small grafana-target-segment-input"
ng-model="target.condition" ng-model="target.condition_key"
placeholder="value condition" placeholder="key"
spellcheck='false' spellcheck='false'
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"
ng-change="get_data()"
ng-model="target.condition_op"
ng-options="f for f in operators" ></select>
<input type="text"
class="input-small grafana-target-segment-input"
ng-model="target.condition_value"
placeholder="value"
spellcheck='false'
data-min-length=0
ng-blur="get_data()">
</li> </li>
<li class="grafana-target-segment" ng-hide="target.rawQuery"> <li class="grafana-target-segment" ng-hide="target.rawQuery">
group by time group by time
</li> </li>
......
...@@ -72,17 +72,19 @@ function (angular, _, kbn) { ...@@ -72,17 +72,19 @@ function (angular, _, kbn) {
} }
else { else {
var template = "select [[func]]([[column]]) as [[column]]_[[func]] from [[series]] " + var template = "select [[func]]([[column]]) as [[column]]_[[func]] from [[series]] " +
"where [[condition]] [[timeFilter]]" + "where [[timeFilter]] [[condition_add]] [[condition_key]] [[condition_op]] [[condition_value]] " +
" group by time([[interval]]) order asc"; "group by time([[interval]]) order asc";
target.condition_joined = (target.condition !== undefined ? target.condition + ' AND ' : '');
var templateData = { var templateData = {
series: target.series, series: target.series,
column: target.column, column: target.column,
func: target.function, func: target.function,
timeFilter: timeFilter, timeFilter: timeFilter,
interval: target.interval || options.interval interval: target.interval || options.interval,
condition_add: target.condiction_filter ? target.condition_add : '',
condition_key: target.condiction_filter ? target.condition_key : '',
condition_op: target.condiction_filter ? target.condition_op : '',
condition_value: target.condiction_filter ? target.condition_value: ''
}; };
query = _.template(template, templateData, this.templateSettings); query = _.template(template, templateData, this.templateSettings);
...@@ -159,12 +161,6 @@ function (angular, _, kbn) { ...@@ -159,12 +161,6 @@ function (angular, _, kbn) {
function handleInfluxQueryResponse(data) { function handleInfluxQueryResponse(data) {
var output = []; 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(data, function(series) { _.each(data, function(series) {
var timeCol = series.columns.indexOf('time'); var timeCol = series.columns.indexOf('time');
......
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