Implement healthcheck service
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good
This commit is contained in:
@@ -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 {
|
||||
|
Reference in New Issue
Block a user