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 {
|
export interface AbstractAuthentication {
|
||||||
TYPE: string;
|
TYPE: string;
|
||||||
|
alfrescoApi: any;
|
||||||
|
|
||||||
login(username: string, password: string): Observable<any>;
|
login(username: string, password: string): Observable<any>;
|
||||||
|
|
||||||
|
@@ -23,6 +23,8 @@ declare let AlfrescoApi: any;
|
|||||||
|
|
||||||
export class AlfrescoAuthenticationBase {
|
export class AlfrescoAuthenticationBase {
|
||||||
|
|
||||||
|
alfrescoApi: any;
|
||||||
|
|
||||||
private _authUrl: string = '/alfresco/api/-default-/public/authentication/versions/1';
|
private _authUrl: string = '/alfresco/api/-default-/public/authentication/versions/1';
|
||||||
private alfrescoSetting: AlfrescoSettingsService;
|
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}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
isLoggedIn(type: string = 'ECM'): boolean {
|
isLoggedIn(type: string = 'ECM'): boolean {
|
||||||
@@ -110,6 +110,10 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAlfrescoApi(): any {
|
||||||
|
return this.findProviderInstance('ECM').alfrescoApi;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the token stored in the localStorage of the specific provider type
|
* Return the token stored in the localStorage of the specific provider type
|
||||||
* @param token
|
* @param token
|
||||||
@@ -198,7 +202,7 @@ export class AlfrescoAuthenticationService extends AlfrescoAuthenticationBase {
|
|||||||
let auth: AbstractAuthentication = null;
|
let auth: AbstractAuthentication = null;
|
||||||
if (this.providersInstance && this.providersInstance.length !== 0) {
|
if (this.providersInstance && this.providersInstance.length !== 0) {
|
||||||
this.providersInstance.forEach((provider) => {
|
this.providersInstance.forEach((provider) => {
|
||||||
if (provider.TYPE === type) {
|
if (provider.TYPE === type.toUpperCase()) {
|
||||||
auth = provider;
|
auth = provider;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -26,6 +26,8 @@ describe('AlfrescoContentService', () => {
|
|||||||
|
|
||||||
let injector, service: AlfrescoContentService, authService: AlfrescoAuthenticationService;
|
let injector, service: AlfrescoContentService, authService: AlfrescoAuthenticationService;
|
||||||
const nodeId = 'blah';
|
const nodeId = 'blah';
|
||||||
|
let DEFAULT_CONTEXT_PATH: string = '/alfresco';
|
||||||
|
let DEFAULT_BASE_API_PATH: string = '/api/-default-/public/alfresco/versions/1';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
injector = ReflectiveInjector.resolveAndCreate([
|
injector = ReflectiveInjector.resolveAndCreate([
|
||||||
@@ -47,8 +49,8 @@ describe('AlfrescoContentService', () => {
|
|||||||
id: nodeId
|
id: nodeId
|
||||||
}
|
}
|
||||||
})).toBe(
|
})).toBe(
|
||||||
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + AlfrescoSettingsService.DEFAULT_CONTEXT_PATH +
|
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + DEFAULT_CONTEXT_PATH +
|
||||||
AlfrescoSettingsService.DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/content' +
|
DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/content' +
|
||||||
'?attachment=false&alf_ticket=' + authService.getTicket()
|
'?attachment=false&alf_ticket=' + authService.getTicket()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -59,8 +61,8 @@ describe('AlfrescoContentService', () => {
|
|||||||
id: nodeId
|
id: nodeId
|
||||||
}
|
}
|
||||||
})).toBe(
|
})).toBe(
|
||||||
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + AlfrescoSettingsService.DEFAULT_CONTEXT_PATH +
|
AlfrescoSettingsService.DEFAULT_HOST_ADDRESS + DEFAULT_CONTEXT_PATH +
|
||||||
AlfrescoSettingsService.DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/renditions/doclib/content' +
|
DEFAULT_BASE_API_PATH + '/nodes/' + nodeId + '/renditions/doclib/content' +
|
||||||
'?attachment=false&alf_ticket=' + authService.getTicket()
|
'?attachment=false&alf_ticket=' + authService.getTicket()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -37,11 +37,4 @@ describe('AlfrescoSettingsService', () => {
|
|||||||
expect(service.host).toBe(address);
|
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() {
|
login() {
|
||||||
this.authService.login('admin', 'admin').subscribe(
|
this.authService.login('admin', 'admin', ['ECM']).subscribe(
|
||||||
token => {
|
token => {
|
||||||
console.log(token);
|
console.log(token);
|
||||||
this.token = token;
|
this.token = token;
|
||||||
|
@@ -40,7 +40,7 @@ export class AlfrescoSearchService {
|
|||||||
rootNodeId: nodeId,
|
rootNodeId: nodeId,
|
||||||
nodeType: 'cm:content'
|
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