mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
feat(tablepanel): fixed header, and pagination styling
This commit is contained in:
parent
0a1af65a4c
commit
7d3146ed8d
@ -4,6 +4,11 @@ export class TableModel {
|
||||
columns: any[];
|
||||
rows: any[];
|
||||
|
||||
constructor() {
|
||||
this.columns = [];
|
||||
this.rows = [];
|
||||
}
|
||||
|
||||
static transform(data, panel) {
|
||||
var model = new TableModel();
|
||||
|
||||
|
@ -170,7 +170,8 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
|
||||
target = options.targets[i];
|
||||
if (target.hide) {return;}
|
||||
|
||||
var esQuery = angular.toJson(this.queryBuilder.build(target));
|
||||
var queryObj = this.queryBuilder.build(target);
|
||||
var esQuery = angular.toJson(queryObj);
|
||||
var luceneQuery = angular.toJson(target.query || '*');
|
||||
// remove inner quotes
|
||||
luceneQuery = luceneQuery.substr(1, luceneQuery.length - 2);
|
||||
@ -185,7 +186,7 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
|
||||
payload = payload.replace(/\$timeTo/g, options.range.to.valueOf());
|
||||
payload = templateSrv.replace(payload, options.scopedVars);
|
||||
|
||||
return this._post('/_msearch?search_type=count', payload).then(function(res) {
|
||||
return this._post('/_msearch', payload).then(function(res) {
|
||||
return new ElasticResponse(sentTargets, res).getTimeSeries();
|
||||
});
|
||||
};
|
||||
|
@ -28,6 +28,7 @@ function (angular, _, queryDef) {
|
||||
$scope.isFirst = $scope.index === 0;
|
||||
$scope.isSingle = metricAggs.length === 1;
|
||||
$scope.settingsLinkText = '';
|
||||
$scope.aggDef = _.findWhere($scope.metricAggTypes, {value: $scope.agg.type});
|
||||
|
||||
if (!$scope.agg.field) {
|
||||
$scope.agg.field = 'select field';
|
||||
@ -53,6 +54,11 @@ function (angular, _, queryDef) {
|
||||
$scope.agg.meta.std_deviation_bounds_lower = true;
|
||||
$scope.agg.meta.std_deviation_bounds_upper = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'raw_document': {
|
||||
$scope.target.metrics = [$scope.agg];
|
||||
$scope.target.bucketAggs = [];
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -65,8 +71,6 @@ function (angular, _, queryDef) {
|
||||
$scope.agg.settings = {};
|
||||
$scope.agg.meta = {};
|
||||
$scope.showOptions = false;
|
||||
|
||||
$scope.validateModel();
|
||||
$scope.onChange();
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<li>
|
||||
<metric-segment-model property="agg.type" options="metricAggTypes" on-change="onTypeChange()" custom="false" css-class="tight-form-item-large"></metric-segment-model>
|
||||
</li>
|
||||
<li ng-if="agg.type !== 'count'">
|
||||
<li ng-if="aggDef.requiresField">
|
||||
<metric-segment-model property="agg.field" get-options="getFieldsInternal()" on-change="onChange()" css-class="tight-form-item-xxlarge"></metric-segment>
|
||||
</li>
|
||||
<li class="tight-form-item last" ng-if="settingsLinkText">
|
||||
|
@ -6,14 +6,15 @@ function (_) {
|
||||
|
||||
return {
|
||||
metricAggTypes: [
|
||||
{text: "Count", value: 'count' },
|
||||
{text: "Average", value: 'avg' },
|
||||
{text: "Sum", value: 'sum' },
|
||||
{text: "Max", value: 'max' },
|
||||
{text: "Min", value: 'min' },
|
||||
{text: "Extended Stats", value: 'extended_stats' },
|
||||
{text: "Percentiles", value: 'percentiles' },
|
||||
{text: "Unique Count", value: "cardinality" }
|
||||
{text: "Count", value: 'count', requiresField: false},
|
||||
{text: "Average", value: 'avg', requiresField: true},
|
||||
{text: "Sum", value: 'sum', requiresField: true},
|
||||
{text: "Max", value: 'max', requiresField: true},
|
||||
{text: "Min", value: 'min', requiresField: true},
|
||||
{text: "Extended Stats", value: 'extended_stats', requiresField: true},
|
||||
{text: "Percentiles", value: 'percentiles', requiresField: true},
|
||||
{text: "Unique Count", value: "cardinality", requiresField: true},
|
||||
{text: "Raw Document", value: "raw_document", requiresField: false}
|
||||
],
|
||||
|
||||
bucketAggTypes: [
|
||||
|
@ -80,4 +80,36 @@ describe('ElasticDatasource', function() {
|
||||
expect(body.query.filtered.query.query_string.query).to.be('escape\\:test');
|
||||
});
|
||||
});
|
||||
|
||||
describe('When issueing document query', function() {
|
||||
var requestOptions, parts, header;
|
||||
|
||||
beforeEach(function() {
|
||||
ctx.ds = new ctx.service({url: 'http://es.com', index: 'test', jsonData: {}});
|
||||
|
||||
ctx.backendSrv.datasourceRequest = function(options) {
|
||||
requestOptions = options;
|
||||
return ctx.$q.when({data: {responses: []}});
|
||||
};
|
||||
|
||||
ctx.ds.query({
|
||||
range: { from: moment([2015, 4, 30, 10]), to: moment([2015, 5, 1, 10]) },
|
||||
targets: [{ bucketAggs: [], metrics: [{type: 'raw_document'}], query: 'test' }]
|
||||
});
|
||||
|
||||
ctx.$rootScope.$apply();
|
||||
parts = requestOptions.data.split('\n');
|
||||
header = angular.fromJson(parts[0]);
|
||||
});
|
||||
|
||||
it('should set search type to query_then_fetch', function() {
|
||||
expect(header.search_type).to.eql('query_then_fetch');
|
||||
});
|
||||
|
||||
it('should set size', function() {
|
||||
var body = angular.fromJson(parts[1]);
|
||||
expect(body.query.size).to.be(500);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user