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,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,
|
||||
|
||||
Reference in New Issue
Block a user