Added conditions management

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