Project

General

Profile

« Previous | Next » 

Revision 49174

Utils of landing pages moved to 'landing-utils' folder | errorMessages.component created to centralize errorMessages according to ErrorCodes in openaireProperties.ts file | http service returning errorCodes and proper display fixed in search and fetch subscriptions (claims, home component, html project report page, csv files, basic info in landing pages, helper component, staticAutocomplete do not return errorCodes yet) | simple searchPages: paging remains when page changes while results load, filters on the left do not change position according to paging

View differences:

advancedSearchOrganizations.component.ts
20 20
                 [(fieldIds)]="fieldIds" [(fieldIdsMap)]="fieldIdsMap"   [(selectedFields)]="selectedFields"
21 21
                 (queryChange)="queryChanged($event)"
22 22
                 [csvParams]="csvParams" csvPath="resources" simpleSearchLink="/search/find/organizations"
23
                 [disableForms]="disableForms">
23
                 [disableForms]="disableForms"
24
                 [loadPaging]="loadPaging"
25
                 [oldTotalResults]="oldTotalResults">
24 26
    </advanced-search-page>
25 27

  
26 28
    `
27 29
 })
28 30

  
29 31
export class AdvancedSearchOrganizationsComponent {
32
  private errorCodes: ErrorCodes;
33

  
30 34
  public results =[];
31 35
  public filters =[];
32 36
  public searchUtils:SearchUtilsClass = new SearchUtilsClass();
......
37 41
  public selectedFields:AdvancedField[] =  [];
38 42
  public csvParams: string;
39 43
  public disableForms: boolean = false;
44
  public loadPaging: boolean = true;
45
  public oldTotalResults: number = 0;
40 46

  
41 47
  @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ;
42 48

  
43 49
public resourcesQuery = "(oaftype exact organization)";
44 50
  constructor (private route: ActivatedRoute, private _searchOrganizationsService: SearchOrganizationsService ) {
45

  
46 51
    this.results =[];
47
    var errorCodes:ErrorCodes = new ErrorCodes();
48
    this.searchUtils.status =errorCodes.LOADING;
52
    this.errorCodes = new ErrorCodes();
53
    this.searchUtils.status = this.errorCodes.LOADING;
49 54
    this.searchUtils.baseUrl = OpenaireProperties.searchLinkToAdvancedOrganizations;
50 55

  
51 56

  
52 57

  
53 58
  }
54 59
  ngOnInit() {
55
    var errorCodes:ErrorCodes = new ErrorCodes();
56
    this.searchUtils.status =errorCodes.LOADING;
60
    //var errorCodes:ErrorCodes = new ErrorCodes();
61
    this.searchUtils.status = this.errorCodes.LOADING;
57 62

  
58
   this.sub =  this.route.queryParams.subscribe(params => {
63
    this.sub =  this.route.queryParams.subscribe(params => {
64
      if(params['page'] && this.searchUtils.page != params['page']) {
65
        this.loadPaging = false;
66
        this.oldTotalResults = this.searchUtils.totalResults;
67
      }
68

  
59 69
      let page = (params['page']=== undefined)?1:+params['page'];
60 70
      this.searchUtils.page = ( page <= 0 ) ? 1 : page;
61 71
      this.searchPage.fieldIds = this.fieldIds;
......
78 88
        this.csvParams ="&type=organizations&query="+this.resourcesQuery;
79 89
      }
80 90

  
81
    var errorCodes:ErrorCodes = new ErrorCodes();
82
    this.searchUtils.status = errorCodes.LOADING;
91
    //var errorCodes:ErrorCodes = new ErrorCodes();
92
    this.searchUtils.status = this.errorCodes.LOADING;
83 93
    //this.searchPage.openLoading();
84 94
    this.disableForms = true;
85 95
    this.results = [];
......
92 102
            console.info("search Organizations total="+this.searchUtils.totalResults);
93 103
            this.results = data[1];
94 104
            this.searchPage.updateBaseUrlWithParameters();
95
            var errorCodes:ErrorCodes = new ErrorCodes();
96
             this.searchUtils.status = errorCodes.DONE;
105
            //var errorCodes:ErrorCodes = new ErrorCodes();
106
            this.searchUtils.status = this.errorCodes.DONE;
97 107
            if(this.searchUtils.totalResults == 0 ){
98
              this.searchUtils.status = errorCodes.NONE;
108
              this.searchUtils.status = this.errorCodes.NONE;
99 109
            }
100 110
            //this.searchPage.closeLoading();
101 111
            this.disableForms = false;
102 112

  
103
            if(this.searchUtils.status == errorCodes.DONE) {
113
            if(this.searchUtils.status == this.errorCodes.DONE) {
104 114
              // Page out of limit!!!
105 115
              let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
106 116
              if(!(Number.isInteger(totalPages))) {
......
108 118
              }
109 119
              if(totalPages < page) {
110 120
                this.searchUtils.totalResults = 0;
111
                this.searchUtils.status = errorCodes.OUT_OF_BOUND;
121
                this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
112 122
              }
113 123
            }
114 124
        },
......
119 129
            // if( ){
120 130
            //   this.searchUtils.status = errorCodes.ERROR;
121 131
            // }
122
            var errorCodes:ErrorCodes = new ErrorCodes();
123
            this.searchUtils.status = errorCodes.NOT_AVAILABLE;
132
            //var errorCodes:ErrorCodes = new ErrorCodes();
133
            //this.searchUtils.status = errorCodes.NOT_AVAILABLE;
134
            if(err.status == '404') {
135
              this.searchUtils.status = this.errorCodes.NOT_FOUND;
136
            } else if(err.status == '500') {
137
              this.searchUtils.status = this.errorCodes.ERROR;
138
            } else {
139
              this.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
140
            }
141

  
124 142
            //this.searchPage.closeLoading();
125 143
            this.disableForms = false;
126 144
        }
......
131 149
  }
132 150

  
133 151
  public queryChanged($event) {
152
    this.loadPaging = true;
153
    
134 154
    var parameters = $event.value;
135 155
    this.getResults(parameters, this.searchUtils.page,this.searchUtils.size);
136 156
    console.info("queryChanged: Execute search query "+parameters);

Also available in: Unified diff