mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
update service and demo search
This commit is contained in:
@@ -35,15 +35,20 @@ import {
|
||||
|
||||
@Component({
|
||||
selector: 'alfresco-search-demo',
|
||||
template: `
|
||||
<div class="container" *ngIf="authenticated">
|
||||
<alfresco-search-control [searchTerm]="searchTerm"
|
||||
(searchChange)="searchTermChange($event);"></alfresco-search-control>
|
||||
<alfresco-search [searchTerm]="searchTerm"></alfresco-search>
|
||||
</div>
|
||||
<div *ngIf="!authenticated">
|
||||
Authentication failed to ip {{ host }}
|
||||
</div>
|
||||
template: `<label for="token"><b>Insert a valid access token / ticket:</b></label><br>
|
||||
<input id="token" type="text" size="48" (change)="updateToken()" [(ngModel)]="token"><br>
|
||||
<label for="token"><b>Insert the ip of your Alfresco instance:</b></label><br>
|
||||
<input id="token" type="text" size="48" (change)="updateHost()" [(ngModel)]="host"><br><br>
|
||||
<div *ngIf="!authenticated" style="color:#FF2323">
|
||||
Authentication failed to ip {{ host }} with user: admin, admin, you can still try to add a valid token to perform
|
||||
operations.
|
||||
</div>
|
||||
<hr>
|
||||
<div class="container" >
|
||||
<alfresco-search-control [searchTerm]="searchTerm"
|
||||
(searchChange)="searchTermChange($event);"></alfresco-search-control>
|
||||
<alfresco-search [searchTerm]="searchTerm"></alfresco-search>
|
||||
</div>
|
||||
`,
|
||||
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();
|
||||
}
|
||||
|
@@ -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';
|
||||
}
|
||||
|
Reference in New Issue
Block a user