Commit 9b4c6429 by Clicky

Hookup additional group by into UI

Allow additional group by fields to be specified without writing a full
on influx query by hand.
parent 4a4708e3
......@@ -3,4 +3,5 @@ node_modules
dist
web.config
config.js
*.sublime-workspace
\ No newline at end of file
*.sublime-workspace
*.swp
......@@ -76,7 +76,7 @@
<input type="text"
class="input-small grafana-target-segment-input"
ng-model="target.column"
placeholder="value column"
placeholder="value"
spellcheck='false'
bs-typeahead="listColumns"
data-min-length=0
......@@ -137,6 +137,24 @@
spellcheck='false'
ng-model-onblur ng-change="get_data()" >
</li>
<li>
<a class="grafana-target-segment"
ng-click="target.groupby_field_add = !target.groupby_field_add; get_data();"
role="menuitem">
<i class="icon-plus"></i>
</a>
</li>
<li ng-show="target.groupby_field_add">
<input type="text"
class="input-small grafana-target-segment-input"
ng-model="target.groupby_field"
placeholder="column"
spellcheck="false"
bs-typeahead="listColumns"
data-min-length=0
ng-blur="get_data()">
</li>
<li class="grafana-target-segment">
alias as
......
......@@ -73,14 +73,14 @@ function (angular, _, kbn) {
query = queryElements.join(" ");
}
else {
var template = "select [[func]]([[column]]) as [[column]]_[[func]] from [[series]] " +
var template = "select [[group]][[group_add]] [[func]]([[column]]) as [[column]]_[[func]] from [[series]] " +
"where [[timeFilter]] [[condition_add]] [[condition_key]] [[condition_op]] [[condition_value]] " +
"group by time([[interval]]) order asc";
"group by time([[interval]])[[group_add]] [[group]] order asc";
if (target.column.indexOf('-') !== -1 || target.column.indexOf('.') !== -1) {
template = "select [[func]](\"[[column]]\") as \"[[column]]_[[func]]\" from [[series]] " +
template = "select [[group]][[group_add]] [[func]](\"[[column]]\") as \"[[column]]_[[func]]\" from [[series]] " +
"where [[timeFilter]] [[condition_add]] [[condition_key]] [[condition_op]] [[condition_value]] " +
"group by time([[interval]]) order asc";
"group by time([[interval]])[[group_add]] [[group]] order asc";
}
var templateData = {
......@@ -92,9 +92,14 @@ function (angular, _, kbn) {
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: ''
condition_value: target.condiction_filter ? target.condition_value : '',
group_add: target.groupby_field_add && target.groupby_field ? ',' : '',
group: target.groupby_field_add ? target.groupby_field : '',
};
if (target.groupby_field_add) {
additionalGroups.push(target.groupby_field);
}
query = _.template(template, templateData, this.templateSettings);
target.query = query;
}
......
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