File tree Expand file tree Collapse file tree 2 files changed +25
-7
lines changed
angular-monorepo/libs/entities
data-repository/src/lib/services
feature-location-dashboard/src/lib/components/location-dashboard Expand file tree Collapse file tree 2 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -178,10 +178,13 @@ export class MockEntityService {
178
178
}
179
179
180
180
getLocationStats ( ) : Observable < LocationStats > {
181
- return of ( {
182
- lastWeekLocationOccupancy : this . lastWeekLocationOccupancy ,
183
- lastWeekEmployeesVisits : this . mapVisits ( ) ,
184
- } ) ;
181
+ return defer ( ( ) => {
182
+ if ( Math . random ( ) < 0.1 ) return throwError ( ( ) => 'Failed to update' ) ;
183
+ return of ( {
184
+ lastWeekLocationOccupancy : this . lastWeekLocationOccupancy ,
185
+ lastWeekEmployeesVisits : this . mapVisits ( ) ,
186
+ } ) ;
187
+ } ) . pipe ( delay ( 1000 ) ) ;
185
188
}
186
189
187
190
private mapVisits ( ) {
Original file line number Diff line number Diff line change 1
1
import { EntityService } from '@angular-monorepo/entities/data-repository' ;
2
2
import { Component } from '@angular/core' ;
3
-
3
+ import { catchError , of } from 'rxjs' ;
4
+ import { MessageService } from 'primeng/api' ;
4
5
@Component ( {
5
6
selector : 'angular-monorepo-location-dashboard' ,
6
7
templateUrl : './location-dashboard.component.html' ,
7
8
styleUrls : [ './location-dashboard.component.scss' ] ,
8
9
} )
9
10
export class LocationDashboardComponent {
10
- data$ = this . entityService . getLocationStats ( ) ;
11
+ data$ = this . entityService . getLocationStats ( ) . pipe (
12
+ catchError ( ( ) => {
13
+ this . messageService . add ( {
14
+ severity : 'error' ,
15
+ detail : 'Could not load location data' ,
16
+ } ) ;
17
+ return of ( {
18
+ lastWeekLocationOccupancy : [ ] ,
19
+ lastWeekEmployeesVisits : [ ] ,
20
+ } ) ;
21
+ } )
22
+ ) ;
11
23
12
- constructor ( private entityService : EntityService ) { }
24
+ constructor (
25
+ private entityService : EntityService ,
26
+ private messageService : MessageService
27
+ ) { }
13
28
}
You can’t perform that action at this time.
0 commit comments