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
@@ -19,10 +19,10 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { LogService } from '../../services/log.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlfrescoApi, MinimalNodeEntryEntity, RelatedContentRepresentation } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { ExternalContent } from '../components/widgets/core/external-content';
|
||||
import { ExternalContentLink } from '../components/widgets/core/external-content-link';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class ActivitiContentService {
|
||||
@@ -43,9 +43,11 @@ export class ActivitiContentService {
|
||||
getAlfrescoNodes(accountId: string, folderId: string): Observable<[ExternalContent]> {
|
||||
let apiService: AlfrescoApi = this.apiService.getInstance();
|
||||
let accountShortId = accountId.replace('alfresco-', '');
|
||||
return Observable.fromPromise(apiService.activiti.alfrescoApi.getContentInFolder(accountShortId, folderId))
|
||||
.map(this.toJsonArray)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(apiService.activiti.alfrescoApi.getContentInFolder(accountShortId, folderId))
|
||||
.pipe(
|
||||
map(this.toJsonArray),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,9 +62,11 @@ export class ActivitiContentService {
|
||||
tenantId: tenantId,
|
||||
includeAccounts: includeAccount
|
||||
};
|
||||
return Observable.fromPromise(apiService.activiti.alfrescoApi.getRepositories(opts))
|
||||
.map(this.toJsonArray)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(apiService.activiti.alfrescoApi.getRepositories(opts))
|
||||
.pipe(
|
||||
map(this.toJsonArray),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,14 +77,18 @@ export class ActivitiContentService {
|
||||
* @param siteId
|
||||
*/
|
||||
linkAlfrescoNode(accountId: string, node: ExternalContent, siteId: string): Observable<ExternalContentLink> {
|
||||
let apiService: AlfrescoApi = this.apiService.getInstance();
|
||||
return Observable.fromPromise(apiService.activiti.contentApi.createTemporaryRelatedContent({
|
||||
const apiService: AlfrescoApi = this.apiService.getInstance();
|
||||
return from(apiService.activiti.contentApi.createTemporaryRelatedContent({
|
||||
link: true,
|
||||
name: node.title,
|
||||
simpleType: node.simpleType,
|
||||
source: accountId,
|
||||
sourceId: node.id + '@' + siteId
|
||||
})).map(this.toJson).catch(err => this.handleError(err));
|
||||
}))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
applyAlfrescoNode(node: MinimalNodeEntryEntity, siteId: string, accountId: string) {
|
||||
@@ -93,10 +101,11 @@ export class ActivitiContentService {
|
||||
name: node.name,
|
||||
link: false
|
||||
};
|
||||
return Observable.fromPromise(
|
||||
apiService.activiti.contentApi.createTemporaryRelatedContent(params))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(apiService.activiti.contentApi.createTemporaryRelatedContent(params))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private getSiteNameFromNodePath(node: MinimalNodeEntryEntity): string {
|
||||
@@ -132,6 +141,6 @@ export class ActivitiContentService {
|
||||
error.status ? `${error.status} - ${error.statusText}` : ActivitiContentService.GENERIC_ERROR_MESSAGE;
|
||||
}
|
||||
this.logService.error(errMsg);
|
||||
return Observable.throw(errMsg);
|
||||
return throwError(errMsg);
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable } from 'rxjs';
|
||||
import { FormModel } from './../components/widgets/core/form.model';
|
||||
import { EcmModelService } from './ecm-model.service';
|
||||
import { setupTestBed } from '../../testing/setupTestBed';
|
||||
|
@@ -18,9 +18,9 @@
|
||||
import { LogService } from '../../services/log.service';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { FormModel } from '../components/widgets/core/form.model';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class EcmModelService {
|
||||
@@ -56,9 +56,9 @@ export class EcmModelService {
|
||||
}
|
||||
|
||||
searchActivitiEcmModel() {
|
||||
return this.getEcmModels().map(function (ecmModels: any) {
|
||||
return this.getEcmModels().pipe(map(function (ecmModels: any) {
|
||||
return ecmModels.list.entries.find(model => model.entry.name === EcmModelService.MODEL_NAME);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
createActivitiEcmModel(formName: string, form: FormModel): Observable<any> {
|
||||
@@ -120,41 +120,51 @@ export class EcmModelService {
|
||||
}
|
||||
|
||||
public searchEcmType(typeName: string, modelName: string): Observable<any> {
|
||||
return this.getEcmType(modelName).map(function (customTypes: any) {
|
||||
return this.getEcmType(modelName).pipe(map(function (customTypes: any) {
|
||||
return customTypes.list.entries.find(type => type.entry.prefixedName === typeName || type.entry.title === typeName);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public activeEcmModel(modelName: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.activateCustomModel(modelName))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().core.customModelApi.activateCustomModel(modelName))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
public createEcmModel(modelName: string, nameSpace: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.createCustomModel('DRAFT', '', modelName, modelName, nameSpace))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().core.customModelApi.createCustomModel('DRAFT', '', modelName, modelName, nameSpace))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
public getEcmModels(): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.getAllCustomModel())
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().core.customModelApi.getAllCustomModel())
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
public getEcmType(modelName: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.getAllCustomType(modelName))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().core.customModelApi.getAllCustomType(modelName))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
public createEcmType(typeName: string, modelName: string, parentType: string): Observable<any> {
|
||||
let name = this.cleanNameType(typeName);
|
||||
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.createCustomType(modelName, name, parentType, typeName, ''))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().core.customModelApi.createCustomType(modelName, name, parentType, typeName, ''))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
public addPropertyToAType(modelName: string, typeName: string, formFields: any) {
|
||||
@@ -177,9 +187,11 @@ export class EcmModelService {
|
||||
}
|
||||
}
|
||||
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.customModelApi.addPropertyToType(modelName, name, properties))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().core.customModelApi.addPropertyToType(modelName, name, properties))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -19,8 +19,7 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { LogService } from '../../services/log.service';
|
||||
import { UserProcessModel } from '../../models';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { Observable, Subject, from, of, throwError } from 'rxjs';
|
||||
import { FormDefinitionModel } from '../models/form-definition.model';
|
||||
import { ContentLinkModel } from './../components/widgets/core/content-link.model';
|
||||
import { GroupModel } from './../components/widgets/core/group.model';
|
||||
@@ -30,10 +29,7 @@ import {
|
||||
ValidateDynamicTableRowEvent, ValidateFormEvent, ValidateFormFieldEvent
|
||||
} from './../events/index';
|
||||
import { EcmModelService } from './ecm-model.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/defaultIfEmpty';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { map, catchError, switchMap, combineAll, defaultIfEmpty } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class FormService {
|
||||
@@ -150,7 +146,7 @@ export class FormService {
|
||||
stencilSet: 0
|
||||
};
|
||||
|
||||
return Observable.fromPromise(
|
||||
return from(
|
||||
this.modelsApi.createModel(dataModel)
|
||||
);
|
||||
}
|
||||
@@ -162,7 +158,7 @@ export class FormService {
|
||||
* @returns Data for the saved form
|
||||
*/
|
||||
saveForm(formId: string, formModel: FormDefinitionModel): Observable<any> {
|
||||
return Observable.fromPromise(
|
||||
return from(
|
||||
this.editorApi.saveForm(formId, formModel)
|
||||
);
|
||||
}
|
||||
@@ -175,7 +171,7 @@ export class FormService {
|
||||
*/
|
||||
addFieldsToAForm(formId: string, formModel: FormDefinitionModel): Observable<any> {
|
||||
this.logService.log('addFieldsToAForm is deprecated in 1.7.0, use saveForm API instead');
|
||||
return Observable.fromPromise(
|
||||
return from(
|
||||
this.editorApi.saveForm(formId, formModel)
|
||||
);
|
||||
}
|
||||
@@ -190,13 +186,15 @@ export class FormService {
|
||||
'modelType': 2
|
||||
};
|
||||
|
||||
return Observable.fromPromise(
|
||||
return from(
|
||||
this.modelsApi.getModels(opts)
|
||||
)
|
||||
.map(function (forms: any) {
|
||||
.pipe(
|
||||
map(function (forms: any) {
|
||||
return forms.data.find(formdata => formdata.name === name);
|
||||
})
|
||||
.catch(err => this.handleError(err));
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,9 +206,11 @@ export class FormService {
|
||||
'modelType': 2
|
||||
};
|
||||
|
||||
return Observable.fromPromise(this.modelsApi.getModels(opts))
|
||||
.map(this.toJsonArray)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.modelsApi.getModels(opts))
|
||||
.pipe(
|
||||
map(this.toJsonArray),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,9 +218,11 @@ export class FormService {
|
||||
* @returns List of process definitions
|
||||
*/
|
||||
getProcessDefinitions(): Observable<any> {
|
||||
return Observable.fromPromise(this.processApi.getProcessDefinitions({}))
|
||||
.map(this.toJsonArray)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.processApi.getProcessDefinitions({}))
|
||||
.pipe(
|
||||
map(this.toJsonArray),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,9 +231,11 @@ export class FormService {
|
||||
* @returns List of instance variable information
|
||||
*/
|
||||
getProcessVarablesById(processInstanceId: string): Observable<any[]> {
|
||||
return Observable.fromPromise(this.processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,9 +243,11 @@ export class FormService {
|
||||
* @returns List of tasks
|
||||
*/
|
||||
getTasks(): Observable<any> {
|
||||
return Observable.fromPromise(this.taskApi.listTasks({}))
|
||||
.map(this.toJsonArray)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.taskApi.listTasks({}))
|
||||
.pipe(
|
||||
map(this.toJsonArray),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,9 +256,11 @@ export class FormService {
|
||||
* @returns Task info
|
||||
*/
|
||||
getTask(taskId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.taskApi.getTask(taskId))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.taskApi.getTask(taskId))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,8 +272,10 @@ export class FormService {
|
||||
saveTaskForm(taskId: string, formValues: FormValues): Observable<any> {
|
||||
let body = JSON.stringify({values: formValues});
|
||||
|
||||
return Observable.fromPromise(this.taskApi.saveTaskForm(taskId, body))
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.taskApi.saveTaskForm(taskId, body))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,8 +292,10 @@ export class FormService {
|
||||
}
|
||||
let body = JSON.stringify(data);
|
||||
|
||||
return Observable.fromPromise(this.taskApi.completeTaskForm(taskId, body))
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.taskApi.completeTaskForm(taskId, body))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,9 +304,11 @@ export class FormService {
|
||||
* @returns Form definition
|
||||
*/
|
||||
getTaskForm(taskId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.taskApi.getTaskForm(taskId))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.taskApi.getTaskForm(taskId))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,9 +317,11 @@ export class FormService {
|
||||
* @returns Form definition
|
||||
*/
|
||||
getFormDefinitionById(formId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.editorApi.getForm(formId))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.editorApi.getForm(formId))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,9 +336,11 @@ export class FormService {
|
||||
'modelType': 2
|
||||
};
|
||||
|
||||
return Observable.fromPromise(this.modelsApi.getModels(opts))
|
||||
.map(this.getFormId)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.modelsApi.getModels(opts))
|
||||
.pipe(
|
||||
map(this.getFormId),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -331,10 +349,11 @@ export class FormService {
|
||||
* @returns Form definition
|
||||
*/
|
||||
getStartFormInstance(processId: string): Observable<any> {
|
||||
return Observable.fromPromise(
|
||||
this.processApi.getProcessInstanceStartForm(processId))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.processApi.getProcessInstanceStartForm(processId))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,9 +362,11 @@ export class FormService {
|
||||
* @returns Process instance
|
||||
*/
|
||||
getProcessIntance(processId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.processApi.getProcessInstance(processId))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.processApi.getProcessInstance(processId))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,10 +375,11 @@ export class FormService {
|
||||
* @returns Form definition
|
||||
*/
|
||||
getStartFormDefinition(processId: string): Observable<any> {
|
||||
return Observable.fromPromise(
|
||||
this.processApi.getProcessDefinitionStartForm(processId))
|
||||
.map(this.toJson)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.processApi.getProcessDefinitionStartForm(processId))
|
||||
.pipe(
|
||||
map(this.toJson),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,7 +389,10 @@ export class FormService {
|
||||
* @returns Field values
|
||||
*/
|
||||
getRestFieldValues(taskId: string, field: string): Observable<any> {
|
||||
return Observable.fromPromise(this.taskApi.getRestFieldValues(taskId, field)).catch(err => this.handleError(err));
|
||||
return from(this.taskApi.getRestFieldValues(taskId, field))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,7 +402,10 @@ export class FormService {
|
||||
* @returns Field values
|
||||
*/
|
||||
getRestFieldValuesByProcessId(processDefinitionId: string, field: string): Observable<any> {
|
||||
return Observable.fromPromise(this.processApi.getRestFieldValues(processDefinitionId, field)).catch(err => this.handleError(err));
|
||||
return from(this.processApi.getRestFieldValues(processDefinitionId, field))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,7 +416,10 @@ export class FormService {
|
||||
* @returns Field values
|
||||
*/
|
||||
getRestFieldValuesColumnByProcessId(processDefinitionId: string, field: string, column?: string): Observable<any> {
|
||||
return Observable.fromPromise(this.processApi.getRestTableFieldValues(processDefinitionId, field, column)).catch(err => this.handleError(err));
|
||||
return from(this.processApi.getRestTableFieldValues(processDefinitionId, field, column))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -399,7 +430,10 @@ export class FormService {
|
||||
* @returns Field values
|
||||
*/
|
||||
getRestFieldValuesColumn(taskId: string, field: string, column?: string): Observable<any> {
|
||||
return Observable.fromPromise(this.taskApi.getRestFieldValuesColumn(taskId, field, column)).catch(err => this.handleError(err));
|
||||
return from(this.taskApi.getRestFieldValuesColumn(taskId, field, column))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,15 +456,17 @@ export class FormService {
|
||||
if (groupId) {
|
||||
option.groupId = groupId;
|
||||
}
|
||||
return Observable.fromPromise(this.usersWorkflowApi.getUsers(option))
|
||||
.switchMap((response: any) => <UserProcessModel[]> response.data || [])
|
||||
.map((user: any) => {
|
||||
user.userImage = this.getUserProfileImageApi(user.id);
|
||||
return Observable.of(user);
|
||||
})
|
||||
.combineAll()
|
||||
.defaultIfEmpty([])
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.usersWorkflowApi.getUsers(option))
|
||||
.pipe(
|
||||
switchMap((response: any) => <UserProcessModel[]> response.data || []),
|
||||
map((user: any) => {
|
||||
user.userImage = this.getUserProfileImageApi(user.id);
|
||||
return of(user);
|
||||
}),
|
||||
combineAll(),
|
||||
defaultIfEmpty([]),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -444,9 +480,11 @@ export class FormService {
|
||||
if (groupId) {
|
||||
option.groupId = groupId;
|
||||
}
|
||||
return Observable.fromPromise(this.groupsApi.getGroups(option))
|
||||
.map((response: any) => <GroupModel[]> response.data || [])
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.groupsApi.getGroups(option))
|
||||
.pipe(
|
||||
map((response: any) => <GroupModel[]> response.data || []),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -500,6 +538,6 @@ export class FormService {
|
||||
error.status ? `${error.status} - ${error.statusText}` : FormService.GENERIC_ERROR_MESSAGE;
|
||||
}
|
||||
this.logService.error(errMsg);
|
||||
return Observable.throw(errMsg);
|
||||
return throwError(errMsg);
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,9 @@
|
||||
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from } from 'rxjs';
|
||||
import { NodeMetadata } from '../models/node-metadata.model';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class NodeService {
|
||||
@@ -31,7 +32,8 @@ export class NodeService {
|
||||
* @param nodeId Node Id
|
||||
*/
|
||||
public getNodeMetadata(nodeId: string): Observable<NodeMetadata> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().nodes.getNodeInfo(nodeId)).map(this.cleanMetadataFromSemicolon);
|
||||
return from(this.apiService.getInstance().nodes.getNodeInfo(nodeId))
|
||||
.pipe(map(this.cleanMetadataFromSemicolon));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +71,7 @@ export class NodeService {
|
||||
|
||||
// TODO: requires update to alfresco-js-api typings
|
||||
let apiService: any = this.apiService.getInstance();
|
||||
return Observable.fromPromise(apiService.nodes.addNode('-root-', body, {}));
|
||||
return from(apiService.nodes.addNode('-root-', body, {}));
|
||||
}
|
||||
|
||||
private generateUuid() {
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs';
|
||||
import { ProcessContentService } from './process-content.service';
|
||||
import { setupTestBed } from '../../testing/setupTestBed';
|
||||
import { CoreModule } from '../../core.module';
|
||||
@@ -188,7 +188,7 @@ describe('ProcessContentService', () => {
|
||||
it('should return a Blob as thumbnail', (done) => {
|
||||
let contentId: number = 999;
|
||||
let blob = createFakeBlob();
|
||||
spyOn(service, 'getContentThumbnail').and.returnValue(Observable.of(blob));
|
||||
spyOn(service, 'getContentThumbnail').and.returnValue(of(blob));
|
||||
service.getContentThumbnail(contentId).subscribe(result => {
|
||||
expect(result).toEqual(jasmine.any(Blob));
|
||||
expect(result.size).toEqual(48);
|
||||
|
@@ -19,10 +19,8 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { LogService } from '../../services/log.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RelatedContentRepresentation } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class ProcessContentService {
|
||||
@@ -44,7 +42,8 @@ export class ProcessContentService {
|
||||
* @returns The created content data
|
||||
*/
|
||||
createTemporaryRawRelatedContent(file: any): Observable<RelatedContentRepresentation> {
|
||||
return Observable.fromPromise(this.contentApi.createTemporaryRawRelatedContent(file)).catch(err => this.handleError(err));
|
||||
return from(this.contentApi.createTemporaryRawRelatedContent(file))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +52,8 @@ export class ProcessContentService {
|
||||
* @returns Metadata for the content
|
||||
*/
|
||||
getFileContent(contentId: number): Observable<RelatedContentRepresentation> {
|
||||
return Observable.fromPromise(this.contentApi.getContent(contentId)).catch(err => this.handleError(err));
|
||||
return from(this.contentApi.getContent(contentId))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,8 @@ export class ProcessContentService {
|
||||
* @returns Binary data of the related content
|
||||
*/
|
||||
getFileRawContent(contentId: number): Observable<Blob> {
|
||||
return Observable.fromPromise(this.contentApi.getRawContent(contentId)).catch(err => this.handleError(err));
|
||||
return from(this.contentApi.getRawContent(contentId))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +109,8 @@ export class ProcessContentService {
|
||||
* @returns Binary data of the thumbnail image
|
||||
*/
|
||||
getContentThumbnail(contentId: number): Observable<Blob> {
|
||||
return Observable.fromPromise(this.contentApi.getContentThumbnail(contentId)).catch(err => this.handleError(err));
|
||||
return from(this.contentApi.getContentThumbnail(contentId))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,8 +119,8 @@ export class ProcessContentService {
|
||||
* @returns Metadata for the content
|
||||
*/
|
||||
getTaskRelatedContent(taskId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.contentApi.getRelatedContentForTask(taskId))
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.contentApi.getRelatedContentForTask(taskId))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,8 +129,8 @@ export class ProcessContentService {
|
||||
* @returns Metadata for the content
|
||||
*/
|
||||
getProcessRelatedContent(processId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.contentApi.getRelatedContentForProcessInstance(processId))
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.contentApi.getRelatedContentForProcessInstance(processId))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,8 +139,8 @@ export class ProcessContentService {
|
||||
* @returns Null response that notifies when the deletion is complete
|
||||
*/
|
||||
deleteRelatedContent(contentId: number): Observable<any> {
|
||||
return Observable.fromPromise(this.contentApi.deleteContent(contentId))
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.contentApi.deleteContent(contentId))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,8 +151,8 @@ export class ProcessContentService {
|
||||
* @returns Details of created content
|
||||
*/
|
||||
createProcessRelatedContent(processInstanceId: string, content: any, opts?: any): Observable<any> {
|
||||
return Observable.fromPromise(this.contentApi.createRelatedContentOnProcessInstance(processInstanceId, content, opts))
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.contentApi.createRelatedContentOnProcessInstance(processInstanceId, content, opts))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,8 +163,8 @@ export class ProcessContentService {
|
||||
* @returns Details of created content
|
||||
*/
|
||||
createTaskRelatedContent(taskId: string, file: any, opts?: any) {
|
||||
return Observable.fromPromise(this.contentApi.createRelatedContentOnTask(taskId, file, opts))
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.contentApi.createRelatedContentOnTask(taskId, file, opts))
|
||||
.pipe(catchError(err => this.handleError(err)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +203,7 @@ export class ProcessContentService {
|
||||
error.status ? `${error.status} - ${error.statusText}` : ProcessContentService.GENERIC_ERROR_MESSAGE;
|
||||
}
|
||||
this.logService.error(errMsg);
|
||||
return Observable.throw(errMsg);
|
||||
return throwError(errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,11 +19,11 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { LogService } from '../../services/log.service';
|
||||
import { Injectable } from '@angular/core';
|
||||
import moment from 'moment-es6';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { FormFieldModel, FormModel, TabModel } from '../components/widgets/core/index';
|
||||
import { TaskProcessVariableModel } from '../models/task-process-variable.model';
|
||||
import { WidgetVisibilityModel } from '../models/widget-visibility.model';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class WidgetVisibilityService {
|
||||
@@ -244,13 +244,15 @@ export class WidgetVisibilityService {
|
||||
}
|
||||
|
||||
getTaskProcessVariable(taskId: string): Observable<TaskProcessVariableModel[]> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.taskFormsApi.getTaskFormVariables(taskId))
|
||||
.map(res => {
|
||||
let jsonRes = this.toJson(res);
|
||||
this.processVarList = <TaskProcessVariableModel[]> jsonRes;
|
||||
return jsonRes;
|
||||
})
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.taskFormsApi.getTaskFormVariables(taskId))
|
||||
.pipe(
|
||||
map(res => {
|
||||
let jsonRes = this.toJson(res);
|
||||
this.processVarList = <TaskProcessVariableModel[]> jsonRes;
|
||||
return jsonRes;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
toJson(res: any) {
|
||||
@@ -259,6 +261,6 @@ export class WidgetVisibilityService {
|
||||
|
||||
private handleError(err) {
|
||||
this.logService.error('Error while performing a call');
|
||||
return Observable.throw('Error while performing a call - Server error');
|
||||
return throwError('Error while performing a call - Server error');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user