Added logout
Change-Id: If09690e089976244ded58a27b1f35a3a850ae2d1
diff --git a/src/app/core/nav/nav.html b/src/app/core/nav/nav.html
index fe96460..37d2f76 100644
--- a/src/app/core/nav/nav.html
+++ b/src/app/core/nav/nav.html
@@ -22,11 +22,26 @@
</ul>
</li>
<li class="nav-info">
- <i class="pe pe-7s-shield text-accent"></i>
-
- <div class="m-t-xs">
- <span class="c-white">{{vm.appName}}</span>
- monitoring and administration for networks applications.
+ <div class="row">
+ <div class="col-sm-4">
+ <i class="pe pe-7s-shield text-accent"></i>
+ </div>
+ <div class="col-sm-8">
+ <h4 class="c-white">{{vm.appName}}</h4>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-xs-12">
+ <span class="c-white">{{vm.payoff}}</span>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-sm-4">
+ <i class="pe pe-7s-lock text-accent"></i>
+ </div>
+ <div class="col-sm-8">
+ <a ng-click="vm.logout()" class="btn btn-accent btn-block btn-logout">Logout</a>
+ </div>
</div>
</li>
</ul>
diff --git a/src/app/core/nav/nav.scss b/src/app/core/nav/nav.scss
index e69de29..7646cd9 100644
--- a/src/app/core/nav/nav.scss
+++ b/src/app/core/nav/nav.scss
@@ -0,0 +1,7 @@
+xos-nav {
+ .nav-info {
+ .row + .row:last-child {
+ margin-top: 20px;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/app/core/nav/nav.spec.ts b/src/app/core/nav/nav.spec.ts
index 6a70f4c..3c18e4d 100644
--- a/src/app/core/nav/nav.spec.ts
+++ b/src/app/core/nav/nav.spec.ts
@@ -18,12 +18,17 @@
this.query = () => baseRoutes;
};
+const AuthMock = {
+ logout: jasmine.createSpy('logout')
+};
+
describe('Nav component', () => {
beforeEach(() => {
angular
.module('xosNav', ['app/core/nav/nav.html', 'ui.router'])
.component('xosNav', xosNav)
- .service('NavigationService', NavigationService);
+ .service('NavigationService', NavigationService)
+ .value('AuthService', AuthMock);
angular.mock.module('xosNav');
});
@@ -54,4 +59,13 @@
const childRouteContainer = $('.nav-second li', element);
expect(childRouteContainer.length).toBe(1);
});
+
+ it('should call the logout method', () => {
+ // NOTE upgrade to test the ng-click binding
+ // const btn = $(element).find('.nav-info .btn-block');
+ // btn.click();
+ // scope.$digest();
+ isolatedScope.vm.logout();
+ expect(AuthMock.logout).toHaveBeenCalled();
+ });
});
diff --git a/src/app/core/nav/nav.ts b/src/app/core/nav/nav.ts
index edaeb24..43f62b3 100644
--- a/src/app/core/nav/nav.ts
+++ b/src/app/core/nav/nav.ts
@@ -1,17 +1,20 @@
import './nav.scss';
import {IXosNavigationService, IXosNavigationRoute} from '../services/navigation';
import {StyleConfig} from '../../config/style.config';
+import {IXosAuthService} from '../../datasources/rest/auth.rest';
class NavCtrl {
- static $inject = ['$scope', '$state', 'NavigationService'];
+ static $inject = ['$scope', '$state', 'NavigationService', 'AuthService'];
public routes: IXosNavigationRoute[];
public navSelected: string;
public appName: string;
+ public payoff: string;
constructor(
private $scope: ng.IScope,
private $state: angular.ui.IStateService,
- private navigationService: IXosNavigationService
+ private navigationService: IXosNavigationService,
+ private authService: IXosAuthService
) {
// NOTE we'll need to have:
// - Base routes (defined from configuration based on BRAND)
@@ -22,6 +25,7 @@
this.routes = routes;
});
this.appName = StyleConfig.projectName;
+ this.payoff = StyleConfig.payoff;
}
activateRoute(route: IXosNavigationRoute) {
@@ -52,7 +56,10 @@
else {
return true;
}
+ }
+ logout() {
+ this.authService.logout();
}
}