Merge "Actionbar: Added notifications"
This commit is contained in:
commit
a108997f03
@ -361,8 +361,6 @@ angular.module('bansho.live', [])
|
|||||||
url: '/surveil/v2/actions/acknowledge/',
|
url: '/surveil/v2/actions/acknowledge/',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: data
|
data: data
|
||||||
}).error(function () {
|
|
||||||
throw new Error('acknowledge : POST Request failed');
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
21
app/components/notifications/notifications.js
Normal file
21
app/components/notifications/notifications.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('bansho.notifications', [])
|
||||||
|
.service('notifications', [
|
||||||
|
function () {
|
||||||
|
var push = function (type, title, message) {
|
||||||
|
$(function(){
|
||||||
|
new PNotify({
|
||||||
|
type: type,
|
||||||
|
title: title,
|
||||||
|
text: message,
|
||||||
|
styling: {},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
"push": push
|
||||||
|
};
|
||||||
|
|
||||||
|
}]);
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('bansho.table.actionbar', ['bansho.table', 'bansho.live'])
|
angular.module('bansho.table.actionbar', ['bansho.table', 'bansho.live', 'bansho.notifications'])
|
||||||
|
|
||||||
.service('actionbarFilters', function () {
|
.service('actionbarFilters', function () {
|
||||||
var actionbarFilters = {
|
var actionbarFilters = {
|
||||||
|
@ -14,28 +14,34 @@ angular.module('bansho.table.actionbar')
|
|||||||
})
|
})
|
||||||
|
|
||||||
.controller('banshoAcknowledgeFormCtrl',
|
.controller('banshoAcknowledgeFormCtrl',
|
||||||
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
|
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', 'notifications',
|
||||||
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) {
|
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient, notifications) {
|
||||||
|
|
||||||
$scope.acknowledgeProblems = function () {
|
$scope.acknowledgeProblems = function () {
|
||||||
angular.forEach(tablesConfig, function (tableConfig) {
|
angular.forEach(tablesConfig, function (table) {
|
||||||
var entries = $filter('filter')(tableConfig.entries,
|
var entries = $filter('filter')(table.entries,
|
||||||
actionbarFilters.searchFilter);
|
actionbarFilters.searchFilter);
|
||||||
|
table.isCheckAll = false;
|
||||||
|
|
||||||
angular.forEach(entries, function (entry) {
|
angular.forEach(entries, function (entry) {
|
||||||
var service_description;
|
var service_description;
|
||||||
|
|
||||||
if (entry.is_checked) {
|
if (entry.is_checked) {
|
||||||
|
entry.is_checked = false;
|
||||||
if ('description' in entry) {
|
if ('description' in entry) {
|
||||||
service_description = entry.description;
|
service_description = entry.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
backendClient.acknowledge(entry.host_name, service_description, $scope.attrs).error(function (data) {
|
backendClient.acknowledge(entry.host_name, service_description, $scope.attrs).then(function (data) {
|
||||||
throw new Error('Acknowledge request failed');
|
notifications.push('success', 'Acknowledgement', 'Acknowledged ' + entry.host_name);
|
||||||
});
|
},
|
||||||
|
function (error) {
|
||||||
|
notifications.push('error', 'Acknowledgement', 'Could not acknowledge ' + entry.host_name);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$scope.isShown = false;
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
@ -51,39 +57,33 @@ angular.module('bansho.table.actionbar')
|
|||||||
})
|
})
|
||||||
|
|
||||||
.controller('banshoDowntimeFormCtrl',
|
.controller('banshoDowntimeFormCtrl',
|
||||||
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
|
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', 'notifications',
|
||||||
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) {
|
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient, notifications) {
|
||||||
|
|
||||||
$scope.messages = [];
|
|
||||||
|
|
||||||
$scope.sendDowntime = function () {
|
$scope.sendDowntime = function () {
|
||||||
angular.forEach(tablesConfig, function (table) {
|
angular.forEach(tablesConfig, function (table) {
|
||||||
var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter);
|
var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter);
|
||||||
|
table.isCheckAll = false;
|
||||||
|
|
||||||
angular.forEach(entries, function (entry) {
|
angular.forEach(entries, function (entry) {
|
||||||
var service_description;
|
var service_description;
|
||||||
|
|
||||||
if (entry.is_checked) {
|
if (entry.is_checked) {
|
||||||
|
entry.is_checked = false;
|
||||||
if ('description' in entry) {
|
if ('description' in entry) {
|
||||||
service_description = entry.description;
|
service_description = entry.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
backendClient.downtime(entry.host_name, service_description, $scope.attrs).then(function (data) {
|
backendClient.downtime(entry.host_name, service_description, $scope.attrs).then(function (data) {
|
||||||
$scope.messages.push({
|
notifications.push('success', 'Downtime', 'Added downtime for ' + entry.host_name);
|
||||||
text: entry.host_name + " success ",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
$scope.isShown = false;
|
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
$scope.messages.push({
|
notifications.push('error', 'Downtime', 'Could not add downtime for ' + entry.host_name);
|
||||||
text: entry.host_name + " error",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
$scope.isShown = false;
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
@ -91,42 +91,33 @@ angular.module('bansho.table.actionbar')
|
|||||||
return {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
templateUrl: 'components/table/actionbar/actions/recheck_button.html',
|
templateUrl: 'components/table/actionbar/actions/recheck_button.html',
|
||||||
scope: {
|
|
||||||
isShown: '='
|
|
||||||
},
|
|
||||||
controller: 'banshoRecheckButtonCtrl'
|
controller: 'banshoRecheckButtonCtrl'
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller('banshoRecheckButtonCtrl',
|
.controller('banshoRecheckButtonCtrl',
|
||||||
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
|
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', 'notifications',
|
||||||
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) {
|
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient, notifications) {
|
||||||
|
|
||||||
$scope.messages = [];
|
|
||||||
|
|
||||||
$scope.sendRecheck = function () {
|
$scope.sendRecheck = function () {
|
||||||
angular.forEach(tablesConfig, function (table) {
|
angular.forEach(tablesConfig, function (table) {
|
||||||
var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter);
|
var entries = $filter('filter')(table.entries, actionbarFilters.searchFilter);
|
||||||
|
table.isCheckAll = false;
|
||||||
|
|
||||||
angular.forEach(entries, function (entry) {
|
angular.forEach(entries, function (entry) {
|
||||||
var service_description;
|
var service_description;
|
||||||
|
|
||||||
if (entry.is_checked) {
|
if (entry.is_checked) {
|
||||||
|
entry.is_checked = false;
|
||||||
if ('description' in entry) {
|
if ('description' in entry) {
|
||||||
service_description = entry.description;
|
service_description = entry.description;
|
||||||
}
|
}
|
||||||
|
|
||||||
backendClient.recheck(entry.host_name, service_description).then(function (data) {
|
backendClient.recheck(entry.host_name, service_description).then(function (data) {
|
||||||
$scope.messages.push({
|
notifications.push('success', 'Recheck', 'Scheduled recheck for ' + entry.host_name);
|
||||||
text: entry.host_name + " success ",
|
|
||||||
type: "success"
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
$scope.messages.push({
|
notifications.push('error', 'Recheck', 'Could not schedule recheck for ' + entry.host_name);
|
||||||
text: entry.host_name + " error",
|
|
||||||
type: "error"
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
<div ng-repeat="message in messages">{{message.text}} + {{message.type}}</div>
|
|
||||||
<h4>Downtime</h4>
|
<h4>Downtime</h4>
|
||||||
<form ng-submit="sendDowntime()">
|
<form ng-submit="sendDowntime()">
|
||||||
<div>
|
<div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<table class="data-table" ng-controller="TableCtrl">
|
<table class="data-table" ng-controller="TableCtrl">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="data-table__checkbox"><input type="checkbox"></th>
|
<th class="data-table__checkbox"><input type="checkbox" ng-click="onCheckChange()" ng-model="isCheckAll"></th>
|
||||||
<th ng-repeat="i in cellIndexes" class="data-table__{{cellsName[i]}}">
|
<th ng-repeat="i in cellIndexes" class="data-table__{{cellsName[i]}}">
|
||||||
{{cellsText[i]}}
|
{{cellsText[i]}}
|
||||||
<i class="ico-up-dir"></i>
|
<i class="ico-up-dir"></i>
|
||||||
|
@ -28,6 +28,20 @@ angular.module('bansho.table', ['bansho.live',
|
|||||||
$scope.cellsText = conf.cells.text;
|
$scope.cellsText = conf.cells.text;
|
||||||
$scope.cellIndexes = [];
|
$scope.cellIndexes = [];
|
||||||
|
|
||||||
|
$scope.$watch(function () {
|
||||||
|
return conf.isCheckAll;
|
||||||
|
}, function () {
|
||||||
|
$scope.isCheckAll = conf.isCheckAll;
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.onCheckChange = function(){
|
||||||
|
conf.isCheckAll = $scope.isCheckAll;
|
||||||
|
angular.forEach(conf.entries, function (entry) {
|
||||||
|
entry.is_checked = $scope.isCheckAll;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < $scope.cellsName.length; i += 1) {
|
for (i = 0; i < $scope.cellsName.length; i += 1) {
|
||||||
$scope.cellIndexes.push(i);
|
$scope.cellIndexes.push(i);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,12 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,400italic' rel='stylesheet' type='text/css'>
|
<link href='http://fonts.googleapis.com/css?family=Roboto:400,700,400italic' rel='stylesheet' type='text/css'>
|
||||||
<link rel="stylesheet" href="assets/css/app.css">
|
<link rel="stylesheet" href="assets/css/app.css">
|
||||||
|
|
||||||
|
<!-- pnotify css -->
|
||||||
|
<link href="bower_components/pnotify/pnotify.core.css" media="all" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="bower_components/pnotify/pnotify.buttons.css" media="all" rel="stylesheet" type="text/css" />
|
||||||
|
<link href="bower_components/pnotify/pnotify.history.css" media="all" rel="stylesheet" type="text/css" />
|
||||||
|
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
|
|
||||||
<!-- build:js js/app.min.js -->
|
<!-- build:js js/app.min.js -->
|
||||||
@ -25,6 +31,14 @@
|
|||||||
<script src="assets/js/scripts.js"></script>
|
<script src="assets/js/scripts.js"></script>
|
||||||
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
|
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
|
||||||
|
|
||||||
|
<!-- pnotify js -->
|
||||||
|
<script src="bower_components/pnotify/pnotify.core.js"></script>
|
||||||
|
<script src="bower_components/pnotify/pnotify.buttons.js"></script>
|
||||||
|
<script src="bower_components/pnotify/pnotify.callbacks.js"></script>
|
||||||
|
<script src="bower_components/pnotify/pnotify.confirm.js"></script>
|
||||||
|
<script src="bower_components/pnotify/pnotify.desktop.js"></script>
|
||||||
|
<script src="bower_components/pnotify/pnotify.nonblock.js"></script>
|
||||||
|
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
<script src="components/config/config.js"></script>
|
<script src="components/config/config.js"></script>
|
||||||
<script src="components/utils/promise_manager.js"></script>
|
<script src="components/utils/promise_manager.js"></script>
|
||||||
@ -32,6 +46,7 @@
|
|||||||
<script src="components/authentication/authentication.js"></script>
|
<script src="components/authentication/authentication.js"></script>
|
||||||
<script src="components/ng-justgage/ng-justgage.js"></script>
|
<script src="components/ng-justgage/ng-justgage.js"></script>
|
||||||
<script src="components/filters/filters.js"></script>
|
<script src="components/filters/filters.js"></script>
|
||||||
|
<script src="components/notifications/notifications.js"></script>
|
||||||
<script src="components/sidebar/sidebar.js"></script>
|
<script src="components/sidebar/sidebar.js"></script>
|
||||||
<script src="components/topbar/topbar.js"></script>
|
<script src="components/topbar/topbar.js"></script>
|
||||||
<script src="components/tactical/tactical.js"></script>
|
<script src="components/tactical/tactical.js"></script>
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"justgage-toorshia": "master",
|
"justgage-toorshia": "master",
|
||||||
"moment": "~2.9.0",
|
"moment": "~2.9.0",
|
||||||
"angular-filter": "~0.5.4",
|
"angular-filter": "~0.5.4",
|
||||||
"angular-cookies": "~1.3.15"
|
"angular-cookies": "~1.3.15",
|
||||||
|
"pnotify": "~2.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user