adding a first draft for advanced search of projects - fixing autocomplete bug (init values when list of results already exists)

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44380 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2016-11-02 15:35:21 +00:00
parent 5437cc97e3
commit 000397b0ee
6 changed files with 158 additions and 1 deletions

View File

@ -21,6 +21,7 @@ import { SearchOrganizationsComponent } from './searchPages/searchOrganizations.
import { SearchPeopleComponent } from './searchPages/searchPeople.component';
import { AdvancedSearchPublicationsComponent } from './searchPages/advanced/advancedSearchPublications.component';
import { AdvancedSearchDataProvidersComponent } from './searchPages/advanced/advancedSearchDataProviders.component';
import { AdvancedSearchProjectsComponent } from './searchPages/advanced/advancedSearchProjects.component';
import { DepositComponent } from './deposit/deposit.component';
import { DepositResultComponent } from './deposit/depositResult.component';
@ -56,6 +57,7 @@ const appRoutes: Routes = [
{ path: 'search/find/people', component: SearchPeopleComponent },
{ path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent },
{ path: 'search/advanced/dataproviders', component: AdvancedSearchDataProvidersComponent },
{ path: 'search/advanced/projects', component: AdvancedSearchProjectsComponent },
{ path: 'deposit', component: DepositComponent},
{ path: 'deposit-results', component: DepositResultComponent},
{ path: 'test', component: TestComponent},

View File

@ -0,0 +1,112 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchProjectsService} from '../../services/searchProjects.service';
import {SearchResult} from '../../utils/entities/searchResult';
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component';
import {SearchFields} from '../../utils/properties/searchFields';
@Component({
selector: 'advanced-search-projects',
template: `
<advanced-search-page pageTitle="Advanced Search projects" entityType="project"
[(results)] = "results" [(totalResults)] = "totalResults"
[(page)] = "page" [(size)] = "size" [baseUrl] = "baseUrl"
[(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap" [(selectedFields)]="selectedFields"
[(status)] = "status"
(queryChange)="queryChanged($event)">
</advanced-search-page>
`
})
export class AdvancedSearchProjectsComponent {
private results =[];
private filters =[];
private totalResults:number = 0 ;
private page :number = 1;
private size :number = 10;
public status:number;
private baseUrl: string;
private searchFields:SearchFields = new SearchFields();
private fieldIds: string[] = this.searchFields.ADVANCED_PROJECTS_PARAM;
private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.PROJECT_FIELDS_MAP;
private selectedFields:AdvancedField[] = [];
@ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
constructor (private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService ) {
this.results =[];
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications();
}
ngOnInit() {
var errorCodes:ErrorCodes = new ErrorCodes();
this.status =errorCodes.LOADING;
this.sub = this.route.queryParams.subscribe(params => {
let page = (params['page']=== undefined)?1:+params['page'];
this.page = ( page <= 0 ) ? 1 : page;
this.searchPage.fieldIds = this.fieldIds;
this.searchPage.selectedFields = this.selectedFields;
this.searchPage.fieldIdsMap = this.fieldIdsMap;
this.searchPage.getSelectedFiltersFromUrl(params);
this.getResults(this.searchPage.createQueryParameters(), this.page, this.size);
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
sub: any;
public getResults(parameters:string, page: number, size: number){
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.LOADING;
console.info("Advanced Search Publications: Execute search query "+parameters);
this._searchProjectsService.searchProjects(parameters, null, page, size, []).subscribe(
data => {
this.totalResults = data[0];
console.info("Advanced Search Projects total="+this.totalResults);
this.results = data[1];
this.searchPage.updateBaseUrlWithParameters();
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.DONE;
if(this.totalResults == 0 ){
this.status = errorCodes.NONE;
}
},
err => {
console.error(err);
console.info("error");
//TODO check erros (service not available, bad request)
// if( ){
// this.status = ErrorCodes.ERROR;
// }
var errorCodes:ErrorCodes = new ErrorCodes();
this.status = errorCodes.NOT_AVAILABLE;
}
);
}
private setFilters(){
//TODO set filters from
}
private queryChanged($event) {
var parameters = $event.value;
this.getResults(parameters, this.page,this.size);
console.info("queryChanged: Execute search query "+parameters);
}
}

View File

@ -33,6 +33,7 @@ import {SearchEntityRegistriesComponent} from './dataProviders/entityRegistries.
//Advanced
import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPublications.component';
import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchDataProviders.component';
import { AdvancedSearchProjectsComponent } from './advanced/advancedSearchProjects.component';
@NgModule({
imports: [
@ -54,6 +55,7 @@ import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchD
SearchPublicationsComponent,
AdvancedSearchPublicationsComponent,
AdvancedSearchDataProvidersComponent,
AdvancedSearchProjectsComponent,
SearchDataprovidersComponent,
SearchComponent,
SearchProjectsComponent,
@ -71,6 +73,7 @@ import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchD
SearchAllComponent,
AdvancedSearchPublicationsComponent,
AdvancedSearchDataProvidersComponent,
AdvancedSearchProjectsComponent,
SearchPublicationsComponent,
SearchProjectsComponent,
SearchDataprovidersComponent,

View File

@ -24,6 +24,33 @@ Selected::
<dynamic-autocomplete [showSelected]=true
placeHolderMessage = "Search for Projects" title = "Projects:" ></dynamic-autocomplete>
<div>
<div class="container" >
<div class="title">
Welcome
</div>
<div class="panel-body">
<div class="row">
<div class="input-field col s12">
<input [(ngModel)]="user.email" id="email"
type="email" class="validate">
<label for="email">Email</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input [(ngModel)]="user.password" id="password"
type="password" class="validate">
<label for="password">Password</label>
</div>
</div>
<span>{{errorMsg}}</span>
<button (click)="login()"
class="btn waves-effect waves-light"
type="submit" name="action">Login</button>
</div>
</div>
`
//[(filtered)] =filteredObs [(selected)] =selectedObs
// [(searchTermStream)] = searchTermStream
@ -38,6 +65,8 @@ export class TestComponent {
// .switchMap((term: string) => this.service(term));
private lan;
private types;
private user:{password:string,email:string} = {password:"",email:""};
constructor(private _projectService: OpenaireProjectsService, private _vocabulariesService: ISVocabulariesService) {
// this.elementRef = myElement;
}
@ -45,6 +74,15 @@ export class TestComponent {
// this.lan = this._vocabulariesService.getLanguages();
this.lan = this._vocabulariesService.getLanguagesJsonFile();
this.types = this._vocabulariesService.getPublicationTypesJsonFile();
this.user.email = localStorage.getItem("email");
this.user.password = localStorage.getItem("password");
}
login(){
localStorage.setItem("email",this.user.email);
localStorage.setItem("password",this.user.password);
console.info("Save email/ password in local Storage. Email is:" + localStorage.getItem("email"));
}
service(term) {
var projects = this._projectService.searchForProjectsObs(term, "this.selectedFunderId");

View File

@ -89,6 +89,8 @@ export class StaticAutocomplete2Component {
}
);
}
}else{
this.afterListFetchedActions();
}
}

View File

@ -71,7 +71,7 @@ app.get('/search', ngApp);
app.get('/search/find/publications', ngApp);
app.get('/search/advanced/publications', ngApp);
app.get('/search/advanced/dataproviders', ngApp);
app.get('/search/advanced/projects', ngApp);
app.get('/search/find/dataproviders', ngApp);
app.get('/search/find/projects', ngApp);
app.get('/search/find/datasets', ngApp);