Commit 9b415050 by Torkel Ödegaard

feat(influxdb): minor progress on new editor

parent c68cd7d1
......@@ -3,11 +3,11 @@ define([
'lodash',
'app/core/utils/datemath',
'./influx_series',
'./query_builder',
'./influx_query',
'./directives',
'./query_ctrl',
],
function (angular, _, dateMath, InfluxSeries, InfluxQueryBuilder) {
function (angular, _, dateMath, InfluxSeries, InfluxQuery) {
'use strict';
var module = angular.module('grafana.services');
......@@ -41,8 +41,9 @@ function (angular, _, dateMath, InfluxSeries, InfluxQueryBuilder) {
queryTargets.push(target);
// build query
var queryBuilder = new InfluxQueryBuilder(target);
var query = queryBuilder.build();
var queryModel = new InfluxQuery(target);
var query = queryModel.render();
console.log(query);
query = query.replace(/\$interval/g, (target.interval || options.interval));
return query;
......
......@@ -18,7 +18,8 @@ class InfluxQuery {
target.tags = target.tags || [];
target.groupBy = target.groupBy || [{type: 'time', interval: 'auto'}];
target.select = target.select || [[
{name: 'mean', params: ['value']},
{name: 'field', params: ['value']},
{name: 'mean', params: []},
]];
this.updateSelectParts();
......
......@@ -87,42 +87,13 @@
<li>
<influx-query-part-editor part="part" class="tight-form-item tight-form-func"></influx-query-part-editor>
</li>
<!-- <li class="dropdown" ng&#45;if="groupBy.type === 'time'"> -->
<!-- <a class="tight&#45;form&#45;item pointer" data&#45;toggle="dropdown" bs&#45;tooltip="'Insert missing values, important when stacking'" data&#45;placement="right"> -->
<!-- <span ng&#45;show="target.fill"> -->
<!-- fill ({{target.fill}}) -->
<!-- </span> -->
<!-- <span ng&#45;show="!target.fill"> -->
<!-- no fill -->
<!-- </span> -->
<!-- </a> -->
<!-- <ul class="dropdown&#45;menu"> -->
<!-- <li><a ng&#45;click="setFill('')">no fill</a></li> -->
<!-- <li><a ng&#45;click="setFill('0')">fill (0)</a></li> -->
<!-- <li><a ng&#45;click="setFill('null')">fill (null)</a></li> -->
<!-- <li><a ng&#45;click="setFill('none')">fill (none)</a></li> -->
<!-- <li><a ng&#45;click="setFill('previous')">fill (previous)</a></li> -->
<!-- </ul> -->
<!-- </li> -->
<!-- <li ng&#45;if="groupBy.type === 'tag'"> -->
<!-- <metric&#45;segment&#45;model property="groupBy.key" get&#45;options="getTagOptions()" on&#45;change="get_data()"></metric&#45;segment> -->
<!-- </li> -->
</ul>
<ul class="tight-form-list pull-right">
<li class="tight-form-item last" ng-show="$index === 0">
<a class="pointer" ng-click="addGroupBy()"><i class="fa fa-plus"></i></a>
</li>
<li class="tight-form-item last" ng-show="$index > 0">
<a class="pointer" ng-click="removeGroupBy($index)"><i class="fa fa-minus"></i></a>
<li class="dropdown" dropdown-typeahead="groupByMenu" dropdown-typeahead-on-select="groupByMenuAction(parts, $item, $subItem)">
</li>
</ul>
<div class="clearfix"></div>
</div>
</div>
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item query-keyword tight-form-align" style="width: 75px;">
......
......@@ -8,6 +8,7 @@ var categories = {
Transformations: [],
Math: [],
Aliasing: [],
Fields: [],
};
class QueryPartDef {
......@@ -65,18 +66,26 @@ function quotedIdentityRenderer(part, innerExpr) {
}
QueryPartDef.register({
name: 'field',
category: categories.Fields,
params: [{type: 'field'}],
defaultParams: ['value'],
renderer: quotedIdentityRenderer,
});
QueryPartDef.register({
name: 'mean',
category: categories.Aggregations,
params: [{type: 'field', quote: 'double'}],
defaultParams: ['value'],
params: [],
defaultParams: [],
renderer: functionRenderer,
});
QueryPartDef.register({
name: 'sum',
category: categories.Aggregations,
params: [{type: 'field', quote: 'double'}],
defaultParams: ['value'],
params: [],
defaultParams: [],
renderer: functionRenderer,
});
......
......@@ -21,7 +21,8 @@ describe.only('InfluxQuery', function() {
measurement: 'cpu',
select: [
[
{name: 'mean', params: ['value']},
{name: 'field', params: ['value']},
{name: 'mean', params: []},
{name: 'math', params: ['/100']},
{name: 'alias', params: ['text']},
]
......
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