[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:
davidcanonieto
2021-02-16 15:27:38 +01:00
committed by GitHub
parent 7996f70b26
commit cf0c95b3d1
23 changed files with 688 additions and 57 deletions

View File

@@ -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);
}
}