From 3ee6c680a1504a8e8e9ea9a4d4d682560529a607 Mon Sep 17 00:00:00 2001 From: Mikko Lakomaa Date: Sat, 13 Jan 2018 18:10:21 +0200 Subject: [PATCH] Agent menu (#540) * Add generate version module script * Remove Fork me on GitHub banner * Add app-version.ts * Revert "Add app-version.ts" This reverts commit fe1a37e6316b2ca2a773e61c449a5661cd17c765. * Add app-version.ts * Add agent icon class * Move settings component under agent folder * Add AboutComponent * Add agent routes * Add index.ts for agent folder * Fix agent folder imports in shared module * Add agent menu to side menu, with Settings and About pages under it * Fix agent icon alignment in side menu * Simplify About page * Make Agent menu 0 level in side menu * Remove bottom Settings menu * Fix Agent menu closing if My UHK is closed in side menu * Fix version text alignment in auto update settings * Remove github fork ribbon styles * use package.json instead of app-version.ts * fix OpenUrlInNewWindow naming * fix lint request * fix: firmware download url calculation --- package.json | 4 ++ packages/uhk-agent/src/package.json | 6 +-- .../uhk-agent/src/services/app.service.ts | 38 ++++--------------- .../uhk-common/src/models/app-start-info.ts | 5 --- packages/uhk-common/src/util/constants.ts | 4 +- packages/uhk-common/src/util/index.ts | 1 + packages/uhk-common/src/util/ipcEvents.ts | 1 + packages/uhk-web/src/app/app.component.html | 3 -- packages/uhk-web/src/app/app.component.scss | 33 ---------------- packages/uhk-web/src/app/app.routes.ts | 4 +- .../agent/about/about.component.html | 10 +++++ .../agent/about/about.component.scss | 20 ++++++++++ .../components/agent/about/about.component.ts | 27 +++++++++++++ .../src/app/components/agent/agent.routes.ts | 15 ++++++++ .../uhk-web/src/app/components/agent/index.ts | 3 ++ .../settings/settings.component.html | 0 .../settings/settings.component.scss | 0 .../settings/settings.component.ts | 10 ++--- .../auto-update-settings.html | 2 +- .../src/app/components/settings/index.ts | 2 - .../components/settings/settings.routes.ts | 10 ----- .../side-menu/side-menu.component.html | 27 +++++++++---- .../side-menu/side-menu.component.scss | 4 ++ .../src/app/services/app-renderer.service.ts | 5 +++ packages/uhk-web/src/app/shared.module.ts | 3 +- packages/uhk-web/src/app/store/actions/app.ts | 20 +++++----- packages/uhk-web/src/app/store/effects/app.ts | 28 +++++++++----- .../src/app/store/reducers/app.reducer.ts | 9 ++--- packages/uhk-web/src/app/util/index.ts | 1 + .../uhk-web/src/app/util/version-helper.ts | 22 +++++++++++ .../uhk-web/src/styles/uhk-icons/uhk-css.svg | 2 +- .../src/styles/uhk-icons/uhk-icon.scss | 5 +++ .../uhk-web/src/svgs/icons/agent-icon.svg | 10 +++++ scripts/download-firmware.js | 2 +- 34 files changed, 199 insertions(+), 137 deletions(-) create mode 100644 packages/uhk-web/src/app/components/agent/about/about.component.html create mode 100644 packages/uhk-web/src/app/components/agent/about/about.component.scss create mode 100644 packages/uhk-web/src/app/components/agent/about/about.component.ts create mode 100644 packages/uhk-web/src/app/components/agent/agent.routes.ts create mode 100644 packages/uhk-web/src/app/components/agent/index.ts rename packages/uhk-web/src/app/components/{ => agent}/settings/settings.component.html (100%) rename packages/uhk-web/src/app/components/{ => agent}/settings/settings.component.scss (100%) rename packages/uhk-web/src/app/components/{ => agent}/settings/settings.component.ts (80%) delete mode 100644 packages/uhk-web/src/app/components/settings/index.ts delete mode 100644 packages/uhk-web/src/app/components/settings/settings.routes.ts create mode 100644 packages/uhk-web/src/app/util/version-helper.ts create mode 100644 packages/uhk-web/src/svgs/icons/agent-icon.svg diff --git a/package.json b/package.json index 1a2e12df..615675e8 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,10 @@ "author": "Ultimate Gadget Laboratories", "main": "electron/dist/electron-main.js", "version": "1.0.4", + "firmwareVersion": "8.0.0", + "deviceProtocolVersion": "4.0.0", + "userConfigVersion": "4.0.0", + "hardwareConfigVersion": "1.0.0", "description": "Agent is the configuration application of the Ultimate Hacking Keyboard.", "repository": { "type": "git", diff --git a/packages/uhk-agent/src/package.json b/packages/uhk-agent/src/package.json index 4ebe7722..ec070101 100644 --- a/packages/uhk-agent/src/package.json +++ b/packages/uhk-agent/src/package.json @@ -15,9 +15,5 @@ }, "dependencies": { "node-hid": "0.5.7" - }, - "firmwareVersion": "8.0.0", - "deviceProtocolVersion": "4.0.0", - "userConfigVersion": "4.0.0", - "hardwareConfigVersion": "1.0.0" + } } diff --git a/packages/uhk-agent/src/services/app.service.ts b/packages/uhk-agent/src/services/app.service.ts index d095bb87..617e624f 100644 --- a/packages/uhk-agent/src/services/app.service.ts +++ b/packages/uhk-agent/src/services/app.service.ts @@ -1,7 +1,5 @@ -import { BrowserWindow, ipcMain } from 'electron'; +import { BrowserWindow, ipcMain, shell } from 'electron'; import { UhkHidDevice } from 'uhk-usb'; -import { readFile } from 'fs'; -import { join } from 'path'; import { AppStartInfo, IpcEvents, LogService } from 'uhk-common'; import { MainServiceBase } from './main-service-base'; @@ -18,53 +16,31 @@ export class AppService extends MainServiceBase { ipcMain.on(IpcEvents.app.getAppStartInfo, this.handleAppStartInfo.bind(this)); ipcMain.on(IpcEvents.app.exit, this.exit.bind(this)); + ipcMain.on(IpcEvents.app.openUrl, this.openUrl.bind(this)); logService.info('[AppService] init success'); } private async handleAppStartInfo(event: Electron.Event) { this.logService.info('[AppService] getAppStartInfo'); - const packageJson = await this.getPackageJson(); - const response: AppStartInfo = { commandLineArgs: { addons: this.options.addons || false, autoWriteConfig: this.options['auto-write-config'] || false }, deviceConnected: this.uhkHidDeviceService.deviceConnected(), - hasPermission: this.uhkHidDeviceService.hasPermission(), - agentVersionInfo: { - version: packageJson.version, - firmwareVersion: packageJson.firmwareVersion, - deviceProtocolVersion: packageJson.deviceProtocolVersion, - moduleProtocolVersion: packageJson.moduleProtocolVersion, - userConfigVersion: packageJson.userConfigVersion, - hardwareConfigVersion: packageJson.hardwareConfigVersion - } + hasPermission: this.uhkHidDeviceService.hasPermission() }; this.logService.info('[AppService] getAppStartInfo response:', response); return event.sender.send(IpcEvents.app.getAppStartInfoReply, response); } - /** - * Read the package.json that delivered with the bundle. Do not use require('package.json') - * because the deploy process change the package.json after the build - * @returns {Promise} - */ - private async getPackageJson(): Promise { - return new Promise((resolve, reject) => { - readFile(join(__dirname, 'package.json'), {encoding: 'utf-8'}, (err, data) => { - if (err) { - return reject(err); - } - - resolve(JSON.parse(data)); - }); - }); - } - private exit() { this.logService.info('[AppService] exit'); this.win.close(); } + + private openUrl(event: Electron.Event, urls: Array) { + shell.openExternal(urls[0]); + } } diff --git a/packages/uhk-common/src/models/app-start-info.ts b/packages/uhk-common/src/models/app-start-info.ts index 126e1b5e..25d92d11 100644 --- a/packages/uhk-common/src/models/app-start-info.ts +++ b/packages/uhk-common/src/models/app-start-info.ts @@ -1,12 +1,7 @@ import { CommandLineArgs } from './command-line-args'; -import { VersionInformation } from './version-information'; export interface AppStartInfo { commandLineArgs: CommandLineArgs; deviceConnected: boolean; hasPermission: boolean; - /** - * This property contains the version information of the deployed agent components - */ - agentVersionInfo: VersionInformation; } diff --git a/packages/uhk-common/src/util/constants.ts b/packages/uhk-common/src/util/constants.ts index 0b3e32e3..c9cc8a3d 100644 --- a/packages/uhk-common/src/util/constants.ts +++ b/packages/uhk-common/src/util/constants.ts @@ -1,5 +1,3 @@ export namespace Constants { - export const VENDOR_ID = 0x1D50; - export const PRODUCT_ID = 0x6122; - export const MAX_PAYLOAD_SIZE = 64; + export const AGENT_GITHUB_URL = 'https://github.com/UltimateHackingKeyboard/agent'; } diff --git a/packages/uhk-common/src/util/index.ts b/packages/uhk-common/src/util/index.ts index d8af9552..6cba937e 100644 --- a/packages/uhk-common/src/util/index.ts +++ b/packages/uhk-common/src/util/index.ts @@ -1,5 +1,6 @@ export { IpcEvents } from './ipcEvents'; export * from './log'; +export * from './constants'; // Source: http://stackoverflow.com/questions/13720256/javascript-regex-camelcase-to-sentence export function camelCaseToSentence(camelCasedText: string): string { diff --git a/packages/uhk-common/src/util/ipcEvents.ts b/packages/uhk-common/src/util/ipcEvents.ts index 0ce2a7d6..c31badf1 100644 --- a/packages/uhk-common/src/util/ipcEvents.ts +++ b/packages/uhk-common/src/util/ipcEvents.ts @@ -3,6 +3,7 @@ class App { public static readonly getAppStartInfo = 'app-get-start-info'; public static readonly getAppStartInfoReply = 'app-get-start-info-reply'; public static readonly exit = 'app-exit'; + public static readonly openUrl = 'open-url'; } class AutoUpdate { diff --git a/packages/uhk-web/src/app/app.component.html b/packages/uhk-web/src/app/app.component.html index 16b5923f..c847097f 100644 --- a/packages/uhk-web/src/app/app.component.html +++ b/packages/uhk-web/src/app/app.component.html @@ -7,9 +7,6 @@
-
- Fork me on GitHub -
+

+ + About +

+
+
Agent version: {{version}}
+
Agent on GitHub
+
+ diff --git a/packages/uhk-web/src/app/components/agent/about/about.component.scss b/packages/uhk-web/src/app/components/agent/about/about.component.scss new file mode 100644 index 00000000..9816fb38 --- /dev/null +++ b/packages/uhk-web/src/app/components/agent/about/about.component.scss @@ -0,0 +1,20 @@ +:host { + overflow-y: auto; + display: block; + height: 100%; + width: 100%; +} + +.agent { + &-version { + margin-bottom: 1rem; + + span { + font-weight: bold; + } + } +} + +.link-github { + cursor: pointer; +} diff --git a/packages/uhk-web/src/app/components/agent/about/about.component.ts b/packages/uhk-web/src/app/components/agent/about/about.component.ts new file mode 100644 index 00000000..85b39e30 --- /dev/null +++ b/packages/uhk-web/src/app/components/agent/about/about.component.ts @@ -0,0 +1,27 @@ +import { Component } from '@angular/core'; +import { Store } from '@ngrx/store'; +import { Constants } from 'uhk-common'; + +import { AppState } from '../../../store'; +import { getVersions } from '../../../util'; +import { OpenUrlInNewWindowAction } from '../../../store/actions/app'; + +@Component({ + selector: 'about-page', + templateUrl: './about.component.html', + styleUrls: ['./about.component.scss'], + host: { + 'class': 'container-fluid' + } +}) +export class AboutComponent { + version: string = getVersions().version; + + constructor(private store: Store) { + } + + openAgentGitHubPage(event) { + event.preventDefault(); + this.store.dispatch(new OpenUrlInNewWindowAction(Constants.AGENT_GITHUB_URL)); + } +} diff --git a/packages/uhk-web/src/app/components/agent/agent.routes.ts b/packages/uhk-web/src/app/components/agent/agent.routes.ts new file mode 100644 index 00000000..8400c98b --- /dev/null +++ b/packages/uhk-web/src/app/components/agent/agent.routes.ts @@ -0,0 +1,15 @@ +import { Routes } from '@angular/router'; + +import { SettingsComponent } from './settings/settings.component'; +import { AboutComponent } from './about/about.component'; + +export const agentRoutes: Routes = [ + { + path: 'settings', + component: SettingsComponent + }, + { + path: 'about', + component: AboutComponent + } +]; diff --git a/packages/uhk-web/src/app/components/agent/index.ts b/packages/uhk-web/src/app/components/agent/index.ts new file mode 100644 index 00000000..aa484a2d --- /dev/null +++ b/packages/uhk-web/src/app/components/agent/index.ts @@ -0,0 +1,3 @@ +export * from './agent.routes'; +export * from './about/about.component'; +export * from './settings/settings.component'; diff --git a/packages/uhk-web/src/app/components/settings/settings.component.html b/packages/uhk-web/src/app/components/agent/settings/settings.component.html similarity index 100% rename from packages/uhk-web/src/app/components/settings/settings.component.html rename to packages/uhk-web/src/app/components/agent/settings/settings.component.html diff --git a/packages/uhk-web/src/app/components/settings/settings.component.scss b/packages/uhk-web/src/app/components/agent/settings/settings.component.scss similarity index 100% rename from packages/uhk-web/src/app/components/settings/settings.component.scss rename to packages/uhk-web/src/app/components/agent/settings/settings.component.scss diff --git a/packages/uhk-web/src/app/components/settings/settings.component.ts b/packages/uhk-web/src/app/components/agent/settings/settings.component.ts similarity index 80% rename from packages/uhk-web/src/app/components/settings/settings.component.ts rename to packages/uhk-web/src/app/components/agent/settings/settings.component.ts index b195a801..7b7a0d6d 100644 --- a/packages/uhk-web/src/app/components/settings/settings.component.ts +++ b/packages/uhk-web/src/app/components/agent/settings/settings.component.ts @@ -2,13 +2,14 @@ import { Component } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs/Observable'; -import { AppState, getAutoUpdateSettings, getCheckingForUpdate } from '../../store'; +import { AppState, getAutoUpdateSettings, getCheckingForUpdate } from '../../../store'; import { CheckForUpdateNowAction, ToggleCheckForUpdateOnStartupAction, TogglePreReleaseFlagAction -} from '../../store/actions/auto-update-settings'; -import { AutoUpdateSettings } from '../../models/auto-update-settings'; +} from '../../../store/actions/auto-update-settings'; +import { AutoUpdateSettings } from '../../../models/auto-update-settings'; +import { getVersions } from '../../../util'; @Component({ selector: 'settings', @@ -19,8 +20,7 @@ import { AutoUpdateSettings } from '../../models/auto-update-settings'; } }) export class SettingsComponent { - // TODO: From where do we get the version number? The electron gives back in main process, but the web... - version = '1.0.0'; + version: string = getVersions().version; autoUpdateSettings$: Observable; checkingForUpdate$: Observable; diff --git a/packages/uhk-web/src/app/components/auto-update-settings/auto-update-settings.html b/packages/uhk-web/src/app/components/auto-update-settings/auto-update-settings.html index 16e201bc..5f88f95b 100644 --- a/packages/uhk-web/src/app/components/auto-update-settings/auto-update-settings.html +++ b/packages/uhk-web/src/app/components/auto-update-settings/auto-update-settings.html @@ -19,7 +19,7 @@
-

{{version}}

+

{{version}}

diff --git a/packages/uhk-web/src/app/components/settings/index.ts b/packages/uhk-web/src/app/components/settings/index.ts deleted file mode 100644 index 5d00f663..00000000 --- a/packages/uhk-web/src/app/components/settings/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './settings.component'; -export * from './settings.routes'; diff --git a/packages/uhk-web/src/app/components/settings/settings.routes.ts b/packages/uhk-web/src/app/components/settings/settings.routes.ts deleted file mode 100644 index 4aa5cec0..00000000 --- a/packages/uhk-web/src/app/components/settings/settings.routes.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Routes } from '@angular/router'; - -import { SettingsComponent } from './settings.component'; - -export const settingsRoutes: Routes = [ - { - path: 'settings', - component: SettingsComponent - } -]; diff --git a/packages/uhk-web/src/app/components/side-menu/side-menu.component.html b/packages/uhk-web/src/app/components/side-menu/side-menu.component.html index ce25c384..5394fdcb 100644 --- a/packages/uhk-web/src/app/components/side-menu/side-menu.component.html +++ b/packages/uhk-web/src/app/components/side-menu/side-menu.component.html @@ -117,14 +117,25 @@ - + + +
  • +
    + Agent + +
    +
      +
    • +
      + Settings +
      +
    • +
    • +
      + About +
      +
  • -
      -
    • - - Settings - -
    • -
    diff --git a/packages/uhk-web/src/app/components/side-menu/side-menu.component.scss b/packages/uhk-web/src/app/components/side-menu/side-menu.component.scss index b3a4d4a7..e7390fdc 100644 --- a/packages/uhk-web/src/app/components/side-menu/side-menu.component.scss +++ b/packages/uhk-web/src/app/components/side-menu/side-menu.component.scss @@ -64,6 +64,10 @@ ul { display: none; cursor: pointer; } + + .uhk-icon-agent-icon { + margin-left: -3px; + } } &__level-2 { diff --git a/packages/uhk-web/src/app/services/app-renderer.service.ts b/packages/uhk-web/src/app/services/app-renderer.service.ts index bcb44b10..edeb729c 100644 --- a/packages/uhk-web/src/app/services/app-renderer.service.ts +++ b/packages/uhk-web/src/app/services/app-renderer.service.ts @@ -26,6 +26,11 @@ export class AppRendererService { this.ipcRenderer.send(IpcEvents.app.exit); } + openUrl(url: string): void { + this.logService.info(`[AppRendererService] open url: ${url}`); + this.ipcRenderer.send(IpcEvents.app.openUrl, url); + } + private registerEvents() { this.ipcRenderer.on(IpcEvents.app.getAppStartInfoReply, (event: string, arg: AppStartInfo) => { this.dispachStoreAction(new ProcessAppStartInfoAction(arg)); diff --git a/packages/uhk-web/src/app/shared.module.ts b/packages/uhk-web/src/app/shared.module.ts index a21f8a68..eb101e23 100644 --- a/packages/uhk-web/src/app/shared.module.ts +++ b/packages/uhk-web/src/app/shared.module.ts @@ -43,7 +43,7 @@ import { } from './components/popover/tab'; import { CaptureKeystrokeButtonComponent } from './components/popover/widgets/capture-keystroke'; import { IconComponent } from './components/popover/widgets/icon'; -import { SettingsComponent } from './components/settings'; +import { AboutComponent, SettingsComponent } from './components/agent'; import { SideMenuComponent } from './components/side-menu'; import { SvgKeyboardComponent } from './components/svg/keyboard'; import { @@ -152,6 +152,7 @@ import { SliderWrapperComponent } from './components/slider-wrapper/slider-wrapp MacroTextTabComponent, MacroNotFoundComponent, AddOnComponent, + AboutComponent, SettingsComponent, KeyboardSliderComponent, CancelableDirective, diff --git a/packages/uhk-web/src/app/store/actions/app.ts b/packages/uhk-web/src/app/store/actions/app.ts index 5e79976c..76bd5aa0 100644 --- a/packages/uhk-web/src/app/store/actions/app.ts +++ b/packages/uhk-web/src/app/store/actions/app.ts @@ -1,6 +1,6 @@ import { Action } from '@ngrx/store'; -import { AppStartInfo, CommandLineArgs, HardwareConfiguration, Notification, type, VersionInformation } from 'uhk-common'; +import { AppStartInfo, CommandLineArgs, HardwareConfiguration, Notification, type } from 'uhk-common'; import { ElectronLogEntry } from '../../models/xterm-log'; const PREFIX = '[app] '; @@ -16,8 +16,8 @@ export const ActionTypes = { 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'), - UPDATE_AGENT_VERSION_INFORMATION: type(PREFIX + 'update agent version information'), - ELECTRON_MAIN_LOG_RECEIVED: type(PREFIX + 'Electron main log received') + ELECTRON_MAIN_LOG_RECEIVED: type(PREFIX + 'Electron main log received'), + OPEN_URL_IN_NEW_WINDOW: type(PREFIX + 'Open URL in new Window') }; export class AppBootsrappedAction implements Action { @@ -66,18 +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 class OpenUrlInNewWindowAction implements Action { + type = ActionTypes.OPEN_URL_IN_NEW_WINDOW; + + constructor(public payload: string) {} +} + export type Actions = AppStartedAction | AppBootsrappedAction @@ -88,6 +88,6 @@ export type Actions | UndoLastSuccessAction | DismissUndoNotificationAction | LoadHardwareConfigurationSuccessAction - | UpdateAgentVersionInformationAction | ElectronMainLogReceivedAction + | OpenUrlInNewWindowAction ; diff --git a/packages/uhk-web/src/app/store/effects/app.ts b/packages/uhk-web/src/app/store/effects/app.ts index 01ae17e1..f49cb391 100644 --- a/packages/uhk-web/src/app/store/effects/app.ts +++ b/packages/uhk-web/src/app/store/effects/app.ts @@ -16,19 +16,15 @@ import { ApplyCommandLineArgsAction, AppStartedAction, DismissUndoNotificationAction, + OpenUrlInNewWindowAction, ProcessAppStartInfoAction, ShowNotificationAction, - UndoLastAction, - UpdateAgentVersionInformationAction + UndoLastAction } from '../actions/app'; import { AppRendererService } from '../../services/app-renderer.service'; import { AppUpdateRendererService } from '../../services/app-update-renderer.service'; -import { - ActionTypes as DeviceActions, - ConnectionStateChangedAction, - SaveToKeyboardSuccessAction -} from '../actions/device'; -import { AppState, autoWriteUserConfiguration } from '../index'; +import { ActionTypes as DeviceActions, ConnectionStateChangedAction, SaveToKeyboardSuccessAction } from '../actions/device'; +import { AppState, autoWriteUserConfiguration, runningInElectron } from '../index'; @Injectable() export class ApplicationEffects { @@ -66,8 +62,7 @@ export class ApplicationEffects { new ConnectionStateChangedAction({ connected: appInfo.deviceConnected, hasPermission: appInfo.hasPermission - }), - new UpdateAgentVersionInformationAction(appInfo.agentVersionInfo) + }) ]; }); @@ -85,6 +80,19 @@ export class ApplicationEffects { } }); + @Effect({dispatch: false}) openUrlInNewWindow$ = this.actions$ + .ofType(ActionTypes.OPEN_URL_IN_NEW_WINDOW) + .withLatestFrom(this.store.select(runningInElectron)) + .do(([action, inElectron]) => { + const url = action.payload; + + if (inElectron) { + this.appRendererService.openUrl(url); + } else { + window.open(url, '_blank'); + } + }); + constructor(private actions$: Actions, private notifierService: NotifierService, private appUpdateRendererService: AppUpdateRendererService, diff --git a/packages/uhk-web/src/app/store/reducers/app.reducer.ts b/packages/uhk-web/src/app/store/reducers/app.reducer.ts index d7b198d2..9272eb50 100644 --- a/packages/uhk-web/src/app/store/reducers/app.reducer.ts +++ b/packages/uhk-web/src/app/store/reducers/app.reducer.ts @@ -7,6 +7,7 @@ import { ActionTypes, ShowNotificationAction } from '../actions/app'; import { ActionTypes as UserConfigActionTypes } from '../actions/user-config'; import { ActionTypes as DeviceActionTypes } from '../actions/device'; import { KeyboardLayout } from '../../keyboard/keyboard-layout.enum'; +import { getVersions } from '../../util'; export interface State { started: boolean; @@ -27,7 +28,8 @@ export const initialState: State = { autoWriteUserConfiguration: false, navigationCountAfterNotification: 0, runningInElectron: runInElectron(), - configLoading: true + configLoading: true, + agentVersionInfo: getVersions() }; export function reducer(state = initialState, action: Action & { payload: any }) { @@ -116,11 +118,6 @@ export function reducer(state = initialState, action: Action & { payload: any }) }; } - case ActionTypes.UPDATE_AGENT_VERSION_INFORMATION: - return { - ...state, - agentVersionInfo: action.payload - }; default: return state; } diff --git a/packages/uhk-web/src/app/util/index.ts b/packages/uhk-web/src/app/util/index.ts index ffa5f8cf..97a932e1 100644 --- a/packages/uhk-web/src/app/util/index.ts +++ b/packages/uhk-web/src/app/util/index.ts @@ -1,2 +1,3 @@ export * from './html-helper'; export * from './validators'; +export * from './version-helper'; diff --git a/packages/uhk-web/src/app/util/version-helper.ts b/packages/uhk-web/src/app/util/version-helper.ts new file mode 100644 index 00000000..ec426c9d --- /dev/null +++ b/packages/uhk-web/src/app/util/version-helper.ts @@ -0,0 +1,22 @@ +import { VersionInformation } from 'uhk-common'; + +const collectVersions = (): VersionInformation => { + const pkgJson = require('../../../../../package.json'); + return { + version: pkgJson['version'], + firmwareVersion: pkgJson['firmwareVersion'], + deviceProtocolVersion: pkgJson['deviceProtocolVersion'], + moduleProtocolVersion: pkgJson['moduleProtocolVersion'], + userConfigVersion: pkgJson['userConfigVersion'], + hardwareConfigVersion: pkgJson['hardwareConfigVersion'] + }; +}; + +let versions: VersionInformation; + +export const getVersions = (): VersionInformation => { + if (!versions) { + versions = collectVersions(); + } + return versions; +}; diff --git a/packages/uhk-web/src/styles/uhk-icons/uhk-css.svg b/packages/uhk-web/src/styles/uhk-icons/uhk-css.svg index 11e9b5af..ab0fad11 100644 --- a/packages/uhk-web/src/styles/uhk-icons/uhk-css.svg +++ b/packages/uhk-web/src/styles/uhk-icons/uhk-css.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/packages/uhk-web/src/styles/uhk-icons/uhk-icon.scss b/packages/uhk-web/src/styles/uhk-icons/uhk-icon.scss index b6a126d4..64724332 100644 --- a/packages/uhk-web/src/styles/uhk-icons/uhk-icon.scss +++ b/packages/uhk-web/src/styles/uhk-icons/uhk-icon.scss @@ -6,3 +6,8 @@ @extend %svg-common; background-position: 0 0; } + +.uhk-icon-agent-icon { + @extend %svg-common; + background-position: 100% 0; +} diff --git a/packages/uhk-web/src/svgs/icons/agent-icon.svg b/packages/uhk-web/src/svgs/icons/agent-icon.svg new file mode 100644 index 00000000..7c5f1d8f --- /dev/null +++ b/packages/uhk-web/src/svgs/icons/agent-icon.svg @@ -0,0 +1,10 @@ + + + + + + diff --git a/scripts/download-firmware.js b/scripts/download-firmware.js index 3679637e..29e7a06f 100644 --- a/scripts/download-firmware.js +++ b/scripts/download-firmware.js @@ -35,7 +35,7 @@ async function downloadFile(url, output) { } (async function main() { - const agentJson = require('../packages/uhk-agent/src/package.json'); + const agentJson = require('../package.json'); const extractedFirmwareDir = path.join(__dirname, '../tmp/packages/firmware'); await fse.emptyDir(extractedFirmwareDir);