mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
notification options in configuration
This commit is contained in:
@@ -21,6 +21,12 @@ module.exports = {
|
||||
msToLive: 15 * 60 * 1000, // 15 minute
|
||||
control: 'max-age=60' // revalidate browser
|
||||
},
|
||||
// Notifications
|
||||
notifications: {
|
||||
rtl: false,
|
||||
position: ['top', 'right'],
|
||||
maxStack: 8
|
||||
},
|
||||
// Angular Universal settings
|
||||
universal: {
|
||||
preboot: true,
|
||||
|
@@ -3,9 +3,7 @@
|
||||
<ds-header></ds-header>
|
||||
|
||||
<ds-notifications-board
|
||||
[options]="boardOptions"
|
||||
(onCreate)="notificationCreated($event)"
|
||||
(onDestroy)="notificationDestroyed($event)">
|
||||
[options]="config.notifications">
|
||||
</ds-notifications-board>
|
||||
|
||||
<main class="main-content">
|
||||
|
@@ -10,7 +10,6 @@ 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 { INotificationBoardOptions } from './shared/notifications/models/notification-options.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-app',
|
||||
@@ -21,22 +20,6 @@ import { INotificationBoardOptions } from './shared/notifications/models/notific
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
|
||||
public boardOptions: INotificationBoardOptions = {
|
||||
position: ['top', 'right'],
|
||||
maxStack: 5,
|
||||
rtl: false
|
||||
};
|
||||
|
||||
notificationCreated(event) {
|
||||
console.log('Notification created');
|
||||
console.log(event);
|
||||
}
|
||||
|
||||
notificationDestroyed() {
|
||||
console.log('Notification destroyed');
|
||||
console.log(event);
|
||||
}
|
||||
|
||||
constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
|
||||
@Inject(NativeWindowService) private _window: NativeWindowRef,
|
||||
private translate: TranslateService,
|
||||
|
@@ -3,35 +3,20 @@ import { NotificationAnimationsType } from './notification-animations-type';
|
||||
export interface INotificationOptions {
|
||||
timeOut: number;
|
||||
clickToClose: boolean;
|
||||
rtl: boolean;
|
||||
animate: NotificationAnimationsType;
|
||||
position: ['top' | 'bottom' | 'middle', 'right' | 'left' | 'center'];
|
||||
}
|
||||
|
||||
export class NotificationOptions implements INotificationOptions {
|
||||
public timeOut: number;
|
||||
public clickToClose: boolean;
|
||||
public rtl: boolean;
|
||||
public animate: any;
|
||||
public position: any;
|
||||
|
||||
constructor(timeOut = 0,
|
||||
clickToClose = true,
|
||||
animate = NotificationAnimationsType.Scale,
|
||||
position = ['top' , 'right'],
|
||||
rtl = false) {
|
||||
animate = NotificationAnimationsType.Scale) {
|
||||
|
||||
this.timeOut = timeOut;
|
||||
this.clickToClose = clickToClose;
|
||||
this.animate = animate;
|
||||
this.position = position;
|
||||
this.rtl = rtl;
|
||||
}
|
||||
}
|
||||
|
||||
export interface INotificationBoardOptions {
|
||||
rtl: boolean;
|
||||
position: ['top' | 'bottom' | 'middle', 'right' | 'left' | 'center'];
|
||||
maxStack: number;
|
||||
maxLength?: number;
|
||||
}
|
||||
|
@@ -61,11 +61,8 @@ export class NotificationComponent implements OnInit, OnDestroy {
|
||||
private steps: number;
|
||||
private speed: number;
|
||||
private count = 0;
|
||||
|
||||
private start: any;
|
||||
private diff: any;
|
||||
|
||||
// 'fade' | 'fromTop' | 'fromRight' | 'fromBottom' | 'fromLeft' | 'rotate' | 'scale' ;
|
||||
public animate: string;
|
||||
|
||||
constructor(private notificationService: NotificationsService,
|
||||
|
@@ -2,11 +2,9 @@ import {
|
||||
ChangeDetectionStrategy,
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { NotificationsService } from '../notifications.service';
|
||||
@@ -16,8 +14,8 @@ import { notificationsStateSelector } from '../selectors';
|
||||
import { difference } from 'lodash';
|
||||
import { INotification } from '../models/notification.model';
|
||||
import { NotificationsState } from '../notifications.reducers';
|
||||
import { INotificationBoardOptions } from '../models/notification-options.model';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
import { INotificationBoardOptions } from '../../../../config/notifications-config.interfaces';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-notifications-board',
|
||||
@@ -33,9 +31,6 @@ export class NotificationsBoardComponent implements OnInit, OnDestroy {
|
||||
this.attachChanges(opt);
|
||||
}
|
||||
|
||||
@Output() onCreate = new EventEmitter();
|
||||
@Output() onDestroy = new EventEmitter();
|
||||
|
||||
public notifications: INotification[] = [];
|
||||
public position: ['top' | 'bottom' | 'middle', 'right' | 'left' | 'center'] = ['bottom', 'right'];
|
||||
|
||||
@@ -60,8 +55,6 @@ export class NotificationsBoardComponent implements OnInit, OnDestroy {
|
||||
} else if (state.length > this.notifications.length) {
|
||||
// Add
|
||||
const newElem = difference(state, this.notifications);
|
||||
console.log('new Elements #', newElem.length);
|
||||
|
||||
newElem.forEach((notification) => {
|
||||
this.add(notification);
|
||||
});
|
||||
|
7
src/config/notifications-config.interfaces.ts
Normal file
7
src/config/notifications-config.interfaces.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Config } from './config.interface';
|
||||
|
||||
export interface INotificationBoardOptions extends Config {
|
||||
rtl: boolean;
|
||||
position: ['top' | 'bottom' | 'middle', 'right' | 'left' | 'center'];
|
||||
maxStack: number;
|
||||
}
|
Reference in New Issue
Block a user