Added luna template and deps
Change-Id: Idd3dcdee3a377a75733c333d4a754632111e17ee
diff --git a/src/app/core/header/header.ts b/src/app/core/header/header.ts
index 20fbc3c..6e057bc 100644
--- a/src/app/core/header/header.ts
+++ b/src/app/core/header/header.ts
@@ -8,21 +8,54 @@
}
class HeaderController {
- static $inject = ['$scope', 'SynchronizerStore'];
+ static $inject = ['$scope', 'SynchronizerStore', 'toastr', 'toastrConfig'];
public title: string;
public notifications: INotification[] = [];
public newNotifications: INotification[] = [];
constructor(
private $scope: angular.IScope,
- private syncStore: IStoreService
+ private syncStore: IStoreService,
+ private toastr: ng.toastr.IToastrService,
+ private toastrConfig: ng.toastr.IToastrConfig
) {
+
+ angular.extend(this.toastrConfig, {
+ newestOnTop: false,
+ positionClass: 'toast-top-right',
+ preventDuplicates: false,
+ preventOpenDuplicates: false,
+ progressBar: true,
+ // autoDismiss: false,
+ // closeButton: false,
+ // timeOut: 0,
+ // tapToDismiss: false
+ });
+
this.title = StyleConfig.projectName;
this.syncStore.query()
.subscribe(
(event: IWSEvent) => {
$scope.$evalAsync(() => {
+ let toastrMsg: string;
+ let toastrLevel: string;
+ if (event.msg.object.backend_status.indexOf('1') > -1) {
+ toastrMsg = 'Synchronization started for:';
+ toastrLevel = 'info';
+ }
+ else if (event.msg.object.backend_status.indexOf('0') > -1) {
+ toastrMsg = 'Synchronization succedeed for:';
+ toastrLevel = 'success';
+ }
+ else if (event.msg.object.backend_status.indexOf('2') > -1) {
+ toastrMsg = 'Synchronization failed for:';
+ toastrLevel = 'error';
+ }
+
+ if (toastrLevel && toastrMsg) {
+ this.toastr[toastrLevel](`${toastrMsg} ${event.msg.object.name}`, event.model);
+ }
this.notifications.unshift(event);
this.newNotifications = this.getNewNotifications(this.notifications);
});
@@ -30,6 +63,7 @@
);
}
+ // TODO display a list of notification in the template
public viewNotification = (notification: INotification) => {
notification.viewed = true;
this.newNotifications = this.getNewNotifications(this.notifications);