Merge "Improve login and logout + replaced tabs by spaces"

This commit is contained in:
Jenkins 2015-05-15 20:35:27 +00:00 committed by Gerrit Code Review
commit 404011bf7e
24 changed files with 525 additions and 462 deletions

View File

@ -18,13 +18,13 @@ module.exports = function (grunt) {
clean: { clean: {
dist: [ dist: [
'<%= project.dist %>/assets/', '<%= project.dist %>/assets/',
'<%= project.dist %>/bower_components/', '<%= project.dist %>/bower_components/',
'<%= project.dist %>/components/', '<%= project.dist %>/components/',
'<%= project.dist %>/js/', '<%= project.dist %>/js/',
'<%= project.dist %>/templates/', '<%= project.dist %>/templates/',
'<%= project.dist %>/index.html' '<%= project.dist %>/index.html'
], ],
tmp: ['<%= project.tmp %>/'] tmp: ['<%= project.tmp %>/']
}, },
@ -84,31 +84,31 @@ module.exports = function (grunt) {
}, },
jshint: { // configure the task jshint: { // configure the task
options: { options: {
node: true, node: true,
loopfunc: true, loopfunc: true,
globals: { globals: {
document: true, document: true,
angular: true, angular: true,
jQuery: true, jQuery: true,
$: true, $: true,
describe: true, describe: true,
it: true, it: true,
expect: true, expect: true,
beforeEach: true, beforeEach: true,
inject: true inject: true
}, },
force: true force: true
}, },
all: [ all: [
'karma.conf.js', 'karma.conf.js',
'Gruntfile.js', 'Gruntfile.js',
'<%= project.app %>/app.js', '<%= project.app %>/app.js',
'<%= project.app %>/**/*.js', '<%= project.app %>/**/*.js',
'!<%= project.app %>/bower_components/**', '!<%= project.app %>/bower_components/**',
'!<%= project.app %>/**/live.js', '!<%= project.app %>/**/live.js',
'!<%= project.app %>/**/adagios.js' '!<%= project.app %>/**/adagios.js'
] ]
}, },
useminPrepare: { useminPrepare: {
@ -166,8 +166,8 @@ module.exports = function (grunt) {
'<%= project.app %>/components/live/surveil.js', '<%= project.app %>/components/live/surveil.js',
'<%= project.assets %>/sass/{,*/}*.{scss,sass}' '<%= project.assets %>/sass/{,*/}*.{scss,sass}'
], ],
tasks: ['production:surveil'] tasks: ['production:surveil']
}, },
options: { options: {
livereload: true livereload: true
} }

View File

@ -2,7 +2,8 @@
angular.module('bansho', [ angular.module('bansho', [
'ngRoute', 'ngRoute',
'angular.filter', 'ngCookies',
'angular.filter',
'bansho.config', 'bansho.config',
'bansho.authentication', 'bansho.authentication',
'bansho.utils.promiseManager', 'bansho.utils.promiseManager',

View File

@ -1,22 +1,22 @@
var AdagiosUI = (function() { var AdagiosUI = (function() {
"use strict"; "use strict";
// States for UI modifications // States for UI modifications
var state = { var state = {
visible: 'state--visible', visible: 'state--visible',
hidden: 'state--hidden', hidden: 'state--hidden',
current: 'state--current', current: 'state--current',
open: 'state--open', open: 'state--open',
fadeIn: 'state--fadein', fadeIn: 'state--fadein',
fadeOut: 'state--fadeout', fadeOut: 'state--fadeout',
hasChild: 'state--haschild' hasChild: 'state--haschild'
}; };
// Breakpoints for the responsive web design // Breakpoints for the responsive web design
var mquery = { var mquery = {
phone: 480, phone: 480,
tablet: 959 tablet: 959
}; };
var test = function() { var test = function() {
console.log(); console.log();
@ -37,12 +37,12 @@ var AdagiosUI = (function() {
}); });
}; };
return { return {
state: state, state: state,
test: test, test: test,
mquery: mquery, mquery: mquery,
syncBkgCheckbox : syncBkgCheckbox, syncBkgCheckbox : syncBkgCheckbox,
closeSidebar : closeSidebar closeSidebar : closeSidebar
}; };
})(); })();

View File

@ -55,3 +55,8 @@
@import '../../components/topbar/topbar'; @import '../../components/topbar/topbar';
@import '../../components/sidebar/sidebar'; @import '../../components/sidebar/sidebar';
@import '../../components/tactical/tactical'; @import '../../components/tactical/tactical';
//----------------------------------*\
// TEMPORARY MODULES
//----------------------------------*/
@import 'temporary';

View File

@ -207,7 +207,7 @@ table {
//overflow-x:auto; //overflow-x:auto;
//@include medium-and-up-screen { //@include medium-and-up-screen {
// display:table; // display:table;
// overflow-x:visible; // overflow-x:visible;
//} //}
} }

View File

@ -34,15 +34,15 @@
position: absolute; position: absolute;
width: 1px; width: 1px;
&.focusable:active, &.focusable:active,
&.focusable:focus { &.focusable:focus {
clip: auto; clip: auto;
height: auto; height: auto;
margin: 0; margin: 0;
overflow: visible; overflow: visible;
position: static; position: static;
width: auto; width: auto;
} }
} }

