[Trunk | Library]:

1. src/assets/common-assets/common/custom.css: Add 'font-display: swap;' in '@font-face' css rules - improve performance.
2. dataProvider.component.html & organizations.component.html & project.component.html & resultLanding.component.html: Add check if 'indexUpdateDate' is initialized.
3. dataProvider.component.ts & organization.component.ts & project.component.ts & resultLanding.component.ts: 
	Initialize 'indexUpdateDate' and tabs counts only if "typeof document !== 'undefined'" (javascript is enabled) - improve performance.
4. resultLanding.component.ts: Get "provenanceActionVocabulary" and "altMetrics" only if "typeof document !== 'undefined'" (javascript is enabled) - improve performance.
5. organization.component.ts: [Bug fix] Get 'indexUpdateDate' from service (not properties) if available.
6. project.component.ts: [Bug fix] Call 'getProjectInfo()' only once (was called twice).
7. project.service.ts: [Bug fix] Add check for rels.rel.to.class=="hasParticipant" (when not array).
8. metrics.component.ts: Get metrics if "typeof document !== 'undefined'" (javascript is enabled) | Show charts only if user clicked on metrics badge | Do not set "width" for <i-frame> elements.
9. iframe.component.ts: Add case when only height is sent as input.
10. searchDataProviders.component.ts & searchOrganizations.component.ts: [Bug fix] Set "firstLoad" to false after getting results (was asking refine filters in paging too). 
11. search-tab.component.ts: [Bug fix]: In method "getEntityName()" add cases when 'entityType == "project"' and 'entityType == "dataprovider"' and fix case when 'entityType == "result"'.
12. navigationBar.component.ts: [Bug fix] Do not initialize navbar inside route.queryParams subscription - !!! check it carefully when deployed in all portals !!! .


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58874 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2020-06-10 11:05:59 +00:00
parent 0c7953b710
commit c20391f3fc
15 changed files with 128 additions and 72 deletions

View File

@ -483,7 +483,7 @@
<div class="uk-width-2-3@m uk-width-1-2"> <div class="uk-width-2-3@m uk-width-1-2">
<img src="assets/common-assets/graph.svg" style="opacity: 0.4"> <img src="assets/common-assets/graph.svg" style="opacity: 0.4">
<span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by OpenAIRE Open Research Graph</span> <span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by OpenAIRE Open Research Graph</span>
<span class="uk-text-baseline uk-text-muted"> <span *ngIf="indexUpdateDate" class="uk-text-baseline uk-text-muted">
. Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}} . Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}}
</span> </span>
</div> </div>

View File

@ -154,13 +154,15 @@ export class DataProviderComponent {
this.route.data this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { if (typeof document !== 'undefined') {
if(lastIndexUpdate) { this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
this.indexUpdateDate = new Date(lastIndexUpdate); if (lastIndexUpdate) {
} else if(this.properties.lastIndexUpdate) { this.indexUpdateDate = new Date(lastIndexUpdate);
this.indexUpdateDate = new Date(this.properties.lastIndexUpdate); } else if (this.properties.lastIndexUpdate) {
} this.indexUpdateDate = new Date(this.properties.lastIndexUpdate);
}); }
});
}
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.updateUrl(data.envSpecific.baseLink + this._router.url); this.updateUrl(data.envSpecific.baseLink + this._router.url);
@ -252,7 +254,9 @@ export class DataProviderComponent {
} else { } else {
this.aggregationStatusIsInitialized = true; this.aggregationStatusIsInitialized = true;
} }
this.initTabs(); if (typeof document !== 'undefined') {
this.initTabs();
}
this.showTabs = true; this.showTabs = true;
this.updateTitle(this.dataProviderInfo.title.name); this.updateTitle(this.dataProviderInfo.title.name);
this.updateDescription("Content provider, " + this.dataProviderInfo.title.name); this.updateDescription("Content provider, " + this.dataProviderInfo.title.name);

View File

