[ACS-7427] Process Services improvements and cleanup (#9664)

This commit is contained in:
Denys Vuika
2024-05-20 16:08:47 -04:00
committed by GitHub
parent 96e607b4de
commit e71e2a749a
174 changed files with 1736 additions and 3933 deletions

View File

@@ -17,19 +17,16 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { AppDefinitionRepresentationModel } from '@alfresco/adf-process-services';
import { AppDefinitionRepresentation } from '@alfresco/js-api';
@Component({
selector: 'app-process-list-view',
templateUrl: './apps-view.component.html'
})
export class AppsViewComponent {
constructor(private router: Router) {}
constructor(private router: Router) {
onAppClicked(app: AppDefinitionRepresentation) {
this.router.navigate(['/activiti/apps', app.id || 0, 'tasks']);
}
onAppClicked(app: AppDefinitionRepresentationModel) {
this.router.navigate(['/activiti/apps', app.id || 0, 'tasks']);
}
}

View File

@@ -1,36 +0,0 @@
/*!
* @license
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 { FormFieldModel, FormFieldTypes, FormFieldValidator } from '@alfresco/adf-core';
export class DemoFieldValidator implements FormFieldValidator {
isSupported(field: FormFieldModel): boolean {
return field && field.type === FormFieldTypes.TEXT;
}
validate(field: FormFieldModel): boolean {
if (this.isSupported(field)) {
if (field.value && field.value.toLowerCase() === 'admin') {
field.validationSummary.message = 'Sorry, the value cannot be "admin".';
return false;
}
}
return true;
}
}

View File

@@ -16,29 +16,12 @@
*/
import { Component, Input, OnChanges, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import {
ProcessAttachmentListComponent,
ProcessInstance,
ProcessService,
ProcessUploadService
} from '@alfresco/adf-process-services';
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
import { DiscoveryApiService, UploadService } from '@alfresco/adf-content-services';
import { ProcessAttachmentListComponent, ProcessService, ProcessUploadService } from '@alfresco/adf-process-services';
import { UploadService } from '@alfresco/adf-content-services';
import { PreviewService } from '../../services/preview.service';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
/**
* Provide a factory for process upload service
*
* @param api api client
* @param config config service
* @param discoveryApiService discovery service
* @returns factory function
*/
export function processUploadServiceFactory(api: AlfrescoApiService, config: AppConfigService, discoveryApiService: DiscoveryApiService) {
return new ProcessUploadService(api, config, discoveryApiService);
}
import { ProcessInstanceRepresentation } from '@alfresco/js-api';
@Component({
selector: 'app-process-attachments',
@@ -47,41 +30,31 @@ export function processUploadServiceFactory(api: AlfrescoApiService, config: App
providers: [
{
provide: UploadService,
useFactory: (processUploadServiceFactory),
deps: [AlfrescoApiService, AppConfigService, DiscoveryApiService]
useClass: ProcessUploadService
}
],
encapsulation: ViewEncapsulation.None
})
export class ProcessAttachmentsComponent implements OnInit, OnChanges, OnDestroy {
@ViewChild('processAttachList')
processAttachList: ProcessAttachmentListComponent;
@Input()
processInstanceId: string;
processInstance: ProcessInstance;
processInstance: ProcessInstanceRepresentation;
private onDestroy$ = new Subject<boolean>();
constructor(
private uploadService: UploadService,
private processService: ProcessService,
private preview: PreviewService
) {}
constructor(private uploadService: UploadService, private processService: ProcessService, private preview: PreviewService) {}
ngOnInit() {
this.uploadService.fileUploadComplete
.pipe(takeUntil(this.onDestroy$))
.subscribe(value => this.onFileUploadComplete(value.data));
this.uploadService.fileUploadComplete.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.onFileUploadComplete(value.data));
}
ngOnChanges() {
if (this.processInstanceId) {
this.processService.getProcess(this.processInstanceId)
.subscribe((processInstance: ProcessInstance) => {
this.processService.getProcess(this.processInstanceId).subscribe((processInstance) => {
this.processInstance = processInstance;
});
}
@@ -103,5 +76,4 @@ export class ProcessAttachmentsComponent implements OnInit, OnChanges, OnDestroy
isCompletedProcess(): boolean {
return this.processInstance?.ended != null;
}
}

View File

@@ -162,7 +162,7 @@
[title]="'Start Process'"
[name]="defaultProcessName"
(formContentClicked)="onContentClick($event)"
(start)="onStartProcessInstance($event)"
(start)="onStartProcessInstance($event.id)"
(cancel)="onCancelProcessInstance()"
(error)="onStartProcessError($event)">
</adf-start-process>

View File

@@ -18,7 +18,7 @@
// eslint-disable-next-line
import { AfterViewInit, Component, ElementRef, Input, OnDestroy, OnInit, ViewChild, ViewEncapsulation, EventEmitter, Output } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Pagination, UserProcessInstanceFilterRepresentation, ScriptFilesApi } from '@alfresco/js-api';
import { Pagination, UserProcessInstanceFilterRepresentation, ScriptFilesApi, UserTaskFilterRepresentation } from '@alfresco/js-api';
import {
FORM_FIELD_VALIDATORS,
FormRenderingService,
@@ -32,10 +32,8 @@ import {
} from '@alfresco/adf-core';
import {
ProcessFiltersComponent,
ProcessInstance,
ProcessInstanceListComponent,
StartProcessInstanceComponent,
FilterRepresentationModel,
TaskDetailsEvent,
TaskFiltersComponent,
TaskListComponent,
@@ -45,7 +43,6 @@ import {
DynamicTableRow
} from '@alfresco/adf-process-services';
import { Subject } from 'rxjs';
import { DemoFieldValidator } from './demo-field-validator';
import { PreviewService } from '../../services/preview.service';
import { Location } from '@angular/common';
import { takeUntil } from 'rxjs/operators';
@@ -107,7 +104,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
activeTab: number = this.tabs.tasks; // tasks|processes|reports
taskFilter: FilterRepresentationModel;
taskFilter: UserTaskFilterRepresentation;
processFilter: UserProcessInstanceFilterRepresentation;
blobFile: any;
flag = true;
@@ -117,7 +114,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
applicationId: number;
processDefinitionName: string;
fieldValidators = [...FORM_FIELD_VALIDATORS, new DemoFieldValidator()];
fieldValidators = [...FORM_FIELD_VALIDATORS];
private onDestroy$ = new Subject<boolean>();
private scriptFileApi: ScriptFilesApi;
@@ -127,17 +124,17 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
private route: ActivatedRoute,
private router: Router,
private apiService: AlfrescoApiService,
private appConfig: AppConfigService,
private preview: PreviewService,
private appConfigService: AppConfigService,
private previewService: PreviewService,
formService: FormService,
private location: Location,
private notificationService: NotificationService,
private preferenceService: UserPreferencesService
) {
this.scriptFileApi = new ScriptFilesApi(this.apiService.getInstance());
this.defaultProcessName = this.appConfig.get<string>('adf-start-process.name');
this.defaultProcessDefinitionName = this.appConfig.get<string>('adf-start-process.processDefinitionName');
this.defaultTaskName = this.appConfig.get<string>('adf-start-task.name');
this.defaultProcessName = this.appConfigService.get<string>('adf-start-process.name');
this.defaultProcessDefinitionName = this.appConfigService.get<string>('adf-start-process.processDefinitionName');
this.defaultTaskName = this.appConfigService.get<string>('adf-start-task.name');
this.processDefinitionName = this.defaultProcessDefinitionName;
this.preferenceService
@@ -190,7 +187,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
this.onDestroy$.complete();
}
onTaskFilterClick(filter: FilterRepresentationModel): void {
onTaskFilterClick(filter: UserTaskFilterRepresentation): void {
this.applyTaskFilter(filter);
this.taskPage = 0;
}
@@ -218,7 +215,7 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
this.applyTaskFilter(this.activitiFilter.getCurrentFilter());
}
applyTaskFilter(filter: FilterRepresentationModel) {
applyTaskFilter(filter: UserTaskFilterRepresentation) {
this.taskFilter = Object.assign({}, filter);
if (filter && this.taskList) {
@@ -285,8 +282,8 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
this.currentTaskId = currentTaskIdNew;
}
onStartProcessInstance(instance: ProcessInstance): void {
this.currentProcessInstanceId = instance.id;
onStartProcessInstance(instanceId: string): void {
this.currentProcessInstanceId = instanceId;
this.activitiStartProcess.reset();
this.activitiProcessFilter.selectRunningFilter();
}
@@ -348,9 +345,9 @@ export class ProcessServiceComponent implements AfterViewInit, OnDestroy, OnInit
private showContentPreview(content: any) {
if (content.contentBlob) {
this.preview.showBlob(content.name, content.contentBlob);
this.previewService.showBlob(content.name, content.contentBlob);
} else {
this.preview.showResource(content.sourceId.split(';')[0]);
this.previewService.showResource(content.sourceId.split(';')[0]);
}
}

View File

@@ -16,12 +16,7 @@
*/
import { Component, Input, OnChanges, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import {
TaskAttachmentListComponent,
TaskDetailsModel,
TaskListService,
TaskUploadService
} from '@alfresco/adf-process-services';
import { TaskAttachmentListComponent, TaskDetailsModel, TaskListService, TaskUploadService } from '@alfresco/adf-process-services';
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
import { DiscoveryApiService, UploadService } from '@alfresco/adf-content-services';
import { PreviewService } from '../../services/preview.service';
@@ -48,14 +43,12 @@ export function taskUploadServiceFactory(api: AlfrescoApiService, config: AppCon
providers: [
{
provide: UploadService,
useFactory: (taskUploadServiceFactory),
useFactory: taskUploadServiceFactory,
deps: [AlfrescoApiService, AppConfigService, DiscoveryApiService]
}
]
})
export class TaskAttachmentsComponent implements OnInit, OnChanges, OnDestroy {
@ViewChild('taskAttachList')
taskAttachList: TaskAttachmentListComponent;
@@ -66,23 +59,15 @@ export class TaskAttachmentsComponent implements OnInit, OnChanges, OnDestroy {
private onDestroy$ = new Subject<boolean>();
constructor(
private uploadService: UploadService,
private activitiTaskList: TaskListService,
private preview: PreviewService) {
}
constructor(private uploadService: UploadService, private taskListService: TaskListService, private previewService: PreviewService) {}
ngOnInit() {
this.uploadService.fileUploadComplete
.pipe(takeUntil(this.onDestroy$))
.subscribe(event => this.onFileUploadComplete(event.data));
this.uploadService.fileUploadComplete.pipe(takeUntil(this.onDestroy$)).subscribe((event) => this.onFileUploadComplete(event.data));
}
ngOnChanges() {
if (this.taskId) {
this.activitiTaskList
.getTaskDetails(this.taskId)
.subscribe(taskDetails => this.taskDetails = taskDetails);
this.taskListService.getTaskDetails(this.taskId).subscribe((taskDetails) => (this.taskDetails = taskDetails));
}
}
@@ -96,11 +81,10 @@ export class TaskAttachmentsComponent implements OnInit, OnChanges, OnDestroy {
}
onAttachmentClick(content: any): void {
this.preview.showBlob(content.name, content.contentBlob);
this.previewService.showBlob(content.name, content.contentBlob);
}
isCompletedTask(): boolean {
return this.taskDetails?.endDate != null;
}
}