mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Deprecated derivequeries
This commit is contained in:
parent
6a93e72a34
commit
d0f7881dd7
@ -1,23 +1 @@
|
||||
<div>
|
||||
<div class="row-fluid">
|
||||
<div class="span1">
|
||||
<label class="small">Length</label>
|
||||
<input type="number" style="width:80%" ng-model="panel.size" ng-change="set_refresh(true)">
|
||||
</div>
|
||||
<div class="span3">
|
||||
<label class="small">Field</label>
|
||||
<input type="text" bs-typeahead="fields.list" style="width:80%" ng-change="set_refresh(true)" ng-model='panel.field'></select>
|
||||
</div>
|
||||
<div class="span3">
|
||||
<label class="small">Query Mode</label>
|
||||
<select style="width:80%" ng-change="set_refresh(true)" ng-model='panel.mode' ng-options="f for f in ['terms only','AND', 'OR']"></select>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<label class="small">Exclude Terms(s) (comma seperated)</label>
|
||||
<input array-join type="text" style="width:90%" ng-change="set_refresh(true)" ng-model='panel.exclude'></input>
|
||||
</div>
|
||||
<div class="span1">
|
||||
<label class="small"> Rest </label><input type="checkbox" ng-model="panel.rest" ng-checked="panel.rest" ng-change="set_refresh(true)">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div></div>
|
@ -1,33 +1,3 @@
|
||||
<div ng-controller='derivequeries' ng-init="init()">
|
||||
<style>
|
||||
.end-derive {
|
||||
position:absolute;
|
||||
right:15px;
|
||||
top:5px;
|
||||
}
|
||||
.panel-derive-field {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
.panel-derive {
|
||||
padding-right: 35px !important;
|
||||
height: 31px !important;
|
||||
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
||||
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
||||
box-sizing: border-box; /* Opera/IE 8+ */
|
||||
}
|
||||
</style>
|
||||
<label class="small">Create new queries from
|
||||
<span class="panel-derive-field" ng-show="!editing" ng-click="editing=true">{{panel.field}}</span>
|
||||
<select ng-show="editing && fields.list.length>1" class="input-medium" ng-model="panel.field" ng-options="f for f in fields.list" ng-change='editing=false' ng-blur="editing=false"></select>
|
||||
<input ng-show="editing && fields.list.length<2" type="text" ng-model="panel.field" ng-blur="editing=false"/>
|
||||
({{panel.mode}} mode)</label>
|
||||
<div>
|
||||
<form class="form-search" style="position:relative" ng-submit="get_data()">
|
||||
<input class="search-query panel-derive input-block-level" bs-typeahead="panel.history" data-min-length=0 data-items=100 type="text" ng-model="panel.query"/>
|
||||
<span class="end-derive">
|
||||
<i class="icon-search pointer" ng-click="get_data()"></i>
|
||||
</span
|
||||
</form>
|
||||
</div>
|
||||
<h4>This panel has been removed and replaced with the new topN query type. Click the colored dot associated with a query to configure the, much improved, equivilent of a derived query.</h4>
|
||||
</div>
|
@ -22,21 +22,10 @@ function (angular, app, _) {
|
||||
var module = angular.module('kibana.panels.derivequeries', []);
|
||||
app.useModule(module);
|
||||
|
||||
module.controller('derivequeries', function($scope, $rootScope, querySrv, fields, dashboard, filterSrv) {
|
||||
module.controller('derivequeries', function($scope) {
|
||||
$scope.panelMeta = {
|
||||
modals : [
|
||||
{
|
||||
description: "Inspect",
|
||||
icon: "icon-info-sign",
|
||||
partial: "app/partials/inspector.html",
|
||||
show: $scope.panel.spyable
|
||||
}
|
||||
],
|
||||
status : "Experimental",
|
||||
description : "Creates a new set of queries using the Elasticsearch terms facet. For example,"+
|
||||
" you might want to create 5 queries showing the most frequent HTTP response codes. Be "+
|
||||
"careful not to select a high cardinality field, as Elasticsearch must load all unique values"+
|
||||
" into memory."
|
||||
status : "Deprecated",
|
||||
description : "This panel has been replaced with the 'topN' mode in the query pull down."
|
||||
};
|
||||
|
||||
// Set and populate defaults
|
||||
@ -59,102 +48,6 @@ function (angular, app, _) {
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.editing = false;
|
||||
$scope.panel.fields = fields.list;
|
||||
};
|
||||
|
||||
$scope.get_data = function() {
|
||||
update_history($scope.panel.query);
|
||||
|
||||
// Make sure we have everything for the request to complete
|
||||
if(dashboard.indices.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.panelMeta.loading = true;
|
||||
var request = $scope.ejs.Request().indices(dashboard.indices);
|
||||
|
||||
// Terms mode
|
||||
request = request
|
||||
.facet($scope.ejs.TermsFacet('query')
|
||||
.field($scope.panel.field)
|
||||
.size($scope.panel.size)
|
||||
.exclude($scope.panel.exclude)
|
||||
.facetFilter($scope.ejs.QueryFilter(
|
||||
$scope.ejs.FilteredQuery(
|
||||
$scope.ejs.QueryStringQuery($scope.panel.query || '*'),
|
||||
filterSrv.getBoolFilter(filterSrv.ids)
|
||||
)))).size(0);
|
||||
|
||||
$scope.populate_modal(request);
|
||||
|
||||
var results = request.doSearch();
|
||||
|
||||
// Populate scope when we have results
|
||||
results.then(function(results) {
|
||||
$scope.panelMeta.loading = false;
|
||||
var suffix;
|
||||
if ($scope.panel.query === '' || $scope.panel.mode === 'terms only') {
|
||||
suffix = '';
|
||||
} else if ($scope.panel.mode === 'AND') {
|
||||
suffix = ' AND (' + $scope.panel.query + ')';
|
||||
} else if ($scope.panel.mode === 'OR') {
|
||||
suffix = ' OR (' + $scope.panel.query + ')';
|
||||
}
|
||||
var ids = [];
|
||||
var terms = results.facets.query.terms;
|
||||
var others = [];
|
||||
_.each(terms, function(v) {
|
||||
var _q = $scope.panel.field+':"'+v.term+'"'+suffix;
|
||||
// if it isn't in the list, remove it
|
||||
var _iq = querySrv.findQuery(_q);
|
||||
if(!_iq) {
|
||||
ids.push(querySrv.set({alias: v.term, query:_q}));
|
||||
} else {
|
||||
ids.push(_iq.id);
|
||||
}
|
||||
others.push("NOT (" + _q + ")");
|
||||
});
|
||||
if ($scope.panel.rest) {
|
||||
var _other_q = others.join(' AND ');
|
||||
var _iq = querySrv.findQuery(_other_q);
|
||||
if (!_iq) {
|
||||
ids.push(querySrv.set({alias: 'other', query: _other_q}));
|
||||
} else {
|
||||
ids.push(_iq.id);
|
||||
}
|
||||
}
|
||||
_.each(_.difference($scope.panel.ids,ids),function(id){
|
||||
querySrv.remove(id);
|
||||
});
|
||||
$scope.panel.ids = ids;
|
||||
dashboard.refresh();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.set_refresh = function (state) {
|
||||
$scope.refresh = state;
|
||||
};
|
||||
|
||||
$scope.close_edit = function() {
|
||||
if($scope.refresh) {
|
||||
$scope.get_data();
|
||||
}
|
||||
$scope.refresh = false;
|
||||
};
|
||||
|
||||
$scope.populate_modal = function(request) {
|
||||
$scope.inspector = angular.toJson(JSON.parse(request.toString()),true);
|
||||
};
|
||||
|
||||
var update_history = function(query) {
|
||||
query = _.isArray(query) ? query : [query];
|
||||
if($scope.panel.remember > 0) {
|
||||
$scope.panel.history = _.union(query.reverse(),$scope.panel.history);
|
||||
var _length = $scope.panel.history.length;
|
||||
if(_length > $scope.panel.remember) {
|
||||
$scope.panel.history = $scope.panel.history.slice(0,$scope.panel.remember);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user