diff options
Diffstat (limited to 'sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts')
-rw-r--r-- | sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts b/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts index 143dd7d4a..79e46df0e 100644 --- a/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts +++ b/sdnr/wt/odlux/apps/mediatorApp/src/actions/mediatorServerActions.ts @@ -73,6 +73,12 @@ export class SetMediatorServerSupportedDevices extends BaseAction { } } +export class SetMediatorServerReachable extends BaseAction { + constructor(public isReachable: boolean) { + super(); + } +} + export const initializeMediatorServerAsyncActionCreator = (serverId: string) => (dispatch: Dispatch) => { dispatch(new SetMediatorServerBusy(true)); mediatorService.getMediatorServerById(serverId).then(mediatorServer => { @@ -82,18 +88,25 @@ export const initializeMediatorServerAsyncActionCreator = (serverId: string) => dispatch(new NavigateToApplication("mediator")); return; } - dispatch(new SetMediatorServerInfo(mediatorServer._id, mediatorServer.name, mediatorServer.url)); - mediatorService.getMediatorServerVersion(mediatorServer._id).then(versionInfo => { - dispatch(new SetMediatorServerVersion(versionInfo)); - }); + dispatch(new SetMediatorServerInfo(mediatorServer.id, mediatorServer.name, mediatorServer.url)); Promise.all([ - mediatorService.getMediatorServerAllConfigs(mediatorServer._id), - mediatorService.getMediatorServerSupportedDevices(mediatorServer._id) - ]).then(([configurations, supportedDevices]) => { + mediatorService.getMediatorServerAllConfigs(mediatorServer.id), + mediatorService.getMediatorServerSupportedDevices(mediatorServer.id), + mediatorService.getMediatorServerVersion(mediatorServer.id) + ]).then(([configurations, supportedDevices, versionInfo]) => { + if (configurations === null && supportedDevices === null && versionInfo === null) { + dispatch(new SetMediatorServerReachable(false)); + } else { + dispatch(new SetMediatorServerReachable(true)); + } dispatch(new SetAllMediatorServerConfigurations(configurations)); dispatch(new SetMediatorServerSupportedDevices(supportedDevices)); + dispatch(new SetMediatorServerVersion(versionInfo)); + dispatch(new SetMediatorServerBusy(false)); + }).catch(error => { + dispatch(new SetMediatorServerReachable(false)); dispatch(new SetMediatorServerBusy(false)); }); }); |