enable prefer-const rule for tslint, fix issues (#4409)

* enable prefer-const rule for tslint, fix issues

* Update content-node-selector.component.spec.ts

* Update content-node-selector.component.spec.ts

* fix const

* fix lint issues

* update tests

* update tests

* update tests

* fix code

* fix page class
This commit is contained in:
Denys Vuika
2019-03-25 12:19:33 +00:00
committed by Eugenio Romano
parent 26c5982a1a
commit a7a48e8b2b
581 changed files with 5435 additions and 5402 deletions

View File

@@ -111,7 +111,7 @@ export class AlfrescoApiService {
}
protected initAlfrescoApi() {
let oauth: OauthConfigModel = Object.assign({}, this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null));
const oauth: OauthConfigModel = Object.assign({}, this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null));
if (oauth) {
oauth.redirectUri = window.location.origin + (oauth.redirectUri || '/');
oauth.redirectUriLogout = window.location.origin + (oauth.redirectUriLogout || '/');

View File

@@ -29,7 +29,7 @@ export class AuthGuardSsoRoleService implements CanActivate {
let hasRole = false;
if (route.data) {
let rolesToCheck = route.data['roles'];
const rolesToCheck = route.data['roles'];
hasRole = this.hasRoles(rolesToCheck);
}

View File

@@ -85,7 +85,7 @@ describe('AuthenticationService', () => {
});
it('[ECM] should return an ECM ticket after the login done', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
expect(authService.isLoggedIn()).toBe(true);
expect(authService.getTicketEcm()).toEqual('fake-post-ticket');
expect(authService.isEcmLoggedIn()).toBe(true);
@@ -101,7 +101,7 @@ describe('AuthenticationService', () => {
});
it('[ECM] should login in the ECM if no provider are defined calling the login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
disposableLogin.unsubscribe();
done();
});
@@ -114,8 +114,8 @@ describe('AuthenticationService', () => {
});
it('[ECM] should return a ticket undefined after logout', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
let disposableLogout = authService.logout().subscribe(() => {
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
const disposableLogout = authService.logout().subscribe(() => {
expect(authService.isLoggedIn()).toBe(false);
expect(authService.getTicketEcm()).toBe(null);
expect(authService.isEcmLoggedIn()).toBe(false);
@@ -206,7 +206,7 @@ describe('AuthenticationService', () => {
});
it('[BPM] should return an BPM ticket after the login done', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe((response) => {
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe((response) => {
expect(authService.isLoggedIn()).toBe(true);
// cspell: disable-next
expect(authService.getTicketBpm()).toEqual('Basic ZmFrZS11c2VybmFtZTpmYWtlLXBhc3N3b3Jk');
@@ -222,8 +222,8 @@ describe('AuthenticationService', () => {
});
it('[BPM] should return a ticket undefined after logout', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
let disposableLogout = authService.logout().subscribe(() => {
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
const disposableLogout = authService.logout().subscribe(() => {
expect(authService.isLoggedIn()).toBe(false);
expect(authService.getTicketBpm()).toBe(null);
expect(authService.isBpmLoggedIn()).toBe(false);
@@ -309,7 +309,7 @@ describe('AuthenticationService', () => {
});
it('[ECM] should save the remember me cookie as a session cookie after successful login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password', false).subscribe(() => {
const disposableLogin = authService.login('fake-username', 'fake-password', false).subscribe(() => {
expect(cookie['ALFRESCO_REMEMBER_ME']).not.toBeUndefined();
expect(cookie['ALFRESCO_REMEMBER_ME'].expiration).toBeNull();
disposableLogin.unsubscribe();
@@ -324,7 +324,7 @@ describe('AuthenticationService', () => {
});
it('[ECM] should save the remember me cookie as a persistent cookie after successful login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password', true).subscribe(() => {
const disposableLogin = authService.login('fake-username', 'fake-password', true).subscribe(() => {
expect(cookie['ALFRESCO_REMEMBER_ME']).not.toBeUndefined();
expect(cookie['ALFRESCO_REMEMBER_ME'].expiration).not.toBeNull();
disposableLogin.unsubscribe();
@@ -340,7 +340,7 @@ describe('AuthenticationService', () => {
});
it('[ECM] should not save the remember me cookie after failed login', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
(res) => {
},
(err: any) => {
@@ -374,7 +374,7 @@ describe('AuthenticationService', () => {
});
it('[ALL] should return both ECM and BPM tickets after the login done', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(() => {
expect(authService.isLoggedIn()).toBe(true);
expect(authService.getTicketEcm()).toEqual('fake-post-ticket');
// cspell: disable-next
@@ -397,7 +397,7 @@ describe('AuthenticationService', () => {
});
it('[ALL] should return login fail if only ECM call fail', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
(res) => {
},
(err: any) => {
@@ -420,7 +420,7 @@ describe('AuthenticationService', () => {
});
it('[ALL] should return login fail if only BPM call fail', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
(res) => {
},
(err: any) => {
@@ -444,7 +444,7 @@ describe('AuthenticationService', () => {
});
it('[ALL] should return ticket undefined when the credentials are wrong', (done) => {
let disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
const disposableLogin = authService.login('fake-username', 'fake-password').subscribe(
(res) => {
},
(err: any) => {

View File

@@ -185,7 +185,7 @@ export class AuthenticationService {
* @returns The ticket or `null` if none was found
*/
getTicketEcmBase64(): string | null {
let ticket = this.alfrescoApi.getInstance().getTicketEcm();
const ticket = this.alfrescoApi.getInstance().getTicketEcm();
if (ticket) {
return 'Basic ' + btoa(ticket);
}
@@ -247,7 +247,7 @@ export class AuthenticationService {
* @returns The redirect URL
*/
getRedirect(): string {
let provider = <string> this.appConfig.get(AppConfigValues.PROVIDERS);
const provider = <string> this.appConfig.get(AppConfigValues.PROVIDERS);
return this.hasValidRedirection(provider) ? this.redirectUrl.url : null;
}

View File

@@ -69,7 +69,7 @@ describe('Comment ProcessService Service', () => {
it('should return the correct comment data', async(() => {
service.getProcessInstanceComments(processId).subscribe((comments) => {
let comment: any = comments[0];
const comment: any = comments[0];
expect(comment.id).toBe(fakeProcessComment.id);
expect(comment.created).toBe(fakeProcessComment.created);
expect(comment.message).toBe(fakeProcessComment.message);

View File

@@ -62,9 +62,9 @@ export class CommentProcessService {
return from(this.apiService.getInstance().activiti.taskApi.getTaskComments(taskId))
.pipe(
map((response: any) => {
let comments: CommentModel[] = [];
const comments: CommentModel[] = [];
response.data.forEach((comment: CommentModel) => {
let user = new UserProcessModel(comment.createdBy);
const user = new UserProcessModel(comment.createdBy);
comments.push(new CommentModel({
id: comment.id,
message: comment.message,
@@ -87,9 +87,9 @@ export class CommentProcessService {
return from(this.apiService.getInstance().activiti.commentsApi.getProcessInstanceComments(processInstanceId))
.pipe(
map((response: any) => {
let comments: CommentModel[] = [];
const comments: CommentModel[] = [];
response.data.forEach((comment: CommentModel) => {
let user = new UserProcessModel(comment.createdBy);
const user = new UserProcessModel(comment.createdBy);
comments.push(new CommentModel({
id: comment.id,
message: comment.message,

View File

@@ -66,7 +66,7 @@ describe('ContentService', () => {
jasmine.Ajax.install();
let appConfig: AppConfigService = TestBed.get(AppConfigService);
const appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config = {
ecmHost: 'http://localhost:9876/ecm',
provider: 'ECM'
@@ -109,33 +109,33 @@ describe('ContentService', () => {
describe('AllowableOperations', () => {
it('should hasAllowableOperations be false if allowableOperation is not present in the node', () => {
let permissionNode = new Node({});
const permissionNode = new Node({});
expect(contentService.hasAllowableOperations(permissionNode, 'create')).toBeFalsy();
});
it('should hasAllowableOperations be true if allowableOperation is present and you have the permission for the request operation', () => {
let permissionNode = new Node({ allowableOperations: ['delete', 'update', 'create', 'updatePermissions'] });
const permissionNode = new Node({ allowableOperations: ['delete', 'update', 'create', 'updatePermissions'] });
expect(contentService.hasAllowableOperations(permissionNode, 'create')).toBeTruthy();
});
it('should hasAllowableOperations be false if allowableOperation is present but you don\'t have the permission for the request operation', () => {
let permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
const permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
expect(contentService.hasAllowableOperations(permissionNode, 'create')).toBeFalsy();
});
it('should hasAllowableOperations works in the opposite way with negate value', () => {
let permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
const permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
expect(contentService.hasAllowableOperations(permissionNode, '!create')).toBeTruthy();
});
it('should hasAllowableOperations return false if no permission parameter are passed', () => {
let permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
const permissionNode = new Node({ allowableOperations: ['delete', 'update', 'updatePermissions'] });
expect(contentService.hasAllowableOperations(permissionNode, null)).toBeFalsy();
});
it('should havePermission return true if permission parameter is copy', () => {
let permissionNode = null;
const permissionNode = null;
expect(contentService.hasAllowableOperations(permissionNode, 'copy')).toBeTruthy();
});
});
@@ -143,38 +143,38 @@ describe('ContentService', () => {
describe('Permissions', () => {
it('should havePermission be false if allowableOperation is not present in the node', () => {
let permissionNode = new Node({});
const permissionNode = new Node({});
expect(contentService.hasPermissions(permissionNode, 'manager')).toBeFalsy();
});
it('should havePermission be true if permissions is present and you have the permission for the request operation', () => {
let permissionNode = new Node({ permissions: { locallySet: [{ name: 'manager' }, { name: 'collaborator' }, { name: 'consumer' }] } });
const permissionNode = new Node({ permissions: { locallySet: [{ name: 'manager' }, { name: 'collaborator' }, { name: 'consumer' }] } });
expect(contentService.hasPermissions(permissionNode, 'manager')).toBeTruthy();
});
it('should havePermission be false if permissions is present but you don\'t have the permission for the request operation', () => {
let permissionNode = new Node({ permissions: { locallySet: [{ name: 'collaborator' }, { name: 'consumer' }] } });
const permissionNode = new Node({ permissions: { locallySet: [{ name: 'collaborator' }, { name: 'consumer' }] } });
expect(contentService.hasPermissions(permissionNode, 'manager')).toBeFalsy();
});
it('should havePermission works in the opposite way with negate value', () => {
let permissionNode = new Node({ permissions: { locallySet: [{ name: 'collaborator' }, { name: 'consumer' }] } });
const permissionNode = new Node({ permissions: { locallySet: [{ name: 'collaborator' }, { name: 'consumer' }] } });
expect(contentService.hasPermissions(permissionNode, '!manager')).toBeTruthy();
});
it('should havePermission return false if no permission parameter are passed', () => {
let permissionNode = new Node({ permissions: { locallySet: [{ name: 'collaborator' }, { name: 'consumer' }] } });
const permissionNode = new Node({ permissions: { locallySet: [{ name: 'collaborator' }, { name: 'consumer' }] } });
expect(contentService.hasPermissions(permissionNode, null)).toBeFalsy();
});
it('should havePermission return true if the permissions is empty and the permission to check is Consumer', () => {
let permissionNode = new Node({ permissions: [] });
const permissionNode = new Node({ permissions: [] });
expect(contentService.hasPermissions(permissionNode, 'Consumer')).toBeTruthy();
});
it('should havePermission return false if the permissions is empty and the permission to check is not Consumer', () => {
let permissionNode = new Node({ permissions: [] });
const permissionNode = new Node({ permissions: [] });
expect(contentService.hasPermissions(permissionNode, '!Consumer')).toBeFalsy();
});
});
@@ -183,13 +183,13 @@ describe('ContentService', () => {
it('Should use native msSaveOrOpenBlob if the browser is IE', (done) => {
let navigatorAny: any = window.navigator;
const navigatorAny: any = window.navigator;
navigatorAny.__defineGetter__('msSaveOrOpenBlob', () => {
done();
});
let blob = new Blob([''], { type: 'text/html' });
const blob = new Blob([''], { type: 'text/html' });
contentService.downloadBlob(blob, 'test_ie');
});
});

View File

@@ -43,7 +43,7 @@ export class ContentService {
private logService: LogService,
private sanitizer: DomSanitizer) {
this.saveData = (function () {
let a = document.createElement('a');
const a = document.createElement('a');
document.body.appendChild(a);
a.style.display = 'none';
@@ -55,7 +55,7 @@ export class ContentService {
}
if (format === 'object' || format === 'json') {
let json = JSON.stringify(fileData);
const json = JSON.stringify(fileData);
blob = new Blob([json], { type: 'octet/stream' });
}
@@ -64,7 +64,7 @@ export class ContentService {
if (typeof window.navigator !== 'undefined' && window.navigator.msSaveOrOpenBlob) {
navigator.msSaveOrOpenBlob(blob, fileName);
} else {
let url = window.URL.createObjectURL(blob);
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = fileName;
a.click();
@@ -110,7 +110,7 @@ export class ContentService {
* @returns URL string
*/
createTrustedUrl(blob: Blob): string {
let url = window.URL.createObjectURL(blob);
const url = window.URL.createObjectURL(blob);
return <string> this.sanitizer.bypassSecurityTrustUrl(url);
}

View File

@@ -24,7 +24,7 @@ import { CoreTestingModule } from '../testing/core.testing.module';
declare let jasmine: any;
let fakeEcmDiscoveryResponse: any = {
const fakeEcmDiscoveryResponse: any = {
'entry': {
'repository': {
'edition': 'FAKE',
@@ -79,7 +79,7 @@ let fakeEcmDiscoveryResponse: any = {
}
};
let fakeBPMDiscoveryResponse: any = {
const fakeBPMDiscoveryResponse: any = {
'revisionVersion': '2',
'edition': 'SUPER FAKE EDITION',
'type': 'bpmSuite',
@@ -96,7 +96,7 @@ describe('Discovery Api Service', () => {
});
beforeEach(() => {
let appConfig: AppConfigService = TestBed.get(AppConfigService);
const appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config = {
ecmHost: 'http://localhost:9876/ecm'
};

View File

@@ -59,7 +59,7 @@ export abstract class DynamicComponentMapper {
throw new Error(`resolver is null or not defined`);
}
let existing = this.types[type];
const existing = this.types[type];
if (existing && !override) {
throw new Error(`already mapped, use override option if you intend replacing existing mapping.`);
}
@@ -75,7 +75,7 @@ export abstract class DynamicComponentMapper {
*/
resolveComponentType(model: DynamicComponentModel, defaultValue: Type<{}> = this.defaultValue): Type<{}> {
if (model) {
let resolver = this.getComponentTypeResolver(model.type, defaultValue);
const resolver = this.getComponentTypeResolver(model.type, defaultValue);
return resolver(model);
}
return defaultValue;

View File

@@ -44,7 +44,7 @@ export class ExternalAlfrescoApiService {
init(ecmHost: string, contextRoot: string) {
let domainPrefix = this.createPrefixFromHost(ecmHost);
const domainPrefix = this.createPrefixFromHost(ecmHost);
const config = {
provider: 'ECM',
@@ -65,7 +65,7 @@ export class ExternalAlfrescoApiService {
}
private createPrefixFromHost(url: string): string {
let match = url.match(/:\/\/(www[0-9]?\.)?(.[^/:]+)/i);
const match = url.match(/:\/\/(www[0-9]?\.)?(.[^/:]+)/i);
let result = null;
if (match != null && match.length > 2 && typeof match[2] === 'string' && match[2].length > 0) {
result = match[2];

View File

@@ -30,13 +30,13 @@ export class JwtHelperService {
* @returns Decoded token data object
*/
decodeToken(token): Object {
let parts = token.split('.');
const parts = token.split('.');
if (parts.length !== 3) {
throw new Error('JWT must have 3 parts');
}
let decoded = this.urlBase64Decode(parts[1]);
const decoded = this.urlBase64Decode(parts[1]);
if (!decoded) {
throw new Error('Cannot decode the token');
}

View File

@@ -28,7 +28,7 @@ import { Subject } from 'rxjs';
export class LogService {
get currentLogLevel() {
let configLevel: string = this.appConfig.get<string>(AppConfigValues.LOG_LEVEL);
const configLevel: string = this.appConfig.get<string>(AppConfigValues.LOG_LEVEL);
if (configLevel) {
return this.getLogLevel(configLevel);
@@ -168,7 +168,7 @@ export class LogService {
* @returns Numeric log level
*/
getLogLevel(level: string): LogLevelsEnum {
let referencedLevel = logLevels.find((currentLevel: any) => {
const referencedLevel = logLevels.find((currentLevel: any) => {
return currentLevel.name.toLocaleLowerCase() === level.toLocaleLowerCase();
});

View File

@@ -27,7 +27,6 @@ describe('LoginDialogService', () => {
let service: LoginDialogService;
let materialDialog: MatDialog;
let spyOnDialogOpen: jasmine.Spy;
let afterOpenObservable: Subject<any>;
setupTestBed({
imports: [CoreModule.forRoot()]
@@ -37,7 +36,7 @@ describe('LoginDialogService', () => {
service = TestBed.get(LoginDialogService);
materialDialog = TestBed.get(MatDialog);
spyOnDialogOpen = spyOn(materialDialog, 'open').and.returnValue({
afterOpen: () => afterOpenObservable,
afterOpen: () => of({}),
afterClosed: () => of({}),
componentInstance: {
error: new Subject<any>()

View File

@@ -36,32 +36,32 @@ class ProvidesNotificationServiceComponent {
}
sendMessageWithoutConfig() {
let promise = this.notificationService.openSnackMessage('Test notification', 1000);
const promise = this.notificationService.openSnackMessage('Test notification', 1000);
return promise;
}
sendMessage() {
let promise = this.notificationService.openSnackMessage('Test notification', 1000);
const promise = this.notificationService.openSnackMessage('Test notification', 1000);
return promise;
}
sendCustomMessage() {
let promise = this.notificationService.openSnackMessage('Test notification', new MatSnackBarConfig());
const promise = this.notificationService.openSnackMessage('Test notification', new MatSnackBarConfig());
return promise;
}
sendMessageActionWithoutConfig() {
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
return promise;
}
sendMessageAction() {
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
return promise;
}
sendCustomMessageAction() {
let promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', new MatSnackBarConfig());
const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', new MatSnackBarConfig());
return promise;
}
@@ -99,7 +99,7 @@ describe('NotificationService', () => {
it('should translate messages', (done) => {
spyOn(translationService, 'instant').and.callThrough();
let promise = fixture.componentInstance.sendMessage();
const promise = fixture.componentInstance.sendMessage();
promise.afterDismissed().subscribe(() => {
expect(translationService.instant).toHaveBeenCalled();
done();
@@ -109,7 +109,7 @@ describe('NotificationService', () => {
});
it('should open a message notification bar', (done) => {
let promise = fixture.componentInstance.sendMessage();
const promise = fixture.componentInstance.sendMessage();
promise.afterDismissed().subscribe(() => {
done();
});
@@ -120,7 +120,7 @@ describe('NotificationService', () => {
});
it('should open a message notification bar without custom configuration', (done) => {
let promise = fixture.componentInstance.sendMessageWithoutConfig();
const promise = fixture.componentInstance.sendMessageWithoutConfig();
promise.afterDismissed().subscribe(() => {
done();
});
@@ -131,7 +131,7 @@ describe('NotificationService', () => {
});
it('should open a message notification bar with custom configuration', async((done) => {
let promise = fixture.componentInstance.sendCustomMessage();
const promise = fixture.componentInstance.sendCustomMessage();
promise.afterDismissed().subscribe(() => {
done();
});
@@ -142,7 +142,7 @@ describe('NotificationService', () => {
}));
it('should open a message notification bar with action', (done) => {
let promise = fixture.componentInstance.sendMessageAction();
const promise = fixture.componentInstance.sendMessageAction();
promise.afterDismissed().subscribe(() => {
done();
});
@@ -153,7 +153,7 @@ describe('NotificationService', () => {
});
it('should open a message notification bar with action and custom configuration', async((done) => {
let promise = fixture.componentInstance.sendCustomMessageAction();
const promise = fixture.componentInstance.sendCustomMessageAction();
promise.afterDismissed().subscribe(() => {
done();
});
@@ -164,7 +164,7 @@ describe('NotificationService', () => {
}));
it('should open a message notification bar with action and no custom configuration', (done) => {
let promise = fixture.componentInstance.sendMessageActionWithoutConfig();
const promise = fixture.componentInstance.sendMessageActionWithoutConfig();
promise.afterDismissed().subscribe(() => {
done();
});

View File

@@ -96,7 +96,7 @@ describe('PeopleProcessService', () => {
});
it('should return user image url', () => {
let url = service.getUserImage(firstInvolvedUser);
const url = service.getUserImage(firstInvolvedUser);
expect(url).toContain('/users/' + firstInvolvedUser.id + '/picture');
});

View File

@@ -38,7 +38,7 @@ export class PeopleProcessService {
* @returns Array of user information objects
*/
getWorkflowUsers(taskId?: string, searchWord?: string): Observable<UserProcessModel[]> {
let option = { excludeTaskId: taskId, filter: searchWord };
const option = { excludeTaskId: taskId, filter: searchWord };
return from(this.getWorkflowUserApi(option))
.pipe(
map((response: any) => <UserProcessModel[]> response.data || []),
@@ -62,7 +62,7 @@ export class PeopleProcessService {
* @returns Empty response when the update completes
*/
involveUserWithTask(taskId: string, idToInvolve: string): Observable<UserProcessModel[]> {
let node = {userId: idToInvolve};
const node = {userId: idToInvolve};
return from(this.involveUserToTaskApi(taskId, node))
.pipe(
catchError((err) => this.handleError(err))
@@ -76,7 +76,7 @@ export class PeopleProcessService {
* @returns Empty response when the update completes
*/
removeInvolvedUser(taskId: string, idToRemove: string): Observable<UserProcessModel[]> {
let node = {userId: idToRemove};
const node = {userId: idToRemove};
return from(this.removeInvolvedUserFromTaskApi(taskId, node))
.pipe(
catchError((err) => this.handleError(err))

View File

@@ -37,9 +37,9 @@ export class RenditionsService {
getAvailableRenditionForNode(nodeId: string): Observable<RenditionEntry> {
return from(this.apiService.renditionsApi.getRenditions(nodeId)).pipe(
map((availableRenditions: RenditionPaging) => {
let renditionsAvailable: RenditionEntry[] = availableRenditions.list.entries.filter(
const renditionsAvailable: RenditionEntry[] = availableRenditions.list.entries.filter(
(rendition) => (rendition.entry.id === 'pdf' || rendition.entry.id === 'imgpreview'));
let existingRendition = renditionsAvailable.find((rend) => rend.entry.status === 'CREATED');
const existingRendition = renditionsAvailable.find((rend) => rend.entry.status === 'CREATED');
return existingRendition ? existingRendition : renditionsAvailable[0];
}));
}

View File

@@ -35,7 +35,7 @@ export class SearchConfigurationService implements SearchConfigurationInterface
* @returns Query body defined by the parameters
*/
public generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody {
let defaultQueryBody: QueryBody = {
const defaultQueryBody: QueryBody = {
query: {
query: searchTerm ? `'${searchTerm}*' OR name:'${searchTerm}*'` : searchTerm
},

View File

@@ -50,7 +50,7 @@ describe('SearchService', () => {
});
it('should call search API with no additional options', (done) => {
let searchTerm = 'searchTerm63688';
const searchTerm = 'searchTerm63688';
spyOn(searchMockApi.core.queriesApi, 'findNodes').and.returnValue(Promise.resolve(fakeSearch));
service.getNodeQueryResults(searchTerm).subscribe(
() => {
@@ -61,7 +61,7 @@ describe('SearchService', () => {
});
it('should call search API with additional options', (done) => {
let searchTerm = 'searchTerm63688', options = {
const searchTerm = 'searchTerm63688', options = {
include: [ 'path' ],
rootNodeId: '-root-',
nodeType: 'cm:content'

View File

@@ -32,7 +32,7 @@ describe('Sites service', () => {
});
beforeEach(() => {
let appConfig: AppConfigService = TestBed.get(AppConfigService);
const appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config = {
ecmHost: 'http://localhost:9876/ecm',
files: {

View File

@@ -67,7 +67,7 @@ export class SitesService {
* @returns Null response notifying when the operation is complete
*/
deleteSite(siteId: string, permanentFlag: boolean = true): Observable<any> {
let options: any = {};
const options: any = {};
options.permanent = permanentFlag;
return from(this.apiService.getInstance().core.sitesApi.deleteSite(siteId, options))
.pipe(

View File

@@ -91,7 +91,7 @@ export class StorageService {
private storageAvailable(type: string): boolean {
try {
let storage = window[type];
const storage = window[type];
const key = '__storage_test__';
storage.setItem(key, key);
storage.removeItem(key, key);

View File

@@ -170,7 +170,7 @@ export class ThumbnailService {
* @returns URL string
*/
public getDocumentThumbnailUrl(node: any): string {
let thumbnail = this.contentService.getDocumentThumbnailUrl(node);
const thumbnail = this.contentService.getDocumentThumbnailUrl(node);
return thumbnail || this.DEFAULT_ICON;
}
@@ -180,7 +180,7 @@ export class ThumbnailService {
* @returns URL string
*/
public getMimeTypeIcon(mimeType: string): string {
let icon = this.mimeTypeIcons[mimeType];
const icon = this.mimeTypeIcons[mimeType];
return (icon || this.DEFAULT_ICON);
}

View File

@@ -43,7 +43,7 @@ export class TranslateLoaderService implements TranslateLoader {
}
registerProvider(name: string, path: string) {
let registered = this.providers.find((provider) => provider.name === name);
const registered = this.providers.find((provider) => provider.name === name);
if (registered) {
registered.path = path;
} else {
@@ -148,7 +148,7 @@ export class TranslateLoaderService implements TranslateLoader {
if (batch.length > 0) {
forkJoin(batch).subscribe(
() => {
let fullTranslation = this.getFullTranslationJSON(lang);
const fullTranslation = this.getFullTranslationJSON(lang);
if (fullTranslation) {
observer.next(fullTranslation);
}
@@ -162,7 +162,7 @@ export class TranslateLoaderService implements TranslateLoader {
observer.error('Failed to load some resources');
});
} else {
let fullTranslation = this.getFullTranslationJSON(lang);
const fullTranslation = this.getFullTranslationJSON(lang);
if (fullTranslation) {
observer.next(fullTranslation);
observer.complete();

View File

@@ -21,7 +21,7 @@ import { TranslationService } from './translation.service';
import { setupTestBed } from '../testing/setupTestBed';
import { CoreModule } from '../core.module';
let componentJson1 = ' {"TEST": "This is a test", "TEST2": "This is another test"} ' ;
const componentJson1 = ' {"TEST": "This is a test", "TEST2": "This is another test"} ' ;
declare let jasmine: any;

View File

@@ -46,7 +46,7 @@ export class TranslationService {
this.customLoader.setDefaultLang(this.defaultLang);
if (providers && providers.length > 0) {
for (let provider of providers) {
for (const provider of providers) {
this.addTranslationFolder(provider.name, provider.source);
}
}

View File

@@ -38,7 +38,7 @@ describe('UploadService', () => {
});
beforeEach(() => {
let appConfig: AppConfigService = TestBed.get(AppConfigService);
const appConfig: AppConfigService = TestBed.get(AppConfigService);
appConfig.config = {
ecmHost: 'http://localhost:9876/ecm',
files: {
@@ -66,13 +66,13 @@ describe('UploadService', () => {
});
it('should add an element in the queue and returns it', () => {
let filesFake = new FileModel(<File> { name: 'fake-name', size: 10 });
const filesFake = new FileModel(<File> { name: 'fake-name', size: 10 });
service.addToQueue(filesFake);
expect(service.getQueue().length).toEqual(1);
});
it('should add two elements in the queue and returns them', () => {
let filesFake = [
const filesFake = [
new FileModel(<File> { name: 'fake-name', size: 10 }),
new FileModel(<File> { name: 'fake-name2', size: 20 })
];
@@ -97,21 +97,21 @@ describe('UploadService', () => {
});
it('should make XHR done request after the file is added in the queue', (done) => {
let emitter = new EventEmitter();
const emitter = new EventEmitter();
let emitterDisposable = emitter.subscribe((e) => {
const emitterDisposable = emitter.subscribe((e) => {
expect(e.value).toBe('File uploaded');
emitterDisposable.unsubscribe();
done();
});
let fileFake = new FileModel(
const fileFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
<FileUploadOptions> { parentId: '-root-', path: 'fake-dir' }
);
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(emitter);
let request = jasmine.Ajax.requests.mostRecent();
const request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations');
expect(request.method).toBe('POST');
@@ -123,14 +123,14 @@ describe('UploadService', () => {
});
it('should make XHR error request after an error occur', (done) => {
let emitter = new EventEmitter();
const emitter = new EventEmitter();
let emitterDisposable = emitter.subscribe((e) => {
const emitterDisposable = emitter.subscribe((e) => {
expect(e.value).toBe('Error file uploaded');
emitterDisposable.unsubscribe();
done();
});
let fileFake = new FileModel(
const fileFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
<FileUploadOptions> { parentId: '-root-' }
);
@@ -147,26 +147,26 @@ describe('UploadService', () => {
});
it('should make XHR abort request after the xhr abort is called', (done) => {
let emitter = new EventEmitter();
const emitter = new EventEmitter();
let emitterDisposable = emitter.subscribe((e) => {
const emitterDisposable = emitter.subscribe((e) => {
expect(e.value).toEqual('File aborted');
emitterDisposable.unsubscribe();
done();
});
let fileFake = new FileModel(<File> { name: 'fake-name', size: 10 });
const fileFake = new FileModel(<File> { name: 'fake-name', size: 10 });
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(emitter);
let file = service.getQueue();
const file = service.getQueue();
service.cancelUpload(...file);
});
it('If newVersion is set, name should be a param', () => {
let uploadFileSpy = spyOn(alfrescoApiService.getInstance().upload, 'uploadFile').and.callThrough();
const uploadFileSpy = spyOn(alfrescoApiService.getInstance().upload, 'uploadFile').and.callThrough();
let emitter = new EventEmitter();
const emitter = new EventEmitter();
const filesFake = new FileModel(<File> { name: 'fake-name', size: 10 }, {
newVersion: true
@@ -188,21 +188,21 @@ describe('UploadService', () => {
});
it('should use custom root folder ID given to the service', (done) => {
let emitter = new EventEmitter();
const emitter = new EventEmitter();
let emitterDisposable = emitter.subscribe((e) => {
const emitterDisposable = emitter.subscribe((e) => {
expect(e.value).toBe('File uploaded');
emitterDisposable.unsubscribe();
done();
});
let filesFake = new FileModel(
const filesFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
<FileUploadOptions> { parentId: '123', path: 'fake-dir' }
);
service.addToQueue(filesFake);
service.uploadFilesInTheQueue(emitter);
let request = jasmine.Ajax.requests.mostRecent();
const request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/123/children?autoRename=true&include=allowableOperations');
expect(request.method).toBe('POST');
@@ -214,10 +214,10 @@ describe('UploadService', () => {
});
it('should append to the request the extra upload options', () => {
let uploadFileSpy = spyOn(alfrescoApiService.getInstance().upload, 'uploadFile').and.callThrough();
let emitter = new EventEmitter();
const uploadFileSpy = spyOn(alfrescoApiService.getInstance().upload, 'uploadFile').and.callThrough();
const emitter = new EventEmitter();
let filesFake = new FileModel(
const filesFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
<FileUploadOptions> {
parentId: '123', path: 'fake-dir',
@@ -246,7 +246,7 @@ describe('UploadService', () => {
});
it('should start downloading the next one if a file of the list is aborted', (done) => {
let emitter = new EventEmitter();
const emitter = new EventEmitter();
service.fileUploadAborted.subscribe((e) => {
expect(e).not.toBeNull();
@@ -257,13 +257,13 @@ describe('UploadService', () => {
done();
});
let fileFake1 = new FileModel(<File> { name: 'fake-name1', size: 10 });
let fileFake2 = new FileModel(<File> { name: 'fake-name2', size: 10 });
let fileList = [fileFake1, fileFake2];
const fileFake1 = new FileModel(<File> { name: 'fake-name1', size: 10 });
const fileFake2 = new FileModel(<File> { name: 'fake-name2', size: 10 });
const fileList = [fileFake1, fileFake2];
service.addToQueue(...fileList);
service.uploadFilesInTheQueue(emitter);
let file = service.getQueue();
const file = service.getQueue();
service.cancelUpload(...file);
});

View File

@@ -94,7 +94,7 @@ export class UploadService {
this.matchingOptions = this.appConfigService.get('files.match-options');
isAllowed = this.excludedFileList.filter((pattern) => {
let minimatch = new Minimatch(pattern, this.matchingOptions);
const minimatch = new Minimatch(pattern, this.matchingOptions);
return minimatch.match(file.name);
}).length === 0;
}
@@ -107,7 +107,7 @@ export class UploadService {
*/
uploadFilesInTheQueue(emitter?: EventEmitter<any>): void {
if (!this.activeTask) {
let file = this.queue.find((currentFile) => currentFile.status === FileUploadStatus.Pending);
const file = this.queue.find((currentFile) => currentFile.status === FileUploadStatus.Pending);
if (file) {
this.onUploadStarting(file);
@@ -115,7 +115,7 @@ export class UploadService {
this.activeTask = promise;
this.cache[file.id] = promise;
let next = () => {
const next = () => {
this.activeTask = null;
setTimeout(() => this.uploadFilesInTheQueue(emitter), 100);
};
@@ -162,7 +162,7 @@ export class UploadService {
* @returns Promise that is resolved if the upload is successful or error otherwise
*/
getUploadPromise(file: FileModel): any {
let opts: any = {
const opts: any = {
renditions: 'doclib',
include: ['allowableOperations']
};
@@ -199,7 +199,7 @@ export class UploadService {
private beginUpload(file: FileModel, emitter: EventEmitter<any>): any {
let promise = this.getUploadPromise(file);
const promise = this.getUploadPromise(file);
promise.on('progress', (progress: FileUploadProgress) => {
this.onUploadProgress(file, progress);

View File

@@ -167,7 +167,7 @@ export class UserPreferencesService {
* @returns Array of page size values
*/
get supportedPageSizes(): number[] {
let supportedPageSizes = this.get(UserPreferenceValues.SupportedPageSizes);
const supportedPageSizes = this.get(UserPreferenceValues.SupportedPageSizes);
if (supportedPageSizes) {
return JSON.parse(supportedPageSizes);
@@ -186,7 +186,7 @@ export class UserPreferencesService {
}
get paginationSize(): number {
let paginationSize = this.get(UserPreferenceValues.PaginationSize);
const paginationSize = this.get(UserPreferenceValues.PaginationSize);
if (paginationSize) {
return Number(paginationSize);