1 |
60908
|
k.triantaf
|
import {Component, ViewChild} from '@angular/core';
|
2 |
59900
|
argiro.kok
|
import {Subscription} from 'rxjs';
|
3 |
55689
|
argiro.kok
|
import {ActivatedRoute, Router} from '@angular/router';
|
4 |
|
|
import {Location} from '@angular/common';
|
5 |
|
|
import "rxjs/add/observable/zip";
|
6 |
60908
|
k.triantaf
|
import {Meta, Title} from '@angular/platform-browser';
|
7 |
55689
|
argiro.kok
|
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
|
8 |
60908
|
k.triantaf
|
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 |
55689
|
argiro.kok
|
|
14 |
60908
|
k.triantaf
|
import {RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
|
15 |
|
|
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
|
16 |
|
|
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
|
17 |
55689
|
argiro.kok
|
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
|
18 |
60908
|
k.triantaf
|
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
|
19 |
59900
|
argiro.kok
|
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
|
20 |
|
|
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
|
21 |
|
|
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
|
22 |
60133
|
argiro.kok
|
import {AggregatorInfo, PortalAggregators} from "../utils/aggregators";
|
23 |
55723
|
argiro.kok
|
import {SearchCustomFilter} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
|
24 |
59900
|
argiro.kok
|
import {properties} from "../../environments/environment";
|
25 |
|
|
import {portalProperties} from "../../environments/environment-aggregator";
|
26 |
55723
|
argiro.kok
|
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
27 |
60305
|
argiro.kok
|
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
|
28 |
60908
|
k.triantaf
|
import {NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
|
29 |
57127
|
argiro.kok
|
|
30 |
55689
|
argiro.kok
|
@Component({
|
31 |
55723
|
argiro.kok
|
selector: 'home',
|
32 |
|
|
templateUrl: 'home.component.html',
|
33 |
55689
|
argiro.kok
|
})
|
34 |
|
|
export class HomeComponent {
|
35 |
59900
|
argiro.kok
|
public keyword:string = "";
|
36 |
55689
|
argiro.kok
|
|
37 |
59900
|
argiro.kok
|
public searchFields:SearchFields = new SearchFields();
|
38 |
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
39 |
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
40 |
|
|
showPublications: boolean = portalProperties.entities.publication.isEnabled;
|
41 |
|
|
showDatasets: boolean = portalProperties.entities.dataset.isEnabled;
|
42 |
|
|
showSoftware: boolean = portalProperties.entities.software.isEnabled;
|
43 |
|
|
showOrp: boolean = portalProperties.entities.other.isEnabled;
|
44 |
|
|
showOrganizations: boolean = portalProperties.entities.organization.isEnabled;
|
45 |
|
|
showProjects: boolean = portalProperties.entities.project.isEnabled;
|
46 |
|
|
showDataProviders: boolean = portalProperties.entities.datasource.isEnabled;
|
47 |
60908
|
k.triantaf
|
properties: EnvProperties = properties;
|
48 |
59900
|
argiro.kok
|
public readMore: boolean = false;
|
49 |
55689
|
argiro.kok
|
|
50 |
59900
|
argiro.kok
|
subs: Subscription[] = [];
|
51 |
|
|
|
52 |
|
|
resultsQuickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
|
53 |
|
|
filter: null,
|
54 |
|
|
selected: true,
|
55 |
|
|
filterId: "resultbestaccessright",
|
56 |
|
|
value: "Open Access"
|
57 |
|
|
};
|
58 |
|
|
selectedEntity = "all";
|
59 |
|
|
selectedEntitySimpleUrl;
|
60 |
|
|
selectedEntityAdvancedUrl;
|
61 |
|
|
resultTypes:Filter = {values:[],filterId:"type", countSelectedValues: 0, filterType: 'checkbox', originalFilterId: "", valueIsExact: true, title: "Result Types",filterOperator:"or"};
|
62 |
|
|
public pageContents = null;
|
63 |
56072
|
argiro.kok
|
customFilter:SearchCustomFilter= null;
|
64 |
59900
|
argiro.kok
|
aggregatorId;
|
65 |
60133
|
argiro.kok
|
aggregator:AggregatorInfo;
|
66 |
60908
|
k.triantaf
|
@ViewChild('numbersComponent') numbersComponent: NumbersComponent;
|
67 |
|
|
|
68 |
59900
|
argiro.kok
|
constructor (
|
69 |
55689
|
argiro.kok
|
private route: ActivatedRoute,
|
70 |
55723
|
argiro.kok
|
private _router: Router,
|
71 |
57127
|
argiro.kok
|
private _searchResearchResultsService: SearchResearchResultsService,
|
72 |
55723
|
argiro.kok
|
private _searchDataprovidersService: SearchDataprovidersService,
|
73 |
|
|
private _searchProjectsService: SearchProjectsService,
|
74 |
|
|
private _searchOrganizationsService: SearchOrganizationsService,
|
75 |
59900
|
argiro.kok
|
private _refineFieldResultsService:RefineFieldResultsService,
|
76 |
|
|
private location: Location, private _piwikService:PiwikService,
|
77 |
|
|
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
|
78 |
|
|
private helper: HelperService
|
79 |
55723
|
argiro.kok
|
) {
|
80 |
60305
|
argiro.kok
|
this.aggregatorId = ConnectHelper.getCommunityFromDomain(properties.domain);
|
81 |
59900
|
argiro.kok
|
this.aggregator = PortalAggregators.getFilterInfoByMenuId(this.aggregatorId);
|
82 |
|
|
this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(this.aggregator);
|
83 |
|
|
let description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide.";
|
84 |
|
|
let title = "OpenAIRE - Explore| " +this.aggregator.title;
|
85 |
55689
|
argiro.kok
|
|
86 |
55723
|
argiro.kok
|
this._title.setTitle(title);
|
87 |
59900
|
argiro.kok
|
this._meta.updateTag({content:description},"name='description'");
|
88 |
|
|
this._meta.updateTag({content:description},"property='og:description'");
|
89 |
|
|
this._meta.updateTag({content:title},"property='og:title'");
|
90 |
56072
|
argiro.kok
|
|
91 |
59900
|
argiro.kok
|
|
92 |
55689
|
argiro.kok
|
}
|
93 |
|
|
|
94 |
59900
|
argiro.kok
|
private getPageContents() {
|
95 |
|
|
this.subs.push(this.helper.getPageHelpContents(this.properties, 'openaire', this._router.url).subscribe(contents => {
|
96 |
|
|
this.pageContents = contents;
|
97 |
|
|
}));
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
public ceil(num: number) {
|
101 |
|
|
return Math.ceil(num);
|
102 |
|
|
}
|
103 |
|
|
|
104 |
55689
|
argiro.kok
|
public ngOnInit() {
|
105 |
59900
|
argiro.kok
|
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink+this._router.url, false);
|
106 |
|
|
this.getPageContents();
|
107 |
|
|
if(this.properties!=null){
|
108 |
|
|
var url = this.properties.domain + this.properties.baseLink+this._router.url;
|
109 |
|
|
this._meta.updateTag({content:url},"property='og:url'");
|
110 |
|
|
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
|
111 |
|
|
this.subs.push(this._piwikService.trackView(this.properties, "OpenAIRE").subscribe());
|
112 |
|
|
}
|
113 |
55689
|
argiro.kok
|
|
114 |
59900
|
argiro.kok
|
//this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
|
115 |
59969
|
argiro.kok
|
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
116 |
59900
|
argiro.kok
|
if(data) {
|
117 |
|
|
var showEntity = {};
|
118 |
|
|
for (var i = 0; i < data['entities'].length; i++) {
|
119 |
55689
|
argiro.kok
|
|
120 |
59900
|
argiro.kok
|
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
121 |
55723
|
argiro.kok
|
}
|
122 |
60908
|
k.triantaf
|
this.showPublications = !!showEntity["publication"];
|
123 |
|
|
this.showDatasets = !!showEntity["dataset"];
|
124 |
|
|
this.showSoftware = !!showEntity["software"];
|
125 |
|
|
this.showOrp = !!showEntity["orp"];
|
126 |
|
|
this.showProjects = !!showEntity["project"];
|
127 |
|
|
this.showDataProviders = !!showEntity["datasource"];
|
128 |
|
|
this.showOrganizations = !!showEntity["organization"];
|
129 |
59900
|
argiro.kok
|
if(this.showPublications){
|
130 |
|
|
this.resultTypes.values.push({name: "Publications" , id:"publications",selected:true, number:0});
|
131 |
|
|
}
|
132 |
|
|
if(this.showDatasets){
|
133 |
|
|
this.resultTypes.values.push({name: "Research data" , id:"datasets",selected:true, number:0});
|
134 |
|
|
}
|
135 |
|
|
if(this.showSoftware){
|
136 |
|
|
this.resultTypes.values.push({name: "Software" , id:"software",selected:true, number:0});
|
137 |
|
|
}
|
138 |
|
|
if(this.showOrp){
|
139 |
|
|
this.resultTypes.values.push({name: "Other research products" , id:"other",selected:true, number:0});
|
140 |
|
|
}
|
141 |
60908
|
k.triantaf
|
this.numbersComponent.init(false, false, this.showPublications, this.showDatasets,
|
142 |
|
|
this.showSoftware, this.showOrp, this.showProjects, this.showDataProviders,
|
143 |
|
|
StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId ))));
|
144 |
59969
|
argiro.kok
|
}
|
145 |
59900
|
argiro.kok
|
},
|
146 |
|
|
error => {
|
147 |
|
|
this.handleError("Error getting community information", error);
|
148 |
|
|
}
|
149 |
59969
|
argiro.kok
|
));
|
150 |
59900
|
argiro.kok
|
}
|
151 |
55689
|
argiro.kok
|
|
152 |
|
|
}
|
153 |
|
|
public ngOnDestroy() {
|
154 |
59900
|
argiro.kok
|
for (let sub of this.subs) {
|
155 |
|
|
sub.unsubscribe();
|
156 |
55689
|
argiro.kok
|
}
|
157 |
55723
|
argiro.kok
|
}
|
158 |
|
|
|
159 |
59900
|
argiro.kok
|
private handleError(message: string, error) {
|
160 |
|
|
console.error("Home Page: "+message, error);
|
161 |
|
|
}
|
162 |
|
|
entityChanged($event){
|
163 |
|
|
this.selectedEntity = $event.entity;
|
164 |
|
|
this.selectedEntitySimpleUrl = $event.simpleUrl;
|
165 |
|
|
this.selectedEntityAdvancedUrl = $event.advancedUrl;
|
166 |
|
|
}
|
167 |
|
|
goTo(simple:boolean){
|
168 |
|
|
let url = (simple)?this.selectedEntitySimpleUrl:this.selectedEntityAdvancedUrl;
|
169 |
|
|
let parameterNames = [];
|
170 |
|
|
let parameterValues = [];
|
171 |
|
|
if (this.selectedEntity == "result") {
|
172 |
|
|
if (this.resultTypes) {
|
173 |
|
|
let values = [];
|
174 |
|
|
for(let value of this.resultTypes.values){
|
175 |
|
|
if (value.selected) {
|
176 |
|
|
values.push(value.id);
|
177 |
55723
|
argiro.kok
|
}
|
178 |
|
|
}
|
179 |
59900
|
argiro.kok
|
if (values.length > 0 && values.length !=4) {
|
180 |
|
|
parameterNames.push("type");
|
181 |
|
|
parameterValues.push(values.join(","));
|
182 |
|
|
}
|
183 |
|
|
if (this.resultsQuickFilter) {
|
184 |
|
|
parameterNames.push("qf");
|
185 |
|
|
parameterValues.push("" + this.resultsQuickFilter.selected);
|
186 |
|
|
}
|
187 |
|
|
}
|
188 |
60133
|
argiro.kok
|
}else if(this.selectedEntity == "all"){
|
189 |
|
|
if (this.resultsQuickFilter) {
|
190 |
|
|
parameterNames.push("qf");
|
191 |
|
|
parameterValues.push("true");
|
192 |
|
|
}
|
193 |
55723
|
argiro.kok
|
}
|
194 |
59900
|
argiro.kok
|
if(this.keyword.length > 0) {
|
195 |
|
|
parameterNames.push("fv0");
|
196 |
|
|
parameterValues.push(this.keyword);
|
197 |
|
|
parameterNames.push("f0");
|
198 |
|
|
parameterValues.push("q");
|
199 |
|
|
}
|
200 |
59939
|
argiro.kok
|
if(this.customFilter){
|
201 |
|
|
parameterNames.push(this.customFilter.queryFieldName);
|
202 |
|
|
parameterValues.push(this.customFilter.valueId);
|
203 |
|
|
parameterNames.push("cf");
|
204 |
|
|
parameterValues.push("true");
|
205 |
|
|
}
|
206 |
59900
|
argiro.kok
|
this._router.navigate([url], {queryParams: this.routerHelper.createQueryParams(parameterNames, parameterValues)});
|
207 |
55723
|
argiro.kok
|
}
|
208 |
59939
|
argiro.kok
|
getQueryParamsForAdvancedSearch(entity){
|
209 |
|
|
let params = {};
|
210 |
|
|
if (entity == "result") {
|
211 |
|
|
if (this.resultsQuickFilter) {
|
212 |
|
|
params["qf"] = "" + this.resultsQuickFilter.selected;
|
213 |
|
|
}
|
214 |
|
|
}
|
215 |
|
|
if(this.keyword.length > 0) {
|
216 |
|
|
params["fv0"] = "" + this.keyword;
|
217 |
|
|
params["f0"] = "q";
|
218 |
|
|
}
|
219 |
|
|
if(this.customFilter){
|
220 |
|
|
params = this.customFilter.getParameters(params);
|
221 |
|
|
}
|
222 |
|
|
return params;
|
223 |
|
|
}
|
224 |
55689
|
argiro.kok
|
}
|