diff --git a/ng2-components/ng2-alfresco-search/demo/src/main.ts b/ng2-components/ng2-alfresco-search/demo/src/main.ts index b928a12c33..cfa3ea46c9 100644 --- a/ng2-components/ng2-alfresco-search/demo/src/main.ts +++ b/ng2-components/ng2-alfresco-search/demo/src/main.ts @@ -35,15 +35,20 @@ import { @Component({ selector: 'alfresco-search-demo', - template: ` -
- - -
-
- Authentication failed to ip {{ host }} -
+ template: `
+
+
+

+
+ Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid token to perform + operations. +
+
+
+ + +
`, styles: [':host > .container {padding: 10px}'], providers: [ALFRESCO_SEARCH_PROVIDERS], @@ -56,18 +61,33 @@ class SearchDemo implements OnInit { public searchTerm: string = 'test'; - host: string = 'http://192.168.99.101:8080'; + host: string = 'http://192.168.99.100:8080'; + + token: string; constructor( private authService: AlfrescoAuthenticationService, - settings: AlfrescoSettingsService, + private alfrescoSettingsService: AlfrescoSettingsService, translation: AlfrescoTranslationService, searchService: AlfrescoService) { - settings.host = this.host; + alfrescoSettingsService.host = this.host; + if (localStorage.getItem('token')) { + this.token = localStorage.getItem('token'); + } + translation.translationInit(); } + public updateToken(): void { + localStorage.setItem('token', this.token); + } + + public updateHost(): void { + this.alfrescoSettingsService.host = this.host; + this.login(); + } + ngOnInit() { this.login(); } diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts index 68265961f4..218f3b379d 100644 --- a/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts +++ b/ng2-components/ng2-alfresco-search/src/services/alfresco.service.ts @@ -29,26 +29,18 @@ declare let AlfrescoApi: any; @Injectable() export class AlfrescoService { - private _host: string = 'http://127.0.0.1:8080'; private _baseUrlPath: string = '/alfresco/api/-default-/public/alfresco/versions/1'; constructor(private http: Http, private settings: AlfrescoSettingsService) { - if (settings) { - this._host = settings.host; - } } - public get host(): string { - return this._host; - } - - public set host(value: string) { - this._host = value; + public getHost(): string { + return this.settings.host; } private getBaseUrl(): string { - return this.host + this._baseUrlPath; + return this.getHost() + this._baseUrlPath; } private getAlfrescoTicket() { @@ -106,7 +98,7 @@ export class AlfrescoService { * @returns {string} URL address. */ getContentUrl(document: any) { - return this._host + + return this.getHost() + '/alfresco/service/api/node/workspace/SpacesStore/' + document.entry.id + '/content'; }