mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +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
@@ -34,7 +34,7 @@ import {
|
||||
import * as alfrescoApi from 'alfresco-js-api';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { StorageService } from './storage.service';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { Subject } from 'rxjs';
|
||||
import { OauthConfigModel } from '../models/oauth-config.model';
|
||||
|
||||
/* tslint:disable:adf-file-name */
|
||||
|
@@ -17,11 +17,10 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppDefinitionRepresentation } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { LogService } from './log.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class AppsProcessService {
|
||||
@@ -35,11 +34,11 @@ export class AppsProcessService {
|
||||
* @returns The list of deployed apps
|
||||
*/
|
||||
getDeployedApplications(): Observable<AppDefinitionRepresentation[]> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
|
||||
.map((response: any) => {
|
||||
return response.data;
|
||||
})
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => <AppDefinitionRepresentation[]> response.data),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,11 +47,11 @@ export class AppsProcessService {
|
||||
* @returns The list of deployed apps
|
||||
*/
|
||||
getDeployedApplicationsByName(name: string): Observable<AppDefinitionRepresentation> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
|
||||
.map((response: any) => {
|
||||
return response.data.find(app => app.name === name);
|
||||
})
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => <AppDefinitionRepresentation> response.data.find(app => app.name === name)),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,16 +60,16 @@ export class AppsProcessService {
|
||||
* @returns Details of the app
|
||||
*/
|
||||
getApplicationDetailsById(appId: number): Observable<AppDefinitionRepresentation> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
|
||||
.map((response: any) => {
|
||||
return response.data.find(app => app.id === appId);
|
||||
})
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.appsApi.getAppDefinitions())
|
||||
.pipe(
|
||||
map((response: any) => response.data.find(app => app.id === appId)),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ import {
|
||||
CanActivateChild, RouterStateSnapshot, Router
|
||||
} from '@angular/router';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable } from 'rxjs';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { OauthConfigModel } from '../models/oauth-config.model';
|
||||
|
||||
@@ -32,12 +32,12 @@ export class AuthGuard implements CanActivate, CanActivateChild {
|
||||
private appConfig: AppConfigService) {
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable<boolean> {
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
|
||||
const redirectUrl = state.url;
|
||||
return this.checkLogin(redirectUrl);
|
||||
}
|
||||
|
||||
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean | Observable<boolean> {
|
||||
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.canActivate(route, state);
|
||||
}
|
||||
|
||||
|
@@ -16,17 +16,14 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { Observable, Subject, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { CookieService } from './cookie.service';
|
||||
import { LogService } from './log.service';
|
||||
import { RedirectionModel } from '../models/redirection.model';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { UserRepresentation } from 'alfresco-js-api';
|
||||
import { map, catchError, tap } from 'rxjs/operators';
|
||||
|
||||
const REMEMBER_ME_COOKIE_KEY = 'ALFRESCO_REMEMBER_ME';
|
||||
const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30 ;
|
||||
@@ -80,16 +77,18 @@ export class AuthenticationService {
|
||||
* @returns Object with auth type ("ECM", "BPM" or "ALL") and auth ticket
|
||||
*/
|
||||
login(username: string, password: string, rememberMe: boolean = false): Observable<{ type: string, ticket: any }> {
|
||||
return Observable.fromPromise(this.alfrescoApi.getInstance().login(username, password))
|
||||
.map((response: any) => {
|
||||
this.saveRememberMeCookie(rememberMe);
|
||||
this.onLogin.next(response);
|
||||
return {
|
||||
type: this.appConfig.get(AppConfigValues.PROVIDERS),
|
||||
ticket: response
|
||||
};
|
||||
})
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.alfrescoApi.getInstance().login(username, password))
|
||||
.pipe(
|
||||
map((response: any) => {
|
||||
this.saveRememberMeCookie(rememberMe);
|
||||
this.onLogin.next(response);
|
||||
return {
|
||||
type: this.appConfig.get(AppConfigValues.PROVIDERS),
|
||||
ticket: response
|
||||
};
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,12 +127,14 @@ export class AuthenticationService {
|
||||
* @returns Response event called when logout is complete
|
||||
*/
|
||||
logout() {
|
||||
return Observable.fromPromise(this.callApiLogout())
|
||||
.do(response => {
|
||||
this.onLogout.next(response);
|
||||
return response;
|
||||
})
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.callApiLogout())
|
||||
.pipe(
|
||||
tap(response => {
|
||||
this.onLogout.next(response);
|
||||
return response;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,7 +234,7 @@ export class AuthenticationService {
|
||||
}
|
||||
|
||||
getBpmLoggedUser(): Observable<UserRepresentation> {
|
||||
return Observable.fromPromise(this.alfrescoApi.getInstance().activiti.profileApi.getProfile());
|
||||
return from(this.alfrescoApi.getInstance().activiti.profileApi.getProfile());
|
||||
}
|
||||
|
||||
private hasValidRedirection(provider: string): boolean {
|
||||
@@ -251,6 +252,6 @@ export class AuthenticationService {
|
||||
*/
|
||||
handleError(error: any): Observable<any> {
|
||||
this.logService.error('Error when logging in', error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -16,13 +16,11 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { CommentModel } from '../models/comment.model';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { LogService } from '../services/log.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class CommentContentService {
|
||||
@@ -38,15 +36,18 @@ export class CommentContentService {
|
||||
* @returns Details of the comment added
|
||||
*/
|
||||
addNodeComment(nodeId: string, message: string): Observable<CommentModel> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.commentsApi.addComment(nodeId, {content: message}))
|
||||
.map((response: any) => {
|
||||
return new CommentModel({
|
||||
id: response.entry.id,
|
||||
message: response.entry.content,
|
||||
created: response.entry.createdAt,
|
||||
createdBy: response.entry.createdBy
|
||||
});
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().core.commentsApi.addComment(nodeId, {content: message}))
|
||||
.pipe(
|
||||
map((response: any) => {
|
||||
return new CommentModel({
|
||||
id: response.entry.id,
|
||||
message: response.entry.content,
|
||||
created: response.entry.createdAt,
|
||||
createdBy: response.entry.createdBy
|
||||
});
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,24 +56,27 @@ export class CommentContentService {
|
||||
* @returns Details for each comment
|
||||
*/
|
||||
getNodeComments(nodeId: string): Observable<CommentModel[]> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.commentsApi.getComments(nodeId))
|
||||
.map((response: any) => {
|
||||
const comments: CommentModel[] = [];
|
||||
response.list.entries.forEach((comment: any) => {
|
||||
comments.push(new CommentModel({
|
||||
id: comment.entry.id,
|
||||
message: comment.entry.content,
|
||||
created: comment.entry.createdAt,
|
||||
createdBy: comment.entry.createdBy
|
||||
}));
|
||||
});
|
||||
return comments;
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().core.commentsApi.getComments(nodeId))
|
||||
.pipe(
|
||||
map((response: any) => {
|
||||
const comments: CommentModel[] = [];
|
||||
response.list.entries.forEach((comment: any) => {
|
||||
comments.push(new CommentModel({
|
||||
id: comment.entry.id,
|
||||
message: comment.entry.content,
|
||||
created: comment.entry.createdAt,
|
||||
createdBy: comment.entry.createdBy
|
||||
}));
|
||||
});
|
||||
return comments;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,14 +16,12 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { CommentModel } from '../models/comment.model';
|
||||
import { UserProcessModel } from '../models/user-process.model';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { LogService } from './log.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class CommentProcessService {
|
||||
@@ -39,17 +37,18 @@ export class CommentProcessService {
|
||||
* @returns Details about the comment
|
||||
*/
|
||||
addTaskComment(taskId: string, message: string): Observable<CommentModel> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.addTaskComment({message: message}, taskId))
|
||||
.map(res => res)
|
||||
.map((response: CommentModel) => {
|
||||
return new CommentModel({
|
||||
id: response.id,
|
||||
message: response.message,
|
||||
created: response.created,
|
||||
createdBy: response.createdBy
|
||||
});
|
||||
}).catch(err => this.handleError(err));
|
||||
|
||||
return from(this.apiService.getInstance().activiti.taskApi.addTaskComment({message: message}, taskId))
|
||||
.pipe(
|
||||
map((response: CommentModel) => {
|
||||
return new CommentModel({
|
||||
id: response.id,
|
||||
message: response.message,
|
||||
created: response.created,
|
||||
createdBy: response.createdBy
|
||||
});
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,16 +57,18 @@ export class CommentProcessService {
|
||||
* @returns Details for each comment
|
||||
*/
|
||||
getTaskComments(taskId: string): Observable<CommentModel[]> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.taskApi.getTaskComments(taskId))
|
||||
.map(res => res)
|
||||
.map((response: any) => {
|
||||
let comments: CommentModel[] = [];
|
||||
response.data.forEach((comment: CommentModel) => {
|
||||
let user = new UserProcessModel(comment.createdBy);
|
||||
comments.push(new CommentModel({id: comment.id, message: comment.message, created: comment.created, createdBy: user}));
|
||||
});
|
||||
return comments;
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.taskApi.getTaskComments(taskId))
|
||||
.pipe(
|
||||
map((response: any) => {
|
||||
let comments: CommentModel[] = [];
|
||||
response.data.forEach((comment: CommentModel) => {
|
||||
let user = new UserProcessModel(comment.createdBy);
|
||||
comments.push(new CommentModel({id: comment.id, message: comment.message, created: comment.created, createdBy: user}));
|
||||
});
|
||||
return comments;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,16 +77,18 @@ export class CommentProcessService {
|
||||
* @returns Details for each comment
|
||||
*/
|
||||
getProcessInstanceComments(processInstanceId: string): Observable<CommentModel[]> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().activiti.commentsApi.getProcessInstanceComments(processInstanceId))
|
||||
.map(res => res)
|
||||
.map((response: any) => {
|
||||
let comments: CommentModel[] = [];
|
||||
response.data.forEach((comment: CommentModel) => {
|
||||
let user = new UserProcessModel(comment.createdBy);
|
||||
comments.push(new CommentModel({id: comment.id, message: comment.message, created: comment.created, createdBy: user}));
|
||||
});
|
||||
return comments;
|
||||
}).catch(err => this.handleError(err));
|
||||
return from(this.apiService.getInstance().activiti.commentsApi.getProcessInstanceComments(processInstanceId))
|
||||
.pipe(
|
||||
map((response: any) => {
|
||||
let comments: CommentModel[] = [];
|
||||
response.data.forEach((comment: CommentModel) => {
|
||||
let user = new UserProcessModel(comment.createdBy);
|
||||
comments.push(new CommentModel({id: comment.id, message: comment.message, created: comment.created, createdBy: user}));
|
||||
});
|
||||
return comments;
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,23 +98,24 @@ export class CommentProcessService {
|
||||
* @returns Details of the comment added
|
||||
*/
|
||||
addProcessInstanceComment(processInstanceId: string, message: string): Observable<CommentModel> {
|
||||
return Observable.fromPromise(
|
||||
return from(
|
||||
this.apiService.getInstance().activiti.commentsApi.addProcessInstanceComment({message: message}, processInstanceId)
|
||||
)
|
||||
.map((response: CommentModel) => {
|
||||
).pipe(
|
||||
map((response: CommentModel) => {
|
||||
return new CommentModel({
|
||||
id: response.id,
|
||||
message: response.message,
|
||||
created: response.created,
|
||||
createdBy: response.createdBy
|
||||
});
|
||||
}).catch(err => this.handleError(err));
|
||||
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -18,17 +18,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { ContentApi, MinimalNodeEntryEntity, Node, NodeEntry } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { Observable, Subject, from, throwError } from 'rxjs';
|
||||
import { FolderCreatedEvent } from '../events/folder-created.event';
|
||||
import { PermissionsEnum } from '../models/permissions.enum';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { LogService } from './log.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/operator/do';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { catchError, tap } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class ContentService {
|
||||
@@ -157,9 +153,10 @@ export class ContentService {
|
||||
* @returns Content data
|
||||
*/
|
||||
getNodeContent(nodeId: string): Observable<any> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.nodesApi.getFileContent(nodeId).then((dataContent) => {
|
||||
return dataContent;
|
||||
})).catch(this.handleError);
|
||||
return from(this.apiService.getInstance().core.nodesApi.getFileContent(nodeId))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,17 +166,19 @@ export class ContentService {
|
||||
* @param parentId Node ID of parent folder
|
||||
* @returns Information about the new folder
|
||||
*/
|
||||
createFolder(relativePath: string, name: string, parentId?: string): Observable<FolderCreatedEvent> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().nodes.createFolder(name, relativePath, parentId))
|
||||
.do(data => {
|
||||
this.folderCreated.next(<FolderCreatedEvent> {
|
||||
relativePath: relativePath,
|
||||
name: name,
|
||||
parentId: parentId,
|
||||
node: data
|
||||
});
|
||||
})
|
||||
.catch(err => this.handleError(err));
|
||||
createFolder(relativePath: string, name: string, parentId?: string): Observable<NodeEntry> {
|
||||
return from(this.apiService.getInstance().nodes.createFolder(name, relativePath, parentId))
|
||||
.pipe(
|
||||
tap(data => {
|
||||
this.folderCreated.next(<FolderCreatedEvent> {
|
||||
relativePath: relativePath,
|
||||
name: name,
|
||||
parentId: parentId,
|
||||
node: data
|
||||
});
|
||||
}),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +188,7 @@ export class ContentService {
|
||||
* @returns Details of the folder
|
||||
*/
|
||||
getNode(nodeId: string, opts?: any): Observable<NodeEntry> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().nodes.getNode(nodeId, opts));
|
||||
return from(this.apiService.getInstance().nodes.getNode(nodeId, opts));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,6 +239,6 @@ export class ContentService {
|
||||
|
||||
private handleError(error: any) {
|
||||
this.logService.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -16,11 +16,12 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, of } from 'rxjs';
|
||||
|
||||
import { NodePaging } from 'alfresco-js-api';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class DeletedNodesApiService {
|
||||
@@ -39,21 +40,16 @@ export class DeletedNodesApiService {
|
||||
* @returns List of nodes in the trash
|
||||
*/
|
||||
getDeletedNodes(options?: Object): Observable<NodePaging> {
|
||||
const { nodesApi, handleError } = this;
|
||||
const defaultOptions = {
|
||||
include: [ 'path', 'properties' ],
|
||||
maxItems: this.preferences.paginationSize,
|
||||
skipCount: 0
|
||||
};
|
||||
const queryOptions = Object.assign(defaultOptions, options);
|
||||
const promise = nodesApi.getDeletedNodes(queryOptions);
|
||||
const promise = this.nodesApi.getDeletedNodes(queryOptions);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
}
|
||||
|
||||
private handleError(error: any): Observable<any> {
|
||||
return Observable.of(error);
|
||||
return from(promise).pipe(
|
||||
catchError(err => of(err))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -16,12 +16,11 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { from, throwError } from 'rxjs';
|
||||
import { BpmProductVersionModel, EcmProductVersionModel } from '../models/product-version.model';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/index';
|
||||
|
||||
@Injectable()
|
||||
export class DiscoveryApiService {
|
||||
@@ -32,25 +31,23 @@ export class DiscoveryApiService {
|
||||
* Gets product information for Content Services.
|
||||
* @returns ProductVersionModel containing product details
|
||||
*/
|
||||
public getEcmProductInfo() {
|
||||
return Observable.fromPromise(
|
||||
this.apiService.getInstance().discovery.discoveryApi.getRepositoryInformation())
|
||||
.map(res => new EcmProductVersionModel(res))
|
||||
.catch(this.handleError);
|
||||
public getEcmProductInfo(): Observable<EcmProductVersionModel> {
|
||||
return from(this.apiService.getInstance().discovery.discoveryApi.getRepositoryInformation())
|
||||
.pipe(
|
||||
map(res => new EcmProductVersionModel(res)),
|
||||
catchError(err => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets product information for Process Services.
|
||||
* @returns ProductVersionModel containing product details
|
||||
*/
|
||||
public getBpmProductInfo() {
|
||||
return Observable.fromPromise(
|
||||
this.apiService.getInstance().activiti.aboutApi.getAppVersion())
|
||||
.map(res => new BpmProductVersionModel(res))
|
||||
.catch(this.handleError);
|
||||
}
|
||||
|
||||
private handleError(error): Observable<any> {
|
||||
return Observable.throw(error);
|
||||
public getBpmProductInfo(): Observable<BpmProductVersionModel> {
|
||||
return from(this.apiService.getInstance().activiti.aboutApi.getAppVersion())
|
||||
.pipe(
|
||||
map(res => new BpmProductVersionModel(res)),
|
||||
catchError(err => throwError(err))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,10 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NodePaging } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, of } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class FavoritesApiService {
|
||||
@@ -69,7 +70,6 @@ export class FavoritesApiService {
|
||||
* @returns List of favorites
|
||||
*/
|
||||
getFavorites(personId: string, options?: any): Observable<NodePaging> {
|
||||
const { favoritesApi, handleError } = this;
|
||||
const defaultOptions = {
|
||||
maxItems: this.preferences.paginationSize,
|
||||
skipCount: 0,
|
||||
@@ -77,16 +77,12 @@ export class FavoritesApiService {
|
||||
include: [ 'properties', 'allowableOperations' ]
|
||||
};
|
||||
const queryOptions = Object.assign(defaultOptions, options);
|
||||
const promise = favoritesApi
|
||||
const promise = this.favoritesApi
|
||||
.getFavorites(personId, queryOptions)
|
||||
.then(this.remapFavoritesData);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
}
|
||||
|
||||
private handleError(error): Observable<any> {
|
||||
return Observable.of(error);
|
||||
return from(promise).pipe(
|
||||
catchError(err => of(err))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
|
||||
import { logLevels, LogLevelsEnum } from '../models/log-levels.model';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class LogService {
|
||||
|
@@ -17,11 +17,10 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class NodesApiService {
|
||||
@@ -45,18 +44,17 @@ export class NodesApiService {
|
||||
* @returns Node information
|
||||
*/
|
||||
getNode(nodeId: string, options: any = {}): Observable<MinimalNodeEntryEntity> {
|
||||
const { nodesApi, handleError, getEntryFromEntity } = this;
|
||||
const defaults = {
|
||||
include: [ 'path', 'properties', 'allowableOperations', 'permissions' ]
|
||||
};
|
||||
const queryOptions = Object.assign(defaults, options);
|
||||
const promise = nodesApi
|
||||
const promise = this.nodesApi
|
||||
.getNode(nodeId, queryOptions)
|
||||
.then(getEntryFromEntity);
|
||||
.then(this.getEntryFromEntity);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
return from(promise).pipe(
|
||||
catchError(err => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,19 +64,18 @@ export class NodesApiService {
|
||||
* @returns List of child items from the folder
|
||||
*/
|
||||
getNodeChildren(nodeId: string, options: any = {}): Observable<NodePaging> {
|
||||
const { nodesApi, handleError } = this;
|
||||
const defaults = {
|
||||
maxItems: this.preferences.paginationSize,
|
||||
skipCount: 0,
|
||||
include: [ 'path', 'properties', 'allowableOperations', 'permissions' ]
|
||||
};
|
||||
const queryOptions = Object.assign(defaults, options);
|
||||
const promise = nodesApi
|
||||
const promise = this.nodesApi
|
||||
.getNodeChildren(nodeId, queryOptions);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
return from(promise).pipe(
|
||||
catchError(err => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,12 +86,13 @@ export class NodesApiService {
|
||||
* @returns Details of the new node
|
||||
*/
|
||||
createNode(parentNodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNodeEntryEntity> {
|
||||
const { nodesApi, handleError, getEntryFromEntity } = this;
|
||||
const promise = nodesApi
|
||||
const promise = this.nodesApi
|
||||
.addNode(parentNodeId, nodeBody, options)
|
||||
.then(getEntryFromEntity);
|
||||
.then(this.getEntryFromEntity);
|
||||
|
||||
return Observable.fromPromise(promise).catch(handleError);
|
||||
return from(promise).pipe(
|
||||
catchError(err => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,18 +115,18 @@ export class NodesApiService {
|
||||
* @returns Updated node information
|
||||
*/
|
||||
updateNode(nodeId: string, nodeBody: any, options: any = {}): Observable<MinimalNodeEntryEntity> {
|
||||
const { nodesApi, handleError, getEntryFromEntity } = this;
|
||||
|
||||
const defaults = {
|
||||
include: [ 'path', 'properties', 'allowableOperations', 'permissions' ]
|
||||
};
|
||||
const queryOptions = Object.assign(defaults, options);
|
||||
|
||||
const promise = nodesApi
|
||||
const promise = this.nodesApi
|
||||
.updateNode(nodeId, nodeBody, queryOptions)
|
||||
.then(getEntryFromEntity);
|
||||
.then(this.getEntryFromEntity);
|
||||
|
||||
return Observable.fromPromise(promise).catch(handleError);
|
||||
return from(promise).pipe(
|
||||
catchError(err => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,14 +135,12 @@ export class NodesApiService {
|
||||
* @param options Optional parameters supported by JSAPI
|
||||
* @returns Empty result that notifies when the deletion is complete
|
||||
*/
|
||||
deleteNode(nodeId: string, options: any = {}): Observable<void> {
|
||||
const { nodesApi, handleError } = this;
|
||||
const promise = nodesApi
|
||||
.deleteNode(nodeId, options);
|
||||
deleteNode(nodeId: string, options: any = {}): Observable<any> {
|
||||
const promise = this.nodesApi.deleteNode(nodeId, options);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
return from(promise).pipe(
|
||||
catchError(err => throwError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,22 +149,12 @@ export class NodesApiService {
|
||||
* @returns Details of the restored node
|
||||
*/
|
||||
restoreNode(nodeId: string): Observable<MinimalNodeEntryEntity> {
|
||||
const { nodesApi, handleError, getEntryFromEntity } = this;
|
||||
const promise = nodesApi
|
||||
const promise = this.nodesApi
|
||||
.restoreNode(nodeId)
|
||||
.then(getEntryFromEntity);
|
||||
.then(this.getEntryFromEntity);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports an error.
|
||||
* @param error Object representing the error
|
||||
* @returns Error information
|
||||
*/
|
||||
handleError(error: any): Observable<any> {
|
||||
return Observable.throw(error);
|
||||
return from(promise).pipe(
|
||||
catchError(err => throwError(err))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ class ProvidesNotificationServiceComponent {
|
||||
}
|
||||
|
||||
sendMessageWithoutConfig() {
|
||||
let promise = this.notificationService.openSnackMessage('Test notification');
|
||||
let promise = this.notificationService.openSnackMessage('Test notification', 1000);
|
||||
return promise;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class ProvidesNotificationServiceComponent {
|
||||
}
|
||||
|
||||
sendMessageActionWithoutConfig() {
|
||||
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn');
|
||||
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
|
||||
return promise;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class ProvidesNotificationServiceComponent {
|
||||
}
|
||||
|
||||
sendCustomMessageAction() {
|
||||
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', new MatSnackBarConfig());
|
||||
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', new MatSnackBarConfig());
|
||||
return promise;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ describe('NotificationService', () => {
|
||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should open a message notification bar without custom configuration', (done) => {
|
||||
it('should open a message notification bar without custom configuration', (done) => {
|
||||
let promise = fixture.componentInstance.sendMessageWithoutConfig();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
done();
|
||||
@@ -163,7 +163,7 @@ describe('NotificationService', () => {
|
||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||
}));
|
||||
|
||||
it('should open a message notification bar with action and no custom configuration', (done) => {
|
||||
it('should open a message notification bar with action and no custom configuration', (done) => {
|
||||
let promise = fixture.componentInstance.sendMessageActionWithoutConfig();
|
||||
promise.afterDismissed().subscribe(() => {
|
||||
done();
|
||||
|
@@ -97,18 +97,5 @@ describe('PeopleAPI', () => {
|
||||
.toBe('-me-');
|
||||
});
|
||||
}));
|
||||
|
||||
it('handles the error when it fails', async(() => {
|
||||
const test = new PeopleContentServiceTest({
|
||||
rejectGetPerson: true
|
||||
});
|
||||
|
||||
const handleErrorSpy = spyOn(test.service, 'handleError')
|
||||
.and.callThrough();
|
||||
|
||||
test.service.getPerson().subscribe(() => {
|
||||
expect(handleErrorSpy).toHaveBeenCalled();
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@@ -16,9 +16,9 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, of } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class PeopleContentService {
|
||||
@@ -35,12 +35,11 @@ export class PeopleContentService {
|
||||
* @returns User information
|
||||
*/
|
||||
getPerson(personId: string): Observable<any> {
|
||||
const { peopleApi, handleError } = this;
|
||||
const promise = peopleApi.getPerson(personId);
|
||||
const promise = this.peopleApi.getPerson(personId);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
return from(promise).pipe(
|
||||
catchError(err => of(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,8 +49,4 @@ export class PeopleContentService {
|
||||
getCurrentPerson(): Observable<any> {
|
||||
return this.getPerson('-me-');
|
||||
}
|
||||
|
||||
private handleError(error): Observable<any> {
|
||||
return Observable.of(error);
|
||||
}
|
||||
}
|
||||
|
@@ -17,12 +17,11 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { UserProcessModel } from '../models/user-process.model';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { LogService } from './log.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class PeopleProcessService {
|
||||
@@ -39,9 +38,11 @@ export class PeopleProcessService {
|
||||
*/
|
||||
getWorkflowUsers(taskId?: string, searchWord?: string): Observable<UserProcessModel[]> {
|
||||
let option = { excludeTaskId: taskId, filter: searchWord };
|
||||
return Observable.fromPromise(this.getWorkflowUserApi(option))
|
||||
.map((response: any) => <UserProcessModel[]> response.data || [])
|
||||
.catch(err => this.handleError(err));
|
||||
return from(this.getWorkflowUserApi(option))
|
||||
.pipe(
|
||||
map((response: any) => <UserProcessModel[]> response.data || []),
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +62,10 @@ export class PeopleProcessService {
|
||||
*/
|
||||
involveUserWithTask(taskId: string, idToInvolve: string): Observable<UserProcessModel[]> {
|
||||
let node = {userId: idToInvolve};
|
||||
return Observable.fromPromise(this.involveUserToTaskApi(taskId, node))
|
||||
.catch(err => this.handleError(err));
|
||||
return from<UserProcessModel[]>(this.involveUserToTaskApi(taskId, node))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,8 +76,10 @@ export class PeopleProcessService {
|
||||
*/
|
||||
removeInvolvedUser(taskId: string, idToRemove: string): Observable<UserProcessModel[]> {
|
||||
let node = {userId: idToRemove};
|
||||
return Observable.fromPromise(this.removeInvolvedUserFromTaskApi(taskId, node))
|
||||
.catch(err => this.handleError(err));
|
||||
return from<UserProcessModel[]>(this.removeInvolvedUserFromTaskApi(taskId, node))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private getWorkflowUserApi(options: any) {
|
||||
@@ -99,6 +104,6 @@ export class PeopleProcessService {
|
||||
*/
|
||||
private handleError(error: Response) {
|
||||
this.logService.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -17,13 +17,9 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { RenditionEntry, RenditionPaging } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, interval } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/concatMap';
|
||||
import 'rxjs/add/operator/combineAll';
|
||||
import 'rxjs/add/observable/interval';
|
||||
import 'rxjs/add/operator/takeWhile';
|
||||
import { concatMap, switchMap, takeWhile } from 'rxjs/operators';
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
@@ -79,36 +75,40 @@ export class RenditionsService {
|
||||
|
||||
/** @deprecated */
|
||||
getRendition(nodeId: string, encoding: string): Observable<RenditionEntry> {
|
||||
return Observable.fromPromise(this.apiService.renditionsApi.getRendition(nodeId, encoding));
|
||||
return from(this.apiService.renditionsApi.getRendition(nodeId, encoding));
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
getRenditionsListByNodeId(nodeId: string): Observable<RenditionPaging> {
|
||||
return Observable.fromPromise(this.apiService.renditionsApi.getRenditions(nodeId));
|
||||
return from(this.apiService.renditionsApi.getRenditions(nodeId));
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
createRendition(nodeId: string, encoding: string): Observable<{}> {
|
||||
return Observable.fromPromise(this.apiService.renditionsApi.createRendition(nodeId, {id: encoding}));
|
||||
return from(this.apiService.renditionsApi.createRendition(nodeId, {id: encoding}));
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
convert(nodeId: string, encoding: string, pollingInterval: number = 1000, retries: number = 5) {
|
||||
return this.createRendition(nodeId, encoding)
|
||||
.concatMap(() => this.pollRendition(nodeId, encoding, pollingInterval, retries));
|
||||
.pipe(
|
||||
concatMap(() => this.pollRendition(nodeId, encoding, pollingInterval, retries))
|
||||
);
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
private pollRendition(nodeId: string, encoding: string, interval: number = 1000, retries: number = 5) {
|
||||
private pollRendition(nodeId: string, encoding: string, intervalSize: number = 1000, retries: number = 5) {
|
||||
let attempts = 0;
|
||||
return Observable.interval(interval)
|
||||
.switchMap(() => this.getRendition(nodeId, encoding))
|
||||
.takeWhile((data) => {
|
||||
attempts += 1;
|
||||
if (attempts > retries) {
|
||||
return false;
|
||||
}
|
||||
return (data.entry.status.toString() !== 'CREATED');
|
||||
});
|
||||
return interval(intervalSize)
|
||||
.pipe(
|
||||
switchMap(() => this.getRendition(nodeId, encoding)),
|
||||
takeWhile((data) => {
|
||||
attempts += 1;
|
||||
if (attempts > retries) {
|
||||
return false;
|
||||
}
|
||||
return (data.entry.status.toString() !== 'CREATED');
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -17,11 +17,10 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NodePaging, QueryBody } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, Subject, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import 'rxjs/add/observable/throw';
|
||||
import { SearchConfigurationService } from './search-configuration.service';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class SearchService {
|
||||
@@ -39,9 +38,9 @@ export class SearchService {
|
||||
this.dataLoaded.next(data);
|
||||
});
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(promise).pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
search(searchTerm: string, maxResults: number, skipCount: number): Observable<NodePaging> {
|
||||
@@ -52,9 +51,9 @@ export class SearchService {
|
||||
this.dataLoaded.next(data);
|
||||
});
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(promise).pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
searchByQueryBody(queryBody: QueryBody): Observable<NodePaging> {
|
||||
@@ -64,13 +63,13 @@ export class SearchService {
|
||||
this.dataLoaded.next(data);
|
||||
});
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(err => this.handleError(err));
|
||||
return from(promise).pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
private handleError(error: any): Observable<any> {
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -17,10 +17,10 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { NodePaging, SharedLinkEntry } from 'alfresco-js-api';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, of } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class SharedLinksApiService {
|
||||
@@ -39,19 +39,17 @@ export class SharedLinksApiService {
|
||||
* @returns List of shared links
|
||||
*/
|
||||
getSharedLinks(options: any = {}): Observable<NodePaging> {
|
||||
const { sharedLinksApi, handleError } = this;
|
||||
const defaultOptions = {
|
||||
maxItems: this.preferences.paginationSize,
|
||||
skipCount: 0,
|
||||
include: ['properties', 'allowableOperations']
|
||||
};
|
||||
const queryOptions = Object.assign({}, defaultOptions, options);
|
||||
const promise = sharedLinksApi
|
||||
.findSharedLinks(queryOptions);
|
||||
const promise = this.sharedLinksApi.findSharedLinks(queryOptions);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
return from(promise).pipe(
|
||||
catchError(err => of(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,13 +59,11 @@ export class SharedLinksApiService {
|
||||
* @returns The shared link just created
|
||||
*/
|
||||
createSharedLinks(nodeId: string, options: any = {}): Observable<SharedLinkEntry> {
|
||||
const { sharedLinksApi, handleError } = this;
|
||||
const promise = this.sharedLinksApi.addSharedLink({ nodeId: nodeId });
|
||||
|
||||
const promise = sharedLinksApi.addSharedLink({ nodeId: nodeId });
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
return from(promise).pipe(
|
||||
catchError(err => of(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,16 +72,10 @@ export class SharedLinksApiService {
|
||||
* @returns Null response notifying when the operation is complete
|
||||
*/
|
||||
deleteSharedLink(sharedId: string): Observable<SharedLinkEntry> {
|
||||
const { sharedLinksApi, handleError } = this;
|
||||
const promise = this.sharedLinksApi.deleteSharedLink(sharedId);
|
||||
|
||||
const promise = sharedLinksApi.deleteSharedLink(sharedId);
|
||||
|
||||
return Observable
|
||||
.fromPromise(promise)
|
||||
.catch(handleError);
|
||||
}
|
||||
|
||||
private handleError(error: any): Observable<any> {
|
||||
return Observable.of(error);
|
||||
return from(promise).pipe(
|
||||
catchError(err => of(err))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -17,11 +17,10 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, from, throwError } from 'rxjs';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
import 'rxjs/add/observable/fromPromise';
|
||||
import 'rxjs/add/operator/catch';
|
||||
import { SitePaging, SiteEntry } from 'alfresco-js-api';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@Injectable()
|
||||
export class SitesService {
|
||||
@@ -40,8 +39,10 @@ export class SitesService {
|
||||
include: ['properties']
|
||||
};
|
||||
const queryOptions = Object.assign({}, defaultOptions, opts);
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.sitesApi.getSites(queryOptions))
|
||||
.catch(this.handleError);
|
||||
return from(this.apiService.getInstance().core.sitesApi.getSites(queryOptions))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,8 +52,10 @@ export class SitesService {
|
||||
* @returns Information about the site
|
||||
*/
|
||||
getSite(siteId: string, opts?: any): Observable<SiteEntry> {
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.sitesApi.getSite(siteId, opts))
|
||||
.catch(this.handleError);
|
||||
return from(this.apiService.getInstance().core.sitesApi.getSite(siteId, opts))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,8 +67,10 @@ export class SitesService {
|
||||
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
|
||||
let options: any = {};
|
||||
options.permanent = permanentFlag;
|
||||
return Observable.fromPromise(this.apiService.getInstance().core.sitesApi.deleteSite(siteId, options)
|
||||
.catch(this.handleError));
|
||||
return from(this.apiService.getInstance().core.sitesApi.deleteSite(siteId, options))
|
||||
.pipe(
|
||||
catchError(err => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,6 +101,6 @@ export class SitesService {
|
||||
|
||||
private handleError(error: Response): any {
|
||||
console.error(error);
|
||||
return Observable.throw(error || 'Server error');
|
||||
return throwError(error || 'Server error');
|
||||
}
|
||||
}
|
||||
|
@@ -19,13 +19,11 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Response } from '@angular/http';
|
||||
import { TranslateLoader } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, forkJoin } from 'rxjs';
|
||||
import { ComponentTranslationModel } from '../models/component.model';
|
||||
import { ObjectUtils } from '../utils/object-utils';
|
||||
import { LogService } from './log.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import 'rxjs/observable/forkJoin';
|
||||
import 'rxjs/add/observable/forkJoin';
|
||||
|
||||
@Injectable()
|
||||
export class TranslateLoaderService implements TranslateLoader {
|
||||
@@ -120,7 +118,7 @@ export class TranslateLoaderService implements TranslateLoader {
|
||||
|
||||
return Observable.create(observer => {
|
||||
if (observableBatch.length > 0) {
|
||||
Observable.forkJoin(observableBatch).subscribe(
|
||||
forkJoin(observableBatch).subscribe(
|
||||
() => {
|
||||
let fullTranslation = this.getFullTranslationJSON(lang);
|
||||
if (fullTranslation) {
|
||||
|
@@ -17,17 +17,9 @@
|
||||
|
||||
import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable } from 'rxjs';
|
||||
import { TranslateLoaderService } from './translate-loader.service';
|
||||
import { UserPreferencesService } from './user-preferences.service';
|
||||
import 'rxjs/add/observable/of';
|
||||
import 'rxjs/add/operator/concat';
|
||||
import 'rxjs/add/operator/share';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/merge';
|
||||
import 'rxjs/add/operator/switchMap';
|
||||
import 'rxjs/add/operator/toArray';
|
||||
import 'rxjs/add/operator/take';
|
||||
|
||||
export const TRANSLATION_PROVIDER = new InjectionToken('Injection token for translation providers.');
|
||||
|
||||
|
@@ -16,8 +16,8 @@
|
||||
*/
|
||||
|
||||
import { EventEmitter, Injectable } from '@angular/core';
|
||||
import * as minimatch_ from 'minimatch';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { Minimatch } from 'minimatch-browser';
|
||||
import { Subject } from 'rxjs';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import {
|
||||
FileUploadCompleteEvent,
|
||||
@@ -28,8 +28,6 @@ import {
|
||||
import { FileModel, FileUploadProgress, FileUploadStatus } from '../models/file.model';
|
||||
import { AlfrescoApiService } from './alfresco-api.service';
|
||||
|
||||
let minimatch: any = (<any> minimatch_).default || minimatch_;
|
||||
|
||||
@Injectable()
|
||||
export class UploadService {
|
||||
|
||||
@@ -37,7 +35,7 @@ export class UploadService {
|
||||
private totalComplete: number = 0;
|
||||
private totalAborted: number = 0;
|
||||
private totalError: number = 0;
|
||||
private excludedFileList: String[] = [];
|
||||
private excludedFileList: string[] = [];
|
||||
private matchingOptions: any = null;
|
||||
|
||||
activeTask: Promise<any> = null;
|
||||
@@ -56,7 +54,7 @@ export class UploadService {
|
||||
|
||||
constructor(protected apiService: AlfrescoApiService,
|
||||
appConfigService: AppConfigService) {
|
||||
this.excludedFileList = <String[]> appConfigService.get('files.excluded');
|
||||
this.excludedFileList = <string[]> appConfigService.get('files.excluded');
|
||||
this.matchingOptions = appConfigService.get('files.match-options');
|
||||
}
|
||||
|
||||
@@ -92,7 +90,11 @@ export class UploadService {
|
||||
let isAllowed = true;
|
||||
|
||||
if (this.excludedFileList) {
|
||||
isAllowed = this.excludedFileList.filter(expr => minimatch(file.name, expr, this.matchingOptions)).length === 0;
|
||||
|
||||
isAllowed = this.excludedFileList.filter((pattern) => {
|
||||
let minimatch = new Minimatch(pattern, this.matchingOptions);
|
||||
return minimatch.match(file.name);
|
||||
}).length === 0;
|
||||
}
|
||||
return isAllowed;
|
||||
}
|
||||
|
@@ -17,11 +17,10 @@
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, BehaviorSubject } from 'rxjs';
|
||||
import { AppConfigService } from '../app-config/app-config.service';
|
||||
import { StorageService } from './storage.service';
|
||||
import 'rxjs/add/operator/distinctUntilChanged';
|
||||
import { distinctUntilChanged, map } from 'rxjs/operators';
|
||||
|
||||
export enum UserPreferenceValues {
|
||||
PaginationSize = 'PAGINATION_SIZE',
|
||||
@@ -71,7 +70,11 @@ export class UserPreferencesService {
|
||||
* @returns Notification callback
|
||||
*/
|
||||
select(property: string): Observable<any> {
|
||||
return this.onChange.map((userPreferenceStatus) => userPreferenceStatus[property]).distinctUntilChanged();
|
||||
return this.onChange
|
||||
.pipe(
|
||||
map((userPreferenceStatus) => userPreferenceStatus[property]),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user