-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from mild-blue/show-slots-number
Show slots number
- Loading branch information
Showing
10 changed files
with
174 additions
and
68 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
backend/src/test/kotlin/blue/mild/covid/vaxx/requests/http-client.env.json
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
{ | ||
"local": { | ||
"url": "http://localhost:8080/api" | ||
"url": "http://localhost:8080/api", | ||
"email": "[email protected]", | ||
"password": "bluemild" | ||
}, | ||
"staging": { | ||
"url": "https://covid-vaxx.stg.mild.blue/api", | ||
|
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
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
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
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,8 @@ | ||
export interface Statistics { | ||
availableSlots: number; | ||
bookedSlots: number; | ||
emailsSentCount: number; | ||
patientsDataVerifiedCount: number; | ||
registrationsCount: number; | ||
vaccinatedPatientsCount: number; | ||
} |
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
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 |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import { Component } from '@angular/core'; | ||
import { StatisticsService } from '@app/services/statistics/statistics.service'; | ||
import { Statistics } from '@app/model/Statistics'; | ||
|
||
@Component({ | ||
selector: 'app-info', | ||
templateUrl: './info.component.html', | ||
styleUrls: ['./info.component.scss'] | ||
}) | ||
export class InfoComponent { | ||
public statistics?: Statistics; | ||
|
||
constructor() { | ||
constructor(private _statisticsService: StatisticsService) { | ||
this._statisticsService.statistics.subscribe(statistics => { | ||
this.statistics = statistics; | ||
}); | ||
} | ||
|
||
} |
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,8 @@ | ||
import { SystemStatisticsDtoOut } from '@app/generated'; | ||
import { Statistics } from '@app/model/Statistics'; | ||
|
||
export const parseStatistics = (data: SystemStatisticsDtoOut): Statistics => { | ||
return { | ||
...data | ||
}; | ||
}; |
16 changes: 16 additions & 0 deletions
16
frontend/src/app/services/statistics/statistics.service.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,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { StatisticsService } from './statistics.service'; | ||
|
||
describe('StatisticsService', () => { | ||
let service: StatisticsService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(StatisticsService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
frontend/src/app/services/statistics/statistics.service.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,43 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { SystemStatisticsDtoOut } from '@app/generated'; | ||
import { environment } from '@environments/environment'; | ||
import { map } from 'rxjs/operators'; | ||
import { Statistics } from '@app/model/Statistics'; | ||
import { parseStatistics } from '@app/parsers/statistics.parser'; | ||
import { BehaviorSubject, Observable } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class StatisticsService { | ||
|
||
private _statisticsnKey = 'questions'; | ||
private _statisticsSubject: BehaviorSubject<Statistics | undefined> = new BehaviorSubject<Statistics | undefined>(undefined); | ||
public statistics: Observable<Statistics | undefined> = this._statisticsSubject.asObservable(); | ||
|
||
constructor(private _http: HttpClient) { | ||
this._initStatistics(); | ||
} | ||
|
||
public async loadStatistics(): Promise<Statistics> { | ||
return this._http.get<SystemStatisticsDtoOut>( | ||
`${environment.apiUrl}/statistics` | ||
).pipe( | ||
map(response => { | ||
const statistics = parseStatistics(response); | ||
|
||
this._statisticsSubject.next(statistics); | ||
localStorage.setItem(this._statisticsnKey, JSON.stringify(statistics)); | ||
|
||
return statistics; | ||
}) | ||
).toPromise(); | ||
} | ||
|
||
private _initStatistics(): void { | ||
const value = localStorage.getItem(this._statisticsnKey); | ||
const savedStatistics = value ? JSON.parse(value) : undefined; | ||
this._statisticsSubject.next(savedStatistics); | ||
} | ||
} |