fix eslint warnigs for core project (#7506)

This commit is contained in:
Denys Vuika
2022-02-17 14:35:33 +00:00
committed by GitHub
parent 5b7f255eec
commit bca5a783ab
246 changed files with 5127 additions and 5065 deletions

View File

@@ -63,7 +63,7 @@ describe('AppsProcessService', () => {
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});
@@ -81,7 +81,7 @@ describe('AppsProcessService', () => {
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});
@@ -99,7 +99,7 @@ describe('AppsProcessService', () => {
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeApps)
});

View File

@@ -39,31 +39,34 @@ export class AppsProcessService {
/**
* Gets a list of deployed apps for this user.
*
* @returns The list of deployed apps
*/
getDeployedApplications(): Observable<AppDefinitionRepresentation[]> {
return from(this.appsApi.getAppDefinitions())
.pipe(
map((response: any) => <AppDefinitionRepresentation[]> response.data),
map((response: any) => response.data),
catchError((err) => this.handleError(err))
);
}
/**
* Gets a list of deployed apps for this user, where the app name is `name`.
*
* @param name Name of the app
* @returns The list of deployed apps
*/
getDeployedApplicationsByName(name: string): Observable<AppDefinitionRepresentation> {
return from(this.appsApi.getAppDefinitions())
.pipe(
map((response: any) => <AppDefinitionRepresentation> response.data.find((app) => app.name === name)),
map((response: any) => response.data.find((app) => app.name === name)),
catchError((err) => this.handleError(err))
);
}
/**
* Gets the details for a specific app ID number.
*
* @param appId ID of the target app
* @returns Details of the app
*/

View File

@@ -55,9 +55,7 @@ export class AuthBearerInterceptor implements HttpInterceptor {
if (shallPass) {
return next.handle(req)
.pipe(
catchError((error) => {
return observableThrowError(error);
})
catchError((error) => observableThrowError(error))
);
}
@@ -68,9 +66,7 @@ export class AuthBearerInterceptor implements HttpInterceptor {
const kcReq = req.clone({ headers: headerWithContentType});
return next.handle(kcReq)
.pipe(
catchError((error) => {
return observableThrowError(error);
})
catchError((error) => observableThrowError(error))
);
})
);

View File

