feat(device): flash device firmware from Agent (#499)
* add dataModelVersion, usbProtocolVersion, slaveProtocolVersion * read the package.json at appstart * flash firmware * update firmware * fix extra resource path * fix import modules * update lock files * fix imports * terminal window * exclude tmp folder from git repo * ok button * auto scroll in xterm * fix maxTry count calculation * optimize logging * optimize timeout * readSync * Add extra delay * fix async call * fix error message in log * fix ok button disable state * retry * list devices * close device after reenumeration * retry snooze * kboot maxtry 10 * retry 100 * remove deprecated toPayload ngrx helper * flash firmware with custom file * fix tslint
This commit is contained in:
committed by
László Monda
parent
f608791a09
commit
297fd3be79
@@ -1,7 +1,7 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { type } from 'uhk-common';
|
||||
import { AppStartInfo, HardwareConfiguration, Notification } from 'uhk-common';
|
||||
import { AppStartInfo, HardwareConfiguration, Notification, type, VersionInformation } from 'uhk-common';
|
||||
import { ElectronLogEntry } from '../../models/xterm-log';
|
||||
|
||||
const PREFIX = '[app] ';
|
||||
|
||||
@@ -15,7 +15,9 @@ export const ActionTypes = {
|
||||
UNDO_LAST: type(PREFIX + 'undo last action'),
|
||||
UNDO_LAST_SUCCESS: type(PREFIX + 'undo last action success'),
|
||||
DISMISS_UNDO_NOTIFICATION: type(PREFIX + 'dismiss notification action'),
|
||||
LOAD_HARDWARE_CONFIGURATION_SUCCESS: type(PREFIX + 'load hardware configuration success')
|
||||
LOAD_HARDWARE_CONFIGURATION_SUCCESS: type(PREFIX + 'load hardware configuration success'),
|
||||
UPDATE_AGENT_VERSION_INFORMATION: type(PREFIX + 'update agent version information'),
|
||||
ELECTRON_MAIN_LOG_RECEIVED: type(PREFIX + 'Electron main log received')
|
||||
};
|
||||
|
||||
export class AppBootsrappedAction implements Action {
|
||||
@@ -64,6 +66,18 @@ export class LoadHardwareConfigurationSuccessAction implements Action {
|
||||
constructor(public payload: HardwareConfiguration) {}
|
||||
}
|
||||
|
||||
export class UpdateAgentVersionInformationAction implements Action {
|
||||
type = ActionTypes.UPDATE_AGENT_VERSION_INFORMATION;
|
||||
|
||||
constructor(public payload: VersionInformation) {}
|
||||
}
|
||||
|
||||
export class ElectronMainLogReceivedAction implements Action {
|
||||
type = ActionTypes.ELECTRON_MAIN_LOG_RECEIVED;
|
||||
|
||||
constructor(public payload: ElectronLogEntry) {}
|
||||
}
|
||||
|
||||
export type Actions
|
||||
= AppStartedAction
|
||||
| AppBootsrappedAction
|
||||
@@ -74,4 +88,6 @@ export type Actions
|
||||
| UndoLastSuccessAction
|
||||
| DismissUndoNotificationAction
|
||||
| LoadHardwareConfigurationSuccessAction
|
||||
| UpdateAgentVersionInformationAction
|
||||
| ElectronMainLogReceivedAction
|
||||
;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
import { type, IpcResponse } from 'uhk-common';
|
||||
import { IpcResponse, type } from 'uhk-common';
|
||||
|
||||
const PREFIX = '[device] ';
|
||||
|
||||
@@ -16,7 +16,13 @@ export const ActionTypes = {
|
||||
SAVE_TO_KEYBOARD_SUCCESS: type(PREFIX + 'save to keyboard success'),
|
||||
SAVE_TO_KEYBOARD_FAILED: type(PREFIX + 'save to keyboard failed'),
|
||||
HIDE_SAVE_TO_KEYBOARD_BUTTON: type(PREFIX + 'hide save to keyboard button'),
|
||||
RESET_USER_CONFIGURATION: type(PREFIX + 'reset user configuration')
|
||||
RESET_USER_CONFIGURATION: type(PREFIX + 'reset user configuration'),
|
||||
UPDATE_FIRMWARE: type(PREFIX + 'update firmware'),
|
||||
UPDATE_FIRMWARE_WITH: type(PREFIX + 'update firmware with'),
|
||||
UPDATE_FIRMWARE_REPLY: type(PREFIX + 'update firmware reply'),
|
||||
UPDATE_FIRMWARE_SUCCESS: type(PREFIX + 'update firmware success'),
|
||||
UPDATE_FIRMWARE_FAILED: type(PREFIX + 'update firmware failed'),
|
||||
UPDATE_FIRMWARE_OK_BUTTON: type(PREFIX + 'update firmware ok button click')
|
||||
};
|
||||
|
||||
export class SetPrivilegeOnLinuxAction implements Action {
|
||||
@@ -26,31 +32,36 @@ export class SetPrivilegeOnLinuxAction implements Action {
|
||||
export class SetPrivilegeOnLinuxReplyAction implements Action {
|
||||
type = ActionTypes.SET_PRIVILEGE_ON_LINUX_REPLY;
|
||||
|
||||
constructor(public payload: IpcResponse) {}
|
||||
constructor(public payload: IpcResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
export class ConnectionStateChangedAction implements Action {
|
||||
type = ActionTypes.CONNECTION_STATE_CHANGED;
|
||||
|
||||
constructor(public payload: boolean) {}
|
||||
constructor(public payload: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
export class PermissionStateChangedAction implements Action {
|
||||
type = ActionTypes.PERMISSION_STATE_CHANGED;
|
||||
|
||||
constructor(public payload: boolean) {}
|
||||
constructor(public payload: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
export class SaveConfigurationAction implements Action {
|
||||
type = ActionTypes.SAVE_CONFIGURATION;
|
||||
|
||||
constructor() {}
|
||||
constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
export class SaveConfigurationReplyAction implements Action {
|
||||
type = ActionTypes.SAVE_CONFIGURATION_REPLY;
|
||||
|
||||
constructor(public payload: IpcResponse) {}
|
||||
constructor(public payload: IpcResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
export class ShowSaveToKeyboardButtonAction implements Action {
|
||||
@@ -73,6 +84,39 @@ export class ResetUserConfigurationAction implements Action {
|
||||
type = ActionTypes.RESET_USER_CONFIGURATION;
|
||||
}
|
||||
|
||||
export class UpdateFirmwareAction implements Action {
|
||||
type = ActionTypes.UPDATE_FIRMWARE;
|
||||
}
|
||||
|
||||
export class UpdateFirmwareWithAction implements Action {
|
||||
type = ActionTypes.UPDATE_FIRMWARE_WITH;
|
||||
|
||||
constructor(public payload: Array<number>) {
|
||||
}
|
||||
}
|
||||
|
||||
export class UpdateFirmwareReplyAction implements Action {
|
||||
type = ActionTypes.UPDATE_FIRMWARE_REPLY;
|
||||
|
||||
constructor(public payload: IpcResponse) {
|
||||
}
|
||||
}
|
||||
|
||||
export class UpdateFirmwareSuccessAction implements Action {
|
||||
type = ActionTypes.UPDATE_FIRMWARE_SUCCESS;
|
||||
}
|
||||
|
||||
export class UpdateFirmwareFailedAction implements Action {
|
||||
type = ActionTypes.UPDATE_FIRMWARE_FAILED;
|
||||
|
||||
constructor(public payload: any) {
|
||||
}
|
||||
}
|
||||
|
||||
export class UpdateFirmwareOkButtonAction implements Action {
|
||||
type = ActionTypes.UPDATE_FIRMWARE_OK_BUTTON;
|
||||
}
|
||||
|
||||
export type Actions
|
||||
= SetPrivilegeOnLinuxAction
|
||||
| SetPrivilegeOnLinuxReplyAction
|
||||
@@ -85,4 +129,10 @@ export type Actions
|
||||
| SaveToKeyboardSuccessFailed
|
||||
| HideSaveToKeyboardButton
|
||||
| ResetUserConfigurationAction
|
||||
| UpdateFirmwareAction
|
||||
| UpdateFirmwareWithAction
|
||||
| UpdateFirmwareReplyAction
|
||||
| UpdateFirmwareSuccessAction
|
||||
| UpdateFirmwareFailedAction
|
||||
| UpdateFirmwareOkButtonAction
|
||||
;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Action } from '@ngrx/store';
|
||||
import { Actions, Effect, toPayload } from '@ngrx/effects';
|
||||
import { Actions, Effect } from '@ngrx/effects';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { NotifierService } from 'angular-notifier';
|
||||
|
||||
@@ -10,8 +10,16 @@ import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/operator/mergeMap';
|
||||
import 'rxjs/add/operator/catch';
|
||||
|
||||
import { AppStartInfo, Notification, NotificationType, LogService } from 'uhk-common';
|
||||
import { ActionTypes, AppStartedAction, DismissUndoNotificationAction, ToggleAddonMenuAction } from '../actions/app';
|
||||
import { AppStartInfo, LogService, Notification, NotificationType } from 'uhk-common';
|
||||
import {
|
||||
ActionTypes,
|
||||
AppStartedAction,
|
||||
DismissUndoNotificationAction,
|
||||
ProcessAppStartInfoAction,
|
||||
ShowNotificationAction,
|
||||
ToggleAddonMenuAction,
|
||||
UndoLastAction, UpdateAgentVersionInformationAction
|
||||
} from '../actions/app';
|
||||
import { AppRendererService } from '../../services/app-renderer.service';
|
||||
import { AppUpdateRendererService } from '../../services/app-update-renderer.service';
|
||||
import { ConnectionStateChangedAction, PermissionStateChangedAction } from '../actions/device';
|
||||
@@ -32,8 +40,8 @@ export class ApplicationEffects {
|
||||
|
||||
@Effect({dispatch: false})
|
||||
showNotification$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.APP_SHOW_NOTIFICATION)
|
||||
.map(toPayload)
|
||||
.ofType<ShowNotificationAction>(ActionTypes.APP_SHOW_NOTIFICATION)
|
||||
.map(action => action.payload)
|
||||
.do((notification: Notification) => {
|
||||
if (notification.type === NotificationType.Undoable) {
|
||||
return;
|
||||
@@ -43,25 +51,27 @@ export class ApplicationEffects {
|
||||
|
||||
@Effect()
|
||||
processStartInfo$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.APP_PROCESS_START_INFO)
|
||||
.map(toPayload)
|
||||
.ofType<ProcessAppStartInfoAction>(ActionTypes.APP_PROCESS_START_INFO)
|
||||
.map(action => action.payload)
|
||||
.mergeMap((appInfo: AppStartInfo) => {
|
||||
this.logService.debug('[AppEffect][processStartInfo] payload:', appInfo);
|
||||
return [
|
||||
new ToggleAddonMenuAction(appInfo.commandLineArgs.addons),
|
||||
new ConnectionStateChangedAction(appInfo.deviceConnected),
|
||||
new PermissionStateChangedAction(appInfo.hasPermission)
|
||||
new PermissionStateChangedAction(appInfo.hasPermission),
|
||||
new UpdateAgentVersionInformationAction(appInfo.agentVersionInfo)
|
||||
];
|
||||
});
|
||||
|
||||
@Effect() undoLastNotification$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.UNDO_LAST)
|
||||
.map(toPayload)
|
||||
.ofType<UndoLastAction>(ActionTypes.UNDO_LAST)
|
||||
.map(action => action.payload)
|
||||
.mergeMap((action: Action) => [action, new DismissUndoNotificationAction()]);
|
||||
|
||||
constructor(private actions$: Actions,
|
||||
private notifierService: NotifierService,
|
||||
private appUpdateRendererService: AppUpdateRendererService,
|
||||
private appRendererService: AppRendererService,
|
||||
private logService: LogService) { }
|
||||
private logService: LogService) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'rxjs/add/operator/mergeMap';
|
||||
import 'rxjs/add/operator/withLatestFrom';
|
||||
import 'rxjs/add/operator/switchMap';
|
||||
|
||||
import { NotificationType, IpcResponse, UhkBuffer, UserConfiguration } from 'uhk-common';
|
||||
import { IpcResponse, NotificationType, UhkBuffer, UserConfiguration } from 'uhk-common';
|
||||
import {
|
||||
ActionTypes,
|
||||
ConnectionStateChangedAction,
|
||||
@@ -21,15 +21,22 @@ import {
|
||||
PermissionStateChangedAction,
|
||||
SaveConfigurationAction,
|
||||
SaveToKeyboardSuccessAction,
|
||||
SaveToKeyboardSuccessFailed
|
||||
SaveToKeyboardSuccessFailed,
|
||||
SetPrivilegeOnLinuxReplyAction,
|
||||
UpdateFirmwareAction,
|
||||
UpdateFirmwareFailedAction,
|
||||
UpdateFirmwareOkButtonAction,
|
||||
UpdateFirmwareReplyAction,
|
||||
UpdateFirmwareSuccessAction,
|
||||
UpdateFirmwareWithAction
|
||||
} from '../actions/device';
|
||||
import { DeviceRendererService } from '../../services/device-renderer.service';
|
||||
import { ShowNotificationAction } from '../actions/app';
|
||||
import { AppState } from '../index';
|
||||
import {
|
||||
ActionTypes as UserConfigActions,
|
||||
LoadConfigFromDeviceAction,
|
||||
LoadResetUserConfigurationAction,
|
||||
ActionTypes as UserConfigActions
|
||||
LoadResetUserConfigurationAction
|
||||
} from '../actions/user-config';
|
||||
import { DefaultUserConfigurationService } from '../../services/default-user-configuration.service';
|
||||
|
||||
@@ -37,8 +44,8 @@ import { DefaultUserConfigurationService } from '../../services/default-user-con
|
||||
export class DeviceEffects {
|
||||
@Effect()
|
||||
deviceConnectionStateChange$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.CONNECTION_STATE_CHANGED)
|
||||
.map(toPayload)
|
||||
.ofType<ConnectionStateChangedAction>(ActionTypes.CONNECTION_STATE_CHANGED)
|
||||
.map(action => action.payload)
|
||||
.do((connected: boolean) => {
|
||||
if (connected) {
|
||||
this.router.navigate(['/']);
|
||||
@@ -56,9 +63,9 @@ export class DeviceEffects {
|
||||
});
|
||||
|
||||
@Effect({dispatch: false})
|
||||
permissionStateChange$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.PERMISSION_STATE_CHANGED)
|
||||
.map(toPayload)
|
||||
permissionStateChange$: Observable<boolean> = this.actions$
|
||||
.ofType<PermissionStateChangedAction>(ActionTypes.PERMISSION_STATE_CHANGED)
|
||||
.map(action => action.payload)
|
||||
.do((hasPermission: boolean) => {
|
||||
if (hasPermission) {
|
||||
this.router.navigate(['/detection']);
|
||||
@@ -77,8 +84,8 @@ export class DeviceEffects {
|
||||
|
||||
@Effect()
|
||||
setPrivilegeOnLinuxReply$: Observable<Action> = this.actions$
|
||||
.ofType(ActionTypes.SET_PRIVILEGE_ON_LINUX_REPLY)
|
||||
.map(toPayload)
|
||||
.ofType<SetPrivilegeOnLinuxReplyAction>(ActionTypes.SET_PRIVILEGE_ON_LINUX_REPLY)
|
||||
.map(action => action.payload)
|
||||
.mergeMap((response: any) => {
|
||||
if (response.success) {
|
||||
return [
|
||||
@@ -142,6 +149,30 @@ export class DeviceEffects {
|
||||
.ofType(UserConfigActions.LOAD_RESET_USER_CONFIGURATION)
|
||||
.switchMap(() => Observable.of(new SaveConfigurationAction()));
|
||||
|
||||
@Effect({dispatch: false}) updateFirmware$ = this.actions$
|
||||
.ofType<UpdateFirmwareAction>(ActionTypes.UPDATE_FIRMWARE)
|
||||
.do(() => this.deviceRendererService.updateFirmware());
|
||||
|
||||
@Effect({dispatch: false}) updateFirmwareWith$ = this.actions$
|
||||
.ofType<UpdateFirmwareWithAction>(ActionTypes.UPDATE_FIRMWARE_WITH)
|
||||
.map(action => action.payload)
|
||||
.do(data => this.deviceRendererService.updateFirmware(data));
|
||||
|
||||
@Effect() updateFirmwareReply$ = this.actions$
|
||||
.ofType<UpdateFirmwareReplyAction>(ActionTypes.UPDATE_FIRMWARE_REPLY)
|
||||
.map(action => action.payload)
|
||||
.switchMap((response: IpcResponse) => {
|
||||
if (response.success) {
|
||||
return Observable.of(new UpdateFirmwareSuccessAction());
|
||||
}
|
||||
|
||||
return Observable.of(new UpdateFirmwareFailedAction(response.error));
|
||||
});
|
||||
|
||||
@Effect({dispatch: false}) updateFirmwareOkButton$ = this.actions$
|
||||
.ofType<UpdateFirmwareOkButtonAction>(ActionTypes.UPDATE_FIRMWARE_OK_BUTTON)
|
||||
.do(() => this.deviceRendererService.startConnectionPoller());
|
||||
|
||||
constructor(private actions$: Actions,
|
||||
private router: Router,
|
||||
private deviceRendererService: DeviceRendererService,
|
||||
|
||||
@@ -49,6 +49,7 @@ export const runningInElectron = createSelector(appState, fromApp.runningInElect
|
||||
export const getHardwareConfiguration = createSelector(appState, fromApp.getHardwareConfiguration);
|
||||
export const getKeyboardLayout = createSelector(appState, fromApp.getKeyboardLayout);
|
||||
export const deviceConfigurationLoaded = createSelector(appState, fromApp.deviceConfigurationLoaded);
|
||||
export const getAgentVersionInfo = createSelector(appState, fromApp.getAgentVersionInfo);
|
||||
|
||||
export const appUpdateState = (state: AppState) => state.appUpdate;
|
||||
export const getShowAppUpdateAvailable = createSelector(appUpdateState, fromAppUpdate.getShowAppUpdateAvailable);
|
||||
@@ -70,3 +71,8 @@ export const saveToKeyboardStateSelector = createSelector(deviceState, fromDevic
|
||||
export const saveToKeyboardState = createSelector(runningInElectron, saveToKeyboardStateSelector, (electron, state) => {
|
||||
return electron ? state : initProgressButtonState;
|
||||
});
|
||||
export const updatingFirmware = createSelector(deviceState, fromDevice.updatingFirmware);
|
||||
export const xtermLog = createSelector(deviceState, fromDevice.xtermLog);
|
||||
export const firmwareOkButtonDisabled = createSelector(deviceState, fromDevice.firmwareOkButtonDisabled);
|
||||
// tslint:disable-next-line: max-line-length
|
||||
export const flashFirmwareButtonDisbabled = createSelector(runningInElectron, deviceState, (electron, state: fromDevice.State) => !electron || state.updatingFirmware);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { ROUTER_NAVIGATION } from '@ngrx/router-store';
|
||||
import { Action } from '@ngrx/store';
|
||||
import { VersionInformation } from 'uhk-common';
|
||||
|
||||
import { HardwareConfiguration, runInElectron, Notification, NotificationType, UserConfiguration } from 'uhk-common';
|
||||
import { HardwareConfiguration, Notification, NotificationType, runInElectron, UserConfiguration } from 'uhk-common';
|
||||
import { ActionTypes, ShowNotificationAction } from '../actions/app';
|
||||
import { ActionTypes as UserConfigActionTypes } from '../actions/user-config';
|
||||
import { ActionTypes as DeviceActionTypes } from '../actions/device';
|
||||
@@ -16,6 +17,7 @@ export interface State {
|
||||
runningInElectron: boolean;
|
||||
configLoading: boolean;
|
||||
hardwareConfig?: HardwareConfiguration;
|
||||
agentVersionInfo?: VersionInformation;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
@@ -99,7 +101,7 @@ export function reducer(state = initialState, action: Action & { payload: any })
|
||||
hardwareConfig: action.payload
|
||||
};
|
||||
|
||||
case DeviceActionTypes.CONNECTION_STATE_CHANGED:
|
||||
case DeviceActionTypes.CONNECTION_STATE_CHANGED: {
|
||||
|
||||
if (action.payload === true) {
|
||||
return state;
|
||||
@@ -109,7 +111,13 @@ export function reducer(state = initialState, action: Action & { payload: any })
|
||||
...state,
|
||||
hardwareConfig: null
|
||||
};
|
||||
}
|
||||
|
||||
case ActionTypes.UPDATE_AGENT_VERSION_INFORMATION:
|
||||
return {
|
||||
...state,
|
||||
agentVersionInfo: action.payload
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
@@ -128,3 +136,4 @@ export const getKeyboardLayout = (state: State): KeyboardLayout => {
|
||||
return KeyboardLayout.ANSI;
|
||||
};
|
||||
export const deviceConfigurationLoaded = (state: State) => !state.runningInElectron ? true : !!state.hardwareConfig;
|
||||
export const getAgentVersionInfo = (state: State) => state.agentVersionInfo || {} as VersionInformation;
|
||||
|
||||
@@ -1,21 +1,31 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import {
|
||||
ActionTypes, ConnectionStateChangedAction, HideSaveToKeyboardButton, PermissionStateChangedAction,
|
||||
SaveConfigurationAction
|
||||
ActionTypes,
|
||||
ConnectionStateChangedAction,
|
||||
PermissionStateChangedAction,
|
||||
SaveConfigurationAction, UpdateFirmwareFailedAction
|
||||
} from '../actions/device';
|
||||
import { ActionTypes as AppActions, ElectronMainLogReceivedAction } from '../actions/app';
|
||||
import { initProgressButtonState, ProgressButtonState } from './progress-button-state';
|
||||
import { XtermCssClass, XtermLog } from '../../models/xterm-log';
|
||||
|
||||
export interface State {
|
||||
connected: boolean;
|
||||
hasPermission: boolean;
|
||||
saveToKeyboard: ProgressButtonState;
|
||||
updatingFirmware: boolean;
|
||||
firmwareUpdateFinished: boolean;
|
||||
log: Array<XtermLog>;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
connected: true,
|
||||
hasPermission: true,
|
||||
saveToKeyboard: initProgressButtonState
|
||||
saveToKeyboard: initProgressButtonState,
|
||||
updatingFirmware: false,
|
||||
firmwareUpdateFinished: false,
|
||||
log: [{message: '', cssClass: XtermCssClass.standard}]
|
||||
};
|
||||
|
||||
export function reducer(state = initialState, action: Action) {
|
||||
@@ -89,11 +99,66 @@ export function reducer(state = initialState, action: Action) {
|
||||
saveToKeyboard: initProgressButtonState
|
||||
};
|
||||
}
|
||||
|
||||
case ActionTypes.UPDATE_FIRMWARE_WITH:
|
||||
case ActionTypes.UPDATE_FIRMWARE:
|
||||
return {
|
||||
...state,
|
||||
updatingFirmware: true,
|
||||
firmwareUpdateFinished: false,
|
||||
log: [{message: 'Start flashing firmware', cssClass: XtermCssClass.standard}]
|
||||
};
|
||||
|
||||
case ActionTypes.UPDATE_FIRMWARE_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
updatingFirmware: false,
|
||||
firmwareUpdateFinished: true
|
||||
};
|
||||
|
||||
case ActionTypes.UPDATE_FIRMWARE_FAILED: {
|
||||
const logEntry = {
|
||||
message: (action as UpdateFirmwareFailedAction).payload.message,
|
||||
cssClass: XtermCssClass.error
|
||||
};
|
||||
|
||||
return {
|
||||
...state,
|
||||
updatingFirmware: false,
|
||||
firmwareUpdateFinished: true,
|
||||
log: [...state.log, logEntry]
|
||||
};
|
||||
}
|
||||
|
||||
case AppActions.ELECTRON_MAIN_LOG_RECEIVED: {
|
||||
if (!state.updatingFirmware) {
|
||||
return state;
|
||||
}
|
||||
|
||||
const payload = (action as ElectronMainLogReceivedAction).payload;
|
||||
|
||||
if (payload.message.indexOf('UHK Device not found:') > -1) {
|
||||
return state;
|
||||
}
|
||||
|
||||
const logEntry = {
|
||||
message: payload.message,
|
||||
cssClass: payload.level === 'error' ? XtermCssClass.error : XtermCssClass.standard
|
||||
};
|
||||
|
||||
return {
|
||||
...state,
|
||||
log: [...state.log, logEntry]
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export const isDeviceConnected = (state: State) => state.connected;
|
||||
export const updatingFirmware = (state: State) => state.updatingFirmware;
|
||||
export const isDeviceConnected = (state: State) => state.connected || state.updatingFirmware;
|
||||
export const hasDevicePermission = (state: State) => state.hasPermission;
|
||||
export const getSaveToKeyboardState = (state: State) => state.saveToKeyboard;
|
||||
export const xtermLog = (state: State) => state.log;
|
||||
export const firmwareOkButtonDisabled = (state: State) => !state.firmwareUpdateFinished;
|
||||
|
||||
Reference in New Issue
Block a user