Revision 60209
Added by Konstantinos Triantafyllou over 3 years ago
modules/uoa-usage-statistics/trunk/src/app/analytics/analytics.component.css | ||
---|---|---|
36 | 36 |
color: var(--portal-dark-color); |
37 | 37 |
} |
38 | 38 |
|
39 |
.countries input, .countries input:focus { |
|
40 |
background: transparent 0 0 no-repeat padding-box; |
|
41 |
border-radius: 4px; |
|
42 |
padding: 15px; |
|
43 |
border: none; |
|
44 |
outline: none; |
|
45 |
} |
|
46 |
|
|
47 |
.countries input::placeholder { |
|
48 |
color: #a3a3a3; |
|
49 |
font-weight: 600; |
|
50 |
} |
|
51 |
|
|
52 |
@media only screen and (max-width: 980px) { |
|
53 |
.countries input { |
|
54 |
font-size: 14px; |
|
55 |
} |
|
56 |
|
|
57 |
.countries .search-mobile { |
|
58 |
padding-bottom: 5px; |
|
59 |
border-bottom: 2px solid var(--portal-main-color); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
button.search, button.search:hover { |
|
64 |
color: #333333; |
|
65 |
font-weight: 700; |
|
66 |
border: none; |
|
67 |
outline: none; |
|
68 |
background-color: transparent; |
|
69 |
font-family: "Roboto", sans-serif; |
|
70 |
font-size: 16px; |
|
71 |
} |
|
72 |
|
|
73 |
button.search:hover { |
|
74 |
color: var(--portal-main-color); |
|
75 |
} |
|
76 |
|
|
77 | 39 |
.card { |
78 | 40 |
background: #FFFFFF 0 0 no-repeat padding-box; |
79 | 41 |
box-shadow: 0 3px 6px #00000029; |
modules/uoa-usage-statistics/trunk/src/app/analytics/analytics.module.ts | ||
---|---|---|
1 |
import {NgModule} from "@angular/core";
|
|
2 |
import {CommonModule} from "@angular/common";
|
|
3 |
import {RouterModule} from "@angular/router";
|
|
1 |
import {NgModule} from '@angular/core';
|
|
2 |
import {CommonModule} from '@angular/common';
|
|
3 |
import {RouterModule} from '@angular/router';
|
|
4 | 4 |
|
5 |
import {AnalyticsComponent} from "./analytics.component";
|
|
5 |
import {AnalyticsComponent} from './analytics.component';
|
|
6 | 6 |
import {MatAutocompleteModule} from '@angular/material/autocomplete'; |
7 | 7 |
import {ReactiveFormsModule} from '@angular/forms'; |
8 | 8 |
import {MatFormFieldModule} from '@angular/material/form-field'; |
... | ... | |
10 | 10 |
import {Schema2jsonldModule} from '../openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module'; |
11 | 11 |
import {IconsModule} from '../openaireLibrary/utils/icons/icons.module'; |
12 | 12 |
import {IconsService} from '../openaireLibrary/utils/icons/icons.service'; |
13 |
import {arrow_down, arrow_right} from '../openaireLibrary/utils/icons/icons';
|
|
13 |
import {arrow_down} from '../openaireLibrary/utils/icons/icons'; |
|
14 | 14 |
import {LoadingModule} from '../openaireLibrary/utils/loading/loading.module'; |
15 |
import {SearchInputModule} from '../openaireLibrary/sharedComponents/search-input/search-input.module'; |
|
15 | 16 |
|
16 | 17 |
@NgModule({ |
17 | 18 |
imports: [ |
18 | 19 |
CommonModule, |
19 |
MatAutocompleteModule, |
|
20 | 20 |
ReactiveFormsModule, |
21 |
MatFormFieldModule, |
|
22 |
MatInputModule, |
|
23 | 21 |
RouterModule.forChild([{ |
24 | 22 |
path: '', component: AnalyticsComponent |
25 | 23 |
}]), |
26 | 24 |
Schema2jsonldModule, |
27 | 25 |
IconsModule, |
28 |
LoadingModule |
|
26 |
LoadingModule, |
|
27 |
SearchInputModule |
|
29 | 28 |
], |
30 | 29 |
declarations: [AnalyticsComponent], |
31 | 30 |
exports: [AnalyticsComponent] |
modules/uoa-usage-statistics/trunk/src/app/analytics/analytics.component.html | ||
---|---|---|
12 | 12 |
<div class="uk-padding-small uk-padding-remove-vertical"> |
13 | 13 |
<h2 class="uk-margin-medium-bottom portal-color uk-text-bold">Track Countries Usage Activity</h2> |
14 | 14 |
<div class="uk-container uk-text-bold"> |
15 |
<div class="uk-flex uk-flex-middle uk-flex-center uk-align-center uk-margin-medium-bottom search-mobile"> |
|
16 |
<div class="uk-width-3-5"> |
|
17 |
<form [formGroup]="countryFb" (ngSubmit)="search()"> |
|
18 |
<input #input type="text" class="uk-width-1-1" |
|
19 |
[class.uk-animation-slide-right-medium]="showSearch && !countryFb.get('country').value" |
|
20 |
[class.uk-hidden@m]="!showSearch" |
|
21 |
[class.uk-hidden]="country" |
|
22 |
placeholder="SEARCH FOR A COUNTRY" |
|
23 |
(blur)="closeSearch()" |
|
24 |
aria-label="Number" |
|
25 |
formControlName="country" |
|
26 |
[matAutocomplete]="auto"> |
|
27 |
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="search()"> |
|
28 |
<mat-option *ngFor="let option of countries | async" [value]="option"> |
|
29 |
{{option}} |
|
30 |
</mat-option> |
|
31 |
</mat-autocomplete> |
|
32 |
</form> |
|
33 |
<div *ngIf="country && !showSearch" class="uk-flex uk-flex-left"> |
|
34 |
<span class="uk-flex uk-flex-middle"> |
|
35 |
<span>{{country}}</span> |
|
36 |
<span class="uk-icon clickable space" uk-icon="icon: close; ratio: 0.8" (click)="reset()"> |
|
37 |
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" data-svg="close"><path |
|
38 |
fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path> |
|
39 |
<path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path> |
|
40 |
</svg> |
|
41 |
</span> |
|
42 |
</span> |
|
43 |
</div> |
|
15 |
<div class="uk-width-4-5@m uk-align-center"> |
|
16 |
<div search-input #searchInput [control]="countryFb" [showSearch]="showSearch" |
|
17 |
placeholder="SEARCH FOR A COUNTRY" |
|
18 |
[selected]="country" [loading]="loading" [list]="countries" (searchEmitter)="search($event)" (resetEmitter)="reset()"> |
|
44 | 19 |
</div> |
45 |
<button [disabled]="loading" class="search uk-margin-medium-left uk-visible@m" |
|
46 |
(mousedown)="$event.preventDefault()" (click)="toggle()"> |
|
47 |
<img src="assets/usage-statistics-assets/analytics/search.svg"> |
|
48 |
<span class="uk-text-uppercase space">search</span> |
|
49 |
</button> |
|
50 |
<button [disabled]="loading" class="search uk-hidden@m" |
|
51 |
(mousedown)="$event.preventDefault()" (click)="search(false)"> |
|
52 |
<img src="assets/usage-statistics-assets/analytics/search.svg"> |
|
53 |
<span class="uk-text-uppercase space">search</span> |
|
54 |
</button> |
|
55 | 20 |
</div> |
56 | 21 |
<div class="uk-margin-medium-bottom"> |
57 | 22 |
<div class="uk-text-uppercase">{{(country) ? country : 'worldwide'}}</div> |
modules/uoa-usage-statistics/trunk/src/app/analytics/analytics.component.ts | ||
---|---|---|
1 |
import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
|
|
1 |
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; |
|
2 | 2 |
import {CountryUsageStat, UsageStat} from '../entities/usage-stat'; |
3 |
import {FormControl, FormGroup} from '@angular/forms';
|
|
3 |
import {FormControl} from '@angular/forms'; |
|
4 | 4 |
import {Observable, Subscriber, Subscription} from 'rxjs'; |
5 | 5 |
import {UsageStatsService} from '../services/usage-stats.service'; |
6 | 6 |
import {map, startWith} from 'rxjs/operators'; |
... | ... | |
13 | 13 |
import {properties} from '../../environments/environment'; |
14 | 14 |
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; |
15 | 15 |
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service'; |
16 |
import {SearchInputComponent} from '../openaireLibrary/sharedComponents/search-input/search-input.component'; |
|
16 | 17 |
|
17 | 18 |
@Component({ |
18 | 19 |
selector: 'analytics', |
... | ... | |
20 | 21 |
styleUrls: ['analytics.component.css'], |
21 | 22 |
}) |
22 | 23 |
export class AnalyticsComponent implements OnInit, OnDestroy { |
23 |
public countryFb: FormGroup;
|
|
24 |
public countryFb: FormControl;
|
|
24 | 25 |
public countries: Observable<string[]>; |
25 | 26 |
public country: string; |
26 | 27 |
public loading: boolean = true; |
... | ... | |
31 | 32 |
private timeouts: any[] = []; |
32 | 33 |
public years = 0; |
33 | 34 |
public charts: SafeUrl[]; |
34 |
@ViewChild('input') input: ElementRef; |
|
35 | 35 |
properties: EnvProperties = properties; |
36 | 36 |
description = "Track Countries Usage Activity. Worldwide Monthly Usage Events, Monthly Views & Downloads."; |
37 | 37 |
title = "OpenAIRE - UsageCounts | Analytics"; |
38 | 38 |
subs: Subscription[] = []; |
39 | 39 |
searchSub: Subscription = null; |
40 |
@ViewChild('searchInput') searchInput: SearchInputComponent; |
|
40 | 41 |
|
41 | 42 |
constructor(private usageStatsService: UsageStatsService, |
42 | 43 |
private route: ActivatedRoute, |
... | ... | |
84 | 85 |
} |
85 | 86 |
|
86 | 87 |
private init() { |
87 |
this.countryFb = new FormGroup({ |
|
88 |
country: new FormControl(null) |
|
89 |
}); |
|
90 |
this.countries = this.countryFb.get('country').valueChanges |
|
88 |
this.countryFb = new FormControl(null); |
|
89 |
this.countries = this.countryFb.valueChanges |
|
91 | 90 |
.pipe( |
92 | 91 |
startWith(''), |
93 | 92 |
map(value => this._filter(value)) |
... | ... | |
124 | 123 |
} |
125 | 124 |
|
126 | 125 |
public search(show: boolean = false) { |
127 |
this.country = this.countryFb.value.country;
|
|
126 |
this.country = this.countryFb.value; |
|
128 | 127 |
this.showSearch = show; |
129 | 128 |
this.loading = true; |
130 | 129 |
this.clearTimeouts(); |
... | ... | |
170 | 169 |
return countries.map(value => value.name).filter(option => filterValue && option.toLowerCase().includes(filterValue)); |
171 | 170 |
} |
172 | 171 |
|
173 |
toggle() { |
|
174 |
this.showSearch = !this.showSearch; |
|
175 |
if (this.showSearch) { |
|
176 |
setTimeout(() => { // this will make the execution after the above boolean has changed |
|
177 |
this.input.nativeElement.focus(); |
|
178 |
}, 0); |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
closeSearch() { |
|
183 |
this.showSearch = false; |
|
184 |
} |
|
185 |
|
|
186 | 172 |
clearTimeouts() { |
187 | 173 |
this.timeouts.forEach(timeout => { |
188 | 174 |
clearTimeout(timeout); |
... | ... | |
197 | 183 |
this.clearTimeouts(); |
198 | 184 |
if (this.state == 0) { |
199 | 185 |
this.init(); |
200 |
this.showSearch = true; |
|
201 |
setTimeout(() => { // this will make the execution after the above boolean has changed |
|
202 |
this.input.nativeElement.focus(); |
|
203 |
}, 0); |
|
204 |
this.search(); |
|
186 |
this.searchInput.reset(); |
|
187 |
this.search(true); |
|
205 | 188 |
} |
206 | 189 |
} |
207 | 190 |
|
Also available in: Unified diff
[Usage Counts | Trunk]: Add search-input on analytics