@@ -68,7 +68,7 @@ describe('AuthGuardService BPM', () => {
provider: 'BPM'
};
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'abc' };
const route = { url: 'abc' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1);
@@ -76,7 +76,7 @@ describe('AuthGuardService BPM', () => {
it('if the alfresco js api is logged in should canActivate be true', async () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
const route = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeTruthy();
});
@@ -85,7 +85,7 @@ describe('AuthGuardService BPM', () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
appConfigService.config.auth.withCredentials = true;
const route = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeTruthy();
});
@@ -93,7 +93,7 @@ describe('AuthGuardService BPM', () => {
it('if the alfresco js api is NOT logged in should canActivate be false', async () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(false);
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
});
@@ -103,7 +103,7 @@ describe('AuthGuardService BPM', () => {
spyOn(router, 'navigateByUrl');
spyOn(authService, 'isBpmLoggedIn').and.returnValue(false);
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url'));
@@ -114,7 +114,7 @@ describe('AuthGuardService BPM', () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
appConfigService.config.oauth2.silentLogin = false;
const route = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
@@ -125,7 +125,7 @@ describe('AuthGuardService BPM', () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
appConfigService.config.oauth2.silentLogin = undefined;
const route = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
@@ -134,7 +134,7 @@ describe('AuthGuardService BPM', () => {
it('should set redirect url', () => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
authGuard.canActivate(null, route);
@@ -147,7 +147,7 @@ describe('AuthGuardService BPM', () => {
it('should set redirect navigation commands with query params', () => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url;q=123' };
const route = { url: 'some-url;q=123' } as RouterStateSnapshot;
authGuard.canActivate(null, route);
@@ -160,7 +160,7 @@ describe('AuthGuardService BPM', () => {
it('should set redirect navigation commands with query params', () => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: '/' };
const route = { url: '/' } as RouterStateSnapshot;
authGuard.canActivate(null, route);
@@ -174,7 +174,7 @@ describe('AuthGuardService BPM', () => {
appConfigService.config.loginRoute = 'fakeLoginRoute';
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
authGuard.canActivate(null, route);
@@ -191,7 +191,7 @@ describe('AuthGuardService BPM', () => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
authGuard.canActivate(null, route);

View File

@@ -51,53 +51,53 @@ describe('AuthGuardService ECM', () => {
appConfigService.config.oauth2 = {};
});
it('if the alfresco js api is logged in should canActivate be true', async() => {
it('if the alfresco js api is logged in should canActivate be true', async () => {
spyOn(authService, 'isEcmLoggedIn').and.returnValue(true);
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
const route = {url : 'some-url'} as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeTruthy();
});
it('if the alfresco js api is configured with withCredentials true should canActivate be true', async() => {
it('if the alfresco js api is configured with withCredentials true should canActivate be true', async () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
appConfigService.config.auth.withCredentials = true;
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
const route = {url : 'some-url'} as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeTruthy();
});
it('if the alfresco js api is NOT logged in should canActivate be false', async() => {
it('if the alfresco js api is NOT logged in should canActivate be false', async () => {
spyOn(authService, 'isEcmLoggedIn').and.returnValue(false);
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
});
it('if the alfresco js api is NOT logged in should trigger a redirect event', async() => {
it('if the alfresco js api is NOT logged in should trigger a redirect event', async () => {
appConfigService.config.loginRoute = 'login';
spyOn(router, 'navigateByUrl');
spyOn(authService, 'isEcmLoggedIn').and.returnValue(false);
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
const route = {url : 'some-url'} as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalledWith(router.parseUrl('/login?redirectUrl=some-url'));
});
it('should redirect url if the alfresco js api is NOT logged in and isOAuthWithoutSilentLogin', async() => {
it('should redirect url if the alfresco js api is NOT logged in and isOAuthWithoutSilentLogin', async () => {
spyOn(router, 'navigateByUrl').and.stub();
spyOn(authService, 'isEcmLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
appConfigService.config.oauth2.silentLogin = false;
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
const route = {url : 'some-url'} as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
});
it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async() => {
it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async () => {
spyOn(authService, 'isEcmLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
spyOn(authService, 'isPublicUrl').and.returnValue(false);
@@ -112,18 +112,18 @@ describe('AuthGuardService ECM', () => {
scope: 'openid'
};
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'abc'};
const route = {url : 'abc'} as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1);
});
it('should not redirect url if NOT logged in and isOAuth but no silentLogin configured', async() => {
it('should not redirect url if NOT logged in and isOAuth but no silentLogin configured', async () => {
spyOn(router, 'navigateByUrl').and.stub();
spyOn(authService, 'isEcmLoggedIn').and.returnValue(false);
spyOn(authService, 'isOauth').and.returnValue(true);
appConfigService.config.oauth2.silentLogin = undefined;
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'some-url'};
const route = {url : 'some-url'} as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeFalsy();
expect(router.navigateByUrl).toHaveBeenCalled();
@@ -132,7 +132,7 @@ describe('AuthGuardService ECM', () => {
it('should set redirect navigation commands', () => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
authGuard.canActivate(null, route);
@@ -145,7 +145,7 @@ describe('AuthGuardService ECM', () => {
it('should set redirect navigation commands with query params', () => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url;q=123' };
const route = { url: 'some-url;q=123' } as RouterStateSnapshot;
authGuard.canActivate(null, route);
@@ -158,7 +158,7 @@ describe('AuthGuardService ECM', () => {
it('should set redirect navigation commands with query params', () => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: '/' };
const route = { url: '/' } as RouterStateSnapshot;
authGuard.canActivate(null, route);
@@ -172,7 +172,7 @@ describe('AuthGuardService ECM', () => {
appConfigService.config.loginRoute = 'fakeLoginRoute';
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
authGuard.canActivate(null, route);
@@ -189,7 +189,7 @@ describe('AuthGuardService ECM', () => {
spyOn(authService, 'setRedirect').and.callThrough();
spyOn(router, 'navigateByUrl').and.stub();
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
authGuard.canActivate(null, route);

View File

@@ -51,31 +51,31 @@ describe('Auth Guard SSO role service', () => {
it('Should canActivate be true if the Role is present int the JWT token', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1'] } });
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['role1', 'role2'] };
router.data = { roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(router)).toBeTruthy();
});
it('Should canActivate be false if the Role is not present int the JWT token', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role3'] } });
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role3'] } });
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['role1', 'role2'] };
router.data = { roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(router)).toBeFalsy();
});
it('Should not redirect if canActivate is', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1'] } });
spyOn(routerService, 'navigate').and.stub();
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['role1', 'role2'] };
router.data = { roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(router)).toBeTruthy();
expect(routerService.navigate).not.toHaveBeenCalled();
@@ -83,7 +83,7 @@ describe('Auth Guard SSO role service', () => {
it('Should canActivate return false if the data Role to check is empty', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1', 'role3'] } });
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1', 'role3'] } });
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
@@ -105,7 +105,7 @@ describe('Auth Guard SSO role service', () => {
spyOn(routerService, 'navigate').and.stub();
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['role1', 'role2'], 'redirectUrl': 'no-role-url' };
router.data = { roles: ['role1', 'role2'], redirectUrl: 'no-role-url' };
expect(await authGuard.canActivate(router)).toBeFalsy();
expect(routerService.navigate).toHaveBeenCalledWith(['/no-role-url']);
@@ -117,7 +117,7 @@ describe('Auth Guard SSO role service', () => {
spyOn(routerService, 'navigate').and.stub();
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['role1', 'role2'] };
router.data = { roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(router)).toBeFalsy();
expect(routerService.navigate).not.toHaveBeenCalled();
@@ -129,7 +129,7 @@ describe('Auth Guard SSO role service', () => {
spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(false);
route.params = { appName: 'fakeapp' };
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
route.data = { clientRoles: ['appName'], roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(route)).toBeFalsy();
});
@@ -140,7 +140,7 @@ describe('Auth Guard SSO role service', () => {
spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(true);
route.params = { appName: 'fakeapp' };
route.data = { 'clientRoles': ['fakeapp'], 'roles': ['role1', 'role2'] };
route.data = { clientRoles: ['fakeapp'], roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(route)).toBeFalsy();
});
@@ -150,12 +150,12 @@ describe('Auth Guard SSO role service', () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({
'realm_access': { roles: ['role1'] },
'resource_access': { fakeapp: { roles: ['role2'] } }
realm_access: { roles: ['role1'] },
resource_access: { fakeapp: { roles: ['role2'] } }
});
route.params = { appName: 'fakeapp' };
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
route.data = { clientRoles: ['appName'], roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(route)).toBeTruthy();
});
@@ -165,12 +165,12 @@ describe('Auth Guard SSO role service', () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({
'realm_access': { roles: ['role1'] },
'resource_access': { fakeapp: { roles: ['role3'] } }
realm_access: { roles: ['role1'] },
resource_access: { fakeapp: { roles: ['role3'] } }
});
route.params = { appName: 'fakeapp' };
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
route.data = { clientRoles: ['appName'], roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(route)).toBeFalsy();
});
@@ -185,7 +185,7 @@ describe('Auth Guard SSO role service', () => {
spyOn(jwtHelperService, 'hasRealmRolesForClientRole').and.returnValue(false);
route.params = { appName: 'fakeapp' };
route.data = { 'clientRoles': ['appName'], 'roles': ['role1', 'role2'] };
route.data = { clientRoles: ['appName'], roles: ['role1', 'role2'] };
expect(await authGuard.canActivate(route)).toBeFalsy();
expect(materialDialog.closeAll).toHaveBeenCalled();
@@ -201,7 +201,7 @@ describe('Auth Guard SSO role service', () => {
spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentAdminCapability()));
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['ALFRESCO_ADMINISTRATORS'] };
router.data = { roles: ['ALFRESCO_ADMINISTRATORS'] };
expect(await authGuard.canActivate(router)).toBeTruthy();
});
@@ -210,7 +210,7 @@ describe('Auth Guard SSO role service', () => {
spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentUserCapability()));
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['ALFRESCO_ADMINISTRATORS'] };
router.data = { roles: ['ALFRESCO_ADMINISTRATORS'] };
expect(await authGuard.canActivate(router)).toBeFalsy();
});
@@ -218,7 +218,7 @@ describe('Auth Guard SSO role service', () => {
it('Should not call the service to check if the user has content admin capability when the roles do not contain ALFRESCO_ADMINISTRATORS', async () => {
const getCurrentPersonSpy = spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentAdminCapability()));
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['fakeRole'] };
router.data = { roles: ['fakeRole'] };
await authGuard.canActivate(router);
@@ -230,20 +230,20 @@ describe('Auth Guard SSO role service', () => {
it('Should canActivate be false when the user has one of the excluded roles', async () => {
spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentAdminCapability()));
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1'] } });
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['ALFRESCO_ADMINISTRATORS'], 'excludedRoles': ['role1'] };
router.data = { roles: ['ALFRESCO_ADMINISTRATORS'], excludedRoles: ['role1'] };
expect(await authGuard.canActivate(router)).toBeFalsy();
});
it('Should canActivate be true when the user has none of the excluded roles', async () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role2'] } });
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role2'] } });
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['role1', 'role2'], 'excludedRoles': ['role3'] };
router.data = { roles: ['role1', 'role2'], excludedRoles: ['role3'] };
expect(await authGuard.canActivate(router)).toBeTruthy();
});
@@ -251,10 +251,10 @@ describe('Auth Guard SSO role service', () => {
it('Should canActivate be false when the user is a content admin and the ALFRESCO_ADMINISTRATORS role is excluded', async () => {
spyOn(peopleContentService, 'getCurrentPerson').and.returnValue(of(getFakeUserWithContentAdminCapability()));
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ 'realm_access': { roles: ['role1'] } });
spyOn(jwtHelperService, 'decodeToken').and.returnValue({ realm_access: { roles: ['role1'] } });
const router: ActivatedRouteSnapshot = new ActivatedRouteSnapshot();
router.data = { 'roles': ['role1'], 'excludedRoles': ['ALFRESCO_ADMINISTRATORS'] };
router.data = { roles: ['role1'], excludedRoles: ['ALFRESCO_ADMINISTRATORS'] };
expect(await authGuard.canActivate(router)).toBeFalsy();
});

View File

@@ -74,7 +74,7 @@ describe('AuthGuardService', () => {
spyOn(authService, 'isBpmLoggedIn').and.returnValue(true);
appConfigService.config.auth.withCredentials = true;
const route: RouterStateSnapshot = <RouterStateSnapshot> { url: 'some-url' };
const route = { url: 'some-url' } as RouterStateSnapshot;
expect(await authGuard.canActivate(null, route)).toBeTruthy();
});

View File

@@ -126,7 +126,7 @@ describe('AuthenticationService', () => {
jasmine.Ajax.requests.mostRecent().respondWith({
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
});
@@ -137,9 +137,9 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
});
@@ -155,14 +155,14 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 204
status: 204
});
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
});
@@ -251,7 +251,7 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json'
});
});
@@ -268,12 +268,12 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200
status: 200
});
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200
status: 200
});
});
@@ -288,7 +288,7 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 403
status: 403
});
});
@@ -340,9 +340,9 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
});
@@ -356,9 +356,9 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
});
@@ -372,15 +372,15 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 403,
status: 403,
contentType: 'application/json',
responseText: JSON.stringify({
'error': {
'errorKey': 'Login failed',
'statusCode': 403,
'briefSummary': '05150009 Login failed',
'stackTrace': 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.',
'descriptionURL': 'https://api-explorer.alfresco.com'
error: {
errorKey: 'Login failed',
statusCode: 403,
briefSummary: '05150009 Login failed',
stackTrace: 'For security reasons the stack trace is no longer displayed, but the property is kept for previous versions.',
descriptionURL: 'https://api-explorer.alfresco.com'
}
})
});
@@ -408,13 +408,13 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.at(0).respondWith({
'status': 201,
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
jasmine.Ajax.requests.at(1).respondWith({
'status': 200
status: 200
});
});
@@ -432,11 +432,11 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.at(0).respondWith({
'status': 403
status: 403
});
jasmine.Ajax.requests.at(1).respondWith({
'status': 200
status: 200
});
});
@@ -453,13 +453,13 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.at(0).respondWith({
'status': 201,
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
jasmine.Ajax.requests.at(1).respondWith({
'status': 403
status: 403
});
});
@@ -477,11 +477,11 @@ describe('AuthenticationService', () => {
});
jasmine.Ajax.requests.at(0).respondWith({
'status': 403
status: 403
});
jasmine.Ajax.requests.at(1).respondWith({
'status': 403
status: 403
});
});

View File

@@ -92,6 +92,7 @@ export class AuthenticationService {
/**
* Checks if the user logged in.
*
* @returns True if logged in, false otherwise
*/
isLoggedIn(): boolean {
@@ -113,6 +114,7 @@ export class AuthenticationService {
/**
* Does kerberos enabled?
*
* @returns True if enabled, false otherwise
*/
isKerberosEnabled(): boolean {
@@ -121,6 +123,7 @@ export class AuthenticationService {
/**
* Does the provider support OAuth?
*
* @returns True if supported, false otherwise
*/
isOauth(): boolean {
@@ -133,6 +136,7 @@ export class AuthenticationService {
/**
* Does the provider support ECM?
*
* @returns True if supported, false otherwise
*/
isECMProvider(): boolean {
@@ -141,6 +145,7 @@ export class AuthenticationService {
/**
* Does the provider support BPM?
*
* @returns True if supported, false otherwise
*/
isBPMProvider(): boolean {
@@ -149,6 +154,7 @@ export class AuthenticationService {
/**
* Does the provider support both ECM and BPM?
*
* @returns True if both are supported, false otherwise
*/
isALLProvider(): boolean {
@@ -157,6 +163,7 @@ export class AuthenticationService {
/**
* Logs the user in.
*
* @param username Username for the login
* @param password Password for the login
* @param rememberMe Stores the user's login details if true
@@ -186,6 +193,7 @@ export class AuthenticationService {
/**
* Saves the "remember me" cookie as either a long-life cookie or a session cookie.
*
* @param rememberMe Enables a long-life cookie
*/
private saveRememberMeCookie(rememberMe: boolean): void {
@@ -202,6 +210,7 @@ export class AuthenticationService {
/**
* Checks whether the "remember me" cookie was set or not.
*
* @returns True if set, false otherwise
*/
isRememberMeSet(): boolean {
@@ -210,6 +219,7 @@ export class AuthenticationService {
/**
* Logs the user out.
*
* @returns Response event called when logout is complete
*/
logout() {
@@ -232,6 +242,7 @@ export class AuthenticationService {
/**
* Gets the ECM ticket stored in the Storage.
*
* @returns The ticket or `null` if none was found
*/
getTicketEcm(): string | null {
@@ -240,6 +251,7 @@ export class AuthenticationService {
/**
* Gets the BPM ticket stored in the Storage.
*
* @returns The ticket or `null` if none was found
*/
getTicketBpm(): string | null {
@@ -248,6 +260,7 @@ export class AuthenticationService {
/**
* Gets the BPM ticket from the Storage in Base 64 format.
*
* @returns The ticket or `null` if none was found
*/
getTicketEcmBase64(): string | null {
@@ -260,6 +273,7 @@ export class AuthenticationService {
/**
* Checks if the user is logged in on an ECM provider.
*
* @returns True if logged in, false otherwise
*/
isEcmLoggedIn(): boolean {
@@ -274,6 +288,7 @@ export class AuthenticationService {
/**
* Checks if the user is logged in on a BPM provider.
*
* @returns True if logged in, false otherwise
*/
isBpmLoggedIn(): boolean {
@@ -288,6 +303,7 @@ export class AuthenticationService {
/**
* Gets the ECM username.
*
* @returns The ECM username
*/
getEcmUsername(): string {
@@ -296,6 +312,7 @@ export class AuthenticationService {
/**
* Gets the BPM username
*
* @returns The BPM username
*/
getBpmUsername(): string {
@@ -303,6 +320,7 @@ export class AuthenticationService {
}
/** Sets the URL to redirect to after login.
*
* @param url URL to redirect to
*/
setRedirect(url: RedirectionModel) {
@@ -310,6 +328,7 @@ export class AuthenticationService {
}
/** Gets the URL to redirect to after login.
*
* @returns The redirect URL
*/
getRedirect(): string {
@@ -319,6 +338,7 @@ export class AuthenticationService {
/**
* Gets information about the user currently logged into APS.
*
* @returns User information
*/
getBpmLoggedUser(): Observable<UserRepresentation> {
@@ -335,6 +355,7 @@ export class AuthenticationService {
/**
* Prints an error message in the console browser
*
* @param error Error message
* @returns Object representing the error message
*/
@@ -345,6 +366,7 @@ export class AuthenticationService {
/**
* Gets the set of URLs that the token bearer is excluded from.
*
* @returns Array of URL strings
*/
getBearerExcludedUrls(): string[] {
@@ -353,6 +375,7 @@ export class AuthenticationService {
/**
* Gets the auth token.
*
* @returns Auth token string
*/
getToken(): string {
@@ -361,6 +384,7 @@ export class AuthenticationService {
/**
* Adds the auth token to an HTTP header using the 'bearer' scheme.
*
* @param headersArg Header that will receive the token
* @returns The new header with the token added
*/

View File

@@ -38,9 +38,7 @@ export class CoreAutomationService {
setup() {
const adfProxy = window['adf'] || {};
adfProxy.getConfigField = (field: string): any => {
return this.appConfigService.get(field);
};
adfProxy.getConfigField = (field: string): any => this.appConfigService.get(field);
adfProxy.setConfigField = (field: string, value: string) => {
this.appConfigService.config[field] = JSON.parse(value);
@@ -54,9 +52,7 @@ export class CoreAutomationService {
this.storageService.removeItem(key);
};
adfProxy.getStorageItem = (key: string): string => {
return this.storageService.getItem(key);
};
adfProxy.getStorageItem = (key: string): string => this.storageService.getItem(key);
adfProxy.setUserPreference = (key: string, data: any) => {
this.userPreferencesService.set(key, data);

View File

@@ -59,7 +59,7 @@ describe('Bpm user service', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify({
lastName: 'fake-last-name',

View File

@@ -21,7 +21,7 @@ import { AlfrescoApiService } from './alfresco-api.service';
import { LogService } from './log.service';
import { BpmUserModel } from '../models/bpm-user.model';
import { map, catchError } from 'rxjs/operators';
import { UserProfileApi, UserRepresentation } from '@alfresco/js-api';
import { UserProfileApi } from '@alfresco/js-api';
/**
*
@@ -33,7 +33,7 @@ import { UserProfileApi, UserRepresentation } from '@alfresco/js-api';
})
export class BpmUserService {
_profileApi: UserProfileApi;
private _profileApi: UserProfileApi;
get profileApi(): UserProfileApi {
this._profileApi = this._profileApi ?? new UserProfileApi(this.apiService.getInstance());
return this._profileApi;
@@ -45,30 +45,26 @@ export class BpmUserService {
/**
* Gets information about the current user.
*
* @returns User information object
*/
getCurrentUserInfo(): Observable<BpmUserModel> {
return from(this.profileApi.getProfile())
.pipe(
map((userRepresentation: UserRepresentation) => {
return new BpmUserModel(userRepresentation);
}),
map((userRepresentation) => new BpmUserModel(userRepresentation)),
catchError((err) => this.handleError(err))
);
}
/**
* Gets the current user's profile image as a URL.
*
* @returns URL string
*/
getCurrentUserProfileImage(): string {
return this.profileApi.getProfilePictureUrl();
}
/**
* Throw the error
* @param error
*/
private handleError(error: any) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console

View File

@@ -63,7 +63,7 @@ describe('Comment Content Service', () => {
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeContentComment)
});
@@ -81,7 +81,7 @@ describe('Comment Content Service', () => {
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeContentComments)
});

View File

@@ -40,6 +40,7 @@ export class CommentContentService {
/**
* Adds a comment to a node.
*
* @param nodeId ID of the target node
* @param message Text for the comment
* @returns Details of the comment added
@@ -47,20 +48,19 @@ export class CommentContentService {
addNodeComment(nodeId: string, message: string): Observable<CommentModel> {
return from(this.commentsApi.createComment(nodeId, { content: message }))
.pipe(
map((response: CommentEntry) => {
return new CommentModel({
id: response.entry.id,
message: response.entry.content,
created: response.entry.createdAt,
createdBy: response.entry.createdBy
});
}),
map((response: CommentEntry) => new CommentModel({
id: response.entry.id,
message: response.entry.content,
created: response.entry.createdAt,
createdBy: response.entry.createdBy
})),
catchError((err) => this.handleError(err))
);
}
/**
* Gets all comments that have been added to a node.
*
* @param nodeId ID of the target node
* @returns Details for each comment
*/

View File

@@ -113,7 +113,7 @@ describe('Comment ProcessService Service', () => {
it('should call service to add comment', () => {
service.addProcessInstanceComment(processId, message);
expect(addProcessInstanceComment).toHaveBeenCalledWith({
message: message
message
}, processId);
});
@@ -158,7 +158,7 @@ describe('Comment ProcessService Service', () => {
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify({
id: '111', message: 'fake-comment-message',
@@ -180,7 +180,7 @@ describe('Comment ProcessService Service', () => {
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeTasksComment)
});

View File

@@ -41,27 +41,27 @@ export class CommentProcessService {
/**
* Adds a comment to a task.
*
* @param taskId ID of the target task
* @param message Text for the comment
* @returns Details about the comment
*/
addTaskComment(taskId: string, message: string): Observable<CommentModel> {
return from(this.commentsApi.addTaskComment({ message: message }, taskId))
return from(this.commentsApi.addTaskComment({ message }, taskId))
.pipe(
map((response) => {
return new CommentModel({
id: response.id,
message: response.message,
created: response.created,
createdBy: response.createdBy
});
}),
map((response) => new CommentModel({
id: response.id,
message: response.message,
created: response.created,
createdBy: response.createdBy
})),
catchError((err: any) => this.handleError(err))
);
}
/**
* Gets all comments that have been added to a task.
*
* @param taskId ID of the target task
* @returns Details for each comment
*/
@@ -87,6 +87,7 @@ export class CommentProcessService {
/**
* Gets all comments that have been added to a process instance.
*
* @param processInstanceId ID of the target process instance
* @returns Details for each comment
*/
@@ -112,22 +113,21 @@ export class CommentProcessService {
/**
* Adds a comment to a process instance.
*
* @param processInstanceId ID of the target process instance
* @param message Text for the comment
* @returns Details of the comment added
*/
addProcessInstanceComment(processInstanceId: string, message: string): Observable<CommentModel> {
return from(
this.commentsApi.addProcessInstanceComment({ message: message }, processInstanceId)
this.commentsApi.addProcessInstanceComment({ message }, processInstanceId)
).pipe(
map((response) => {
return new CommentModel({
id: response.id,
message: response.message,
created: response.created,
createdBy: response.createdBy
});
}),
map((response) => new CommentModel({
id: response.id,
message: response.message,
created: response.created,
createdBy: response.createdBy
})),
catchError((err: any) => this.handleError(err))
);
}

View File

@@ -76,9 +76,9 @@ describe('ContentService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
});
@@ -91,9 +91,9 @@ describe('ContentService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 201,
status: 201,
contentType: 'application/json',
responseText: JSON.stringify({ 'entry': { 'id': 'fake-post-ticket', 'userId': 'admin' } })
responseText: JSON.stringify({ entry: { id: 'fake-post-ticket', userId: 'admin' } })
});
});

View File

@@ -71,12 +71,13 @@ export class ContentService {
/**
* Creates a trusted object URL from the Blob.
* WARNING: calling this method with untrusted user data exposes your application to XSS security risks!
*
* @param blob Data to wrap into object URL
* @returns URL string
*/
createTrustedUrl(blob: Blob): string {
const url = window.URL.createObjectURL(blob);
return <string> this.sanitizer.bypassSecurityTrustUrl(url);
return this.sanitizer.bypassSecurityTrustUrl(url) as string;
}
/**
@@ -93,6 +94,7 @@ export class ContentService {
/**
* Gets a content URL for the given node.
*
* @param node Node or Node ID to get URL for.
* @param attachment Toggles whether to retrieve content as an attachment for download
* @param ticket Custom ticket to use for authentication
@@ -116,6 +118,7 @@ export class ContentService {
/**
* Gets content for the given node.
*
* @param nodeId ID of the target node
* @returns Content data
*/
@@ -128,6 +131,7 @@ export class ContentService {
/**
* Gets a Node via its node ID.
*
* @param nodeId ID of the target node
* @param opts Options supported by JS-API
* @returns Details of the folder
@@ -138,6 +142,7 @@ export class ContentService {
/**
* Checks if the user has permission on that node
*
* @param node Node to check permissions
* @param permission Required permission type
* @param userId Optional current user id will be taken by default
@@ -172,6 +177,7 @@ export class ContentService {
/**
* Checks if the user has permissions on that node
*
* @param node Node to check allowableOperations
* @param allowableOperation Create, delete, update, updatePermissions, !create, !delete, !update, !updatePermissions
* @returns True if the user has the required permissions, false otherwise

View File

@@ -37,6 +37,7 @@ export class CookieService {
/**
* Checks if cookies are enabled.
*
* @returns True if enabled, false otherwise
*/
isEnabled(): boolean {
@@ -45,6 +46,7 @@ export class CookieService {
/**
* Retrieves a cookie by its key.
*
* @param key Key to identify the cookie
* @returns The cookie data or null if it is not found
*/
@@ -56,6 +58,7 @@ export class CookieService {
/**
* Sets a cookie.
*
* @param key Key to identify the cookie
* @param data Data value to set for the cookie
* @param expiration Expiration date of the data
@@ -69,6 +72,7 @@ export class CookieService {
/**
* Delete a cookie Key.
*
* @param key Key to identify the cookie
* @param path "Pathname" to store the cookie
*/

View File

@@ -48,6 +48,7 @@ export class DeletedNodesApiService {
/**
* Gets a list of nodes in the trash.
*
* @param options Options for JS-API call
* @returns List of nodes in the trash
*/

View File

@@ -17,6 +17,7 @@
import { DirectionalityConfigService } from '../services/directionality-config.service';
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function directionalityConfigFactory(directionalityConfigService: DirectionalityConfigService) {
return () => directionalityConfigService;
}

View File

@@ -36,7 +36,7 @@ export class DirectionalityConfigService {
.select('textOrientation')
.subscribe((direction: Direction) => {
renderer.setAttribute(this.document.body, 'dir', direction);
(<any> this.directionality).value = direction;
(this.directionality as any).value = direction;
});
}
}

View File

@@ -49,9 +49,10 @@ export class DiscoveryApiService {
/**
* Gets product information for Content Services.
*
* @returns ProductVersionModel containing product details
*/
public getEcmProductInfo(): Observable<RepositoryInfo> {
getEcmProductInfo(): Observable<RepositoryInfo> {
const discoveryApi = new DiscoveryApi(this.apiService.getInstance());
return from(discoveryApi.getRepositoryInformation())
@@ -63,9 +64,10 @@ export class DiscoveryApiService {
/**
* Gets product information for Process Services.
*
* @returns ProductVersionModel containing product details
*/
public getBpmProductInfo(): Observable<BpmProductVersionModel> {
getBpmProductInfo(): Observable<BpmProductVersionModel> {
const aboutApi = new AboutApi(this.apiService.getInstance());
return from(aboutApi.getAppVersion())
@@ -75,7 +77,7 @@ export class DiscoveryApiService {
);
}
public getBPMSystemProperties(): Observable<SystemPropertiesRepresentation> {
getBPMSystemProperties(): Observable<SystemPropertiesRepresentation> {
const systemPropertiesApi = new SystemPropertiesApi(this.apiService.getInstance());
return from(systemPropertiesApi.getProperties())

View File

@@ -27,7 +27,7 @@ import { catchError } from 'rxjs/operators';
})
export class DownloadZipService {
_downloadsApi: DownloadsApi;
private _downloadsApi: DownloadsApi;
get downloadsApi(): DownloadsApi {
this._downloadsApi = this._downloadsApi ?? new DownloadsApi(this.apiService.getInstance());
return this._downloadsApi;
@@ -39,6 +39,7 @@ export class DownloadZipService {
/**
* Creates a new download.
*
* @param payload Object containing the node IDs of the items to add to the ZIP file
* @returns Status object for the download
*/
@@ -50,6 +51,7 @@ export class DownloadZipService {
/**
* Gets status information for a download node.
*
* @param downloadId ID of the download node
* @returns Status object for the download
*/
@@ -59,6 +61,7 @@ export class DownloadZipService {
/**
* Cancels a download.
*
* @param downloadId ID of the target download node
*/
cancelDownload(downloadId: string) {

View File

@@ -28,6 +28,7 @@ describe('DownloadService', () => {
it('Should use native msSaveOrOpenBlob if the browser is IE', (done) => {
const navigatorAny: any = window.navigator;
// eslint-disable-next-line no-underscore-dangle
navigatorAny.__defineGetter__('msSaveOrOpenBlob', () => {
done();
});

View File

@@ -24,12 +24,12 @@ export class DownloadService {
private readonly saveData: any;
constructor() {
this.saveData = (function() {
this.saveData = (() => {
const a = document.createElement('a');
document.body.appendChild(a);
a.style.display = 'none';
return function(fileData, format, fileName) {
return (fileData, format, fileName) => {
let blob = null;
if (format === 'blob' || format === 'data') {
@@ -42,10 +42,8 @@ export class DownloadService {
}
if (blob) {
if (
typeof window.navigator !== 'undefined' &&
window.navigator['msSaveOrOpenBlob']
) {
if (typeof window.navigator !== 'undefined' &&
window.navigator['msSaveOrOpenBlob']) {
window.navigator['msSaveOrOpenBlob'](blob, fileName);
} else {
const url = window.URL.createObjectURL(blob);
@@ -62,6 +60,7 @@ export class DownloadService {
/**
* Invokes content download for a Blob with a file name.
*
* @param blob Content to download.
* @param fileName Name of the resulting file.
*/
@@ -71,6 +70,7 @@ export class DownloadService {
/**
* Invokes content download for a data array with a file name.
*
* @param data Data to download.
* @param fileName Name of the resulting file.
*/
@@ -80,6 +80,7 @@ export class DownloadService {
/**
* Invokes content download for a JSON object with a file name.
*
* @param json JSON object to download.
* @param fileName Name of the resulting file.
*/
@@ -89,6 +90,7 @@ export class DownloadService {
/**
* Invokes the download of the file by its URL address.
*
* @param url Url address pointing to the file.
* @param fileName Name of the file download.
*/

View File

@@ -33,6 +33,7 @@ export abstract class DynamicComponentMapper {
/**
* Gets the currently active DynamicComponentResolveFunction for a field type.
*
* @param type The type whose resolver you want
* @param defaultValue Default type returned for types that are not yet mapped
* @returns Resolver function
@@ -46,6 +47,7 @@ export abstract class DynamicComponentMapper {
/**
* Sets or optionally replaces a DynamicComponentResolveFunction for a field type.
*
* @param type The type whose resolver you want to set
* @param resolver The new resolver function
* @param override The new resolver will only replace an existing one if this parameter is true
@@ -80,6 +82,7 @@ export abstract class DynamicComponentMapper {
/**
* Finds the component type that is needed to render a form field.
*
* @param model Form field model for the field to render
* @param defaultValue Default type returned for field types that are not yet mapped.
* @returns Component type

View File

@@ -40,6 +40,7 @@ export class EcmUserService {
/**
* Gets information about a user identified by their username.
*
* @param userName Target username
* @returns User information
*/
@@ -52,6 +53,7 @@ export class EcmUserService {
/**
* Gets information about the user who is currently logged-in.
*
* @returns User information as for getUserInfo
*/
getCurrentUserInfo() {
@@ -60,6 +62,7 @@ export class EcmUserService {
/**
* Returns a profile image as a URL.
*
* @param avatarId Target avatar
* @returns Image URL
*/

View File

@@ -59,7 +59,7 @@ export class ExternalAlfrescoApiService {
provider: 'ECM',
hostEcm: ecmHost,
authType: 'BASIC',
contextRoot: contextRoot,
contextRoot,
domainPrefix
};
this.initAlfrescoApi(config);

View File

@@ -53,7 +53,7 @@ export class FavoritesApiService {
const entries: any[] = this
.remapFavoriteEntries(data?.list?.entries || []);
return <NodePaging> {
return {
list: { entries, pagination }
};
}
@@ -69,6 +69,7 @@ export class FavoritesApiService {
/**
* Gets the favorites for a user.
*
* @param personId ID of the user
* @param options Options supported by JS-API
* @returns List of favorites

View File

@@ -15,6 +15,4 @@
* limitations under the License.
*/
export function getType(type: any): any {
return () => type;
}
export const getType = (type: any): any => () => type;

View File

@@ -29,6 +29,7 @@ export class HighlightTransformService {
/**
* Searches for `search` string(s) within `text` and highlights all occurrences.
*
* @param text Text to search within
* @param search Text pattern to search for
* @param wrapperClass CSS class used to provide highlighting style
@@ -40,9 +41,7 @@ export class HighlightTransformService {
if (search && text) {
let pattern = search.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
pattern = pattern.split(' ').filter((t) => {
return t.length > 0;
}).join('|');
pattern = pattern.split(' ').filter((t) => t.length > 0).join('|');
const regex = new RegExp(pattern, 'gi');
result = text.replace(/<[^>]+>/g, '').replace(regex, (match) => {

View File

@@ -19,8 +19,6 @@ import { fakeAsync, TestBed } from '@angular/core/testing';
import { setupTestBed } from '../testing/setup-test-bed';
import { AlfrescoApiService } from './alfresco-api.service';
import { IdentityGroupService } from './identity-group.service';
import { IdentityGroupSearchParam } from '../models/identity-group.model';
import { HttpErrorResponse } from '@angular/common/http';
import { throwError, of } from 'rxjs';
import {
@@ -59,7 +57,7 @@ describe('IdentityGroupService', () => {
it('should be able to fetch groups based on group name', (done) => {
spyOn(apiService, 'getInstance').and.returnValue(groupsMockApi);
service.findGroupsByName(<IdentityGroupSearchParam> {name: 'mock'}).subscribe((res) => {
service.findGroupsByName({name: 'mock'}).subscribe((res) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(5);

View File

@@ -44,6 +44,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Gets all groups.
*
* @returns Array of group information objects
*/
getGroups(): Observable<IdentityGroupModel[]> {
@@ -53,6 +54,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Gets available roles
*
* @param groupId Id of the group.
* @returns Array of available roles information objects
*/
@@ -63,6 +65,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Gets assigned roles
*
* @param groupId Id of the group.
* @returns Array of available roles
*/
@@ -73,6 +76,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Assigns roles to the group
*
* @param groupId The ID of the group
* @param roles Array of roles to assign
*/
@@ -85,6 +89,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Removes roles from the group
*
* @param groupId The ID of the group
* @param roles Array of roles to remove
*/
@@ -97,6 +102,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Get effective roles
*
* @param groupId Id of the group
* @returns Array of effective roles
*/
@@ -107,6 +113,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Queries groups.
*
* @returns Array of user information objects
*/
queryGroups(requestQuery: IdentityGroupQueryCloudRequestModel): Observable<IdentityGroupQueryResponse> {
@@ -116,24 +123,23 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
return this.getTotalGroupsCount().pipe(
switchMap((totalCount: IdentityGroupCountModel) =>
this.oAuth2Service.get<any[]>({ url, queryParams }).pipe(
map((response) => {
return <IdentityGroupQueryResponse> {
entries: response,
pagination: {
skipCount: requestQuery.first,
maxItems: requestQuery.max,
count: totalCount.count,
hasMoreItems: false,
totalItems: totalCount.count
}
};
})
map((response) => ({
entries: response,
pagination: {
skipCount: requestQuery.first,
maxItems: requestQuery.max,
count: totalCount.count,
hasMoreItems: false,
totalItems: totalCount.count
}
} as IdentityGroupQueryResponse))
))
);
}
/**
* Gets groups total count.
*
* @returns Number of groups count.
*/
getTotalGroupsCount(): Observable<IdentityGroupCountModel> {
@@ -143,6 +149,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Creates new group.
*
* @param newGroup Object of containing the new group details.
* @returns Empty response when the group created.
*/
@@ -155,6 +162,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Updates group details.
*
* @param groupId Id of the targeted group.
* @param updatedGroup Object of containing the group details
* @returns Empty response when the group updated.
@@ -168,6 +176,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Deletes Group.
*
* @param groupId Id of the group.
* @returns Empty response when the group deleted.
*/
@@ -178,6 +187,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Finds groups filtered by name.
*
* @param searchParams Object containing the name filter string
* @returns List of group information
*/
@@ -193,6 +203,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Gets details for a specified group.
*
* @param groupId Id of the target group
* @returns Group details
*/
@@ -203,6 +214,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Check that a group has one or more roles from the supplied list.
*
* @param groupId Id of the target group
* @param roleNames Array of role names
* @returns True if the group has one or more of the roles, false otherwise
@@ -225,6 +237,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Gets the client Id using the app name.
*
* @param applicationName Name of the app
* @returns client Id string
*/
@@ -239,6 +252,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Gets client roles.
*
* @param groupId Id of the target group
* @param clientId Id of the client
* @returns List of roles
@@ -250,6 +264,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Checks if a group has a client app.
*
* @param groupId Id of the target group
* @param clientId Id of the client
* @returns True if the group has the client app, false otherwise
@@ -262,6 +277,7 @@ export class IdentityGroupService implements IdentityGroupServiceInterface {
/**
* Check if a group has any of the client app roles in the supplied list.
*
* @param groupId Id of the target group
* @param clientId Id of the client
* @param roleNames Array of role names to check

View File

@@ -21,19 +21,19 @@ import { TestBed } from '@angular/core/testing';
import { of, throwError } from 'rxjs';
import { IdentityRoleResponseModel, IdentityRoleService } from './identity-role.service';
export let mockIdentityRole1 = {
export const mockIdentityRole1 = {
id: 'mock-id-1', name: 'Mock_Role_1', description: 'Mock desc1', clientRole: true, composite: false
};
export let mockIdentityRole2 = {
export const mockIdentityRole2 = {
id: 'mock-id-2', name: 'Mock_Role_2', description: 'Mock desc2', clientRole: false, composite: true
};
export let mockIdentityRole3 = {
export const mockIdentityRole3 = {
id: 'mock-id-3', name: 'Mock_Role_3', description: 'Mock desc3', clientRole: false, composite: false
};
export let mockIdentityRoles = {
export const mockIdentityRoles = {
entries: [
mockIdentityRole1, mockIdentityRole2, mockIdentityRole3
],
@@ -73,8 +73,8 @@ describe('IdentityRoleService', () => {
it('should be able to add role', (done) => {
const response = new HttpResponse({
body: [],
'status': 201,
'statusText': 'Created'
status: 201,
statusText: 'Created'
});
spyOn(service, 'addRole').and.returnValue(of(response));
service.addRole(mockIdentityRole1).subscribe(
@@ -107,8 +107,8 @@ describe('IdentityRoleService', () => {
it('should be able to delete role', (done) => {
const response = new HttpResponse({
body: [],
'status': 204,
'statusText': 'No Content'
status: 204,
statusText: 'No Content'
});
spyOn(service, 'deleteRole').and.returnValue(of(response));
service.deleteRole(mockIdentityRole1).subscribe(

View File

@@ -47,6 +47,7 @@ export class IdentityRoleService {
/**
* Ret all roles
*
* @returns List of roles
*/
getRoles(
@@ -54,9 +55,7 @@ export class IdentityRoleService {
size: number = 5
): Observable<IdentityRoleResponseModel> {
return this.http.get<any>(`${this.identityHost}/roles`).pipe(
map(res => {
return this.preparePaginationWithRoles(res, skipCount, size);
}),
map(res => this.preparePaginationWithRoles(res, skipCount, size)),
catchError(error => this.handleError(error))
);
}
@@ -69,7 +68,7 @@ export class IdentityRoleService {
return {
entries: roles.slice(skipCount, skipCount + size),
pagination: {
skipCount: skipCount,
skipCount,
maxItems: size,
count: roles.length,
hasMoreItems: false,
@@ -80,6 +79,7 @@ export class IdentityRoleService {
/**
* Add new role
*
* @param newRole Role model
* @returns Server result payload
*/
@@ -95,6 +95,7 @@ export class IdentityRoleService {
/**
* Delete existing role
*
* @param deletedRole Role model
* @returns Server result payload
*/
@@ -106,6 +107,7 @@ export class IdentityRoleService {
/**
* Update existing role
*
* @param updatedRole Role model
* @param roleId Role id
* @returns Server result payload

View File

@@ -76,12 +76,8 @@ describe('IdentityUserService', () => {
beforeEach(() => {
const store = {};
spyOn(localStorage, 'getItem').and.callFake( (key: string): string => {
return store[key] || null;
});
spyOn(localStorage, 'setItem').and.callFake((key: string, value: string): string => {
return store[key] = <string> value;
});
spyOn(localStorage, 'getItem').and.callFake( (key: string): string => store[key] || null);
spyOn(localStorage, 'setItem').and.callFake((key: string, value: string): string => store[key] = value);
});
it('should fetch identity user info from Jwt id token', () => {

View File

@@ -46,6 +46,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets the name and other basic details of the current user.
*
* @returns The user's details
*/
getCurrentUserInfo(): IdentityUserModel {
@@ -53,11 +54,12 @@ export class IdentityUserService implements IdentityUserServiceInterface {
const givenName = this.jwtHelperService.getValueFromLocalToken<string>(JwtHelperService.GIVEN_NAME);
const email = this.jwtHelperService.getValueFromLocalToken<string>(JwtHelperService.USER_EMAIL);
const username = this.jwtHelperService.getValueFromLocalToken<string>(JwtHelperService.USER_PREFERRED_USERNAME);
return { firstName: givenName, lastName: familyName, email: email, username: username };
return { firstName: givenName, lastName: familyName, email, username };
}
/**
* Find users based on search input.
*
* @param search Search query string
* @returns List of users
*/
@@ -66,13 +68,14 @@ export class IdentityUserService implements IdentityUserServiceInterface {
return of([]);
}
const url = this.buildUserUrl();
const queryParams = { search: search };
const queryParams = { search };
return this.oAuth2Service.get({ url, queryParams });
}
/**
* Find users based on username input.
*
* @param username Search query string
* @returns List of users
*/
@@ -81,13 +84,14 @@ export class IdentityUserService implements IdentityUserServiceInterface {
return of([]);
}
const url = this.buildUserUrl();
const queryParams = { username: username };
const queryParams = { username };
return this.oAuth2Service.get({url, queryParams });
}
/**
* Find users based on email input.
*
* @param email Search query string
* @returns List of users
*/
@@ -96,13 +100,14 @@ export class IdentityUserService implements IdentityUserServiceInterface {
return of([]);
}
const url = this.buildUserUrl();
const queryParams = { email: email };
const queryParams = { email };
return this.oAuth2Service.get({ url, queryParams });
}
/**
* Find users based on id input.
*
* @param id Search query string
* @returns users object
*/
@@ -116,6 +121,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Get client roles of a user for a particular client.
*
* @param userId ID of the target user
* @param clientId ID of the client app
* @returns List of client roles
@@ -127,6 +133,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Checks whether user has access to a client app.
*
* @param userId ID of the target user
* @param clientId ID of the client app
* @returns True if the user has access, false otherwise
@@ -139,6 +146,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Checks whether a user has any of the client app roles.
*
* @param userId ID of the target user
* @param clientId ID of the client app
* @param roleNames List of role names to check for
@@ -165,6 +173,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets the client ID for an application.
*
* @param applicationName Name of the application
* @returns Client ID string
*/
@@ -181,20 +190,20 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Checks if a user has access to an application.
*
* @param userId ID of the user
* @param applicationName Name of the application
* @returns True if the user has access, false otherwise
*/
checkUserHasApplicationAccess(userId: string, applicationName: string): Observable<boolean> {
return this.getClientIdByApplicationName(applicationName).pipe(
switchMap((clientId: string) => {
return this.checkUserHasClientApp(userId, clientId);
})
switchMap((clientId: string) => this.checkUserHasClientApp(userId, clientId))
);
}
/**
* Checks if a user has any application role.
*
* @param userId ID of the target user
* @param applicationName Name of the application
* @param roleNames List of role names to check for
@@ -202,14 +211,13 @@ export class IdentityUserService implements IdentityUserServiceInterface {
*/
checkUserHasAnyApplicationRole(userId: string, applicationName: string, roleNames: string[]): Observable<boolean> {
return this.getClientIdByApplicationName(applicationName).pipe(
switchMap((clientId: string) => {
return this.checkUserHasAnyClientAppRole(userId, clientId, roleNames);
})
switchMap((clientId: string) => this.checkUserHasAnyClientAppRole(userId, clientId, roleNames))
);
}
/**
* Gets details for all users.
*
* @returns Array of user info objects
*/
getUsers(): Observable<IdentityUserModel[]> {
@@ -219,6 +227,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets a list of roles for a user.
*
* @param userId ID of the user
* @returns Array of role info objects
*/
@@ -229,6 +238,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets an array of users (including the current user) who have any of the roles in the supplied list.
*
* @param roleNames List of role names to look for
* @returns Array of user info objects
*/
@@ -250,6 +260,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets an array of users (not including the current user) who have any of the roles in the supplied list.
*
* @param roleNames List of role names to look for
* @returns Array of user info objects
*/
@@ -275,9 +286,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
private async userHasAnyRole(userId: string, roleNames: string[]): Promise<boolean> {
const userRoles = await this.getUserRoles(userId).toPromise();
const hasAnyRole = roleNames.some((roleName) => {
const filteredRoles = userRoles.filter((userRole) => {
return userRole.name.toLocaleLowerCase() === roleName.toLocaleLowerCase();
});
const filteredRoles = userRoles.filter((userRole) => userRole.name.toLocaleLowerCase() === roleName.toLocaleLowerCase());
return filteredRoles.length > 0;
});
@@ -287,6 +296,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Checks if a user has one of the roles from a list.
*
* @param userId ID of the target user
* @param roleNames Array of roles to check for
* @returns True if the user has one of the roles, false otherwise
@@ -309,6 +319,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets details for all users.
*
* @returns Array of user information objects.
*/
queryUsers(requestQuery: IdentityUserQueryCloudRequestModel): Observable<IdentityUserQueryResponse> {
@@ -318,18 +329,16 @@ export class IdentityUserService implements IdentityUserServiceInterface {
return this.getTotalUsersCount().pipe(
switchMap((totalCount) =>
this.oAuth2Service.get<IdentityUserModel[]>({ url, queryParams }).pipe(
map((response) => {
return <IdentityUserQueryResponse> {
entries: response,
pagination: {
skipCount: requestQuery.first,
maxItems: requestQuery.max,
count: totalCount,
hasMoreItems: false,
totalItems: totalCount
}
};
})
map((response) => ({
entries: response,
pagination: {
skipCount: requestQuery.first,
maxItems: requestQuery.max,
count: totalCount,
hasMoreItems: false,
totalItems: totalCount
}
} as IdentityUserQueryResponse))
)
)
);
@@ -337,6 +346,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets users total count.
*
* @returns Number of users count.
*/
getTotalUsersCount(): Observable<number> {
@@ -346,6 +356,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Creates new user.
*
* @param newUser Object containing the new user details.
* @returns Empty response when the user created.
*/
@@ -358,6 +369,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Updates user details.
*
* @param userId Id of the user.
* @param updatedUser Object containing the user details.
* @returns Empty response when the user updated.
@@ -371,6 +383,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Deletes User.
*
* @param userId Id of the user.
* @returns Empty response when the user deleted.
*/
@@ -381,6 +394,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Changes user password.
*
* @param userId Id of the user.
* @param credentials Details of user Credentials.
* @returns Empty response when the password changed.
@@ -394,6 +408,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets involved groups.
*
* @param userId Id of the user.
* @returns Array of involved groups information objects.
*/
@@ -406,6 +421,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Joins group.
*
* @param joinGroupRequest Details of join group request (IdentityJoinGroupRequestModel).
* @returns Empty response when the user joined the group.
*/
@@ -418,6 +434,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Leaves group.
*
* @param userId Id of the user.
* @param groupId Id of the group.
* @returns Empty response when the user left the group.
@@ -429,6 +446,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets available roles
*
* @param userId Id of the user.
* @returns Array of available roles information objects
*/
@@ -439,6 +457,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets assigned roles.
*
* @param userId Id of the user.
* @returns Array of assigned roles information objects
*/
@@ -451,6 +470,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Gets effective roles.
*
* @param userId Id of the user.
* @returns Array of composite roles information objects
*/
@@ -463,6 +483,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Assigns roles to the user.
*
* @param userId Id of the user.
* @param roles Array of roles.
* @returns Empty response when the role assigned.
@@ -476,6 +497,7 @@ export class IdentityUserService implements IdentityUserServiceInterface {
/**
* Removes assigned roles.
*
* @param userId Id of the user.
* @param roles Array of roles.
* @returns Empty response when the role removed.

View File

@@ -52,7 +52,7 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{
'realm_access': { roles: ['role1'] }
realm_access: { roles: ['role1'] }
});
const result = jwtHelperService.hasRealmRole('role1');
@@ -64,7 +64,7 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{
'realm_access': { roles: ['role1'] }
realm_access: { roles: ['role1'] }
});
const result = jwtHelperService.hasRealmRoles(['role1', 'role2']);
@@ -75,7 +75,7 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{
'realm_access': { roles: ['role3'] }
realm_access: { roles: ['role3'] }
});
const result = jwtHelperService.hasRealmRole('role1');
expect(result).toBeFalsy();
@@ -85,7 +85,7 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{
'realm_access': { roles: ['role1'] }
realm_access: { roles: ['role1'] }
});
const result = jwtHelperService.hasRealmRoles(['role3', 'role2']);
expect(result).toBeFalsy();
@@ -99,7 +99,7 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{
'resource_access': { fakeapp: { roles: ['role1'] } }
resource_access: { fakeapp: { roles: ['role1'] } }
});
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1']);
@@ -111,7 +111,7 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{
'resource_access': { fakeapp: { roles: ['role1'] } }
resource_access: { fakeapp: { roles: ['role1'] } }
});
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']);
@@ -122,7 +122,7 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{
'resource_access': { fakeapp: { roles: ['role3'] } }
resource_access: { fakeapp: { roles: ['role3'] } }
});
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']);
expect(result).toBeFalsy();
@@ -132,7 +132,7 @@ describe('JwtHelperService', () => {
spyOn(jwtHelperService, 'getAccessToken').and.returnValue('my-access_token');
spyOn(jwtHelperService, 'decodeToken').and.returnValue(
{
'resource_access': { anotherfakeapp: { roles: ['role1'] } }
resource_access: { anotherfakeapp: { roles: ['role1'] } }
});
const result = jwtHelperService.hasRealmRolesForClientRole('fakeapp', ['role1', 'role2']);
expect(result).toBeFalsy();

View File

@@ -38,6 +38,7 @@ export class JwtHelperService {
/**
* Decodes a JSON web token into a JS object.
*
* @param token Token in encoded form
* @returns Decoded token data object
*/
@@ -79,6 +80,7 @@ export class JwtHelperService {
/**
* Gets a named value from the user access or id token.
*
* @param key Key name of the field to retrieve
* @returns Value from the token
*/
@@ -88,6 +90,7 @@ export class JwtHelperService {
/**
* Gets a named value from the user access token.
*
* @param key Key name of the field to retrieve
* @returns Value from the token
*/
@@ -97,6 +100,7 @@ export class JwtHelperService {
/**
* Gets access token
*
* @returns access token
*/
getAccessToken(): string {
@@ -105,6 +109,7 @@ export class JwtHelperService {
/**
* Gets a named value from the user id token.
*
* @param key Key name of the field to retrieve
* @returns Value from the token
*/
@@ -114,6 +119,7 @@ export class JwtHelperService {
/**
* Gets id token
*
* @returns id token
*/
getIdToken(): string {
@@ -122,6 +128,7 @@ export class JwtHelperService {
/**
* Gets a named value from the user access token.
*
* @param accessToken your SSO access token where the value is encode
* @param key Key name of the field to retrieve
* @returns Value from the token
@@ -132,11 +139,12 @@ export class JwtHelperService {
const tokenPayload = this.decodeToken(token);
value = tokenPayload[key];
}
return <T> value;
return value;
}
/**
* Gets realm roles.
*
* @returns Array of realm roles
*/
getRealmRoles(): string[] {
@@ -146,6 +154,7 @@ export class JwtHelperService {
/**
* Gets Client roles.
*
* @returns Array of client roles
*/
getClientRoles(clientName: string): string[] {
@@ -155,6 +164,7 @@ export class JwtHelperService {
/**
* Checks for single realm role.
*
* @param role Role name to check
* @returns True if it contains given role, false otherwise
*/
@@ -162,38 +172,35 @@ export class JwtHelperService {
let hasRole = false;
if (this.getAccessToken()) {
const realmRoles = this.getRealmRoles();
hasRole = realmRoles.some((currentRole) => {
return currentRole === role;
});
hasRole = realmRoles.some((currentRole) => currentRole === role);
}
return hasRole;
}
/**
* Checks for realm roles.
*
* @param rolesToCheck List of role names to check
* @returns True if it contains at least one of the given roles, false otherwise
*/
hasRealmRoles(rolesToCheck: string []): boolean {
return rolesToCheck.some((currentRole) => {
return this.hasRealmRole(currentRole);
});
return rolesToCheck.some((currentRole) => this.hasRealmRole(currentRole));
}
/**
* Checks for client roles.
*
* @param clientName Targeted client name
* @param rolesToCheck List of role names to check
* @returns True if it contains at least one of the given roles, false otherwise
*/
hasRealmRolesForClientRole(clientName: string, rolesToCheck: string []): boolean {
return rolesToCheck.some((currentRole) => {
return this.hasClientRole(clientName, currentRole);
});
return rolesToCheck.some((currentRole) => this.hasClientRole(clientName, currentRole));
}
/**
* Checks for client role.
*
* @param clientName Targeted client name
* @param role Role name to check
* @returns True if it contains given role, false otherwise
@@ -202,9 +209,7 @@ export class JwtHelperService {
let hasRole = false;
if (this.getAccessToken()) {
const clientRoles = this.getClientRoles(clientName);
hasRole = clientRoles.some((currentRole) => {
return currentRole === role;
});
hasRole = clientRoles.some((currentRole) => currentRole === role);
}
return hasRole;
}

View File

@@ -25,23 +25,23 @@ import { UserPreferencesService } from './user-preferences.service';
export class LanguageService {
private languages = new BehaviorSubject<LanguageItem[]>([
{'key': 'de', 'label': 'Deutsch'},
{'key': 'en', 'label': 'English'},
{'key': 'es', 'label': 'Español'},
{'key': 'fr', 'label': 'Français'},
{'key': 'it', 'label': 'Italiano'},
{'key': 'ja', 'label': '日本語'},
{'key': 'nb', 'label': 'Bokmål'},
{'key': 'nl', 'label': 'Nederlands'},
{'key': 'pt-BR', 'label': 'Português (Brasil)'},
{'key': 'ru', 'label': 'Русский'},
{'key': 'zh-CN', 'label': '中文简体'},
{'key': 'cs', 'label': 'Čeština'},
{'key': 'da', 'label': 'Dansk'},
{'key': 'fi', 'label': 'Suomi'},
{'key': 'pl', 'label': 'Polski'},
{'key': 'sv', 'label': 'Svenska'},
{'key': 'ar', 'label': 'العربية', direction: 'rtl'}
{key: 'de', label: 'Deutsch'},
{key: 'en', label: 'English'},
{key: 'es', label: 'Español'},
{key: 'fr', label: 'Français'},
{key: 'it', label: 'Italiano'},
{key: 'ja', label: '日本語'},
{key: 'nb', label: 'Bokmål'},
{key: 'nl', label: 'Nederlands'},
{key: 'pt-BR', label: 'Português (Brasil)'},
{key: 'ru', label: 'Русский'},
{key: 'zh-CN', label: '中文简体'},
{key: 'cs', label: 'Čeština'},
{key: 'da', label: 'Dansk'},
{key: 'fi', label: 'Suomi'},
{key: 'pl', label: 'Polski'},
{key: 'sv', label: 'Svenska'},
{key: 'ar', label: 'العربية', direction: 'rtl'}
]);
languages$ = this.languages.asObservable();

View File

@@ -29,9 +29,9 @@ describe('PeopleProcessService', () => {
let service: LockService;
let apiService: AlfrescoApiService;
const fakeNodeUnlocked: Node = <Node> { name: 'unlocked', isLocked: false, isFile: true };
const fakeFolderNode: Node = <Node> { name: 'unlocked', isLocked: false, isFile: false, isFolder: true };
const fakeNodeNoProperty: Node = <Node> { name: 'unlocked', isLocked: true, isFile: true, properties: {} };
const fakeNodeUnlocked: Node = { name: 'unlocked', isLocked: false, isFile: true } as Node;
const fakeFolderNode: Node = { name: 'unlocked', isLocked: false, isFile: false, isFolder: true } as Node;
const fakeNodeNoProperty: Node = { name: 'unlocked', isLocked: true, isFile: true, properties: {} } as Node;
setupTestBed({
imports: [
@@ -58,7 +58,7 @@ describe('PeopleProcessService', () => {
});
describe('When the lock is readonly', () => {
const nodeReadonly: Node = <Node> {
const nodeReadonly: Node = {
name: 'readonly-lock-node',
isLocked: true,
isFile: true,
@@ -67,9 +67,9 @@ describe('PeopleProcessService', () => {
'cm:lockType': 'READ_ONLY_LOCK',
'cm:lockLifetime': 'PERSISTENT'
}
};
} as Node;
const nodeReadOnlyWithExpiredDate: Node = <Node> {
const nodeReadOnlyWithExpiredDate: Node = {
name: 'readonly-lock-node',
isLocked: true,
isFile: true,
@@ -80,9 +80,9 @@ describe('PeopleProcessService', () => {
'cm:lockOwner': { id: 'lock-owner-user' },
'cm:expiryDate': moment().subtract(4, 'days')
}
};
} as Node;
const nodeReadOnlyWithActiveExpiration: Node = <Node> {
const nodeReadOnlyWithActiveExpiration: Node = {
name: 'readonly-lock-node',
isLocked: true,
isFile: true,
@@ -93,7 +93,7 @@ describe('PeopleProcessService', () => {
'cm:lockOwner': { id: 'lock-owner-user' },
'cm:expiryDate': moment().add(4, 'days')
}
};
} as Node;
it('should return true when readonly lock is active', () => {
expect(service.isLocked(nodeReadonly)).toBeTruthy();
@@ -109,7 +109,7 @@ describe('PeopleProcessService', () => {
});
describe('When only the lock owner is allowed', () => {
const nodeOwnerAllowedLock: Node = <Node> {
const nodeOwnerAllowedLock: Node = {
name: 'readonly-lock-node',
isLocked: true,
isFile: true,
@@ -119,9 +119,9 @@ describe('PeopleProcessService', () => {
'cm:lockLifetime': 'PERSISTENT',
'cm:lockOwner': { id: 'lock-owner-user' }
}
};
} as Node;
const nodeOwnerAllowedLockWithExpiredDate: Node = <Node> {
const nodeOwnerAllowedLockWithExpiredDate: Node = {
name: 'readonly-lock-node',
isLocked: true,
isFile: true,
@@ -132,9 +132,9 @@ describe('PeopleProcessService', () => {
'cm:lockOwner': { id: 'lock-owner-user' },
'cm:expiryDate': moment().subtract(4, 'days')
}
};
} as Node;
const nodeOwnerAllowedLockWithActiveExpiration: Node = <Node> {
const nodeOwnerAllowedLockWithActiveExpiration: Node = {
name: 'readonly-lock-node',
isLocked: true,
isFile: true,
@@ -145,7 +145,7 @@ describe('PeopleProcessService', () => {
'cm:lockOwner': { id: 'lock-owner-user' },
'cm:expiryDate': moment().add(4, 'days')
}
};
} as Node;
it('should return false when the user is the lock owner', () => {
spyOn(apiService.getInstance(), 'getEcmUsername').and.returnValue('lock-owner-user');

View File

@@ -45,6 +45,7 @@ export class LogService {
/**
* Logs a message at the "ERROR" level.
*
* @param message Message to log
* @param optionalParams Interpolation values for the message in "printf" format
*/
@@ -59,6 +60,7 @@ export class LogService {
/**
* Logs a message at the "DEBUG" level.
*
* @param message Message to log
* @param optionalParams Interpolation values for the message in "printf" format
*/
@@ -73,6 +75,7 @@ export class LogService {
/**
* Logs a message at the "INFO" level.
*
* @param message Message to log
* @param optionalParams Interpolation values for the message in "printf" format
*/
@@ -87,6 +90,7 @@ export class LogService {
/**
* Logs a message at any level from "TRACE" upwards.
*
* @param message Message to log
* @param optionalParams Interpolation values for the message in "printf" format
*/
@@ -101,6 +105,7 @@ export class LogService {
/**
* Logs a message at the "TRACE" level.
*
* @param message Message to log
* @param optionalParams Interpolation values for the message in "printf" format
*/
@@ -115,6 +120,7 @@ export class LogService {
/**
* Logs a message at the "WARN" level.
*
* @param message Message to log
* @param optionalParams Interpolation values for the message in "printf" format
*/
@@ -129,6 +135,7 @@ export class LogService {
/**
* Logs a message if a boolean test fails.
*
* @param test Test value (typically a boolean expression)
* @param message Message to show if test is false
* @param optionalParams Interpolation values for the message in "printf" format
@@ -144,6 +151,7 @@ export class LogService {
/**
* Starts an indented group of log messages.
*
* @param groupTitle Title shown at the start of the group
* @param optionalParams Interpolation values for the title in "printf" format
*/
@@ -164,23 +172,23 @@ export class LogService {
/**
* Converts a log level name string into its numeric equivalent.
*
* @param level Level name
* @returns Numeric log level
*/
getLogLevel(level: string): LogLevelsEnum {
const referencedLevel = logLevels.find((currentLevel: any) => {
return currentLevel.name.toLocaleLowerCase() === level.toLocaleLowerCase();
});
const referencedLevel = logLevels.find((currentLevel: any) => currentLevel.name.toLocaleLowerCase() === level.toLocaleLowerCase());
return referencedLevel ? referencedLevel.level : 5;
}
/**
* Triggers notification callback for log messages.
*
* @param text Message text
* @param logLevel Log level for the message
*/
messageBus(text: string, logLevel: string) {
this.onMessage.next({ text: text, type: logLevel });
this.onMessage.next({ text, type: logLevel });
}
}

View File

@@ -31,6 +31,7 @@ export class LoginDialogService {
/**
* Opens a dialog to choose a file to upload.
*
* @param actionName Name of the action to show in the title
* @param title Title for the dialog
* @returns Information about the chosen file(s)

View File

@@ -50,6 +50,7 @@ export class NodesApiService {
/**
* Gets the stored information about a node.
*
* @param nodeId ID of the target node
* @param options Optional parameters supported by JS-API
* @returns Node information
@@ -68,6 +69,7 @@ export class NodesApiService {
/**
* Gets the items contained in a folder node.
*
* @param nodeId ID of the target node
* @param options Optional parameters supported by JS-API
* @returns List of child items from the folder
@@ -87,6 +89,7 @@ export class NodesApiService {
/**
* Creates a new document node inside a folder.
*
* @param parentNodeId ID of the parent folder node
* @param nodeBody Data for the new node
* @param options Optional parameters supported by JS-API
@@ -101,6 +104,7 @@ export class NodesApiService {
/**
* Creates a new folder node inside a parent folder.
*
* @param parentNodeId ID of the parent folder node
* @param nodeBody Data for the new folder
* @param options Optional parameters supported by JS-API
@@ -113,6 +117,7 @@ export class NodesApiService {
/**
* Updates the information about a node.
*
* @param nodeId ID of the target node
* @param nodeBody New data for the node
* @param options Optional parameters supported by JS-API
@@ -132,6 +137,7 @@ export class NodesApiService {
/**
* Moves a node to the trashcan.
*
* @param nodeId ID of the target node
* @param options Optional parameters supported by JS-API
* @returns Empty result that notifies when the deletion is complete
@@ -144,6 +150,7 @@ export class NodesApiService {
/**
* Restores a node previously moved to the trashcan.
*
* @param nodeId ID of the node to restore
* @returns Details of the restored node
*/
@@ -156,6 +163,7 @@ export class NodesApiService {
/**
* Get the metadata and the nodeType for a nodeId cleaned by the prefix.
*
* @param nodeId ID of the target node
* @returns Node metadata
*/
@@ -166,6 +174,7 @@ export class NodesApiService {
/**
* Create a new Node from form metadata.
*
* @param path Path to the node
* @param nodeType Node type
* @param name Node name
@@ -186,6 +195,7 @@ export class NodesApiService {
/**
* Create a new Node inside `-root-` folder
*
* @param name Node name
* @param nodeType Node type
* @param properties Node body properties
@@ -194,16 +204,16 @@ export class NodesApiService {
*/
public createNodeInsideRoot(name: string, nodeType: string, properties: any, path: string): Observable<NodeEntry> {
const body = {
name: name,
nodeType: nodeType,
properties: properties,
name,
nodeType,
properties,
relativePath: path
};
return from(this.nodesApi.createNode('-root-', body, {}));
}
private generateUuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);

View File

@@ -38,6 +38,7 @@ export class PageTitleService {
/**
* Sets the page title.
*
* @param value The new title
*/
setTitle(value: string = '') {

View File

@@ -23,6 +23,7 @@ import { PersonEntry, PeopleApi, PersonBodyCreate, Pagination, PersonBodyUpdate
import { EcmUserModel } from '../models/ecm-user.model';
import { LogService } from './log.service';
// eslint-disable-next-line no-shadow
export enum ContentGroups {
ALFRESCO_ADMINISTRATORS = 'ALFRESCO_ADMINISTRATORS'
}
@@ -50,7 +51,7 @@ export class PeopleContentService {
private hasContentAdminRole: boolean = false;
hasCheckedIsContentAdmin: boolean = false;
_peopleApi: PeopleApi;
private _peopleApi: PeopleApi;
get peopleApi(): PeopleApi {
this._peopleApi = this._peopleApi ?? new PeopleApi(this.apiService.getInstance());
return this._peopleApi;
@@ -61,6 +62,7 @@ export class PeopleContentService {
/**
* Gets information about a user identified by their username.
*
* @param personId ID of the target user
* @returns User information
*/
@@ -74,6 +76,7 @@ export class PeopleContentService {
/**
* Gets information about the user who is currently logged in.
*
* @returns User information
*/
getCurrentPerson(): Observable<any> {
@@ -82,6 +85,7 @@ export class PeopleContentService {
/**
* Gets a list of people.
*
* @param requestQuery maxItems and skipCount parameters supported by JS-API
* @returns Response containing pagination and list of entries
*/
@@ -94,31 +98,31 @@ export class PeopleContentService {
const promise = this.peopleApi.listPeople(requestQueryParams);
return from(promise).pipe(
map(response => {
return {
pagination: response.list.pagination,
entries: response.list.entries.map((person: PersonEntry) => <EcmUserModel> person.entry)
};
}),
map(response => ({
pagination: response.list.pagination,
entries: response.list.entries.map((person) => person.entry as EcmUserModel)
})),
catchError((err) => this.handleError(err))
);
}
/**
* Creates new person.
*
* @param newPerson Object containing the new person details.
* @param opts Optional parameters
* @returns Created new person
*/
createPerson(newPerson: PersonBodyCreate, opts?: any): Observable<EcmUserModel> {
return from(this.peopleApi.createPerson(newPerson, opts)).pipe(
map((res: PersonEntry) => <EcmUserModel> res?.entry),
map((res) => res?.entry as EcmUserModel),
catchError((error) => this.handleError(error))
);
}
/**
* Updates the person details
*
* @param personId The identifier of a person
* @param details The person details
* @param opts Optional parameters
@@ -126,7 +130,7 @@ export class PeopleContentService {
*/
updatePerson(personId: string, details: PersonBodyUpdate, opts?: any): Observable<EcmUserModel> {
return from(this.peopleApi.updatePerson(personId, details, opts)).pipe(
map((res: PersonEntry) => <EcmUserModel> res?.entry),
map((res) => res?.entry as EcmUserModel),
catchError((error) => this.handleError(error))
);
}

View File

@@ -50,6 +50,7 @@ export class PeopleProcessService {
/**
* Gets information about users across all tasks.
*
* @param taskId ID of the task
* @param searchWord Filter text to search for
* @returns Array of user information objects
@@ -58,13 +59,14 @@ export class PeopleProcessService {
const option = { excludeTaskId: taskId, filter: searchWord };
return from(this.getWorkflowUserApi(option))
.pipe(
map((response: any) => <UserProcessModel[]> response.data || []),
map((response: any) => response.data || []),
catchError((err) => this.handleError(err))
);
}
/**
* Gets the profile picture URL for the specified user.
*
* @param user The target user
* @returns Profile picture URL
*/
@@ -74,6 +76,7 @@ export class PeopleProcessService {
/**
* Sets a user to be involved with a task.
*
* @param taskId ID of the target task
* @param idToInvolve ID of the user to involve
* @returns Empty response when the update completes
@@ -88,6 +91,7 @@ export class PeopleProcessService {
/**
* Removes a user who is currently involved with a task.
*
* @param taskId ID of the target task
* @param idToRemove ID of the user to remove
* @returns Empty response when the update completes
@@ -116,10 +120,6 @@ export class PeopleProcessService {
return this.userApi.getUserProfilePictureUrl(userId);
}
/**
* Throw the error
* @param error
*/
private handleError(error: any) {
this.logService.error(error);
return throwError(error || 'Server error');

View File

@@ -52,7 +52,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeRenditionsList)
});
@@ -66,7 +66,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeRenditionsListWithACreated)
});
@@ -79,7 +79,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeRenditionsList)
});
@@ -93,7 +93,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: ''
});
@@ -118,7 +118,7 @@ describe('RenditionsService', () => {
);
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 403,
status: 403,
contentType: 'application/json',
responseText: 'error'
});
@@ -131,7 +131,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeRendition)
});
@@ -144,7 +144,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 403,
status: 403,
contentType: 'application/json'
});
});
@@ -156,7 +156,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeRenditionCreated)
});
@@ -169,7 +169,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify(fakeRendition)
});
@@ -182,7 +182,7 @@ describe('RenditionsService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 400,
status: 400,
contentType: 'application/json'
});
});

View File

@@ -26,13 +26,13 @@ import { concatMap, switchMap, takeWhile, map } from 'rxjs/operators';
})
export class RenditionsService {
_renditionsApi: RenditionsApi;
private _renditionsApi: RenditionsApi;
get renditionsApi(): RenditionsApi {
this._renditionsApi = this._renditionsApi ?? new RenditionsApi(this.apiService.getInstance());
return this._renditionsApi;
}
_contentApi: ContentApi;
private _contentApi: ContentApi;
get contentApi(): ContentApi {
this._contentApi = this._contentApi ?? new ContentApi(this.apiService.getInstance());
return this._contentApi;
@@ -43,6 +43,7 @@ export class RenditionsService {
/**
* Gets the first available rendition found for a node.
*
* @param nodeId ID of the target node
* @returns Information object for the rendition
*/
@@ -58,6 +59,7 @@ export class RenditionsService {
/**
* Generates a rendition for a node using the first available encoding.
*
* @param nodeId ID of the target node
* @returns Null response to indicate completion
*/
@@ -75,6 +77,7 @@ export class RenditionsService {
/**
* Checks if the specified rendition is available for a node.
*
* @param nodeId ID of the target node
* @param encoding Name of the rendition encoding
* @returns True if the rendition is available, false otherwise
@@ -100,6 +103,7 @@ export class RenditionsService {
/**
* Checks if the node can be converted using the specified rendition.
*
* @param nodeId ID of the target node
* @param encoding Name of the rendition encoding
* @returns True if the node can be converted, false otherwise
@@ -121,6 +125,7 @@ export class RenditionsService {
/**
* Gets a URL linking to the specified rendition of a node.
*
* @param nodeId ID of the target node
* @param encoding Name of the rendition encoding
* @returns URL string
@@ -131,6 +136,7 @@ export class RenditionsService {
/**
* Gets information about a rendition of a node.
*
* @param nodeId ID of the target node
* @param encoding Name of the rendition encoding
* @returns Information object about the rendition
@@ -141,6 +147,7 @@ export class RenditionsService {
/**
* Gets a list of all renditions for a node.
*
* @param nodeId ID of the target node
* @returns Paged list of rendition details
*/
@@ -150,6 +157,7 @@ export class RenditionsService {
/**
* Creates a rendition for a node.
*
* @param nodeId ID of the target node
* @param encoding Name of the rendition encoding
* @returns Null response to indicate completion
@@ -160,6 +168,7 @@ export class RenditionsService {
/**
* Repeatedly attempts to create a rendition, through to success or failure.
*
* @param nodeId ID of the target node
* @param encoding Name of the rendition encoding
* @param pollingInterval Time interval (in milliseconds) between checks for completion

View File

@@ -29,12 +29,13 @@ export class SearchConfigurationService implements SearchConfigurationInterface
/**
* Generates a QueryBody object with custom search parameters.
*
* @param searchTerm Term text to search for
* @param maxResults Maximum number of search results to show in a page
* @param skipCount The offset of the start of the page within the results list
* @returns Query body defined by the parameters
*/
public generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody {
generateQueryBody(searchTerm: string, maxResults: number, skipCount: number): QueryBody {
const defaultQueryBody: QueryBody = {
query: {
query: searchTerm ? `'${searchTerm}*' OR name:'${searchTerm}*'` : searchTerm
@@ -42,7 +43,7 @@ export class SearchConfigurationService implements SearchConfigurationInterface
include: ['path', 'allowableOperations'],
paging: {
maxItems: maxResults,
skipCount: skipCount
skipCount
},
filterQueries: [
{ query: `TYPE:'cm:folder' OR TYPE:'cm:content'` },

View File

@@ -28,13 +28,13 @@ export class SearchService {
dataLoaded: Subject<ResultSetPaging> = new Subject();
_queriesApi: QueriesApi;
private _queriesApi: QueriesApi;
get queriesApi(): QueriesApi {
this._queriesApi = this._queriesApi ?? new QueriesApi(this.apiService.getInstance());
return this._queriesApi;
}
_searchApi: SearchApi;
private _searchApi: SearchApi;
get searchApi(): SearchApi {
this._searchApi = this._searchApi ?? new SearchApi(this.apiService.getInstance());
return this._searchApi;
@@ -46,6 +46,7 @@ export class SearchService {
/**
* Gets a list of nodes that match the given search criteria.
*
* @param term Term to search for
* @param options Options for delivery of the search results
* @returns List of nodes resulting from the search
@@ -62,6 +63,7 @@ export class SearchService {
/**
* Performs a search.
*
* @param searchTerm Term to search for
* @param maxResults Maximum number of items in the list of results
* @param skipCount Number of higher-ranked items to skip over in the list
@@ -80,6 +82,7 @@ export class SearchService {
/**
* Performs a search with its parameters supplied by a QueryBody object.
*
* @param queryBody Object containing the search parameters
* @returns List of search results
*/

View File

@@ -29,7 +29,7 @@ export class SharedLinksApiService {
error = new Subject<{ statusCode: number; message: string }>();
_sharedLinksApi: SharedlinksApi;
private _sharedLinksApi: SharedlinksApi;
get sharedLinksApi(): SharedlinksApi {
this._sharedLinksApi = this._sharedLinksApi ?? new SharedlinksApi(this.apiService.getInstance());
return this._sharedLinksApi;
@@ -41,6 +41,7 @@ export class SharedLinksApiService {
/**
* Gets shared links available to the current user.
*
* @param options Options supported by JS-API
* @returns List of shared links
*/
@@ -60,12 +61,13 @@ export class SharedLinksApiService {
/**
* Creates a shared link available to the current user.
*
* @param nodeId ID of the node to link to
* @param options Options supported by JS-API
* @returns The shared link just created
*/
createSharedLinks(nodeId: string, options: any = {}): Observable<SharedLinkEntry> {
const promise = this.sharedLinksApi.createSharedLink({ nodeId: nodeId }, options);
const promise = this.sharedLinksApi.createSharedLink({ nodeId }, options);
return from(promise).pipe(
catchError((err) => of(err))
@@ -74,6 +76,7 @@ export class SharedLinksApiService {
/**
* Deletes a shared link.
*
* @param sharedId ID of the link to delete
* @returns Null response notifying when the operation is complete
*/

View File

@@ -62,23 +62,23 @@ describe('Sites service', () => {
status: 200,
contentType: 'json',
responseText: {
'list': {
'pagination': {
'count': 1,
'hasMoreItems': false,
'totalItems': 1,
'skipCount': 0,
'maxItems': 100
list: {
pagination: {
count: 1,
hasMoreItems: false,
totalItems: 1,
skipCount: 0,
maxItems: 100
},
'entries': [
entries: [
{
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'description': 'This is a Sample Alfresco Team site.',
'id': 'swsdp',
'title': 'FAKE'
entry: {
role: 'SiteManager',
visibility: 'PUBLIC',
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
description: 'This is a Sample Alfresco Team site.',
id: 'swsdp',
title: 'FAKE'
}
}
]
@@ -97,14 +97,14 @@ describe('Sites service', () => {
status: 200,
contentType: 'json',
responseText: {
'entry': {
'role': 'SiteManager',
'visibility': 'PUBLIC',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'description': 'This is a Sample Alfresco Team site.',
'id': 'swsdp',
'preset': 'site-dashboard',
'title': 'FAKE-SINGLE-TITLE'
entry: {
role: 'SiteManager',
visibility: 'PUBLIC',
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
description: 'This is a Sample Alfresco Team site.',
id: 'swsdp',
preset: 'site-dashboard',
title: 'FAKE-SINGLE-TITLE'
}
}
});
@@ -121,35 +121,35 @@ describe('Sites service', () => {
status: 200,
contentType: 'json',
responseText: {
'list': {
'pagination': {
'count': 1,
'hasMoreItems': false,
'totalItems': 1,
'skipCount': 0,
'maxItems': 100
list: {
pagination: {
count: 1,
hasMoreItems: false,
totalItems: 1,
skipCount: 0,
maxItems: 100
},
'entries': [
entries: [
{
'entry': {
'id': 'site-id',
'createdAt': '2020-05-13T07:46:36.180Z',
'site': {
'id': 'site-id',
'guid': 'b4cff62a-664d-4d45-9302-98723eac1319',
'title': 'Sample Site',
'description': '',
'visibility': 'MODERATED',
'preset': 'preset',
'role': 'Manager'
entry: {
id: 'site-id',
createdAt: '2020-05-13T07:46:36.180Z',
site: {
id: 'site-id',
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
title: 'Sample Site',
description: '',
visibility: 'MODERATED',
preset: 'preset',
role: 'Manager'
},
'person': {
'id': 'user-id',
'firstName': 'string',
'lastName': 'string',
'displayName': 'string'
person: {
id: 'user-id',
firstName: 'string',
lastName: 'string',
displayName: 'string'
},
'message': 'message'
message: 'message'
}
}
]

View File

@@ -40,7 +40,7 @@ import { LogService } from './log.service';
})
export class SitesService {
_sitesApi: SitesApi;
private _sitesApi: SitesApi;
get sitesApi(): SitesApi {
this._sitesApi = this._sitesApi ?? new SitesApi(this.apiService.getInstance());
return this._sitesApi;
@@ -51,6 +51,7 @@ export class SitesService {
/**
* Create a site
*
* @param siteBody SiteBodyCreate to create site
* @returns site SiteEntry
*/
@@ -63,6 +64,7 @@ export class SitesService {
/**
* Gets a list of all sites in the repository.
*
* @param opts Options supported by JS-API
* @returns List of sites
*/
@@ -80,6 +82,7 @@ export class SitesService {
/**
* Gets the details for a site.
*
* @param siteId ID of the target site
* @param opts Options supported by JS-API
* @returns Information about the site
@@ -93,6 +96,7 @@ export class SitesService {
/**
* Deletes a site.
*
* @param siteId Site to delete
* @param permanentFlag True: deletion is permanent; False: site is moved to the trash
* @returns Null response notifying when the operation is complete
@@ -108,6 +112,7 @@ export class SitesService {
/**
* Gets a site's content.
*
* @param siteId ID of the target site
* @returns Site content
*/
@@ -117,6 +122,7 @@ export class SitesService {
/**
* Gets a list of all a site's members.
*
* @param siteId ID of the target site
* @returns Site members
*/
@@ -126,6 +132,7 @@ export class SitesService {
/**
* Gets a list of all a site's members.
*
* @param siteId ID of the target site
* @param opts Optional parameters supported by JS-API
* @returns Observable<SiteMemberPaging>
@@ -136,6 +143,7 @@ export class SitesService {
/**
* Gets the username of the user currently logged into ACS.
*
* @returns Username string
*/
getEcmCurrentLoggedUserName(): string {
@@ -145,6 +153,7 @@ export class SitesService {
/**
* Looks for a site inside the path of a Node and returns its guid if it finds one.
* (return an empty string if no site is found)
*
* @param node Node to look for parent site
* @returns Site guid
*/
@@ -162,6 +171,7 @@ export class SitesService {
/**
* Gets a list of site membership requests.
*
* @param opts Options supported by JS-API
* @returns Site membership requests
*/
@@ -174,6 +184,7 @@ export class SitesService {
/**
* Creates a site membership for person **personId** on site **siteId**.
*
* @param siteId The identifier of a site
* @param siteMembershipBodyCreate The person to add and their role
* @param opts Optional parameters
@@ -188,6 +199,7 @@ export class SitesService {
/**
* Update a site membership
*
* @param siteId The identifier of a site.
* @param personId The identifier of a person.
* @param siteMembershipBodyUpdate The persons new role
@@ -203,6 +215,7 @@ export class SitesService {
/**
* Delete a site membership
*
* @param siteId The identifier of a site.
* @param personId The identifier of a person.
* @return Null response notifying when the operation is complete
@@ -216,6 +229,7 @@ export class SitesService {
/**
* Accept site membership requests.
*
* @param siteId The identifier of a site.
* @param inviteeId The invitee user name.
* @param opts Options supported by JS-API
@@ -230,6 +244,7 @@ export class SitesService {
/**
* Reject site membership requests.
*
* @param siteId The identifier of a site.
* @param inviteeId The invitee user name.
* @param opts Options supported by JS-API
@@ -244,6 +259,7 @@ export class SitesService {
/**
* List group membership for site
*
* @param siteId The identifier of a site.
* @param opts Options supported by JS-API
* @returns Observable<SiteGroupPaging>
@@ -257,6 +273,7 @@ export class SitesService {
/**
* Create a site membership for group
*
* @param siteId The identifier of a site.
* @param siteMembershipBodyCreate The Group to add and its role
* @returns Observable<SiteGroupEntry>
@@ -270,6 +287,7 @@ export class SitesService {
/**
* Get information about site membership of group
*
* @param siteId The identifier of a site.
* @param groupId The authorityId of a group.
* @return Observable<SiteGroupEntry>
@@ -283,6 +301,7 @@ export class SitesService {
/**
* Update site membership of group
*
* @param siteId The identifier of a site.
* @param groupId The authorityId of a group.
* @param siteMembershipBodyUpdate The group new role
@@ -297,6 +316,7 @@ export class SitesService {
/**
* Delete a group membership for site
*
* @param siteId The identifier of a site.
* @param groupId The authorityId of a group.
* @return Observable<void>

View File

@@ -17,6 +17,7 @@
import { AlfrescoApiService } from './alfresco-api.service';
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function startupServiceFactory(alfrescoApiService: AlfrescoApiService) {
return () => alfrescoApiService.load();
}

View File

@@ -40,6 +40,7 @@ export class StorageService {
/**
* Gets an item.
*
* @param key Key to identify the item
* @returns The item (if any) retrieved by the key
*/
@@ -53,6 +54,7 @@ export class StorageService {
/**
* Stores an item
*
* @param key Key to identify the item
* @param data Data to store
*/
@@ -75,6 +77,7 @@ export class StorageService {
/**
* Removes a single item.
*
* @param key Key to identify the item
*/
removeItem(key: string) {
@@ -87,6 +90,7 @@ export class StorageService {
/**
* Is any item currently stored under `key`?
*
* @param key Key identifying item to check
* @returns True if key retrieves an item, false otherwise
*/

View File

@@ -149,18 +149,18 @@ export class ThumbnailService {
'application/vnd.visio': './assets/images/ft_ic_document.svg',
'application/wordperfect': './assets/images/ft_ic_document.svg',
'application/x-cpio': './assets/images/ft_ic_document.svg',
'folder': './assets/images/ft_ic_folder.svg',
'smartFolder': './assets/images/ft_ic_smart_folder.svg',
'ruleFolder': './assets/images/ft_ic_folder_rule.svg',
'linkFolder': './assets/images/ft_ic_folder_shortcut_link.svg',
folder: './assets/images/ft_ic_folder.svg',
smartFolder: './assets/images/ft_ic_smart_folder.svg',
ruleFolder: './assets/images/ft_ic_folder_rule.svg',
linkFolder: './assets/images/ft_ic_folder_shortcut_link.svg',
'disable/folder': './assets/images/ft_ic_folder_disable.svg',
'selected': './assets/images/ft_ic_selected.svg',
selected: './assets/images/ft_ic_selected.svg',
'dynamic-feed': './assets/images/dynamic_feed-24px.svg',
'ic-process': './assets/images/ic-process.svg',
'filter': './assets/images/ft_ic_filter.svg',
filter: './assets/images/ft_ic_filter.svg',
'save-as': './assets/images/save-as.svg',
'save': './assets/images/save.svg',
'task': './assets/images/task.svg'
save: './assets/images/save.svg',
task: './assets/images/task.svg'
};
_contentApi: ContentApi;
@@ -180,6 +180,7 @@ export class ThumbnailService {
/**
* Gets a thumbnail URL for the given document node.
*
* @param node Node or Node ID to get URL for.
* @param attachment Toggles whether to retrieve content as an attachment for download
* @param ticket Custom ticket to use for authentication
@@ -205,6 +206,7 @@ export class ThumbnailService {
/**
* Gets a thumbnail URL for a MIME type.
*
* @param mimeType MIME type for the thumbnail
* @returns URL string
*/
@@ -215,6 +217,7 @@ export class ThumbnailService {
/**
* Gets a "miscellaneous" thumbnail URL for types with no other icon defined.
*
* @returns URL string
*/
public getDefaultMimeTypeIcon(): string {

View File

@@ -46,7 +46,7 @@ export class TranslateLoaderService implements TranslateLoader {
if (registered) {
registered.path = path;
} else {
this.providers.push(new ComponentTranslationModel({ name: name, path: path }));
this.providers.push(new ComponentTranslationModel({ name, path }));
}
}
@@ -131,14 +131,12 @@ export class TranslateLoaderService implements TranslateLoader {
getTranslation(lang: string): Observable<any> {
let hasFailures = false;
const batch = [
...this.getComponentToFetch(lang).map((observable) => {
return observable.pipe(
catchError((error) => {
hasFailures = true;
return of(error);
})
);
})
...this.getComponentToFetch(lang).map((observable) => observable.pipe(
catchError((error) => {
hasFailures = true;
return of(error);
})
))
];
return new Observable((observer) => {

View File

@@ -40,7 +40,7 @@ describe('TranslateLoader', () => {
beforeEach(() => {
translationService = TestBed.inject(TranslationService);
customLoader = <TranslateLoaderService> translationService.translate.currentLoader;
customLoader = translationService.translate.currentLoader as TranslateLoaderService;
jasmine.Ajax.install();
});

View File

@@ -75,9 +75,9 @@ describe('TranslationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify({'TEST': 'This is a test', 'TEST2': 'This is another test'})
responseText: JSON.stringify({TEST: 'This is a test', TEST2: 'This is another test'})
});
});
@@ -87,9 +87,9 @@ describe('TranslationService', () => {
});
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'application/json',
responseText: JSON.stringify({'TEST': 'This is a test', 'TEST2': 'This is another test'})
responseText: JSON.stringify({TEST: 'This is a test', TEST2: 'This is another test'})
});
});

View File

@@ -39,7 +39,7 @@ export class TranslationService {
constructor(public translate: TranslateService,
userPreferencesService: UserPreferencesService,
@Optional() @Inject(TRANSLATION_PROVIDER) providers: TranslationProvider[]) {
this.customLoader = <TranslateLoaderService> this.translate.currentLoader;
this.customLoader = this.translate.currentLoader as TranslateLoaderService;
this.defaultLang = 'en';
translate.setDefaultLang(this.defaultLang);
@@ -61,6 +61,7 @@ export class TranslationService {
/**
* Adds a new folder of translation source files.
*
* @param name Name for the translation provider
* @param path Path to the folder
*/
@@ -78,6 +79,7 @@ export class TranslationService {
/**
* Loads a translation file.
*
* @param lang Language code for the language to load
* @param fallback Language code to fall back to if the first one was unavailable
*/
@@ -97,17 +99,19 @@ export class TranslationService {
/**
* Triggers a notification callback when the translation language changes.
*
* @param lang The new language code
*/
onTranslationChanged(lang: string): void {
this.translate.onTranslationChange.next({
lang: lang,
lang,
translations: this.customLoader.getFullTranslationJSON(lang)
});
}
/**
* Sets the target language for translations.
*
* @param lang Code name for the language
* @returns Translations available for the language
*/
@@ -118,6 +122,7 @@ export class TranslationService {
/**
* Gets the translation for the supplied key.
*
* @param key Key to translate
* @param interpolateParams String(s) to be interpolated into the main message
* @returns Translated text
@@ -128,6 +133,7 @@ export class TranslationService {
/**
* Directly returns the translation for the supplied key.
*
* @param key Key to translate
* @param interpolateParams String(s) to be interpolated into the main message
* @returns Translated text

View File

@@ -17,14 +17,14 @@
import { EventEmitter } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { FileModel, FileUploadOptions, FileUploadStatus } from '../models/file.model';
import { FileModel, FileUploadStatus } from '../models/file.model';
import { AppConfigModule } from '../app-config/app-config.module';
import { UploadService } from './upload.service';
import { AppConfigService } from '../app-config/app-config.service';
import { setupTestBed } from '../testing/setup-test-bed';
import { CoreTestingModule } from '../testing/core.testing.module';
import { AssocChildBody, AssociationBody, RepositoryInfo } from '@alfresco/js-api';
import { RepositoryInfo } from '@alfresco/js-api';
import { TranslateModule } from '@ngx-translate/core';
import { DiscoveryApiService } from './discovery-api.service';
import { BehaviorSubject } from 'rxjs';
@@ -93,26 +93,26 @@ describe('UploadService', () => {
});
it('should add an element in the queue and returns it', () => {
const filesFake = new FileModel(<File> { name: 'fake-name', size: 10 });
const filesFake = new FileModel({ name: 'fake-name', size: 10 } as File);
service.addToQueue(filesFake);
expect(service.getQueue().length).toEqual(1);
});
it('should add two elements in the queue and returns them', () => {
const filesFake = [
new FileModel(<File> { name: 'fake-name', size: 10 }),
new FileModel(<File> { name: 'fake-name2', size: 20 })
new FileModel({ name: 'fake-name', size: 10 } as File),
new FileModel({ name: 'fake-name2', size: 20 } as File)
];
service.addToQueue(...filesFake);
expect(service.getQueue().length).toEqual(2);
});
it('should not have the queue uploading if all files are complete, cancelled, aborted, errored or deleted', () => {
const file1 = new FileModel(<File> { name: 'fake-file-1', size: 10 });
const file2 = new FileModel(<File> { name: 'fake-file-2', size: 20 });
const file3 = new FileModel(<File> { name: 'fake-file-3', size: 30 });
const file4 = new FileModel(<File> { name: 'fake-file-4', size: 40 });
const file5 = new FileModel(<File> { name: 'fake-file-5', size: 50 });
const file1 = new FileModel({ name: 'fake-file-1', size: 10 } as File);
const file2 = new FileModel({ name: 'fake-file-2', size: 20 } as File);
const file3 = new FileModel({ name: 'fake-file-3', size: 30 } as File);
const file4 = new FileModel({ name: 'fake-file-4', size: 40 } as File);
const file5 = new FileModel({ name: 'fake-file-5', size: 50 } as File);
file1.status = FileUploadStatus.Complete;
file2.status = FileUploadStatus.Cancelled;
@@ -126,8 +126,8 @@ describe('UploadService', () => {
});
it('should have the queue still uploading if some files are still pending, starting or in progress', () => {
const file1 = new FileModel(<File> { name: 'fake-file-1', size: 10 });
const file2 = new FileModel(<File> { name: 'fake-file-2', size: 20 });
const file1 = new FileModel({ name: 'fake-file-1', size: 10 } as File);
const file2 = new FileModel({ name: 'fake-file-2', size: 20 } as File);
service.addToQueue(file1, file2);
@@ -167,8 +167,8 @@ describe('UploadService', () => {
done();
});
const fileFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
<FileUploadOptions> { parentId: '-root-', path: 'fake-dir' }
{ name: 'fake-name', size: 10 } as File,
{ parentId: '-root-', path: 'fake-dir' }
);
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(emitter);
@@ -178,7 +178,7 @@ describe('UploadService', () => {
expect(request.method).toBe('POST');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'text/plain',
responseText: 'File uploaded'
});
@@ -193,8 +193,8 @@ describe('UploadService', () => {
done();
});
const fileFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
<FileUploadOptions> { parentId: '-root-' }
{ name: 'fake-name', size: 10 } as File,
{ parentId: '-root-' }
);
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(null, emitter);
@@ -202,7 +202,7 @@ describe('UploadService', () => {
.toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 404,
status: 404,
contentType: 'text/plain',
responseText: 'Error file uploaded'
});
@@ -217,7 +217,7 @@ describe('UploadService', () => {
done();
});
const fileFake = new FileModel(<File> { name: 'fake-name', size: 10000000 });
const fileFake = new FileModel({ name: 'fake-name', size: 10000000 } as File);
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(emitter);
@@ -237,14 +237,14 @@ describe('UploadService', () => {
expect(deleteRequest.method).toBe('DELETE');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'text/plain',
responseText: 'File deleted'
});
done();
});
const fileFake = new FileModel(<File> { name: 'fake-name', size: 10 });
const fileFake = new FileModel({ name: 'fake-name', size: 10 } as File);
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(emitter);
@@ -256,7 +256,7 @@ describe('UploadService', () => {
expect(request.method).toBe('POST');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'json',
responseText: {
entry: {
@@ -278,14 +278,14 @@ describe('UploadService', () => {
expect(deleteRequest.method).toBe('DELETE');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'text/plain',
responseText: 'File deleted'
});
done();
});
const fileFake = new FileModel(<File> {name: 'fake-name', size: 10}, null, 'fakeId');
const fileFake = new FileModel({name: 'fake-name', size: 10} as File, null, 'fakeId');
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(emitter);
@@ -297,7 +297,7 @@ describe('UploadService', () => {
expect(request.method).toBe('PUT');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'json',
responseText: {
entry: {
@@ -313,7 +313,7 @@ describe('UploadService', () => {
it('If newVersion is set, name should be a param', () => {
const emitter = new EventEmitter();
const filesFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
{ name: 'fake-name', size: 10 } as File,
{ newVersion: true }
);
service.addToQueue(filesFake);
@@ -347,8 +347,8 @@ describe('UploadService', () => {
done();
});
const filesFake = new FileModel(
<File> { name: 'fake-file-name', size: 10 },
<FileUploadOptions> { parentId: '123', path: 'fake-dir' }
{ name: 'fake-file-name', size: 10 } as File,
{ parentId: '123', path: 'fake-dir' }
);
service.addToQueue(filesFake);
service.uploadFilesInTheQueue(emitter);
@@ -358,7 +358,7 @@ describe('UploadService', () => {
expect(request.method).toBe('POST');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 200,
status: 200,
contentType: 'text/plain',
responseText: 'File uploaded'
});
@@ -367,10 +367,8 @@ describe('UploadService', () => {
describe('versioningEnabled', () => {
it('should upload with "versioningEnabled" parameter taken from file options', () => {
const model = new FileModel(
<File> { name: 'file-name', size: 10 },
<FileUploadOptions> {
versioningEnabled: true
}
{ name: 'file-name', size: 10 } as File,
{ versioningEnabled: true }
);
service.addToQueue(model);
@@ -395,8 +393,8 @@ describe('UploadService', () => {
it('should not use "versioningEnabled" if not explicitly provided', () => {
const model = new FileModel(
<File> { name: 'file-name', size: 10 },
<FileUploadOptions> {}
{ name: 'file-name', size: 10 } as File,
{}
);
service.addToQueue(model);
@@ -421,13 +419,13 @@ describe('UploadService', () => {
it('should append the extra upload options to the request', () => {
const filesFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
<FileUploadOptions> {
{ name: 'fake-name', size: 10 } as File,
{
parentId: '123',
path: 'fake-dir',
secondaryChildren: [<AssocChildBody> { assocType: 'assoc-1', childId: 'child-id' }],
secondaryChildren: [{ assocType: 'assoc-1', childId: 'child-id' }],
association: { assocType: 'fake-assoc' },
targets: [<AssociationBody> { assocType: 'target-assoc', targetId: 'fake-target-id' }]
targets: [{ assocType: 'target-assoc', targetId: 'fake-target-id' }]
});
service.addToQueue(filesFake);
service.uploadFilesInTheQueue();
@@ -443,9 +441,9 @@ describe('UploadService', () => {
newVersion: false,
parentId: '123',
path: 'fake-dir',
secondaryChildren: [<AssocChildBody> { assocType: 'assoc-1', childId: 'child-id' }],
secondaryChildren: [ { assocType: 'assoc-1', childId: 'child-id' }],
association: { assocType: 'fake-assoc' },
targets: [<AssociationBody> { assocType: 'target-assoc', targetId: 'fake-target-id' }]
targets: [{ assocType: 'target-assoc', targetId: 'fake-target-id' }]
},
{
renditions: 'doclib',
@@ -465,8 +463,8 @@ describe('UploadService', () => {
done();
});
const fileFake1 = new FileModel(<File> { name: 'fake-name1', size: 10 });
const fileFake2 = new FileModel(<File> { name: 'fake-name2', size: 10 });
const fileFake1 = new FileModel({ name: 'fake-name1', size: 10 } as File);
const fileFake2 = new FileModel({ name: 'fake-name2', size: 10 } as File);
const fileList = [fileFake1, fileFake2];
service.addToQueue(...fileList);
service.uploadFilesInTheQueue();
@@ -511,7 +509,7 @@ describe('UploadService', () => {
});
it('should call onUploadDeleted if file was deleted', () => {
const file = <FileModel> { status: FileUploadStatus.Deleted };
const file = { status: FileUploadStatus.Deleted } as FileModel;
spyOn(service.fileUploadDeleted, 'next');
service.cancelUpload(file);
@@ -520,7 +518,7 @@ describe('UploadService', () => {
});
it('should call fileUploadError if file has error status', () => {
const file = <any> ({ status: FileUploadStatus.Error });
const file = { status: FileUploadStatus.Error } as FileModel;
spyOn(service.fileUploadError, 'next');
service.cancelUpload(file);
@@ -529,7 +527,7 @@ describe('UploadService', () => {
});
it('should call fileUploadCancelled if file is in pending', () => {
const file = <any> ({ status: FileUploadStatus.Pending });
const file = { status: FileUploadStatus.Pending } as FileModel;
spyOn(service.fileUploadCancelled, 'next');
service.cancelUpload(file);
@@ -541,7 +539,7 @@ describe('UploadService', () => {
mockProductInfo.next({ status: { isThumbnailGenerationEnabled: false } } as RepositoryInfo);
const filesFake = new FileModel(
<File> { name: 'fake-name', size: 10 },
{ name: 'fake-name', size: 10 } as File,
{ newVersion: true}
);
service.addToQueue(filesFake);

View File

@@ -47,8 +47,8 @@ describe('UserPreferencesService', () => {
appConfig = TestBed.inject(AppConfigService);
appConfig.config = {
pagination: {
'size': 10,
'supportedPageSizes': [5, 10, 15, 20]
size: 10,
supportedPageSizes: [5, 10, 15, 20]
}
};

View File

@@ -24,6 +24,7 @@ import { distinctUntilChanged, map, filter } from 'rxjs/operators';
import { AlfrescoApiService } from './alfresco-api.service';
import { LanguageItem } from './language-item.interface';
// eslint-disable-next-line no-shadow
export enum UserPreferenceValues {
PaginationSize = 'paginationSize',
Locale = 'locale',
@@ -78,6 +79,7 @@ export class UserPreferencesService {
/**
* Sets up a callback to notify when a property has changed.
*
* @param property The property to watch
* @returns Notification callback
*/
@@ -91,6 +93,7 @@ export class UserPreferencesService {
/**
* Gets a preference property.
*
* @param property Name of the property
* @param defaultValue Default to return if the property is not found
* @returns Preference property
@@ -106,6 +109,7 @@ export class UserPreferencesService {
/**
* Sets a preference property.
*
* @param property Name of the property
* @param value New value for the property
*/
@@ -123,6 +127,7 @@ export class UserPreferencesService {
/**
* Sets a preference property.
*
* @param property Name of the property
* @param value New value for the property
*/
@@ -136,6 +141,7 @@ export class UserPreferencesService {
/**
* Check if an item is present in the storage
*
* @param property Name of the property
* @returns True if the item is present, false otherwise
*/
@@ -150,6 +156,7 @@ export class UserPreferencesService {
/**
* Gets the active storage prefix for preferences.
*
* @returns Storage prefix
*/
getStoragePrefix(): string {
@@ -158,6 +165,7 @@ export class UserPreferencesService {
/**
* Sets the active storage prefix for preferences.
*
* @param value Name of the prefix
*/
setStoragePrefix(value: string) {
@@ -167,6 +175,7 @@ export class UserPreferencesService {
/**
* Gets the full property key with prefix.
*
* @param property The property name
* @returns Property key
*/
@@ -176,6 +185,7 @@ export class UserPreferencesService {
/**
* Gets an array containing the available page sizes.
*
* @returns Array of page size values
*/
get supportedPageSizes(): number[] {
@@ -218,17 +228,18 @@ export class UserPreferencesService {
/**
* Gets the default locale.
*
* @returns Default locale language code
*/
public getDefaultLocale(): string {
getDefaultLocale(): string {
return this.appConfig.get<string>(UserPreferenceValues.Locale) || this.translate.getBrowserCultureLang() || 'en';
}
private getLanguageByKey(key: string): LanguageItem {
return (
this.appConfig
.get<Array<LanguageItem>>(AppConfigValues.APP_CONFIG_LANGUAGES_KEY, [<LanguageItem> { key: 'en' }])
.find((language) => key.includes(language.key)) || <LanguageItem> { key: 'en' }
.get<Array<LanguageItem>>(AppConfigValues.APP_CONFIG_LANGUAGES_KEY, [{ key: 'en' } as LanguageItem])
.find((language) => key.includes(language.key)) || { key: 'en' } as LanguageItem
);
}
}

View File

@@ -17,6 +17,7 @@
import { VersionCompatibilityService } from './version-compatibility.service';
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
export function versionCompatibilityFactory(versionCompatibilityService: VersionCompatibilityService) {
return () => versionCompatibilityService;
}

View File

@@ -72,9 +72,9 @@ export class VersionCompatibilityService {
const patch = version.split('.')[2] || '0';
return {
major: major,
minor: minor,
patch: patch
major,
minor,
patch
} as VersionInfo;
}
}