mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4954] Notification history persist (#5154)
* persist notification in storage * add max stack check * add max stack check * fix folder
This commit is contained in:
@@ -127,7 +127,6 @@ describe('Create folder directive', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('[C260159] Should not be possible create a folder with banned character', async () => {
|
it('[C260159] Should not be possible create a folder with banned character', async () => {
|
||||||
await browser.refresh();
|
|
||||||
await contentServicesPage.clickOnCreateNewFolder();
|
await contentServicesPage.clickOnCreateNewFolder();
|
||||||
|
|
||||||
await createFolderDialog.addFolderName('*');
|
await createFolderDialog.addFolderName('*');
|
||||||
|
@@ -21,6 +21,7 @@ import { NotificationModel } from '../models/notification.model';
|
|||||||
import { MatMenuTrigger } from '@angular/material';
|
import { MatMenuTrigger } from '@angular/material';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
import { StorageService } from '../../services/storage.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-notification-history',
|
selector: 'adf-notification-history',
|
||||||
@@ -33,6 +34,8 @@ export class NotificationHistoryComponent implements OnDestroy {
|
|||||||
|
|
||||||
notifications: NotificationModel[] = [];
|
notifications: NotificationModel[] = [];
|
||||||
|
|
||||||
|
MAX_NOTIFICATION_STACK_LENGTH = 100;
|
||||||
|
|
||||||
@ViewChild(MatMenuTrigger)
|
@ViewChild(MatMenuTrigger)
|
||||||
trigger: MatMenuTrigger;
|
trigger: MatMenuTrigger;
|
||||||
|
|
||||||
@@ -45,12 +48,19 @@ export class NotificationHistoryComponent implements OnDestroy {
|
|||||||
menuPositionY: string = 'below';
|
menuPositionY: string = 'below';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private notificationService: NotificationService) {
|
private notificationService: NotificationService, public storageService: StorageService) {
|
||||||
|
this.notifications = JSON.parse(storageService.getItem('notifications')) || [];
|
||||||
this.notificationService.notifications$
|
this.notificationService.notifications$
|
||||||
.pipe(takeUntil(this.onDestroy$))
|
.pipe(takeUntil(this.onDestroy$))
|
||||||
.subscribe((message) => {
|
.subscribe((message) => {
|
||||||
this.notifications.push(message);
|
this.notifications.push(message);
|
||||||
});
|
|
||||||
|
if (this.notifications.length > this.MAX_NOTIFICATION_STACK_LENGTH) {
|
||||||
|
this.notifications.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
storageService.setItem('notifications', JSON.stringify(this.notifications));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmptyNotification(): boolean {
|
isEmptyNotification(): boolean {
|
||||||
@@ -62,6 +72,7 @@ export class NotificationHistoryComponent implements OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
markAsRead() {
|
markAsRead() {
|
||||||
|
this.storageService.setItem('notifications', '');
|
||||||
this.notifications = [];
|
this.notifications = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user