1 |
56563
|
konstantin
|
import {Component, Input, ViewChild} from '@angular/core';
|
2 |
58563
|
argiro.kok
|
import {ActivatedRoute, Router} from '@angular/router';
|
3 |
56563
|
konstantin
|
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 |
58563
|
argiro.kok
|
import {SearchCustomFilter, 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 |
58563
|
argiro.kok
|
import {Breadcrumb} from "../utils/breadcrumbs/breadcrumbs.component";
|
14 |
56563
|
konstantin
|
|
15 |
|
|
@Component({
|
16 |
58244
|
argiro.kok
|
selector: 'deposit-search-dataproviders',
|
17 |
56563
|
konstantin
|
template: `
|
18 |
|
|
|
19 |
56677
|
argiro.kok
|
<div class="uk-section uk-padding-remove-bottom uk-padding-remove-top">
|
20 |
58649
|
konstantin
|
<div class="explorePanelBackground communityPanelBackground uk-padding-small">
|
21 |
56563
|
konstantin
|
<div class="uk-container uk-container-large uk-margin-small-top uk-margin-small-bottom">
|
22 |
58563
|
argiro.kok
|
<!--<ul class="uk-breadcrumb">
|
23 |
56816
|
konstantin
|
<li><a class="breadcrumb" routerLinkActive="router-link-active" [routerLink]="depositLearnHowPage"
|
24 |
|
|
[queryParams]="properties.environment!='development'?{}:routerHelper.createQueryParam('communityId',communityId)">
|
25 |
|
|
Deposit
|
26 |
|
|
</a></li>
|
27 |
57406
|
konstantin
|
<li><span class="active uk-text-bold">Browse content providers</span></li>
|
28 |
58563
|
argiro.kok
|
</ul>-->
|
29 |
58571
|
argiro.kok
|
<breadcrumbs [light]="!!(this.communityId)" [breadcrumbs]="breadcrumbs"></breadcrumbs>
|
30 |
56563
|
konstantin
|
</div>
|
31 |
|
|
</div>
|
32 |
|
|
</div>
|
33 |
58649
|
konstantin
|
<div class="">
|
34 |
58563
|
argiro.kok
|
<div class="uk-container uk-container-large">
|
35 |
|
|
|
36 |
|
|
<form
|
37 |
|
|
class="uk-margin-top uk-grid uk-margin-small-left ng-untouched ng-pristine ng-valid uk-form-width-large uk-float-right">
|
38 |
|
|
|
39 |
|
|
<div class=" uk-padding-remove-left uk-margin-small-top uk-inline uk-width-expand">
|
40 |
|
|
<a *ngIf="keyword.length > 0" class="uk-form-icon uk-form-icon-flip"
|
41 |
|
|
(click)="keyword = ''"
|
42 |
|
|
uk-icon="icon: close"></a>
|
43 |
|
|
<input type="text" class="uk-input text-input-box uk-width-expand"
|
44 |
|
|
placeholder="Search by name, description, subject..." aria-describedby="sizing-addon2"
|
45 |
|
|
[(ngModel)]="keyword" name="keyword">
|
46 |
|
|
</div>
|
47 |
|
|
<!--<div class="uk-padding-remove-left uk-margin-small-top">
|
48 |
|
|
<button (click)="keywordChanged()" type="submit"
|
49 |
|
|
class=" uk-button portal-button uk-text-bold ">
|
50 |
|
|
Search
|
51 |
|
|
</button>
|
52 |
|
|
</div>-->
|
53 |
58572
|
argiro.kok
|
<div class="uk-padding-remove-left">
|
54 |
58563
|
argiro.kok
|
<button (click)="keywordChanged()" type="submit"
|
55 |
|
|
class="portal-button uk-margin-small-left uk-margin-small-top uk-button">Search
|
56 |
|
|
</button>
|
57 |
58572
|
argiro.kok
|
</div>
|
58 |
58563
|
argiro.kok
|
|
59 |
|
|
</form>
|
60 |
|
|
</div>
|
61 |
|
|
<search-dataproviders [simpleView]="true" type="deposit" simpleSearchLink="/participate/deposit/search" [includeOnlyResultsAndFilter]="true" >
|
62 |
|
|
</search-dataproviders>
|
63 |
|
|
</div>
|
64 |
56563
|
konstantin
|
`
|
65 |
|
|
})
|
66 |
|
|
export class SearchDataprovidersToDepositComponent {
|
67 |
|
|
private errorCodes: ErrorCodes;
|
68 |
|
|
private errorMessages: ErrorMessagesComponent;
|
69 |
|
|
@Input() piwikSiteId = null;
|
70 |
|
|
public results =[];
|
71 |
|
|
public filters =[];
|
72 |
|
|
public totalResults:number = 0 ;
|
73 |
|
|
public baseUrl:string;
|
74 |
|
|
public searchUtils:SearchUtilsClass = new SearchUtilsClass();
|
75 |
|
|
public sub: any; public subResults: any;
|
76 |
|
|
public _location:Location;
|
77 |
|
|
public searchFields:SearchFields = new SearchFields();
|
78 |
|
|
public refineFields: string[] = this.searchFields.DEPOSIT_DATASOURCE_REFINE_FIELDS;
|
79 |
|
|
public fieldIdsMap= this.searchFields.DEPOSIT_DATASOURCE_FIELDS;
|
80 |
|
|
public keywordFields = this.searchFields.DEPOSIT_DATASOURCE_KEYWORD_FIELDS;
|
81 |
|
|
public csvParams: string;
|
82 |
|
|
|
83 |
|
|
public disableForms: boolean = false;
|
84 |
|
|
public loadPaging: boolean = true;
|
85 |
|
|
public oldTotalResults: number = 0;
|
86 |
|
|
pagingLimit = 0;
|
87 |
|
|
|
88 |
|
|
properties:EnvProperties;
|
89 |
|
|
|
90 |
58244
|
argiro.kok
|
// @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
|
91 |
56563
|
konstantin
|
|
92 |
56816
|
konstantin
|
@Input() public communityId: string = null;
|
93 |
56570
|
konstantin
|
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
94 |
|
|
|
95 |
56816
|
konstantin
|
depositLearnHowPage: string = null;
|
96 |
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
97 |
58563
|
argiro.kok
|
breadcrumbs:Breadcrumb[] = [];
|
98 |
|
|
parameters = {};
|
99 |
|
|
keyword = "";
|
100 |
|
|
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService, private router: Router) {
|
101 |
56563
|
konstantin
|
this.errorCodes = new ErrorCodes();
|
102 |
|
|
this.errorMessages = new ErrorMessagesComponent();
|
103 |
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
104 |
|
|
this.searchUtils.page =1;
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
public ngOnInit() {
|
108 |
58563
|
argiro.kok
|
|
109 |
56563
|
konstantin
|
this.route.data
|
110 |
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
111 |
|
|
this.properties = data.envSpecific;
|
112 |
56816
|
konstantin
|
this.depositLearnHowPage = this.properties.depositLearnHowPage;
|
113 |
|
|
this.baseUrl = this.properties.depositSearchPage;
|
114 |
|
|
this.pagingLimit = this.properties.pagingLimit;
|
115 |
58563
|
argiro.kok
|
this.breadcrumbs.push({name: 'home', route: '/'}, {
|
116 |
|
|
name: "Deposit",
|
117 |
|
|
route: this.depositLearnHowPage
|
118 |
|
|
}, {name: "Browse repositories", route: null});
|
119 |
56563
|
konstantin
|
});
|
120 |
58563
|
argiro.kok
|
this.sub = this.route.queryParams.subscribe(params => {
|
121 |
58606
|
argiro.kok
|
this.parameters = Object.assign({}, params);
|
122 |
58563
|
argiro.kok
|
this.keyword = params["fv0"]?params["fv0"]:'';
|
123 |
|
|
});
|
124 |
58244
|
argiro.kok
|
// this.searchPage.refineFields = this.refineFields;
|
125 |
|
|
// this.searchPage.fieldIdsMap = this.fieldIdsMap;
|
126 |
|
|
// this.searchPage.keywordFields = this.keywordFields;
|
127 |
|
|
// var firstLoad =true;
|
128 |
|
|
//
|
129 |
|
|
// this.sub = this.route.queryParams.subscribe(params => {
|
130 |
|
|
// this.loadPaging = true;
|
131 |
|
|
// if(params['page'] && this.searchUtils.page != params['page']) {
|
132 |
|
|
// this.loadPaging = false;
|
133 |
|
|
// this.oldTotalResults = this.searchUtils.totalResults;
|
134 |
|
|
// }
|
135 |
|
|
//
|
136 |
|
|
// this.searchUtils.keyword = (params['keyword']?params['keyword']:'');
|
137 |
|
|
// var refine = true;
|
138 |
|
|
// if(this.searchUtils.page != ((params['page']=== undefined)?1:+params['page']) && this.filters && !firstLoad){
|
139 |
|
|
// refine = false;
|
140 |
|
|
//
|
141 |
|
|
// }
|
142 |
|
|
// firstLoad = false;
|
143 |
|
|
// this.searchUtils.page = (params['page']=== undefined)?1:+params['page'];
|
144 |
|
|
// this.searchUtils.size = (params['size']=== undefined)?5:+params['size'];
|
145 |
|
|
// if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
146 |
|
|
// this.searchUtils.size = 5;
|
147 |
|
|
// }
|
148 |
|
|
// this.searchPage.usedBy = "deposit";
|
149 |
|
|
// var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
|
150 |
|
|
// this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
|
151 |
|
|
// });
|
152 |
56563
|
konstantin
|
}
|
153 |
|
|
|
154 |
|
|
public ngOnDestroy() {
|
155 |
|
|
if(this.sub){
|
156 |
|
|
this.sub.unsubscribe();
|
157 |
|
|
}
|
158 |
|
|
if(this.subResults){
|
159 |
|
|
this.subResults.unsubscribe();
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
58563
|
argiro.kok
|
keywordChanged(){
|
163 |
56563
|
konstantin
|
|
164 |
58563
|
argiro.kok
|
if ( this.keyword.length > 0) {
|
165 |
|
|
this.parameters["fv0"] = this.keyword;
|
166 |
|
|
this.parameters["f0"] = "q";
|
167 |
|
|
}else{
|
168 |
|
|
delete this.parameters['fv0'];
|
169 |
|
|
delete this.parameters['f0'];
|
170 |
|
|
}
|
171 |
|
|
|
172 |
58606
|
argiro.kok
|
if(this.parameters["page"]){
|
173 |
|
|
//GO to first page
|
174 |
|
|
delete this.parameters['page'];
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
|
178 |
58563
|
argiro.kok
|
this.router.navigate([this.properties.depositSearchPage], {queryParams: this.parameters} );
|
179 |
|
|
}
|
180 |
58244
|
argiro.kok
|
/*public getResults(keyword:string,refine:boolean, page: number, size: number){
|
181 |
56563
|
konstantin
|
var parameters = "";
|
182 |
|
|
if(keyword.length > 0){
|
183 |
|
|
//parameters = "q="+ keyword;
|
184 |
|
|
|
185 |
|
|
if(this.keywordFields.length > 0) {
|
186 |
|
|
parameters = "&fq=";
|
187 |
|
|
}
|
188 |
|
|
|
189 |
|
|
for(let i=0; i< this.keywordFields.length ; i++) {
|
190 |
|
|
if(i > 0) {
|
191 |
|
|
parameters += " or ";
|
192 |
|
|
}
|
193 |
|
|
let field = this.keywordFields[i];
|
194 |
|
|
parameters += field.name+field.equalityOperator+StringUtils.URIEncode(this.searchUtils.keyword);
|
195 |
|
|
}
|
196 |
|
|
}
|
197 |
|
|
this._getResults(parameters,refine,page, size);
|
198 |
|
|
}
|
199 |
|
|
private _getResults(parameters:string,refine:boolean, page: number, size: number){
|
200 |
|
|
if(page > this.pagingLimit) {
|
201 |
|
|
size=0;
|
202 |
|
|
}
|
203 |
|
|
if(page <= this.pagingLimit || this.searchUtils.status == this.errorCodes.LOADING) {
|
204 |
|
|
this.csvParams = parameters;
|
205 |
|
|
|
206 |
|
|
this.searchUtils.status = this.errorCodes.LOADING;
|
207 |
|
|
|
208 |
|
|
this.disableForms = true;
|
209 |
|
|
this.results = [];
|
210 |
|
|
this.searchUtils.totalResults = 0;
|
211 |
|
|
|
212 |
|
|
this.subResults = this._searchDataprovidersService.searchDataprovidersForDepositSearch(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields(),this.properties, "deposit").subscribe(
|
213 |
|
|
data => {
|
214 |
|
|
this.searchUtils.totalResults = data[0];
|
215 |
|
|
this.results = data[1];
|
216 |
|
|
if(refine){
|
217 |
|
|
this.filters = data[2];
|
218 |
|
|
}
|
219 |
|
|
this.searchPage.checkSelectedFilters(this.filters);
|
220 |
|
|
this.searchPage.updateBaseUrlWithParameters(this.filters);
|
221 |
|
|
this.searchUtils.status = this.errorCodes.DONE;
|
222 |
|
|
if(this.searchUtils.totalResults == 0 ){
|
223 |
|
|
this.searchUtils.status = this.errorCodes.NONE;
|
224 |
|
|
}
|
225 |
|
|
this.disableForms = false;
|
226 |
|
|
|
227 |
|
|
if(this.searchUtils.status == this.errorCodes.DONE) {
|
228 |
|
|
// Page out of limit!!!
|
229 |
|
|
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
230 |
|
|
if(!(Number.isInteger(totalPages))) {
|
231 |
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
232 |
|
|
}
|
233 |
|
|
if(totalPages < page) {
|
234 |
|
|
this.searchUtils.totalResults = 0;
|
235 |
|
|
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
236 |
|
|
}
|
237 |
|
|
}
|
238 |
|
|
},
|
239 |
|
|
err => {
|
240 |
|
|
this.handleError("Error getting content providers", err);
|
241 |
|
|
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
|
242 |
|
|
|
243 |
|
|
this.disableForms = false;
|
244 |
|
|
}
|
245 |
|
|
);
|
246 |
|
|
}
|
247 |
|
|
}
|
248 |
58244
|
argiro.kok
|
*/
|
249 |
56563
|
konstantin
|
|
250 |
|
|
private handleError(message: string, error) {
|
251 |
|
|
console.error("Content Providers simple Search Page: "+message, error);
|
252 |
|
|
}
|
253 |
|
|
}
|