diff --git a/src/app/+home-page/home-page.component.html b/src/app/+home-page/home-page.component.html index d015e53850..637b975ad3 100644 --- a/src/app/+home-page/home-page.component.html +++ b/src/app/+home-page/home-page.component.html @@ -5,12 +5,8 @@ - - - - - - + + diff --git a/src/app/+home-page/home-page.component.ts b/src/app/+home-page/home-page.component.ts index 1acd4951fa..936d7ccecc 100644 --- a/src/app/+home-page/home-page.component.ts +++ b/src/app/+home-page/home-page.component.ts @@ -1,7 +1,9 @@ -import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; +import { Component, TemplateRef, ViewChild } from '@angular/core'; import { NotificationsService } from '../shared/notifications/notifications.service'; -import { Options } from '../shared/notifications/interfaces/options.type'; -import { NotificationOptions } from '../shared/notifications/models/notification-options.model'; +import { + INotificationBoardOptions, + NotificationOptions +} from '../shared/notifications/models/notification-options.model'; @Component({ selector: 'ds-home-page', @@ -9,15 +11,6 @@ import { NotificationOptions } from '../shared/notifications/models/notification templateUrl: './home-page.component.html' }) export class HomePageComponent { - public notificationOptions: Options = { - position: ['top', 'right'], - timeOut: 0, - animate: 'fromLeft' - // lastOnBottom: true, - // clickIconToClose: false, - // showProgressBar: true, - }; - @ViewChild('example') example: TemplateRef; constructor(private notificationsService: NotificationsService) { @@ -25,24 +18,40 @@ export class HomePageComponent { createNotification() { const n1 = this.notificationsService.success('Welcome in DSpace', 'Good choice!', - new NotificationOptions(2000, false, 'fromLeft')); - const n2 = this.notificationsService.info('Info in DSpace', 'For your info...!'); - const n3 = this.notificationsService.warning('Warning in DSpace', 'This is a fake alert!'); - const n4 = this.notificationsService.danger(this.example); - console.log('Notifications pushed'); - console.log(n1); - console.log(n2); - console.log(n3); - console.log(n4); + new NotificationOptions(10000, false, 'fromLeft', ['bottom', 'left'])); + // const n2 = this.notificationsService.info('Info in DSpace', 'For your info...!'); + // const n3 = this.notificationsService.warning('Warning in DSpace', 'This is a fake alert!'); + // // const n4 = this.notificationsService.danger(this.example); + // console.log('Notifications pushed'); + // console.log(n1); + // console.log(n2); + // console.log(n3); + // // console.log(n4); } - notificationCreated(event) { - console.log('Notification created'); - console.log(event); + createNotification1() { + const n1 = this.notificationsService.warning('Welcome in DSpace', 'Good choice!', + new NotificationOptions(10000, false, 'fromLeft', ['bottom', 'left'])); + // const n2 = this.notificationsService.info('Info in DSpace', 'For your info...!'); + // const n3 = this.notificationsService.warning('Warning in DSpace', 'This is a fake alert!'); + // // const n4 = this.notificationsService.danger(this.example); + // console.log('Notifications pushed'); + // console.log(n1); + // console.log(n2); + // console.log(n3); + // // console.log(n4); } - notificationDestroyed() { - console.log('Notification destroyed'); - console.log(event); + createNotification2() { + // const n1 = this.notificationsService.error('Welcome in DSpace', 'Good choice!', + // new NotificationOptions(100000, false, 'fromLeft', ['bottom', 'left'])); + // const n2 = this.notificationsService.info('Info in DSpace', 'For your info...!'); + // const n3 = this.notificationsService.warning('Warning in DSpace', 'This is a fake alert!'); + const n4 = this.notificationsService.html(this.example); + // console.log('Notifications pushed'); + // console.log(n1); + // console.log(n2); + // console.log(n3); + // // console.log(n4); } } diff --git a/src/app/app.component.html b/src/app/app.component.html index 6fb3c3a31e..3e71fafc5c 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -3,7 +3,7 @@ diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4fb14f4d75..f5ace25acf 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,11 +1,4 @@ -import { - ChangeDetectionStrategy, - Component, - HostListener, - Inject, - OnInit, - ViewEncapsulation -} from '@angular/core'; +import { ChangeDetectionStrategy, Component, HostListener, Inject, OnInit, ViewEncapsulation } from '@angular/core'; import { Store } from '@ngrx/store'; @@ -17,7 +10,7 @@ import { MetadataService } from './core/metadata/metadata.service'; import { HostWindowResizeAction } from './shared/host-window.actions'; import { HostWindowState } from './shared/host-window.reducer'; import { NativeWindowRef, NativeWindowService } from './shared/window.service'; -import { Options } from './shared/notifications/interfaces/options.type'; +import { INotificationBoardOptions } from './shared/notifications/models/notification-options.model'; @Component({ selector: 'ds-app', @@ -28,13 +21,10 @@ import { Options } from './shared/notifications/interfaces/options.type'; }) export class AppComponent implements OnInit { - public notificationOptions: Options = { + public boardOptions: INotificationBoardOptions = { position: ['top', 'right'], - timeOut: 0, - animate: 'fromLeft' - // lastOnBottom: true, - // clickIconToClose: false, - // showProgressBar: true, + maxStack: 5, + rtl: false }; notificationCreated(event) { @@ -47,13 +37,11 @@ export class AppComponent implements OnInit { console.log(event); } - constructor( - @Inject(GLOBAL_CONFIG) public config: GlobalConfig, - @Inject(NativeWindowService) private _window: NativeWindowRef, - private translate: TranslateService, - private store: Store, - private metadata: MetadataService - ) { + constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig, + @Inject(NativeWindowService) private _window: NativeWindowRef, + private translate: TranslateService, + private store: Store, + private metadata: MetadataService) { // this language will be used as a fallback when a translation isn't found in the current language translate.setDefaultLang('en'); // the lang to use, if the lang isn't available, it will use the current loader to get them diff --git a/src/app/shared/notifications/interfaces/icons.ts b/src/app/shared/notifications/interfaces/icons.ts deleted file mode 100644 index bf3066c2ac..0000000000 --- a/src/app/shared/notifications/interfaces/icons.ts +++ /dev/null @@ -1,41 +0,0 @@ -export interface Icons { - alert: string; - error: string; - info: string; - warn: string; - success: string; -} - -export const defaultIcons: Icons = { - alert: ` - - - - - `, - error: ` - - - - - `, - info: ` - - - - - `, - success: ` - - - - - `, - warn: ` - - - - - - ` -}; diff --git a/src/app/shared/notifications/interfaces/notification-event.type.ts b/src/app/shared/notifications/interfaces/notification-event.type.ts deleted file mode 100644 index 978cf3dc69..0000000000 --- a/src/app/shared/notifications/interfaces/notification-event.type.ts +++ /dev/null @@ -1,8 +0,0 @@ -import {Notification} from './notification.type'; - -export interface NotificationEvent { - add?: boolean; - command: string; - id?: string; - notification?: Notification; -} diff --git a/src/app/shared/notifications/interfaces/notification.type.ts b/src/app/shared/notifications/interfaces/notification.type.ts deleted file mode 100644 index eb69260cbf..0000000000 --- a/src/app/shared/notifications/interfaces/notification.type.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {EventEmitter} from '@angular/core'; - -export interface Notification { - id?: string - type: string - icon?: string - title?: any - content?: any - override?: any - html?: any - state?: string - createdOn?: Date - destroyedOn?: Date - animate?: string - timeOut?: number - maxLength?: number - pauseOnHover?: boolean - clickToClose?: boolean - clickIconToClose?: boolean - theClass?: string - click?: EventEmitter<{}>; - clickIcon?: EventEmitter<{}>; - timeoutEnd?: EventEmitter<{}>; -} diff --git a/src/app/shared/notifications/interfaces/options.type.ts b/src/app/shared/notifications/interfaces/options.type.ts deleted file mode 100644 index cfd45529cd..0000000000 --- a/src/app/shared/notifications/interfaces/options.type.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {Icons} from './icons'; - -export interface Options { - timeOut?: number; - // showProgressBar?: boolean; - // pauseOnHover?: boolean; - // lastOnBottom?: boolean; - // clickToClose?: boolean; - // clickIconToClose?: boolean; - maxLength?: number; - maxStack?: number; - // preventDuplicates?: boolean; - // preventLastDuplicates?: boolean | string; - theClass?: string; - rtl?: boolean; - animate?: 'fade' | 'fromTop' | 'fromRight' | 'fromBottom' | 'fromLeft' | 'rotate' | 'scale'; - icons?: Icons; - position?: ['top' | 'bottom' | 'middle', 'right' | 'left' | 'center']; -} diff --git a/src/app/shared/notifications/models/notification-options.model.ts b/src/app/shared/notifications/models/notification-options.model.ts index b651a0b3d1..b8357f5269 100644 --- a/src/app/shared/notifications/models/notification-options.model.ts +++ b/src/app/shared/notifications/models/notification-options.model.ts @@ -26,3 +26,10 @@ export class NotificationOptions implements INotificationOptions { this.rtl = rtl; } } + +export interface INotificationBoardOptions { + rtl: boolean; + position: ['top' | 'bottom' | 'middle', 'right' | 'left' | 'center']; + maxStack: number; + maxLength?: number; +} diff --git a/src/app/shared/notifications/models/notification-type.ts b/src/app/shared/notifications/models/notification-type.ts index b21696ab1f..8ef5d790b5 100644 --- a/src/app/shared/notifications/models/notification-type.ts +++ b/src/app/shared/notifications/models/notification-type.ts @@ -1,8 +1,7 @@ export enum NotificationType { - Success = 'success', - Error = 'error', - Danger = 'danger', - Info = 'info', - Warning = 'warning', + Success = 'alert-success', + Error = 'alert-danger', + Info = 'alert-info', + Warning = 'alert-warning', // Bare = 'bare' } diff --git a/src/app/shared/notifications/models/notification.model.ts b/src/app/shared/notifications/models/notification.model.ts index 91f2f9bbe9..e5da5d1bff 100644 --- a/src/app/shared/notifications/models/notification.model.ts +++ b/src/app/shared/notifications/models/notification.model.ts @@ -1,6 +1,10 @@ import { INotificationOptions, NotificationOptions } from './notification-options.model'; import { NotificationType } from './notification-type'; import { isEmpty } from '../../empty.util'; +import { ElementRef, TemplateRef } from '@angular/core'; +import { Deserialize, Serialize, serialize } from 'cerialize'; +import { deserialize } from 'cerialize'; +import { NotificationsService } from '../notifications.service'; export interface INotification { id: string @@ -17,7 +21,6 @@ export class Notification implements INotification { public title: any; public content: any; public options: INotificationOptions; - public html?: any; constructor(id: string, type: NotificationType, @@ -31,4 +34,14 @@ export class Notification implements INotification { this.content = content; this.options = isEmpty(options) ? new NotificationOptions() : options; } + + get html() { + if (this.title === '' && this.content === '') { + return NotificationsService.htmlArray.get(this.id); + } else { + return null; + } + } + + } diff --git a/src/app/shared/notifications/notification/notification.component.html b/src/app/shared/notifications/notification/notification.component.html index 977a1298b1..a50af4b51d 100644 --- a/src/app/shared/notifications/notification/notification.component.html +++ b/src/app/shared/notifications/notification/notification.component.html @@ -1,32 +1,18 @@ - -
+ +
-
- - -