diff --git a/lib/core/clipboard/clipboard.service.spec.ts b/lib/core/clipboard/clipboard.service.spec.ts
index 3760b5f7c9..6d07a4d6fd 100644
--- a/lib/core/clipboard/clipboard.service.spec.ts
+++ b/lib/core/clipboard/clipboard.service.spec.ts
@@ -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';
diff --git a/lib/core/clipboard/clipboard.service.ts b/lib/core/clipboard/clipboard.service.ts
index a265340e70..32eb064a19 100644
--- a/lib/core/clipboard/clipboard.service.ts
+++ b/lib/core/clipboard/clipboard.service.ts
@@ -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 {
diff --git a/lib/core/core.module.ts b/lib/core/core.module.ts
index d724a1bf14..042b8a247f 100644
--- a/lib/core/core.module.ts
+++ b/lib/core/core.module.ts
@@ -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';
diff --git a/lib/core/i18n/ar.json b/lib/core/i18n/ar.json
index 3f8909a883..a128a7e963 100755
--- a/lib/core/i18n/ar.json
+++ b/lib/core/i18n/ar.json
@@ -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": "تم نسخ النص إلى الحافظة"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/cs.json b/lib/core/i18n/cs.json
index 302e800c03..b13639a4b0 100755
--- a/lib/core/i18n/cs.json
+++ b/lib/core/i18n/cs.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/da.json b/lib/core/i18n/da.json
index 8184745722..7d208db223 100755
--- a/lib/core/i18n/da.json
+++ b/lib/core/i18n/da.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/de.json b/lib/core/i18n/de.json
index ac2ec706cd..87932609d6 100755
--- a/lib/core/i18n/de.json
+++ b/lib/core/i18n/de.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/en.json b/lib/core/i18n/en.json
index ced58feafb..f92a469376 100644
--- a/lib/core/i18n/en.json
+++ b/lib/core/i18n/en.json
@@ -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": {
diff --git a/lib/core/i18n/es.json b/lib/core/i18n/es.json
index 1458e5fd84..315b1da060 100755
--- a/lib/core/i18n/es.json
+++ b/lib/core/i18n/es.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/fi.json b/lib/core/i18n/fi.json
index 7c1d983dae..64f9d2d4eb 100755
--- a/lib/core/i18n/fi.json
+++ b/lib/core/i18n/fi.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/fr.json b/lib/core/i18n/fr.json
index cdf88042a3..f8a92a454e 100755
--- a/lib/core/i18n/fr.json
+++ b/lib/core/i18n/fr.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/it.json b/lib/core/i18n/it.json
index 0c17625989..4de2c71fa4 100755
--- a/lib/core/i18n/it.json
+++ b/lib/core/i18n/it.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/ja.json b/lib/core/i18n/ja.json
index b78fc097ba..47910cc16d 100755
--- a/lib/core/i18n/ja.json
+++ b/lib/core/i18n/ja.json
@@ -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": "テキストがクリップボードにコピーされました"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/nb.json b/lib/core/i18n/nb.json
index 54d5650066..6784e02dc4 100755
--- a/lib/core/i18n/nb.json
+++ b/lib/core/i18n/nb.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/nl.json b/lib/core/i18n/nl.json
index f998496a4e..66733cc60b 100755
--- a/lib/core/i18n/nl.json
+++ b/lib/core/i18n/nl.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/pl.json b/lib/core/i18n/pl.json
index 2a79cc7f25..4325f5ec83 100755
--- a/lib/core/i18n/pl.json
+++ b/lib/core/i18n/pl.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/pt-BR.json b/lib/core/i18n/pt-BR.json
index ed807b1303..3300d44847 100755
--- a/lib/core/i18n/pt-BR.json
+++ b/lib/core/i18n/pt-BR.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/ru.json b/lib/core/i18n/ru.json
index b81fc63b92..71844f2c92 100755
--- a/lib/core/i18n/ru.json
+++ b/lib/core/i18n/ru.json
@@ -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": "Текст скопирован в буфер обмена"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/sv.json b/lib/core/i18n/sv.json
index f03ef0233f..4aa6b22e55 100755
--- a/lib/core/i18n/sv.json
+++ b/lib/core/i18n/sv.json
@@ -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"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/i18n/zh-CN.json b/lib/core/i18n/zh-CN.json
index 772b801965..fc0d9cffe7 100755
--- a/lib/core/i18n/zh-CN.json
+++ b/lib/core/i18n/zh-CN.json
@@ -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": "复制到剪贴板上的文本"
}
-}
\ No newline at end of file
+}
diff --git a/lib/core/index.ts b/lib/core/index.ts
index 7411e7597f..a78bb5c00b 100644
--- a/lib/core/index.ts
+++ b/lib/core/index.ts
@@ -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';
diff --git a/lib/core/models/public-api.ts b/lib/core/models/public-api.ts
index 8df9e6af25..e79a97fa5d 100644
--- a/lib/core/models/public-api.ts
+++ b/lib/core/models/public-api.ts
@@ -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';
diff --git a/lib/core/notification-history/notification-history.component.html b/lib/core/notifications/components/notification-history.component.html
similarity index 72%
rename from lib/core/notification-history/notification-history.component.html
rename to lib/core/notifications/components/notification-history.component.html
index 00fe54a17c..3ba9cbda4d 100644
--- a/lib/core/notification-history/notification-history.component.html
+++ b/lib/core/notifications/components/notification-history.component.html
@@ -9,22 +9,22 @@
- {{ 'NOTIFICATION_HISTORY.NOTIFICATIONS' | translate }}
+ {{ 'NOTIFICATIONS.TITLE' | translate }}
- {{notification.info? notification.info: 'info'}}
- {{notification.message}}
- {{notification.dateTime | date}}
+ {{notification.info ? notification.info: 'info'}}
+ {{ message }}
+ {{notification.datetime | date}}
- {{ 'NOTIFICATION_HISTORY.NO_MESSAGE' | translate }}
+ {{ 'NOTIFICATIONS.NO_MESSAGE' | translate }}
-
diff --git a/lib/core/notification-history/notification-history.component.scss b/lib/core/notifications/components/notification-history.component.scss
similarity index 100%
rename from lib/core/notification-history/notification-history.component.scss
rename to lib/core/notifications/components/notification-history.component.scss
diff --git a/lib/core/notification-history/notification-history.component.spec.ts b/lib/core/notifications/components/notification-history.component.spec.ts
similarity index 93%
rename from lib/core/notification-history/notification-history.component.spec.ts
rename to lib/core/notifications/components/notification-history.component.spec.ts
index 18e3e8b534..33d27dc046 100644
--- a/lib/core/notification-history/notification-history.component.spec.ts
+++ b/lib/core/notifications/components/notification-history.component.spec.ts
@@ -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', () => {
diff --git a/lib/core/notification-history/notification-history.component.ts b/lib/core/notifications/components/notification-history.component.ts
similarity index 93%
rename from lib/core/notification-history/notification-history.component.ts
rename to lib/core/notifications/components/notification-history.component.ts
index 120337a8ff..e41b7ffb12 100644
--- a/lib/core/notification-history/notification-history.component.ts
+++ b/lib/core/notifications/components/notification-history.component.ts
@@ -17,7 +17,7 @@
import { Component, Input, ViewChild, OnDestroy } from '@angular/core';
import { NotificationService } from '../services/notification.service';
-import { NotificationModel } from '../models/notification.model';
+import { Notification } from '../models/notification.model';
import { MatMenuTrigger } from '@angular/material';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
@@ -31,7 +31,7 @@ export class NotificationHistoryComponent implements OnDestroy {
onDestroy$ = new Subject
();
- notifications: NotificationModel[] = [];
+ notifications: Notification[] = [];
@ViewChild(MatMenuTrigger)
trigger: MatMenuTrigger;
@@ -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);
diff --git a/lib/core/notifications/helpers/notification.factory.ts b/lib/core/notifications/helpers/notification.factory.ts
new file mode 100644
index 0000000000..39545cec9a
--- /dev/null
+++ b/lib/core/notifications/helpers/notification.factory.ts
@@ -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,
+ Notification
+} from '../models/notification.model';
+
+export const rootInitiator: NotificationInitiator = {
+ key: '*',
+ displayName: 'NOTIFICATIONS.SYSTEM'
+};
+
+export function info(messages: string | string[], initiator: NotificationInitiator = rootInitiator): Notification {
+ return {
+ type: NOTIFICATION_TYPE.INFO,
+ datetime: new Date(),
+ initiator,
+ messages: [].concat(messages)
+ };
+}
+
+export function warning(messages: string | string[], initiator: NotificationInitiator = rootInitiator): Notification {
+ return {
+ type: NOTIFICATION_TYPE.WARN,
+ datetime: new Date(),
+ initiator,
+ messages: [].concat(messages)
+ };
+}
+
+export function error(messages: string | string[], initiator: NotificationInitiator = rootInitiator): Notification {
+ return {
+ type: NOTIFICATION_TYPE.ERROR,
+ datetime: new Date(),
+ initiator,
+ messages: [].concat(messages)
+ };
+}
diff --git a/lib/core/notification-history/index.ts b/lib/core/notifications/index.ts
similarity index 100%
rename from lib/core/notification-history/index.ts
rename to lib/core/notifications/index.ts
diff --git a/lib/core/models/notification.model.ts b/lib/core/notifications/models/notification.model.ts
similarity index 63%
rename from lib/core/models/notification.model.ts
rename to lib/core/notifications/models/notification.model.ts
index 973d71e9ba..b7cb44dcf6 100644
--- a/lib/core/models/notification.model.ts
+++ b/lib/core/notifications/models/notification.model.ts
@@ -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 Notification {
+ type: NOTIFICATION_TYPE;
+ initiator: NotificationInitiator;
+ datetime: Date;
+ messages: string[];
}
diff --git a/lib/core/notification-history/notification-history.module.ts b/lib/core/notifications/notification-history.module.ts
similarity index 92%
rename from lib/core/notification-history/notification-history.module.ts
rename to lib/core/notifications/notification-history.module.ts
index 7ff6a537e6..1cefa36c47 100644
--- a/lib/core/notification-history/notification-history.module.ts
+++ b/lib/core/notifications/notification-history.module.ts
@@ -19,7 +19,7 @@ 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';
@NgModule({
diff --git a/lib/core/notification-history/public-api.ts b/lib/core/notifications/public-api.ts
similarity index 76%
rename from lib/core/notification-history/public-api.ts
rename to lib/core/notifications/public-api.ts
index 887fe4b1c6..4270a04134 100644
--- a/lib/core/notification-history/public-api.ts
+++ b/lib/core/notifications/public-api.ts
@@ -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';
diff --git a/lib/core/services/notification.service.spec.ts b/lib/core/notifications/services/notification.service.spec.ts
similarity index 96%
rename from lib/core/services/notification.service.spec.ts
rename to lib/core/notifications/services/notification.service.spec.ts
index f26646baa1..d9664c47ed 100644
--- a/lib/core/services/notification.service.spec.ts
+++ b/lib/core/notifications/services/notification.service.spec.ts
@@ -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: '',
diff --git a/lib/core/notifications/services/notification.service.ts b/lib/core/notifications/services/notification.service.ts
new file mode 100644
index 0000000000..bbfd7a8731
--- /dev/null
+++ b/lib/core/notifications/services/notification.service.ts
@@ -0,0 +1,129 @@
+/*!
+ * @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 { Injectable } from '@angular/core';
+import { MatSnackBar, MatSnackBarRef, MatSnackBarConfig } from '@angular/material';
+import { TranslationService } from '../../services/translation.service';
+import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
+import { Subject } from 'rxjs';
+import { Notification } 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'
+})
+export class NotificationService {
+
+ DEFAULT_DURATION_MESSAGE: number = 5000;
+
+ notifications$: Subject = new Subject();
+
+ constructor(private snackBar: MatSnackBar,
+ private translationService: TranslationService,
+ private appConfigService: AppConfigService) {
+ this.DEFAULT_DURATION_MESSAGE = this.appConfigService.get(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 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, interpolateArgs?: any): MatSnackBarRef {
+ return this.dispatchNotification(message, null, config, interpolateArgs);
+ }
+
+ /**
+ * Opens a SnackBar notification with a message and a response button.
+ * @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, interpolateArgs?: any): MatSnackBarRef {
+ return this.dispatchNotification(message, action, config, interpolateArgs);
+ }
+
+ /**
+ * 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 {
+ return this.dispatchNotification(message, action, { panelClass: ERROR_SNACK_CLASS }, interpolateArgs);
+ }
+
+ /**
+ * 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 {
+ return this.dispatchNotification(message, action, { panelClass: INFO_SNACK_CLASS }, interpolateArgs);
+ }
+
+ /**
+ * 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 {
+ return this.dispatchNotification(message, action, { panelClass: WARN_SNACK_CLASS }, interpolateArgs);
+ }
+
+ /**
+ * dismiss the notification snackbar
+ */
+ dismissSnackMessageAction() {
+ return this.snackBar.dismiss();
+ }
+
+ private dispatchNotification(message: string, action?: string, config?: number | MatSnackBarConfig, interpolateArgs?: any): MatSnackBarRef {
+ 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 getNotificationCreator(config?: number | MatSnackBarConfig) {
+ const panelClass: string = config && ( config).panelClass && ( config).panelClass[0] || '';
+
+ switch (panelClass) {
+ case ERROR_SNACK_CLASS:
+ return error;
+ case WARN_SNACK_CLASS:
+ return warning;
+ default:
+ return info;
+ }
+ }
+}
diff --git a/lib/core/services/notification.service.ts b/lib/core/services/notification.service.ts
deleted file mode 100644
index a8ba26d12c..0000000000
--- a/lib/core/services/notification.service.ts
+++ /dev/null
@@ -1,140 +0,0 @@
-/*!
- * @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 { 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 { Subject } from 'rxjs';
-import { NotificationModel } from '../models/notification.model';
-
-@Injectable({
- providedIn: 'root'
-})
-export class NotificationService {
-
- DEFAULT_DURATION_MESSAGE: number = 5000;
-
- messages: Subject = new Subject();
-
- constructor(private snackBar: MatSnackBar,
- private translationService: TranslationService,
- private appConfigService: AppConfigService) {
- this.DEFAULT_DURATION_MESSAGE = this.appConfigService.get(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
- * @returns Information/control object for the SnackBar
- */
- openSnackMessage(message: string, config?: number | MatSnackBarConfig, translationArgs?: any): MatSnackBarRef {
- const translatedMessage = this.translationService.instant(message, translationArgs);
- return this.performOpening(translatedMessage, config);
- }
-
- private performOpening(translatedMessage: string, config?: number | MatSnackBarConfig): MatSnackBarRef {
- 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);
- }
-
- /**
- * Opens a SnackBar notification with a message and a response button.
- * @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
- * @returns Information/control object for the SnackBar
- */
- openSnackMessageAction(message: string, action: string, config?: number | MatSnackBarConfig): MatSnackBarRef {
- if (!config) {
- config = this.DEFAULT_DURATION_MESSAGE;
- }
-
- const translatedMessage = this.translationService.instant(message);
-
- if (typeof config === 'number') {
- config = {
- duration: config
- };
- }
-
- this.messages.next({ message: translatedMessage, dateTime: new Date });
-
- return this.snackBar.open(translatedMessage, action, config);
- }
-
- /**
- * dismiss the notification snackbar
- */
- dismissSnackMessageAction() {
- return this.snackBar.dismiss();
- }
-
- protected showMessage(message: string, panelClass: string, action?: string, interpolateArgs?: any): MatSnackBarRef {
- message = this.translationService.instant(message, interpolateArgs);
- return this.openMessageBar(message, panelClass, action);
- }
-
- private openMessageBar(message: string, panelClass: string, action?: string): MatSnackBarRef {
- this.messages.next({ message: message, dateTime: new Date });
-
- 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 {
- 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 {
- 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 {
- return this.showMessage(message, 'adf-warning-snackbar', action);
- }
-}
diff --git a/lib/core/services/public-api.ts b/lib/core/services/public-api.ts
index a336846312..423bee6f94 100644
--- a/lib/core/services/public-api.ts
+++ b/lib/core/services/public-api.ts
@@ -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';