mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-7427] Process Services improvements and cleanup (#9664)
This commit is contained in:
@@ -16,24 +16,18 @@
|
||||
*/
|
||||
|
||||
import { EcmUserModel, PeopleContentService } from '@alfresco/adf-content-services';
|
||||
import { BpmUserModel, PeopleProcessService } from '@alfresco/adf-process-services';
|
||||
import {
|
||||
AuthenticationService,
|
||||
BasicAlfrescoAuthService,
|
||||
IdentityUserModel,
|
||||
IdentityUserService,
|
||||
UserInfoMode
|
||||
} from '@alfresco/adf-core';
|
||||
import { PeopleProcessService } from '@alfresco/adf-process-services';
|
||||
import { AuthenticationService, BasicAlfrescoAuthService, IdentityUserModel, IdentityUserService, UserInfoMode } from '@alfresco/adf-core';
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { MenuPositionX, MenuPositionY } from '@angular/material/menu';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { UserRepresentation } from '@alfresco/js-api';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shell-user-info',
|
||||
templateUrl: './user-info.component.html'
|
||||
})
|
||||
export class UserInfoComponent implements OnInit {
|
||||
|
||||
/** Custom choice for opening the menu at the bottom. Can be `before` or `after`. */
|
||||
@Input()
|
||||
menuPositionX: MenuPositionX = 'after';
|
||||
@@ -44,17 +38,17 @@ export class UserInfoComponent implements OnInit {
|
||||
|
||||
mode: UserInfoMode;
|
||||
ecmUser$: Observable<EcmUserModel>;
|
||||
bpmUser$: Observable<BpmUserModel>;
|
||||
bpmUser$: Observable<UserRepresentation>;
|
||||
identityUser$: Observable<IdentityUserModel>;
|
||||
selectedIndex: number;
|
||||
userInfoMode = UserInfoMode;
|
||||
|
||||
constructor(private peopleContentService: PeopleContentService,
|
||||
private peopleProcessService: PeopleProcessService,
|
||||
private identityUserService: IdentityUserService,
|
||||
private basicAlfrescoAuthService: BasicAlfrescoAuthService,
|
||||
private authService: AuthenticationService) {
|
||||
}
|
||||
constructor(
|
||||
private peopleContentService: PeopleContentService,
|
||||
private peopleProcessService: PeopleProcessService,
|
||||
private identityUserService: IdentityUserService,
|
||||
private basicAlfrescoAuthService: BasicAlfrescoAuthService,
|
||||
private authService: AuthenticationService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.getUserInfo();
|
||||
@@ -69,7 +63,6 @@ export class UserInfoComponent implements OnInit {
|
||||
this.mode = UserInfoMode.CONTENT_SSO;
|
||||
this.loadEcmUserInfo();
|
||||
}
|
||||
|
||||
} else if (this.isAllLoggedIn()) {
|
||||
this.loadEcmUserInfo();
|
||||
this.loadBpmUserInfo();
|
||||
@@ -103,7 +96,10 @@ export class UserInfoComponent implements OnInit {
|
||||
}
|
||||
|
||||
private isAllLoggedIn() {
|
||||
return (this.authService.isEcmLoggedIn() && this.authService.isBpmLoggedIn()) || (this.authService.isALLProvider() && this.basicAlfrescoAuthService.isKerberosEnabled());
|
||||
return (
|
||||
(this.authService.isEcmLoggedIn() && this.authService.isBpmLoggedIn()) ||
|
||||
(this.authService.isALLProvider() && this.basicAlfrescoAuthService.isKerberosEnabled())
|
||||
);
|
||||
}
|
||||
|
||||
private isBpmLoggedIn() {
|
||||
@@ -114,4 +110,3 @@ export class UserInfoComponent implements OnInit {
|
||||
return this.authService.isEcmLoggedIn() || (this.authService.isECMProvider() && this.basicAlfrescoAuthService.isKerberosEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import { UntypedFormGroup, UntypedFormBuilder, Validators, UntypedFormControl, A
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||
import { Subject } from 'rxjs';
|
||||
import { ProcessInstanceQueryRepresentationSort, ProcessInstanceQueryRepresentationState } from '@alfresco/js-api';
|
||||
|
||||
const DEFAULT_SIZE = 20;
|
||||
|
||||
@@ -27,15 +28,14 @@ const DEFAULT_SIZE = 20;
|
||||
templateUrl: './process-list-demo.component.html',
|
||||
styleUrls: [`./process-list-demo.component.scss`]
|
||||
})
|
||||
|
||||
export class ProcessListDemoComponent implements OnInit, OnDestroy {
|
||||
minValue = 0;
|
||||
processListForm: UntypedFormGroup;
|
||||
appId: number;
|
||||
processDefId: string;
|
||||
processInsId: string;
|
||||
state: string;
|
||||
sort: string;
|
||||
state: ProcessInstanceQueryRepresentationState;
|
||||
sort: ProcessInstanceQueryRepresentationSort;
|
||||
size: number = DEFAULT_SIZE;
|
||||
page: number = 0;
|
||||
|
||||
@@ -48,15 +48,13 @@ export class ProcessListDemoComponent implements OnInit, OnDestroy {
|
||||
];
|
||||
|
||||
sortOptions = [
|
||||
{value: 'created-asc', title: 'Created (asc)'},
|
||||
{value: 'created-desc', title: 'Created (desc)'}
|
||||
{ value: 'created-asc', title: 'Created (asc)' },
|
||||
{ value: 'created-desc', title: 'Created (desc)' }
|
||||
];
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private formBuilder: UntypedFormBuilder) {
|
||||
}
|
||||
constructor(private route: ActivatedRoute, private formBuilder: UntypedFormBuilder) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.resetQueryParameters();
|
||||
@@ -91,12 +89,11 @@ export class ProcessListDemoComponent implements OnInit, OnDestroy {
|
||||
this.processListForm.valueChanges
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.pipe(debounceTime(500))
|
||||
.subscribe(processFilter => {
|
||||
.subscribe((processFilter) => {
|
||||
if (this.isFormValid()) {
|
||||
this.filterProcesses(processFilter);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
filterProcesses(processFilter: any) {
|
||||
|
@@ -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']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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>
|
||||
|
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user