Added logout
Change-Id: If09690e089976244ded58a27b1f35a3a850ae2d1
diff --git a/src/app/core/header/header.html b/src/app/core/header/header.html
index db25904..0a90822 100644
--- a/src/app/core/header/header.html
+++ b/src/app/core/header/header.html
@@ -27,8 +27,8 @@
<minimaliza-menu></minimaliza-menu>
</div>
<a class="navbar-brand" href="#/">
- <em class="brand-title">{{vm.title}}</em>
- <span>v.1.2</span>
+ <img class="img-responsive" ng-src="{{vm.getLogo()}}" alt="">
+ <span>v.{{vm.version}}</span>
</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
@@ -45,7 +45,7 @@
<!--</li>-->
<li class=" profil-link">
<a ui-sref="commonviews.login">
- <span class="profile-address">luna@company.io</span>
+ <span class="profile-address">{{vm.userEmail}}</span>
<img src="../../images/profile.jpg" class="img-circle" alt="">
</a>
</li>
diff --git a/src/app/core/header/header.scss b/src/app/core/header/header.scss
index 8a1664f..a1be115 100644
--- a/src/app/core/header/header.scss
+++ b/src/app/core/header/header.scss
@@ -1,3 +1,21 @@
#toast-container [toast]:not(:first-child) {
margin-top: 10px !important;
+}
+
+xos-header {
+ .navbar-brand {
+ padding: 10px 30px !important;
+ position: relative;
+ background: #24262d !important;
+ span {
+ position: absolute;
+ right: 30px;
+ bottom: 0;
+ color: #24262d;
+ }
+ }
+
+ .navbar-default {
+ background: #2a2d35 !important;
+ }
}
\ No newline at end of file
diff --git a/src/app/core/header/header.spec.ts b/src/app/core/header/header.spec.ts
index c8dffe7..c115a4e 100644
--- a/src/app/core/header/header.spec.ts
+++ b/src/app/core/header/header.spec.ts
@@ -5,7 +5,6 @@
import * as angular from 'angular';
import 'angular-mocks';
import {xosHeader, INotification} from './header';
-import {StyleConfig} from '../../config/style.config';
import {Subject} from 'rxjs';
let element, scope: angular.IRootScopeService, compile: ng.ICompileService, isolatedScope;
@@ -19,14 +18,16 @@
};
};
-interface ImockToastr {
- info(msg: string, title: string): void;
-}
-
-const MockToastr: ImockToastr = {
+const MockToastr = {
info: jasmine.createSpy('info')
};
+const MockAuth = {
+ getUser: () => {
+ return {email: 'test@xos.us'};
+ }
+};
+
const MockToastrConfig = {};
const infoNotification = {
@@ -36,7 +37,7 @@
pk: 1,
object: {
name: 'TestName',
- backend_status: '1 - Test Status'
+ backend_status: '0 - In Progress'
}
}
};
@@ -48,7 +49,8 @@
.component('xosHeader', xosHeader)
.service('SynchronizerStore', MockStore)
.value('toastr', MockToastr)
- .value('toastrConfig', MockToastrConfig);
+ .value('toastrConfig', MockToastrConfig)
+ .value('AuthService', MockAuth);
angular.mock.module('xosHeader');
});
@@ -63,13 +65,14 @@
isolatedScope.notifications = [];
}));
- it('should render the appropriate title', () => {
- const header = $('a.navbar-brand .brand-title', element).text();
- expect(header.trim()).toEqual(StyleConfig.projectName);
+ it('should render the appropriate logo', () => {
+ const header = $('a.navbar-brand img', element).attr('src');
+ // webpack convert img to base64, how to test?
+ expect(header.trim()).not.toBeNull();
});
- it('should set the appropriate favicon', () => {
- console.log($('#favicon').attr('href'));
+ it('should print user email', () => {
+ expect($('.profile-address', element).text()).toBe('test@xos.us');
});
it('should configure toastr', () => {
diff --git a/src/app/core/header/header.ts b/src/app/core/header/header.ts
index 6e057bc..efaa385 100644
--- a/src/app/core/header/header.ts
+++ b/src/app/core/header/header.ts
@@ -2,24 +2,27 @@
import {StyleConfig} from '../../config/style.config';
import {IWSEvent} from '../../datasources/websocket/global';
import {IStoreService} from '../../datasources/stores/synchronizer.store';
+import {IXosAuthService} from '../../datasources/rest/auth.rest';
export interface INotification extends IWSEvent {
viewed?: boolean;
}
class HeaderController {
- static $inject = ['$scope', 'SynchronizerStore', 'toastr', 'toastrConfig'];
- public title: string;
+ static $inject = ['$scope', 'AuthService', 'SynchronizerStore', 'toastr', 'toastrConfig'];
public notifications: INotification[] = [];
public newNotifications: INotification[] = [];
+ public version: string;
+ public userEmail: string;
constructor(
private $scope: angular.IScope,
+ private authService: IXosAuthService,
private syncStore: IStoreService,
private toastr: ng.toastr.IToastrService,
private toastrConfig: ng.toastr.IToastrConfig
) {
-
+ this.version = require('../../../../package.json').version;
angular.extend(this.toastrConfig, {
newestOnTop: false,
positionClass: 'toast-top-right',
@@ -32,7 +35,7 @@
// tapToDismiss: false
});
- this.title = StyleConfig.projectName;
+ this.userEmail = this.authService.getUser().email;
this.syncStore.query()
.subscribe(
@@ -40,11 +43,11 @@
$scope.$evalAsync(() => {
let toastrMsg: string;
let toastrLevel: string;
- if (event.msg.object.backend_status.indexOf('1') > -1) {
+ if (event.msg.object.backend_status.indexOf('0') > -1) {
toastrMsg = 'Synchronization started for:';
toastrLevel = 'info';
}
- else if (event.msg.object.backend_status.indexOf('0') > -1) {
+ else if (event.msg.object.backend_status.indexOf('1') > -1) {
toastrMsg = 'Synchronization succedeed for:';
toastrLevel = 'success';
}
@@ -56,24 +59,28 @@
if (toastrLevel && toastrMsg) {
this.toastr[toastrLevel](`${toastrMsg} ${event.msg.object.name}`, event.model);
}
- this.notifications.unshift(event);
- this.newNotifications = this.getNewNotifications(this.notifications);
+ // this.notifications.unshift(event);
+ // this.newNotifications = this.getNewNotifications(this.notifications);
});
}
);
}
- // TODO display a list of notification in the template
- public viewNotification = (notification: INotification) => {
- notification.viewed = true;
- this.newNotifications = this.getNewNotifications(this.notifications);
- };
+ public getLogo(): string {
+ return require(`../../images/brand/${StyleConfig.logo}`);
+ }
- private getNewNotifications = (notifications: INotification[]) => {
- return this.notifications.filter((n: INotification) => {
- return !n.viewed;
- });
- };
+ // TODO display a list of notification in the template (if it make sense)
+ // public viewNotification = (notification: INotification) => {
+ // notification.viewed = true;
+ // this.newNotifications = this.getNewNotifications(this.notifications);
+ // };
+ //
+ // private getNewNotifications = (notifications: INotification[]) => {
+ // return this.notifications.filter((n: INotification) => {
+ // return !n.viewed;
+ // });
+ // };
}
export const xosHeader: angular.IComponentOptions = {