Added logout
Change-Id: If09690e089976244ded58a27b1f35a3a850ae2d1
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 = {