Project

General

Profile

« Previous | Next » 

Revision 50586

USe a json file to read properties | replace openaire Properties | parameterize menu (use params, community, ) | parameterize search pages (hide community information)

View differences:

searchDatasets.component.ts
5 5

  
6 6
import {SearchDatasetsService} from '../../services/searchDatasets.service';
7 7
import {SearchResult}     from '../../utils/entities/searchResult';
8
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
8
import { ErrorCodes} from '../../utils/properties/openaireProperties';
9 9
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
10 10
import {SearchPageComponent } from '../searchUtils/searchPage.component';
11 11
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
12 12
import {DOI} from '../../utils/string-utils.class';
13
import{EnvProperties} from '../../utils/properties/env-properties';
13 14

  
14 15
@Component({
15 16
    selector: 'search-datasets',
......
24 25
                 [disableForms]="disableForms"
25 26
                 [loadPaging]="loadPaging"
26 27
                 [oldTotalResults]="oldTotalResults"
27
                 searchFormClass="datasetsSearchForm">
28
                 searchFormClass="datasetsSearchForm"
29
                 [(openaireLink)]=openaireLink
30
                 [(advancedSearchParameters)]=advancedSearchParameters
31
                 [(connectCommunityId)]=connectCommunityId >
28 32
    </search-page>
29 33
    `
30 34
})
......
36 40
  public filters: Filter[] =[];
37 41
  // public totalResults:number  = 0 ;
38 42
  public baseUrl:string;
39

  
43
  @Input() openaireLink: string ;
44
  @Input() connectCommunityId: string;
45
  @Input() advancedSearchParameters ;
40 46
  public searchUtils:SearchUtilsClass = new SearchUtilsClass();
41 47
  private sub: any;
42 48
  private subResults: any;
......
49 55
  public disableForms: boolean = false;
50 56
  public loadPaging: boolean = true;
51 57
  public oldTotalResults: number = 0;
52

  
58
  pagingLimit = 0;
59
properties: EnvProperties;
53 60
  @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
54 61
  constructor (private route: ActivatedRoute, private _searchDatasetsService: SearchDatasetsService ) {
55 62

  
56 63
    this.errorCodes = new ErrorCodes();
57 64
    this.searchUtils.status = this.errorCodes.LOADING;
58 65
    this.searchUtils.page =1;
59
    this.baseUrl = OpenaireProperties.getLinkToSearchDatasets();
60 66

  
61 67
  }
62 68

  
63 69
  public ngOnInit() {
70
    this.route.data
71
      .subscribe((data: { envSpecific: EnvProperties }) => {
72
        this.properties = data.envSpecific;
73
        this.baseUrl = data.envSpecific.searchLinkToDatasets;
74
        this.pagingLimit = data.envSpecific.pagingLimit;
75

  
76
      });
64 77
    this.searchPage.refineFields = this.refineFields;
65 78
     this.searchPage.fieldIdsMap = this.fieldIdsMap;
66 79
     this.searchPage.type = "research data";
......
104 117

  
105 118
  if(parameters != "") {
106 119

  
107
      this._searchDatasetsService.searchDatasetsForEntity(parameters, page, size).subscribe(
120
      this._searchDatasetsService.searchDatasetsForEntity(parameters, page, size, this.properties).subscribe(
108 121
          data => {
109 122
              this.searchUtils.totalResults = data[0];
110 123
              console.info("search Research Data for "+entity+": [Parameters:"+parameters+" ]  [total results:"+this.searchUtils.totalResults+"]");
......
146 159

  
147 160
  if(parameters != "") {
148 161

  
149
      this._searchDatasetsService.searchDatasetsForDataproviders(parameters, page, size).subscribe(
162
      this._searchDatasetsService.searchDatasetsForDataproviders(parameters, page, size, this.properties).subscribe(
150 163
          data => {
151 164
              this.searchUtils.totalResults = data[0];
152 165
              console.info("search Research Data for Dataproviders: [Parameters:"+parameters+" ]  [total results:"+this.searchUtils.totalResults+"]");
......
195 208
  this._getResults(parameters,refine,page,size);
196 209
}
197 210
private _getResults(parameters:string,refine:boolean, page: number, size: number){
211
  if(page > this.pagingLimit) {
212
    size=0;
213
  }
214
  if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
198 215
    this.csvParams = parameters;
199 216

  
200
  // if(!refine && !this.searchPage){
201
  //     this.searchPage = new SearchPageComponent(this._location);
202
  // }
203
  //var errorCodes:ErrorCodes = new ErrorCodes();
204
  this.searchUtils.status = this.errorCodes.LOADING;
205
  //this.searchPage.openLoading();
206
  this.disableForms = true;
207
  this.results = [];
208
  this.searchUtils.totalResults = 0;
217
    this.searchUtils.status = this.errorCodes.LOADING;
218
    //this.searchPage.openLoading();
219
    this.disableForms = true;
220
    this.results = [];
221
    this.searchUtils.totalResults = 0;
209 222

  
210
  this.subResults = this._searchDatasetsService.searchDatasets(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe(
223
    this.subResults = this._searchDatasetsService.searchDatasets(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields(), this.properties).subscribe(
211 224
      data => {
212 225
          this.searchUtils.totalResults = data[0];
213 226
          console.info("search Research Data: [Parameters:"+parameters+" ]  [total results:"+this.searchUtils.totalResults+"]");
......
256 269
          //this.searchPage.closeLoading();
257 270
          this.disableForms = false;
258 271
      }
259
  );
272
    );
273
  }
260 274
}
261 275

  
262 276

  
......
267 281

  
268 282
  public queryChanged($event) {
269 283
    this.loadPaging = true;
270
    
284

  
271 285
    var parameters = $event.value;
272 286
    //this.getResults(parameters, this.searchUtils.page, this.searchUtils.size, "searchPage");
273 287
    this._getResults(parameters, true, this.searchUtils.page, this.searchUtils.size);

Also available in: Unified diff