mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3299] and [ADF-3300] upgrade to Angular and Material 6 (#3579)
* upgrade to HttpClient * upgrade to Renderer2 * upgrade Document reference * remove useless test with deprecated ReflectiveInjector * upgrade to latest typescript * upgrade libs * upgrade package scripts * remove rxjs blacklists and duplicate rules * add rxjs compat to help with migration * fix breaking changes * fix breaking changes in material * fix breaking changes (material 6) * upgrade rxjs, ngx-translate and flex layout * update unit tests * restore providers * upgrade deprecated Observable.error * rebase fix first configuration problems * fix style issues commented * fix core build * fix lib template errors * move lib test execution in angular.json * ignore * karma conf files * fix import statement test * single run option * update packages reporter * restore report * increase timeout * improve karma conf test configuration * fix test issues about lint * fix test analytics * fix process service test * content service fix test * fix logout directive test * fix core test * fix build * update node-sass to latest * update angular cli dependencies * improve build script create directorites and move files only if previous command succeded * upgrade individual libs to 6.0 * remove old webpack files * revert sass change * fix type issues fix style issues * fix tslint demo shell issue * fix peerdependencies * fix test e2e BC * package upate * fix style import issue * extract-text-webpack-plugin beta * fix test dist build command * remove alpha js-api * fix tslint issue add banner tslint rule * upload service fix * change BC script * fix test dist script * increase demo shell timeout test * verbose copy * path absolute * fix script bc * fix copy part * fix path warning fix monaco editor * remove duplicate header * remove unused import * fix align and check ago tests * add missing import * fix notification button selector * [ANGULAR6] fixed core tests * fix CS test * fix cs test step 2 * increase travis_wait for dist * fix attachment PS * fix checklist test * use pdf min
This commit is contained in:
committed by
Eugenio Romano
parent
c510ec864d
commit
6b24bfb1d4
@@ -17,14 +17,14 @@
|
||||
|
||||
import { AlfrescoApiService, FormValues } from '@alfresco/adf-core';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { TaskDetailsModel } from '../../task-list';
|
||||
import { ProcessFilterParamRepresentationModel } from '../models/filter-process.model';
|
||||
import { ProcessDefinitionRepresentation } from '../models/process-definition.model';
|
||||
import { ProcessInstanceVariable } from '../models/process-instance-variable.model';
|
||||
import { ProcessInstance } from '../models/process-instance.model';
|
||||
import { ProcessListModel } from '../models/process-list.model';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
declare let moment: any;
|
||||
|
||||
@@ -41,16 +41,19 @@ export class ProcessService {
|
||||
* @returns List of process instances
|
||||
*/
|
||||
getProcessInstances(requestNode: ProcessFilterParamRepresentationModel, processDefinitionKey?: string): Observable<ProcessListModel> {
|
||||
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstances(requestNode))
|
||||
.map((res: any) => {
|
||||
if (processDefinitionKey) {
|
||||
const filtered = res.data.filter(process => process.processDefinitionKey === processDefinitionKey);
|
||||
res.data = filtered;
|
||||
return res;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
}).catch(err => this.handleProcessError(err));
|
||||
return from(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstances(requestNode))
|
||||
.pipe(
|
||||
map((res: any) => {
|
||||
if (processDefinitionKey) {
|
||||
const filtered = res.data.filter(process => process.processDefinitionKey === processDefinitionKey);
|
||||
res.data = filtered;
|
||||
return res;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
}),
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,8 +62,10 @@ export class ProcessService {
|
||||
* @returns Binary PDF data
|
||||
*/
|
||||
fetchProcessAuditPdfById(processId: string): Observable<Blob> {
|
||||
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessAuditPdf(processId))
|
||||
.catch(err => this.handleProcessError(err));
|
||||
return from<Blob>(this.alfrescoApiService.getInstance().activiti.processApi.getProcessAuditPdf(processId))
|
||||
.pipe(
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +74,10 @@ export class ProcessService {
|
||||
* @returns JSON data
|
||||
*/
|
||||
fetchProcessAuditJsonById(processId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessAuditJson(processId))
|
||||
.catch(err => this.handleProcessError(err));
|
||||
return from(this.alfrescoApiService.getInstance().activiti.processApi.getProcessAuditJson(processId))
|
||||
.pipe(
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,8 +86,10 @@ export class ProcessService {
|
||||
* @returns Metadata for the instance
|
||||
*/
|
||||
getProcess(processInstanceId: string): Observable<ProcessInstance> {
|
||||
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstance(processInstanceId))
|
||||
.catch(err => this.handleProcessError(err));
|
||||
return from(this.alfrescoApiService.getInstance().activiti.processApi.getProcessInstance(processInstanceId))
|
||||
.pipe(
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,13 +105,15 @@ export class ProcessService {
|
||||
} : {
|
||||
processInstanceId: processInstanceId
|
||||
};
|
||||
return Observable.fromPromise(this.alfrescoApiService.getInstance().activiti.taskApi.listTasks(taskOpts))
|
||||
.map(this.extractData)
|
||||
.map(tasks => tasks.map((task: any) => {
|
||||
task.created = moment(task.created, 'YYYY-MM-DD').format();
|
||||
return task;
|
||||
}))
|
||||
.catch(err => this.handleProcessError(err));
|
||||
return from(this.alfrescoApiService.getInstance().activiti.taskApi.listTasks(taskOpts))
|
||||
.pipe(
|
||||
map(this.extractData),
|
||||
map(tasks => tasks.map((task: any) => {
|
||||
task.created = moment(task.created, 'YYYY-MM-DD').format();
|
||||
return task;
|
||||
})),
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,12 +128,14 @@ export class ProcessService {
|
||||
} : {
|
||||
latest: true
|
||||
};
|
||||
return Observable.fromPromise(
|
||||
return from(
|
||||
this.alfrescoApiService.getInstance().activiti.processApi.getProcessDefinitions(opts)
|
||||
)
|
||||
.map(this.extractData)
|
||||
.map(processDefs => processDefs.map((pd) => new ProcessDefinitionRepresentation(pd)))
|
||||
.catch(err => this.handleProcessError(err));
|
||||
.pipe(
|
||||
map(this.extractData),
|
||||
map(processDefs => processDefs.map((pd) => new ProcessDefinitionRepresentation(pd))),
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,11 +161,13 @@ export class ProcessService {
|
||||
if (variables) {
|
||||
startRequest.variables = variables;
|
||||
}
|
||||
return Observable.fromPromise(
|
||||
return from(
|
||||
this.alfrescoApiService.getInstance().activiti.processApi.startNewProcessInstance(startRequest)
|
||||
)
|
||||
.map((pd) => new ProcessInstance(pd))
|
||||
.catch(err => this.handleProcessError(err));
|
||||
.pipe(
|
||||
map((pd) => new ProcessInstance(pd)),
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,10 +176,12 @@ export class ProcessService {
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
cancelProcess(processInstanceId: string): Observable<void> {
|
||||
return Observable.fromPromise(
|
||||
return from<void>(
|
||||
this.alfrescoApiService.getInstance().activiti.processApi.deleteProcessInstance(processInstanceId)
|
||||
)
|
||||
.catch(err => this.handleProcessError(err));
|
||||
.pipe(
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,11 +190,13 @@ export class ProcessService {
|
||||
* @returns Array of instance variable info
|
||||
*/
|
||||
getProcessInstanceVariables(processInstanceId: string): Observable<ProcessInstanceVariable[]> {
|
||||
return Observable.fromPromise(
|
||||
return from(
|
||||
this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId)
|
||||
)
|
||||
.map((processVars: any[]) => processVars.map((pd) => new ProcessInstanceVariable(pd)))
|
||||
.catch(err => this.handleProcessError(err));
|
||||
.pipe(
|
||||
map((processVars: any[]) => processVars.map((pd) => new ProcessInstanceVariable(pd))),
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,10 +206,12 @@ export class ProcessService {
|
||||
* @returns Array of instance variable info
|
||||
*/
|
||||
createOrUpdateProcessInstanceVariables(processInstanceId: string, variables: ProcessInstanceVariable[]): Observable<ProcessInstanceVariable[]> {
|
||||
return Observable.fromPromise(
|
||||
return from<ProcessInstanceVariable[]>(
|
||||
this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processInstanceId, variables)
|
||||
)
|
||||
.catch(err => this.handleProcessError(err));
|
||||
.pipe(
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,10 +221,12 @@ export class ProcessService {
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
deleteProcessInstanceVariable(processInstanceId: string, variableName: string): Observable<void> {
|
||||
return Observable.fromPromise(
|
||||
return from<void>(
|
||||
this.alfrescoApiService.getInstance().activiti.processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName)
|
||||
)
|
||||
.catch(err => this.handleProcessError(err));
|
||||
.pipe(
|
||||
catchError(err => this.handleProcessError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private extractData(res: any) {
|
||||
@@ -211,6 +234,6 @@ export class ProcessService {
|
||||
}
|
||||
|
||||
private handleProcessError(error: any) {
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user