-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9531471
commit db485a5
Showing
7 changed files
with
227 additions
and
38 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
...pps/dashboard/src/app/modules/climate-data/pages/station/components/rainfall-summary.html
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
...-apps/dashboard/src/app/modules/climate-data/pages/station/components/rainfall-summary.ts
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
.../app/modules/climate-data/pages/station/components/rainfall-summary/rainfall-summary.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div style="display: flex; align-items: center"> | ||
<h3 style="flex: 1">Rainfall Summary</h3> | ||
<button mat-stroked-button (click)="refreshData()" [disabled]="api.cb['rainfallSummary']==='pending'"> | ||
<mat-icon [class.spin]="api.cb['rainfallSummary']==='pending'">autorenew</mat-icon> | ||
Refresh Data | ||
</button> | ||
</div> | ||
<mat-tab-group preserveContent> | ||
<mat-tab> | ||
<ng-template mat-tab-label> | ||
<mat-icon>view_list</mat-icon> | ||
Table | ||
</ng-template> | ||
</mat-tab> | ||
<mat-tab> | ||
<ng-template mat-tab-label> | ||
<mat-icon>show_chart</mat-icon> | ||
Chart | ||
</ng-template> | ||
</mat-tab> | ||
<mat-tab> | ||
<ng-template mat-tab-label> | ||
<mat-icon>description</mat-icon> | ||
Definition | ||
</ng-template> | ||
</mat-tab> | ||
</mat-tab-group> |
File renamed without changes.
155 changes: 155 additions & 0 deletions
155
...p/modules/climate-data/pages/station/components/rainfall-summary/rainfall-summary.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
export const RAINFALL_SUMMARY_MOCK = { | ||
metadata: { | ||
annual_rain: { | ||
annual_rain: ['TRUE'], | ||
n_rain: ['TRUE'], | ||
na_rm: ['FALSE'], | ||
}, | ||
start_rains: { | ||
threshold: [1], | ||
start_day: [1], | ||
end_day: [366], | ||
total_rainfall: ['TRUE'], | ||
amount_rain: [25], | ||
over_days: [3], | ||
proportion: ['FALSE'], | ||
number_rain_days: ['FALSE'], | ||
dry_spell: ['TRUE'], | ||
spell_max_dry_days: [10], | ||
spell_interval: [21], | ||
dry_period: ['FALSE'], | ||
_last_updated: ['2022-11-25'], | ||
}, | ||
end_rains: { | ||
start_day: [121], | ||
end_day: [366], | ||
interval_length: [1], | ||
min_rainfall: [10], | ||
}, | ||
end_season: { | ||
start_day: [121], | ||
end_day: [366], | ||
capacity: [100], | ||
water_balance_max: [60], | ||
evaporation: ['value'], | ||
evaporation_value: [5], | ||
}, | ||
seasonal_rain: { | ||
seasonal_rain: ['TRUE'], | ||
n_rain: ['TRUE'], | ||
na_rm: ['FALSE'], | ||
rain_day: [0.85], | ||
total_rain: [0], | ||
}, | ||
}, | ||
data: [ | ||
{ | ||
year: 1945, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: '', | ||
n_rain: '', | ||
start_rains: '', | ||
end_rains: 365, | ||
end_season: '', | ||
seasonal_rain: '', | ||
n_seasonal_rain: '', | ||
season_length: '', | ||
}, | ||
{ | ||
year: 1946, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: 1081.2, | ||
n_rain: 90, | ||
start_rains: 1, | ||
end_rains: 366, | ||
end_season: 121, | ||
seasonal_rain: 652.2, | ||
n_seasonal_rain: 54, | ||
season_length: 120, | ||
}, | ||
{ | ||
year: 1947, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: 1055.3, | ||
n_rain: 89, | ||
start_rains: 3, | ||
end_rains: 362, | ||
end_season: 121, | ||
seasonal_rain: 760, | ||
n_seasonal_rain: 64, | ||
season_length: 118, | ||
}, | ||
{ | ||
year: 1948, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: 1212.3, | ||
n_rain: 88, | ||
start_rains: 5, | ||
end_rains: 359, | ||
end_season: 125, | ||
seasonal_rain: 901.9, | ||
n_seasonal_rain: 65, | ||
season_length: 120, | ||
}, | ||
{ | ||
year: 1949, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: 896.7, | ||
n_rain: 68, | ||
start_rains: 20, | ||
end_rains: 366, | ||
end_season: 121, | ||
seasonal_rain: 492, | ||
n_seasonal_rain: 35, | ||
season_length: 101, | ||
}, | ||
{ | ||
year: 1950, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: 1048.1, | ||
n_rain: 82, | ||
start_rains: 2, | ||
end_rains: 365, | ||
end_season: 121, | ||
seasonal_rain: 870.6, | ||
n_seasonal_rain: 66, | ||
season_length: 119, | ||
}, | ||
{ | ||
year: 1951, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: 1100.1, | ||
n_rain: 98, | ||
start_rains: 5, | ||
end_rains: 366, | ||
end_season: 121, | ||
seasonal_rain: 564, | ||
n_seasonal_rain: 57, | ||
season_length: 116, | ||
}, | ||
{ | ||
year: 1952, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: 893.1999999999999, | ||
n_rain: 74, | ||
start_rains: 2, | ||
end_rains: 365, | ||
end_season: 121, | ||
seasonal_rain: 697, | ||
n_seasonal_rain: 51, | ||
season_length: 119, | ||
}, | ||
{ | ||
year: 1953, | ||
station_name: 'CHIPATA MET', | ||
annual_rain: 1056.9, | ||
n_rain: 84, | ||
start_rains: 1, | ||
end_rains: 366, | ||
end_season: 121, | ||
seasonal_rain: 775.5, | ||
n_seasonal_rain: 58, | ||
season_length: 120, | ||
}, | ||
], | ||
}; |
44 changes: 44 additions & 0 deletions
44
...rc/app/modules/climate-data/pages/station/components/rainfall-summary/rainfall-summary.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { AfterViewInit, Component } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { MatTabsModule } from '@angular/material/tabs'; | ||
|
||
import { ClimateDataDashboardService } from '../../../../climate-data.service'; | ||
import { ClimateDataApiService } from '../../../../climate-data-api.service'; | ||
import { RAINFALL_SUMMARY_MOCK } from './rainfall-summary.spec'; | ||
|
||
@Component({ | ||
selector: 'dashboard-climate-rainfall-summary', | ||
templateUrl: './rainfall-summary.html', | ||
standalone: true, | ||
imports: [MatButtonModule, MatIconModule, MatTabsModule], | ||
styleUrl: './rainfall-summary.scss', | ||
}) | ||
export class RainfallSummaryComponent implements AfterViewInit { | ||
constructor(public api: ClimateDataApiService, private service: ClimateDataDashboardService) {} | ||
|
||
ngAfterViewInit() { | ||
// TODO - retrieve from server | ||
this.loadData(RAINFALL_SUMMARY_MOCK); | ||
} | ||
|
||
public async refreshData() { | ||
const { station_id, country_code } = this.service.activeStation; | ||
const { response, data, error } = await this.api | ||
.useCallback('rainfallSummary') | ||
.POST('/v1/annual_rainfall_summaries/', { | ||
body: { | ||
country: `${country_code}` as any, | ||
station_id: `${station_id}`, | ||
summaries: ['annual_rain', 'start_rains', 'end_rains', 'end_season', 'seasonal_rain', 'seasonal_length'], | ||
}, | ||
}); | ||
console.log({ response, data, error }); | ||
this.loadData(data); | ||
} | ||
|
||
private loadData(summaryData) { | ||
console.log('loading data', summaryData); | ||
const { data, metadata } = summaryData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters