Implement healthcheck service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma
2020-07-22 20:31:12 +02:00
parent e525227865
commit d494a7c7d6
5 changed files with 103 additions and 74 deletions

View File

@@ -10,6 +10,7 @@ import { IEventMessage } from '../../models/event.message';
import { IListItem} from '../../models/list.item';
import { EventService } from '../../services/event.service';
import * as commonActions from '../../actions/app-common.actions';
import { HealthCheckService } from '../../services/healthcheck.service';
import * as appReducers from '../../reducers/app-common.reducer';
@@ -46,26 +47,18 @@ export class AppComponent implements OnInit, OnDestroy {
private meta: Meta,
private store: Store<appReducers.State>,
private eventService: EventService,
private healthCheckService: HealthCheckService
) {
var connection = navigator['connection'] || navigator['mozConnection'] || navigator['webkitConnection'];
if(connection) {
this.setOnOffline(connection);
connection.addEventListener('change', () => {
this.setOnOffline(connection);
});
}
}
setOnOffline(connection:any) {
console.debug(connection);
if(connection.downlink == 0) {
this.store.dispatch(new commonActions.Offline());
} else {
//check health every 30 seconds
this.healthCheckService.check(30000).subscribe((online) => {
if(online) {
this.store.dispatch(new commonActions.Online());
}
} else {
this.store.dispatch(new commonActions.Offline());
}
});
}
getActionFromEvent(event: IEventMessage): Action {