put timers-functions in 2 components to watch execution.. | fixing query for entities in autocomlete

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44772 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-12-02 12:01:15 +00:00
parent 4467c0dd0c
commit 125e427554
6 changed files with 96 additions and 35 deletions

View File

@ -200,10 +200,10 @@ export class ClaimSelectedComponent {
@Component({
selector: 'add-more',
template: ``
})
export class Addmore {
@Input() type = 'publication';
}
// @Component({
// selector: 'add-more',
// template: ``
// })
// export class Addmore {
// @Input() type = 'publication';
// }

View File

@ -1,15 +0,0 @@
<div class="container">
<div class="row">
<form>
<div class="col-lg-6">
<div class="input-group">
<input #term type="text" class="form-control col-xs-5" placeholder="Search for..." name="keyword" >
<span class="input-group-btn">
<button class="btn btn-default" type="submit" (click)="searchTerm(term.value)" >GO</button>
</span>
</div>
</div>
</form>
</div>
</div>

View File

@ -5,11 +5,54 @@ import {Location} from '@angular/common';
@Component({
selector: 'home',
templateUrl: 'home.component.html',
template:`
<div class="container">
<div class="row">
<form>
<div class="col-lg-6">
<div class="input-group">
<input #term type="text" class="form-control col-xs-5" placeholder="Search for..." name="keyword" >
<span class="input-group-btn">
<button class="btn btn-default" type="submit" (click)="searchTerm(term.value)" >GO</button>
</span>
</div>
</div>
</form>
</div>
</div>
`
})
export class HomeComponent {
constructor ( private _router: Router, private location: Location) {}
private start ;private end ;
constructor ( private _router: Router, private location: Location) {
this.start = new Date().getTime();
}
ngOnInit() {
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngOnInit:Execution time: ' + time);
}
ngAfterContentInit() {
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngAfterContentInit:Execution time: ' + time);
}
ngAfterViewChecked() {
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngAfterViewChecked: Execution time: ' + time);
}
searchTerm(term: string) {
window.location.href="/search?keyword="+term;

View File

@ -13,7 +13,10 @@ import{TabsComponent} from './tabs.component';
})
export class DataProviderComponent {
private start ;private end ;
constructor (private _publicationService: DataProviderService, private route: ActivatedRoute) {
this.start = new Date().getTime();
}
ngOnInit() {
this.sub = this.route.queryParams.subscribe(data => {
@ -24,11 +27,25 @@ export class DataProviderComponent {
}else{
console.info("Datasource id not found");
}
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngOnInit:Execution time: ' + time);
});
});
}
}
ngAfterContentInit() {
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngAfterContentInit:Execution time: ' + time);
}
ngAfterViewChecked() {
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngAfterViewChecked: Execution time: ' + time);
}
ngOnDestroy() {
this.sub.unsubscribe();

View File

@ -20,8 +20,9 @@ export class PublicationComponent {
private showAllFundedBy: boolean = false;
private showAllPublishedIn: boolean = false;
private start ;private end ;
constructor (private _publicationService: PublicationService, private route: ActivatedRoute) {
this.start = new Date().getTime();
}
ngOnInit() {
this.sub = this.route.queryParams.subscribe(data => {
@ -32,11 +33,27 @@ export class PublicationComponent {
}else{
console.info("Article id not found");
}
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngOnInit:Execution time: ' + time);
});
}
ngAfterContentInit() {
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngAfterContentInit:Execution time: ' + time);
}
ngAfterViewChecked() {
// console.info("indentifiers:"+(this.publicationInfo != undefined&& this.publicationInfo.identifiers!= undefined)?this.publicationInfo.identifiers.size:"-");
this.end = new Date().getTime();
var time = this.end - this.start;
console.log('ngAfterViewChecked: Execution time: ' + time);
}
ngOnDestroy() {
this.sub.unsubscribe();

View File

@ -14,8 +14,7 @@ export class EntitiesSearchService {
constructor(private http: Http, public _cache: CacheService) {}
searchProjectsByFunder(keyword:string, funderId:string):any {
//TODO .............
let url = OpenaireProperties. getSearchAPIURLLast()+"projects?"+((keyword && keyword.length > 0)?("q=" +keyword+"&op=and"):"")+"&funder="+funderId+"&fn=and&size=10&page=1"+"&format=json";
let url = OpenaireProperties. getSearchAPIURLLast()+"projects?"+((keyword && keyword.length > 0)?("q=" +keyword):"")+"&fq=funderid exact " + '"'+funderId+ '"'+"&size=10&page=0&format=json";
return this.http.get(url).toPromise()
.then(request =>
{
@ -58,16 +57,16 @@ export class EntitiesSearchService {
}
private searchEntity (keyword: string,APIname:string,oafEntityType:string, type:string):any {
let link = OpenaireProperties. getSearchAPIURLLast()+APIname+"?format=json";
let link = OpenaireProperties. getSearchAPIURLLast()+APIname;
return this.search(link,keyword,oafEntityType,type)
}
private fetchEntity (id: string,APIname:string,oafEntityType:string, type:string):any {
let link = OpenaireProperties. getSearchAPIURLLast()+APIname+"?format=json";
let link = OpenaireProperties. getSearchAPIURLLast()+APIname;
return this.fetch(link,id,oafEntityType,type)
}
private fetch (link,id,oafEntityType,type){
let url = link+"/"+id;
let url = link+"/"+id+"?format=json";
return this.http.get(url)
.map(request => <any> request.json())
// .do(res => console.info(res))
@ -79,10 +78,10 @@ private fetch (link,id,oafEntityType,type){
private search (link,keyword,oafEntityType,type){
let url = link+"?";
if(keyword!= null && keyword != '' ) {
url += "q="+ keyword+"&op=and";
url += "q="+ keyword;
}
//TODO change page size when new API is ready
url += "&page="+(type == "publication"?0:1)+"&size="+10;
url += "&page=0&size="+10+"&format=json";
return this.http.get(url).toPromise()
.then(request =>
{