@ -45,14 +45,16 @@ import {animate, state, style, transition, trigger} from "@angular/animations";
class="charts uk-visible-toggle" tabindex="-1" uk-slider> class="charts uk-visible-toggle" tabindex="-1" uk-slider>
<ul class="uk-slider-items uk-child-width-1-1"> <ul class="uk-slider-items uk-child-width-1-1">
<li #element> <li #element>
<i-frame *ngIf="metrics.totalViews > 0 && viewsFrameUrl" <!-- [width]="element.offsetWidth"-->
[width]="element.offsetWidth" [height]="200" <i-frame *ngIf="metricsClicked && metrics.totalViews > 0 && viewsFrameUrl"
[height]="200"
[url]=viewsFrameUrl> [url]=viewsFrameUrl>
</i-frame> </i-frame>
</li> </li>
<li #element> <li #element>
<i-frame *ngIf="metrics.totalDownloads > 0 && downloadsFrameUrl" <!-- [width]="element.offsetWidth"-->
[width]="element.offsetWidth" [height]="200" <i-frame *ngIf="metricsClicked && metrics.totalDownloads > 0 && downloadsFrameUrl"
[height]="200"
[url]=downloadsFrameUrl> [url]=downloadsFrameUrl>
</i-frame> </i-frame>
</li> </li>
@ -164,7 +166,9 @@ export class MetricsComponent {
public errorCodes: ErrorCodes; public errorCodes: ErrorCodes;
private sub: Subscription; private sub: Subscription;
private timeouts: any[] = []; private timeouts: any[] = [];
public metricsClicked: boolean = false;
public status: number; public status: number;
public state: number = -1; public state: number = -1;
@ -173,12 +177,16 @@ export class MetricsComponent {
ngOnInit() { ngOnInit() {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.status = this.errorCodes.LOADING; if (typeof document !== 'undefined') {
this.getMetrics(); this.status = this.errorCodes.LOADING;
this.getMetrics();
}
} }
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); if(this.sub) {
this.sub.unsubscribe();
}
} }
public get total(): number { public get total(): number {
@ -225,6 +233,8 @@ export class MetricsComponent {
public toggle(event) { public toggle(event) {
this.metricsClicked = true;
event.stopPropagation(); event.stopPropagation();
if(this.state !== -1) { if(this.state !== -1) {
this.timeouts.forEach(timeout => { this.timeouts.forEach(timeout => {

View File

@ -253,7 +253,7 @@
<div class="uk-width-2-3@m uk-width-1-2"> <div class="uk-width-2-3@m uk-width-1-2">
<img src="assets/common-assets/graph.svg" style="opacity: 0.4"> <img src="assets/common-assets/graph.svg" style="opacity: 0.4">
<span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by OpenAIRE Open Research Graph</span> <span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by OpenAIRE Open Research Graph</span>
<span class="uk-text-baseline uk-text-muted"> <span *ngIf="indexUpdateDate" class="uk-text-baseline uk-text-muted">
. Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}} . Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}}
</span> </span>
</div> </div>

View File

@ -21,6 +21,7 @@ import {HelperService} from "../../utils/helper/helper.service";
import {Location} from "@angular/common"; import {Location} from "@angular/common";
import {FetchResearchResults} from "../../utils/fetchEntitiesClasses/fetchResearchResults.class"; import {FetchResearchResults} from "../../utils/fetchEntitiesClasses/fetchResearchResults.class";
import {FetchDataproviders} from "../../utils/fetchEntitiesClasses/fetchDataproviders.class"; import {FetchDataproviders} from "../../utils/fetchEntitiesClasses/fetchDataproviders.class";
import {IndexInfoService} from "../../utils/indexInfo.service";
@Component({ @Component({
selector: 'organization', selector: 'organization',
@ -124,7 +125,8 @@ export class OrganizationComponent {
private _router: Router, private _router: Router,
private helper: HelperService, private helper: HelperService,
private seoService: SEOService, private seoService: SEOService,
private _location: Location) { private _location: Location,
private indexInfoService: IndexInfoService) {
this.fetchProjects = new FetchProjects(this._searchProjectsService); this.fetchProjects = new FetchProjects(this._searchProjectsService);
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService); this.fetchPublications = new FetchResearchResults(this._searchResearchResultsService);
@ -137,8 +139,14 @@ export class OrganizationComponent {
this.route.data this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
if (this.properties.lastIndexUpdate) { if (typeof document !== 'undefined') {
this.indexUpdateDate = new Date(this.properties.lastIndexUpdate); this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
if (lastIndexUpdate) {
this.indexUpdateDate = new Date(lastIndexUpdate);
} else if (this.properties.lastIndexUpdate) {
this.indexUpdateDate = new Date(this.properties.lastIndexUpdate);
}
});
} }
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
@ -330,8 +338,12 @@ export class OrganizationComponent {
this.piwiksub = this._piwikService.trackView(this.properties, this.organizationInfo.title.name, this.piwikSiteId).subscribe(); this.piwiksub = this._piwikService.trackView(this.properties, this.organizationInfo.title.name, this.piwikSiteId).subscribe();
} }
var refineFields: string [] = ["funder"]; var refineFields: string [] = ["funder"];
this.getTotalResearchResults();
this.getTotalDataproviders(); if (typeof document !== 'undefined') {
this.getTotalResearchResults();
this.getTotalDataproviders();
}
this.fetchProjects.getResultsForOrganizations(this.organizationId, "", 1, this.searchNumber, refineFields, this.properties); this.fetchProjects.getResultsForOrganizations(this.organizationId, "", 1, this.searchNumber, refineFields, this.properties);
this.showLoading = false; this.showLoading = false;
} }

View File

@ -689,7 +689,7 @@
<div class="uk-width-2-3@m uk-width-1-2"> <div class="uk-width-2-3@m uk-width-1-2">
<img src="assets/common-assets/graph.svg" style="opacity: 0.4"> <img src="assets/common-assets/graph.svg" style="opacity: 0.4">
<span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by OpenAIRE Open Research Graph</span> <span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by OpenAIRE Open Research Graph</span>
<span class="uk-text-baseline uk-text-muted"> <span *ngIf="indexUpdateDate" class="uk-text-baseline uk-text-muted">
. Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}} . Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}}
</span> </span>
</div> </div>

View File

@ -152,13 +152,15 @@ export class ProjectComponent {
this.route.data this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { if (typeof document !== 'undefined') {
if(lastIndexUpdate) { this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
this.indexUpdateDate = new Date(lastIndexUpdate); if (lastIndexUpdate) {
} else if(this.properties.lastIndexUpdate) { this.indexUpdateDate = new Date(lastIndexUpdate);
this.indexUpdateDate = new Date(this.properties.lastIndexUpdate); } else if (this.properties.lastIndexUpdate) {
} this.indexUpdateDate = new Date(this.properties.lastIndexUpdate);
}); }
});
}
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.updateUrl(data.envSpecific.baseLink + this._router.url); this.updateUrl(data.envSpecific.baseLink + this._router.url);
@ -251,12 +253,15 @@ export class ProjectComponent {
} }
actionsAfterLoadId() { actionsAfterLoadId() {
this.getProjectInfo(this.projectId); //this.getProjectInfo(this.projectId);
//this.searchPublications(); //this.searchPublications();
this.fetchPublications.getNumForEntity("publication", "project", this.projectId, this.properties);
this.fetchDatasets.getNumForEntity("dataset", "project", this.projectId, this.properties); if (typeof document !== 'undefined') {
this.fetchSoftware.getNumForEntity("software", "project", this.projectId, this.properties); this.fetchPublications.getNumForEntity("publication", "project", this.projectId, this.properties);
this.fetchOrps.getNumForEntity("other", "project", this.projectId, this.properties); this.fetchDatasets.getNumForEntity("dataset", "project", this.projectId, this.properties);
this.fetchSoftware.getNumForEntity("software", "project", this.projectId, this.properties);
this.fetchOrps.getNumForEntity("other", "project", this.projectId, this.properties);
}
} }
ngOnDestroy() { ngOnDestroy() {

View File

@ -179,22 +179,25 @@ export class ProjectService {
let id: string = ""; let id: string = "";
if(!Array.isArray(data[2])) { if(!Array.isArray(data[2])) {
if(data[2].hasOwnProperty("legalshortname")) { if(data[2].hasOwnProperty("to") && data[2]['to'].class == "hasParticipant") {
if (data[2].hasOwnProperty("legalshortname")) {
acronym = data[2].legalshortname; acronym = data[2].legalshortname;
} }
if(data[2].hasOwnProperty("legalname")) { if (data[2].hasOwnProperty("legalname")) {
name = data[2].legalname; name = data[2].legalname;
} }
if(!acronym && !name){ if (!acronym && !name) {
// acronym is displayed with link and name only in tooltip // acronym is displayed with link and name only in tooltip
acronym = "[no title available]"; acronym = "[no title available]";
} }
if(data[2].hasOwnProperty("to")) { if (data[2].hasOwnProperty("to")) {
id = data[2]['to'].content; id = data[2]['to'].content;
} }
this.projectInfo.organizations.push({"acronym": acronym, "name": name, "id": id}); this.projectInfo.organizations.push({"acronym": acronym, "name": name, "id": id});
}
} else { } else {
for(let i=0; i<data[2].length; i++) { for(let i=0; i<data[2].length; i++) {
if(data[2][i].hasOwnProperty("to") && data[2][i]['to'].class == "hasParticipant") { if(data[2][i].hasOwnProperty("to") && data[2][i]['to'].class == "hasParticipant") {

View File

@ -468,7 +468,7 @@
<div class="uk-width-2-3@m uk-width-1-2"> <div class="uk-width-2-3@m uk-width-1-2">
<img src="assets/common-assets/graph.svg" style="opacity: 0.4"> <img src="assets/common-assets/graph.svg" style="opacity: 0.4">
<span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by OpenAIRE Open Research Graph</span> <span class="uk-margin-small-left uk-text-baseline uk-text-muted">Powered by OpenAIRE Open Research Graph</span>
<span class="uk-text-baseline uk-text-muted"> <span *ngIf="indexUpdateDate" class="uk-text-baseline uk-text-muted">
. Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}} . Last update of records in OpenAIRE: {{indexUpdateDate | date: 'MMM dd, yyyy'}}
</span> </span>
</div> </div>

View File

@ -116,13 +116,15 @@ export class ResultLandingComponent {
this.route.data this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => { .subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => { if (typeof document !== 'undefined') {
if (lastIndexUpdate) { this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
this.indexUpdateDate = new Date(lastIndexUpdate); if (lastIndexUpdate) {
} else if (this.properties.lastIndexUpdate) { this.indexUpdateDate = new Date(lastIndexUpdate);
this.indexUpdateDate = new Date(this.properties.lastIndexUpdate); } else if (this.properties.lastIndexUpdate) {
} this.indexUpdateDate = new Date(this.properties.lastIndexUpdate);
}); }
});
}
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.updateUrl(data.envSpecific.baseLink + this._router.url); this.updateUrl(data.envSpecific.baseLink + this._router.url);
@ -248,15 +250,19 @@ export class ResultLandingComponent {
this.showLoading = true; this.showLoading = true;
this.resultLandingInfo = null; this.resultLandingInfo = null;
this._resultLaningService.getProvenanceActionVocabulary(this.properties).subscribe( if (typeof document !== 'undefined') {
provenanceActionVocabulary => { this._resultLaningService.getProvenanceActionVocabulary(this.properties).subscribe(
this.getResultLandingInfo(provenanceActionVocabulary); provenanceActionVocabulary => {
}, err => { this.getResultLandingInfo(provenanceActionVocabulary);
this.getResultLandingInfo(null); }, err => {
this.handleError("Error getting provenance action vocabulary for " + this.type + " with id: " + this.id, err); this.getResultLandingInfo(null);
} this.handleError("Error getting provenance action vocabulary for " + this.type + " with id: " + this.id, err);
); }
);
} else {
this.getResultLandingInfo(null);
}
} }
@ -325,13 +331,15 @@ export class ResultLandingComponent {
}); });
} }
this.bioentitiesNum = bioentitiesNum; this.bioentitiesNum = bioentitiesNum;
if (this.resultLandingInfo.identifiers != undefined && this.resultLandingInfo.identifiers.has('doi')) { if(typeof document !== 'undefined') {
this.doi = this.resultLandingInfo.identifiers.get('doi')[0]; if (this.resultLandingInfo.identifiers != undefined && this.resultLandingInfo.identifiers.has('doi')) {
this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => { this.doi = this.resultLandingInfo.identifiers.get('doi')[0];
this.hasAltMetrics = hasAltMetrics; this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => {
}, error => { this.hasAltMetrics = hasAltMetrics;
this.hasAltMetrics = false; }, error => {
}); this.hasAltMetrics = false;
});
}
} }
this.showLoading = false; this.showLoading = false;
this.setActiveTab(); this.setActiveTab();

