Commit 09c9e132 by Rashid Khan

Merge pull request #427 from rashidkpc/jshint

Jshint and white space cleanse 
parents ae5ddf87 4a360ffb
......@@ -5,9 +5,9 @@
// Base modules
var modules = [
'kibana.services',
'kibana.controllers',
'kibana.filters',
'kibana.directives',
'kibana.controllers',
'kibana.filters',
'kibana.directives',
'elasticjs.service',
'$strap.directives',
'kibana.panels',
......
......@@ -3,7 +3,7 @@
'use strict';
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) {
$scope.editor = {
......@@ -23,7 +23,7 @@ angular.module('kibana.controllers', [])
$scope.fields = fields;
$scope.reset_row();
var ejs = $scope.ejs = ejsResource(config.elasticsearch);
var ejs = $scope.ejs = ejsResource(config.elasticsearch);
};
$scope.add_row = function(dash,row) {
......@@ -58,7 +58,7 @@ angular.module('kibana.controllers', [])
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) {
var _error = data.match("nested: (.*?);");
return _.isNull(_error) ? data : _error[1];
......
......@@ -9,7 +9,7 @@ angular.module('kibana.directives', [])
link: function(scope, elem, attrs) {
var template = '<i class="icon-spinner small icon-spin icon-large panel-loading" '+
'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">'+
'<span class="small">{{panel.type}}</span> <i class="icon-cog pointer"></i> '+
'</span><h4>'+
......@@ -73,7 +73,7 @@ angular.module('kibana.directives', [])
elm.bind('blur', function() {
scope.$apply(function() {
ngModelCtrl.$setViewValue(elm.val());
});
});
});
}
};
......
/*jshint globalstrict:true */
/*jshint globalstrict:true, forin:false */
/*global angular:true */
/*global Blob:false*/
'use strict';
......
/*jshint forin:false*/
// Wrap this all up in a 'kbn' object so I don't have a billion globals
(function() {
'use strict';
......@@ -102,54 +103,54 @@
kbn.round_interval = function(interval) {
switch (true) {
// 0.5s
case (interval <= 500):
case (interval <= 500):
return 100; // 0.1s
// 5s
case (interval <= 5000):
case (interval <= 5000):
return 1000; // 1s
// 7.5s
case (interval <= 7500):
case (interval <= 7500):
return 5000; // 5s
// 15s
case (interval <= 15000):
case (interval <= 15000):
return 10000; // 10s
// 45s
case (interval <= 45000):
case (interval <= 45000):
return 30000; // 30s
// 3m
case (interval <= 180000):
case (interval <= 180000):
return 60000; // 1m
// 9m
case (interval <= 450000):
case (interval <= 450000):
return 300000; // 5m
// 20m
case (interval <= 1200000):
case (interval <= 1200000):
return 600000; // 10m
// 45m
case (interval <= 2700000):
case (interval <= 2700000):
return 1800000; // 30m
// 2h
case (interval <= 7200000):
case (interval <= 7200000):
return 3600000; // 1h
// 6h
case (interval <= 21600000):
case (interval <= 21600000):
return 10800000; // 3h
// 24h
case (interval <= 86400000):
case (interval <= 86400000):
return 43200000; // 12h
// 48h
case (interval <= 172800000):
case (interval <= 172800000):
return 86400000; // 24h
// 1w
case (interval <= 604800000):
case (interval <= 604800000):
return 86400000; // 24h
// 3w
case (interval <= 1814400000):
case (interval <= 1814400000):
return 604800000; // 1w
// 2y
case (interval < 3628800000):
case (interval < 3628800000):
return 2592000000; // 30d
default:
default:
return 31536000000; // 1y
}
};
......@@ -194,21 +195,21 @@
kbn.interval_to_seconds = function(string) {
var matches = string.match(/(\d+(?:\.\d+)?)([Mwdhmsy])/);
switch (matches[2]) {
case 'y':
case 'y':
return matches[1]*31536000;
case 'M':
case 'M':
return matches[1]*2592000;
case 'w':
case 'w':
return matches[1]*604800;
case 'd':
case 'd':
return matches[1]*86400;
case 'h':
case 'h':
return matches[1]*3600;
case 'm':
case 'm':
return matches[1]*60;
case 's':
case 's':
return matches[1];
}
}
};
// This should go away, moment.js can do this
......@@ -235,7 +236,7 @@
if (objidx > 0) {
strval = strval + ', ';
}
strval = strval + JSON.stringify(obj[objidx]);
}
array[rootname] = strval;
......@@ -299,7 +300,7 @@ _.mixin({
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
return array;
}
}
});
_.mixin({
......@@ -308,7 +309,7 @@ _.mixin({
array.splice(index, 1);
return array;
}
}
});
_.mixin({
......
......@@ -61,7 +61,7 @@ angular.module('kibana.bettermap', [])
$scope.panel.error = "Please select a field that contains geo point in [lon,lat] format";
return;
}
// Determine the field to sort on
var timeField = _.uniq(_.pluck(filterSrv.getByType('time'),'field'));
if(timeField.length > 1) {
......@@ -75,7 +75,7 @@ angular.module('kibana.bettermap', [])
var _segment = _.isUndefined(segment) ? 0 : segment;
$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();
_.each($scope.panel.queries.ids,function(id) {
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
......@@ -132,7 +132,7 @@ angular.module('kibana.bettermap', [])
} else {
return;
}
$scope.$emit('draw');
// Get $size results then stop querying
......@@ -169,12 +169,12 @@ angular.module('kibana.bettermap', [])
var map, markers, layerGroup, mcg;
function render_panel() {
function render_panel() {
scope.panelMeta.loading = false;
var scripts = $LAB.script("panels/bettermap/lib/leaflet.js").wait()
.script("panels/bettermap/lib/plugins.js");
//add markers dynamically
scripts.wait(function(){
if(_.isUndefined(map)) {
......
......@@ -6,7 +6,7 @@
### Parameters
* panels :: an array of panel objects. All of their spans should be set to 12
*/
'use strict';
......@@ -84,7 +84,7 @@ angular.module('kibana.column', [])
}
elem.html($compile(angular.element(template))(scope));
});
});
});
}
};
}).filter('withoutColumn', function() {
......
......@@ -17,7 +17,7 @@
* hide_control :: Upon save, hide this panel
* elasticsearch_size :: show this many dashboards under the ES section in the load drop down
* temp :: Allow saving of temp dashboards
* ttl :: Enable setting ttl.
* ttl :: Enable setting ttl.
* temp_ttl :: How long should temp dashboards persist
*/
......@@ -91,7 +91,7 @@ angular.module('kibana.dashcontrol', [])
).then(
function(result) {
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);
if(type === 'temp') {
$scope.share = dashboard.share_link(dashboard.current.title,'temp',result._id);
......
......@@ -5,7 +5,7 @@
## Derivequeries
### 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
* field :: the field to facet on
* rest :: include a filter that matches all other terms,
......@@ -54,7 +54,7 @@ angular.module('kibana.derivequeries', [])
$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;
......@@ -122,8 +122,8 @@ angular.module('kibana.derivequeries', [])
});
};
$scope.set_refresh = function (state) {
$scope.refresh = state;
$scope.set_refresh = function (state) {
$scope.refresh = state;
};
$scope.close_edit = function() {
......
......@@ -23,7 +23,7 @@ angular.module('kibana.fields', [])
var _d = {
style : {},
arrange : 'vertical',
micropanel_position : 'right',
micropanel_position : 'right',
};
_.defaults($scope.panel,_d);
......
......@@ -10,7 +10,7 @@
* arrangement :: How should I arrange the query results? 'horizontal' or 'vertical'
* chart :: Show a chart? 'none', 'bar', 'pie'
* 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?
*/
......@@ -48,7 +48,7 @@ angular.module('kibana.hits', [])
$scope.init = function () {
$scope.hits = 0;
$scope.$on('refresh',function(){
$scope.get_data();
});
......@@ -67,14 +67,14 @@ angular.module('kibana.hits', [])
var _segment = _.isUndefined(segment) ? 0 : segment;
var request = $scope.ejs.Request().indices(dashboard.indices[_segment]);
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
// Build the question part of the query
_.each($scope.panel.queries.ids, function(id) {
var _q = $scope.ejs.FilteredQuery(
querySrv.getEjsObj(id),
filterSrv.getBoolFilter(filterSrv.ids));
request = request
.facet($scope.ejs.QueryFacet(id)
.query(_q)
......@@ -95,7 +95,7 @@ angular.module('kibana.hits', [])
$scope.data = [];
query_id = $scope.query_id = new Date().getTime();
}
// Check for error and abort if found
if(!(_.isUndefined(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);});
// 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
) {
var i = 0;
_.each($scope.panel.queries.ids, function(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;
$scope.hits += v.count;
// Create series
$scope.data[i] = {
$scope.data[i] = {
info: querySrv.list[id],
id: id,
hits: hits,
......@@ -130,13 +130,13 @@ angular.module('kibana.hits', [])
if(_segment < dashboard.indices.length-1) {
$scope.get_data(_segment+1,query_id);
}
}
});
};
$scope.set_refresh = function (state) {
$scope.refresh = state;
$scope.set_refresh = function (state) {
$scope.refresh = state;
};
$scope.close_edit = function() {
......@@ -161,7 +161,7 @@ angular.module('kibana.hits', [])
scope.$on('render',function(){
render_panel();
});
// Re-render if the window is resized
angular.element(window).bind('resize', function(){
render_panel();
......@@ -186,7 +186,7 @@ angular.module('kibana.hits', [])
scripts.wait(function(){
// Populate element
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') {
scope.plot = $.plot(elem, scope.data, {
legend: { show: false },
......@@ -222,7 +222,7 @@ angular.module('kibana.hits', [])
stroke: {
width: 0
},
label: {
label: {
show: scope.panel.labels,
radius: 2/3,
formatter: function(label, series){
......@@ -230,7 +230,7 @@ angular.module('kibana.hits', [])
' "style="font-size:8pt;text-align:center;padding:2px;color:white;">'+
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) {
var tooltip = $('#pie-tooltip').length ?
var tooltip = $('#pie-tooltip').length ?
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
//var tooltip = $('#pie-tooltip')
tooltip.html(contents).css({
......@@ -265,7 +265,7 @@ angular.module('kibana.hits', [])
elem.bind("plothover", function (event, pos, item) {
if (item) {
var value = scope.panel.chart === 'bar' ?
var value = scope.panel.chart === 'bar' ?
item.datapoint[1] : item.datapoint[1][0][1];
tt(pos.pageX, pos.pageY,
"<div style='vertical-align:middle;border-radius:10px;display:inline-block;background:"+
......
......@@ -7,8 +7,8 @@
### Parameters
* map :: 'world', 'us' or 'europe'
* 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
* 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
* size :: How big to make the facet. Higher = more countries
* exclude :: Exlude the array of counties
* spyable :: Show the 'eye' icon that reveals the last ES query
......@@ -53,7 +53,7 @@ angular.module('kibana.map', [])
};
$scope.get_data = function() {
// Make sure we have everything for the request to complete
if(dashboard.indices.length === 0) {
return;
......@@ -65,7 +65,7 @@ angular.module('kibana.map', [])
request = $scope.ejs.Request().indices(dashboard.indices);
$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();
_.each($scope.panel.queries.ids,function(id) {
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
......@@ -106,8 +106,8 @@ angular.module('kibana.map', [])
body : "<h5>Last Elasticsearch Query</h5><pre>"+
'curl -XGET '+config.elasticsearch+'/'+dashboard.indices+"/_search?pretty -d'\n"+
angular.toJson(JSON.parse(request.toString()),true)+
"'</pre>",
};
"'</pre>",
};
};
$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
var scripts = $LAB.script("panels/map/lib/jquery.jvectormap.min.js").wait()
.script("panels/map/lib/map."+scope.panel.map+".js");
// Populate element. Note that jvectormap appends, does not replace.
scripts.wait(function(){
elem.text('');
$('.jvectormap-zoomin,.jvectormap-zoomout,.jvectormap-label').remove();
var map = elem.vectorMap({
var map = elem.vectorMap({
map: scope.panel.map,
regionStyle: {initial: {fill: '#8c8c8c'}},
zoomOnScroll: false,
......
......@@ -14,7 +14,7 @@
* legend :: Show the legend?
* labels :: Label the slices of the pie?
* 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
* spyable :: Show the 'eye' icon that displays the last ES query for this panel
*/
......@@ -36,7 +36,7 @@ angular.module('kibana.pie', [])
editorTabs : [
{title:'Queries', src:'partials/querySelect.html'}
],
query : { field:"_type", goal: 100},
query : { field:"_type", goal: 100},
queries : {
mode : 'all',
ids : []
......@@ -70,8 +70,8 @@ angular.module('kibana.pie', [])
}
};
$scope.set_refresh = function (state) {
$scope.refresh = state;
$scope.set_refresh = function (state) {
$scope.refresh = state;
};
$scope.close_edit = function() {
......@@ -83,18 +83,18 @@ angular.module('kibana.pie', [])
};
$scope.get_data = function() {
// 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);
$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();
_.each($scope.panel.queries.ids,function(id) {
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
......@@ -127,7 +127,7 @@ angular.module('kibana.pie', [])
$scope.data = [];
var k = 0;
_.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(slice);
k = k + 1;
......@@ -140,9 +140,9 @@ angular.module('kibana.pie', [])
.query(boolQuery)
.filter(filterSrv.getBoolFilter(filterSrv.ids))
.size(0);
$scope.populate_modal(request);
results = request.doSearch();
results.then(function(results) {
......@@ -165,8 +165,8 @@ angular.module('kibana.pie', [])
body : "<h5>Last Elasticsearch Query</h5><pre>"+
'curl -XGET '+config.elasticsearch+'/'+dashboard.indices+"/_search?pretty -d'\n"+
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()
.script("common/lib/panels/jquery.flot.pie.js");
var label;
if(scope.panel.mode === 'goal') {
label = {
label = {
show: scope.panel.labels,
radius: 0,
formatter: function(label, series){
......@@ -211,15 +211,15 @@ angular.module('kibana.pie', [])
}
},
};
} else {
label = {
} else {
label = {
show: scope.panel.labels,
radius: 2/3,
formatter: function(label, series){
return '<div "style="font-size:8pt;text-align:center;padding:2px;color:white;">'+
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: {
grid: {
backgroundColor: null,
hoverable: true,
clickable: true
hoverable: true,
clickable: true
},
legend: { show: false },
colors: querySrv.colors
......@@ -263,7 +263,7 @@ angular.module('kibana.pie', [])
}
function tt(x, y, contents) {
var tooltip = $('#pie-tooltip').length ?
var tooltip = $('#pie-tooltip').length ?
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
tooltip.html(contents).css({
......
......@@ -5,9 +5,9 @@
## query
### 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
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
*/
......
......@@ -6,14 +6,14 @@
### Parameters
* 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
* 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')
* style :: hash of css properties
* fields :: columns to show in table
* 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.
* sortable :: Allow sorting?
* spyable :: Show the 'eye' icon that reveals the last ES query for this panel
......@@ -110,7 +110,7 @@ angular.module('kibana.table', [])
} else {
$scope.panel.highlight.push(field);
}
};
};
$scope.toggle_details = function(row) {
row.kibana = row.kibana || {};
......@@ -147,7 +147,7 @@ angular.module('kibana.table', [])
if(dashboard.indices.length === 0) {
return;
}
$scope.panelMeta.loading = true;
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
......@@ -208,14 +208,14 @@ angular.module('kibana.table', [])
_sort : hit.sort
};
}));
$scope.hits += results.hits.total;
// Sort the data
$scope.data = _.sortBy($scope.data, function(v){
return v._sort[0];
});
// Reverse if needed
if($scope.panel.sort[1] === 'desc') {
$scope.data.reverse();
......@@ -245,14 +245,14 @@ angular.module('kibana.table', [])
};
$scope.without_kibana = function (row) {
return {
return {
_source : row._source,
highlight : row.highlight
};
};
};
$scope.set_refresh = function (state) {
$scope.refresh = state;
$scope.set_refresh = function (state) {
$scope.refresh = state;
};
$scope.close_edit = function() {
......@@ -296,7 +296,7 @@ angular.module('kibana.table', [])
type = fields.mapping[event._index][event._type][field]['type'];
if(type === 'date' && scope.panel.normTimes) {
return moment(text).format('YYYY-MM-DD HH:mm:ss');
}
}
}
return text;
};
......
......@@ -11,7 +11,7 @@
* arrangement :: How should I arrange the query results? 'horizontal' or 'vertical'
* chart :: Show a chart? 'none', 'bar', 'pie'
* 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?
*/
......@@ -26,7 +26,7 @@ angular.module('kibana.terms', [])
{title:'Queries', src:'partials/querySelect.html'}
],
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"
};
......@@ -55,7 +55,7 @@ angular.module('kibana.terms', [])
$scope.init = function () {
$scope.hits = 0;
$scope.$on('refresh',function(){
$scope.get_data();
});
......@@ -67,7 +67,7 @@ angular.module('kibana.terms', [])
// Make sure we have everything for the request to complete
if(dashboard.indices.length === 0) {
return;
}
}
$scope.panelMeta.loading = true;
var request,
......@@ -77,7 +77,7 @@ angular.module('kibana.terms', [])
request = $scope.ejs.Request().indices(dashboard.indices);
$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();
_.each($scope.panel.queries.ids,function(id) {
boolQuery = boolQuery.should(querySrv.getEjsObj(id));
......@@ -108,11 +108,11 @@ angular.module('kibana.terms', [])
$scope.hits = results.hits.total;
$scope.data = [];
_.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);
k = k + 1;
});
$scope.data.push({label:'Missing field',
data:[[k,results.facets.terms.missing]],meta:"missing",color:'#aaa',opacity:0});
$scope.data.push({label:'Other values',
......@@ -135,8 +135,8 @@ angular.module('kibana.terms', [])
dashboard.refresh();
};
$scope.set_refresh = function (state) {
$scope.refresh = state;
$scope.set_refresh = function (state) {
$scope.refresh = state;
};
$scope.close_edit = function() {
......@@ -169,7 +169,7 @@ angular.module('kibana.terms', [])
scope.$on('render',function(){
render_panel();
});
// Re-render if the window is resized
angular.element(window).bind('resize', function(){
render_panel();
......@@ -186,16 +186,16 @@ angular.module('kibana.terms', [])
// Make a clone we can operate on.
chartData = _.clone(scope.data);
chartData = scope.panel.missing ? chartData :
chartData = scope.panel.missing ? chartData :
_.without(chartData,_.findWhere(chartData,{meta:'missing'}));
chartData = scope.panel.other ? chartData :
chartData = scope.panel.other ? chartData :
_.without(chartData,_.findWhere(chartData,{meta:'other'}));
// Populate element.
scripts.wait(function(){
// Populate element
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') {
plot = $.plot(elem, chartData, {
legend: { show: false },
......@@ -238,11 +238,11 @@ angular.module('kibana.terms', [])
stroke: {
width: 0
},
label: {
label: {
show: scope.panel.labels,
radius: 2/3,
formatter: labelFormat,
threshold: 0.1
threshold: 0.1
}
}
},
......@@ -269,7 +269,7 @@ angular.module('kibana.terms', [])
}
function tt(x, y, contents) {
var tooltip = $('#pie-tooltip').length ?
var tooltip = $('#pie-tooltip').length ?
$('#pie-tooltip') : $('<div id="pie-tooltip"></div>');
//var tooltip = $('#pie-tooltip')
tooltip.html(contents).css({
......@@ -293,7 +293,7 @@ angular.module('kibana.terms', [])
elem.bind("plothover", function (event, pos, item) {
if (item) {
var value = scope.panel.chart === 'bar' ?
var value = scope.panel.chart === 'bar' ?
item.datapoint[1] : item.datapoint[1][0][1];
tt(pos.pageX, pos.pageY,
"<div style='vertical-align:middle;border-radius:10px;display:inline-block;background:"+
......
......@@ -9,7 +9,7 @@
* mode :: 'text', 'html', 'markdown'
* content :: Content of the panel
* style :: Hash containing css properties
*/
'use strict';
......@@ -35,7 +35,7 @@ angular.module('kibana.text', [])
$scope.init = function() {
$scope.ready = false;
};
}).directive('markdown', function() {
return {
restrict: 'E',
......
......@@ -36,7 +36,7 @@ angular.module('kibana.timepicker', [])
timefield : '@timestamp',
timeformat : "",
refresh : {
enable : false,
enable : false,
interval: 30,
min : 3
}
......@@ -112,7 +112,7 @@ angular.module('kibana.timepicker', [])
$scope.panel.refresh.interval = refresh_interval;
if(_.isNumber($scope.panel.refresh.interval)) {
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);
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
// json for relative periods
if($scope.panel.mode !== 'relative') {
$scope.panel.time = {
$scope.panel.time = {
from : $scope.time.from.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.panel.mode = mode;
$scope.panel.refresh.enable = mode === 'absolute' ?
$scope.panel.refresh.enable = mode === 'absolute' ?
false : $scope.panel.refresh.enable;
update_panel();
......@@ -177,7 +177,7 @@ angular.module('kibana.timepicker', [])
$scope.time_apply();
};
//
//
$scope.time_calc = function(){
var from,to;
// If time picker is defined (usually is) TOFIX: Horrible parsing
......@@ -208,17 +208,17 @@ angular.module('kibana.timepicker', [])
};
};
$scope.time_apply = function() {
$scope.panel.error = "";
$scope.time_apply = function() {
$scope.panel.error = "";
// Update internal time object
// Remove all other time filters
filterSrv.removeByType('time');
$scope.time = $scope.time_calc();
$scope.time.field = $scope.panel.timefield;
update_panel();
set_time_filter($scope.time);
......@@ -254,7 +254,7 @@ angular.module('kibana.timepicker', [])
to : {
time : to.format("HH:mm:ss"),
date : to.format("MM/DD/YYYY")
}
}
};
}
......
......@@ -139,7 +139,7 @@ angular.module('kibana.trends', [])
};
// 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) {
$scope.panelMeta.loading = false;
if(_segment === 0) {
......@@ -147,7 +147,7 @@ angular.module('kibana.trends', [])
$scope.data = [];
query_id = $scope.query_id = new Date().getTime();
}
// Check for error and abort if found
if(!(_.isUndefined(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);}});
// 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
) {
var i = 0;
......@@ -168,17 +168,17 @@ angular.module('kibana.trends', [])
var o = results.facets['old_'+id].count;
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
};
$scope.hits.new += n;
$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;
// Create series
$scope.data[i] = {
$scope.data[i] = {
info: querySrv.list[id],
hits: {
new : hits.new,
......@@ -203,8 +203,8 @@ angular.module('kibana.trends', [])
return x === 0 ? null : 100*(y-x)/x;
}
$scope.set_refresh = function (state) {
$scope.refresh = state;
$scope.set_refresh = function (state) {
$scope.refresh = state;
};
$scope.close_edit = function() {
......
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