mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
[ADF-4896] Merging AMA and ADF notifications for a better world (#5084)
* [ADF-4896] Merging AMA and ADF notifications for a better world * Second part * update package-lock
This commit is contained in:
commit
e5466f032a
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@ bundles
|
||||
workspace.xml
|
||||
.idea/
|
||||
.env.*
|
||||
.env
|
||||
dist/
|
||||
e2e/.env.cloud
|
||||
tmp
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { LogService } from '../services/log.service';
|
||||
import { NotificationService } from '../services/notification.service';
|
||||
import { NotificationService } from '../notifications/services/notification.service';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ClipboardModule } from './clipboard.module';
|
||||
|
@ -18,7 +18,7 @@
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { DOCUMENT } from '@angular/platform-browser';
|
||||
import { LogService } from '../services/log.service';
|
||||
import { NotificationService } from '../services/notification.service';
|
||||
import { NotificationService } from '../notifications/services/notification.service';
|
||||
|
||||
@Injectable()
|
||||
export class ClipboardService {
|
||||
|
@ -41,7 +41,7 @@ import { CommentsModule } from './comments/comments.module';
|
||||
import { ButtonsMenuModule } from './buttons-menu/buttons-menu.module';
|
||||
import { TemplateModule } from './templates/template.module';
|
||||
import { ClipboardModule } from './clipboard/clipboard.module';
|
||||
import { NotificationHistoryModule } from './notification-history/notification-history.module';
|
||||
import { NotificationHistoryModule } from './notifications/notification-history.module';
|
||||
|
||||
import { DirectiveModule } from './directives/directive.module';
|
||||
import { DialogModule } from './dialogs/dialog.module';
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "مطالبة",
|
||||
"UNCLAIM": "تحرير",
|
||||
"START PROCESS": "بدء العملية",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "لا توجد رسائل",
|
||||
"NOTIFICATIONS": "إعلامات",
|
||||
"TITLE": "إعلامات",
|
||||
"MARK_AS_READ": "وضع علامة على الكل كغير مقروءة"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "انقر للنسخ",
|
||||
"SUCCESS_COPY": "تم نسخ النص إلى الحافظة"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Převzít",
|
||||
"UNCLAIM": "Vzdát se",
|
||||
"START PROCESS": "Zahájit proces",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Žádné zprávy",
|
||||
"NOTIFICATIONS": "Upozornění",
|
||||
"TITLE": "Upozornění",
|
||||
"MARK_AS_READ": "Označit všechny jako přečtené"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Kliknutím zkopírovat",
|
||||
"SUCCESS_COPY": "Text zkopírovaný do schránky"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Gør krav på",
|
||||
"UNCLAIM": "Frigiv",
|
||||
"START PROCESS": "Start proces",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Ingen meddelelser",
|
||||
"NOTIFICATIONS": "Meddelelser",
|
||||
"TITLE": "Meddelelser",
|
||||
"MARK_AS_READ": "Markér alle som læst"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Klik for at kopiere",
|
||||
"SUCCESS_COPY": "Teksten er kopieret til Udklipsholder"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Beanspruchen",
|
||||
"UNCLAIM": "Anspruch aufheben",
|
||||
"START PROCESS": "Prozess starten",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Keine Nachrichten",
|
||||
"NOTIFICATIONS": "Benachrichtigungen",
|
||||
"TITLE": "Benachrichtigungen",
|
||||
"MARK_AS_READ": "Alles als gelesen markieren"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Zum Kopieren klicken",
|
||||
"SUCCESS_COPY": "Text in Zwischenablage kopiert"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,11 @@
|
||||
"CLAIM": "CLAIM",
|
||||
"UNCLAIM": "RELEASE",
|
||||
"START PROCESS": "START PROCESS",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "No messages",
|
||||
"NOTIFICATIONS": "Notifications",
|
||||
"MARK_AS_READ": "Mark all as read"
|
||||
"TITLE": "Notifications",
|
||||
"MARK_AS_READ": "Mark all as read",
|
||||
"SYSTEM": "System"
|
||||
},
|
||||
"FORM": {
|
||||
"START_FORM": {
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Pedir",
|
||||
"UNCLAIM": "Liberar",
|
||||
"START PROCESS": "Iniciar proceso",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "No hay mensajes",
|
||||
"NOTIFICATIONS": "Notificaciones",
|
||||
"TITLE": "Notificaciones",
|
||||
"MARK_AS_READ": "Marcar todo como leído"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Haga clic para copiar",
|
||||
"SUCCESS_COPY": "Texto copiado al portapapeles"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Varaa",
|
||||
"UNCLAIM": "Vapauta",
|
||||
"START PROCESS": "Käynnistä prosessi",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Ei viestejä",
|
||||
"NOTIFICATIONS": "Ilmoitukset",
|
||||
"TITLE": "Ilmoitukset",
|
||||
"MARK_AS_READ": "Merkitse kaikki luetuiksi"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Kopioi napsauttamalla",
|
||||
"SUCCESS_COPY": "Teksti kopioitiin leikepöydälle"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "S'attribuer",
|
||||
"UNCLAIM": "Libérer",
|
||||
"START PROCESS": "Démarrer le processus",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Aucun message",
|
||||
"NOTIFICATIONS": "Notifications",
|
||||
"TITLE": "Notifications",
|
||||
"MARK_AS_READ": "Marquer tout comme lu"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Cliquer pour copier",
|
||||
"SUCCESS_COPY": "Texte copié dans le presse-papiers"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Richiedi",
|
||||
"UNCLAIM": "Restituisci",
|
||||
"START PROCESS": "Avvia processo",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Nessun messaggio",
|
||||
"NOTIFICATIONS": "Notifiche",
|
||||
"TITLE": "Notifiche",
|
||||
"MARK_AS_READ": "Seleziona tutti come già letti"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Fare clic per copiare",
|
||||
"SUCCESS_COPY": "Testo copiato negli appunti"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "担当する",
|
||||
"UNCLAIM": "担当解除",
|
||||
"START PROCESS": "プロセスの開始",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "メッセージなし",
|
||||
"NOTIFICATIONS": "通知",
|
||||
"TITLE": "通知",
|
||||
"MARK_AS_READ": "すべて既読にする"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "コピーするにはクリックします",
|
||||
"SUCCESS_COPY": "テキストがクリップボードにコピーされました"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Krev",
|
||||
"UNCLAIM": "Frigi",
|
||||
"START PROCESS": "Start prosess",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Ingen meldinger",
|
||||
"NOTIFICATIONS": "Varsler",
|
||||
"TITLE": "Varsler",
|
||||
"MARK_AS_READ": "Merk alle som lest"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Klikk for å kopiere",
|
||||
"SUCCESS_COPY": "Tekst kopiert til utklippstavle"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Claimen",
|
||||
"UNCLAIM": "Vrijgeven",
|
||||
"START PROCESS": "Proces starten",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Geen berichten",
|
||||
"NOTIFICATIONS": "Meldingen",
|
||||
"TITLE": "Meldingen",
|
||||
"MARK_AS_READ": "Alles markeren als gelezen"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Klik om te kopiëren",
|
||||
"SUCCESS_COPY": "Tekst gekopieerd naar Klembord"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Przejmij",
|
||||
"UNCLAIM": "Zwolnij",
|
||||
"START PROCESS": "Rozpocznij proces",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Brak komunikatów",
|
||||
"NOTIFICATIONS": "Powiadomienia",
|
||||
"TITLE": "Powiadomienia",
|
||||
"MARK_AS_READ": "Oznacz wszystkie jako przeczytane"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Kliknij, aby skopiować",
|
||||
"SUCCESS_COPY": "Tekst skopiowano do schowka"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Reivindicar",
|
||||
"UNCLAIM": "Liberar",
|
||||
"START PROCESS": "Iniciar processo",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Não há mensagens",
|
||||
"NOTIFICATIONS": "Notificações",
|
||||
"TITLE": "Notificações",
|
||||
"MARK_AS_READ": "Marcar todas como lidas"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Clique para copiar",
|
||||
"SUCCESS_COPY": "Texto copiado para a área de transferência"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Принять",
|
||||
"UNCLAIM": "Освободить",
|
||||
"START PROCESS": "Начать процесс",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Нет сообщений",
|
||||
"NOTIFICATIONS": "Оповещения",
|
||||
"TITLE": "Оповещения",
|
||||
"MARK_AS_READ": "Отметить все как прочитанное"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Нажмите, чтобы скопировать",
|
||||
"SUCCESS_COPY": "Текст скопирован в буфер обмена"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "Anta",
|
||||
"UNCLAIM": "Avsäga",
|
||||
"START PROCESS": "Starta process",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "Inga meddelanden",
|
||||
"NOTIFICATIONS": "Aviseringar",
|
||||
"TITLE": "Aviseringar",
|
||||
"MARK_AS_READ": "Markera allt som läst"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "Klicka för att kopiera",
|
||||
"SUCCESS_COPY": "Texten har kopierats till urklipp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,9 @@
|
||||
"CLAIM": "申领",
|
||||
"UNCLAIM": "释放",
|
||||
"START PROCESS": "启动流程",
|
||||
"NOTIFICATION_HISTORY": {
|
||||
"NOTIFICATIONS": {
|
||||
"NO_MESSAGE": "无消息",
|
||||
"NOTIFICATIONS": "通知",
|
||||
"TITLE": "通知",
|
||||
"MARK_AS_READ": "全部标记为已读"
|
||||
},
|
||||
"FORM": {
|
||||
@ -480,4 +480,4 @@
|
||||
"CLICK_TO_COPY": "单击以复制",
|
||||
"SUCCESS_COPY": "复制到剪贴板上的文本"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ export * from './directives/index';
|
||||
export * from './clipboard/index';
|
||||
export * from './dialogs/index';
|
||||
export * from './icon/index';
|
||||
export * from './notification-history/index';
|
||||
export * from './notifications/index';
|
||||
|
||||
export * from './utils/index';
|
||||
export * from './interface/index';
|
||||
|
@ -26,5 +26,4 @@ export * from './redirection.model';
|
||||
export * from './pagination.model';
|
||||
export * from './oauth-config.model';
|
||||
export * from './request-pagination.model';
|
||||
export * from './notification.model';
|
||||
export * from './decimal-number.model';
|
||||
|
@ -9,22 +9,23 @@
|
||||
<div id="adf-notification-history-list">
|
||||
<mat-list>
|
||||
<mat-list-item>
|
||||
<h6 mat-line>{{ 'NOTIFICATION_HISTORY.NOTIFICATIONS' | translate }}</h6>
|
||||
<h6 mat-line>{{ 'NOTIFICATIONS.TITLE' | translate }}</h6>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
<mat-divider></mat-divider>
|
||||
|
||||
<mat-list>
|
||||
<mat-list-item *ngFor="let notification of notifications">
|
||||
<mat-icon mat-list-icon>{{notification.info? notification.info: 'info'}}</mat-icon>
|
||||
<h4 mat-line>{{notification.message}}</h4>
|
||||
<p mat-line> {{notification.dateTime | date}} </p>
|
||||
<mat-icon mat-list-icon>{{ notification | noticicationIcon }}</mat-icon>
|
||||
<h4 *ngFor="let message of notification.messages" mat-line>{{ message }}</h4>
|
||||
<p mat-line> {{notification.datetime | date}} </p>
|
||||
<p mat-line> {{notification.initiator.displayName | translate}} </p>
|
||||
</mat-list-item>
|
||||
<mat-list-item *ngIf="isEmptyNotification()" id="adf-notification-history-component-no-message">
|
||||
<h4 mat-line>{{ 'NOTIFICATION_HISTORY.NO_MESSAGE' | translate }}</h4>
|
||||
<h4 mat-line>{{ 'NOTIFICATIONS.NO_MESSAGE' | translate }}</h4>
|
||||
</mat-list-item>
|
||||
<mat-action-list *ngIf="!isEmptyNotification()" id="adf-notification-history-mark-as-read">
|
||||
<button mat-list-item (click)="markAsRead()">{{ 'NOTIFICATION_HISTORY.MARK_AS_READ' | translate }}
|
||||
<button mat-list-item (click)="markAsRead()">{{ 'NOTIFICATIONS.MARK_AS_READ' | translate }}
|
||||
</button>
|
||||
</mat-action-list>
|
||||
</mat-list>
|
@ -16,11 +16,11 @@
|
||||
*/
|
||||
|
||||
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
|
||||
import { NotificationService } from '../services';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { setupTestBed } from '../../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../../testing/core.testing.module';
|
||||
import { NotificationHistoryComponent } from './notification-history.component';
|
||||
import { OverlayContainer } from '@angular/cdk/overlay';
|
||||
import { NotificationService } from '../services/notification.service';
|
||||
|
||||
describe('Notification History Component', () => {
|
||||
|
@ -46,7 +46,7 @@ export class NotificationHistoryComponent implements OnDestroy {
|
||||
|
||||
constructor(
|
||||
private notificationService: NotificationService) {
|
||||
this.notificationService.messages
|
||||
this.notificationService.notifications$
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((message) => {
|
||||
this.notifications.push(message);
|
54
lib/core/notifications/helpers/notification.factory.ts
Normal file
54
lib/core/notifications/helpers/notification.factory.ts
Normal file
@ -0,0 +1,54 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
NotificationInitiator,
|
||||
NOTIFICATION_TYPE,
|
||||
NotificationModel
|
||||
} from '../models/notification.model';
|
||||
|
||||
export const rootInitiator: NotificationInitiator = {
|
||||
key: '*',
|
||||
displayName: 'NOTIFICATIONS.SYSTEM'
|
||||
};
|
||||
|
||||
export function info(messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel {
|
||||
return {
|
||||
type: NOTIFICATION_TYPE.INFO,
|
||||
datetime: new Date(),
|
||||
initiator,
|
||||
messages: [].concat(messages)
|
||||
};
|
||||
}
|
||||
|
||||
export function warning(messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel {
|
||||
return {
|
||||
type: NOTIFICATION_TYPE.WARN,
|
||||
datetime: new Date(),
|
||||
initiator,
|
||||
messages: [].concat(messages)
|
||||
};
|
||||
}
|
||||
|
||||
export function error(messages: string | string[], initiator: NotificationInitiator = rootInitiator): NotificationModel {
|
||||
return {
|
||||
type: NOTIFICATION_TYPE.ERROR,
|
||||
datetime: new Date(),
|
||||
initiator,
|
||||
messages: [].concat(messages)
|
||||
};
|
||||
}
|
@ -15,7 +15,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export interface NotificationModel {
|
||||
dateTime: Date;
|
||||
message: string;
|
||||
export enum NOTIFICATION_TYPE {
|
||||
INFO = 'info',
|
||||
WARN = 'warning',
|
||||
ERROR = 'error'
|
||||
}
|
||||
|
||||
export interface NotificationInitiator {
|
||||
key: string | Symbol;
|
||||
displayName: string;
|
||||
extra?: any;
|
||||
}
|
||||
|
||||
export interface NotificationModel {
|
||||
type: NOTIFICATION_TYPE;
|
||||
initiator: NotificationInitiator;
|
||||
datetime: Date;
|
||||
messages: string[];
|
||||
}
|
@ -19,8 +19,9 @@ import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { MaterialModule } from '../material.module';
|
||||
|
||||
import { NotificationHistoryComponent } from './notification-history.component';
|
||||
import { NotificationHistoryComponent } from './components/notification-history.component';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NotificationIconPipe } from './pipes/notification-icon.pipe';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@ -29,7 +30,8 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
TranslateModule.forChild()
|
||||
],
|
||||
declarations: [
|
||||
NotificationHistoryComponent
|
||||
NotificationHistoryComponent,
|
||||
NotificationIconPipe
|
||||
],
|
||||
exports: [
|
||||
NotificationHistoryComponent
|
36
lib/core/notifications/pipes/notification-icon.pipe.ts
Normal file
36
lib/core/notifications/pipes/notification-icon.pipe.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { NotificationModel, NOTIFICATION_TYPE } from '../models/notification.model';
|
||||
|
||||
@Pipe({
|
||||
name: 'noticicationIcon'
|
||||
})
|
||||
export class NotificationIconPipe implements PipeTransform {
|
||||
|
||||
transform(notification: NotificationModel): string {
|
||||
switch (notification.type) {
|
||||
case NOTIFICATION_TYPE.ERROR:
|
||||
return 'error';
|
||||
case NOTIFICATION_TYPE.WARN:
|
||||
return 'warning';
|
||||
default:
|
||||
return 'info';
|
||||
}
|
||||
}
|
||||
}
|
@ -15,5 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export * from './notification-history.component';
|
||||
export * from './components/notification-history.component';
|
||||
export * from './helpers/notification.factory';
|
||||
export * from './models/notification.model';
|
||||
export * from './services/notification.service';
|
||||
export * from './notification-history.module';
|
@ -23,10 +23,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatSnackBar, MatSnackBarModule, MatSnackBarConfig } from '@angular/material';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NotificationService } from './notification.service';
|
||||
import { TranslationMock } from '../mock/translation.service.mock';
|
||||
import { TranslationService } from './translation.service';
|
||||
import { TranslationMock } from '../../mock/translation.service.mock';
|
||||
import { TranslationService } from '../../services/translation.service';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { setupTestBed } from '../../testing/setupTestBed';
|
||||
|
||||
@Component({
|
||||
template: '',
|
@ -17,10 +17,15 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MatSnackBar, MatSnackBarRef, MatSnackBarConfig } from '@angular/material';
|
||||
import { TranslationService } from './translation.service';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { TranslationService } from '../../services/translation.service';
|
||||
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { NotificationModel } from '../models/notification.model';
|
||||
import { info, warning, error } from '../helpers/notification.factory';
|
||||
|
||||
const INFO_SNACK_CLASS = 'adf-info-snackbar';
|
||||
const WARN_SNACK_CLASS = 'adf-warning-snackbar';
|
||||
const ERROR_SNACK_CLASS = 'adf-error-snackbar';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -29,40 +34,23 @@ export class NotificationService {
|
||||
|
||||
DEFAULT_DURATION_MESSAGE: number = 5000;
|
||||
|
||||
messages: Subject<NotificationModel> = new Subject();
|
||||
notifications$: Subject<NotificationModel> = new Subject();
|
||||
|
||||
constructor(private snackBar: MatSnackBar,
|
||||
private translationService: TranslationService,
|
||||
private appConfigService: AppConfigService) {
|
||||
this.DEFAULT_DURATION_MESSAGE = this.appConfigService.get<number>(AppConfigValues.NOTIFY_DURATION) || this.DEFAULT_DURATION_MESSAGE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a SnackBar notification to show a message.
|
||||
* @param message The message (or resource key) to show.
|
||||
* @param translationArgs The interpolation parameters to add for the translation
|
||||
* @param config Time before notification disappears after being shown or MatSnackBarConfig object
|
||||
* @param interpolateArgs The interpolation parameters to add for the translation
|
||||
* @returns Information/control object for the SnackBar
|
||||
*/
|
||||
openSnackMessage(message: string, config?: number | MatSnackBarConfig, translationArgs?: any): MatSnackBarRef<any> {
|
||||
const translatedMessage = this.translationService.instant(message, translationArgs);
|
||||
return this.performOpening(translatedMessage, config);
|
||||
}
|
||||
|
||||
private performOpening(translatedMessage: string, config?: number | MatSnackBarConfig): MatSnackBarRef<any> {
|
||||
if (!config) {
|
||||
config = this.DEFAULT_DURATION_MESSAGE;
|
||||
}
|
||||
|
||||
if (typeof config === 'number') {
|
||||
config = {
|
||||
duration: config
|
||||
};
|
||||
}
|
||||
this.messages.next({ message: translatedMessage, dateTime: new Date });
|
||||
|
||||
return this.snackBar.open(translatedMessage, null, config);
|
||||
openSnackMessage(message: string, config?: number | MatSnackBarConfig, interpolateArgs?: any): MatSnackBarRef<any> {
|
||||
return this.dispatchNotification(message, null, config, interpolateArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,24 +58,41 @@ export class NotificationService {
|
||||
* @param message The message (or resource key) to show.
|
||||
* @param action Caption for the response button
|
||||
* @param config Time before notification disappears after being shown or MatSnackBarConfig object
|
||||
* @param interpolateArgs The interpolation parameters to add for the translation
|
||||
* @returns Information/control object for the SnackBar
|
||||
*/
|
||||
openSnackMessageAction(message: string, action: string, config?: number | MatSnackBarConfig): MatSnackBarRef<any> {
|
||||
if (!config) {
|
||||
config = this.DEFAULT_DURATION_MESSAGE;
|
||||
}
|
||||
openSnackMessageAction(message: string, action: string, config?: number | MatSnackBarConfig, interpolateArgs?: any): MatSnackBarRef<any> {
|
||||
return this.dispatchNotification(message, action, config, interpolateArgs);
|
||||
}
|
||||
|
||||
const translatedMessage = this.translationService.instant(message);
|
||||
/**
|
||||
* Rase error message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action Action name
|
||||
* @param interpolateArgs The interpolation parameters to add for the translation
|
||||
*/
|
||||
showError(message: string, action?: string, interpolateArgs?: any): MatSnackBarRef<any> {
|
||||
return this.dispatchNotification(message, action, { panelClass: ERROR_SNACK_CLASS }, interpolateArgs);
|
||||
}
|
||||
|
||||
if (typeof config === 'number') {
|
||||
config = {
|
||||
duration: config
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Rase info message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action Action name
|
||||
* @param interpolateArgs The interpolation parameters to add for the translation
|
||||
*/
|
||||
showInfo(message: string, action?: string, interpolateArgs?: any): MatSnackBarRef<any> {
|
||||
return this.dispatchNotification(message, action, { panelClass: INFO_SNACK_CLASS }, interpolateArgs);
|
||||
}
|
||||
|
||||
this.messages.next({ message: translatedMessage, dateTime: new Date });
|
||||
|
||||
return this.snackBar.open(translatedMessage, action, config);
|
||||
/**
|
||||
* Rase warning message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action Action name
|
||||
* @param interpolateArgs The interpolation parameters to add for the translation
|
||||
*/
|
||||
showWarning(message: string, action?: string, interpolateArgs?: any): MatSnackBarRef<any> {
|
||||
return this.dispatchNotification(message, action, { panelClass: WARN_SNACK_CLASS }, interpolateArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,44 +102,31 @@ export class NotificationService {
|
||||
return this.snackBar.dismiss();
|
||||
}
|
||||
|
||||
protected showMessage(message: string, panelClass: string, action?: string, interpolateArgs?: any): MatSnackBarRef<any> {
|
||||
message = this.translationService.instant(message, interpolateArgs);
|
||||
return this.openMessageBar(message, panelClass, action);
|
||||
private dispatchNotification(message: string, action?: string, config?: number | MatSnackBarConfig, interpolateArgs?: any): MatSnackBarRef<any> {
|
||||
const translatedMessage: string = this.translationService.instant(message, interpolateArgs);
|
||||
const createNotification = this.getNotificationCreator(config);
|
||||
this.notifications$.next(createNotification(translatedMessage));
|
||||
|
||||
return this.snackBar.open(translatedMessage, action, {
|
||||
duration: (typeof config === 'number') ? config : this.DEFAULT_DURATION_MESSAGE,
|
||||
panelClass: INFO_SNACK_CLASS,
|
||||
...( (typeof config === 'object') ? config : {} )
|
||||
});
|
||||
}
|
||||
|
||||
private openMessageBar(message: string, panelClass: string, action?: string): MatSnackBarRef<any> {
|
||||
this.messages.next({ message: message, dateTime: new Date });
|
||||
private getNotificationCreator(config?: number | MatSnackBarConfig) {
|
||||
let panelClass: string = null;
|
||||
if (typeof config === 'object') {
|
||||
panelClass = Array.isArray(config.panelClass) ? config.panelClass[0] : config.panelClass;
|
||||
}
|
||||
|
||||
return this.snackBar.open(message, action, {
|
||||
duration: this.DEFAULT_DURATION_MESSAGE,
|
||||
panelClass
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Rase error message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action Action name
|
||||
*/
|
||||
showError(message: string, action?: string): MatSnackBarRef<any> {
|
||||
return this.showMessage(message, 'adf-error-snackbar', action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rase info message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action Action name
|
||||
*/
|
||||
showInfo(message: string, action?: string, interpolateArgs?: any): MatSnackBarRef<any> {
|
||||
return this.showMessage(message, 'adf-info-snackbar', action, interpolateArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rase warning message
|
||||
* @param message Text message or translation key for the message.
|
||||
* @param action Action name
|
||||
*/
|
||||
showWarning(message: string, action?: string): MatSnackBarRef<any> {
|
||||
return this.showMessage(message, 'adf-warning-snackbar', action);
|
||||
switch (panelClass) {
|
||||
case ERROR_SNACK_CLASS:
|
||||
return error;
|
||||
case WARN_SNACK_CLASS:
|
||||
return warning;
|
||||
default:
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,6 @@ export * from './page-title.service';
|
||||
export * from './storage.service';
|
||||
export * from './cookie.service';
|
||||
export * from './renditions.service';
|
||||
export * from './notification.service';
|
||||
export * from './log.service';
|
||||
export * from './translation.service';
|
||||
export * from './translate-loader.service';
|
||||
|
56
package-lock.json
generated
56
package-lock.json
generated
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "alfresco-ng2-components",
|
||||
"version": "3.4.0",
|
||||
"version": "3.5.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@alfresco/adf-cli": {
|
||||
"version": "3.5.0-7ebd28772876fa4144c347fd4fca956a27bce493",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-cli/-/adf-cli-3.5.0-7ebd28772876fa4144c347fd4fca956a27bce493.tgz",
|
||||
"integrity": "sha512-FdIvMKQ9DleFXV1g+w6dKgWg6h4mB1a44bJtxL0l/fJy4Cdsf/1IQQ2BRDl3X3dPmTOVV26Q1pAlhF08KySzKQ==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-cli/-/adf-cli-3.5.0.tgz",
|
||||
"integrity": "sha512-qHkuhb2WRzhdU7fsRfTuhWwjl0yRoaXV0XEzcBzQ+8FDIcUzkUc/cT5TzJQrkhKkJtfpV4MQEYhhXWCoXqGlVA==",
|
||||
"requires": {
|
||||
"@angular-devkit/core": "^7.2.15",
|
||||
"commander": "^2.15.1",
|
||||
@ -20,65 +20,65 @@
|
||||
}
|
||||
},
|
||||
"@alfresco/adf-content-services": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-content-services/-/adf-content-services-3.4.0.tgz",
|
||||
"integrity": "sha512-4VdB2GkWwKahOGr1jDQ3n3kaA3RFMYrIWRIdv+MU3Mx9XUPCrj/f6X0Um8qf1Wp110hDxhbSXd4PZtCqwBd1dQ==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-content-services/-/adf-content-services-3.5.0.tgz",
|
||||
"integrity": "sha512-fdw6AJyujOP/XHzVeLRnH09IMfGRFiCKFfAPxt71jhq0fj4eywlIq/OwibvXNQ2jQfWBom7tt8WHKx5uq3nHZQ==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"@alfresco/adf-core": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-core/-/adf-core-3.4.0.tgz",
|
||||
"integrity": "sha512-1TwJ9ELFTBxOKU8rKy1MDMviAHDmtexV2Q1Eo9f5JmEPRGwps2aO0R5JrdvBAf8HGpNcOp3NvJlBnVI5gjGA9Q==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-core/-/adf-core-3.5.0.tgz",
|
||||
"integrity": "sha512-uUD4hwTo2H7PTVSgo8bsp6X49dKQY5EPOh0B79bW4bTma6naoKoAGJ6wlpDBmxcG9CJNzBmmKu1pIwWhdmO71Q==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"@alfresco/adf-extensions": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-extensions/-/adf-extensions-3.4.0.tgz",
|
||||
"integrity": "sha512-nxSgwOYBn7Q3c+4Tt7J8lAw32tTWUjUOO/suYJDdaPFRG7GB2G7Ulv2gb2105gPnGDDWPUCx3qvfGRbPWjPB/A==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-extensions/-/adf-extensions-3.5.0.tgz",
|
||||
"integrity": "sha512-SbQ3+bXLZ1J+KJafcdttenJ/fe4EuqTzsb24C1Tkt4vDyHp48f0PdQL0Lq0FnMxQyErsrLijCIIlRsiWOIy24A==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"@alfresco/adf-insights": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-insights/-/adf-insights-3.4.0.tgz",
|
||||
"integrity": "sha512-skCVL80nC1uyTsjIWNwHktj0zHNLKcM1rPiqWfygW6zZwTjVpI5/XGPR7Yespr96v0qq19p1KOSwLWQ86NfL0g==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-insights/-/adf-insights-3.5.0.tgz",
|
||||
"integrity": "sha512-u1XtaFxcaC4GBR9sJ/Tt3g/Zy6Hmg3mlq4uabqYMmHe13hmtnyQ0EZZkafpn7MD7yJ+uHejUNPuFD7brRuVxVg==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"@alfresco/adf-process-services": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-process-services/-/adf-process-services-3.4.0.tgz",
|
||||
"integrity": "sha512-KD9/55QuVdoa7jZZuMPaPfQVPRFKb+3X5QAjkEb1j0+7+1tT1TNJzMxMbdCz4Z4GiFscMNUN3v8GzG4pToSxCA==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-process-services/-/adf-process-services-3.5.0.tgz",
|
||||
"integrity": "sha512-7QpVUlIDhOrX7/mTeMPNQmkUBOUSvtcKouvyVw8d9R4Huuxr7Kg7xTzdfvfNW3zRN+LYPTzDW9cBepf1Z4ywyA==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"@alfresco/adf-process-services-cloud": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-process-services-cloud/-/adf-process-services-cloud-3.4.0.tgz",
|
||||
"integrity": "sha512-pIEVNnr0muHIHPUxoP5TMgbOhojR6BaY/uA0t5hSB8tAkh6s7nM3/WUTVQCUcJWalb6xmSS1XYTrMgOvDVDH6g==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-process-services-cloud/-/adf-process-services-cloud-3.5.0.tgz",
|
||||
"integrity": "sha512-+2uSBkOip12vROQBe6KXQLxB2dgJzSi5mkvVf5z9Ubn3adFwYa8JI2Bdr5EUz0cQU9t+kjdqjEe7u6+Oo4g4YQ==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"@alfresco/adf-testing": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-testing/-/adf-testing-3.4.0.tgz",
|
||||
"integrity": "sha512-JKKq/yo2zA7x+KjcW+4tL91WLrvizvvywPyA8AyVu93SiWbuR9LUfg6DfrIhcI7ijM60SKx60PQT9gTA+ypETw==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/adf-testing/-/adf-testing-3.5.0.tgz",
|
||||
"integrity": "sha512-eYGtcalnWCzxpv98kVN9rkQUWAB0Iglux43AwQXSiHRJnA4yWeuIS3UuaXL/grSuRyj+6H+1M8fMJZfKyXjDhQ==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"@alfresco/js-api": {
|
||||
"version": "3.5.0-00a7b1b556070818a4c689ae63aa21e0b6e26f9f",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-3.5.0-00a7b1b556070818a4c689ae63aa21e0b6e26f9f.tgz",
|
||||
"integrity": "sha512-JIWAMO+mmJkMjdtL4w5wqvsMNGSyJlMCJuDdR7fBH6tQJqMEmYeHwU7OQZxsM0Ev4IrnlefNx/Hxf6P7I1JsAQ==",
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-3.5.0.tgz",
|
||||
"integrity": "sha512-LdbVDAR9AA5vwHHLHsp+v00D0XR82+myLR4JxRHIe/+KaP2DSIcZbmgqzIn0LH+tQgq3KSVcxSOZkVivB0TxOQ==",
|
||||
"requires": {
|
||||
"event-emitter": "0.3.4",
|
||||
"minimatch": "3.0.4",
|
||||
|
Loading…
x
Reference in New Issue
Block a user