feat: Show not supported OS on firmware page when relevant (#695)

This commit is contained in:
Róbert Kiss
2018-06-24 22:16:00 +02:00
committed by László Monda
parent 94cfd9d2e9
commit 114014fa13
9 changed files with 53 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
import { ipcMain, shell } from 'electron'; import { ipcMain, shell } from 'electron';
import { UhkHidDevice } from 'uhk-usb'; import { UhkHidDevice } from 'uhk-usb';
import * as os from 'os';
import { AppStartInfo, IpcEvents, LogService } from 'uhk-common'; import { AppStartInfo, IpcEvents, LogService } from 'uhk-common';
import { MainServiceBase } from './main-service-base'; import { MainServiceBase } from './main-service-base';
@@ -30,7 +31,9 @@ export class AppService extends MainServiceBase {
}, },
deviceConnected: deviceConnectionState.connected, deviceConnected: deviceConnectionState.connected,
hasPermission: deviceConnectionState.hasPermission, hasPermission: deviceConnectionState.hasPermission,
bootloaderActive: deviceConnectionState.bootloaderActive bootloaderActive: deviceConnectionState.bootloaderActive,
platform: process.platform as string,
osVersion: os.release()
}; };
this.logService.info('[AppService] getAppStartInfo response:', response); this.logService.info('[AppService] getAppStartInfo response:', response);
return event.sender.send(IpcEvents.app.getAppStartInfoReply, response); return event.sender.send(IpcEvents.app.getAppStartInfoReply, response);

View File

@@ -5,4 +5,6 @@ export interface AppStartInfo {
deviceConnected: boolean; deviceConnected: boolean;
hasPermission: boolean; hasPermission: boolean;
bootloaderActive: boolean; bootloaderActive: boolean;
platform: string;
osVersion: string;
} }

View File

@@ -12,7 +12,7 @@
Firmware {{ hardwareModules.rightModuleInfo.firmwareVersion }} is running on the right keyboard half. Firmware {{ hardwareModules.rightModuleInfo.firmwareVersion }} is running on the right keyboard half.
</p> </p>
<p>Please note that firmware update doesn't work on Windows 7, Windows Vista, and Windows XP. Use Windows 10, Windows 8, Linux, or OSX instead.</p> <p *ngIf="showUnsupportedOsToFirmwareUpgrade$ | async">Firmware update doesn't work on Windows 7, Windows Vista, and Windows XP. Use Windows 10, Windows 8, Linux, or OSX instead.</p>
<p>If the update process fails, disconnect every USB device from your computer including USB hubs, KVM switches, and every USB device. Then connect only your UHK and retry.</p> <p>If the update process fails, disconnect every USB device from your computer including USB hubs, KVM switches, and every USB device. Then connect only your UHK and retry.</p>

View File