View File

@ -10,7 +10,7 @@
@include medium-and-up-screen { @include medium-and-up-screen {
border:0; border:0;
display:table; display:table;
min-height:0; min-height:0;
overflow-x:visible; overflow-x:visible;
width:100%; width:100%;

View File

@ -0,0 +1,32 @@
.centered {
position: fixed;
margin-top: 15px;
left: 50%;
transform: translate(-50%);
}
.bansho-title {
color: #ddd;
font-size: 300%;
padding-bottom: 0px;
margin-bottom: 0px;
}
.form-group {
padding-top: 5px;
padding-bottom: 15px;
}
.form-control {
width: 500px;
}
.field {
float: right;
width: 400px;
}
.label {
width: 85px;
padding-right: 15px;
}

View File

@ -1,19 +1,31 @@
<form name="loginForm" <div class="centered">
ng-controller="LoginController" <h1 class="bansho-title">Bansho</h1>
ng-submit="login(credentials)" novalidate> <p>Web client for Surveil</p>
<label for="username">Username:</label> <h2>Login</h2>
<input type="text" id="username" <br>
ng-model="credentials.auth.passwordCredentials.username"> <form name="loginForm"
ng-controller="LoginController"
ng-submit="login(credentials)" novalidate>
<label for="password">Password:</label> <div class="form-group">
<input type="password" id="password" <label for="username" class="label">Username:</label>
ng-model="credentials.auth.passwordCredentials.password"> <input type="text" id="username" class="form-control field"
ng-model="credentials.auth.passwordCredentials.username">
</div>
<label for="tenantName">Tenant Name:</label> <div class="form-group">
<input type="text" id="tenant-name" <label for="password" class="label">Password:</label>
ng-model="credentials.auth.tenantName"> <input type="password" class="form-control field" id="password"
ng-model="credentials.auth.passwordCredentials.password">
</div>
<button type="submit">Login</button> <div class="form-group">
<label for="tenantName" class="label">Tenant Name:</label>
<input type="text" id="tenant-name"class="form-control field"
ng-model="credentials.auth.tenantName">
</div>
</form> <button type="submit">Login</button>
</form>
</div>

View File

@ -10,7 +10,7 @@ angular.module('bansho.authentication', [])
}]) }])
.controller('LoginController', ['$scope', '$rootScope', '$location', 'authService', 'configManager', function ($scope, $rootScope, $location, authService, configManager) { .controller('LoginController', ['$scope', '$rootScope', '$location', 'authService', 'configManager', function ($scope, $rootScope, $location, authService, configManager) {
var login = function (credentials) { var login = function (credentials) {
authService.login(credentials); authService.login(credentials);
}; };
@ -25,27 +25,31 @@ angular.module('bansho.authentication', [])
}; };
$scope.login = function() { $scope.login = function() {
login($scope.credentials); login($scope.credentials);
}; };
configManager.loadDevelopmentConfig().then(function () { if (authService.isAuthenticated()) {
var devConfig = configManager.getDevelopmentConfig(); login($scope.credentials);
if (devConfig.env === 'development') { }
login({
'auth': { configManager.loadDevelopmentConfig().then(function () {
'tenantName': '', var devConfig = configManager.getDevelopmentConfig();
'passwordCredentials': { if (devConfig.env === 'development') {
'username': devConfig.username, login({
'password': devConfig.password 'auth': {
} 'tenantName': '',
} 'passwordCredentials': {
}); 'username': devConfig.username,
} 'password': devConfig.password
}
}
});
}
}, function () {
// Development config failed
});
}, function () {
// Development config failed
});
}]) }])
.factory('authService', ['$http', '$location', '$rootScope', 'session', 'configManager', function ($http, $location, $rootScope, session, configManager) { .factory('authService', ['$http', '$location', '$rootScope', 'session', 'configManager', function ($http, $location, $rootScope, session, configManager) {
@ -73,21 +77,33 @@ angular.module('bansho.authentication', [])
}; };
authService.isAuthenticated = function () { authService.isAuthenticated = function () {
return !!session.sessionId; return !!session.isUserConnected();
}; };
authService.logout = function () {
$rootScope.isAuthenticated = false;
session.destroy();
$location.path('/login');
};
return authService; return authService;
}]) }])
.service('session', function () { .service('session', ['$cookies', function ($cookies) {
this.isUserConnected = function () {
return $cookies.connected === 'true';
};
this.create = function (sessionId, expirationTime) { this.create = function (sessionId, expirationTime) {
this.sessionId = sessionId; this.sessionId = sessionId;
this.expirationTime = expirationTime; this.expirationTime = expirationTime;
$cookies.connected = 'true';
}; };
this.destroy = function () { this.destroy = function () {
this.sessionId = null; this.sessionId = null;
this.expirationTime = null; this.expirationTime = null;
$cookies.connected = 'false';
}; };
}); }]);

