Revision 61069
Added by Konstantinos Triantafyllou almost 3 years ago
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/searchPages/searchUtils/searchFilter.component.ts | ||
---|---|---|
1 |
import { |
|
2 |
Component, |
|
3 |
Input, |
|
4 |
Output, |
|
5 |
EventEmitter, |
|
6 |
OnInit, |
|
7 |
OnChanges, |
|
8 |
SimpleChanges |
|
9 |
} from '@angular/core'; |
|
10 |
import { Filter, Value} from './searchHelperClasses.class'; |
|
11 |
import {ActivatedRoute, Router} from "@angular/router"; |
|
12 |
import {SearchFields} from "../../utils/properties/searchFields"; |
|
13 |
@Component({ |
|
14 |
selector: 'search-filter', |
|
15 |
templateUrl: 'searchFilter.component.html' |
|
16 |
}) |
|
17 |
|
|
18 |
export class SearchFilterComponent implements OnInit, OnChanges{ |
|
19 |
|
|
20 |
@Input() filter:Filter; |
|
21 |
@Input() showResultCount:boolean = true; |
|
22 |
@Input() isDisabled:boolean = false; |
|
23 |
@Input() addShowMore:boolean = true; |
|
24 |
@Input() showMoreInline: boolean = true; |
|
25 |
@Input() filterValuesNum: number = 6; |
|
26 |
public showAll:boolean = false; |
|
27 |
public _maxCharacters:number =28; |
|
28 |
|
|
29 |
@Output() toggleModal = new EventEmitter(); |
|
30 |
|
|
31 |
@Output() modalChange = new EventEmitter(); |
|
32 |
@Output() onFilterChange = new EventEmitter(); |
|
33 |
keyword = ""; |
|
34 |
sortBy = "name"; |
|
35 |
queryParams = {}; |
|
36 |
paramPosition = 0; |
|
37 |
@Input() actionRoute:boolean = false; |
|
38 |
@Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string }; |
|
39 |
sub; |
|
40 |
public isOpen:boolean=false; |
|
41 |
|
|
42 |
constructor (private _router: Router, private route: ActivatedRoute) { |
|
43 |
} |
|
44 |
ngOnDestroy() { |
|
45 |
if(this.sub){ |
|
46 |
this.sub.unsubscribe(); |
|
47 |
} |
|
48 |
} |
|
49 |
ngOnInit() { |
|
50 |
this.sub = this.route.queryParams.subscribe(params => { |
|
51 |
this.queryParams = Object.assign({}, params); |
|
52 |
this.paramPosition = SearchFields.getParameterOrder(this.filter.filterId, this.getEntries(params)); |
|
53 |
}); |
|
54 |
this.filter.values = this.filter.values.filter(value => !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available')); |
|
55 |
if(this.filter.filterType == "radio"){ |
|
56 |
this.filter.radioValue = ""; |
|
57 |
this.filter.values.forEach(value => { |
|
58 |
if(value.selected){ |
|
59 |
this.filter.radioValue = value.id |
|
60 |
} |
|
61 |
}); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
ngOnChanges(changes: SimpleChanges) { |
|
66 |
if(changes.filter) { |
|
67 |
this.filter.values = this.filter.values.filter(value => !value.name.toLowerCase().includes('unknown') && !value.name.toLowerCase().includes('not available')); |
|
68 |
if(this.filter.filterType == "radio"){ |
|
69 |
this.filter.radioValue = ""; |
|
70 |
this.filter.values.forEach(value => { |
|
71 |
if(value.selected){ |
|
72 |
this.filter.radioValue = value.id |
|
73 |
} |
|
74 |
}); |
|
75 |
} |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
public _formatTitle(title,length){ |
|
80 |
return (((title+" ("+length+")").length >this._maxCharacters)?(title.substring(0,(this._maxCharacters - (" ("+length+")").length - ('...').length))+"..."):title)+" ("+(length>95?"100":length)+")"; |
|
81 |
} |
|
82 |
public _formatName(value){ |
|
83 |
//let maxLineLength = 24; |
|
84 |
let maxLineLength = 35; |
|
85 |
|
|
86 |
//1 space after checkbox |
|
87 |
//3 space before number + parenthesis |
|
88 |
if(!this.showResultCount && value.name.length+1 > maxLineLength ){ |
|
89 |
return value.name.substr(0, maxLineLength -3 -1)+'...'; |
|
90 |
} |
|
91 |
if(value.name.length+value.number.toLocaleString().length +1 +3> maxLineLength){ |
|
92 |
return value.name.substr(0, (maxLineLength- 3 -4 - value.number.toLocaleString().length))+'...'; |
|
93 |
} |
|
94 |
|
|
95 |
return value.name; |
|
96 |
} |
|
97 |
|
|
98 |
filterKeywords(value){ |
|
99 |
if(this.keyword.length > 0){ |
|
100 |
if(value.toLowerCase().indexOf(this.keyword.toLowerCase()) ==-1){ |
|
101 |
return false; |
|
102 |
} |
|
103 |
} |
|
104 |
return true; |
|
105 |
} |
|
106 |
filterChange(selected:boolean){ |
|
107 |
if(selected){ |
|
108 |
this.filter.countSelectedValues++; |
|
109 |
}else{ |
|
110 |
this.filter.countSelectedValues--; |
|
111 |
} |
|
112 |
this.onFilterChange.emit({ |
|
113 |
value: this.filter |
|
114 |
}); |
|
115 |
} |
|
116 |
uniqueFilterChange(value: Value) { |
|
117 |
let tmp = value.selected; |
|
118 |
value.selected = !tmp; |
|
119 |
|
|
120 |
if(value.selected){ |
|
121 |
this.filter.countSelectedValues = 1; |
|
122 |
}else{ |
|
123 |
this.filter.countSelectedValues = 0; |
|
124 |
} |
|
125 |
|
|
126 |
this.filter.values.forEach(value => { |
|
127 |
value.selected = (value.id == this.filter.radioValue); |
|
128 |
}); |
|
129 |
this.onFilterChange.emit({ |
|
130 |
value: this.filter |
|
131 |
}); |
|
132 |
} |
|
133 |
clearFilter() { |
|
134 |
for (var i=0; i < this.filter.values.length; i++){ |
|
135 |
this.filter.values[i].selected = false; |
|
136 |
} |
|
137 |
this.filter.countSelectedValues = 0; |
|
138 |
this.onFilterChange.emit({ |
|
139 |
value: this.filter |
|
140 |
}); |
|
141 |
this.filter.radioValue = ""; |
|
142 |
} |
|
143 |
|
|
144 |
getSelectedAndTopValues(filter, topNum: number = 6):any{ |
|
145 |
var values = []; |
|
146 |
|
|
147 |
for (let i=0; i < topNum; i++){ |
|
148 |
if(filter.values.length <= i) { |
|
149 |
break; |
|
150 |
} |
|
151 |
values.push(filter.values[i]); |
|
152 |
} |
|
153 |
|
|
154 |
if(filter.countSelectedValues >0){ |
|
155 |
for (let i=topNum; i < filter.values.length; i++){ |
|
156 |
if(filter.values[i].selected){ |
|
157 |
values.push(filter.values[i]); |
|
158 |
} |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
return values; |
|
163 |
} |
|
164 |
|
|
165 |
getSelectedValues(filter, sortBy:string = "num"):any{ |
|
166 |
var selected = []; |
|
167 |
if(filter.countSelectedValues >0){ |
|
168 |
for (var i=0; i < filter.values.length; i++){ |
|
169 |
if(filter.values[i].selected){ |
|
170 |
selected.push(filter.values[i]); |
|
171 |
} |
|
172 |
} |
|
173 |
} |
|
174 |
if(sortBy == "name"){ |
|
175 |
|
|
176 |
selected.sort((n1,n2)=> { |
|
177 |
if (n1.name > n2.name) { |
|
178 |
return 1; |
|
179 |
} |
|
180 |
|
|
181 |
if (n1.name < n2.name) { |
|
182 |
return -1; |
|
183 |
} |
|
184 |
|
|
185 |
return 0; |
|
186 |
}); |
|
187 |
} |
|
188 |
return selected; |
|
189 |
|
|
190 |
} |
|
191 |
getNotSelectedValues(filter, sortBy:string = "num"):any{ |
|
192 |
var notSselected = []; |
|
193 |
for (var i=0; i < filter.values.length; i++){ |
|
194 |
if(!filter.values[i].selected){ |
|
195 |
notSselected.push(filter.values[i]); |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
if(sortBy == "name"){ |
|
200 |
|
|
201 |
notSselected.sort((n1,n2)=> { |
|
202 |
if (n1.name > n2.name) { |
|
203 |
return 1; |
|
204 |
} |
|
205 |
if (n1.name < n2.name) { |
|
206 |
return -1; |
|
207 |
} |
|
208 |
|
|
209 |
return 0; |
|
210 |
}); |
|
211 |
} |
|
212 |
return notSselected; |
|
213 |
} |
|
214 |
|
|
215 |
sort(values: Value[]) { |
|
216 |
let sorted: Value[] = values.slice(); |
|
217 |
if(this.sortBy == "name"){ |
|
218 |
|
|
219 |
sorted.sort((n1,n2)=> { |
|
220 |
if (n1.name.toLowerCase() > n2.name.toLowerCase()) { |
|
221 |
return 1; |
|
222 |
} |
|
223 |
|
|
224 |
if (n1.name < n2.name) { |
|
225 |
return -1; |
|
226 |
} |
|
227 |
|
|
228 |
return 0; |
|
229 |
}); |
|
230 |
} |
|
231 |
return sorted; |
|
232 |
} |
|
233 |
|
|
234 |
toggle() { |
|
235 |
this.isOpen = !this.isOpen; |
|
236 |
} |
|
237 |
|
|
238 |
getFilterName(value){ |
|
239 |
let name = value.name +" ("+ value.number.format()+")"; |
|
240 |
console.log(name); |
|
241 |
return name; |
|
242 |
} |
|
243 |
getRoute(){ |
|
244 |
return this._router.url.split("?")[0]; |
|
245 |
} |
|
246 |
getParams(filter:Filter, value:Value){ |
|
247 |
let params = Object.assign({}, this.queryParams); |
|
248 |
/* let qf=false; |
|
249 |
if(this.quickFilter && this.quickFilter.filterId == filter.filterId && this.quickFilter.selected && value.id == this.quickFilter.value){ |
|
250 |
params['qf']="false"; |
|
251 |
qf=true; |
|
252 |
}*/ |
|
253 |
if(params[filter.filterId] && this.checkIfValueIndexOf(params[filter.filterId].split(','),value.id)==-1 /*&& !qf*/) { |
|
254 |
//has other values of this filter --> add this value |
|
255 |
params[filter.filterId] = params[filter.filterId] + ',' + '"' + encodeURIComponent(value.id) + '"'; |
|
256 |
}else if(params[filter.filterId] && this.checkIfValueIndexOf(params[filter.filterId].split(','),value.id)!=-1) { |
|
257 |
// has this filter and the value -- > remove it |
|
258 |
|
|
259 |
let values = params[filter.filterId].split(','); |
|
260 |
values.splice(this.checkIfValueIndexOf(values,value.id), 1); |
|
261 |
params[filter.filterId] =values.join(','); |
|
262 |
if(values.length == 0){ |
|
263 |
delete params[filter.filterId]; |
|
264 |
} |
|
265 |
} else /*if(!qf)*/{ |
|
266 |
//has no filter, no value --> add the value |
|
267 |
//check the order |
|
268 |
let keyValues = this.getEntries(params); |
|
269 |
keyValues.splice(this.paramPosition,0, [filter.filterId,'"' + encodeURIComponent(value.id) + '"']); // insert key value at paramPosition. |
|
270 |
params = keyValues.reduce((o, key) => Object.assign(o, {[key[0]]:key[1]}), {}); |
|
271 |
// params[filter.filterId] = '"' + encodeURIComponent(value.id) + '"' ; |
|
272 |
} |
|
273 |
delete params['page']; |
|
274 |
return params; |
|
275 |
} |
|
276 |
checkIfValueIndexOf(array, value){ |
|
277 |
let encodedValue = encodeURIComponent(value); |
|
278 |
if(array.indexOf(encodedValue)!=-1){ |
|
279 |
return array.indexOf(encodedValue); |
|
280 |
} |
|
281 |
if(array.indexOf('"'+encodedValue+'"')!=-1){ |
|
282 |
return array.indexOf('"'+encodedValue+'"'); |
|
283 |
} |
|
284 |
return -1; |
|
285 |
} |
|
286 |
getEntries(obj) { |
|
287 |
if (!Object.entries) { |
|
288 |
|
|
289 |
var ownProps = Object.keys(obj), |
|
290 |
i = ownProps.length, |
|
291 |
resArray = new Array(i); // preallocate the Array |
|
292 |
while (i--) |
|
293 |
resArray[i] = [ownProps[i], obj[ownProps[i]]]; |
|
294 |
return resArray; |
|
295 |
}else{ |
|
296 |
return Object.entries(obj); |
|
297 |
} |
|
298 |
} |
|
299 |
} |
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/searchPages/searchUtils/entitiesSelection.component.ts | ||
---|---|---|
1 |
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core'; |
|
2 |
import {FormBuilder} from "@angular/forms"; |
|
3 |
import {EnvProperties} from "../../utils/properties/env-properties"; |
|
4 |
import {SearchCustomFilter} from "./searchUtils.class"; |
|
5 |
import {ConfigurationService} from "../../utils/configuration/configuration.service"; |
|
6 |
import {Router} from "@angular/router"; |
|
7 |
import {MatSelect} from "@angular/material"; |
|
8 |
import {Subscription} from "rxjs"; |
|
9 |
import {properties} from '../../../../environments/environment'; |
|
10 |
|
|
11 |
@Component({ |
|
12 |
selector: 'entities-selection', |
|
13 |
template: ` |
|
14 |
<span *ngIf="!disableSelect && show>1 && selectedEntity" |
|
15 |
class=" entitiesSelection portal-box uk-text-small clickable" style="" |
|
16 |
(click)="open()"> |
|
17 |
<mat-select *ngIf="!onlyresults" [(value)]="selectedEntity" |
|
18 |
(valueChange)="entityChanged()" [disableOptionCentering]="true" [panelClass]="matPanelClass"> |
|
19 |
<mat-option *ngIf="simpleView && showAll" |
|
20 |
value="all">All content |
|
21 |
</mat-option> |
|
22 |
<mat-option *ngIf="showResearchOutcomes" value="result">Research outcomes</mat-option> |
|
23 |
<mat-option *ngIf="showProjects" value="project">Projects</mat-option> |
|
24 |
<mat-option *ngIf="showDataProviders" value="dataprovider">Content providers</mat-option> |
|
25 |
<mat-option *ngIf="showOrganizations" value="organization">Organizations</mat-option> |
|
26 |
</mat-select> |
|
27 |
<mat-select *ngIf="onlyresults" [(value)]="selectedEntity" |
|
28 |
(valueChange)="entityChanged()" [disableOptionCentering]="true" [panelClass]="matPanelClass"> |
|
29 |
<mat-option |
|
30 |
*ngIf="simpleView && showAll" |
|
31 |
value="all">All research outcomes |
|
32 |
</mat-option> |
|
33 |
<mat-option *ngIf="showPublications" value="publications">Publications</mat-option> |
|
34 |
<mat-option *ngIf="showDatasets" value="datasets">Datasets</mat-option> |
|
35 |
<mat-option *ngIf="showSoftware" value="software">Software</mat-option> |
|
36 |
<mat-option *ngIf="showOther" value="other">Other Research products</mat-option> |
|
37 |
</mat-select> |
|
38 |
|
|
39 |
</span> |
|
40 |
<span *ngIf="currentEntity && disableSelect" class="entitiesSelection portal-box uk-text-small " style=""> |
|
41 |
<div> |
|
42 |
<span *ngIf="currentEntity=='all'">{{onlyresults ? 'All research outcomes' : 'All content'}}</span> |
|
43 |
<span *ngIf="currentEntity=='result'">Research outcomes</span> |
|
44 |
<span *ngIf="currentEntity=='project'">Projects</span> |
|
45 |
<span *ngIf="currentEntity=='dataprovider'">Content providers</span> |
|
46 |
<span *ngIf="currentEntity=='organization'">Organizations</span> |
|
47 |
<span *ngIf="currentEntity=='publications'">Publications</span> |
|
48 |
<span *ngIf="currentEntity=='datasets'">Datasets</span> |
|
49 |
<span *ngIf="currentEntity=='software'">Software</span> |
|
50 |
<span *ngIf="currentEntity=='other'">Other Research products</span> |
|
51 |
</div> |
|
52 |
</span> |
|
53 |
<!--<span *ngIf="onlyresults && !disableSelect"> |
|
54 |
<select *ngIf="show" [(ngModel)]="selectedEntity" class="uk-select uk-width-auto portal-box uk-text-small" (ngModelChange)="entityChanged()" > |
|
55 |
<option |
|
56 |
*ngIf="simpleView && (show)>1 && !(this.customFilter && this.customFilter.queryFieldName=='communityId' )" |
|
57 |
value="all">All research outcomes |
|
58 |
</option> |
|
59 |
<option *ngIf="showPublications" value="publications">Publications</option> |
|
60 |
<option *ngIf="showDatasets" value="datasets">Datasets</option> |
|
61 |
<option *ngIf="showSoftware" value="software">Software</option> |
|
62 |
<option *ngIf="showOther" value="other">Other Research products</option> |
|
63 |
</select> |
|
64 |
</span>--> |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
` |
|
70 |
}) |
|
71 |
|
|
72 |
export class EntitiesSelectionComponent { |
|
73 |
|
|
74 |
showResearchOutcomes: boolean = false; |
|
75 |
showPublications: boolean = false; |
|
76 |
showDatasets: boolean = false; |
|
77 |
showSoftware: boolean = false; |
|
78 |
showOther: boolean = false; |
|
79 |
showProjects: boolean = false; |
|
80 |
showDataProviders: boolean = false; |
|
81 |
showOrganizations: boolean = false; |
|
82 |
showAll: boolean = true; |
|
83 |
@Input() allEnable = false; |
|
84 |
@Input() properties: EnvProperties = properties; |
|
85 |
@Input() customFilter: SearchCustomFilter = null; |
|
86 |
@Input() @Output() selectedEntity = "Research Outcomes"; |
|
87 |
@Input() currentEntity = "Research Outcomes"; |
|
88 |
@Input() simpleView: boolean = true; |
|
89 |
@Input() onChangeNavigate: boolean = true; |
|
90 |
@Output() selectionChange = new EventEmitter(); |
|
91 |
@Input() onlyresults: boolean = false; |
|
92 |
@Input() matPanelClass = "matSelectionPanel"; |
|
93 |
@Input() disableSelect: boolean = false; |
|
94 |
show = 0; |
|
95 |
@ViewChild(MatSelect) matSelect: MatSelect; |
|
96 |
|
|
97 |
subs: Subscription[] = []; |
|
98 |
|
|
99 |
constructor(private _fb: FormBuilder, private config: ConfigurationService, private router: Router) {} |
|
100 |
|
|
101 |
ngOnInit() { |
|
102 |
this.show = 0; |
|
103 |
if(!this.allEnable) { |
|
104 |
if((this.customFilter && this.customFilter.queryFieldName == "communityId") || (this.properties.adminToolsCommunity !== "monitor")) { |
|
105 |
//this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => { |
|
106 |
this.subs.push(this.config.communityInformationState.subscribe(data => { |
|
107 |
if(data) { |
|
108 |
let showEntity = {}; |
|
109 |
let showPage = {}; |
|
110 |
if(data['entities']) { |
|
111 |
for (let i = 0; i < data['entities'].length; i++) { |
|
112 |
|
|
113 |
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"]; |
|
114 |
} |
|
115 |
} |
|
116 |
if(data['pages']) { |
|
117 |
for (let i = 0; i < data['pages'].length; i++) { |
|
118 |
showPage["" + data['pages'][i]["route"] + ""] = data['pages'][i]["isEnabled"]; |
|
119 |
} |
|
120 |
} |
|
121 |
this.showResearchOutcomes = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && (showEntity["publication"] || showEntity["dataset"] || showEntity["software"] || showEntity["orp"]); |
|
122 |
this.showPublications = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["publication"]; |
|
123 |
this.showDatasets = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["dataset"]; |
|
124 |
this.showSoftware = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["software"]; |
|
125 |
this.showOther = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["orp"]; |
|
126 |
this.showProjects = showPage[this.simpleView?this.properties.searchLinkToProjects:this.properties.searchLinkToAdvancedProjects] && showEntity["project"]; |
|
127 |
this.showOrganizations = showPage[this.simpleView?this.properties.searchLinkToOrganizations:this.properties.searchLinkToAdvancedOrganizations] && showEntity["organization"]; |
|
128 |
this.showDataProviders = showPage[this.simpleView?this.properties.searchLinkToDataProviders:this.properties.searchLinkToAdvancedDataProviders] && showEntity["datasource"]; |
|
129 |
if (this.customFilter && this.customFilter.queryFieldName == "communityId" || this.properties.adminToolsCommunity === "connect") { |
|
130 |
//for community pages: no organization in simple search, only results in advanced |
|
131 |
this.showAll = false; |
|
132 |
this.showOrganizations = false; |
|
133 |
if (!this.simpleView) { |
|
134 |
this.showProjects = false; |
|
135 |
this.showDataProviders = false; |
|
136 |
} |
|
137 |
} |
|
138 |
if (this.showResearchOutcomes) { |
|
139 |
this.show++; |
|
140 |
} |
|
141 |
if (this.showDataProviders) { |
|
142 |
this.show++; |
|
143 |
} |
|
144 |
if (this.showOrganizations) { |
|
145 |
this.show++; |
|
146 |
} |
|
147 |
if (this.showProjects) { |
|
148 |
this.show++; |
|
149 |
} |
|
150 |
if (this.show == 1) { |
|
151 |
this.disableSelect = true; |
|
152 |
} |
|
153 |
} |
|
154 |
})); |
|
155 |
} else if((this.customFilter && this.customFilter.queryFieldName == "community") && this.properties.adminToolsCommunity === "monitor") { |
|
156 |
this.show = 1; |
|
157 |
this.disableSelect = true; |
|
158 |
} else if(this.customFilter && (this.customFilter.queryFieldName == "relfunder" || this.customFilter.queryFieldName == "funder")) { |
|
159 |
/*this.showResearchOutcomes = true; |
|
160 |
this.showPublications = true; |
|
161 |
this.showDatasets = true; |
|
162 |
this.showSoftware = true; |
|
163 |
this.showOther = true; |
|
164 |
this.showProjects = true; |
|
165 |
this.showAll = false; |
|
166 |
this.show = 2;*/ |
|
167 |
this.show = 1; |
|
168 |
this.disableSelect = true; |
|
169 |
} else if(this.customFilter && this.customFilter.queryFieldName == "relorganizationid") { |
|
170 |
/*this.showResearchOutcomes = true; |
|
171 |
this.showPublications = true; |
|
172 |
this.showDatasets = true; |
|
173 |
this.showSoftware = true; |
|
174 |
this.showOther = true; |
|
175 |
this.showProjects = true; |
|
176 |
this.showDataProviders = true; |
|
177 |
this.showAll = false; |
|
178 |
this.show = 3;*/ |
|
179 |
this.show = 1; |
|
180 |
this.disableSelect = true; |
|
181 |
} else { |
|
182 |
this.showResearchOutcomes = true; |
|
183 |
this.showPublications = true; |
|
184 |
this.showDatasets = true; |
|
185 |
this.showSoftware = true; |
|
186 |
this.showOther = true; |
|
187 |
this.showProjects = true; |
|
188 |
this.showOrganizations = true; |
|
189 |
this.showDataProviders = true; |
|
190 |
this.showAll = false; |
|
191 |
this.show = 4; |
|
192 |
} |
|
193 |
} else { |
|
194 |
this.showResearchOutcomes = true; |
|
195 |
this.showPublications = true; |
|
196 |
this.showDatasets = true; |
|
197 |
this.showSoftware = true; |
|
198 |
this.showOther = true; |
|
199 |
this.showProjects = true; |
|
200 |
this.showOrganizations = true; |
|
201 |
this.showDataProviders = true; |
|
202 |
this.showAll = true; |
|
203 |
this.show = 5; |
|
204 |
} |
|
205 |
this.selectedEntity = this.currentEntity; |
|
206 |
this.selectionChange.emit({ |
|
207 |
entity: this.selectedEntity, |
|
208 |
simpleUrl: this.getUrl(true), |
|
209 |
advancedUrl: this.getUrl(false) |
|
210 |
}); |
|
211 |
} |
|
212 |
|
|
213 |
public ngOnDestroy() { |
|
214 |
for (let sub of this.subs) { |
|
215 |
sub.unsubscribe(); |
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
entityChanged() { |
|
220 |
if (!this.simpleView || this.onChangeNavigate) { |
|
221 |
this.router.navigate([this.getUrl(this.simpleView)], {queryParams: this.customFilter?this.customFilter.getParameters():{}}); |
|
222 |
} else { |
|
223 |
this.selectionChange.emit({ |
|
224 |
entity: this.selectedEntity, |
|
225 |
simpleUrl: this.getUrl(true), |
|
226 |
advancedUrl: this.getUrl(false) |
|
227 |
}); |
|
228 |
} |
|
229 |
|
|
230 |
} |
|
231 |
|
|
232 |
getUrl(simpleView: boolean) { |
|
233 |
let url = ""; |
|
234 |
if (!this.onlyresults) { |
|
235 |
if (this.selectedEntity == "all") { |
|
236 |
url = (simpleView ? "/search/find/" : null); |
|
237 |
} else if (this.selectedEntity == "result") { |
|
238 |
url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults); |
|
239 |
} else if (this.selectedEntity == "project") { |
|
240 |
url = (simpleView ? this.properties.searchLinkToProjects : this.properties.searchLinkToAdvancedProjects); |
|
241 |
} else if (this.selectedEntity == "dataprovider") { |
|
242 |
url = (simpleView ? this.properties.searchLinkToDataProviders : this.properties.searchLinkToAdvancedDataProviders); |
|
243 |
} else if (this.selectedEntity == "organization") { |
|
244 |
url = (simpleView ? this.properties.searchLinkToOrganizations : this.properties.searchLinkToAdvancedOrganizations); |
|
245 |
} |
|
246 |
} else { |
|
247 |
url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults); |
|
248 |
} |
|
249 |
return url; |
|
250 |
} |
|
251 |
|
|
252 |
toggle() { |
|
253 |
if (this.matSelect) { |
|
254 |
this.matSelect.toggle(); |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
open() { |
|
259 |
if (this.matSelect && !this.matSelect.focused) { |
|
260 |
this.matSelect.open(); |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
} |
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/searchPages/searchUtils/no-load-paging.component.ts | ||
---|---|---|
1 |
import {Component, Input, Output, EventEmitter} from '@angular/core'; |
|
2 |
|
|
3 |
@Component({ |
|
4 |
selector: 'no-load-paging', |
|
5 |
template: ` |
|
6 |
<div class="paging-hr searchPaging uk-margin-small-bottom"> |
|
7 |
<div class="uk-panel uk-margin-small-top uk-grid uk-flex uk-flex-middle"> |
|
8 |
<div class="uk-width-1-1@s uk-width-1-2@m uk-text-uppercase" *ngIf="type && totalResults"> |
|
9 |
<span class="uk-text-bold">{{totalResults | number}}</span> |
|
10 |
<span class="uk-text-muted uk-text-uppercase"> {{type}}, page </span> |
|
11 |
<span class="uk-text-bold">{{page}}</span> |
|
12 |
<span class="uk-text-muted uk-text-uppercase"> of </span> |
|
13 |
<span class="uk-text-bold">{{paging.getTotalPages() | number}}</span> |
|
14 |
</div> |
|
15 |
<div class="float-children-right-at-medium margin-small-top-at-small uk-width-expand"> |
|
16 |
<paging-no-load #paging [currentPage]="page" |
|
17 |
customClasses="uk-margin-remove-bottom" |
|
18 |
[totalResults]="totalResults" [size]="pageSize" |
|
19 |
(pageChange)="updatePage($event)"> |
|
20 |
</paging-no-load> |
|
21 |
</div> |
|
22 |
</div> |
|
23 |
</div> |
|
24 |
` |
|
25 |
}) |
|
26 |
export class NoLoadPagingComponent { |
|
27 |
@Input() type: string; |
|
28 |
@Input() page: number = 1; |
|
29 |
@Input() pageSize: number = 10; |
|
30 |
@Input() totalResults: number; |
|
31 |
@Output() pageChange: EventEmitter<any> = new EventEmitter<any>(); |
|
32 |
|
|
33 |
public updatePage(event) { |
|
34 |
this.pageChange.emit({ |
|
35 |
value: event.value |
|
36 |
}); |
|
37 |
} |
|
38 |
} |
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/searchPages/searchUtils/newSearchPage.module.ts | ||
---|---|---|
1 |
import {NgModule} from '@angular/core'; |
|
2 |
import {CommonModule} from '@angular/common'; |
|
3 |
import {FormsModule} from '@angular/forms'; |
|
4 |
import {RouterModule} from '@angular/router'; |
|
5 |
|
|
6 |
import {NewSearchPageComponent} from './newSearchPage.component'; |
|
7 |
import {SearchFormModule} from './searchForm.module'; |
|
8 |
import {SearchFilterModule} from './searchFilter.module'; |
|
9 |
import {RangeFilterModule} from "../../utils/rangeFilter/rangeFilter.module"; |
|
10 |
import {LoadingModalModule} from '../../utils/modal/loadingModal.module'; |
|
11 |
import {ReportsServiceModule} from '../../services/reportsService.module'; |
|
12 |
import {SearchPagingModule} from './searchPaging.module'; |
|
13 |
import {SearchResultsPerPageModule} from './searchResultsPerPage.module'; |
|
14 |
import {SearchSortingModule} from './searchSorting.module'; |
|
15 |
import {SearchDownloadModule} from './searchDownload.module'; |
|
16 |
import {ModalModule} from '../../utils/modal/modal.module'; |
|
17 |
import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; |
|
18 |
import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; |
|
19 |
import {HelperModule} from '../../utils/helper/helper.module'; |
|
20 |
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; |
|
21 |
import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module'; |
|
22 |
import {PortalSearchResultModule} from "./portal-search-result.module"; |
|
23 |
import {SearchResultsModule} from "./searchResults.module"; |
|
24 |
import {SearchResultsInDepositModule} from "../../deposit/searchResultsInDeposit.module"; |
|
25 |
import {AdvancedSearchFormModule} from "./advancedSearchForm.module"; |
|
26 |
import {QuickSelectionsModule} from "./quick-selections.module"; |
|
27 |
import {BreadcrumbsModule} from "../../utils/breadcrumbs/breadcrumbs.module"; |
|
28 |
import {AlertModalModule} from "../../utils/modal/alertModal.module"; |
|
29 |
import {ClickModule} from "../../utils/click/click.module"; |
|
30 |
import {SearchResultsForOrcidModule} from "../../orcid/recommend-orcid-links/searchResultsForOrcid.module"; |
|
31 |
|
|
32 |
@NgModule({ |
|
33 |
imports: [ |
|
34 |
CommonModule, FormsModule, RouterModule, SearchFormModule, PortalSearchResultModule, |
|
35 |
LoadingModalModule, ReportsServiceModule, |
|
36 |
SearchPagingModule, SearchResultsPerPageModule, SearchSortingModule, SearchDownloadModule, ModalModule, |
|
37 |
SearchFilterModule, RangeFilterModule, |
|
38 |
PiwikServiceModule, HelperModule, Schema2jsonldModule, SEOServiceModule, SearchResultsModule, |
|
39 |
SearchResultsInDepositModule, SearchResultsForOrcidModule, |
|
40 |
AdvancedSearchFormModule, QuickSelectionsModule, BreadcrumbsModule, AlertModalModule, ClickModule |
|
41 |
], |
|
42 |
declarations: [ |
|
43 |
NewSearchPageComponent |
|
44 |
], |
|
45 |
|
|
46 |
providers:[ |
|
47 |
PreviousRouteRecorder |
|
48 |
], |
|
49 |
exports: [ |
|
50 |
NewSearchPageComponent |
|
51 |
] |
|
52 |
}) |
|
53 |
export class NewSearchPageModule { } |
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/services/utilities.service.ts | ||
---|---|---|
1 |
import {Injectable} from '@angular/core'; |
|
2 |
import {Observable} from 'rxjs'; |
|
3 |
import {CustomOptions} from './servicesUtils/customOptions.class'; |
|
4 |
import {HttpClient} from '@angular/common/http'; |
|
5 |
|
|
6 |
@Injectable({ |
|
7 |
providedIn: "root" |
|
8 |
}) |
|
9 |
export class UtilitiesService { |
|
10 |
constructor(private http: HttpClient) { |
|
11 |
} |
|
12 |
|
|
13 |
uploadPhoto(url: string, photo: File): Observable<any> { |
|
14 |
const formData = new FormData(); |
|
15 |
formData.append('photo', photo); |
|
16 |
return this.http.post(url, formData, CustomOptions.getAuthOptions()); |
|
17 |
} |
|
18 |
|
|
19 |
deletePhoto(url: string) { |
|
20 |
return this.http.delete(url, CustomOptions.getAuthOptions()); |
|
21 |
} |
|
22 |
|
|
23 |
getTiny(url: string) { |
|
24 |
return this.http.get(url, {responseType: 'text'}); |
|
25 |
} |
|
26 |
|
|
27 |
} |
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/searchPages/searchUtils/quick-selections.component.ts | ||
---|---|---|
1 |
import {ChangeDetectorRef, Component, EventEmitter, Input, Output} from '@angular/core'; |
|
2 |
import {FormBuilder} from "@angular/forms"; |
|
3 |
import {Filter} from "./searchHelperClasses.class"; |
|
4 |
import {EnvProperties} from "../../utils/properties/env-properties"; |
|
5 |
import {ConfigurationService} from "../../utils/configuration/configuration.service"; |
|
6 |
import {Subscription} from "rxjs"; |
|
7 |
import {ActivatedRoute, Router} from "@angular/router"; |
|
8 |
|
|
9 |
@Component({ |
|
10 |
selector: 'quick-selections', |
|
11 |
template: ` |
|
12 |
<div *ngIf="!vertical && (resultTypes || quickFilter)" |
|
13 |
[class]="(isDisabled ? 'uk-disabled' : '') + ' uk-text-small uk-margin-small-bottom uk-grid uk-inline uk-flex uk-margin-small-left'"> |
|
14 |
<div *ngIf="quickFilter" class="uk-margin-small-top uk-padding-remove-left uk-margin-right "> |
|
15 |
<span class="uk-text-bold">{{quickFilter.value}}</span> |
|
16 |
<mat-slide-toggle |
|
17 |
class="uk-margin-small-left" name="qf" [(ngModel)]="quickFilter.selected" (ngModelChange)="quickFilterChanged()"> |
|
18 |
</mat-slide-toggle> |
|
19 |
</div> |
|
20 |
<div *ngIf="resultTypes && showEntities" class="uk-margin-small-top uk-padding-remove-left"> |
|
21 |
<span class="uk-text-muted">Include: </span> |
|
22 |
<span> |
|
23 |
<ng-container *ngFor="let value of resultTypes.values"> |
|
24 |
<span class="uk-margin-small-left"> |
|
25 |
<input #input type="checkbox" class="uk-checkbox" [(ngModel)]="value.selected" (ngModelChange)="changed()"/> |
|
26 |
<span class="space clickable" (click)="input.click()">{{value.name}}</span> |
|
27 |
</span> |
|
28 |
</ng-container> |
|
29 |
</span> |
|
30 |
</div> |
|
31 |
</div> |
|
32 |
<div *ngIf="vertical && (resultTypes || quickFilter)" |
|
33 |
[class]="(isDisabled ? 'uk-disabled' : '') + ' uk-margin-small-bottom uk-list uk-list-divider'"> |
|
34 |
<search-filter |
|
35 |
[isDisabled]="isDisabled" |
|
36 |
[filter]="resultTypes" [showResultCount]='false' |
|
37 |
(onFilterChange)="changed()" [actionRoute]="actionRoute"></search-filter> |
|
38 |
</div> |
|
39 |
|
|
40 |
` |
|
41 |
}) |
|
42 |
|
|
43 |
export class QuickSelectionsComponent { |
|
44 |
@Input() resultTypes:Filter; |
|
45 |
@Output() typeChange = new EventEmitter(); |
|
46 |
@Input() isDisabled; |
|
47 |
@Input() quickFilter: { filter: Filter, selected: boolean, filterId: string, value: string }; |
|
48 |
initialized = false; |
|
49 |
@Input() properties: EnvProperties; |
|
50 |
@Input() vertical: boolean=false; |
|
51 |
showPublications:boolean= false; |
|
52 |
showDatasets:boolean= false; |
|
53 |
showSoftware: boolean = false; |
|
54 |
showOrp: boolean = false; |
|
55 |
showEntities = false; |
|
56 |
@Input() actionRoute:boolean = false; |
|
57 |
queryParams = {}; |
|
58 |
|
|
59 |
subs: Subscription[] = []; |
|
60 |
|
|
61 |
constructor(private _fb: FormBuilder, private config: ConfigurationService, private _router: Router, private route: ActivatedRoute, private cdr:ChangeDetectorRef) { |
|
62 |
} |
|
63 |
|
|
64 |
changed() { |
|
65 |
|
|
66 |
this.typeChange.emit({}); |
|
67 |
} |
|
68 |
|
|
69 |
quickFilterChanged() { |
|
70 |
if(this.quickFilter.filter) { |
|
71 |
this.quickFilter.filter.countSelectedValues = 0; |
|
72 |
if (this.quickFilter.selected) { |
|
73 |
for (let filterValue of this.quickFilter.filter.values) { |
|
74 |
if((filterValue.name == this.quickFilter.value)) { |
|
75 |
filterValue.selected = true |
|
76 |
this.quickFilter.filter.countSelectedValues = 1; |
|
77 |
}else{ |
|
78 |
filterValue.selected = false; |
|
79 |
} |
|
80 |
} |
|
81 |
} else { |
|
82 |
for (let filterValue of this.quickFilter.filter.values) { |
|
83 |
filterValue.selected = false; |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
this.typeChange.emit({}); |
|
88 |
} |
|
89 |
|
|
90 |
ngOnInit() { |
|
91 |
this.subs.push(this.route.queryParams.subscribe(params => { |
|
92 |
this.queryParams = Object.assign({}, params); |
|
93 |
this.initializeFilters(); |
|
94 |
})); |
|
95 |
//Allow all types |
|
96 |
/* if(this.properties && !this.initialized) { |
|
97 |
if(this.properties.adminToolsCommunity !== "monitor") { |
|
98 |
this.subs.push(this.config.communityInformationState.subscribe(data => { |
|
99 |
if(data) { |
|
100 |
var showEntity = {}; |
|
101 |
for (var i = 0; i < data['entities'].length; i++) { |
|
102 |
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"]; |
|
103 |
} |
|
104 |
this.showPublications = showEntity["publication"]; |
|
105 |
this.showDatasets = showEntity["dataset"]; |
|
106 |
this.showSoftware = showEntity["software"]; |
|
107 |
this.showOrp = showEntity["orp"]; |
|
108 |
this.showEntities = this.showPublications || this.showDatasets || this.showSoftware || this.showOrp; |
|
109 |
this.initialized = true; |
|
110 |
this.initializeFilters(); |
|
111 |
} |
|
112 |
}, error => { |
|
113 |
this.showPublications = true; |
|
114 |
this.showDatasets = true; |
|
115 |
this.showSoftware = true; |
|
116 |
this.showOrp = true; |
|
117 |
this.showEntities = true; |
|
118 |
this.initializeFilters(); |
|
119 |
})); |
|
120 |
} else {*/ |
|
121 |
this.showPublications = true; |
|
122 |
this.showDatasets = true; |
|
123 |
this.showSoftware = true; |
|
124 |
this.showOrp = true; |
|
125 |
this.showEntities = true; |
|
126 |
this.initialized = true; |
|
127 |
this.initializeFilters(); |
|
128 |
/*} |
|
129 |
|
|
130 |
}else{ |
|
131 |
this.initializeFilters(); |
|
132 |
}*/ |
|
133 |
|
|
134 |
} |
|
135 |
initializeFilters(){ |
|
136 |
if(this.showEntities ){ |
|
137 |
let selected = []; |
|
138 |
for(let value of this.resultTypes.values){ |
|
139 |
if(value.selected){ |
|
140 |
selected.push(value.id); |
|
141 |
} |
|
142 |
} |
|
143 |
this.resultTypes.countSelectedValues = selected.length; |
|
144 |
this.resultTypes.values = []; |
|
145 |
if(this.showPublications){ |
|
146 |
this.resultTypes.values.push({name: "Publications" , id:"publications",selected:selected.indexOf("publications")!=-1, number:0}); |
|
147 |
} |
|
148 |
if(this.showDatasets){ |
|
149 |
this.resultTypes.values.push({name: "Research data" , id:"datasets",selected:selected.indexOf("datasets")!=-1, number:0}); |
|
150 |
} |
|
151 |
if(this.showSoftware){ |
|
152 |
this.resultTypes.values.push({name: "Software" , id:"software",selected:selected.indexOf("software")!=-1, number:0}); |
|
153 |
} |
|
154 |
if(this.showOrp){ |
|
155 |
this.resultTypes.values.push({name: "Other research products" , id:"other",selected:selected.indexOf("other")!=-1, number:0}); |
|
156 |
} |
|
157 |
} |
|
158 |
this.typeChange.emit("filters_update"); |
|
159 |
} |
|
160 |
public ngOnDestroy() { |
|
161 |
for (let sub of this.subs) { |
|
162 |
sub.unsubscribe(); |
|
163 |
} |
|
164 |
} |
|
165 |
} |
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/services/searchResearchResults.service.ts | ||
---|---|---|
1 |
import {Injectable, OnDestroy} from '@angular/core'; |
|
2 |
import {HttpClient} from "@angular/common/http"; |
|
3 |
import {SearchResult} from '../utils/entities/searchResult'; |
|
4 |
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; |
|
5 |
import {Dates, DOI, StringUtils} from '../utils/string-utils.class'; |
|
6 |
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class'; |
|
7 |
import {EnvProperties} from '../utils/properties/env-properties'; |
|
8 |
import {map} from "rxjs/operators"; |
|
9 |
import {properties} from "../../../environments/environment"; |
|
10 |
|
|
11 |
|
|
12 |
@Injectable() |
|
13 |
export class SearchResearchResultsService { |
|
14 |
private sizeOfDescription: number = 270; |
|
15 |
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); |
|
16 |
|
|
17 |
constructor(private http: HttpClient) { |
|
18 |
} |
|
19 |
|
|
20 |
|
|
21 |
search(resultType: string, params: string, refineParams: string, page: number, size: number, sortBy: string, refineFields: string[], properties: EnvProperties): any { |
|
22 |
let link = properties.searchAPIURLLAst + this.getEntityName(resultType, true); |
|
23 |
|
|
24 |
let url = link + "?"; |
|
25 |
if (params != null && params != '') { |
|
26 |
url += params; |
|
27 |
} |
|
28 |
if (refineParams != null && refineParams != '') { |
|
29 |
url += refineParams; |
|
30 |
} |
|
31 |
if (sortBy) { |
|
32 |
url += "&sortBy=" + sortBy; |
|
33 |
} |
|
34 |
url += "&page=" + (page - 1) + "&size=" + size + "&format=json"; |
|
35 |
|
|
36 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
37 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); |
|
38 |
} |
|
39 |
|
|
40 |
searchById(resultType: string, id: string, properties: EnvProperties): any { |
|
41 |
let url = properties.searchAPIURLLAst + this.getEntityName(resultType, true) + "/" + id + "?format=json"; |
|
42 |
|
|
43 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
44 |
.pipe(map(res => this.parseResults(resultType, res, properties))); |
|
45 |
} |
|
46 |
|
|
47 |
searchAggregators(resultType: string, id: string, params: string, refineParams: string, page: number, size: number, properties: EnvProperties): any { |
|
48 |
let link = properties.searchAPIURLLAst + this.getEntityName(resultType, true); |
|
49 |
|
|
50 |
let url = link + "?" + "&format=json"; |
|
51 |
if (params != null && params != '') { |
|
52 |
url += params; |
|
53 |
} |
|
54 |
if (refineParams != null && refineParams != '') { |
|
55 |
url += refineParams; |
|
56 |
} |
|
57 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
58 |
|
|
59 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
60 |
.pipe(map(res => this.parseRefineResults(id, res['refineResults']))); |
|
61 |
} |
|
62 |
|
|
63 |
searchByListOfDOI(resultType: string, DOIs: string[], refineParams: string, page: number, size: number, refineFields: string[], properties: EnvProperties): any { |
|
64 |
let link = properties.searchAPIURLLAst + this.getEntityName(resultType, true); |
|
65 |
|
|
66 |
let url = link + "?" + "&format=json&"; |
|
67 |
var doisParams = ""; |
|
68 |
|
|
69 |
for (var i = 0; i < DOIs.length; i++) { |
|
70 |
doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + DOIs[i] + '"'; |
|
71 |
} |
|
72 |
if (doisParams.length > 0) { |
|
73 |
url += "&" + doisParams; |
|
74 |
|
|
75 |
} |
|
76 |
if (refineParams != null && refineParams != '') { |
|
77 |
url += refineParams; |
|
78 |
} |
|
79 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
80 |
|
|
81 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
82 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); |
|
83 |
} |
|
84 |
|
|
85 |
advancedSearch(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any { |
|
86 |
let url = properties.searchResourcesAPIURL; |
|
87 |
var basicQuery = "(oaftype exact result) and (resulttypeid exact " + this.getEntityName(resultType, false) + ") "; |
|
88 |
url += "?query="; |
|
89 |
if (params != null && params != '') { |
|
90 |
url += " ( " + basicQuery + " ) " + " and (" + params + ")"; |
|
91 |
} else { |
|
92 |
url += " ( " + basicQuery + " ) "; |
|
93 |
} |
|
94 |
if (refineParams != null && refineParams != '') { |
|
95 |
url += refineParams; |
|
96 |
} |
|
97 |
if (sortBy) { |
|
98 |
let sortOptions = sortBy.split(","); |
|
99 |
url += "sortBy " + sortOptions[0] + "/sort." + sortOptions[1] + " "; |
|
100 |
} |
|
101 |
if (refineQuery) { |
|
102 |
url += "&" + refineQuery; |
|
103 |
} |
|
104 |
|
|
105 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
106 |
url += "&format=json"; |
|
107 |
|
|
108 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
109 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); |
|
110 |
} |
|
111 |
|
|
112 |
advancedSearchResults(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any { |
|
113 |
let url = properties.searchAPIURLLAst + "resources2/?format=json"; |
|
114 |
if (params != null && params != '') { |
|
115 |
url += "&query=(" + params + ")"; |
|
116 |
} |
|
117 |
if (sortBy) { |
|
118 |
let sortOptions = sortBy.split(","); |
|
119 |
url += (params ? " " : "&query=(*) ") + "sortBy " + sortOptions[0] + "/sort." + sortOptions[1] + (params ? " " : " "); |
|
120 |
} |
|
121 |
if (refineParams != null && refineParams != '') { |
|
122 |
url += refineParams; |
|
123 |
} |
|
124 |
if (refineQuery) { |
|
125 |
url += "&" + refineQuery; |
|
126 |
} |
|
127 |
|
|
128 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
129 |
// url += "&format=json"; |
|
130 |
|
|
131 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
132 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); |
|
133 |
} |
|
134 |
|
|
135 |
searchResultForEntity(resultType: string, params: string, page: number, size: number, properties: EnvProperties): any { |
|
136 |
let link = properties.searchAPIURLLAst; |
|
137 |
//let url = link+params+"/"+this.getEntityName(resultType,true)+ "?format=json"; |
|
138 |
//url += "&page="+(page-1)+"&size="+size; |
|
139 |
//url += "&sortBy=resultdateofacceptance,descending"; |
|
140 |
|
|
141 |
//let url = link+"/resources2?format=json&query="+params+" sortBy resultdateofacceptance/sort.descending&type="+this.getEntityName(resultType,true); |
|
142 |
|
|
143 |
let url = link + "/" + this.getEntityName(resultType, true); |
|
144 |
url += "?format=json"; |
|
145 |
url += "&fq=" + params; |
|
146 |
url += "&sortBy=resultdateofacceptance,descending"; |
|
147 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
148 |
|
|
149 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
150 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); |
|
151 |
} |
|
152 |
|
|
153 |
//???? why different from above? |
|
154 |
searchForDataproviders(resultType: string, params: string, page: number, size: number, properties: EnvProperties): any { |
|
155 |
let link = properties.searchAPIURLLAst; |
|
156 |
let url = link + params; |
|
157 |
url += "&sortBy=resultdateofacceptance,descending"; |
|
158 |
url += "&page=" + (page - 1) + "&size=" + size + "&format=json"; |
|
159 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
160 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); |
|
161 |
} |
|
162 |
|
|
163 |
searchForMyOrcidLinks(resultType: string, orcidQuery: string, typeQuery: string, page: number, size: number): any { |
|
164 |
let url = properties.searchAPIURLLAst + "resources2/?format=json"; |
|
165 |
if (orcidQuery != null && orcidQuery != '') { |
|
166 |
url += "&query=(" + orcidQuery + ")"; |
|
167 |
} |
|
168 |
url += typeQuery; |
|
169 |
url += "&page=" + (page - 1) + "&size=" + size; |
|
170 |
|
|
171 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
172 |
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); |
|
173 |
} |
|
174 |
|
|
175 |
parseResults(resultType: string, data: any, properties: EnvProperties): SearchResult[] { |
|
176 |
let results: SearchResult[] = []; |
|
177 |
|
|
178 |
let length = Array.isArray(data) ? data.length : 1; |
|
179 |
|
|
180 |
for (let i = 0; i < length; i++) { |
|
181 |
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result']; |
|
182 |
|
|
183 |
var result: SearchResult = new SearchResult(); |
|
184 |
if (resData['resulttype']) { |
|
185 |
result.entityType = resData['resulttype']['classname']; |
|
186 |
} else { |
|
187 |
result.entityType = resultType; |
|
188 |
} |
|
189 |
result.types = new Array<string>(); |
|
190 |
let types = new Set<string>(); |
|
191 |
|
|
192 |
let instance; |
|
193 |
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1; |
|
194 |
|
|
195 |
for (let i = 0; i < length; i++) { |
|
196 |
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance']; |
|
197 |
this.parsingFunctions.parseTypes(result.types, types, instance); |
|
198 |
} |
|
199 |
/////////////////////////// Athena Code /////////////////////////// |
|
200 |
if (resData['pid']) { |
|
201 |
if (!Array.isArray(resData['pid'])) { |
|
202 |
if (resData['pid'].classid && resData['pid'].classid == 'doi') { |
|
203 |
if (resData['pid'].content != '' && resData['pid'].content != null) { |
|
204 |
result.DOIs.push(resData['pid'].content.replace("https://doi.org/", "")); |
|
205 |
} |
|
206 |
} |
|
207 |
} else { |
|
208 |
for (let i = 0; i < resData['pid'].length; i++) { |
|
209 |
if (resData['pid'][i].classid == 'doi') { |
|
210 |
if (resData['pid'][i].content != '' && resData['pid'][i].content != null) { |
|
211 |
result.DOIs.push(resData['pid'][i].content.replace("https://doi.org/", "")); |
|
212 |
} |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']); |
|
217 |
} |
|
218 |
/////////////////////////// Athena Code /////////////////////////// |
|
219 |
if (resData['programmingLanguage'] && resData['programmingLanguage'] != null) { |
|
220 |
result.programmingLanguages = new Array<string>(); |
|
221 |
|
|
222 |
if (!Array.isArray(resData['programmingLanguage'])) { |
|
223 |
if (resData['programmingLanguage'].classname != "Undetermined" && resData['programmingLanguage'].classname) { |
|
224 |
result.programmingLanguages.push(resData['programmingLanguage'].classname); |
|
225 |
} |
|
226 |
} else { |
|
227 |
for (let i = 0; i < resData['programmingLanguage'].length; i++) { |
|
228 |
if (resData['programmingLanguage'][i].classname != "Undetermined" && resData['programmingLanguage'][i].classname) { |
|
229 |
result.programmingLanguages.push(resData['programmingLanguage'][i].classname); |
|
230 |
} |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
|
|
235 |
if (resData['language'] && resData['language'] != null) { |
|
236 |
result.languages = new Array<string>(); |
|
237 |
|
|
238 |
if (!Array.isArray(resData['language'])) { |
|
239 |
if (resData['language'].classname != "Undetermined" && resData['language'].classname) { |
|
240 |
result.languages.push(resData['language'].classname); |
|
241 |
} |
|
242 |
} else { |
|
243 |
for (let i = 0; i < resData['language'].length; i++) { |
|
244 |
if (resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) { |
|
245 |
result.languages.push(resData['language'][i].classname); |
|
246 |
} |
|
247 |
} |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
if (resData['country'] && resData['country'] != null) { |
|
252 |
result.countriesForResults = new Array<string>(); |
|
253 |
|
|
254 |
if (!Array.isArray(resData['country'])) { |
|
255 |
if (resData['country'].classname != "Undetermined" && resData['country'].classname) { |
|
256 |
result.countriesForResults.push(resData['country'].classname); |
|
257 |
} |
|
258 |
} else { |
|
259 |
for (let i = 0; i < resData['country'].length; i++) { |
|
260 |
if (resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) { |
|
261 |
result.countriesForResults.push(resData['country'][i].classname); |
|
262 |
} |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
result['title'] = {"name": '', "accessMode": '', "sc39": ''}; |
|
268 |
|
|
269 |
if (Array.isArray(resData['title'])) { |
|
270 |
for (let i = 0; i < resData['title'].length; i++) { |
|
271 |
if (resData['title'][i] && resData['title'][i].content) { |
|
272 |
if (!result.title.name || resData['title'][i].classid == "main title") { |
|
273 |
result['title'].name = String(resData['title'][i].content); |
|
274 |
} |
|
275 |
if (resData['title'][i].classid == "main title") { |
|
276 |
break; |
|
277 |
} |
|
278 |
} |
|
279 |
} |
|
280 |
if (!result.title.name) { |
|
281 |
result['title'].name = ""; |
|
282 |
} |
|
283 |
// result['title'].name = (resData['title'][0] && resData['title'][0].content) ? String(resData['title'][0].content) : ""; |
|
284 |
} else { |
|
285 |
result['title'].name = (resData['title'] && resData['title'].content) ? String(resData['title'].content) : ""; |
|
286 |
} |
|
287 |
|
|
288 |
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; |
|
289 |
let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "result"); |
|
290 |
if (canId) { |
|
291 |
result['id'] = canId; |
|
292 |
} |
|
293 |
result['relcanId'] = result['id']; |
|
294 |
|
|
295 |
if (resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classname")) { |
|
296 |
result['title'].accessMode = resData['bestaccessright'].classname; |
|
297 |
} |
|
298 |
if (resData['rels'].hasOwnProperty("rel")) { |
|
299 |
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1; |
|
300 |
|
|
301 |
for (let j = 0; j < relLength; j++) { |
|
302 |
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel']; |
|
303 |
|
|
304 |
if (relation.hasOwnProperty("to")) { |
|
305 |
if (relation['to'].class == "isProducedBy") { |
|
306 |
result['projects'] = this.parseProjects(result['projects'], relation); |
|
307 |
} |
|
308 |
} |
|
309 |
} |
|
310 |
} |
|
311 |
|
|
312 |
if (resData.hasOwnProperty("creator") && resData['creator'] != null) { |
|
313 |
if (result['authors'] == undefined) { |
|
314 |
result['authors'] = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>(); |
|
315 |
} |
|
316 |
|
|
317 |
let authors = resData['creator']; |
|
318 |
let length = Array.isArray(authors) ? authors.length : 1; |
|
319 |
|
|
320 |
for (let i = 0; i < length; i++) { |
|
321 |
let author = Array.isArray(authors) ? authors[i] : authors; |
|
322 |
if (author) { |
|
323 |
if(author.orcid) { |
|
324 |
author.orcid = author.orcid.toUpperCase(); |
|
325 |
} |
|
326 |
if(author.orcid_pending) { |
|
327 |
author.orcid_pending = author.orcid_pending.toUpperCase(); |
|
328 |
} |
|
329 |
result['authors'][author.rank] = { |
|
330 |
"fullName": author.content, |
|
331 |
"orcid": author.orcid, |
|
332 |
"orcid_pending": author.orcid_pending |
|
333 |
}; |
|
334 |
} |
|
335 |
} |
|
336 |
result.authors = result.authors.filter(function (item) { |
|
337 |
return (item != undefined && item.fullName != undefined); |
|
338 |
}); |
|
339 |
} |
|
340 |
|
|
341 |
var date: string = (resData.dateofacceptance) + ""; // transform to string in case it is an integer |
|
342 |
result.year = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date; |
|
343 |
|
|
344 |
if (!Array.isArray(resData.description)) { |
|
345 |
result.description = (resData.description) ? String(resData.description) : ""; |
|
346 |
} else { |
|
347 |
result.description = (resData.description[0]) ? String(resData.description[0]) : ""; |
|
348 |
} |
|
349 |
|
|
350 |
if (result.description && result.description.length > this.sizeOfDescription) { |
|
351 |
result.description = result.description.substring(0, this.sizeOfDescription) + "..."; |
|
352 |
} |
|
353 |
|
|
354 |
if (resData.embargoenddate && resData.embargoenddate != '') { |
|
355 |
result.embargoEndDate = Dates.getDate(resData.embargoenddate); |
|
356 |
} |
|
357 |
|
|
358 |
if (!Array.isArray(resData.publisher)) { |
|
359 |
result.publisher = resData.publisher; |
|
360 |
} else { |
|
361 |
for (let i = 0; i < resData.publisher.length; i++) { |
|
362 |
if (result.publisher != undefined) { |
|
363 |
result.publisher += ', ' + resData['publisher'][i]; |
|
364 |
} else { |
|
365 |
result.publisher = resData['publisher'][i]; |
|
366 |
} |
|
367 |
} |
|
368 |
} |
|
369 |
if(resData['context'] != null) { |
|
370 |
result.enermapsId = ParsingFunctions.getEnermapsConceptId(this.parsingFunctions.parseContexts(resData['context'])); |
|
371 |
} |
|
372 |
results.push(result); |
|
373 |
} |
|
374 |
|
|
375 |
return results; |
|
376 |
} |
|
377 |
|
|
378 |
parseProjects(projects: { |
|
379 |
"id": string, "acronym": string, "title": string, |
|
380 |
"funderShortname": string, "funderName": string, |
|
381 |
"code": string |
|
382 |
}[], relation: any): { |
|
383 |
"id": string, "acronym": string, "title": string, |
|
384 |
"funderShortname": string, "funderName": string, |
|
385 |
"code": string |
|
386 |
}[] { |
|
387 |
if (projects == undefined) { |
|
388 |
projects = new Array<{ |
|
389 |
"id": string, "acronym": string, "title": string, |
|
390 |
"funderShortname": string, "funderName": string, |
|
391 |
"code": string |
|
392 |
}>(); |
|
393 |
} |
|
394 |
|
|
395 |
let countProjects = projects.length; |
|
396 |
|
|
397 |
projects[countProjects] = { |
|
398 |
"id": "", "acronym": "", "title": "", |
|
399 |
"funderShortname": "", "funderName": "", |
|
400 |
"code": "" |
|
401 |
}; |
|
402 |
|
|
403 |
if (relation.title != 'unidentified') { |
|
404 |
projects[countProjects]['id'] = relation['to'].content; |
|
405 |
projects[countProjects]['acronym'] = relation.acronym; |
|
406 |
projects[countProjects]['title'] = relation.title; |
|
407 |
projects[countProjects]['code'] = relation.code; |
|
408 |
} else { |
|
409 |
projects[countProjects]['id'] = ""; |
|
410 |
projects[countProjects]['acronym'] = ""; |
|
411 |
projects[countProjects]['title'] = ""; |
|
412 |
projects[countProjects]['code'] = ""; |
|
413 |
} |
|
414 |
|
|
415 |
if (relation.hasOwnProperty("funding")) { |
|
416 |
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1; |
|
417 |
|
|
418 |
for (let z = 0; z < fundingLength; z++) { |
|
419 |
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding']; |
|
420 |
|
|
421 |
if (fundingData.hasOwnProperty("funder")) { |
|
422 |
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname; |
|
423 |
projects[countProjects]['funderName'] = fundingData['funder'].name; |
|
424 |
} |
|
425 |
} |
|
426 |
} |
|
427 |
|
|
428 |
return projects; |
|
429 |
} |
|
430 |
|
|
431 |
parseRefineResults(id: string, data: any): any { |
|
432 |
var results: any = []; |
|
433 |
if (data.hasOwnProperty("resulthostingdatasource")) { |
|
434 |
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1; |
|
435 |
|
|
436 |
for (let i = 0; i < length; i++) { |
|
437 |
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource']; |
|
438 |
|
|
439 |
let result: { "name": string, "id": string, "count": number } = {"name": "", "id": "", "count": 0}; |
|
440 |
result['name'] = datasource.name; |
|
441 |
result['id'] = datasource.id.split("||")[0]; |
|
442 |
result['count'] = datasource.count; |
|
443 |
|
|
444 |
if (result['id'] != id && result['name'] != "Unknown Repository") { |
|
445 |
results.push(result); |
|
446 |
} |
|
447 |
} |
|
448 |
} |
|
449 |
return results; |
|
450 |
} |
|
451 |
|
|
452 |
private numOfResults(url: string, properties: EnvProperties): any { |
|
453 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
454 |
.pipe(map(res => res['total'])); |
|
455 |
} |
|
456 |
|
|
457 |
numOfEntityResults(resultType: string, id: string, entity: string, properties: EnvProperties): any { |
|
458 |
var parameters: string = ""; |
|
459 |
parameters = this.getEntityName(entity, true) + "/" + id + "/" + this.getEntityName(resultType, true) + "/count"; |
|
460 |
let url = properties.searchAPIURLLAst + parameters + "?format=json"; |
|
461 |
return this.numOfResults(url, properties); |
|
462 |
} |
|
463 |
|
|
464 |
numOfResearchOutcomes(params: string, properties: EnvProperties, refineParams: string = null): any { |
|
465 |
let url = properties.searchAPIURLLAst + "resources2/?format=json&size=0&type=results"; |
|
466 |
if (params.length > 0) { |
|
467 |
// var DOIs:string[] = DOI.getDOIsFromString(params); |
|
468 |
// var doisParams = ""; |
|
469 |
// |
|
470 |
// for(var i =0 ;i < DOIs.length; i++){ |
|
471 |
// doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; |
|
472 |
// } |
|
473 |
// if(doisParams.length > 0){ |
|
474 |
// url += "&"+doisParams; |
|
475 |
// }else{ |
|
476 |
// url += "&query=" + StringUtils.URIEncode(params); |
|
477 |
// } |
|
478 |
url += "&query=" + params; |
|
479 |
} |
|
480 |
|
|
481 |
if (refineParams != null && refineParams != '') { |
|
482 |
url += refineParams; |
|
483 |
} |
|
484 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
485 |
.pipe(map(res => res['meta']['total'])); |
|
486 |
} |
|
487 |
|
|
488 |
numOfSearchResults(resultType: string, params: string, properties: EnvProperties, refineParams: string = null): any { |
|
489 |
let url = properties.searchAPIURLLAst + this.getEntityName(resultType, true) + "/count?format=json"; |
|
490 |
if (params.length > 0) { |
|
491 |
var DOIs: string[] = DOI.getDOIsFromString(params); |
|
492 |
var doisParams = ""; |
|
493 |
|
|
494 |
for (var i = 0; i < DOIs.length; i++) { |
|
495 |
doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + DOIs[i] + '"'; |
|
496 |
} |
|
497 |
if (doisParams.length > 0) { |
|
498 |
url += "&" + doisParams; |
|
499 |
} else { |
|
500 |
url += "&q=" + StringUtils.URIEncode(params); |
|
501 |
} |
|
502 |
} |
|
503 |
|
|
504 |
if (refineParams != null && refineParams != '') { |
|
505 |
url += refineParams; |
|
506 |
} |
|
507 |
return this.numOfResults(url, properties); |
|
508 |
} |
|
509 |
|
|
510 |
numOfSearchResultsLinkedToPub(resultType: string, properties: EnvProperties): any { |
|
511 |
let url = properties.searchAPIURLLAst + "resources?query=" + encodeURIComponent("( (oaftype exact result) and (resulttypeid exact " + resultType + ") and (relresulttype=publication) )") + "&page=0&size=0&format=json"; |
|
512 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
|
513 |
.pipe(map(res => res['meta']['total'])); |
|
514 |
} |
|
515 |
|
|
516 |
countTotalResults(resultType: string, properties: EnvProperties, refineParams: string = null): any { |
|
517 |
let url = properties.searchAPIURLLAst + this.getEntityName(resultType, true) + "/count?format=json" + refineParams; |
|
518 |
return this.numOfResults(url, properties); |
|
519 |
} |
|
520 |
|
|
521 |
/* |
|
522 |
private quote(word: any): string { |
|
523 |
return '"'+word+'"'; |
|
524 |
} |
|
525 |
*/ |
|
526 |
|
|
527 |
private getEntityName(entityType: string, plural: boolean) { |
|
528 |
if (entityType == "publication" || entityType == "dataset" || entityType == "organization" || entityType == "datasource" || entityType == "project") { |
|
529 |
if (plural) { |
|
530 |
return entityType + "s"; |
|
531 |
} else { |
|
532 |
return entityType; |
|
533 |
} |
|
534 |
} else { |
|
535 |
return entityType; |
|
536 |
} |
|
537 |
} |
|
538 |
} |
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/searchPages/searchUtils/tabResult.module.ts | ||
---|---|---|
1 |
import { NgModule} from '@angular/core'; |
|
2 |
import { CommonModule } from '@angular/common'; |
|
3 |
import { FormsModule } from '@angular/forms'; |
|
4 |
|
|
5 |
import {TabResultComponent} from './tabResult.component'; |
|
6 |
import {RouterModule} from '@angular/router'; |
|
7 |
import {ShowAuthorsModule} from "../../utils/authors/showAuthors.module"; |
|
8 |
|
|
9 |
@NgModule({ |
|
10 |
imports: [ |
|
11 |
CommonModule, FormsModule, |
|
12 |
RouterModule, ShowAuthorsModule |
|
13 |
], |
|
14 |
declarations: [ |
|
15 |
TabResultComponent, |
|
16 |
], |
|
17 |
providers:[ |
|
18 |
], |
|
19 |
exports: [ |
|
20 |
TabResultComponent |
|
21 |
] |
|
22 |
}) |
|
23 |
export class TabResultModule { } |
modules/uoa-services-library/branches/angular-8/ng-openaire-library/src/app/services/searchDataproviders.service.ts | ||
---|---|---|
1 |
import {Injectable} from '@angular/core'; |
|
2 |
import {HttpClient} from "@angular/common/http"; |
|
3 |
import {SearchResult} from '../utils/entities/searchResult'; |
|
4 |
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; |
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
import {StringUtils} from '../utils/string-utils.class'; |
|
9 |
import{EnvProperties} from '../utils/properties/env-properties'; |
|
10 |
import {map} from "rxjs/operators"; |
|
11 |
|
|
12 |
@Injectable() |
|
13 |
export class SearchDataprovidersService { |
|
14 |
private sizeOfDescription: number = 270; |
|
15 |
|
|
16 |
constructor(private http: HttpClient ) {} |
|
17 |
|
|
18 |
searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties, usedBy: string="search" ):any { |
|
19 |
let link = properties.searchAPIURLLAst+"datasources"; |
|
20 |
|
|
21 |
let url = link+"?"; |
|
22 |
if(params!= null && params != '' ) { |
|
23 |
url += params; |
|
24 |
} |
|
25 |
if(refineParams!= null && refineParams != '' ) { |
|
26 |
url += refineParams; |
|
27 |
} |
|
28 |
url += "&page="+(page-1)+"&size="+size+"&format=json"; |
|
29 |
|
|
30 |
|
|
31 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
32 |
//.map(res => <any> res.json()) |
|
33 |
//.do(res => console.info(res)) |
|
34 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource", usedBy)])); |
|
35 |
} |
|
36 |
//((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb")) |
|
37 |
advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null, depositQuery:boolean = false ):any { |
|
38 |
let url = properties.searchAPIURLLAst+"resources"+(depositQuery?'':2)+"/?format=json"; |
|
39 |
|
|
40 |
if(params!= null && params != '' ) { |
|
41 |
url +="&query=(" + params + ")"; |
|
42 |
|
|
43 |
} |
|
44 |
if(refineParams!= null && refineParams != '' ) { |
|
45 |
url += refineParams; |
|
46 |
} |
|
47 |
if(refineQuery) { |
|
48 |
url += "&" + refineQuery; |
|
49 |
} |
Also available in: Unified diff
[Library]: Creating branch for angular 8