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

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

View File

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

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

View File

@ -28,6 +28,10 @@ angular.module('bansho.authentication', [])
login($scope.credentials);
};
if (authService.isAuthenticated()) {
login($scope.credentials);
}
configManager.loadDevelopmentConfig().then(function () {
var devConfig = configManager.getDevelopmentConfig();
if (devConfig.env === 'development') {
@ -73,21 +77,33 @@ angular.module('bansho.authentication', [])
};
authService.isAuthenticated = function () {
return !!session.sessionId;
return !!session.isUserConnected();
};
authService.logout = function () {
$rootScope.isAuthenticated = false;
session.destroy();
$location.path('/login');
};
return authService;
}])
.service('session', function () {
.service('session', ['$cookies', function ($cookies) {
this.isUserConnected = function () {
return $cookies.connected === 'true';
};
this.create = function (sessionId, expirationTime) {
this.sessionId = sessionId;
this.expirationTime = expirationTime;
$cookies.connected = 'true';
};
this.destroy = function () {
this.sessionId = null;
this.expirationTime = null;
$cookies.connected = 'false';
};
});
}]);

View File

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

View File

@ -131,16 +131,7 @@
<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="#">Configure</a></li>
</ul>
</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>
<li class="topbar__settings__subitem" ng-click="logout()"><a>Logout</a></li>
</ul>
</li>
</ul>

View File

@ -2,8 +2,8 @@
angular.module('bansho.topbar', ['bansho.live'])
.controller('TopBarCtrl', ['$rootScope', '$scope', '$interval', 'backendClient', 'promisesManager',
function ($rootScope, $scope, $interval, backendClient, promisesManager) {
.controller('TopBarCtrl', ['$rootScope', '$scope', '$interval', 'backendClient', 'promisesManager', 'authService',
function ($rootScope, $scope, $interval, backendClient, promisesManager, authService) {
var getData,
hostProblems,
serviceProblems;
@ -23,6 +23,10 @@ angular.module('bansho.topbar', ['bansho.live'])
// TODO: Change hardcoded interval when the topbar dashboard will be implemented
promisesManager.addAjaxPromise($interval(getData, 10000));
getData();
$scope.logout = function () {
authService.logout();
};
}])
.directive('banshoTopbar', function () {

View File

@ -15,6 +15,7 @@
<!-- build:js js/app.min.js -->
<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-cookies/angular-cookies.min.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/moment/moment.js"></script>

View File

@ -5,15 +5,16 @@
"license": "AGPLv3",
"private": true,
"dependencies": {
"angular": "1.2.x",
"angular-route": "1.2.x",
"angular-loader": "1.2.x",
"angular-mocks": "~1.2.x",
"html5-boilerplate": "~4.3.0",
"angular": "~1.3.15",
"angular-route": "~1.3.15",
"angular-loader": "~1.3.15",
"angular-mocks": "~1.3.15",
"html5-boilerplate": "~5.2.0",
"bootstrap-sass-official": "3.3.1",
"fontawesome": "4.2.0",
"fontawesome": "~4.3.0",
"justgage-toorshia": "master",
"moment": "~2.9.0",
"angular-filter": "~0.5.4"
"angular-filter": "~0.5.4",
"angular-cookies": "~1.3.15"
}
}