View File

@ -5,26 +5,26 @@ angular.module('bansho.config', [])
.service('configManager', ['$http', '$q', function ($http, $q) { .service('configManager', ['$http', '$q', function ($http, $q) {
var config = {}, var config = {},
developmentConfig = {}; developmentConfig = {};
this.loadDevelopmentConfig = function() { this.loadDevelopmentConfig = function() {
var promise = $q.defer(); var promise = $q.defer();
$http.get('components/config/developmentConfig.json') $http.get('components/config/developmentConfig.json')
.success(function (config) { .success(function (config) {
developmentConfig = config; developmentConfig = config;
promise.resolve(); promise.resolve();
}) })
.error(function() { .error(function() {
promise.reject(); promise.reject();
}); });
return promise.promise; return promise.promise;
}; };
this.getDevelopmentConfig = function () { this.getDevelopmentConfig = function () {
return developmentConfig; return developmentConfig;
}; };
this.loadByTemplate = function (templateName, destination) { this.loadByTemplate = function (templateName, destination) {
var viewsConfig = config.data; var viewsConfig = config.data;

View File

@ -219,13 +219,13 @@
] ]
}, },
"host": { "host": {
"title": "Host", "title": "Host",
"refreshInterval": 0, "refreshInterval": 0,
"template": "host" "template": "host"
}, },
"service": { "service": {
"title": "Service", "title": "Service",
"refreshInterval": 0, "refreshInterval": 0,
"template": "service" "template": "service"
} }
} }

View File

@ -1,5 +1,5 @@
{ {
"env": "development", "env": "production",
"username":"", "username":"",
"password":"" "password":""
} }

View File

@ -324,20 +324,20 @@ angular.module('bansho.live', [])
}; };
var acknowledge = function (host_name, service_description, attrs) { var acknowledge = function (host_name, service_description, attrs) {
var data = {}; var data = {};
data.host_name = host_name; data.host_name = host_name;
if (attrs.sticky) { if (attrs.sticky) {
data.sticky = parseInt(attrs.sticky, 10); data.sticky = parseInt(attrs.sticky, 10);
} }
if (attrs.notify) { if (attrs.notify) {
data.notify = parseInt(attrs.notify, 10); data.notify = parseInt(attrs.notify, 10);
} }
if (attrs.persistent) { if (attrs.persistent) {
data.persistent = parseInt(attrs.persistent, 10); data.persistent = parseInt(attrs.persistent, 10);
} }
if (service_description !== undefined) { if (service_description !== undefined) {
data.service_description = service_description; data.service_description = service_description;
@ -353,47 +353,47 @@ angular.module('bansho.live', [])
}; };
var downtime = function (host_name, service_description, attrs) { var downtime = function (host_name, service_description, attrs) {
attrs.host_name = host_name; attrs.host_name = host_name;
if (service_description !== undefined) { if (service_description !== undefined) {
attrs.service_description = service_description; attrs.service_description = service_description;
} }
return $http({ return $http({
url: '/surveil/v2/actions/downtime/', url: '/surveil/v2/actions/downtime/',
method: 'POST', method: 'POST',
data: attrs data: attrs
}); });
}; };
var recheck = function (host_name, service_description) { var recheck = function (host_name, service_description) {
var attrs = {}; var attrs = {};
attrs.host_name = host_name; attrs.host_name = host_name;
if (service_description !== undefined) { if (service_description !== undefined) {
attrs.service_description = service_description; attrs.service_description = service_description;
} }
return $http({ return $http({
url: '/surveil/v2/actions/recheck/', url: '/surveil/v2/actions/recheck/',
method: 'POST', method: 'POST',
data: attrs data: attrs
}); });
}; };
return { return {
getHost: getHost, getHost: getHost,
getObjects : getObjects, getObjects : getObjects,
getService : getService, getService : getService,
hostQueryTransform: hostQueryTransform, hostQueryTransform: hostQueryTransform,
acknowledge: acknowledge, acknowledge: acknowledge,
getHostOpenProblems: getHostOpenProblems, getHostOpenProblems: getHostOpenProblems,
hostMiddleware: hostMiddleware, hostMiddleware: hostMiddleware,
getServiceProblems: getServiceProblems, getServiceProblems: getServiceProblems,
getServiceOpenProblems: getServiceOpenProblems, getServiceOpenProblems: getServiceOpenProblems,
getHostProblems: getHostProblems, getHostProblems: getHostProblems,
getTableData: getTableData, getTableData: getTableData,
getTotalHosts: getTotalHosts, getTotalHosts: getTotalHosts,
getTotalServices: getTotalServices, getTotalServices: getTotalServices,
downtime: downtime, downtime: downtime,
recheck: recheck recheck: recheck
}; };
}]); }]);

