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

View File

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

View File

@@ -12,7 +12,7 @@
Firmware {{ hardwareModules.rightModuleInfo.firmwareVersion }} is running on the right keyboard half.
</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>

View File

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

View File

@@ -1,6 +1,6 @@
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';
const PREFIX = '[app] ';
@@ -10,7 +10,7 @@ export const ActionTypes = {
APP_BOOTSRAPPED: type(PREFIX + 'bootstrapped'),
APP_STARTED: type(PREFIX + 'started'),
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'),
UNDO_LAST: type(PREFIX + 'undo last action'),
UNDO_LAST_SUCCESS: type(PREFIX + 'undo last action success'),
@@ -38,10 +38,10 @@ export class ShowNotificationAction implements Action {
}
}
export class ApplyCommandLineArgsAction implements Action {
type = ActionTypes.APPLY_COMMAND_LINE_ARGS;
export class ApplyAppStartInfoAction implements Action {
type = ActionTypes.APPLY_APP_START_INFO;
constructor(public payload: CommandLineArgs) {
constructor(public payload: AppStartInfo) {
}
}
@@ -107,7 +107,7 @@ export type Actions
= AppStartedAction
| AppBootsrappedAction
| ShowNotificationAction
| ApplyCommandLineArgsAction
| ApplyAppStartInfoAction
| ProcessAppStartInfoAction
| UndoLastAction
| UndoLastSuccessAction

View File

@@ -13,7 +13,7 @@ import 'rxjs/add/operator/catch';
import { AppStartInfo, LogService, Notification, NotificationType } from 'uhk-common';
import {
ActionTypes,
ApplyCommandLineArgsAction,
ApplyAppStartInfoAction,
AppStartedAction,
DismissUndoNotificationAction,
OpenUrlInNewWindowAction,
@@ -65,7 +65,7 @@ export class ApplicationEffects {
.mergeMap((appInfo: AppStartInfo) => {
this.logService.debug('[AppEffect][processStartInfo] payload:', appInfo);
return [
new ApplyCommandLineArgsAction(appInfo.commandLineArgs),
new ApplyAppStartInfoAction(appInfo),
new ConnectionStateChangedAction({
connected: appInfo.deviceConnected,
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 getAgentVersionInfo = createSelector(appState, fromApp.getAgentVersionInfo);
export const getPrivilegePageState = createSelector(appState, fromApp.getPrivilagePageState);
export const runningOnNotSupportedWindows = createSelector(appState, fromApp.runningOnNotSupportedWindows);
export const appUpdateState = (state: AppState) => state.appUpdate;
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 getRestoreUserConfiguration = createSelector(deviceState, fromDevice.getHasBackupUserConfiguration);
export const bootloaderActive = createSelector(deviceState, fromDevice.bootloaderActive);
export const firmwareUpgradeFailed = createSelector(deviceState, fromDevice.firmwareUpgradeFailed);
export const getSideMenuPageState = createSelector(
showAddonMenu,
@@ -106,3 +108,9 @@ export const getSideMenuPageState = createSelector(
);
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 { Action } from '@ngrx/store';
import {
AppStartInfo,
CommandLineArgs,
HardwareConfiguration,
Notification,
@@ -29,6 +30,8 @@ export interface State {
agentVersionInfo?: VersionInformation;
privilegeWhatWillThisDoClicked: boolean;
permissionError?: any;
platform?: string;
osVersion?: string;
}
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 {
...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
};
};
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;
updatingFirmware: boolean;
firmwareUpdateFinished: boolean;
firmwareUpdateFailed?: boolean;
modules: HardwareModules;
log: Array<XtermLog>;
restoringUserConfiguration: boolean;
@@ -136,6 +137,7 @@ export function reducer(state = initialState, action: Action): State {
...state,
updatingFirmware: false,
firmwareUpdateFinished: true,
firmwareUpdateFailed: false,
modules: (action as UpdateFirmwareSuccessAction).payload
};
@@ -150,6 +152,7 @@ export function reducer(state = initialState, action: Action): State {
...state,
updatingFirmware: false,
firmwareUpdateFinished: true,
firmwareUpdateFailed: true,
modules: data.modules,
log: [...state.log, logEntry]
};
@@ -228,3 +231,4 @@ export const getBackupUserConfigurationState = (state: State): RestoreConfigurat
};
};
export const bootloaderActive = (state: State) => state.bootloaderActive;
export const firmwareUpgradeFailed = (state: State) => state.firmwareUpdateFailed;