View File

@ -40,6 +40,7 @@ import {DatasourcesHelperClass} from "./searchUtils/datasourcesHelper.class";
[sort]="false"> [sort]="false">
</new-search-page> </new-search-page>
<!-- [filters]="filters"-->
` `
}) })
@ -129,6 +130,7 @@ export class SearchDataProvidersComponent {
// console.log(this.refineFields) // console.log(this.refineFields)
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "dataprovider"); this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "dataprovider");
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
firstLoad = false;
}); });
} }
ngOnDestroy() { ngOnDestroy() {
@ -167,7 +169,8 @@ export class SearchDataProvidersComponent {
this.results = data[1]; this.results = data[1];
//console.log(this.results); //console.log(this.results);
if (refine) { if (refine) {
this.filters = this.searchPage.prepareFiltersToShow((this.type=="all" || this.type == "deposit")?data[2]:this.filters, this.searchUtils.totalResults); this.filters =
this.searchPage.prepareFiltersToShow((this.type=="all" || this.type == "deposit")?data[2]:this.filters, this.searchUtils.totalResults);
}else{ }else{
this.searchPage.buildPageURLParameters(this.filters, [], false); this.searchPage.buildPageURLParameters(this.filters, [], false);
} }

View File

@ -121,7 +121,7 @@ public resourcesQuery = "(oaftype exact organization)";
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "organization"); this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap,this.customFilter,params, "organization");
this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad)); this.getResults(this.searchPage.getSearchAPIQueryForAdvancedSearhFields(), this.searchUtils.page, this.searchUtils.size, refine, this.searchPage.getSearchAPIQueryForRefineFields(params, firstLoad));
firstLoad = false;
}); });
} }
ngOnDestroy() { ngOnDestroy() {

View File

@ -50,13 +50,16 @@ export class NavigationBarComponent {
ngOnInit() { ngOnInit() {
this.activeRouteEnabled = false; this.activeRouteEnabled = false;
this.sub = this.route.queryParams.subscribe(params => { //this.sub = this.route.queryParams.subscribe(params => {
//console.log("params: ",params);
this.initialize(); this.initialize();
}); //});
} }
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); if(this.sub) {
this.sub.unsubscribe();
}
} }
initialize() { initialize() {

View File

@ -27,7 +27,11 @@ export class IFrameComponent {
this.style = { this.style = {
"width.px": this.width, "width.px": this.width,
"height.px": this.height "height.px": this.height
} };
} else if(this.height) {
this.style = {
"height.px": this.height
};
} }
} }
} }

View File

@ -58,7 +58,11 @@ export class SearchTabComponent {
} else if (entityType == "other") { } else if (entityType == "other") {
return (full ? ("other research product" + (plural ? "s" : "")) : "other"); return (full ? ("other research product" + (plural ? "s" : "")) : "other");
} else if (entityType == "result") { } else if (entityType == "result") {
return (full ? ("research outcome" + (plural ? "s" : "")) : "result"); return ((full ? "research outcome" : "result") + (plural ? "s" : ""));
} else if (entityType == "project") {
return "project" + (plural ? "s" : "");
} else if (entityType == "dataprovider") {
return ((full ? "content provider" : "dataprovider") + (plural ? "s" : ""));
} }
} }
} }