View File

@ -1,90 +1,90 @@
<menu class="filters" ng-controller="TableActionbarCtrl"> <menu class="filters" ng-controller="TableActionbarCtrl">
<ul class="filters__list clearfix"> <ul class="filters__list clearfix">
<li class="filters__item filters__item--problems"> <li class="filters__item filters__item--problems">
<button class="filters__button" <button class="filters__button"
type="button" type="button"
data-toggle="collapse" data-toggle="collapse"
data-target="#filtersProblems" data-target="#filtersProblems"
aria-expanded="false" aria-expanded="false"
aria-controls="filtersProblems"> aria-controls="filtersProblems">
<span>{{ actionbarFilters.activeFilter.text }}</span> <span>{{ actionbarFilters.activeFilter.text }}</span>
<i class="ico-down-dir"></i> <i class="ico-down-dir"></i>
</button> </button>
<div class="filters__panel collapse" id="filtersProblems"> <div class="filters__panel collapse" id="filtersProblems">
<ul class="filters__sublist"> <ul class="filters__sublist">
<li class="filters__subitem" ng-repeat="actionbarFilter in actionbarFilters.possibleFilters" ng-click="activateFilter($index)"> <li class="filters__subitem" ng-repeat="actionbarFilter in actionbarFilters.possibleFilters" ng-click="activateFilter($index)">
<a class="filters__link state--current" ng-if="actionbarFilter === actionbarFilters.activeFilter">{{ actionbarFilter.text }}</a> <a class="filters__link state--current" ng-if="actionbarFilter === actionbarFilters.activeFilter">{{ actionbarFilter.text }}</a>
<a class="filters__link" ng-if="actionbarFilter !== actionbarFilters.activeFilter">{{ actionbarFilter.text }}</a> <a class="filters__link" ng-if="actionbarFilter !== actionbarFilters.activeFilter">{{ actionbarFilter.text }}</a>
</li> </li>
</ul> </ul>
</div> </div>
</li> </li>
<li class="filters__item filters__item--recheck"> <li class="filters__item filters__item--recheck">
<bansho-recheck-button></bansho-recheck-button> <bansho-recheck-button></bansho-recheck-button>
</li> </li>
<li class="filters__item filters__item--acknowledge" data-mover="true"> <li class="filters__item filters__item--acknowledge" data-mover="true">
<button class="filters__button" type="button" ng-click="switchAcknowledgeForm()"> <button class="filters__button" type="button" ng-click="switchAcknowledgeForm()">
<span class="visuallyhidden">Acknowledge</span> <span class="visuallyhidden">Acknowledge</span>
<i class="ico-thumbs-up"></i> <i class="ico-thumbs-up"></i>
</button> </button>
</li> </li>
<li class="filters__item filters__item--downtime" data-mover="true"> <li class="filters__item filters__item--downtime" data-mover="true">
<button class="filters__button" type="button" ng-click="switchDowntimeForm()"> <button class="filters__button" type="button" ng-click="switchDowntimeForm()">
<span class="visuallyhidden">Downtime</span> <span class="visuallyhidden">Downtime</span>
<i class="ico-clock"></i> <i class="ico-clock"></i>
</button> </button>
</li> </li>
<li class="filters__item filters__item--more clearfix"> <li class="filters__item filters__item--more clearfix">
<button class="filters__button" <button class="filters__button"
type="button" type="button"
data-toggle="collapse" data-toggle="collapse"
data-target="#filtersMore" data-target="#filtersMore"
aria-expanded="false" aria-expanded="false"
aria-controls="filtersMore"> aria-controls="filtersMore">
<span>More</span> <span>More</span>
<i class="ico-down-dir"></i> <i class="ico-down-dir"></i>
</button> </button>
<div class="filters__panel collapse" id="filtersMore"> <div class="filters__panel collapse" id="filtersMore">
<ul class="filters__sublist"> <ul class="filters__sublist">
<li class="filters__subitem"> <li class="filters__subitem">
<a class="filters__link" href="#">More I</a> <a class="filters__link" href="#">More I</a>
</li> </li>
<li class="filters__subitem"> <li class="filters__subitem">
<a class="filters__link" href="#">More II</a> <a class="filters__link" href="#">More II</a>
</li> </li>
<li class="filters__subitem"> <li class="filters__subitem">
<a class="filters__link" href="#">More III</a> <a class="filters__link" href="#">More III</a>
</li> </li>
</ul> </ul>
</div> </div>
</li> </li>
<li class="filters__item clearfix"> <li class="filters__item clearfix">
<input id=filter__search" type="search" ng-model="actionbarFilters.searchFilter"/>{{ actionbarFilters.searchFilter }} <input id=filter__search" type="search" ng-model="actionbarFilters.searchFilter"/>{{ actionbarFilters.searchFilter }}
</li> </li>
<li class="filters__item filters__item--settings"> <li class="filters__item filters__item--settings">
<button class="filters__button" <button class="filters__button"
type="button" type="button"
data-toggle="collapse" data-toggle="collapse"
data-target="#filtersSettings" data-target="#filtersSettings"
aria-expanded="false" aria-expanded="false"
aria-controls="filtersSettings"> aria-controls="filtersSettings">
<span class="visuallyhidden">Filters Settings</span> <span class="visuallyhidden">Filters Settings</span>
<i class="ico-cog"></i> <i class="ico-cog"></i>
</button> </button>
<div class="filters__panel collapse" id="filtersSettings"> <div class="filters__panel collapse" id="filtersSettings">
<ul class="filters__sublist"> <ul class="filters__sublist">
<li>...</li> <li>...</li>
<li>...</li> <li>...</li>
<li>...</li> <li>...</li>
</ul> </ul>
</div> </div>
</li> </li>
</ul> </ul>
<bansho-acknowledge-form ng-show="isAcknowledgeShown" is-shown="isAcknowledgeShown" selected-hosts="selected"> </bansho-acknowledge-form> <bansho-acknowledge-form ng-show="isAcknowledgeShown" is-shown="isAcknowledgeShown" selected-hosts="selected"> </bansho-acknowledge-form>
<bansho-downtime-form ng-show="isDowntimeShown" is-shown="isDowntimeShown" selected-hosts="selected"> </bansho-downtime-form> <bansho-downtime-form ng-show="isDowntimeShown" is-shown="isDowntimeShown" selected-hosts="selected"> </bansho-downtime-form>
</menu> </menu>

