1 |
|
import {Component} from '@angular/core';
|
|
1 |
import {Component, ViewChild} from '@angular/core';
|
2 |
2 |
import {Subscription} from 'rxjs';
|
3 |
3 |
import {ActivatedRoute, Router} from '@angular/router';
|
4 |
4 |
import {Location} from '@angular/common';
|
5 |
5 |
import "rxjs/add/observable/zip";
|
6 |
|
import {Title, Meta} from '@angular/platform-browser';
|
|
6 |
import {Meta, Title} from '@angular/platform-browser';
|
7 |
7 |
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
8 |
|
import { SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
|
9 |
|
import { SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
|
10 |
|
import { SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service';
|
11 |
|
import { RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service';
|
12 |
|
import { SearchFields} from '../openaireLibrary/utils/properties/searchFields';
|
13 |
|
import { NumberUtils} from '../openaireLibrary/utils/number-utils.class';
|
|
8 |
import {SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
|
|
9 |
import {SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
|
|
10 |
import {SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service';
|
|
11 |
import {RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service';
|
|
12 |
import {SearchFields} from '../openaireLibrary/utils/properties/searchFields';
|
14 |
13 |
|
15 |
|
import { RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
|
16 |
|
import { EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
17 |
|
import { ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
|
14 |
import {RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
|
|
15 |
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
|
16 |
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
18 |
17 |
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
19 |
|
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
|
18 |
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
20 |
19 |
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
21 |
20 |
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
22 |
21 |
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
... | ... | |
26 |
25 |
import {portalProperties} from "../../environments/environment-aggregator";
|
27 |
26 |
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
28 |
27 |
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
|
|
28 |
import {NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
|
29 |
29 |
|
30 |
30 |
@Component({
|
31 |
31 |
selector: 'home',
|
... | ... | |
58 |
58 |
showOrganizations: boolean = portalProperties.entities.organization.isEnabled;
|
59 |
59 |
showProjects: boolean = portalProperties.entities.project.isEnabled;
|
60 |
60 |
showDataProviders: boolean = portalProperties.entities.datasource.isEnabled;
|
61 |
|
properties: EnvProperties;
|
|
61 |
properties: EnvProperties = properties;
|
62 |
62 |
public readMore: boolean = false;
|
63 |
63 |
|
64 |
64 |
subs: Subscription[] = [];
|
... | ... | |
77 |
77 |
customFilter:SearchCustomFilter= null;
|
78 |
78 |
aggregatorId;
|
79 |
79 |
aggregator:AggregatorInfo;
|
|
80 |
@ViewChild('numbersComponent') numbersComponent: NumbersComponent;
|
|
81 |
|
80 |
82 |
constructor (
|
81 |
83 |
private route: ActivatedRoute,
|
82 |
84 |
private _router: Router,
|
... | ... | |
109 |
111 |
}));
|
110 |
112 |
}
|
111 |
113 |
|
112 |
|
public getKeys(obj: {}) {
|
113 |
|
return Object.keys(obj);
|
114 |
|
}
|
115 |
|
|
116 |
|
createRange(number){
|
117 |
|
var items: number[] = [];
|
118 |
|
for(var i = 1; i <= number; i++){
|
119 |
|
items.push(i);
|
120 |
|
}
|
121 |
|
return items;
|
122 |
|
}
|
123 |
|
|
124 |
114 |
public ceil(num: number) {
|
125 |
115 |
return Math.ceil(num);
|
126 |
116 |
}
|
127 |
117 |
|
128 |
118 |
public ngOnInit() {
|
129 |
|
this.properties = properties;
|
130 |
119 |
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink+this._router.url, false);
|
131 |
120 |
this.getPageContents();
|
132 |
|
|
133 |
121 |
if(this.properties!=null){
|
134 |
122 |
var url = this.properties.domain + this.properties.baseLink+this._router.url;
|
135 |
123 |
this._meta.updateTag({content:url},"property='og:url'");
|
... | ... | |
145 |
133 |
|
146 |
134 |
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
147 |
135 |
}
|
148 |
|
this.showPublications = showEntity["publication"];
|
149 |
|
this.showDatasets = showEntity["dataset"];
|
150 |
|
this.showSoftware = showEntity["software"];
|
151 |
|
this.showOrp = showEntity["orp"];
|
152 |
|
this.showProjects = showEntity["project"];
|
153 |
|
this.showDataProviders = showEntity["datasource"];
|
154 |
|
this.showOrganizations = showEntity["organization"];
|
|
136 |
this.showPublications = !!showEntity["publication"];
|
|
137 |
this.showDatasets = !!showEntity["dataset"];
|
|
138 |
this.showSoftware = !!showEntity["software"];
|
|
139 |
this.showOrp = !!showEntity["orp"];
|
|
140 |
this.showProjects = !!showEntity["project"];
|
|
141 |
this.showDataProviders = !!showEntity["datasource"];
|
|
142 |
this.showOrganizations = !!showEntity["organization"];
|
155 |
143 |
if(this.showPublications){
|
156 |
144 |
this.resultTypes.values.push({name: "Publications" , id:"publications",selected:true, number:0});
|
157 |
145 |
}
|
... | ... | |
164 |
152 |
if(this.showOrp){
|
165 |
153 |
this.resultTypes.values.push({name: "Other research products" , id:"other",selected:true, number:0});
|
166 |
154 |
}
|
167 |
|
this.getNumbers();
|
|
155 |
this.numbersComponent.init(false, false, this.showPublications, this.showDatasets,
|
|
156 |
this.showSoftware, this.showOrp, this.showProjects, this.showDataProviders,
|
|
157 |
StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId ))));
|
168 |
158 |
}
|
169 |
159 |
},
|
170 |
160 |
error => {
|
... | ... | |
180 |
170 |
}
|
181 |
171 |
}
|
182 |
172 |
|
183 |
|
private getNumbers() {
|
184 |
|
let refineQuery = null
|
185 |
|
if(this.customFilter){
|
186 |
|
refineQuery= "&fq="+StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId )));
|
187 |
|
}
|
188 |
|
if(this.showPublications){
|
189 |
|
this.subs.push(this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties, refineQuery).subscribe(
|
190 |
|
data => {
|
191 |
|
if(data && data != null && data > 0 ){
|
192 |
|
this.publicationsSize = NumberUtils.roundNumber(data);
|
193 |
|
|
194 |
|
}
|
195 |
|
},
|
196 |
|
err => {
|
197 |
|
//console.log(err);
|
198 |
|
this.handleError("Error getting number of publications", err);
|
199 |
|
}
|
200 |
|
));
|
201 |
|
}
|
202 |
|
if(this.showDatasets){
|
203 |
|
this.subs.push(this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties, refineQuery).subscribe(
|
204 |
|
data => {
|
205 |
|
if(data && data != null && data > 0 ){
|
206 |
|
this.datasetsSize = NumberUtils.roundNumber(data);
|
207 |
|
}
|
208 |
|
},
|
209 |
|
err => {
|
210 |
|
//console.log(err);
|
211 |
|
this.handleError("Error getting number of research data", err);
|
212 |
|
}
|
213 |
|
));
|
214 |
|
/*this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties, refineQuery).subscribe(
|
215 |
|
data => {
|
216 |
|
if(data && data != null && data > 0 ){
|
217 |
|
this.datasetsLinkedSize = NumberUtils.roundNumber(data);
|
218 |
|
}
|
219 |
|
},
|
220 |
|
err => {
|
221 |
|
//console.log(err);
|
222 |
|
this.handleError("Error getting number of linkedresearch data", err);
|
223 |
|
}
|
224 |
|
));*/
|
225 |
|
|
226 |
|
}
|
227 |
|
if (this.showSoftware) {
|
228 |
|
this.subs.push(this._searchResearchResultsService.numOfSearchResults("software", "", this.properties, refineQuery).subscribe(
|
229 |
|
data => {
|
230 |
|
if (data && data > 0) {
|
231 |
|
this.softwareSize = NumberUtils.roundNumber(data);
|
232 |
|
}else{
|
233 |
|
this.showSoftware = false;
|
234 |
|
}
|
235 |
|
},
|
236 |
|
err => {
|
237 |
|
this.handleError("Error getting number of software data", err);
|
238 |
|
}
|
239 |
|
));
|
240 |
|
/* this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties, refineQuery).subscribe(
|
241 |
|
data => {
|
242 |
|
if(data && data != null && data > 0 ){
|
243 |
|
this.softwareLinkedSize = NumberUtils.roundNumber(data);
|
244 |
|
}
|
245 |
|
},
|
246 |
|
err => {
|
247 |
|
//console.log(err);
|
248 |
|
this.handleError("Error getting number of linked software", err);
|
249 |
|
}
|
250 |
|
));*/
|
251 |
|
}
|
252 |
|
if (this.showOrp) {
|
253 |
|
this.subs.push(this._searchResearchResultsService.numOfSearchResults("other", "", this.properties, refineQuery).subscribe(
|
254 |
|
data => {
|
255 |
|
if (data && data > 0) {
|
256 |
|
this.otherSize = NumberUtils.roundNumber(data);
|
257 |
|
}else{
|
258 |
|
this.showOrp = false;
|
259 |
|
}
|
260 |
|
},
|
261 |
|
err => {
|
262 |
|
this.handleError("Error getting number of software data", err);
|
263 |
|
}
|
264 |
|
));
|
265 |
|
}
|
266 |
|
if(this.showProjects){
|
267 |
|
this.subs.push(this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties, refineQuery).subscribe(
|
268 |
|
data => {
|
269 |
|
|
270 |
|
|
271 |
|
if(data[0] && data[0] > 0 ){
|
272 |
|
this.projectsSize = NumberUtils.roundNumber(data[0]);
|
273 |
|
}
|
274 |
|
if(data[1].length > 0 && data[1][0].filterId == "funder" && data[1][0].values ){
|
275 |
|
this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length);
|
276 |
|
}
|
277 |
|
|
278 |
|
},
|
279 |
|
err => {
|
280 |
|
//console.log(err);
|
281 |
|
this.handleError("Error getting 'funder' field results of projects", err);
|
282 |
|
}));
|
283 |
|
}
|
284 |
|
if(this.showDataProviders){
|
285 |
|
this.subs.push(this._searchDataprovidersService.numOfSearchDataproviders("", this.properties, refineQuery).subscribe(
|
286 |
|
data => {
|
287 |
|
if(data && data != null && data > 0 ){
|
288 |
|
this.datasourcesSize = NumberUtils.roundNumber(data);
|
289 |
|
}
|
290 |
|
|
291 |
|
},
|
292 |
|
err => {
|
293 |
|
//console.log(err);
|
294 |
|
this.handleError("Error getting number of content providers", err);
|
295 |
|
}
|
296 |
|
));
|
297 |
|
}
|
298 |
|
}
|
299 |
|
|
300 |
173 |
private handleError(message: string, error) {
|
301 |
174 |
console.error("Home Page: "+message, error);
|
302 |
175 |
}
|
[Aggragator | Trunk]: Add numbers on home page