Improved error handling via alertSrv service

This commit is contained in:
Rashid Khan
2013-08-26 13:45:31 -07:00
parent c5bc350d4f
commit 809b0a34e7
5 changed files with 93 additions and 53 deletions
+3 -24
View File
@@ -4,7 +4,7 @@
angular.module('kibana.controllers', [])
.controller('DashCtrl', function($scope, $rootScope, $http, $timeout, $route, ejsResource,
fields, dashboard) {
fields, dashboard, alertSrv) {
$scope.editor = {
index: 0
@@ -16,11 +16,12 @@ angular.module('kibana.controllers', [])
// Make underscore.js available to views
$scope._ = _;
$scope.dashboard = dashboard;
$scope.dashAlerts = alertSrv;
alertSrv.clearAll();
// Provide a global list of all see fields
$scope.fields = fields;
$scope.reset_row();
$scope.clear_all_alerts();
var ejs = $scope.ejs = ejsResource(config.elasticsearch);
};
@@ -41,28 +42,6 @@ angular.module('kibana.controllers', [])
return { 'min-height': row.collapse ? '5px' : row.height };
};
$scope.alert = function(title,text,severity,timeout) {
var alert = {
title: title,
text: text,
severity: severity || 'info',
};
$scope.global_alert.push(alert);
if (timeout > 0) {
$timeout(function() {
$scope.global_alert = _.without($scope.global_alert,alert);
}, timeout);
}
};
$scope.clear_alert = function(alert) {
$scope.global_alert = _.without($scope.global_alert,alert);
};
$scope.clear_all_alerts = function() {
$scope.global_alert = [];
};
$scope.edit_path = function(type) {
if(type) {
return 'panels/'+type+'/editor.html';