Skip to content
This repository has been archived by the owner on Nov 21, 2022. It is now read-only.

Commit

Permalink
per cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed Jul 26, 2020
1 parent 790b3fd commit 72c02fa
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
{{ data.Country }} {{ data.Date }} {{ data.Status }} {{ data.Cases }}
</div> -->

<select
[ngModel]="statusSelected"
(ngModelChange)="changeStatus($event)"
id="status"
>
<option *ngFor="let s of status" [ngValue]="s">{{ s }}</option>
</select>

<table class="table table-hover">
<thead class="thead-dark">
<tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@ export class CovidTableDataComponent implements OnInit {
public Countries: CountryCovid19[] = [];
public displayData = new Map<string , CovidData[]>();
public lastItems : CovidData[] = [];

public status = [
'confirmed',
'recovered',
'deaths'
];
public statusSelected = 'confirmed';
constructor( private covidDataService: CovidDataService) { }

ngOnInit(): void {
changeStatus(s: string) {
this.statusSelected = s;
window.alert(this.statusSelected);
this.reloadData();
window.alert(this.statusSelected);
// window.alert(this.statusSelected);
//this.getCovidDataAll(this.countrySelected.map((it) => it?.Slug));
}
reloadData(){
this.lastItems.length=0;
this.covidDataService.getCovid19ApiCountries()
.pipe(
tap(it=>this.Countries=it),
map(res => res.map(cnt => this.covidDataService.getCovidData(cnt.Country, 'confirmed'))),
map(res => res.map(cnt => this.covidDataService.getCovidData(cnt.Country, this.statusSelected))),
mergeMap(it=> forkJoin(it)),
tap(dict=> {

Expand All @@ -34,10 +47,14 @@ export class CovidTableDataComponent implements OnInit {
var last=item[1][0];
this.lastItems.push(last);
}
this.lastItems = this.lastItems.sort((a,b)=> b.Cases - a.Cases);
// window.alert(this.displayData.size);
})
)
.subscribe();
}
ngOnInit(): void {
this.reloadData();
}

}

0 comments on commit 72c02fa

Please sign in to comment.