Merge pull request #31 from rashidkpc/master

Better errors
This commit is contained in:
Rashid Khan
2013-04-05 13:05:10 -07:00
10 changed files with 2816 additions and 796 deletions
+4 -3
View File
@@ -1,9 +1,10 @@
/*! elastic.js - v1.0.0 - 2013-01-15
/*! elastic.js - v1.0.0 - 2013-03-05
* https://github.com/fullscale/elastic.js
* Copyright (c) 2013 FullScale Labs, LLC; Licensed MIT */
/*jshint browser:true */
/*global angular:true */
/*jshint es5:true */
'use strict';
/*
@@ -26,8 +27,8 @@ angular.module('elasticjs.service', [])
(successcb || angular.noop)(response.data);
return response.data;
}, function (response) {
(errorcb || angular.noop)(undefined);
return undefined;
(errorcb || angular.noop)(response.data);
return response.data;
});
};
+2 -2
View File
@@ -1,4 +1,4 @@
/*! elastic.js - v1.0.0 - 2013-01-15
/*! elastic.js - v1.0.0 - 2013-03-05
* https://github.com/fullscale/elastic.js
* Copyright (c) 2013 FullScale Labs, LLC; Licensed MIT */
"use strict";angular.module("elasticjs.service",[]).factory("ejsResource",["$http",function(e){return function(t){var n=window.ejs||{},r=function(e,t,n){return e.then(function(e){return(t||angular.noop)(e.data),e.data},function(e){return(n||angular.noop)(undefined),undefined})};return t==null&&(t=""),n.client={server:function(e){return e==null?t:(t=e,this)},post:function(n,i,s,o){return n=t+n,r(e.post(n,i),s,o)},get:function(n,i,s,o){return n=t+n,r(e.get(n,i),s,o)},put:function(n,i,s,o){return n=t+n,r(e.put(n,i),s,o)},del:function(n,i,s,o){return n=t+n,r(e.delete(n,i),s,o)},head:function(n,r,i,s){return n=t+n,e.head(n,r).then(function(e){return(i||angular.noop)(e.headers()),e.headers()},function(e){return(s||angular.noop)(undefined),undefined})}},n}}]);
"use strict";angular.module("elasticjs.service",[]).factory("ejsResource",["$http",function(e){return function(t){var n=window.ejs||{},r=function(e,t,n){return e.then(function(e){return(t||angular.noop)(e.data),e.data},function(e){return(n||angular.noop)(undefined),undefined})};return t==null&&(t=""),n.client={server:function(e){return e==null?t:(t=e,this)},post:function(n,i,s,o){return n=t+n,r(e.post(n,i),s,o)},get:function(n,i,s,o){return n=t+n,r(e.get(n,i),s,o)},put:function(n,i,s,o){return n=t+n,r(e.put(n,i),s,o)},del:function(n,i,s,o){return n=t+n,r(e.delete(n,i),s,o)},head:function(n,r,i,s){return n=t+n,e.head(n,r).then(function(e){return(i||angular.noop)(e.headers()),e.headers()},function(e){return(s||angular.noop)(undefined),undefined})}},n}}]);
+2784 -781
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -27,7 +27,7 @@ var labjs = $LAB
.script("common/lib/angular-strap.min.js")
.script("common/lib/angular-sanitize.min.js")
.script("common/lib/elastic.min.js")
.script("common/lib/elastic-angular-client.min.js")
.script("common/lib/elastic-angular-client.js")
.script("common/lib/dateformat.js")
.script("common/lib/date.js")
.script("common/lib/datepicker.js")
+6
View File
@@ -74,6 +74,12 @@ angular.module('kibana.controllers', [])
return 'panels/'+type+'/editor.html';
}
// 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];
}
$scope.init();
})
+2 -1
View File
@@ -187,8 +187,9 @@ angular.module('kibana.dashcontrol', [])
var results = request.query(
$scope.ejs.QueryStringQuery(query || '*')
).size($scope.panel.elasticsearch_size).doSearch();
results.then(function(results) {
if(_.isUndefined(results)) {
if(_.isUndefined(results.hits)) {
return;
}
$scope.panel.error = false;
+1
View File
@@ -12,5 +12,6 @@
<div class='small' style='display:inline-block'>{{series.label}} ({{series.hits}})</div>
</span><span class="small"> per <strong>{{panel.interval}}</strong> | (<strong>{{hits}}</strong> total)</span>
</div>
<center><img ng-show='panel.loading && _.isUndefined(data)' src="common/img/load_big.gif"></center>
<div histogram params="{{panel}}" style="height:{{panel.height || row.height}};position:relative"></div>
</kibana-panel>
+8 -2
View File
@@ -48,6 +48,7 @@ angular.module('kibana.histogram', [])
}
$scope.get_data = function(segment,query_id) {
delete $scope.panel.error
// Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return
@@ -92,6 +93,13 @@ angular.module('kibana.histogram', [])
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);
return;
}
if($scope.query_id === query_id) {
var i = 0;
@@ -183,8 +191,6 @@ angular.module('kibana.histogram', [])
var height = scope.panel.height || scope.row.height;
elem.html('<center><img src="common/img/load_big.gif"></center>')
// Receive render events
scope.$on('render',function(){
render_panel();
+6 -4
View File
@@ -76,6 +76,8 @@ angular.module('kibana.table', [])
}
$scope.get_data = function(segment,query_id) {
$scope.panel.error = false;
// Make sure we have everything for the request to complete
if(_.isUndefined($scope.panel.index) || _.isUndefined($scope.time))
return
@@ -98,7 +100,7 @@ angular.module('kibana.table', [])
$scope.populate_modal(request)
var results = request.doSearch();
var results = request.doSearch()
// Populate scope when we have results
results.then(function(results) {
@@ -110,11 +112,11 @@ angular.module('kibana.table', [])
query_id = $scope.query_id = new Date().getTime()
}
if(_.isUndefined(results)) {
$scope.panel.error = 'Your query was unsuccessful';
// Check for error and abort if found
if(!(_.isUndefined(results.error))) {
$scope.panel.error = $scope.parse_error(results.error);
return;
}
$scope.panel.error = false;
// Check that we're still on the same query, if not stop
if($scope.query_id === query_id) {