View File

@ -30,19 +30,19 @@ angular.module('bansho.table.actionbar', ['bansho.table', 'bansho.live'])
.controller('TableActionbarCtrl', ['$scope', '$filter', 'backendClient', 'actionbarFilters', 'tablesConfig', .controller('TableActionbarCtrl', ['$scope', '$filter', 'backendClient', 'actionbarFilters', 'tablesConfig',
function ($scope, $filter, backendClient, actionbarFilters, tablesConfig, actionbarSelectFilter) { function ($scope, $filter, backendClient, actionbarFilters, tablesConfig, actionbarSelectFilter) {
$scope.isDowntimeShown = false; $scope.isDowntimeShown = false;
$scope.isAcknowledgeShown = false; $scope.isAcknowledgeShown = false;
$scope.switchDowntimeForm = function () { $scope.switchDowntimeForm = function () {
$scope.isAcknowledgeShown = false; $scope.isAcknowledgeShown = false;
$scope.isDowntimeShown = !$scope.isDowntimeShown; $scope.isDowntimeShown = !$scope.isDowntimeShown;
}; };
$scope.switchAcknowledgeForm = function () { $scope.switchAcknowledgeForm = function () {
$scope.isDowntimeShown = false; $scope.isDowntimeShown = false;
$scope.isAcknowledgeShown = !$scope.isAcknowledgeShown; $scope.isAcknowledgeShown = !$scope.isAcknowledgeShown;
}; };
$scope.actionbarFilters = actionbarFilters; $scope.actionbarFilters = actionbarFilters;
$scope.actionbarFilters.activeFilter = $scope.actionbarFilters.possibleFilters[0]; $scope.actionbarFilters.activeFilter = $scope.actionbarFilters.possibleFilters[0];

View File

@ -1,39 +1,39 @@
<h4 id="acknowledgeModalLabel">Acknowlege</h4> <h4 id="acknowledgeModalLabel">Acknowlege</h4>
<form data-ng-submit="acknowledgeProblems()"> <form data-ng-submit="acknowledgeProblems()">
<div> <div>
<label for="author">Author :</label> <label for="author">Author :</label>
<input type="text" id="acknowledge-author" ng-model="attrs.author"> <input type="text" id="acknowledge-author" ng-model="attrs.author">
</div> </div>
<div> <div>
<label for="sticky">Sticky :</label> <label for="sticky">Sticky :</label>
<input type="checkbox" <input type="checkbox"
id="acknowledge-sticky" id="acknowledge-sticky"
ng-model="attrs.sticky" ng-model="attrs.sticky"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0">
</div> </div>
<div> <div>
<label for="notify">Notify :</label> <label for="notify">Notify :</label>
<input type="checkbox" <input type="checkbox"
id="acknowledge-notify" id="acknowledge-notify"
ng-model="attrs.notify" ng-model="attrs.notify"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0">
</div > </div >
<div> <div>
<label for="persistent">Persistent :</label> <label for="persistent">Persistent :</label>
<input type="checkbox" <input type="checkbox"
id="acknowledge-persistent" id="acknowledge-persistent"
ng-model="attrs.persistent" ng-model="attrs.persistent"
ng-true-value="1" ng-true-value="1"
ng-false-value="0"> ng-false-value="0">
</div> </div>
<div> <div>
<label for="comment">Comment :</label> <label for="comment">Comment :</label>
<input type="message-text" id="acknowledge-comment" ng-model="attrs.comment"> <input type="message-text" id="acknowledge-comment" ng-model="attrs.comment">
</div> </div>
<div> <div>
<button type="button" ng-click="isShown = !isShown">Close</button> <button type="button" ng-click="isShown = !isShown">Close</button>
<button type="button" ng-click="acknowledgeProblems()">Send</button> <button type="button" ng-click="acknowledgeProblems()">Send</button>
</div> </div>
</form> </form>

View File

@ -2,134 +2,134 @@
angular.module('bansho.table.actionbar') angular.module('bansho.table.actionbar')
.directive('banshoAcknowledgeForm', function () { .directive('banshoAcknowledgeForm', function () {
return { return {
restrict: 'E', restrict: 'E',
templateUrl: 'components/table/actionbar/actions/acknowledge_form.html', templateUrl: 'components/table/actionbar/actions/acknowledge_form.html',
scope: { scope: {
isShown: '=' isShown: '='
}, },
controller: 'banshoAcknowledgeFormCtrl' controller: 'banshoAcknowledgeFormCtrl'
}; };
}) })
.controller('banshoAcknowledgeFormCtrl', .controller('banshoAcknowledgeFormCtrl',
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) { function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) {
$scope.acknowledgeProblems = function () { $scope.acknowledgeProblems = function () {
angular.forEach(tablesConfig, function (tableConfig) { angular.forEach(tablesConfig, function (tableConfig) {
var entries = $filter('filter')(tableConfig.entries, var entries = $filter('filter')(tableConfig.entries,
actionbarFilters.searchFilter); actionbarFilters.searchFilter);
angular.forEach(entries, function (entry) { angular.forEach(entries, function (entry) {
var service_description; var service_description;
if (entry.is_checked) { if (entry.is_checked) {
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).error(function (data) {
throw new Error('Acknowledge request failed'); throw new Error('Acknowledge request failed');
}); });
} }
}); });
}); });
}; };
}]) }])
.directive('banshoDowntimeForm', function () { .directive('banshoDowntimeForm', function () {
return { return {
restrict: 'E', restrict: 'E',
templateUrl: 'components/table/actionbar/actions/downtime_form.html', templateUrl: 'components/table/actionbar/actions/downtime_form.html',
scope: { scope: {
isShown: '=' isShown: '='
}, },
controller: 'banshoDowntimeFormCtrl' controller: 'banshoDowntimeFormCtrl'
}; };
}) })
.controller('banshoDowntimeFormCtrl', .controller('banshoDowntimeFormCtrl',
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) { function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) {
$scope.messages = []; $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);
angular.forEach(entries, function (entry) { angular.forEach(entries, function (entry) {
var service_description; var service_description;
if (entry.is_checked) { if (entry.is_checked) {
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({ $scope.messages.push({
text: entry.host_name + " success ", text: entry.host_name + " success ",
type: "success" type: "success"
}); });
$scope.isShown = false; $scope.isShown = false;
}, },
function (error) { function (error) {
$scope.messages.push({ $scope.messages.push({
text: entry.host_name + " error", text: entry.host_name + " error",
type: "error" type: "error"
}); });
}); });
} }
}); });
}); });
}; };
}]) }])
.directive('banshoRecheckButton', function () { .directive('banshoRecheckButton', function () {
return { return {
restrict: 'E', restrict: 'E',
templateUrl: 'components/table/actionbar/actions/recheck_button.html', templateUrl: 'components/table/actionbar/actions/recheck_button.html',
scope: { scope: {
isShown: '=' isShown: '='
}, },
controller: 'banshoRecheckButtonCtrl' controller: 'banshoRecheckButtonCtrl'
}; };
}) })
.controller('banshoRecheckButtonCtrl', .controller('banshoRecheckButtonCtrl',
['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient', ['$scope', '$filter', 'tablesConfig', 'actionbarFilters', 'backendClient',
function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) { function ($scope, $filter, tablesConfig, actionbarFilters, backendClient) {
$scope.messages = []; $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);
angular.forEach(entries, function (entry) { angular.forEach(entries, function (entry) {
var service_description; var service_description;
if (entry.is_checked) { if (entry.is_checked) {
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({ $scope.messages.push({
text: entry.host_name + " success ", text: entry.host_name + " success ",
type: "success" type: "success"
}); });
}, },
function (error) { function (error) {
$scope.messages.push({ $scope.messages.push({
text: entry.host_name + " error", text: entry.host_name + " error",
type: "error" type: "error"
}); });
}); });
} }
}); });
}); });
}; };
}]); }]);

