diff --git a/packages/uhk-agent/src/services/device.service.ts b/packages/uhk-agent/src/services/device.service.ts index 7cf61584..c67c3701 100644 --- a/packages/uhk-agent/src/services/device.service.ts +++ b/packages/uhk-agent/src/services/device.service.ts @@ -220,10 +220,6 @@ export class DeviceService { await this.operations.updateRightFirmware(); - await snooze(500); - - this.pollUhkDevice(); - response.modules = await this.getHardwareModules(false); response.success = true; } catch (error) { diff --git a/packages/uhk-web/src/app/components/device/device.routes.ts b/packages/uhk-web/src/app/components/device/device.routes.ts index 7547de4f..52c6f267 100644 --- a/packages/uhk-web/src/app/components/device/device.routes.ts +++ b/packages/uhk-web/src/app/components/device/device.routes.ts @@ -5,7 +5,6 @@ import { DeviceFirmwareComponent } from './firmware/device-firmware.component'; import { MouseSpeedComponent } from './mouse-speed/mouse-speed.component'; import { LEDBrightnessComponent } from './led-brightness/led-brightness.component'; import { RestoreConfigurationComponent } from './restore-configuration/restore-configuration.component'; -import { RecoveryModeComponent } from './recovery-mode/recovery-mode.component'; export const deviceRoutes: Routes = [ { @@ -35,10 +34,6 @@ export const deviceRoutes: Routes = [ { path: 'restore-user-configuration', component: RestoreConfigurationComponent - }, - { - path: 'recovery-mode', - component: RecoveryModeComponent } ] } diff --git a/packages/uhk-web/src/app/components/device/recovery-mode/recovery-mode.component.html b/packages/uhk-web/src/app/components/device/recovery-mode/recovery-mode.component.html index 129c52fe..9cb028e5 100644 --- a/packages/uhk-web/src/app/components/device/recovery-mode/recovery-mode.component.html +++ b/packages/uhk-web/src/app/components/device/recovery-mode/recovery-mode.component.html @@ -15,6 +15,11 @@ [disabled]="flashFirmwareButtonDisbabled$ | async" (click)="onRecoveryDevice()">Fix device +

diff --git a/packages/uhk-web/src/app/components/device/recovery-mode/recovery-mode.component.ts b/packages/uhk-web/src/app/components/device/recovery-mode/recovery-mode.component.ts index 364a7d54..39a8fbeb 100644 --- a/packages/uhk-web/src/app/components/device/recovery-mode/recovery-mode.component.ts +++ b/packages/uhk-web/src/app/components/device/recovery-mode/recovery-mode.component.ts @@ -3,8 +3,8 @@ import { Store } from '@ngrx/store'; import { Observable } from 'rxjs/Observable'; import { XtermLog } from '../../../models/xterm-log'; -import { AppState, flashFirmwareButtonDisbabled, xtermLog } from '../../../store'; -import { RecoveryDeviceAction } from '../../../store/actions/device'; +import { AppState, flashFirmwareButtonDisbabled, updatingFirmware, xtermLog } from '../../../store'; +import { RecoveryDeviceAction, StartConnectionPollerAction } from '../../../store/actions/device'; @Component({ selector: 'device-recovery-mode', @@ -17,6 +17,7 @@ import { RecoveryDeviceAction } from '../../../store/actions/device'; }) export class RecoveryModeComponent implements OnInit { flashFirmwareButtonDisbabled$: Observable; + updatingFirmware$: Observable; xtermLog$: Observable>; @@ -25,10 +26,15 @@ export class RecoveryModeComponent implements OnInit { ngOnInit(): void { this.flashFirmwareButtonDisbabled$ = this.store.select(flashFirmwareButtonDisbabled); + this.updatingFirmware$ = this.store.select(updatingFirmware); this.xtermLog$ = this.store.select(xtermLog); } onRecoveryDevice(): void { this.store.dispatch(new RecoveryDeviceAction()); } + + onClose(): void { + this.store.dispatch(new StartConnectionPollerAction()); + } } diff --git a/packages/uhk-web/src/app/store/actions/device.ts b/packages/uhk-web/src/app/store/actions/device.ts index 6c025e0f..de8dfac0 100644 --- a/packages/uhk-web/src/app/store/actions/device.ts +++ b/packages/uhk-web/src/app/store/actions/device.ts @@ -29,7 +29,8 @@ export const ActionTypes = { RESTORE_CONFIGURATION_FROM_BACKUP: type(PREFIX + 'Restore configuration from backup'), RESTORE_CONFIGURATION_FROM_BACKUP_SUCCESS: type(PREFIX + 'Restore configuration from backup success'), RECOVERY_DEVICE: type(PREFIX + 'Recovery device'), - ENABLE_USB_STACK_TEST: type(PREFIX + 'USB stack test') + ENABLE_USB_STACK_TEST: type(PREFIX + 'USB stack test'), + START_CONNECTION_POLLER: type(PREFIX + 'Start connection poller') }; export class SetPrivilegeOnLinuxAction implements Action { @@ -104,6 +105,7 @@ export class UpdateFirmwareReplyAction implements Action { export class UpdateFirmwareSuccessAction implements Action { type = ActionTypes.UPDATE_FIRMWARE_SUCCESS; + constructor(public payload: HardwareModules) { } } @@ -149,6 +151,10 @@ export class EnableUsbStackTestAction implements Action { type = ActionTypes.ENABLE_USB_STACK_TEST; } +export class StartConnectionPollerAction implements Action { + type = ActionTypes.START_CONNECTION_POLLER; +} + export type Actions = SetPrivilegeOnLinuxAction | SetPrivilegeOnLinuxReplyAction @@ -172,4 +178,5 @@ export type Actions | RestoreUserConfigurationFromBackupSuccessAction | RecoveryDeviceAction | EnableUsbStackTestAction + | StartConnectionPollerAction ; diff --git a/packages/uhk-web/src/app/store/effects/device.ts b/packages/uhk-web/src/app/store/effects/device.ts index 1f720f6a..6e1b03ec 100644 --- a/packages/uhk-web/src/app/store/effects/device.ts +++ b/packages/uhk-web/src/app/store/effects/device.ts @@ -18,7 +18,6 @@ import { HardwareConfiguration, IpcResponse, NotificationType, - UdevRulesInfo, UserConfiguration } from 'uhk-common'; import { @@ -67,7 +66,7 @@ export class DeviceEffects { return; } - if (!state.hasPermission || !state.zeroInterfaceAvailable) { + if (!state.hasPermission) { return this.router.navigate(['/privilege']); } @@ -75,6 +74,10 @@ export class DeviceEffects { return this.router.navigate(['/recovery-device']); } + if (!state.zeroInterfaceAvailable) { + return this.router.navigate(['/privilege']); + } + if (state.connected && state.zeroInterfaceAvailable) { return this.router.navigate(['/']); } @@ -241,6 +244,10 @@ export class DeviceEffects { .ofType(ActionTypes.ENABLE_USB_STACK_TEST) .do(() => this.deviceRendererService.enableUsbStackTest()); + @Effect({dispatch: false}) startConnectionPoller$ = this.actions$ + .ofType(ActionTypes.START_CONNECTION_POLLER) + .do(() => this.deviceRendererService.startConnectionPoller()); + constructor(private actions$: Actions, private router: Router, private appRendererService: AppRendererService,