openaire-library/landingPages/landing-utils/metrics/metrics.component.ts

332 lines
15 KiB
TypeScript
Raw Normal View History

import {Component, Input, Output, EventEmitter, ChangeDetectorRef} from '@angular/core';
import {Metrics} from '../../../utils/entities/metrics';
import {MetricsService} from '../../../services/metrics.service';
import {ErrorCodes} from '../../../utils/properties/errorCodes';
import {Subscription, zip} from 'rxjs';
import {EnvProperties} from '../../../utils/properties/env-properties';
[Library & common-assets | new-theme]: Updates for redesign. 1. availableOn.component.ts: Updated class of title to "uk-text-light-grey" and added custom-external icon to links and updated accessright icons. 2. citation.class.ts: Added fileFormatOptions: Option[] to use it in input options. 3. citeThis.component.ts: Updated select inputs using "input" from InputComponent | Updated copy to clipboard button to link. 4. citeThis.module.ts: Import InputModule. 5. fos.component.ts: Updated class of title to "uk-text-light-grey". 6. fundedBy.component.ts: Updated class of title to "uk-text-light-grey" and updated links with uk-text-emphasis class. 7. landing-header.component.ts: Increase authorsLimit to 7 | Changed class of "under curation" to uk-text-primary (used to be custom class). 8. metrics.component.ts: Updated in clickOutside event. parsingFunctions.class.ts: Updated open, closed and unknown with icon names instead of paths to svgs (download accessright icons). 9. relatedTo.component.ts: Updated class of title to "uk-text-light-grey" and added custom-external for links. 10. resultLandingUtils.module.ts: Inport AlertModalModule (to open modal). 11. sdg.component.ts: Updated class of titlte to "uk-text-light-grey". 12. showIdentifiers.component.ts: Added view more functionality. 13. showPublisher.component.ts: Updated custon-external class. 14. resultLanding.module.ts: registerIcon link. 15. resultLanding.component.html: Updated css for result landing and commented annotations (b2note). 16. orcid-work.component.ts: Updated orcid action button for landing page. 17. orcid.module.ts: registerIcons orcid_add and orcid_bin. 18. customOptions.class.ts: [Bug fix] [By Kostis] registryOptions() was not returning properly httpHeaders. 19. showAuthors.component.ts: Updated css 20. icons.ts: Export svgs orcid_add, orcid_bin, link. 21. alert.ts: Removed margin from title. 22. result-preview.component.html: Title of results set to <h2> and uk-h6 and when links to uk-link-heading | accessRightIcon for hostedBy_collectedFrom. 23. result-preview.module.ts: Imported IconsModule. 24. landing-utils.css: Updates in landing css & css of landing-action-button & added backdrop filter missing rules. 25. utils.css: Updated class orcid-clipboard-wrapper and renamed to clipboad-wrapper | Update class .custom-external to set in content with code instead of name and updated not to underline it on hover 26. library.css: Added class .default-dropdown with max-width: 500px;
2022-04-16 09:47:30 +02:00
import {ClickEvent} from "../../../utils/click/click-outside-or-esc.directive";
import {NumberUtils} from "../../../utils/number-utils.class";
import {OpenaireEntities} from "../../../utils/properties/searchFields";
import {StringUtils} from "../../../utils/string-utils.class";
import {properties} from "../../../../../environments/environment";
import {RouterHelper} from "../../../utils/routerHelper.class";
@Component({
selector: 'metrics',
template: `
<div *ngIf="metrics && (pageViews >0 || metrics.totalViews > 0|| metrics.totalDownloads >0)" class="metrics">
[Library | new-theme]: Redesign of project landing page and small upadates on result landing and common components. 1. addThis.component.ts: Updated social icons of addThis. 2. landing-header.component.ts: Added "uk-text-small" in subtitle. 3. metrics.component.ts: Added method "clickedMetrics()" to set "metricsClicked" | Added metricsClicked and metrics.infos conditions for loading table or iframes | Added customContainerClass and customIframeClass in <i-frame>. 4. project.component: Updated project landing page according to UI redesign. 5. project.module.ts: Import LoadingModule, IconsModule, InputModule. 6. project.service.ts: Use parsingFunctions.parseDescription. 7. projectService.module.ts: iconsService.registerIcons([link, graph]). 8. resultLanding.component.html: Small fixes in ui | Added right arrow on tooltips of actions that are links to other pages | Display of description updated as innerHtml (#7345). 9. orcid-work.component.ts: Added flex=true in <icon>. 10. input.component.ts: Added disabled?: boolean in Option interface and show disabled options as muted. 11. projectInfo.ts: Updated description to be string[] instead of string. 12. iframe.component.ts: Added @Input() customContainerClass: string = ""; and @Input() customIframeClass: string = ""; 13. search-tab.component.ts: Updated according to redesign | Update "getEntityName()" to return values from OpenaireEntities. 14. tabs.component.ts: Added "uk-height-1-1" in custom tabs | In #mytabs::before set left:0.
2022-04-28 11:13:06 +02:00
<a class="m-badge uk-link-reset uk-display-block" (click)="clickedMetrics()">
<img src="assets/common-assets/logo-small-usage-counts.png" loading="lazy" alt="usage counts">
<div class="uk-margin-xsmall-top uk-text-primary uk-text-small uk-text-bold uk-text-center">
<ng-container *ngIf="isNumberLarge(total, true); else notFormattedTotal">{{formatNumber(total)}}</ng-container>
<ng-template #notFormattedTotal>{{total | number}}</ng-template>
</div>
2022-04-19 12:58:10 +02:00
</a>
<div class="uk-dropdown uk-background-default" uk-dropdown="pos: right-top; mode: click; offset: 30; animation: uk-animation-fade">
<div class="uk-padding-small uk-width-large@s uk-width-medium">
2022-04-19 12:58:10 +02:00
<div *ngIf="entityType == 'projects'" class="uk-alert uk-alert-primary uk-margin-small-bottom">
<span class="uk-text-center uk-text-small">{{openaireEntities.PROJECT}} metrics
are derived from aggregating individual {{openaireEntities.RESULTS}} metrics.
2022-04-19 12:58:10 +02:00
</span>
</div>
<div class="uk-child-width-1-3@m uk-grid-small uk-grid-divider uk-margin-top" uk-grid>
<div class="uk-text-center">
<div class="number uk-text-bold uk-text-background">
<ng-container *ngIf="metrics.totalDownloads == 0">-</ng-container>
<span *ngIf="metrics.totalDownloads > 0" [attr.uk-tooltip]="metrics.totalDownloads >= 1000 ? 'cls: uk-active' : 'cls: uk-invisible'"
title="{{metrics.totalDownloads | number}}">{{formatNumber(metrics.totalDownloads)}}</span>
<!-- <ng-container *ngIf="isNumberLarge(metrics.totalDownloads); else notFormattedDownloads">{{formatNumber(metrics.totalDownloads)}}</ng-container>-->
<!-- <ng-template #notFormattedDownloads>{{metrics.totalDownloads | number}}</ng-template>-->
</div>
2022-04-19 12:58:10 +02:00
<div>Downloads</div>
</div>
2022-04-19 12:58:10 +02:00
<div class="uk-text-center">
<div class="number uk-text-bold uk-text-background">
<ng-container *ngIf="pageViews == 0">-</ng-container>
<span *ngIf="pageViews > 0" [attr.uk-tooltip]="pageViews >= 1000 ? 'cls: uk-active' : 'cls: uk-invisible'"
title="{{pageViews | number}}">{{formatNumber(pageViews)}}</span>
<!-- <ng-container *ngIf="isNumberLarge(pageViews); else notFormattedPageviews">{{formatNumber(pageViews)}}</ng-container>-->
<!-- <ng-template #notFormattedPageviews>{{pageViews | number}}</ng-template>-->
</div>
2022-04-19 12:58:10 +02:00
<div>OpenAIRE views</div>
</div>
2022-04-19 12:58:10 +02:00
<div class="uk-text-center">
<div class="number uk-text-bold uk-text-background">
<ng-container *ngIf="metrics.totalViews == 0">-</ng-container>
<span *ngIf="metrics.totalViews > 0" [attr.uk-tooltip]="metrics.totalViews >= 1000 ? 'cls: uk-active' : 'cls: uk-invisible'"
title="{{metrics.totalViews | number}}">{{formatNumber(metrics.totalViews)}}</span>
<!-- <ng-container *ngIf="isNumberLarge(metrics.totalViews); else notFormattedTotalviews">{{formatNumber(metrics.totalViews)}}</ng-container>-->
<!-- <ng-template #notFormattedTotalviews>{{metrics.totalViews | number}}</ng-template> -->
</div>
2022-04-19 12:58:10 +02:00
<div>Total views</div>
</div>
</div>
<div class="uk-padding">
[Library | new-theme]: Redesign of project landing page and small upadates on result landing and common components. 1. addThis.component.ts: Updated social icons of addThis. 2. landing-header.component.ts: Added "uk-text-small" in subtitle. 3. metrics.component.ts: Added method "clickedMetrics()" to set "metricsClicked" | Added metricsClicked and metrics.infos conditions for loading table or iframes | Added customContainerClass and customIframeClass in <i-frame>. 4. project.component: Updated project landing page according to UI redesign. 5. project.module.ts: Import LoadingModule, IconsModule, InputModule. 6. project.service.ts: Use parsingFunctions.parseDescription. 7. projectService.module.ts: iconsService.registerIcons([link, graph]). 8. resultLanding.component.html: Small fixes in ui | Added right arrow on tooltips of actions that are links to other pages | Display of description updated as innerHtml (#7345). 9. orcid-work.component.ts: Added flex=true in <icon>. 10. input.component.ts: Added disabled?: boolean in Option interface and show disabled options as muted. 11. projectInfo.ts: Updated description to be string[] instead of string. 12. iframe.component.ts: Added @Input() customContainerClass: string = ""; and @Input() customIframeClass: string = ""; 13. search-tab.component.ts: Updated according to redesign | Update "getEntityName()" to return values from OpenaireEntities. 14. tabs.component.ts: Added "uk-height-1-1" in custom tabs | In #mytabs::before set left:0.
2022-04-28 11:13:06 +02:00
<div *ngIf="metricsClicked && (metrics.infos?.size > 0 || (metrics.totalViews > 0 && viewsFrameUrl) || (metrics.totalDownloads > 0 && downloadsFrameUrl))"
2022-04-19 12:58:10 +02:00
class="uk-position-relative uk-visible-toggle uk-slider uk-margin-small-top" tabIndex="1" uk-slider>
<div class="uk-slider-container">
<ul class="uk-slider-items uk-child-width-1-1">
<li *ngIf="metrics && metrics.infos.size > 0" class="uk-overflow-auto" style="height: 200px">
<table
class="uk-table uk-table-small uk-table-striped">
<thead>
<tr>
<th class="uk-text-center uk-text-bold">From</th>
<th class="uk-text-center uk-text-bold">Views</th>
<th class="uk-text-center uk-text-bold">Downloads</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let key of getKeys(metrics.infos)">
<td class="uk-width-1-3 uk-text-center uk-text-truncate" uk-tooltip [title]="metrics.infos.get(key).name">
<a [queryParams]="addEoscPrevInParams({datasourceId: metrics.infos.get(key).url})" [routerLink]="properties.searchLinkToDataProvider.split('?')[0]">
2022-04-19 12:58:10 +02:00
{{metrics.infos.get(key).name}}
</a>
</td>
<td class="uk-text-center">
<ng-container *ngIf="isNumberLarge(metrics.infos.get(key).numOfViews, true); else notFormattedNumViews">{{formatNumber(metrics.infos.get(key).numOfViews)}}</ng-container>
<ng-template #notFormattedNumViews>{{metrics.infos.get(key).numOfViews | number}}</ng-template>
2022-04-19 12:58:10 +02:00
<!-- <span *ngIf="metrics.infos.get(key).numOfViews > 0 && metrics.infos.get(key).openaireViews > 0">
( {{metrics.infos.get(key).openaireViews | number}} from OpenAIRE )
</span>-->
</td>
<td class="uk-text-center">
<ng-container *ngIf="isNumberLarge(metrics.infos.get(key).numOfDownloads, true); else notFormattedNumDownloads">{{formatNumber(metrics.infos.get(key).numOfDownloads)}}</ng-container>
<ng-template #notFormattedNumDownloads>{{metrics.infos.get(key).numOfDownloads | number}}</ng-template>
2022-04-19 12:58:10 +02:00
<!--<span *ngIf="metrics.infos.get(key).numOfDownloads > 0 && metrics.infos.get(key).openaireDownloads > 0">
( {{metrics.infos.get(key).openaireDownloads | number}} from OpenAIRE )
</span>-->
</td>
</tr>
</tbody>
</table>
</li>
<!-- remove check for datasources when with the new charts -->
<li *ngIf="metricsClicked && metrics.totalViews > 0 && viewsFrameUrl">
[Library | new-theme]: Redesign of project landing page and small upadates on result landing and common components. 1. addThis.component.ts: Updated social icons of addThis. 2. landing-header.component.ts: Added "uk-text-small" in subtitle. 3. metrics.component.ts: Added method "clickedMetrics()" to set "metricsClicked" | Added metricsClicked and metrics.infos conditions for loading table or iframes | Added customContainerClass and customIframeClass in <i-frame>. 4. project.component: Updated project landing page according to UI redesign. 5. project.module.ts: Import LoadingModule, IconsModule, InputModule. 6. project.service.ts: Use parsingFunctions.parseDescription. 7. projectService.module.ts: iconsService.registerIcons([link, graph]). 8. resultLanding.component.html: Small fixes in ui | Added right arrow on tooltips of actions that are links to other pages | Display of description updated as innerHtml (#7345). 9. orcid-work.component.ts: Added flex=true in <icon>. 10. input.component.ts: Added disabled?: boolean in Option interface and show disabled options as muted. 11. projectInfo.ts: Updated description to be string[] instead of string. 12. iframe.component.ts: Added @Input() customContainerClass: string = ""; and @Input() customIframeClass: string = ""; 13. search-tab.component.ts: Updated according to redesign | Update "getEntityName()" to return values from OpenaireEntities. 14. tabs.component.ts: Added "uk-height-1-1" in custom tabs | In #mytabs::before set left:0.
2022-04-28 11:13:06 +02:00
<i-frame [height]="200" [url]=viewsFrameUrl [addClass]="false"
customContainerClass="uk-background-default" customIframeClass="uk-blend-multiply"></i-frame>
2022-04-19 12:58:10 +02:00
</li>
<li *ngIf="metricsClicked && metrics.totalDownloads > 0 && downloadsFrameUrl">
[Library | new-theme]: Redesign of project landing page and small upadates on result landing and common components. 1. addThis.component.ts: Updated social icons of addThis. 2. landing-header.component.ts: Added "uk-text-small" in subtitle. 3. metrics.component.ts: Added method "clickedMetrics()" to set "metricsClicked" | Added metricsClicked and metrics.infos conditions for loading table or iframes | Added customContainerClass and customIframeClass in <i-frame>. 4. project.component: Updated project landing page according to UI redesign. 5. project.module.ts: Import LoadingModule, IconsModule, InputModule. 6. project.service.ts: Use parsingFunctions.parseDescription. 7. projectService.module.ts: iconsService.registerIcons([link, graph]). 8. resultLanding.component.html: Small fixes in ui | Added right arrow on tooltips of actions that are links to other pages | Display of description updated as innerHtml (#7345). 9. orcid-work.component.ts: Added flex=true in <icon>. 10. input.component.ts: Added disabled?: boolean in Option interface and show disabled options as muted. 11. projectInfo.ts: Updated description to be string[] instead of string. 12. iframe.component.ts: Added @Input() customContainerClass: string = ""; and @Input() customIframeClass: string = ""; 13. search-tab.component.ts: Updated according to redesign | Update "getEntityName()" to return values from OpenaireEntities. 14. tabs.component.ts: Added "uk-height-1-1" in custom tabs | In #mytabs::before set left:0.
2022-04-28 11:13:06 +02:00
<i-frame [height]="200" [url]=downloadsFrameUrl [addClass]="false"
customContainerClass="uk-background-default" customIframeClass="uk-blend-multiply"></i-frame>
2022-04-19 12:58:10 +02:00
</li>
</ul>
</div>
2022-04-19 12:58:10 +02:00
<a class="uk-position-center-left-out" uk-slider-item="previous"><span uk-icon="icon: chevron-left; ratio: 2"></span></a>
<a class="uk-position-center-right-out" uk-slider-item="next"><span uk-icon="icon: chevron-right; ratio: 2"></span></a>
</div>
</div>
2022-04-19 12:58:10 +02:00
<div class="uk-flex uk-flex-center uk-flex-middle">
<span class="uk-margin-small-right uk-text-small uk-text-meta">Powered by</span>
2022-04-19 12:58:10 +02:00
<a href="https://usagecounts.openaire.eu" target="_blank">
<img width="120" src="assets/common-assets/logo-large-usage-counts.png" loading="lazy" alt="usage counts">
</a>
</div>
</div>
</div>
</div>
`,
styleUrls: ['metrics.component.less']
})
export class MetricsComponent {
[Library | develop & Eosc Explore | develop]: Added font-family "Inter" to align with Marketplace | Updated how back button "Go to search" is build - combine referrer and the new url parameter "pv", which is expected to have the previous url path and params. 1. /assets: Added /media/fonts/inter folder with the "Inter" font-family. 2. eosc-custom.less: Override the default font family to use 'Inter', sans-serif. 3. routerHelper.class.ts: Added method "addQueryParam()" to add a query parameter in already existing or not object with parameters. 4. search-tab.component.ts & searchResult.component & projects-in-modal.component.ts & result/deletedByInference/deletedByInference.component.ts & organization/deletedByInference/deletedByInference.component.ts: Added @Input() prevPath: string = ""; and pass it to the appropriate children components. 5. result-preview.component & fundedBy.component.ts & availableOn.component.ts & relatedDatasourcesTab.component.ts: Added @Input() prevPath: string = ""; and method "addEoscPrevInParams()" and call it when building queryParams of internal links. 6. metrics.component.ts: Added @Input() prevPath: string = ""; and use it when building internal urls. 7. resultLanding.component.ts & project.component.ts & organization.component.ts & dataProvider.component.ts: a. Added fields public referrer: string; and public prevPath: string; b. Read "pv" url property and get referrer. c. Added methods "addEoscPrevInParams()" and "eoscBackLink()". 8. resultLanding.component.html & project.component.html & organization.component.html & dataProvider.component.html: a. Update "Go to Search" back link. b. Call "addEoscPrevInParams()" method when building queryParams of internal links. c. Pass "prevPath" to the appropriate children components.
2023-04-20 19:06:53 +02:00
@Input() prevPath: string = "";
@Output() metricsResults = new EventEmitter();
@Input() id: string;
@Input() entityType: string;
@Input() entity: string;
//@Input() name: string = "";
@Input() pageViews: number = 0;
@Input() properties: EnvProperties;
@Input() shortView: boolean = false;
@Input() open = false;
@Input() viewsFrameUrl: string;
@Input() downloadsFrameUrl: string;
public metrics: Metrics;
public errorCodes: ErrorCodes;
private sub: Subscription;
private timeouts: any[] = [];
[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
2020-06-10 13:05:59 +02:00
public metricsClicked: boolean = false;
[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
2020-06-10 13:05:59 +02:00
public status: number;
public state: number = -1;
public openaireEntities = OpenaireEntities;
public routerHelper:RouterHelper = new RouterHelper();
constructor(private metricsService: MetricsService, private cdr: ChangeDetectorRef) {
}
ngOnInit() {
this.errorCodes = new ErrorCodes();
[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
2020-06-10 13:05:59 +02:00
if (typeof document !== 'undefined') {
this.status = this.errorCodes.LOADING;
this.getMetrics();
}
}
ngOnDestroy() {
[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
2020-06-10 13:05:59 +02:00
if(this.sub) {
this.sub.unsubscribe();
}
}
public get total(): number {
return +this.pageViews + +this.metrics.totalViews + +this.metrics.totalDownloads;
}
private getMetrics() {
//queries from old API - replaced with queries to the stats tool
/* this.sub = this.metricsService.getMetrics(this.id, this.entityType, this.properties).subscribe(
data => {
this.metrics = data;
this.cdr.detectChanges();
this.status = this.errorCodes.DONE;
this.metricsResults.emit({
totalViews: this.metrics.totalViews,
totalDownloads: this.metrics.totalDownloads,
pageViews: this.metrics.pageViews
});
},
err => {
if (err.status == '404') {
this.status = this.errorCodes.NOT_FOUND;
} else if (err.status == '500') {
this.status = this.errorCodes.ERROR;
} else {
this.status = this.errorCodes.NOT_AVAILABLE;
}
this.metricsResults.emit({
totalViews: 0,
totalDownloads: 0
});
}
);*/
let obs;
if (this.entityType == "results") {
obs = zip(this.metricsService.getMetricsNumber(this.id, "usagestats.results.views", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.results.downloads", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.results.views.openaire", this.properties),
this.metricsService.getMetricsNumbersByRepository(this.id, "usagestats.results.viewsdownloads.repository", this.properties)
);
} else if (this.entityType == "projects") {
obs = zip(this.metricsService.getMetricsNumber(this.id, "usagestats.projects.views", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.projects.downloads", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.projects.views.openaire", this.properties));
} else if (this.entityType == "datasources") {
obs = zip(this.metricsService.getMetricsNumber(this.id, "usagestats.views.repository.local", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.downloads.repository.local", this.properties),
this.metricsService.getMetricsNumber(this.id, "usagestats.views.openaire", this.properties),
// this.metricsService.getMetricsNumber(this.id, "usagestats.downloads.repository.openaire", this.properties)
);
}
this.sub = obs.subscribe(
data => {
this.metrics = new Metrics();
this.metrics.infos = new Map<string, { "name": string, "url": string, "numOfDownloads": string, "numOfViews": string, "openaireDownloads": string, "openaireViews": string }>();
this.metrics.totalViews = data[0] ? data[0] : 0;
this.metrics.totalDownloads = data[1] ? data[1] : 0;
this.metrics.pageViews = data[2] ? data[2] : 0;
this.metrics.infos = data[3] ? data[3] : 0;
this.cdr.detectChanges();
this.status = this.errorCodes.DONE;
this.metricsResults.emit({
totalViews: this.metrics.totalViews,
totalDownloads: this.metrics.totalDownloads,
pageViews: this.metrics.pageViews
});
},
err => {
if (err.status == '404') {
this.status = this.errorCodes.NOT_FOUND;
} else if (err.status == '500') {
this.status = this.errorCodes.ERROR;
} else {
this.status = this.errorCodes.NOT_AVAILABLE;
}
this.metricsResults.emit({
totalViews: 0,
totalDownloads: 0,
pageViews: 0
});
}
);
}
[Library & common-assets | new-theme]: Updates for redesign. 1. availableOn.component.ts: Updated class of title to "uk-text-light-grey" and added custom-external icon to links and updated accessright icons. 2. citation.class.ts: Added fileFormatOptions: Option[] to use it in input options. 3. citeThis.component.ts: Updated select inputs using "input" from InputComponent | Updated copy to clipboard button to link. 4. citeThis.module.ts: Import InputModule. 5. fos.component.ts: Updated class of title to "uk-text-light-grey". 6. fundedBy.component.ts: Updated class of title to "uk-text-light-grey" and updated links with uk-text-emphasis class. 7. landing-header.component.ts: Increase authorsLimit to 7 | Changed class of "under curation" to uk-text-primary (used to be custom class). 8. metrics.component.ts: Updated in clickOutside event. parsingFunctions.class.ts: Updated open, closed and unknown with icon names instead of paths to svgs (download accessright icons). 9. relatedTo.component.ts: Updated class of title to "uk-text-light-grey" and added custom-external for links. 10. resultLandingUtils.module.ts: Inport AlertModalModule (to open modal). 11. sdg.component.ts: Updated class of titlte to "uk-text-light-grey". 12. showIdentifiers.component.ts: Added view more functionality. 13. showPublisher.component.ts: Updated custon-external class. 14. resultLanding.module.ts: registerIcon link. 15. resultLanding.component.html: Updated css for result landing and commented annotations (b2note). 16. orcid-work.component.ts: Updated orcid action button for landing page. 17. orcid.module.ts: registerIcons orcid_add and orcid_bin. 18. customOptions.class.ts: [Bug fix] [By Kostis] registryOptions() was not returning properly httpHeaders. 19. showAuthors.component.ts: Updated css 20. icons.ts: Export svgs orcid_add, orcid_bin, link. 21. alert.ts: Removed margin from title. 22. result-preview.component.html: Title of results set to <h2> and uk-h6 and when links to uk-link-heading | accessRightIcon for hostedBy_collectedFrom. 23. result-preview.module.ts: Imported IconsModule. 24. landing-utils.css: Updates in landing css & css of landing-action-button & added backdrop filter missing rules. 25. utils.css: Updated class orcid-clipboard-wrapper and renamed to clipboad-wrapper | Update class .custom-external to set in content with code instead of name and updated not to underline it on hover 26. library.css: Added class .default-dropdown with max-width: 500px;
2022-04-16 09:47:30 +02:00
public close(event: ClickEvent) {
if(event.clicked && this.state !== -1) {
this.timeouts.forEach(timeout => {
clearTimeout(timeout);
});
this.state = -1;
this.timeouts = [];
}
}
[Library | new-theme]: Redesign of project landing page and small upadates on result landing and common components. 1. addThis.component.ts: Updated social icons of addThis. 2. landing-header.component.ts: Added "uk-text-small" in subtitle. 3. metrics.component.ts: Added method "clickedMetrics()" to set "metricsClicked" | Added metricsClicked and metrics.infos conditions for loading table or iframes | Added customContainerClass and customIframeClass in <i-frame>. 4. project.component: Updated project landing page according to UI redesign. 5. project.module.ts: Import LoadingModule, IconsModule, InputModule. 6. project.service.ts: Use parsingFunctions.parseDescription. 7. projectService.module.ts: iconsService.registerIcons([link, graph]). 8. resultLanding.component.html: Small fixes in ui | Added right arrow on tooltips of actions that are links to other pages | Display of description updated as innerHtml (#7345). 9. orcid-work.component.ts: Added flex=true in <icon>. 10. input.component.ts: Added disabled?: boolean in Option interface and show disabled options as muted. 11. projectInfo.ts: Updated description to be string[] instead of string. 12. iframe.component.ts: Added @Input() customContainerClass: string = ""; and @Input() customIframeClass: string = ""; 13. search-tab.component.ts: Updated according to redesign | Update "getEntityName()" to return values from OpenaireEntities. 14. tabs.component.ts: Added "uk-height-1-1" in custom tabs | In #mytabs::before set left:0.
2022-04-28 11:13:06 +02:00
public clickedMetrics() {
setTimeout( () => {
this.metricsClicked = true;
});
}
public toggle(event) {
[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
2020-06-10 13:05:59 +02:00
this.metricsClicked = true;
event.stopPropagation();
if(this.state !== -1) {
this.timeouts.forEach(timeout => {
clearTimeout(timeout);
});
this.state = -1;
this.timeouts = [];
} else {
this.state++;
this.timeouts.push(setTimeout(() => {
this.state++;
this.timeouts.push(setTimeout(() => {
this.state++;
this.timeouts.push(setTimeout(() => {
this.state++;
this.timeouts.push(setTimeout(() => {
this.state++;
}, 400));
}, 800));
}, 300));
}, 100));
}
this.cdr.detectChanges();
}
public getKeys(map) {
return Array.from(map.keys());
}
public isNumberLarge(num: number | string, bigNum: boolean = false) {
let limit: number = bigNum ? 100000000 : 100000;
return (+num) >= limit;
}
public formatNumber(num: number | string) {
let formatted = NumberUtils.roundNumber(+num);
return formatted.number + formatted.size;
}
public addEoscPrevInParams(obj) {
if(properties.adminToolsPortalType == "eosc" && this.prevPath) {
let splitted: string[] = this.prevPath.split("?");
obj = this.routerHelper.addQueryParam("return_path", splitted[0], obj);
if(splitted.length > 0) {
obj = this.routerHelper.addQueryParam("search_params", splitted[1], obj);
}
}
return obj;
}
}