mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-4259] Task filter counter notifications (#6607)
* [ACA-4259] Task Filter Counter Notifications * Improve Apollo connection for multiple apps * Improve Notification Cloud Service * Rebase branch * Rebase branch * Add peer dependencies * Rebase * Remove apollo-angular-link-http * Fix linting * Rebase branch * Fix package lock * Push package lock
This commit is contained in:
@@ -214,6 +214,11 @@
|
||||
"STORE": "Store",
|
||||
"RESTORE": "Restore"
|
||||
},
|
||||
"NOTIFICATIONS": {
|
||||
"TASK_ASSIGNED": "{{taskName}} task has been assigned to {{assignee}}",
|
||||
"PROCESS_STARTED": "{{processName}} process has been started",
|
||||
"TASK_UPDATED": "{{taskName}} task details has been updated"
|
||||
},
|
||||
"FORM-LOADING": {
|
||||
"FORM_DATA": "Form Data",
|
||||
"FORM_DATA_MESSAGE": "Enter values to populate the form",
|
||||
|
@@ -17,6 +17,23 @@
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { CloudLayoutService } from './services/cloud-layout.service';
|
||||
import { NotificationModel, NotificationService } from '@alfresco/adf-core';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { NotificationCloudService } from '@alfresco/adf-process-services-cloud';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
const SUBSCRIPTION_QUERY = `
|
||||
subscription {
|
||||
engineEvents(eventType: [
|
||||
PROCESS_STARTED
|
||||
TASK_ASSIGNED
|
||||
TASK_UPDATED
|
||||
]) {
|
||||
eventType
|
||||
entity
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@Component({
|
||||
selector: 'app-cloud-layout',
|
||||
@@ -31,13 +48,26 @@ export class CloudLayoutComponent implements OnInit {
|
||||
constructor(
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
private cloudLayoutService: CloudLayoutService
|
||||
private cloudLayoutService: CloudLayoutService,
|
||||
private notificationCloudService: NotificationCloudService,
|
||||
private notificationService: NotificationService,
|
||||
private translateService: TranslateService
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
let root: string = '';
|
||||
this.route.params.subscribe((params) => {
|
||||
this.appName = params.appName;
|
||||
this.notificationCloudService.makeGQLQuery(
|
||||
this.appName, SUBSCRIPTION_QUERY
|
||||
)
|
||||
.pipe(map((events: any) => events.data.engineEvents))
|
||||
.subscribe((result) => {
|
||||
result.map((engineEvent) => {
|
||||
this.notifyEvent(engineEvent);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (this.route.snapshot && this.route.snapshot.firstChild) {
|
||||
@@ -62,4 +92,37 @@ export class CloudLayoutComponent implements OnInit {
|
||||
onStartProcess() {
|
||||
this.router.navigate([`/cloud/${this.appName}/start-process/`]);
|
||||
}
|
||||
|
||||
notifyEvent(engineEvent) {
|
||||
let message;
|
||||
switch (engineEvent.eventType) {
|
||||
case 'TASK_ASSIGNED':
|
||||
message = this.translateService.instant('NOTIFICATIONS.TASK_ASSIGNED',
|
||||
{ taskName: engineEvent.entity.name || '', assignee: engineEvent.entity.assignee });
|
||||
this.pushNotification(engineEvent, message);
|
||||
break;
|
||||
case 'PROCESS_STARTED':
|
||||
message = this.translateService.instant('NOTIFICATIONS.PROCESS_STARTED',
|
||||
{ processName: engineEvent.entity.name });
|
||||
this.pushNotification(engineEvent, message);
|
||||
break;
|
||||
case 'TASK_UPDATED':
|
||||
message = this.translateService.instant('NOTIFICATIONS.TASK_UPDATED',
|
||||
{ taskName: engineEvent.entity.name || '' });
|
||||
this.pushNotification(engineEvent, message);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
pushNotification(engineEvent: any, message: string) {
|
||||
const notification = {
|
||||
messages: [message],
|
||||
icon: 'info',
|
||||
datetime: new Date(),
|
||||
initiator: { displayName: engineEvent.entity.initiator || 'System' }
|
||||
} as NotificationModel;
|
||||
|
||||
this.notificationService.pushToNotificationHistory(notification);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user