mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
white-space cleanse, and added forin flags to a couple files that need to be looked at at a later date.
This commit is contained in:
parent
d778873ba5
commit
389f8aef4d
@ -5,9 +5,9 @@
|
|||||||
// Base modules
|
// Base modules
|
||||||
var modules = [
|
var modules = [
|
||||||
'kibana.services',
|
'kibana.services',
|
||||||
'kibana.controllers',
|
'kibana.controllers',
|
||||||
'kibana.filters',
|
'kibana.filters',
|
||||||
'kibana.directives',
|
'kibana.directives',
|
||||||
'elasticjs.service',
|
'elasticjs.service',
|
||||||
'$strap.directives',
|
'$strap.directives',
|
||||||
'kibana.panels',
|
'kibana.panels',
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('kibana.controllers', [])
|
angular.module('kibana.controllers', [])
|
||||||
.controller('DashCtrl', function($scope, $rootScope, $http, $timeout, $route, ejsResource,
|
.controller('DashCtrl', function($scope, $rootScope, $http, $timeout, $route, ejsResource,
|
||||||
fields, dashboard, alertSrv) {
|
fields, dashboard, alertSrv) {
|
||||||
|
|
||||||
$scope.editor = {
|
$scope.editor = {
|
||||||
@ -23,7 +23,7 @@ angular.module('kibana.controllers', [])
|
|||||||
$scope.fields = fields;
|
$scope.fields = fields;
|
||||||
$scope.reset_row();
|
$scope.reset_row();
|
||||||
|
|
||||||
var ejs = $scope.ejs = ejsResource(config.elasticsearch);
|
var ejs = $scope.ejs = ejsResource(config.elasticsearch);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.add_row = function(dash,row) {
|
$scope.add_row = function(dash,row) {
|
||||||
@ -58,7 +58,7 @@ angular.module('kibana.controllers', [])
|
|||||||
return $scope.editorTabs;
|
return $scope.editorTabs;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is whoafully incomplete, but will do for now
|
// This is whoafully incomplete, but will do for now
|
||||||
$scope.parse_error = function(data) {
|
$scope.parse_error = function(data) {
|
||||||
var _error = data.match("nested: (.*?);");
|
var _error = data.match("nested: (.*?);");
|
||||||
return _.isNull(_error) ? data : _error[1];
|
return _.isNull(_error) ? data : _error[1];
|
||||||
|
@ -9,7 +9,7 @@ angular.module('kibana.directives', [])
|
|||||||
link: function(scope, elem, attrs) {
|
link: function(scope, elem, attrs) {
|
||||||
var template = '<i class="icon-spinner small icon-spin icon-large panel-loading" '+
|
var template = '<i class="icon-spinner small icon-spin icon-large panel-loading" '+
|
||||||
'ng-show="panelMeta.loading == true && !panel.title"></i>'+
|
'ng-show="panelMeta.loading == true && !panel.title"></i>'+
|
||||||
' <span class="editlink panelextra pointer" style="right:15px;top:0px" ' +
|
' <span class="editlink panelextra pointer" style="right:15px;top:0px" ' +
|
||||||
'bs-modal="\'partials/paneleditor.html\'" ng-show="panel.editable != false">'+
|
'bs-modal="\'partials/paneleditor.html\'" ng-show="panel.editable != false">'+
|
||||||
'<span class="small">{{panel.type}}</span> <i class="icon-cog pointer"></i> '+
|
'<span class="small">{{panel.type}}</span> <i class="icon-cog pointer"></i> '+
|
||||||
'</span><h4>'+
|
'</span><h4>'+
|
||||||
@ -73,7 +73,7 @@ angular.module('kibana.directives', [])
|
|||||||
elm.bind('blur', function() {
|
elm.bind('blur', function() {
|
||||||
scope.$apply(function() {
|
scope.$apply(function() {
|
||||||
ngModelCtrl.$setViewValue(elm.val());
|
ngModelCtrl.$setViewValue(elm.val());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*jshint globalstrict:true */
|
/*jshint globalstrict:true, forin:false */
|
||||||
/*global angular:true */
|
/*global angular:true */
|
||||||
/*global Blob:false*/
|
/*global Blob:false*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
57
js/shared.js
57
js/shared.js
@ -1,3 +1,4 @@
|
|||||||
|
/*jshint forin:false*/
|
||||||
// Wrap this all up in a 'kbn' object so I don't have a billion globals
|
// Wrap this all up in a 'kbn' object so I don't have a billion globals
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -102,54 +103,54 @@
|
|||||||
kbn.round_interval = function(interval) {
|
kbn.round_interval = function(interval) {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// 0.5s
|
// 0.5s
|
||||||
case (interval <= 500):
|
case (interval <= 500):
|
||||||
return 100; // 0.1s
|
return 100; // 0.1s
|
||||||
// 5s
|
// 5s
|
||||||
case (interval <= 5000):
|
case (interval <= 5000):
|
||||||
return 1000; // 1s
|
return 1000; // 1s
|
||||||
// 7.5s
|
// 7.5s
|
||||||
case (interval <= 7500):
|
case (interval <= 7500):
|
||||||
return 5000; // 5s
|
return 5000; // 5s
|
||||||
// 15s
|
// 15s
|
||||||
case (interval <= 15000):
|
case (interval <= 15000):
|
||||||
return 10000; // 10s
|
return 10000; // 10s
|
||||||
// 45s
|
// 45s
|
||||||
case (interval <= 45000):
|
case (interval <= 45000):
|
||||||
return 30000; // 30s
|
return 30000; // 30s
|
||||||
// 3m
|
// 3m
|
||||||
case (interval <= 180000):
|
case (interval <= 180000):
|
||||||
return 60000; // 1m
|
return 60000; // 1m
|
||||||
// 9m
|
// 9m
|
||||||
case (interval <= 450000):
|
case (interval <= 450000):
|
||||||
return 300000; // 5m
|
return 300000; // 5m
|
||||||
// 20m
|
// 20m
|
||||||
case (interval <= 1200000):
|
case (interval <= 1200000):
|
||||||
return 600000; // 10m
|
return 600000; // 10m
|
||||||
// 45m
|
// 45m
|
||||||
case (interval <= 2700000):
|
case (interval <= 2700000):
|
||||||
return 1800000; // 30m
|
return 1800000; // 30m
|
||||||
// 2h
|
// 2h
|
||||||
case (interval <= 7200000):
|
case (interval <= 7200000):
|
||||||
return 3600000; // 1h
|
return 3600000; // 1h
|
||||||
// 6h
|
// 6h
|
||||||
case (interval <= 21600000):
|
case (interval <= 21600000):
|
||||||
return 10800000; // 3h
|
return 10800000; // 3h
|
||||||
// 24h
|
// 24h
|
||||||
case (interval <= 86400000):
|
case (interval <= 86400000):
|
||||||
return 43200000; // 12h
|
return 43200000; // 12h
|
||||||
// 48h
|
// 48h
|
||||||
case (interval <= 172800000):
|
case (interval <= 172800000):
|
||||||
return 86400000; // 24h
|
return 86400000; // 24h
|
||||||
// 1w
|
// 1w
|
||||||
case (interval <= 604800000):
|
case (interval <= 604800000):
|
||||||
return 86400000; // 24h
|
return 86400000; // 24h
|
||||||
// 3w
|
// 3w
|
||||||
case (interval <= 1814400000):
|
case (interval <= 1814400000):
|
||||||
return 604800000; // 1w
|
return 604800000; // 1w
|
||||||
// 2y
|
// 2y
|
||||||
case (interval < 3628800000):
|
case (interval < 3628800000):
|
||||||
return 2592000000; // 30d
|
return 2592000000; // 30d
|
||||||
default:
|
default:
|
||||||
return 31536000000; // 1y
|
return 31536000000; // 1y
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -194,21 +195,21 @@
|
|||||||
kbn.interval_to_seconds = function(string) {
|
kbn.interval_to_seconds = function(string) {
|
||||||
var matches = string.match(/(\d+(?:\.\d+)?)([Mwdhmsy])/);
|
var matches = string.match(/(\d+(?:\.\d+)?)([Mwdhmsy])/);
|
||||||
switch (matches[2]) {
|
switch (matches[2]) {
|
||||||
case 'y':
|
case 'y':
|
||||||
return matches[1]*31536000;
|
return matches[1]*31536000;
|
||||||
case 'M':
|
case 'M':
|
||||||
return matches[1]*2592000;
|
return matches[1]*2592000;
|
||||||
case 'w':
|
case 'w':
|
||||||
return matches[1]*604800;
|
return matches[1]*604800;
|
||||||
case 'd':
|
case 'd':
|
||||||
return matches[1]*86400;
|
return matches[1]*86400;
|
||||||
case 'h':
|
case 'h':
|
||||||
return matches[1]*3600;
|
return matches[1]*3600;
|
||||||
case 'm':
|
case 'm':
|
||||||
return matches[1]*60;
|
return matches[1]*60;
|
||||||
case 's':
|
case 's':
|
||||||
return matches[1];
|
return matches[1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// This should go away, moment.js can do this
|
// This should go away, moment.js can do this
|
||||||
@ -235,7 +236,7 @@
|
|||||||
if (objidx > 0) {
|
if (objidx > 0) {
|
||||||
strval = strval + ', ';
|
strval = strval + ', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
strval = strval + JSON.stringify(obj[objidx]);
|
strval = strval + JSON.stringify(obj[objidx]);
|
||||||
}
|
}
|
||||||
array[rootname] = strval;
|
array[rootname] = strval;
|
||||||
@ -299,7 +300,7 @@ _.mixin({
|
|||||||
|
|
||||||
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
|
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_.mixin({
|
_.mixin({
|
||||||
@ -308,7 +309,7 @@ _.mixin({
|
|||||||
|
|
||||||
array.splice(index, 1);
|
array.splice(index, 1);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
_.mixin({
|
_.mixin({
|
||||||
|
@ -61,7 +61,7 @@ angular.module('kibana.bettermap', [])
|
|||||||
$scope.panel.error = "Please select a field that contains geo point in [lon,lat] format";
|
$scope.panel.error = "Please select a field that contains geo point in [lon,lat] format";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the field to sort on
|
// Determine the field to sort on
|
||||||
var timeField = _.uniq(_.pluck(filterSrv.getByType('time'),'field'));
|
var timeField = _.uniq(_.pluck(filterSrv.getByType('time'),'field'));
|
||||||
if(timeField.length > 1) {
|
if(timeField.length > 1) {
|
||||||
@ -75,7 +75,7 @@ angular.module('kibana.bettermap', [])
|
|||||||
var _segment = _.isUndefined(segment) ? 0 : segment;
|
var _segment = _.isUndefined(segment) ? 0 : segment;
|
||||||
|
|
||||||
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
||||||
// This could probably be changed to a BoolFilter
|
// This could probably be changed to a BoolFilter
|
||||||
var boolQuery = $scope.ejs.BoolQuery();
|
var boolQuery = $scope.ejs.BoolQuery();
|
||||||
_.each($scope.panel.queries.ids,function(id) {
|
_.each($scope.panel.queries.ids,function(id) {
|
||||||
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
||||||
@ -132,7 +132,7 @@ angular.module('kibana.bettermap', [])
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.$emit('draw');
|
$scope.$emit('draw');
|
||||||
|
|
||||||
// Get $size results then stop querying
|
// Get $size results then stop querying
|
||||||
@ -169,12 +169,12 @@ angular.module('kibana.bettermap', [])
|
|||||||
|
|
||||||
var map, markers, layerGroup, mcg;
|
var map, markers, layerGroup, mcg;
|
||||||
|
|
||||||
function render_panel() {
|
function render_panel() {
|
||||||
scope.panelMeta.loading = false;
|
scope.panelMeta.loading = false;
|
||||||
|
|
||||||
var scripts = $LAB.script("panels/bettermap/lib/leaflet.js").wait()
|
var scripts = $LAB.script("panels/bettermap/lib/leaflet.js").wait()
|
||||||
.script("panels/bettermap/lib/plugins.js");
|
.script("panels/bettermap/lib/plugins.js");
|
||||||
|
|
||||||
//add markers dynamically
|
//add markers dynamically
|
||||||
scripts.wait(function(){
|
scripts.wait(function(){
|
||||||
if(_.isUndefined(map)) {
|
if(_.isUndefined(map)) {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
* panels :: an array of panel objects. All of their spans should be set to 12
|
* panels :: an array of panel objects. All of their spans should be set to 12
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -84,7 +84,7 @@ angular.module('kibana.column', [])
|
|||||||
}
|
}
|
||||||
elem.html($compile(angular.element(template))(scope));
|
elem.html($compile(angular.element(template))(scope));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}).filter('withoutColumn', function() {
|
}).filter('withoutColumn', function() {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
* hide_control :: Upon save, hide this panel
|
* hide_control :: Upon save, hide this panel
|
||||||
* elasticsearch_size :: show this many dashboards under the ES section in the load drop down
|
* elasticsearch_size :: show this many dashboards under the ES section in the load drop down
|
||||||
* temp :: Allow saving of temp dashboards
|
* temp :: Allow saving of temp dashboards
|
||||||
* ttl :: Enable setting ttl.
|
* ttl :: Enable setting ttl.
|
||||||
* temp_ttl :: How long should temp dashboards persist
|
* temp_ttl :: How long should temp dashboards persist
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -91,7 +91,7 @@ angular.module('kibana.dashcontrol', [])
|
|||||||
).then(
|
).then(
|
||||||
function(result) {
|
function(result) {
|
||||||
if(!_.isUndefined(result._id)) {
|
if(!_.isUndefined(result._id)) {
|
||||||
alertSrv.set('Dashboard Saved','This dashboard has been saved to Elasticsearch as "' +
|
alertSrv.set('Dashboard Saved','This dashboard has been saved to Elasticsearch as "' +
|
||||||
result._id + '"','success',5000);
|
result._id + '"','success',5000);
|
||||||
if(type === 'temp') {
|
if(type === 'temp') {
|
||||||
$scope.share = dashboard.share_link(dashboard.current.title,'temp',result._id);
|
$scope.share = dashboard.share_link(dashboard.current.title,'temp',result._id);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
## Derivequeries
|
## Derivequeries
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
* label :: The label to stick over the field
|
* label :: The label to stick over the field
|
||||||
* query :: A string to use as a filter for the terms facet
|
* query :: A string to use as a filter for the terms facet
|
||||||
* field :: the field to facet on
|
* field :: the field to facet on
|
||||||
* rest :: include a filter that matches all other terms,
|
* rest :: include a filter that matches all other terms,
|
||||||
@ -54,7 +54,7 @@ angular.module('kibana.derivequeries', [])
|
|||||||
|
|
||||||
$scope.get_data = function() {
|
$scope.get_data = function() {
|
||||||
update_history($scope.panel.query);
|
update_history($scope.panel.query);
|
||||||
|
|
||||||
// Make sure we have everything for the request to complete
|
// Make sure we have everything for the request to complete
|
||||||
if(dashboard.indices.length === 0) {
|
if(dashboard.indices.length === 0) {
|
||||||
return;
|
return;
|
||||||
@ -122,8 +122,8 @@ angular.module('kibana.derivequeries', [])
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.set_refresh = function (state) {
|
$scope.set_refresh = function (state) {
|
||||||
$scope.refresh = state;
|
$scope.refresh = state;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.close_edit = function() {
|
$scope.close_edit = function() {
|
||||||
|
@ -23,7 +23,7 @@ angular.module('kibana.fields', [])
|
|||||||
var _d = {
|
var _d = {
|
||||||
style : {},
|
style : {},
|
||||||
arrange : 'vertical',
|
arrange : 'vertical',
|
||||||
micropanel_position : 'right',
|
micropanel_position : 'right',
|
||||||
};
|
};
|
||||||
_.defaults($scope.panel,_d);
|
_.defaults($scope.panel,_d);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* arrangement :: How should I arrange the query results? 'horizontal' or 'vertical'
|
* arrangement :: How should I arrange the query results? 'horizontal' or 'vertical'
|
||||||
* chart :: Show a chart? 'none', 'bar', 'pie'
|
* chart :: Show a chart? 'none', 'bar', 'pie'
|
||||||
* donut :: Only applies to 'pie' charts. Punches a hole in the chart for some reason
|
* donut :: Only applies to 'pie' charts. Punches a hole in the chart for some reason
|
||||||
* tilt :: Only 'pie' charts. Janky 3D effect. Looks terrible 90% of the time.
|
* tilt :: Only 'pie' charts. Janky 3D effect. Looks terrible 90% of the time.
|
||||||
* lables :: Only 'pie' charts. Labels on the pie?
|
* lables :: Only 'pie' charts. Labels on the pie?
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -48,7 +48,7 @@ angular.module('kibana.hits', [])
|
|||||||
|
|
||||||
$scope.init = function () {
|
$scope.init = function () {
|
||||||
$scope.hits = 0;
|
$scope.hits = 0;
|
||||||
|
|
||||||
$scope.$on('refresh',function(){
|
$scope.$on('refresh',function(){
|
||||||
$scope.get_data();
|
$scope.get_data();
|
||||||
});
|
});
|
||||||
@ -67,14 +67,14 @@ angular.module('kibana.hits', [])
|
|||||||
|
|
||||||
var _segment = _.isUndefined(segment) ? 0 : segment;
|
var _segment = _.isUndefined(segment) ? 0 : segment;
|
||||||
var request = $scope.ejs.Request().indices(dashboard.indices[_segment]);
|
var request = $scope.ejs.Request().indices(dashboard.indices[_segment]);
|
||||||
|
|
||||||
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
||||||
// Build the question part of the query
|
// Build the question part of the query
|
||||||
_.each($scope.panel.queries.ids, function(id) {
|
_.each($scope.panel.queries.ids, function(id) {
|
||||||
var _q = $scope.ejs.FilteredQuery(
|
var _q = $scope.ejs.FilteredQuery(
|
||||||
querySrv.getEjsObj(id),
|
querySrv.getEjsObj(id),
|
||||||
filterSrv.getBoolFilter(filterSrv.ids));
|
filterSrv.getBoolFilter(filterSrv.ids));
|
||||||
|
|
||||||
request = request
|
request = request
|
||||||
.facet($scope.ejs.QueryFacet(id)
|
.facet($scope.ejs.QueryFacet(id)
|
||||||
.query(_q)
|
.query(_q)
|
||||||
@ -95,7 +95,7 @@ angular.module('kibana.hits', [])
|
|||||||
$scope.data = [];
|
$scope.data = [];
|
||||||
query_id = $scope.query_id = new Date().getTime();
|
query_id = $scope.query_id = new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for error and abort if found
|
// Check for error and abort if found
|
||||||
if(!(_.isUndefined(results.error))) {
|
if(!(_.isUndefined(results.error))) {
|
||||||
$scope.panel.error = $scope.parse_error(results.error);
|
$scope.panel.error = $scope.parse_error(results.error);
|
||||||
@ -106,18 +106,18 @@ angular.module('kibana.hits', [])
|
|||||||
var facetIds = _.map(_.keys(results.facets),function(k){return parseInt(k, 10);});
|
var facetIds = _.map(_.keys(results.facets),function(k){return parseInt(k, 10);});
|
||||||
|
|
||||||
// Make sure we're still on the same query/queries
|
// Make sure we're still on the same query/queries
|
||||||
if($scope.query_id === query_id &&
|
if($scope.query_id === query_id &&
|
||||||
_.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length
|
_.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length
|
||||||
) {
|
) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
_.each($scope.panel.queries.ids, function(id) {
|
_.each($scope.panel.queries.ids, function(id) {
|
||||||
var v = results.facets[id];
|
var v = results.facets[id];
|
||||||
var hits = _.isUndefined($scope.data[i]) || _segment === 0 ?
|
var hits = _.isUndefined($scope.data[i]) || _segment === 0 ?
|
||||||
v.count : $scope.data[i].hits+v.count;
|
v.count : $scope.data[i].hits+v.count;
|
||||||
$scope.hits += v.count;
|
$scope.hits += v.count;
|
||||||
|
|
||||||
// Create series
|
// Create series
|
||||||
$scope.data[i] = {
|
$scope.data[i] = {
|
||||||
info: querySrv.list[id],
|
info: querySrv.list[id],
|
||||||
id: id,
|
id: id,
|
||||||
hits: hits,
|
hits: hits,
|
||||||
@ -130,13 +130,13 @@ angular.module('kibana.hits', [])
|
|||||||
if(_segment < dashboard.indices.length-1) {
|
if(_segment < dashboard.indices.length-1) {
|
||||||
$scope.get_data(_segment+1,query_id);
|
$scope.get_data(_segment+1,query_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.set_refresh = function (state) {
|
$scope.set_refresh = function (state) {
|
||||||
$scope.refresh = state;
|
$scope.refresh = state;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.close_edit = function() {
|
$scope.close_edit = function() {
|
||||||
@ -161,7 +161,7 @@ angular.module('kibana.hits', [])
|
|||||||
scope.$on('render',function(){
|
scope.$on('render',function(){
|
||||||
render_panel();
|
render_panel();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-render if the window is resized
|
// Re-render if the window is resized
|
||||||
angular.element(window).bind('resize', function(){
|
angular.element(window).bind('resize', function(){
|
||||||
render_panel();
|
render_panel();
|
||||||
@ -186,7 +186,7 @@ angular.module('kibana.hits', [])
|
|||||||
scripts.wait(function(){
|
scripts.wait(function(){
|
||||||
// Populate element
|
// Populate element
|
||||||
try {
|
try {
|
||||||
// Add plot to scope so we can build out own legend
|
// Add plot to scope so we can build out own legend
|
||||||
if(scope.panel.chart === 'bar') {
|
if(scope.panel.chart === 'bar') {
|
||||||
scope.plot = $.plot(elem, scope.data, {
|
scope.plot = $.plot(elem, scope.data, {
|
||||||
legend: { show: false },
|
legend: { show: false },
|
||||||
@ -222,7 +222,7 @@ angular.module('kibana.hits', [])
|
|||||||
stroke: {
|
stroke: {
|
||||||
width: 0
|
width: 0
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
show: scope.panel.labels,
|
show: scope.panel.labels,
|
||||||
radius: 2/3,
|
radius: 2/3,
|
||||||
formatter: function(label, series){
|
formatter: function(label, series){
|
||||||
@ -230,7 +230,7 @@ angular.module('kibana.hits', [])
|
|||||||
' "style="font-size:8pt;text-align:center;padding:2px;color:white;">'+
|
' "style="font-size:8pt;text-align:center;padding:2px;color:white;">'+
|
||||||
label+'<br/>'+Math.round(series.percent)+'%</div>';
|
label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
},
|
},
|
||||||
threshold: 0.1
|
threshold: 0.1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -247,7 +247,7 @@ angular.module('kibana.hits', [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tt(x, y, contents) {
|
function tt(x, y, contents) {
|
||||||
var tooltip = $('#pie-tooltip').length ?
|
var tooltip = $('#pie-tooltip').length ?
|
||||||
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
|
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
|
||||||
//var tooltip = $('#pie-tooltip')
|
//var tooltip = $('#pie-tooltip')
|
||||||
tooltip.html(contents).css({
|
tooltip.html(contents).css({
|
||||||
@ -265,7 +265,7 @@ angular.module('kibana.hits', [])
|
|||||||
|
|
||||||
elem.bind("plothover", function (event, pos, item) {
|
elem.bind("plothover", function (event, pos, item) {
|
||||||
if (item) {
|
if (item) {
|
||||||
var value = scope.panel.chart === 'bar' ?
|
var value = scope.panel.chart === 'bar' ?
|
||||||
item.datapoint[1] : item.datapoint[1][0][1];
|
item.datapoint[1] : item.datapoint[1][0][1];
|
||||||
tt(pos.pageX, pos.pageY,
|
tt(pos.pageX, pos.pageY,
|
||||||
"<div style='vertical-align:middle;border-radius:10px;display:inline-block;background:"+
|
"<div style='vertical-align:middle;border-radius:10px;display:inline-block;background:"+
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
* map :: 'world', 'us' or 'europe'
|
* map :: 'world', 'us' or 'europe'
|
||||||
* colors :: an array of colors to use for the regions of the map. If this is a 2
|
* colors :: an array of colors to use for the regions of the map. If this is a 2
|
||||||
element array, jquerymap will generate shades between these colors
|
element array, jquerymap will generate shades between these colors
|
||||||
* size :: How big to make the facet. Higher = more countries
|
* size :: How big to make the facet. Higher = more countries
|
||||||
* exclude :: Exlude the array of counties
|
* exclude :: Exlude the array of counties
|
||||||
* spyable :: Show the 'eye' icon that reveals the last ES query
|
* spyable :: Show the 'eye' icon that reveals the last ES query
|
||||||
@ -53,7 +53,7 @@ angular.module('kibana.map', [])
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.get_data = function() {
|
$scope.get_data = function() {
|
||||||
|
|
||||||
// Make sure we have everything for the request to complete
|
// Make sure we have everything for the request to complete
|
||||||
if(dashboard.indices.length === 0) {
|
if(dashboard.indices.length === 0) {
|
||||||
return;
|
return;
|
||||||
@ -65,7 +65,7 @@ angular.module('kibana.map', [])
|
|||||||
request = $scope.ejs.Request().indices(dashboard.indices);
|
request = $scope.ejs.Request().indices(dashboard.indices);
|
||||||
|
|
||||||
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
||||||
// This could probably be changed to a BoolFilter
|
// This could probably be changed to a BoolFilter
|
||||||
var boolQuery = $scope.ejs.BoolQuery();
|
var boolQuery = $scope.ejs.BoolQuery();
|
||||||
_.each($scope.panel.queries.ids,function(id) {
|
_.each($scope.panel.queries.ids,function(id) {
|
||||||
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
||||||
@ -106,8 +106,8 @@ angular.module('kibana.map', [])
|
|||||||
body : "<h5>Last Elasticsearch Query</h5><pre>"+
|
body : "<h5>Last Elasticsearch Query</h5><pre>"+
|
||||||
'curl -XGET '+config.elasticsearch+'/'+dashboard.indices+"/_search?pretty -d'\n"+
|
'curl -XGET '+config.elasticsearch+'/'+dashboard.indices+"/_search?pretty -d'\n"+
|
||||||
angular.toJson(JSON.parse(request.toString()),true)+
|
angular.toJson(JSON.parse(request.toString()),true)+
|
||||||
"'</pre>",
|
"'</pre>",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.build_search = function(field,value) {
|
$scope.build_search = function(field,value) {
|
||||||
@ -137,12 +137,12 @@ angular.module('kibana.map', [])
|
|||||||
// Using LABjs, wait until all scripts are loaded before rendering panel
|
// Using LABjs, wait until all scripts are loaded before rendering panel
|
||||||
var scripts = $LAB.script("panels/map/lib/jquery.jvectormap.min.js").wait()
|
var scripts = $LAB.script("panels/map/lib/jquery.jvectormap.min.js").wait()
|
||||||
.script("panels/map/lib/map."+scope.panel.map+".js");
|
.script("panels/map/lib/map."+scope.panel.map+".js");
|
||||||
|
|
||||||
// Populate element. Note that jvectormap appends, does not replace.
|
// Populate element. Note that jvectormap appends, does not replace.
|
||||||
scripts.wait(function(){
|
scripts.wait(function(){
|
||||||
elem.text('');
|
elem.text('');
|
||||||
$('.jvectormap-zoomin,.jvectormap-zoomout,.jvectormap-label').remove();
|
$('.jvectormap-zoomin,.jvectormap-zoomout,.jvectormap-label').remove();
|
||||||
var map = elem.vectorMap({
|
var map = elem.vectorMap({
|
||||||
map: scope.panel.map,
|
map: scope.panel.map,
|
||||||
regionStyle: {initial: {fill: '#8c8c8c'}},
|
regionStyle: {initial: {fill: '#8c8c8c'}},
|
||||||
zoomOnScroll: false,
|
zoomOnScroll: false,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* legend :: Show the legend?
|
* legend :: Show the legend?
|
||||||
* labels :: Label the slices of the pie?
|
* labels :: Label the slices of the pie?
|
||||||
* mode :: 'terms' or 'goal'
|
* mode :: 'terms' or 'goal'
|
||||||
* default_field :: LOL wat? A dumb fail over field if for some reason the query object
|
* default_field :: LOL wat? A dumb fail over field if for some reason the query object
|
||||||
doesn't have a field
|
doesn't have a field
|
||||||
* spyable :: Show the 'eye' icon that displays the last ES query for this panel
|
* spyable :: Show the 'eye' icon that displays the last ES query for this panel
|
||||||
*/
|
*/
|
||||||
@ -36,7 +36,7 @@ angular.module('kibana.pie', [])
|
|||||||
editorTabs : [
|
editorTabs : [
|
||||||
{title:'Queries', src:'partials/querySelect.html'}
|
{title:'Queries', src:'partials/querySelect.html'}
|
||||||
],
|
],
|
||||||
query : { field:"_type", goal: 100},
|
query : { field:"_type", goal: 100},
|
||||||
queries : {
|
queries : {
|
||||||
mode : 'all',
|
mode : 'all',
|
||||||
ids : []
|
ids : []
|
||||||
@ -70,8 +70,8 @@ angular.module('kibana.pie', [])
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.set_refresh = function (state) {
|
$scope.set_refresh = function (state) {
|
||||||
$scope.refresh = state;
|
$scope.refresh = state;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.close_edit = function() {
|
$scope.close_edit = function() {
|
||||||
@ -83,18 +83,18 @@ angular.module('kibana.pie', [])
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.get_data = function() {
|
$scope.get_data = function() {
|
||||||
|
|
||||||
// Make sure we have everything for the request to complete
|
// Make sure we have everything for the request to complete
|
||||||
if(dashboard.indices.length === 0) {
|
if(dashboard.indices.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$scope.panelMeta.loading = true;
|
$scope.panelMeta.loading = true;
|
||||||
var request = $scope.ejs.Request().indices(dashboard.indices);
|
var request = $scope.ejs.Request().indices(dashboard.indices);
|
||||||
|
|
||||||
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
||||||
// This could probably be changed to a BoolFilter
|
// This could probably be changed to a BoolFilter
|
||||||
var boolQuery = $scope.ejs.BoolQuery();
|
var boolQuery = $scope.ejs.BoolQuery();
|
||||||
_.each($scope.panel.queries.ids,function(id) {
|
_.each($scope.panel.queries.ids,function(id) {
|
||||||
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
||||||
@ -127,7 +127,7 @@ angular.module('kibana.pie', [])
|
|||||||
$scope.data = [];
|
$scope.data = [];
|
||||||
var k = 0;
|
var k = 0;
|
||||||
_.each(results.facets.pie.terms, function(v) {
|
_.each(results.facets.pie.terms, function(v) {
|
||||||
var slice = { label : v.term, data : v.count };
|
var slice = { label : v.term, data : v.count };
|
||||||
$scope.data.push();
|
$scope.data.push();
|
||||||
$scope.data.push(slice);
|
$scope.data.push(slice);
|
||||||
k = k + 1;
|
k = k + 1;
|
||||||
@ -140,9 +140,9 @@ angular.module('kibana.pie', [])
|
|||||||
.query(boolQuery)
|
.query(boolQuery)
|
||||||
.filter(filterSrv.getBoolFilter(filterSrv.ids))
|
.filter(filterSrv.getBoolFilter(filterSrv.ids))
|
||||||
.size(0);
|
.size(0);
|
||||||
|
|
||||||
$scope.populate_modal(request);
|
$scope.populate_modal(request);
|
||||||
|
|
||||||
results = request.doSearch();
|
results = request.doSearch();
|
||||||
|
|
||||||
results.then(function(results) {
|
results.then(function(results) {
|
||||||
@ -165,8 +165,8 @@ angular.module('kibana.pie', [])
|
|||||||
body : "<h5>Last Elasticsearch Query</h5><pre>"+
|
body : "<h5>Last Elasticsearch Query</h5><pre>"+
|
||||||
'curl -XGET '+config.elasticsearch+'/'+dashboard.indices+"/_search?pretty -d'\n"+
|
'curl -XGET '+config.elasticsearch+'/'+dashboard.indices+"/_search?pretty -d'\n"+
|
||||||
angular.toJson(JSON.parse(request.toString()),true)+
|
angular.toJson(JSON.parse(request.toString()),true)+
|
||||||
"'</pre>",
|
"'</pre>",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -194,11 +194,11 @@ angular.module('kibana.pie', [])
|
|||||||
|
|
||||||
var scripts = $LAB.script("common/lib/panels/jquery.flot.js").wait()
|
var scripts = $LAB.script("common/lib/panels/jquery.flot.js").wait()
|
||||||
.script("common/lib/panels/jquery.flot.pie.js");
|
.script("common/lib/panels/jquery.flot.pie.js");
|
||||||
|
|
||||||
var label;
|
var label;
|
||||||
|
|
||||||
if(scope.panel.mode === 'goal') {
|
if(scope.panel.mode === 'goal') {
|
||||||
label = {
|
label = {
|
||||||
show: scope.panel.labels,
|
show: scope.panel.labels,
|
||||||
radius: 0,
|
radius: 0,
|
||||||
formatter: function(label, series){
|
formatter: function(label, series){
|
||||||
@ -211,15 +211,15 @@ angular.module('kibana.pie', [])
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
label = {
|
label = {
|
||||||
show: scope.panel.labels,
|
show: scope.panel.labels,
|
||||||
radius: 2/3,
|
radius: 2/3,
|
||||||
formatter: function(label, series){
|
formatter: function(label, series){
|
||||||
return '<div "style="font-size:8pt;text-align:center;padding:2px;color:white;">'+
|
return '<div "style="font-size:8pt;text-align:center;padding:2px;color:white;">'+
|
||||||
label+'<br/>'+Math.round(series.percent)+'%</div>';
|
label+'<br/>'+Math.round(series.percent)+'%</div>';
|
||||||
},
|
},
|
||||||
threshold: 0.1
|
threshold: 0.1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,10 +241,10 @@ angular.module('kibana.pie', [])
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
//grid: { hoverable: true, clickable: true },
|
//grid: { hoverable: true, clickable: true },
|
||||||
grid: {
|
grid: {
|
||||||
backgroundColor: null,
|
backgroundColor: null,
|
||||||
hoverable: true,
|
hoverable: true,
|
||||||
clickable: true
|
clickable: true
|
||||||
},
|
},
|
||||||
legend: { show: false },
|
legend: { show: false },
|
||||||
colors: querySrv.colors
|
colors: querySrv.colors
|
||||||
@ -263,7 +263,7 @@ angular.module('kibana.pie', [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tt(x, y, contents) {
|
function tt(x, y, contents) {
|
||||||
var tooltip = $('#pie-tooltip').length ?
|
var tooltip = $('#pie-tooltip').length ?
|
||||||
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
|
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
|
||||||
|
|
||||||
tooltip.html(contents).css({
|
tooltip.html(contents).css({
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
## query
|
## query
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
* label :: The label to stick over the field
|
* label :: The label to stick over the field
|
||||||
* query :: A string or an array of querys. String if multi is off, array if it is on
|
* query :: A string or an array of querys. String if multi is off, array if it is on
|
||||||
This should be fixed, it should always be an array even if its only
|
This should be fixed, it should always be an array even if its only
|
||||||
one element
|
one element
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
* size :: Number of events per page to show
|
* size :: Number of events per page to show
|
||||||
* pages :: Number of pages to show. size * pages = number of cached events.
|
* pages :: Number of pages to show. size * pages = number of cached events.
|
||||||
Bigger = more memory usage byh the browser
|
Bigger = more memory usage byh the browser
|
||||||
* offset :: Position from which to start in the array of hits
|
* offset :: Position from which to start in the array of hits
|
||||||
* sort :: An array with 2 elements. sort[0]: field, sort[1]: direction ('asc' or 'desc')
|
* sort :: An array with 2 elements. sort[0]: field, sort[1]: direction ('asc' or 'desc')
|
||||||
* style :: hash of css properties
|
* style :: hash of css properties
|
||||||
* fields :: columns to show in table
|
* fields :: columns to show in table
|
||||||
* overflow :: 'height' or 'min-height' controls wether the row will expand (min-height) to
|
* overflow :: 'height' or 'min-height' controls wether the row will expand (min-height) to
|
||||||
to fit the table, or if the table will scroll to fit the row (height)
|
to fit the table, or if the table will scroll to fit the row (height)
|
||||||
* trimFactor :: If line is > this many characters, divided by the number of columns, trim it.
|
* trimFactor :: If line is > this many characters, divided by the number of columns, trim it.
|
||||||
* sortable :: Allow sorting?
|
* sortable :: Allow sorting?
|
||||||
* spyable :: Show the 'eye' icon that reveals the last ES query for this panel
|
* spyable :: Show the 'eye' icon that reveals the last ES query for this panel
|
||||||
@ -110,7 +110,7 @@ angular.module('kibana.table', [])
|
|||||||
} else {
|
} else {
|
||||||
$scope.panel.highlight.push(field);
|
$scope.panel.highlight.push(field);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggle_details = function(row) {
|
$scope.toggle_details = function(row) {
|
||||||
row.kibana = row.kibana || {};
|
row.kibana = row.kibana || {};
|
||||||
@ -147,7 +147,7 @@ angular.module('kibana.table', [])
|
|||||||
if(dashboard.indices.length === 0) {
|
if(dashboard.indices.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.panelMeta.loading = true;
|
$scope.panelMeta.loading = true;
|
||||||
|
|
||||||
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
||||||
@ -208,14 +208,14 @@ angular.module('kibana.table', [])
|
|||||||
_sort : hit.sort
|
_sort : hit.sort
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
$scope.hits += results.hits.total;
|
$scope.hits += results.hits.total;
|
||||||
|
|
||||||
// Sort the data
|
// Sort the data
|
||||||
$scope.data = _.sortBy($scope.data, function(v){
|
$scope.data = _.sortBy($scope.data, function(v){
|
||||||
return v._sort[0];
|
return v._sort[0];
|
||||||
});
|
});
|
||||||
|
|
||||||
// Reverse if needed
|
// Reverse if needed
|
||||||
if($scope.panel.sort[1] === 'desc') {
|
if($scope.panel.sort[1] === 'desc') {
|
||||||
$scope.data.reverse();
|
$scope.data.reverse();
|
||||||
@ -245,14 +245,14 @@ angular.module('kibana.table', [])
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.without_kibana = function (row) {
|
$scope.without_kibana = function (row) {
|
||||||
return {
|
return {
|
||||||
_source : row._source,
|
_source : row._source,
|
||||||
highlight : row.highlight
|
highlight : row.highlight
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.set_refresh = function (state) {
|
$scope.set_refresh = function (state) {
|
||||||
$scope.refresh = state;
|
$scope.refresh = state;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.close_edit = function() {
|
$scope.close_edit = function() {
|
||||||
@ -296,7 +296,7 @@ angular.module('kibana.table', [])
|
|||||||
type = fields.mapping[event._index][event._type][field]['type'];
|
type = fields.mapping[event._index][event._type][field]['type'];
|
||||||
if(type === 'date' && scope.panel.normTimes) {
|
if(type === 'date' && scope.panel.normTimes) {
|
||||||
return moment(text).format('YYYY-MM-DD HH:mm:ss');
|
return moment(text).format('YYYY-MM-DD HH:mm:ss');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* arrangement :: How should I arrange the query results? 'horizontal' or 'vertical'
|
* arrangement :: How should I arrange the query results? 'horizontal' or 'vertical'
|
||||||
* chart :: Show a chart? 'none', 'bar', 'pie'
|
* chart :: Show a chart? 'none', 'bar', 'pie'
|
||||||
* donut :: Only applies to 'pie' charts. Punches a hole in the chart for some reason
|
* donut :: Only applies to 'pie' charts. Punches a hole in the chart for some reason
|
||||||
* tilt :: Only 'pie' charts. Janky 3D effect. Looks terrible 90% of the time.
|
* tilt :: Only 'pie' charts. Janky 3D effect. Looks terrible 90% of the time.
|
||||||
* lables :: Only 'pie' charts. Labels on the pie?
|
* lables :: Only 'pie' charts. Labels on the pie?
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@ -26,7 +26,7 @@ angular.module('kibana.terms', [])
|
|||||||
{title:'Queries', src:'partials/querySelect.html'}
|
{title:'Queries', src:'partials/querySelect.html'}
|
||||||
],
|
],
|
||||||
status : "Beta",
|
status : "Beta",
|
||||||
description : "Displays the results of an elasticsearch facet as a pie chart, bar chart, or a "+
|
description : "Displays the results of an elasticsearch facet as a pie chart, bar chart, or a "+
|
||||||
"table"
|
"table"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ angular.module('kibana.terms', [])
|
|||||||
|
|
||||||
$scope.init = function () {
|
$scope.init = function () {
|
||||||
$scope.hits = 0;
|
$scope.hits = 0;
|
||||||
|
|
||||||
$scope.$on('refresh',function(){
|
$scope.$on('refresh',function(){
|
||||||
$scope.get_data();
|
$scope.get_data();
|
||||||
});
|
});
|
||||||
@ -67,7 +67,7 @@ angular.module('kibana.terms', [])
|
|||||||
// Make sure we have everything for the request to complete
|
// Make sure we have everything for the request to complete
|
||||||
if(dashboard.indices.length === 0) {
|
if(dashboard.indices.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.panelMeta.loading = true;
|
$scope.panelMeta.loading = true;
|
||||||
var request,
|
var request,
|
||||||
@ -77,7 +77,7 @@ angular.module('kibana.terms', [])
|
|||||||
request = $scope.ejs.Request().indices(dashboard.indices);
|
request = $scope.ejs.Request().indices(dashboard.indices);
|
||||||
|
|
||||||
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
|
||||||
// This could probably be changed to a BoolFilter
|
// This could probably be changed to a BoolFilter
|
||||||
boolQuery = $scope.ejs.BoolQuery();
|
boolQuery = $scope.ejs.BoolQuery();
|
||||||
_.each($scope.panel.queries.ids,function(id) {
|
_.each($scope.panel.queries.ids,function(id) {
|
||||||
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
|
||||||
@ -108,11 +108,11 @@ angular.module('kibana.terms', [])
|
|||||||
$scope.hits = results.hits.total;
|
$scope.hits = results.hits.total;
|
||||||
$scope.data = [];
|
$scope.data = [];
|
||||||
_.each(results.facets.terms.terms, function(v) {
|
_.each(results.facets.terms.terms, function(v) {
|
||||||
var slice = { label : v.term, data : [[k,v.count]], actions: true};
|
var slice = { label : v.term, data : [[k,v.count]], actions: true};
|
||||||
$scope.data.push(slice);
|
$scope.data.push(slice);
|
||||||
k = k + 1;
|
k = k + 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.data.push({label:'Missing field',
|
$scope.data.push({label:'Missing field',
|
||||||
data:[[k,results.facets.terms.missing]],meta:"missing",color:'#aaa',opacity:0});
|
data:[[k,results.facets.terms.missing]],meta:"missing",color:'#aaa',opacity:0});
|
||||||
$scope.data.push({label:'Other values',
|
$scope.data.push({label:'Other values',
|
||||||
@ -135,8 +135,8 @@ angular.module('kibana.terms', [])
|
|||||||
dashboard.refresh();
|
dashboard.refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.set_refresh = function (state) {
|
$scope.set_refresh = function (state) {
|
||||||
$scope.refresh = state;
|
$scope.refresh = state;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.close_edit = function() {
|
$scope.close_edit = function() {
|
||||||
@ -169,7 +169,7 @@ angular.module('kibana.terms', [])
|
|||||||
scope.$on('render',function(){
|
scope.$on('render',function(){
|
||||||
render_panel();
|
render_panel();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-render if the window is resized
|
// Re-render if the window is resized
|
||||||
angular.element(window).bind('resize', function(){
|
angular.element(window).bind('resize', function(){
|
||||||
render_panel();
|
render_panel();
|
||||||
@ -186,16 +186,16 @@ angular.module('kibana.terms', [])
|
|||||||
|
|
||||||
// Make a clone we can operate on.
|
// Make a clone we can operate on.
|
||||||
chartData = _.clone(scope.data);
|
chartData = _.clone(scope.data);
|
||||||
chartData = scope.panel.missing ? chartData :
|
chartData = scope.panel.missing ? chartData :
|
||||||
_.without(chartData,_.findWhere(chartData,{meta:'missing'}));
|
_.without(chartData,_.findWhere(chartData,{meta:'missing'}));
|
||||||
chartData = scope.panel.other ? chartData :
|
chartData = scope.panel.other ? chartData :
|
||||||
_.without(chartData,_.findWhere(chartData,{meta:'other'}));
|
_.without(chartData,_.findWhere(chartData,{meta:'other'}));
|
||||||
|
|
||||||
// Populate element.
|
// Populate element.
|
||||||
scripts.wait(function(){
|
scripts.wait(function(){
|
||||||
// Populate element
|
// Populate element
|
||||||
try {
|
try {
|
||||||
// Add plot to scope so we can build out own legend
|
// Add plot to scope so we can build out own legend
|
||||||
if(scope.panel.chart === 'bar') {
|
if(scope.panel.chart === 'bar') {
|
||||||
plot = $.plot(elem, chartData, {
|
plot = $.plot(elem, chartData, {
|
||||||
legend: { show: false },
|
legend: { show: false },
|
||||||
@ -238,11 +238,11 @@ angular.module('kibana.terms', [])
|
|||||||
stroke: {
|
stroke: {
|
||||||
width: 0
|
width: 0
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
show: scope.panel.labels,
|
show: scope.panel.labels,
|
||||||
radius: 2/3,
|
radius: 2/3,
|
||||||
formatter: labelFormat,
|
formatter: labelFormat,
|
||||||
threshold: 0.1
|
threshold: 0.1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -269,7 +269,7 @@ angular.module('kibana.terms', [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
function tt(x, y, contents) {
|
function tt(x, y, contents) {
|
||||||
var tooltip = $('#pie-tooltip').length ?
|
var tooltip = $('#pie-tooltip').length ?
|
||||||
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
|
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
|
||||||
//var tooltip = $('#pie-tooltip')
|
//var tooltip = $('#pie-tooltip')
|
||||||
tooltip.html(contents).css({
|
tooltip.html(contents).css({
|
||||||
@ -293,7 +293,7 @@ angular.module('kibana.terms', [])
|
|||||||
|
|
||||||
elem.bind("plothover", function (event, pos, item) {
|
elem.bind("plothover", function (event, pos, item) {
|
||||||
if (item) {
|
if (item) {
|
||||||
var value = scope.panel.chart === 'bar' ?
|
var value = scope.panel.chart === 'bar' ?
|
||||||
item.datapoint[1] : item.datapoint[1][0][1];
|
item.datapoint[1] : item.datapoint[1][0][1];
|
||||||
tt(pos.pageX, pos.pageY,
|
tt(pos.pageX, pos.pageY,
|
||||||
"<div style='vertical-align:middle;border-radius:10px;display:inline-block;background:"+
|
"<div style='vertical-align:middle;border-radius:10px;display:inline-block;background:"+
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
* mode :: 'text', 'html', 'markdown'
|
* mode :: 'text', 'html', 'markdown'
|
||||||
* content :: Content of the panel
|
* content :: Content of the panel
|
||||||
* style :: Hash containing css properties
|
* style :: Hash containing css properties
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -35,7 +35,7 @@ angular.module('kibana.text', [])
|
|||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
$scope.ready = false;
|
$scope.ready = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}).directive('markdown', function() {
|
}).directive('markdown', function() {
|
||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
|
@ -36,7 +36,7 @@ angular.module('kibana.timepicker', [])
|
|||||||
timefield : '@timestamp',
|
timefield : '@timestamp',
|
||||||
timeformat : "",
|
timeformat : "",
|
||||||
refresh : {
|
refresh : {
|
||||||
enable : false,
|
enable : false,
|
||||||
interval: 30,
|
interval: 30,
|
||||||
min : 3
|
min : 3
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ angular.module('kibana.timepicker', [])
|
|||||||
$scope.panel.refresh.interval = refresh_interval;
|
$scope.panel.refresh.interval = refresh_interval;
|
||||||
if(_.isNumber($scope.panel.refresh.interval)) {
|
if(_.isNumber($scope.panel.refresh.interval)) {
|
||||||
if($scope.panel.refresh.interval < $scope.panel.refresh.min) {
|
if($scope.panel.refresh.interval < $scope.panel.refresh.min) {
|
||||||
$scope.panel.refresh.interval = $scope.panel.refresh.min;
|
$scope.panel.refresh.interval = $scope.panel.refresh.min;
|
||||||
timer.cancel($scope.refresh_timer);
|
timer.cancel($scope.refresh_timer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ angular.module('kibana.timepicker', [])
|
|||||||
// we're in relative mode since we dont want to store the time object in the
|
// we're in relative mode since we dont want to store the time object in the
|
||||||
// json for relative periods
|
// json for relative periods
|
||||||
if($scope.panel.mode !== 'relative') {
|
if($scope.panel.mode !== 'relative') {
|
||||||
$scope.panel.time = {
|
$scope.panel.time = {
|
||||||
from : $scope.time.from.format("MM/DD/YYYY HH:mm:ss"),
|
from : $scope.time.from.format("MM/DD/YYYY HH:mm:ss"),
|
||||||
to : $scope.time.to.format("MM/DD/YYYY HH:mm:ss"),
|
to : $scope.time.to.format("MM/DD/YYYY HH:mm:ss"),
|
||||||
};
|
};
|
||||||
@ -151,7 +151,7 @@ angular.module('kibana.timepicker', [])
|
|||||||
|
|
||||||
$scope.set_mode = function(mode) {
|
$scope.set_mode = function(mode) {
|
||||||
$scope.panel.mode = mode;
|
$scope.panel.mode = mode;
|
||||||
$scope.panel.refresh.enable = mode === 'absolute' ?
|
$scope.panel.refresh.enable = mode === 'absolute' ?
|
||||||
false : $scope.panel.refresh.enable;
|
false : $scope.panel.refresh.enable;
|
||||||
|
|
||||||
update_panel();
|
update_panel();
|
||||||
@ -177,7 +177,7 @@ angular.module('kibana.timepicker', [])
|
|||||||
$scope.time_apply();
|
$scope.time_apply();
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
$scope.time_calc = function(){
|
$scope.time_calc = function(){
|
||||||
var from,to;
|
var from,to;
|
||||||
// If time picker is defined (usually is) TOFIX: Horrible parsing
|
// If time picker is defined (usually is) TOFIX: Horrible parsing
|
||||||
@ -208,17 +208,17 @@ angular.module('kibana.timepicker', [])
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.time_apply = function() {
|
$scope.time_apply = function() {
|
||||||
$scope.panel.error = "";
|
$scope.panel.error = "";
|
||||||
// Update internal time object
|
// Update internal time object
|
||||||
|
|
||||||
// Remove all other time filters
|
// Remove all other time filters
|
||||||
filterSrv.removeByType('time');
|
filterSrv.removeByType('time');
|
||||||
|
|
||||||
|
|
||||||
$scope.time = $scope.time_calc();
|
$scope.time = $scope.time_calc();
|
||||||
$scope.time.field = $scope.panel.timefield;
|
$scope.time.field = $scope.panel.timefield;
|
||||||
|
|
||||||
update_panel();
|
update_panel();
|
||||||
set_time_filter($scope.time);
|
set_time_filter($scope.time);
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ angular.module('kibana.timepicker', [])
|
|||||||
to : {
|
to : {
|
||||||
time : to.format("HH:mm:ss"),
|
time : to.format("HH:mm:ss"),
|
||||||
date : to.format("MM/DD/YYYY")
|
date : to.format("MM/DD/YYYY")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ angular.module('kibana.trends', [])
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Populate scope when we have results
|
// Populate scope when we have results
|
||||||
var process_results = function(results,_segment,query_id) {
|
var process_results = function(results,_segment,query_id) {
|
||||||
results.then(function(results) {
|
results.then(function(results) {
|
||||||
$scope.panelMeta.loading = false;
|
$scope.panelMeta.loading = false;
|
||||||
if(_segment === 0) {
|
if(_segment === 0) {
|
||||||
@ -147,7 +147,7 @@ angular.module('kibana.trends', [])
|
|||||||
$scope.data = [];
|
$scope.data = [];
|
||||||
query_id = $scope.query_id = new Date().getTime();
|
query_id = $scope.query_id = new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for error and abort if found
|
// Check for error and abort if found
|
||||||
if(!(_.isUndefined(results.error))) {
|
if(!(_.isUndefined(results.error))) {
|
||||||
$scope.panel.error = $scope.parse_error(results.error);
|
$scope.panel.error = $scope.parse_error(results.error);
|
||||||
@ -158,7 +158,7 @@ angular.module('kibana.trends', [])
|
|||||||
var facetIds = _.map(_.keys(results.facets),function(k){if(!isNaN(k)){return parseInt(k, 10);}});
|
var facetIds = _.map(_.keys(results.facets),function(k){if(!isNaN(k)){return parseInt(k, 10);}});
|
||||||
|
|
||||||
// Make sure we're still on the same query/queries
|
// Make sure we're still on the same query/queries
|
||||||
if($scope.query_id === query_id &&
|
if($scope.query_id === query_id &&
|
||||||
_.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length
|
_.intersection(facetIds,$scope.panel.queries.ids).length === $scope.panel.queries.ids.length
|
||||||
) {
|
) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
@ -168,17 +168,17 @@ angular.module('kibana.trends', [])
|
|||||||
var o = results.facets['old_'+id].count;
|
var o = results.facets['old_'+id].count;
|
||||||
|
|
||||||
var hits = {
|
var hits = {
|
||||||
new : _.isUndefined($scope.data[i]) || _segment === 0 ? n : $scope.data[i].hits.new+n,
|
new : _.isUndefined($scope.data[i]) || _segment === 0 ? n : $scope.data[i].hits.new+n,
|
||||||
old : _.isUndefined($scope.data[i]) || _segment === 0 ? o : $scope.data[i].hits.old+o
|
old : _.isUndefined($scope.data[i]) || _segment === 0 ? o : $scope.data[i].hits.old+o
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.hits.new += n;
|
$scope.hits.new += n;
|
||||||
$scope.hits.old += o;
|
$scope.hits.old += o;
|
||||||
|
|
||||||
var percent = percentage(hits.old,hits.new) == null ?
|
var percent = percentage(hits.old,hits.new) == null ?
|
||||||
'?' : Math.round(percentage(hits.old,hits.new)*100)/100;
|
'?' : Math.round(percentage(hits.old,hits.new)*100)/100;
|
||||||
// Create series
|
// Create series
|
||||||
$scope.data[i] = {
|
$scope.data[i] = {
|
||||||
info: querySrv.list[id],
|
info: querySrv.list[id],
|
||||||
hits: {
|
hits: {
|
||||||
new : hits.new,
|
new : hits.new,
|
||||||
@ -203,8 +203,8 @@ angular.module('kibana.trends', [])
|
|||||||
return x === 0 ? null : 100*(y-x)/x;
|
return x === 0 ? null : 100*(y-x)/x;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.set_refresh = function (state) {
|
$scope.set_refresh = function (state) {
|
||||||
$scope.refresh = state;
|
$scope.refresh = state;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.close_edit = function() {
|
$scope.close_edit = function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user