View File

@ -1,28 +1,28 @@
<div ng-repeat="message in messages">{{message.text}} + {{message.type}}</div> <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>
<label for="author">Author :</label> <label for="author">Author :</label>
<input type="text" id="author" ng-model="attrs.author"> <input type="text" id="author" ng-model="attrs.author">
</div> </div>
<div> <div>
<label for="comment">Comment :</label> <label for="comment">Comment :</label>
<input type="message-text" id="comment" ng-model="attrs.comment"> <input type="message-text" id="comment" ng-model="attrs.comment">
</div> </div>
<div> <div>
<label for="duration">Duration :</label> <label for="duration">Duration :</label>
<input type="number" id="duration" ng-model="attrs.duration"> <input type="number" id="duration" ng-model="attrs.duration">
</div> </div>
<div> <div>
<label for="start_time">Start time :</label> <label for="start_time">Start time :</label>
<input type="number" id="start_time" ng-model="attrs.start_time"> <input type="number" id="start_time" ng-model="attrs.start_time">
</div> </div>
<div> <div>
<label for="end_time">End time :</label> <label for="end_time">End time :</label>
<input type="number" id="end_time" ng-model="attrs.end_time"> <input type="number" id="end_time" ng-model="attrs.end_time">
</div> </div>
<div> <div>
<button type="button" ng-click="isShown = !isShown">Close</button> <button type="button" ng-click="isShown = !isShown">Close</button>
<button type="submit">Send</button> <button type="submit">Send</button>
</div> </div>
</form> </form>

