fix: device recovery mode (#879)

This commit is contained in:
Róbert Kiss
2018-12-18 00:10:02 +01:00
committed by László Monda
parent 8c7d625573
commit 9112b597f8
6 changed files with 30 additions and 14 deletions

View File

@@ -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) {

View File

@@ -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
}
]
}

View File

@@ -15,6 +15,11 @@
[disabled]="flashFirmwareButtonDisbabled$ | async"
(click)="onRecoveryDevice()">Fix device
</button>
<button class="btn btn-default"
type="button"
[disabled]="updatingFirmware$ | async"
(click)="onClose()">Close
</button>
</p>
</div>
<div class="flex-grow">

View File

@@ -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<boolean>;
updatingFirmware$: Observable<boolean>;
xtermLog$: Observable<Array<XtermLog>>;
@@ -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());
}
}

View File

@@ -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
;

View File

@@ -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<EnableUsbStackTestAction>(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,