mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
update example search
This commit is contained in:
@@ -100,35 +100,56 @@ import {
|
|||||||
ALFRESCO_CORE_PROVIDERS,
|
ALFRESCO_CORE_PROVIDERS,
|
||||||
AlfrescoSettingsService,
|
AlfrescoSettingsService,
|
||||||
AlfrescoAuthenticationService,
|
AlfrescoAuthenticationService,
|
||||||
AlfrescoPipeTranslate,
|
|
||||||
AlfrescoTranslationService
|
AlfrescoTranslationService
|
||||||
} from 'ng2-alfresco-core/dist/ng2-alfresco-core';
|
} from 'ng2-alfresco-core/dist/ng2-alfresco-core';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ALFRESCO_SEARCH_PROVIDERS,
|
ALFRESCO_SEARCH_DIRECTIVES
|
||||||
ALFRESCO_SEARCH_DIRECTIVES,
|
|
||||||
AlfrescoService
|
|
||||||
} from 'ng2-alfresco-search/dist/ng2-alfresco-search';
|
} from 'ng2-alfresco-search/dist/ng2-alfresco-search';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'alfresco-search-demo',
|
selector: 'alfresco-search-demo',
|
||||||
template: `
|
template: `
|
||||||
<alfresco-search-control [searchTerm]="searchTerm" (searchChange)="searchTermChange($event);">
|
<alfresco-search-control *ngIf="authenticated" [searchTerm]="searchTerm" (searchChange)="searchTermChange($event);">
|
||||||
</alfresco-search-control>
|
</alfresco-search-control>
|
||||||
|
<div *ngIf="!authenticated">
|
||||||
|
Authentication failed to ip {{ host }}
|
||||||
|
</div>
|
||||||
`,
|
`,
|
||||||
directives: [ALFRESCO_SEARCH_DIRECTIVES]
|
directives: [ALFRESCO_SEARCH_DIRECTIVES]
|
||||||
})
|
})
|
||||||
class SearchDemo implements OnInit {
|
class SearchDemo implements OnInit {
|
||||||
|
|
||||||
public searchTerm: string = 'foo bar';
|
public searchTerm: string = 'test';
|
||||||
|
|
||||||
constructor() {
|
authenticated: boolean;
|
||||||
|
|
||||||
|
host: string = 'http://192.168.99.100:8080';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private authService: AlfrescoAuthenticationService,
|
||||||
|
settings: AlfrescoSettingsService,
|
||||||
|
translation: AlfrescoTranslationService) {
|
||||||
|
|
||||||
|
settings.host = this.host;
|
||||||
|
translation.translationInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
searchTermChange(event) {
|
searchTermChange(event) {
|
||||||
console.log('Search term changed', event);
|
console.log('Search term changed', event);
|
||||||
this.searchTerm = event.value;
|
this.searchTerm = event.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.login();
|
||||||
|
}
|
||||||
|
|
||||||
|
login() {
|
||||||
|
this.authService.login('admin', 'admin').subscribe(token => {
|
||||||
|
this.authenticated = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap(SearchDemo, [
|
bootstrap(SearchDemo, [
|
||||||
@@ -219,30 +240,71 @@ search term. If no ruter is present pon the page of if the router does not provi
|
|||||||
results page will be shown.
|
results page will be shown.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Component } from 'angular2/core';
|
import { Component, OnInit } from 'angular2/core';
|
||||||
import { bootstrap } from 'angular2/platform/browser';
|
import { bootstrap } from 'angular2/platform/browser';
|
||||||
import { HTTP_PROVIDERS } from 'angular2/http';
|
import { HTTP_PROVIDERS } from 'angular2/http';
|
||||||
|
|
||||||
import { ALFRESCO_CORE_PROVIDERS } from 'ng2-alfresco-core/dist/ng2-alfresco-core';
|
import {
|
||||||
import { ALFRESCO_SEARCH_DIRECTIVES } from 'ng2-alfresco-search/dist/ng2-alfresco-search';
|
ALFRESCO_CORE_PROVIDERS,
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoTranslationService
|
||||||
|
} from 'ng2-alfresco-core/dist/ng2-alfresco-core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
ALFRESCO_SEARCH_DIRECTIVES
|
||||||
|
} from 'ng2-alfresco-search/dist/ng2-alfresco-search';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'alfresco-search-demo',
|
selector: 'alfresco-search-demo',
|
||||||
template: `
|
template: `
|
||||||
<alfresco-search [searchTerm]="searchTerm"></alfresco-search>
|
<alfresco-search *ngIf="authenticated" [searchTerm]="searchTerm"></alfresco-search>
|
||||||
|
<div *ngIf="!authenticated">
|
||||||
|
Authentication failed to ip {{ host }}
|
||||||
|
</div>
|
||||||
`,
|
`,
|
||||||
directives: [ALFRESCO_SEARCH_DIRECTIVES]
|
directives: [ALFRESCO_SEARCH_DIRECTIVES]
|
||||||
})
|
})
|
||||||
class SearchDemo {
|
class SearchDemo implements OnInit {
|
||||||
searchTerm: string = '';
|
|
||||||
constructor() {
|
public searchTerm: string = 'test';
|
||||||
|
|
||||||
|
authenticated: boolean;
|
||||||
|
|
||||||
|
host: string = 'http://192.168.99.101:8080';
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private authService: AlfrescoAuthenticationService,
|
||||||
|
settings: AlfrescoSettingsService,
|
||||||
|
translation: AlfrescoTranslationService) {
|
||||||
|
|
||||||
|
settings.host = this.host;
|
||||||
|
translation.translationInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchTermChange(event) {
|
||||||
|
console.log('Search term changed', event);
|
||||||
|
this.searchTerm = event.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.login();
|
||||||
|
}
|
||||||
|
|
||||||
|
login() {
|
||||||
|
this.authService.login('admin', 'admin').subscribe(token => {
|
||||||
|
this.authenticated = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bootstrap(SearchDemo, [
|
bootstrap(SearchDemo, [
|
||||||
HTTP_PROVIDERS,
|
HTTP_PROVIDERS,
|
||||||
ALFRESCO_CORE_PROVIDERS
|
ALFRESCO_CORE_PROVIDERS
|
||||||
]);
|
]);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Example of an component that displays search results, taking the search term from a `@Input` property provided by the container.
|
Example of an component that displays search results, taking the search term from a `@Input` property provided by the container.
|
||||||
|
@@ -54,9 +54,9 @@ class SearchDemo implements OnInit {
|
|||||||
|
|
||||||
authenticated: boolean;
|
authenticated: boolean;
|
||||||
|
|
||||||
public searchTerm: string = 'foo bar';
|
public searchTerm: string = 'test';
|
||||||
|
|
||||||
host: string = 'http://192.168.99.100:8080';
|
host: string = 'http://192.168.99.101:8080';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private authService: AlfrescoAuthenticationService,
|
private authService: AlfrescoAuthenticationService,
|
||||||
|
Reference in New Issue
Block a user