refactore: create feature modules (#387)
* add @angular/cli to the project * increase nodejs version -> 8.2.1 * add lerna * merge web and shared module * move electron module into packages as uhk-agent Electron agent functionality is not working * delete symlinker * convert private properties to public of component if used in html * revert uhk-message.component * fix component path * fix the correct name of the uhk-message.component.scss * building web and electron module * delete uhk-renderer package * handle device connect disconnect state * add privilege detection * fix set privilege functionality * turn back download keymap functionality * add bootstrap, select2 js and fix null pointer exception * turn back upload data to keyboard * fix send keymap * fix test-serializer * add missing package.json * merging * fix appveyor build * fix linting * turn back electron storage service * commit the missing electron-datastorage-repository * update node to 8.3.0 in .nvmrc and log node version in appveyor build * set exact version number in appveyor build * vertical align privilege and missing device components * set back node version to 8 in appveyor * move node-usb dependency from usb dir to root maybe it is fix the appveyor build * revert usb to root * fix electron builder script * fix electron builder script * turn off electron devtools * remove CTRL+U functionality * fix CTRL+o * fix lint error * turnoff store freeze * start process when got `Error: EPERM: operation not permitted` error * move files from root usb dir -> packages/usb
This commit is contained in:
committed by
László Monda
parent
97770f67c0
commit
0f558e4132
7
packages/uhk-common/src/models/app-start-info.ts
Normal file
7
packages/uhk-common/src/models/app-start-info.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { CommandLineArgs } from './command-line-args';
|
||||
|
||||
export interface AppStartInfo {
|
||||
commandLineArgs: CommandLineArgs;
|
||||
deviceConnected: boolean;
|
||||
hasPermission: boolean;
|
||||
}
|
||||
3
packages/uhk-common/src/models/command-line-args.ts
Normal file
3
packages/uhk-common/src/models/command-line-args.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface CommandLineArgs {
|
||||
addons: boolean;
|
||||
}
|
||||
4
packages/uhk-common/src/models/index.ts
Normal file
4
packages/uhk-common/src/models/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from './command-line-args';
|
||||
export * from './notification';
|
||||
export * from './ipc-response';
|
||||
export * from './app-start-info';
|
||||
4
packages/uhk-common/src/models/ipc-response.ts
Normal file
4
packages/uhk-common/src/models/ipc-response.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export class IpcResponse {
|
||||
success: boolean;
|
||||
error?: { message: string };
|
||||
}
|
||||
17
packages/uhk-common/src/models/notification.ts
Normal file
17
packages/uhk-common/src/models/notification.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
export enum NotificationType {
|
||||
Default = 'default',
|
||||
Success = 'success',
|
||||
Error = 'error',
|
||||
Warning = 'warning',
|
||||
Info = 'info',
|
||||
Undoable = 'undoable'
|
||||
}
|
||||
|
||||
export interface Notification {
|
||||
type: NotificationType;
|
||||
title?: string;
|
||||
message: string;
|
||||
extra?: Action;
|
||||
}
|
||||
1
packages/uhk-common/src/services/index.ts
Normal file
1
packages/uhk-common/src/services/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './logger.service';
|
||||
20
packages/uhk-common/src/services/logger.service.ts
Normal file
20
packages/uhk-common/src/services/logger.service.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class LogService {
|
||||
error(...args: any[]): void {
|
||||
console.error(args);
|
||||
}
|
||||
|
||||
debug(...args: any[]): void {
|
||||
console.debug(args);
|
||||
}
|
||||
|
||||
silly(...args: any[]): void {
|
||||
console.debug(args);
|
||||
}
|
||||
|
||||
info(...args: any[]): void {
|
||||
console.info(args);
|
||||
}
|
||||
}
|
||||
5
packages/uhk-common/src/util/constants.ts
Normal file
5
packages/uhk-common/src/util/constants.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export namespace Constants {
|
||||
export const VENDOR_ID = 0x1D50;
|
||||
export const PRODUCT_ID = 0x6122;
|
||||
export const MAX_PAYLOAD_SIZE = 64;
|
||||
}
|
||||
39
packages/uhk-common/src/util/index.ts
Normal file
39
packages/uhk-common/src/util/index.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
export { Constants } from './constants';
|
||||
export { IpcEvents } from './ipcEvents';
|
||||
|
||||
// Source: http://stackoverflow.com/questions/13720256/javascript-regex-camelcase-to-sentence
|
||||
export function camelCaseToSentence(camelCasedText: string): string {
|
||||
return camelCasedText.replace(/^[a-z]|[A-Z]/g, function (v, i) {
|
||||
return i === 0 ? v.toUpperCase() : ' ' + v.toLowerCase();
|
||||
});
|
||||
}
|
||||
|
||||
export function capitalizeFirstLetter(text: string): string {
|
||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function coerces a string into a string literal type.
|
||||
* Using tagged union types in TypeScript 2.0, this enables
|
||||
* powerful typechecking of our reducers.
|
||||
*
|
||||
* Since every action label passes through this function it
|
||||
* is a good place to ensure all of our action labels
|
||||
* are unique.
|
||||
*/
|
||||
|
||||
const typeCache: { [label: string]: boolean } = {};
|
||||
|
||||
export function type<T>(label: T | ''): T {
|
||||
if (typeCache[<string>label]) {
|
||||
throw new Error(`Action type "${label}" is not unique"`);
|
||||
}
|
||||
|
||||
typeCache[<string>label] = true;
|
||||
|
||||
return <T>label;
|
||||
}
|
||||
|
||||
export function runInElectron() {
|
||||
return window && (<any>window).process && (<any>window).process.type;
|
||||
}
|
||||
31
packages/uhk-common/src/util/ipcEvents.ts
Normal file
31
packages/uhk-common/src/util/ipcEvents.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
class App {
|
||||
public static readonly appStarted = 'app-started';
|
||||
public static readonly getAppStartInfo = 'app-get-start-info';
|
||||
public static readonly getAppStartInfoReply = 'app-get-start-info-reply';
|
||||
}
|
||||
|
||||
class AutoUpdate {
|
||||
public static readonly checkingForUpdate = 'checking-for-update';
|
||||
public static readonly updateAvailable = 'update-available';
|
||||
public static readonly updateNotAvailable = 'update-not-available';
|
||||
public static readonly autoUpdateError = 'auto-update-error';
|
||||
public static readonly autoUpdateDownloaded = 'update-downloaded';
|
||||
public static readonly autoUpdateDownloadProgress = 'auto-update-download-progress';
|
||||
public static readonly updateAndRestart = 'update-and-restart';
|
||||
public static readonly checkForUpdate = 'check-for-update';
|
||||
public static readonly checkForUpdateNotAvailable = 'check-for-update-not-available';
|
||||
}
|
||||
|
||||
class Device {
|
||||
public static readonly setPrivilegeOnLinux = 'set-privilege-on-linux';
|
||||
public static readonly setPrivilegeOnLinuxReply = 'set-privilege-on-linux-reply';
|
||||
public static readonly deviceConnectionStateChanged = 'device-connection-state-changed';
|
||||
public static readonly saveUserConfiguration = 'device-save-user-configuration';
|
||||
public static readonly saveUserConfigurationReply = 'device-save-user-configuration-reply';
|
||||
}
|
||||
|
||||
export class IpcEvents {
|
||||
public static readonly app = App;
|
||||
public static readonly autoUpdater = AutoUpdate;
|
||||
public static readonly device = Device;
|
||||
}
|
||||
Reference in New Issue
Block a user