Revision 58825
Added by Stefania Martziou almost 4 years ago
data-view.component.ts | ||
---|---|---|
1 |
import {Component, Input, OnInit, ViewEncapsulation} from '@angular/core'; |
|
2 |
import { CountryOverview } from '../../domain/overview-data'; |
|
1 |
import { Component, OnInit } from '@angular/core'; |
|
3 | 2 |
import { printPage } from '../../shared/reusablecomponents/print-function'; |
4 | 3 |
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; |
4 |
import { DataService } from '../../services/data.service'; |
|
5 |
import { DataHandlerService } from '../../services/data-handler.service'; |
|
6 |
import { CountryTableData } from '../../domain/overview-map-data'; |
|
5 | 7 |
|
6 | 8 |
@Component({ |
7 | 9 |
selector: 'app-data-view', |
8 | 10 |
templateUrl: './data-view.component.html', |
9 |
// styleUrls: ['./top-menu.component.css'], |
|
10 |
encapsulation: ViewEncapsulation.None |
|
11 | 11 |
}) |
12 | 12 |
|
13 | 13 |
export class DataViewComponent implements OnInit { |
14 | 14 |
|
15 |
@Input() type: string; |
|
16 |
@Input() countries: CountryOverview[]; |
|
15 |
// @Input() type: string;
|
|
16 |
// @Input() countries: CountryOverview[];
|
|
17 | 17 |
|
18 | 18 |
activeView: string = 'absolute'; |
19 |
contentAbsoluteSelection: string = 'affiliated'; |
|
20 |
contentPercentageSelection: string = 'affiliated'; |
|
19 | 21 |
|
22 |
tableAbsoluteData: CountryTableData[]; |
|
23 |
tablePercentageData: CountryTableData[]; |
|
24 |
|
|
25 |
loading: boolean = true; |
|
26 |
|
|
20 | 27 |
oaPublicationsURL: SafeResourceUrl; |
21 | 28 |
oaRepositoriesURL: SafeResourceUrl; |
22 | 29 |
oaJournalsURL: SafeResourceUrl; |
... | ... | |
24 | 31 |
oaSoftwareURL: SafeResourceUrl; |
25 | 32 |
oaOtherURL: SafeResourceUrl; |
26 | 33 |
|
27 |
constructor(private sanitizer: DomSanitizer) {} |
|
34 |
constructor(private sanitizer: DomSanitizer, |
|
35 |
private dataService: DataService, |
|
36 |
private dataHandlerService: DataHandlerService) {} |
|
28 | 37 |
|
38 |
ngOnInit(): void { |
|
39 |
this.getAbsoluteData(); |
|
40 |
} |
|
41 |
|
|
42 |
getAbsoluteData() { |
|
43 |
this.loading = true; |
|
44 |
this.dataService.getOverviewTableAbsoluteData(this.contentAbsoluteSelection).subscribe( |
|
45 |
rawData => { |
|
46 |
this.tableAbsoluteData = this.dataHandlerService.convertRawDataToAbsoluteTableData(rawData); |
|
47 |
this.loading = false; |
|
48 |
}, error => { |
|
49 |
console.log(error); |
|
50 |
this.loading = false; |
|
51 |
} |
|
52 |
); |
|
53 |
} |
|
54 |
|
|
55 |
getPercentageData() { |
|
56 |
this.loading = true; |
|
57 |
this.dataService.getOverviewTableAbsoluteData(this.contentPercentageSelection).subscribe( |
|
58 |
rawData => { |
|
59 |
this.tablePercentageData = this.dataHandlerService.convertRawDataToAbsoluteTableData(rawData); |
|
60 |
this.loading = false; |
|
61 |
}, error => { |
|
62 |
console.log(error); |
|
63 |
this.loading = false; |
|
64 |
} |
|
65 |
); |
|
66 |
} |
|
67 |
|
|
68 |
getContentAbsolute(contentSelection: string): void { |
|
69 |
this.contentAbsoluteSelection = contentSelection; |
|
70 |
this.getAbsoluteData(); |
|
71 |
} |
|
72 |
|
|
73 |
getContentPercentage(contentSelection: string): void { |
|
74 |
this.contentPercentageSelection = contentSelection; |
|
75 |
this.getPercentageData(); |
|
76 |
} |
|
77 |
|
|
29 | 78 |
changeView(view: string) { |
30 | 79 |
this.activeView = view; |
31 | 80 |
if (view === 'graph') { |
... | ... | |
59 | 108 |
printOverviewData(sectionID: string) { |
60 | 109 |
printPage(sectionID); |
61 | 110 |
} |
62 |
|
|
63 |
ngOnInit(): void { |
|
64 |
} |
|
65 | 111 |
} |
Also available in: Unified diff
Working on the new version of the oso. Work on the home page almost done