Commit 65558294 by Rashid Khan

Merge pull request #109 from rashidkpc/master

Fixes for trend panel
parents 0dd0cfeb eb965c4c
<!DOCTYPE html> <!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en" id="ng-app"> <![endif]--> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en" id="ng-app"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en" id="ng-app"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en" id="ng-app"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="Search based application built using ElasticSearch, elastic.js, and Angular.js"> <meta name="description" content="Search based application built using ElasticSearch, elastic.js, and Angular.js">
...@@ -20,16 +20,9 @@ ...@@ -20,16 +20,9 @@
<link rel="stylesheet" href="common/css/elasticjs.css"> <link rel="stylesheet" href="common/css/elasticjs.css">
<link rel="stylesheet" href="common/css/timepicker.css"> <link rel="stylesheet" href="common/css/timepicker.css">
<!-- project dependency libs --> </head>
<script src="common/lib/LAB.min.js"></script>
<script src="common/lib/underscore.min.js"></script>
<script src="common/lib/settings.js"></script>
<script src="config.js"></script>
<script src="js/app.js"></script>
</head> <body ng-controller="DashCtrl" ng-cloak>
<body ng-controller="DashCtrl" ng-cloak>
<div ng-repeat='alert in global_alert' class="alert alert-{{alert.severity}} span12" style="position: fixed;top:2px;opacity:0.9;z-index:8000"> <div ng-repeat='alert in global_alert' class="alert alert-{{alert.severity}} span12" style="position: fixed;top:2px;opacity:0.9;z-index:8000">
<button type="button" class="close" ng-click="clear_alert(alert)">&times;</button> <button type="button" class="close" ng-click="clear_alert(alert)">&times;</button>
<strong>{{alert.title}}</strong> <span ng-bind-html-unsafe='alert.text'></span> <div class='pull-right small'> {{$index + 1}} alert(s) </div> <strong>{{alert.title}}</strong> <span ng-bind-html-unsafe='alert.text'></span> <div class='pull-right small'> {{$index + 1}} alert(s) </div>
...@@ -48,5 +41,13 @@ ...@@ -48,5 +41,13 @@
<div ng-view></div> <div ng-view></div>
</div> </div>
</div> </div>
</body> </body>
<!-- project dependency libs -->
<script src="common/lib/LAB.min.js"></script>
<script src="common/lib/underscore.min.js"></script>
<script src="common/lib/settings.js"></script>
<script src="config.js"></script>
<script src="js/app.js"></script>
</html> </html>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</div> </div>
<div class="span3"> <div class="span3">
<label class="small">Time Ago</label> <label class="small">Time Ago</label>
<input type="text" class="input-small" ng-model="panel.ago"> <input type="text" class="input-small" ng-model="panel.ago" ng-change="set_refresh(true)">
</div> </div>
<div class="span2"> <div class="span2">
<label class="small">Font Size</label> <label class="small">Font Size</label>
...@@ -52,10 +52,7 @@ ...@@ -52,10 +52,7 @@
</form> </form>
</div> </div>
<div class="span8"> <div class="span8">
<form class="input-append" style="margin-bottom: 0px">
<input type="text" style="width:80%" ng-model="q.query" ng-change="set_refresh(true)"> <input type="text" style="width:80%" ng-model="q.query" ng-change="set_refresh(true)">
<button class="btn" ng-click="get_data()"><i class="icon-search"></i></button>
</form>
</div> </div>
<div class="span1"> <div class="span1">
<i class="icon-remove pointer" ng-click="remove_query(q)"></i> <i class="icon-remove pointer" ng-click="remove_query(q)"></i>
......
...@@ -147,7 +147,8 @@ angular.module('kibana.trends', []) ...@@ -147,7 +147,8 @@ angular.module('kibana.trends', [])
$scope.hits.new += n; $scope.hits.new += n;
$scope.hits.old += o; $scope.hits.old += o;
var percent = Math.round(percentage(hits.old,hits.new)*100)/100 var percent = percentage(hits.old,hits.new) == null ?
'?' : Math.round(percentage(hits.old,hits.new)*100)/100
// Create series // Create series
$scope.data[i] = { $scope.data[i] = {
label: $scope.panel.query[i].label || "query"+(parseInt(i)+1), label: $scope.panel.query[i].label || "query"+(parseInt(i)+1),
...@@ -155,7 +156,7 @@ angular.module('kibana.trends', []) ...@@ -155,7 +156,7 @@ angular.module('kibana.trends', [])
new : hits.new, new : hits.new,
old : hits.old old : hits.old
}, },
percent: _.isNull(percent) ? 0 : percent percent: percent
}; };
i++; i++;
...@@ -171,7 +172,7 @@ angular.module('kibana.trends', []) ...@@ -171,7 +172,7 @@ angular.module('kibana.trends', [])
} }
function percentage(x,y) { function percentage(x,y) {
return 100*(y-x)/x return x == 0 ? null : 100*(y-x)/x
} }
$scope.remove_query = function(q) { $scope.remove_query = function(q) {
......
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