mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
integrate search new javascript api
This commit is contained in:
@@ -19,6 +19,7 @@ import { Observable } from 'rxjs/Rx';
|
||||
|
||||
export interface AbstractAuthentication {
|
||||
TYPE: string;
|
||||
alfrescoApi: any;
|
||||
|
||||
login(username: string, password: string): Observable<any>;
|
||||
|
||||
|
@@ -23,6 +23,8 @@ declare let AlfrescoApi: any;
|
||||
|
||||
export class AlfrescoAuthenticationBase {
|
||||
|
||||
alfrescoApi: any;
|
||||
|
||||
private _authUrl: string = '/alfresco/api/-default-/public/authentication/versions/1';
|
||||
private alfrescoSetting: AlfrescoSettingsService;
|
||||
/**
|
||||
|
@@ -99,7 +99,7 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* The method return tru if the user is logged in
|
||||
* The method return true if the user is logged in
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isLoggedIn(type: string = 'ECM'): boolean {
|
||||
@@ -110,6 +110,10 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
getAlfrescoApi(): any {
|
||||
return this.findProviderInstance('ECM').alfrescoApi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the token stored in the localStorage of the specific provider type
|
||||
* @param token
|
||||
@@ -198,7 +202,7 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
||||
let auth: AbstractAuthentication = null;
|
||||
if (this.providersInstance && this.providersInstance.length !== 0) {
|
||||
this.providersInstance.forEach((provider) => {
|
||||
if (provider.TYPE === type) {
|
||||
if (provider.TYPE === type.toUpperCase()) {
|
||||
auth = provider;
|
||||
}
|
||||
});
|
||||
|
@@ -26,6 +26,8 @@ describe('AlfrescoContentService', () => {
|
||||
|
||||
let injector, service: AlfrescoContentService, authService: AlfrescoAuthenticationService;
|
||||
const nodeId = 'blah';
|
||||
let DEFAULT_CONTEXT_PATH: string = '/alfresco';
|
||||
let DEFAULT_BASE_API_PATH: string = '/api/-default-/public/alfresco/versions/1';
|
||||
|
||||
beforeEach(() => {
|
||||
injector = ReflectiveInjector.resolveAndCreate([
|
||||
@@ -47,8 +49,8 @@ describe('AlfrescoContentService', () => {
|
||||
id: nodeId
|
||||
}
|
||||
})).toBe(
|
||||
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + AlfrescoSettingsService.DEFAULT_CONTEXT_PATH +
|
||||
AlfrescoSettingsService.DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/content' +
|
||||
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + DEFAULT_CONTEXT_PATH +
|
||||
DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/content' +
|
||||
'?attachment=false&alf_ticket=' + authService.getTicket()
|
||||
);
|
||||
});
|
||||
@@ -59,8 +61,8 @@ describe('AlfrescoContentService', () => {
|
||||
id: nodeId
|
||||
}
|
||||
})).toBe(
|
||||
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + AlfrescoSettingsService.DEFAULT_CONTEXT_PATH +
|
||||
AlfrescoSettingsService.DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/renditions/doclib/content' +
|
||||
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + DEFAULT_CONTEXT_PATH +
|
||||
DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/renditions/doclib/content' +
|
||||
'?attachment=false&alf_ticket=' + authService.getTicket()
|
||||
);
|
||||
});
|
||||
|
@@ -37,11 +37,4 @@ describe('AlfrescoSettingsService', () => {
|
||||
expect(service.host).toBe(address);
|
||||
});
|
||||
|
||||
it('should format api url', () => {
|
||||
let address = 'http://192.168.0.1';
|
||||
let expectedUrl =
|
||||
`${address}${AlfrescoSettingsService.DEFAULT_CONTEXT_PATH}${AlfrescoSettingsService.DEFAULT_BASE_API_PATH}`;
|
||||
service.host = address;
|
||||
expect(service.getApiBaseUrl()).toBe(expectedUrl);
|
||||
});
|
||||
});
|
||||
|
@@ -81,7 +81,7 @@ class SearchDemo implements OnInit {
|
||||
}
|
||||
|
||||
login() {
|
||||
this.authService.login('admin', 'admin').subscribe(
|
||||
this.authService.login('admin', 'admin', ['ECM']).subscribe(
|
||||
token => {
|
||||
console.log(token);
|
||||
this.token = token;
|
||||
|
@@ -40,7 +40,7 @@ export class AlfrescoSearchService {
|
||||
rootNodeId: nodeId,
|
||||
nodeType: 'cm:content'
|
||||
};
|
||||
return this.authService.alfrescoApi.search.liveSearchNodes(term, opts);
|
||||
return this.authService.getAlfrescoApi().search.liveSearchNodes(term, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user