View File

@ -1,4 +1,4 @@
<button class="filters__button" type="button" ng-click="sendRecheck()"> <button class="filters__button" type="button" ng-click="sendRecheck()">
<span class="visuallyhidden">Recheck</span> <span class="visuallyhidden">Recheck</span>
<i class="ico-arrows-cw"></i> <i class="ico-arrows-cw"></i>
</button> </button>

View File

@ -131,16 +131,7 @@
<li class="topbar__settings__subitem"><a href="#">Missing Plugins</a></li> <li class="topbar__settings__subitem"><a href="#">Missing Plugins</a></li>
<li class="topbar__settings__subitem"><a href="#">Object History</a></li> <li class="topbar__settings__subitem"><a href="#">Object History</a></li>
<li class="topbar__settings__subitem"><a href="#">Configure</a></li> <li class="topbar__settings__subitem"><a href="#">Configure</a></li>
</ul> <li class="topbar__settings__subitem" ng-click="logout()"><a>Logout</a></li>
</li>
<li class="topbar__settings__item">
<span class="topbar__settings__category">Nagios</span>
<ul class="topbar__settings__sublist">
<li class="topbar__settings__subitem"><a href="#">Settings</a></li>
<li class="topbar__settings__subitem"><a href="#">Edit nagios.cfg</a></li>
<li class="topbar__settings__subitem"><a href="#">Nagios Service</a></li>
<li class="topbar__settings__subitem"><a href="#">Pnp intergration</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

