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
@@ -0,0 +1,98 @@
|
||||
import { Component, Input, OnChanges } from '@angular/core';
|
||||
|
||||
import { KeyAction, MouseAction, MouseActionParam } from '../../../../config-serializer/config-items/key-action';
|
||||
import { Tab } from '../tab';
|
||||
|
||||
@Component({
|
||||
selector: 'mouse-tab',
|
||||
templateUrl: './mouse-tab.component.html',
|
||||
styleUrls: ['./mouse-tab.component.scss']
|
||||
})
|
||||
export class MouseTabComponent extends Tab implements OnChanges {
|
||||
@Input() defaultKeyAction: KeyAction;
|
||||
|
||||
/* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */
|
||||
MouseActionParam = MouseActionParam;
|
||||
/* tslint:enable:variable-name*/
|
||||
mouseActionParam: MouseActionParam;
|
||||
selectedPageIndex: number;
|
||||
pages: string[];
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.selectedPageIndex = 0;
|
||||
this.pages = ['Move', 'Scroll', 'Click', 'Speed'];
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.fromKeyAction(this.defaultKeyAction);
|
||||
this.validAction.emit(this.keyActionValid());
|
||||
}
|
||||
|
||||
keyActionValid(): boolean {
|
||||
return this.mouseActionParam !== undefined;
|
||||
}
|
||||
|
||||
fromKeyAction(keyAction: KeyAction): boolean {
|
||||
if (!(keyAction instanceof MouseAction)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const mouseAction: MouseAction = <MouseAction>keyAction;
|
||||
this.mouseActionParam = mouseAction.mouseAction;
|
||||
|
||||
if (mouseAction.mouseAction === MouseActionParam.moveUp) {
|
||||
this.selectedPageIndex = 0;
|
||||
}
|
||||
|
||||
switch (mouseAction.mouseAction) {
|
||||
case MouseActionParam.moveDown:
|
||||
case MouseActionParam.moveUp:
|
||||
case MouseActionParam.moveLeft:
|
||||
case MouseActionParam.moveRight:
|
||||
this.selectedPageIndex = 0;
|
||||
break;
|
||||
case MouseActionParam.scrollDown:
|
||||
case MouseActionParam.scrollUp:
|
||||
case MouseActionParam.scrollLeft:
|
||||
case MouseActionParam.scrollRight:
|
||||
this.selectedPageIndex = 1;
|
||||
break;
|
||||
case MouseActionParam.leftClick:
|
||||
case MouseActionParam.middleClick:
|
||||
case MouseActionParam.rightClick:
|
||||
this.selectedPageIndex = 2;
|
||||
break;
|
||||
case MouseActionParam.decelerate:
|
||||
case MouseActionParam.accelerate:
|
||||
this.selectedPageIndex = 3;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
toKeyAction(): MouseAction {
|
||||
const mouseAction: MouseAction = new MouseAction();
|
||||
mouseAction.mouseAction = this.mouseActionParam;
|
||||
return mouseAction;
|
||||
}
|
||||
|
||||
changePage(index: number) {
|
||||
if (index < -1 || index > 3) {
|
||||
console.error(`Invalid index error: ${index}`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectedPageIndex = index;
|
||||
this.mouseActionParam = undefined;
|
||||
this.validAction.emit(false);
|
||||
}
|
||||
|
||||
setMouseActionParam(mouseActionParam: MouseActionParam) {
|
||||
this.mouseActionParam = mouseActionParam;
|
||||
this.validAction.emit(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user