@@ -2,15 +2,15 @@ import { Component, OnDestroy } from '@angular/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
import { HardwareModules, VersionInformation } from 'uhk-common'; import { Constants, HardwareModules, VersionInformation } from 'uhk-common';
import { Constants } from 'uhk-common';
import { OpenUrlInNewWindowAction } from '../../../store/actions/app';
import { OpenUrlInNewWindowAction } from '../../../store/actions/app';
import { import {
AppState, AppState,
flashFirmwareButtonDisbabled, flashFirmwareButtonDisbabled,
getAgentVersionInfo, getAgentVersionInfo,
getHardwareModules, getHardwareModules,
showUnsupportedOsToFirmwareUpgrade,
xtermLog xtermLog
} from '../../../store'; } from '../../../store';
import { UpdateFirmwareAction, UpdateFirmwareWithAction } from '../../../store/actions/device'; import { UpdateFirmwareAction, UpdateFirmwareWithAction } from '../../../store/actions/device';
@@ -31,6 +31,7 @@ export class DeviceFirmwareComponent implements OnDestroy {
getAgentVersionInfo$: Observable<VersionInformation>; getAgentVersionInfo$: Observable<VersionInformation>;
hardwareModulesSubscription: Subscription; hardwareModulesSubscription: Subscription;
hardwareModules: HardwareModules; hardwareModules: HardwareModules;
showUnsupportedOsToFirmwareUpgrade$: Observable<boolean>;
constructor(private store: Store<AppState>) { constructor(private store: Store<AppState>) {
this.flashFirmwareButtonDisbabled$ = store.select(flashFirmwareButtonDisbabled); this.flashFirmwareButtonDisbabled$ = store.select(flashFirmwareButtonDisbabled);
@@ -39,6 +40,7 @@ export class DeviceFirmwareComponent implements OnDestroy {
this.hardwareModulesSubscription = store.select(getHardwareModules).subscribe(data => { this.hardwareModulesSubscription = store.select(getHardwareModules).subscribe(data => {
this.hardwareModules = data; this.hardwareModules = data;
}); });
this.showUnsupportedOsToFirmwareUpgrade$ = store.select(showUnsupportedOsToFirmwareUpgrade);
} }
ngOnDestroy(): void { ngOnDestroy(): void {

View File

@@ -1,6 +1,6 @@
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { AppStartInfo, CommandLineArgs, HardwareConfiguration, Notification, type } from 'uhk-common'; import { AppStartInfo, HardwareConfiguration, Notification, type } from 'uhk-common';
import { ElectronLogEntry } from '../../models/xterm-log'; import { ElectronLogEntry } from '../../models/xterm-log';
const PREFIX = '[app] '; const PREFIX = '[app] ';
@@ -10,7 +10,7 @@ export const ActionTypes = {
APP_BOOTSRAPPED: type(PREFIX + 'bootstrapped'), APP_BOOTSRAPPED: type(PREFIX + 'bootstrapped'),
APP_STARTED: type(PREFIX + 'started'), APP_STARTED: type(PREFIX + 'started'),
APP_SHOW_NOTIFICATION: type(PREFIX + 'show notification'), APP_SHOW_NOTIFICATION: type(PREFIX + 'show notification'),
APPLY_COMMAND_LINE_ARGS: type(PREFIX + 'apply command line args'), APPLY_APP_START_INFO: type(PREFIX + 'apply command line args'),
APP_PROCESS_START_INFO: type(PREFIX + 'process start info'), APP_PROCESS_START_INFO: type(PREFIX + 'process start info'),
UNDO_LAST: type(PREFIX + 'undo last action'), UNDO_LAST: type(PREFIX + 'undo last action'),
UNDO_LAST_SUCCESS: type(PREFIX + 'undo last action success'), UNDO_LAST_SUCCESS: type(PREFIX + 'undo last action success'),
@@ -38,10 +38,10 @@ export class ShowNotificationAction implements Action {
} }
} }
export class ApplyCommandLineArgsAction implements Action { export class ApplyAppStartInfoAction implements Action {
type = ActionTypes.APPLY_COMMAND_LINE_ARGS; type = ActionTypes.APPLY_APP_START_INFO;
constructor(public payload: CommandLineArgs) { constructor(public payload: AppStartInfo) {
} }
} }
@@ -107,7 +107,7 @@ export type Actions
= AppStartedAction = AppStartedAction
| AppBootsrappedAction | AppBootsrappedAction
| ShowNotificationAction | ShowNotificationAction
| ApplyCommandLineArgsAction | ApplyAppStartInfoAction
| ProcessAppStartInfoAction | ProcessAppStartInfoAction
| UndoLastAction | UndoLastAction
| UndoLastSuccessAction | UndoLastSuccessAction

View File

@@ -13,7 +13,7 @@ import 'rxjs/add/operator/catch';
import { AppStartInfo, LogService, Notification, NotificationType } from 'uhk-common'; import { AppStartInfo, LogService, Notification, NotificationType } from 'uhk-common';
import { import {
ActionTypes, ActionTypes,
ApplyCommandLineArgsAction, ApplyAppStartInfoAction,
AppStartedAction, AppStartedAction,
DismissUndoNotificationAction, DismissUndoNotificationAction,
OpenUrlInNewWindowAction, OpenUrlInNewWindowAction,
@@ -65,7 +65,7 @@ export class ApplicationEffects {
.mergeMap((appInfo: AppStartInfo) => { .mergeMap((appInfo: AppStartInfo) => {
this.logService.debug('[AppEffect][processStartInfo] payload:', appInfo); this.logService.debug('[AppEffect][processStartInfo] payload:', appInfo);
return [ return [
new ApplyCommandLineArgsAction(appInfo.commandLineArgs), new ApplyAppStartInfoAction(appInfo),
new ConnectionStateChangedAction({ new ConnectionStateChangedAction({
connected: appInfo.deviceConnected, connected: appInfo.deviceConnected,
hasPermission: appInfo.hasPermission, hasPermission: appInfo.hasPermission,

View File

@@ -52,6 +52,7 @@ export const getKeyboardLayout = createSelector(appState, fromApp.getKeyboardLay
export const deviceConfigurationLoaded = createSelector(appState, fromApp.deviceConfigurationLoaded); export const deviceConfigurationLoaded = createSelector(appState, fromApp.deviceConfigurationLoaded);
export const getAgentVersionInfo = createSelector(appState, fromApp.getAgentVersionInfo); export const getAgentVersionInfo = createSelector(appState, fromApp.getAgentVersionInfo);
export const getPrivilegePageState = createSelector(appState, fromApp.getPrivilagePageState); export const getPrivilegePageState = createSelector(appState, fromApp.getPrivilagePageState);
export const runningOnNotSupportedWindows = createSelector(appState, fromApp.runningOnNotSupportedWindows);
export const appUpdateState = (state: AppState) => state.appUpdate; export const appUpdateState = (state: AppState) => state.appUpdate;
export const getShowAppUpdateAvailable = createSelector(appUpdateState, fromAppUpdate.getShowAppUpdateAvailable); export const getShowAppUpdateAvailable = createSelector(appUpdateState, fromAppUpdate.getShowAppUpdateAvailable);
@@ -81,6 +82,7 @@ export const getHardwareModules = createSelector(deviceState, fromDevice.getHard
export const getBackupUserConfigurationState = createSelector(deviceState, fromDevice.getBackupUserConfigurationState); export const getBackupUserConfigurationState = createSelector(deviceState, fromDevice.getBackupUserConfigurationState);
export const getRestoreUserConfiguration = createSelector(deviceState, fromDevice.getHasBackupUserConfiguration); export const getRestoreUserConfiguration = createSelector(deviceState, fromDevice.getHasBackupUserConfiguration);
export const bootloaderActive = createSelector(deviceState, fromDevice.bootloaderActive); export const bootloaderActive = createSelector(deviceState, fromDevice.bootloaderActive);
export const firmwareUpgradeFailed = createSelector(deviceState, fromDevice.firmwareUpgradeFailed);
export const getSideMenuPageState = createSelector( export const getSideMenuPageState = createSelector(
showAddonMenu, showAddonMenu,
@@ -106,3 +108,9 @@ export const getSideMenuPageState = createSelector(
); );
export const getRouterState = (state: AppState) => state.router; export const getRouterState = (state: AppState) => state.router;
export const showUnsupportedOsToFirmwareUpgrade = createSelector(
runningOnNotSupportedWindows,
firmwareUpgradeFailed,
(isUnsupportedOs,
hasFirmwareUpgradeFailed) => isUnsupportedOs && hasFirmwareUpgradeFailed);

View File

@@ -1,6 +1,7 @@
import { ROUTER_NAVIGATION } from '@ngrx/router-store'; import { ROUTER_NAVIGATION } from '@ngrx/router-store';
import { Action } from '@ngrx/store'; import { Action } from '@ngrx/store';
import { import {
AppStartInfo,
CommandLineArgs, CommandLineArgs,
HardwareConfiguration, HardwareConfiguration,
Notification, Notification,
@@ -29,6 +30,8 @@ export interface State {
agentVersionInfo?: VersionInformation; agentVersionInfo?: VersionInformation;
privilegeWhatWillThisDoClicked: boolean; privilegeWhatWillThisDoClicked: boolean;
permissionError?: any; permissionError?: any;
platform?: string;
osVersion?: string;
} }
export const initialState: State = { export const initialState: State = {
@@ -50,10 +53,14 @@ export function reducer(state = initialState, action: Action & { payload: any })
}; };
} }
case ActionTypes.APPLY_COMMAND_LINE_ARGS: { case ActionTypes.APPLY_APP_START_INFO: {
const payload = action.payload as AppStartInfo;
return { return {
...state, ...state,
commandLineArgs: action.payload commandLineArgs: payload.commandLineArgs,
platform: payload.platform,
osVersion: payload.osVersion
}; };
} }
@@ -172,3 +179,15 @@ export const getPrivilagePageState = (state: State): PrivilagePageSate => {
showWhatWillThisDoContent: state.privilegeWhatWillThisDoClicked || permissionSetupFailed showWhatWillThisDoContent: state.privilegeWhatWillThisDoClicked || permissionSetupFailed
}; };
}; };
export const runningOnNotSupportedWindows = (state: State): boolean => {
if (!state.osVersion || state.platform !== 'win32') {
return false;
}
const version = state.osVersion.split('.');
const osMajor = +version[0];
const osMinor = +version[1];
return osMajor < 6 || (osMajor === 6 && osMinor < 2);
};

View File

@@ -23,6 +23,7 @@ export interface State {
savingToKeyboard: boolean; savingToKeyboard: boolean;
updatingFirmware: boolean; updatingFirmware: boolean;
firmwareUpdateFinished: boolean; firmwareUpdateFinished: boolean;
firmwareUpdateFailed?: boolean;
modules: HardwareModules; modules: HardwareModules;
log: Array<XtermLog>; log: Array<XtermLog>;
restoringUserConfiguration: boolean; restoringUserConfiguration: boolean;
@@ -136,6 +137,7 @@ export function reducer(state = initialState, action: Action): State {
...state, ...state,
updatingFirmware: false, updatingFirmware: false,
firmwareUpdateFinished: true, firmwareUpdateFinished: true,
firmwareUpdateFailed: false,
modules: (action as UpdateFirmwareSuccessAction).payload modules: (action as UpdateFirmwareSuccessAction).payload
}; };
@@ -150,6 +152,7 @@ export function reducer(state = initialState, action: Action): State {
...state, ...state,
updatingFirmware: false, updatingFirmware: false,
firmwareUpdateFinished: true, firmwareUpdateFinished: true,
firmwareUpdateFailed: true,
modules: data.modules, modules: data.modules,
log: [...state.log, logEntry] log: [...state.log, logEntry]
}; };
@@ -228,3 +231,4 @@ export const getBackupUserConfigurationState = (state: State): RestoreConfigurat
}; };
}; };
export const bootloaderActive = (state: State) => state.bootloaderActive; export const bootloaderActive = (state: State) => state.bootloaderActive;
export const firmwareUpgradeFailed = (state: State) => state.firmwareUpdateFailed;