@ -2,27 +2,31 @@
angular.module('bansho.topbar', ['bansho.live']) angular.module('bansho.topbar', ['bansho.live'])
.controller('TopBarCtrl', ['$rootScope', '$scope', '$interval', 'backendClient', 'promisesManager', .controller('TopBarCtrl', ['$rootScope', '$scope', '$interval', 'backendClient', 'promisesManager', 'authService',
function ($rootScope, $scope, $interval, backendClient, promisesManager) { function ($rootScope, $scope, $interval, backendClient, promisesManager, authService) {
var getData, var getData,
hostProblems, hostProblems,
serviceProblems; serviceProblems;
getData = function () { getData = function () {
if ($rootScope.isAuthenticated) { if ($rootScope.isAuthenticated) {
backendClient.getServiceProblems().success(function (data) { backendClient.getServiceProblems().success(function (data) {
serviceProblems = data.length; serviceProblems = data.length;
backendClient.getHostProblems().success(function (data) { backendClient.getHostProblems().success(function (data) {
hostProblems = data.length; hostProblems = data.length;
$scope.allProblems = serviceProblems + hostProblems; $scope.allProblems = serviceProblems + hostProblems;
}); });
}); });
} }
}; };
// TODO: Change hardcoded interval when the topbar dashboard will be implemented // TODO: Change hardcoded interval when the topbar dashboard will be implemented
promisesManager.addAjaxPromise($interval(getData, 10000)); promisesManager.addAjaxPromise($interval(getData, 10000));
getData(); getData();
$scope.logout = function () {
authService.logout();
};
}]) }])
.directive('banshoTopbar', function () { .directive('banshoTopbar', function () {

View File

@ -15,6 +15,7 @@
<!-- build:js js/app.min.js --> <!-- build:js js/app.min.js -->
<script src="bower_components/angular/angular.js"></script> <script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-filter/dist/angular-filter.min.js"></script> <script src="bower_components/angular-filter/dist/angular-filter.min.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.min.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script> <script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/jquery/dist/jquery.min.js"></script> <script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/moment/moment.js"></script> <script src="bower_components/moment/moment.js"></script>

View File

@ -5,15 +5,16 @@
"license": "AGPLv3", "license": "AGPLv3",
"private": true, "private": true,
"dependencies": { "dependencies": {
"angular": "1.2.x", "angular": "~1.3.15",
"angular-route": "1.2.x", "angular-route": "~1.3.15",
"angular-loader": "1.2.x", "angular-loader": "~1.3.15",
"angular-mocks": "~1.2.x", "angular-mocks": "~1.3.15",
"html5-boilerplate": "~4.3.0", "html5-boilerplate": "~5.2.0",
"bootstrap-sass-official": "3.3.1", "bootstrap-sass-official": "3.3.1",
"fontawesome": "4.2.0", "fontawesome": "~4.3.0",
"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"
} }
} }