1 |
56563
|
konstantin
|
import {Component, Input, ViewChild} from '@angular/core';
|
2 |
|
|
import {ActivatedRoute} from '@angular/router';
|
3 |
|
|
import {Location} from '@angular/common';
|
4 |
|
|
import {SearchDataprovidersService} from '../services/searchDataproviders.service';
|
5 |
|
|
import {ErrorCodes} from '../utils/properties/errorCodes';
|
6 |
|
|
import {ErrorMessagesComponent} from '../utils/errorMessages.component';
|
7 |
|
|
import {SearchFields} from '../utils/properties/searchFields';
|
8 |
58244
|
argiro.kok
|
|
9 |
56840
|
konstantin
|
import {SearchUtilsClass} from '../searchPages/searchUtils/searchUtils.class';
|
10 |
56563
|
konstantin
|
import {EnvProperties} from '../utils/properties/env-properties';
|
11 |
|
|
import {ZenodoInformationClass} from "./utils/zenodoInformation.class";
|
12 |
56816
|
konstantin
|
import {RouterHelper} from "../utils/routerHelper.class";
|
13 |
56563
|
konstantin
|
|
14 |
|
|
@Component({
|
15 |
58244
|
argiro.kok
|
selector: 'deposit-search-dataproviders',
|
16 |
56563
|
konstantin
|
template: `
|
17 |
|
|
|
18 |
56677
|
argiro.kok
|
<div class="uk-section uk-padding-remove-bottom uk-padding-remove-top">
|
19 |
57406
|
konstantin
|
<div class="explorePanelBackground communityPanelBackground uk-margin-top uk-padding-small">
|
20 |
56563
|
konstantin
|
<div class="uk-container uk-container-large uk-margin-small-top uk-margin-small-bottom">
|
21 |
|
|
<ul class="uk-breadcrumb">
|
22 |
56816
|
konstantin
|
<li><a class="breadcrumb" routerLinkActive="router-link-active" [routerLink]="depositLearnHowPage"
|
23 |
|
|
[queryParams]="properties.environment!='development'?{}:routerHelper.createQueryParam('communityId',communityId)">
|
24 |
|
|
Deposit
|
25 |
|
|
</a></li>
|
26 |
57406
|
konstantin
|
<li><span class="active uk-text-bold">Browse content providers</span></li>
|
27 |
56563
|
konstantin
|
</ul>
|
28 |
|
|
</div>
|
29 |
|
|
</div>
|
30 |
|
|
</div>
|
31 |
58244
|
argiro.kok
|
<search-dataproviders [simpleView]="true" type="deposit" simpleSearchLink="/participate/deposit/search" >
|
32 |
|
|
</search-dataproviders>
|
33 |
56563
|
konstantin
|
`
|
34 |
|
|
})
|
35 |
|
|
export class SearchDataprovidersToDepositComponent {
|
36 |
|
|
private errorCodes: ErrorCodes;
|
37 |
|
|
private errorMessages: ErrorMessagesComponent;
|
38 |
|
|
@Input() piwikSiteId = null;
|
39 |
|
|
public results =[];
|
40 |
|
|
public filters =[];
|
41 |
|
|
public totalResults:number = 0 ;
|
42 |
|
|
public baseUrl:string;
|
43 |
|
|
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
44 |
|
|
public sub: any; public subResults: any;
|
45 |
|
|
public _location:Location;
|
46 |
|
|
public searchFields:SearchFields = new SearchFields();
|
47 |
|
|
public refineFields: string[] = this.searchFields.DEPOSIT_DATASOURCE_REFINE_FIELDS;
|
48 |
|
|
public fieldIdsMap= this.searchFields.DEPOSIT_DATASOURCE_FIELDS;
|
49 |
|
|
public keywordFields = this.searchFields.DEPOSIT_DATASOURCE_KEYWORD_FIELDS;
|
50 |
|
|
public csvParams: string;
|
51 |
|
|
|
52 |
|
|
public disableForms: boolean = false;
|
53 |
|
|
public loadPaging: boolean = true;
|
54 |
|
|
public oldTotalResults: number = 0;
|
55 |
|
|
pagingLimit = 0;
|
56 |
|
|
|
57 |
|
|
properties:EnvProperties;
|
58 |
|
|
|
59 |
58244
|
argiro.kok
|
// @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
60 |
56563
|
konstantin
|
|
61 |
56816
|
konstantin
|
@Input() public communityId: string = null;
|
62 |
56570
|
konstantin
|
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
63 |
|
|
|
64 |
56816
|
konstantin
|
depositLearnHowPage: string = null;
|
65 |
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
66 |
|
|
|
67 |
56840
|
konstantin
|
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService) {
|
68 |
56563
|
konstantin
|
this.errorCodes = new ErrorCodes();
|
69 |
|
|
this.errorMessages = new ErrorMessagesComponent();
|
70 |
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
71 |
|
|
this.searchUtils.page =1;
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
public ngOnInit() {
|
75 |
|
|
this.route.data
|
76 |
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
77 |
|
|
this.properties = data.envSpecific;
|
78 |
56816
|
konstantin
|
this.depositLearnHowPage = this.properties.depositLearnHowPage;
|
79 |
|
|
this.baseUrl = this.properties.depositSearchPage;
|
80 |
|
|
this.pagingLimit = this.properties.pagingLimit;
|
81 |
56563
|
konstantin
|
});
|
82 |
58244
|
argiro.kok
|
// this.searchPage.refineFields = this.refineFields;
|
83 |
|
|
// this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
84 |
|
|
// this.searchPage.keywordFields = this.keywordFields;
|
85 |
|
|
// var firstLoad =true;
|
86 |
|
|
//
|
87 |
|
|
// this.sub = this.route.queryParams.subscribe(params => {
|
88 |
|
|
// this.loadPaging = true;
|
89 |
|
|
// if(params['page'] && this.searchUtils.page != params['page']) {
|
90 |
|
|
// this.loadPaging = false;
|
91 |
|
|
// this.oldTotalResults = this.searchUtils.totalResults;
|
92 |
|
|
// }
|
93 |
|
|
//
|
94 |
|
|
// this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
95 |
|
|
// var refine = true;
|
96 |
|
|
// if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
|
97 |
|
|
// refine = false;
|
98 |
|
|
//
|
99 |
|
|
// }
|
100 |
|
|
// firstLoad = false;
|
101 |
|
|
// this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
102 |
|
|
// this.searchUtils.size = (params['size']=== undefined)?5:+params['size'];
|
103 |
|
|
// if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
104 |
|
|
// this.searchUtils.size = 5;
|
105 |
|
|
// }
|
106 |
|
|
// this.searchPage.usedBy = "deposit";
|
107 |
|
|
// var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
|
108 |
|
|
// this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
|
109 |
|
|
// });
|
110 |
56563
|
konstantin
|
}
|
111 |
|
|
|
112 |
|
|
public ngOnDestroy() {
|
113 |
|
|
if(this.sub){
|
114 |
|
|
this.sub.unsubscribe();
|
115 |
|
|
}
|
116 |
|
|
if(this.subResults){
|
117 |
|
|
this.subResults.unsubscribe();
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
|
121 |
58244
|
argiro.kok
|
/*public getResults(keyword:string,refine:boolean, page: number, size: number){
|
122 |
56563
|
konstantin
|
var parameters = "";
|
123 |
|
|
if(keyword.length > 0){
|
124 |
|
|
//parameters = "q="+ keyword;
|
125 |
|
|
|
126 |
|
|
if(this.keywordFields.length > 0) {
|
127 |
|
|
parameters = "&fq=";
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
for(let i=0; i< this.keywordFields.length ; i++) {
|
131 |
|
|
if(i > 0) {
|
132 |
|
|
parameters += " or ";
|
133 |
|
|
}
|
134 |
|
|
let field = this.keywordFields[i];
|
135 |
|
|
parameters += field.name+field.equalityOperator+StringUtils.URIEncode(this.searchUtils.keyword);
|
136 |
|
|
}
|
137 |
|
|
}
|
138 |
|
|
this._getResults(parameters,refine,page, size);
|
139 |
|
|
}
|
140 |
|
|
private _getResults(parameters:string,refine:boolean, page: number, size: number){
|
141 |
|
|
if(page > this.pagingLimit) {
|
142 |
|
|
size=0;
|
143 |
|
|
}
|
144 |
|
|
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
145 |
|
|
this.csvParams = parameters;
|
146 |
|
|
|
147 |
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
148 |
|
|
|
149 |
|
|
this.disableForms = true;
|
150 |
|
|
this.results = [];
|
151 |
|
|
this.searchUtils.totalResults = 0;
|
152 |
|
|
|
153 |
|
|
this.subResults = this._searchDataprovidersService.searchDataprovidersForDepositSearch(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields(),this.properties, "deposit").subscribe(
|
154 |
|
|
data => {
|
155 |
|
|
this.searchUtils.totalResults = data[0];
|
156 |
|
|
this.results = data[1];
|
157 |
|
|
if(refine){
|
158 |
|
|
this.filters = data[2];
|
159 |
|
|
}
|
160 |
|
|
this.searchPage.checkSelectedFilters(this.filters);
|
161 |
|
|
this.searchPage.updateBaseUrlWithParameters(this.filters);
|
162 |
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
163 |
|
|
if(this.searchUtils.totalResults == 0 ){
|
164 |
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
165 |
|
|
}
|
166 |
|
|
this.disableForms = false;
|
167 |
|
|
|
168 |
|
|
if(this.searchUtils.status == this.errorCodes.DONE) {
|
169 |
|
|
// Page out of limit!!!
|
170 |
|
|
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
171 |
|
|
if(!(Number.isInteger(totalPages))) {
|
172 |
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
173 |
|
|
}
|
174 |
|
|
if(totalPages < page) {
|
175 |
|
|
this.searchUtils.totalResults = 0;
|
176 |
|
|
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
177 |
|
|
}
|
178 |
|
|
}
|
179 |
|
|
},
|
180 |
|
|
err => {
|
181 |
|
|
this.handleError("Error getting content providers", err);
|
182 |
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
183 |
|
|
|
184 |
|
|
this.disableForms = false;
|
185 |
|
|
}
|
186 |
|
|
);
|
187 |
|
|
}
|
188 |
|
|
}
|
189 |
58244
|
argiro.kok
|
*/
|
190 |
56563
|
konstantin
|
|
191 |
|
|
private handleError(message: string, error) {
|
192 |
|
|
console.error("Content Providers simple Search Page: "+message, error);
|
193 |
|
|
}
|
194 |
|
|
}
|