Revision 59469
Added by Konstantinos Triantafyllou over 3 years ago
modules/uoa-usage-statistics/trunk/src/app/entities/usage-stat.ts | ||
---|---|---|
1 | 1 |
export interface UsageStat { |
2 |
repositories: string;
|
|
3 |
total_downloads: string;
|
|
4 |
total_views: string;
|
|
2 |
repositories: any;
|
|
3 |
total_downloads: any;
|
|
4 |
total_views: any;
|
|
5 | 5 |
} |
6 | 6 |
|
7 | 7 |
export interface CountryUsageStat { |
8 | 8 |
country: string; |
9 |
views: string;
|
|
10 |
downloads:string;
|
|
11 |
total_repos: string;
|
|
9 |
views: any;
|
|
10 |
downloads:any;
|
|
11 |
total_repos: any;
|
|
12 | 12 |
} |
modules/uoa-usage-statistics/trunk/src/app/analytics/analytics.component.html | ||
---|---|---|
59 | 59 |
</div> |
60 | 60 |
<div *ngIf="display && !loading" class="uk-grid uk-child-width-1-3@m uk-child-width-1-2@s" |
61 | 61 |
uk-grid> |
62 |
<div *ngIf="display.total_repos && state > 0" [class.uk-animation-fade]="state == 1" |
|
63 |
class="uk-padding-remove-left"> |
|
62 |
<div *ngIf="display.total_repos && state > 0" [class.uk-animation-fade]="state == 1"> |
|
64 | 63 |
<div class="card"> |
65 | 64 |
<div class="uk-margin-medium-bottom"> |
66 | 65 |
Repositories |
67 | 66 |
</div> |
68 | 67 |
<h4> |
69 |
{{display.total_repos | number}}
|
|
68 |
{{display.total_repos.number | number}}{{(display.total_repos.size)?display.total_repos.size:""}}
|
|
70 | 69 |
</h4> |
71 | 70 |
<img src="../../assets/usage-statistics-assets/analytics/1.1.svg"> |
72 | 71 |
</div> |
... | ... | |
77 | 76 |
Repositories |
78 | 77 |
</div> |
79 | 78 |
<h4> |
80 |
{{display.repositories | number}}
|
|
79 |
{{display.repositories.number | number}}{{(display.repositories.size)?display.repositories.size:""}}
|
|
81 | 80 |
</h4> |
82 | 81 |
<img src="../../assets/usage-statistics-assets/analytics/1.1.svg"> |
83 | 82 |
</div> |
... | ... | |
88 | 87 |
Views |
89 | 88 |
</div> |
90 | 89 |
<h4> |
91 |
{{display.total_views | number}}
|
|
90 |
{{display.total_views.number | number}}{{(display.total_views.size)?display.total_views.size:""}}
|
|
92 | 91 |
</h4> |
93 | 92 |
<img src="../../assets/usage-statistics-assets/analytics/1.2.svg"> |
94 | 93 |
</div> |
... | ... | |
99 | 98 |
Views |
100 | 99 |
</div> |
101 | 100 |
<h4> |
102 |
{{display.views | number}}
|
|
101 |
{{display.views.number | number}}{{(display.views.size)?display.views.size:""}}
|
|
103 | 102 |
</h4> |
104 | 103 |
<img src="../../assets/usage-statistics-assets/analytics/1.2.svg"> |
105 | 104 |
</div> |
... | ... | |
110 | 109 |
Downloads |
111 | 110 |
</div> |
112 | 111 |
<h4> |
113 |
{{display.total_downloads | number}}
|
|
112 |
{{display.total_downloads.number | number}}{{(display.total_downloads.size)?display.total_downloads.size:""}}
|
|
114 | 113 |
</h4> |
115 | 114 |
<img src="../../assets/usage-statistics-assets/analytics/1.3.svg"> |
116 | 115 |
</div> |
... | ... | |
121 | 120 |
Downloads |
122 | 121 |
</div> |
123 | 122 |
<h4> |
124 |
{{display.downloads | number}}
|
|
123 |
{{display.downloads.number | number}}{{(display.downloads.size)?display.downloads.size:""}}
|
|
125 | 124 |
</h4> |
126 | 125 |
<img src="../../assets/usage-statistics-assets/analytics/1.3.svg"> |
127 | 126 |
</div> |
modules/uoa-usage-statistics/trunk/src/app/analytics/analytics.component.ts | ||
---|---|---|
8 | 8 |
import {DomSanitizer, SafeUrl, Title} from '@angular/platform-browser'; |
9 | 9 |
import {StringUtils} from '../openaireLibrary/utils/string-utils.class'; |
10 | 10 |
import {ActivatedRoute} from '@angular/router'; |
11 |
import {NumberUtils} from '../openaireLibrary/utils/number-utils.class'; |
|
11 | 12 |
|
12 | 13 |
@Component({ |
13 | 14 |
selector: 'analytics', |
... | ... | |
74 | 75 |
this.iframeLoading = false; |
75 | 76 |
} |
76 | 77 |
|
78 |
roundUsageStat(stats: UsageStat) { |
|
79 |
if(stats) { |
|
80 |
stats.repositories = NumberUtils.roundNumber(Number.parseInt(stats.repositories)); |
|
81 |
stats.total_downloads = NumberUtils.roundNumber(Number.parseInt(stats.total_downloads)); |
|
82 |
stats.total_views = NumberUtils.roundNumber(Number.parseInt(stats.total_views)); |
|
83 |
} |
|
84 |
return stats; |
|
85 |
} |
|
86 |
|
|
87 |
roundCountryUsageStat(stats: CountryUsageStat) { |
|
88 |
if(stats) { |
|
89 |
stats.total_repos = NumberUtils.roundNumber(Number.parseInt(stats.total_repos)); |
|
90 |
stats.downloads = NumberUtils.roundNumber(Number.parseInt(stats.downloads)); |
|
91 |
stats.views = NumberUtils.roundNumber(Number.parseInt(stats.views)); |
|
92 |
} |
|
93 |
return stats; |
|
94 |
} |
|
95 |
|
|
77 | 96 |
public search() { |
78 | 97 |
this.country = this.countryFb.value.country; |
79 | 98 |
this.showSearch = false; |
... | ... | |
82 | 101 |
if (this.country && this.country.length > 0) { |
83 | 102 |
this.country = StringUtils.capitalize(this.country); |
84 | 103 |
this.usageStatsService.getCountryMetrics(this.country).subscribe(stats => { |
85 |
this.display = stats;
|
|
104 |
this.display = this.roundCountryUsageStat(stats);
|
|
86 | 105 |
this.loading = false; |
87 | 106 |
if (this.display) { |
88 | 107 |
this.state = 1; |
... | ... | |
94 | 113 |
}); |
95 | 114 |
} else { |
96 | 115 |
this.usageStatsService.getAllMetrics().subscribe(stats => { |
97 |
this.display = stats;
|
|
116 |
this.display = this.roundUsageStat(stats);
|
|
98 | 117 |
this.loading = false; |
99 | 118 |
if (this.display) { |
100 | 119 |
this.state = 1; |
... | ... | |
156 | 175 |
goTo(id: string) { |
157 | 176 |
const yOffset = -100; |
158 | 177 |
const element = document.getElementById(id); |
159 |
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset; |
|
160 |
window.scrollTo({top: y, behavior: 'smooth'}); |
|
178 |
if(element) { |
|
179 |
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset; |
|
180 |
window.scrollTo({top: y, behavior: 'smooth'}); |
|
181 |
} |
|
161 | 182 |
} |
162 | 183 |
|
163 | 184 |
public getSafeUrl(url: string): SafeUrl { |
modules/uoa-usage-statistics/trunk/src/app/about/about.component.ts | ||
---|---|---|
27 | 27 |
goTo(id: string) { |
28 | 28 |
const yOffset = -100; |
29 | 29 |
const element = document.getElementById(id); |
30 |
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset; |
|
31 |
window.scrollTo({top: y, behavior: 'smooth'}); |
|
30 |
if(element) { |
|
31 |
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset; |
|
32 |
window.scrollTo({top: y, behavior: 'smooth'}); |
|
33 |
} |
|
32 | 34 |
} |
33 | 35 |
} |
modules/uoa-usage-statistics/trunk/src/app/resources/resources.component.ts | ||
---|---|---|
25 | 25 |
goTo(id: string) { |
26 | 26 |
const yOffset = -100; |
27 | 27 |
const element = document.getElementById(id); |
28 |
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset; |
|
29 |
window.scrollTo({top: y, behavior: 'smooth'}); |
|
28 |
if(element) { |
|
29 |
const y = element.getBoundingClientRect().top + window.pageYOffset + yOffset; |
|
30 |
window.scrollTo({top: y, behavior: 'smooth'}); |
|
31 |
} |
|
30 | 32 |
} |
31 | 33 |
} |
Also available in: Unified diff
[Usage Counts | Trunk]: Round numbers on analytics. Fix error when a fragment does not exist