diff --git a/src/app/about/about.component.ts b/src/app/about/about.component.ts
index d8561cd..c9ed7bd 100644
--- a/src/app/about/about.component.ts
+++ b/src/app/about/about.component.ts
@@ -27,7 +27,9 @@ export class AboutComponent implements OnInit {
goTo(id: string) {
const yOffset = -100;
const element = document.getElementById(id);
- const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
- window.scrollTo({top: y, behavior: 'smooth'});
+ if(element) {
+ const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
+ window.scrollTo({top: y, behavior: 'smooth'});
+ }
}
}
diff --git a/src/app/analytics/analytics.component.html b/src/app/analytics/analytics.component.html
index 990275b..7153f09 100644
--- a/src/app/analytics/analytics.component.html
+++ b/src/app/analytics/analytics.component.html
@@ -59,14 +59,13 @@
-
0" [class.uk-animation-fade]="state == 1"
- class="uk-padding-remove-left">
+
0" [class.uk-animation-fade]="state == 1">
Repositories
- {{display.total_repos | number}}
+ {{display.total_repos.number | number}}{{(display.total_repos.size)?display.total_repos.size:""}}
@@ -77,7 +76,7 @@
Repositories
- {{display.repositories | number}}
+ {{display.repositories.number | number}}{{(display.repositories.size)?display.repositories.size:""}}
@@ -88,7 +87,7 @@
Views
- {{display.total_views | number}}
+ {{display.total_views.number | number}}{{(display.total_views.size)?display.total_views.size:""}}
@@ -99,7 +98,7 @@
Views
- {{display.views | number}}
+ {{display.views.number | number}}{{(display.views.size)?display.views.size:""}}
@@ -110,7 +109,7 @@
Downloads
- {{display.total_downloads | number}}
+ {{display.total_downloads.number | number}}{{(display.total_downloads.size)?display.total_downloads.size:""}}
@@ -121,7 +120,7 @@
Downloads
- {{display.downloads | number}}
+ {{display.downloads.number | number}}{{(display.downloads.size)?display.downloads.size:""}}
diff --git a/src/app/analytics/analytics.component.ts b/src/app/analytics/analytics.component.ts
index 9eb0a07..ca865b9 100644
--- a/src/app/analytics/analytics.component.ts
+++ b/src/app/analytics/analytics.component.ts
@@ -8,6 +8,7 @@ import {countries} from '../services/countries';
import {DomSanitizer, SafeUrl, Title} from '@angular/platform-browser';
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
import {ActivatedRoute} from '@angular/router';
+import {NumberUtils} from '../openaireLibrary/utils/number-utils.class';
@Component({
selector: 'analytics',
@@ -74,6 +75,24 @@ export class AnalyticsComponent implements OnInit {
this.iframeLoading = false;
}
+ roundUsageStat(stats: UsageStat) {
+ if(stats) {
+ stats.repositories = NumberUtils.roundNumber(Number.parseInt(stats.repositories));
+ stats.total_downloads = NumberUtils.roundNumber(Number.parseInt(stats.total_downloads));
+ stats.total_views = NumberUtils.roundNumber(Number.parseInt(stats.total_views));
+ }
+ return stats;
+ }
+
+ roundCountryUsageStat(stats: CountryUsageStat) {
+ if(stats) {
+ stats.total_repos = NumberUtils.roundNumber(Number.parseInt(stats.total_repos));
+ stats.downloads = NumberUtils.roundNumber(Number.parseInt(stats.downloads));
+ stats.views = NumberUtils.roundNumber(Number.parseInt(stats.views));
+ }
+ return stats;
+ }
+
public search() {
this.country = this.countryFb.value.country;
this.showSearch = false;
@@ -82,7 +101,7 @@ export class AnalyticsComponent implements OnInit {
if (this.country && this.country.length > 0) {
this.country = StringUtils.capitalize(this.country);
this.usageStatsService.getCountryMetrics(this.country).subscribe(stats => {
- this.display = stats;
+ this.display = this.roundCountryUsageStat(stats);
this.loading = false;
if (this.display) {
this.state = 1;
@@ -94,7 +113,7 @@ export class AnalyticsComponent implements OnInit {
});
} else {
this.usageStatsService.getAllMetrics().subscribe(stats => {
- this.display = stats;
+ this.display = this.roundUsageStat(stats);
this.loading = false;
if (this.display) {
this.state = 1;
@@ -156,8 +175,10 @@ export class AnalyticsComponent implements OnInit {
goTo(id: string) {
const yOffset = -100;
const element = document.getElementById(id);
- const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
- window.scrollTo({top: y, behavior: 'smooth'});
+ if(element) {
+ const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
+ window.scrollTo({top: y, behavior: 'smooth'});
+ }
}
public getSafeUrl(url: string): SafeUrl {
diff --git a/src/app/entities/usage-stat.ts b/src/app/entities/usage-stat.ts
index ec94c42..0c0d768 100644
--- a/src/app/entities/usage-stat.ts
+++ b/src/app/entities/usage-stat.ts
@@ -1,12 +1,12 @@
export interface UsageStat {
- repositories: string;
- total_downloads: string;
- total_views: string;
+ repositories: any;
+ total_downloads: any;
+ total_views: any;
}
export interface CountryUsageStat {
country: string;
- views: string;
- downloads:string;
- total_repos: string;
+ views: any;
+ downloads:any;
+ total_repos: any;
}
diff --git a/src/app/resources/resources.component.ts b/src/app/resources/resources.component.ts
index debd11f..16f680d 100644
--- a/src/app/resources/resources.component.ts
+++ b/src/app/resources/resources.component.ts
@@ -25,7 +25,9 @@ export class ResourcesComponent implements OnInit {
goTo(id: string) {
const yOffset = -100;
const element = document.getElementById(id);
- const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
- window.scrollTo({top: y, behavior: 'smooth'});
+ if(element) {
+ const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset;
+ window.scrollTo({top: y, behavior: 'smooth'});
+ }
}
}