chore: upgrade angular => 7.x (#925)
* Merge branch 'master' into chore-upgrade-angular-to-7 * reformat files of the store * set preserveWhitespaces = true * delete console.log from AutoGrowInputComponent * fix null pinter exception when set the keyaction on an undefined key * speed tuning * delete svg-keyboard-key animation * revert electron logger upgrade * improve animation speed of scg-keyboard-key component * fix: popover keymap tab visibility * fix: remove btn-line css class
This commit is contained in:
committed by
László Monda
parent
b1b2f1d431
commit
33c910d70c
@@ -6,13 +6,14 @@
|
||||
*ngFor="let module of modules; let i = index"
|
||||
[coverages]="module.coverages"
|
||||
[keyboardKeys]="module.keyboardKeys"
|
||||
[keybindAnimationEnabled]="keybindAnimationEnabled"
|
||||
[capturingEnabled]="capturingEnabled"
|
||||
[attr.transform]="module.attributes.transform"
|
||||
[keyActions]="moduleConfig[i].keyActions"
|
||||
[selectedKey]="selectedKey"
|
||||
[@split]="moduleAnimationStates[i]"
|
||||
[selected]="selectedKey?.moduleId === i"
|
||||
[lastEdited]="lastEditedKey?.moduleId === i"
|
||||
[lastEditedKeyId]="lastEditedKey?.key"
|
||||
(keyClick)="onKeyClick(i, $event)"
|
||||
(keyHover)="onKeyHover($event.index, $event.event, $event.over, i)"
|
||||
(capture)="onCapture(i, $event)" />
|
||||
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
@@ -1,4 +1,4 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output, SimpleChanges, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, Output, SimpleChanges, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { animate, state, trigger, style, transition } from '@angular/animations';
|
||||
import { DomSanitizer, SafeStyle } from '@angular/platform-browser';
|
||||
import { Module } from 'uhk-common';
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
SvgKeyboardCaptureEvent,
|
||||
SvgModuleKeyClickEvent
|
||||
} from '../../../models/svg-key-events';
|
||||
import { LastEditedKey } from '../../../models';
|
||||
|
||||
@Component({
|
||||
selector: 'svg-keyboard',
|
||||
@@ -41,9 +42,8 @@ import {
|
||||
])
|
||||
]
|
||||
})
|
||||
export class SvgKeyboardComponent implements OnInit {
|
||||
export class SvgKeyboardComponent {
|
||||
@Input() moduleConfig: Module[];
|
||||
@Input() keybindAnimationEnabled: boolean;
|
||||
@Input() capturingEnabled: boolean;
|
||||
@Input() selectedKey: { layerId: number, moduleId: number, keyId: number };
|
||||
@Input() selected: boolean;
|
||||
@@ -51,6 +51,7 @@ export class SvgKeyboardComponent implements OnInit {
|
||||
@Input() keyboardLayout = KeyboardLayout.ANSI;
|
||||
@Input() description: string;
|
||||
@Input() showDescription = false;
|
||||
@Input() lastEditedKey: LastEditedKey;
|
||||
@Output() keyClick = new EventEmitter<SvgKeyboardKeyClickEvent>();
|
||||
@Output() keyHover = new EventEmitter<SvgKeyHoverEvent>();
|
||||
@Output() capture = new EventEmitter<SvgKeyboardCaptureEvent>();
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
<svg:rect [@change]="changeAnimation"
|
||||
(@change.done)="onChangeAnimationDone()"
|
||||
[@active]="active"
|
||||
<svg:rect #svgRec
|
||||
class="svg-rec"
|
||||
[class.active]="active"
|
||||
[id]="id"
|
||||
[attr.rx]="rx"
|
||||
[attr.ry]="ry"
|
||||
|
||||
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
+24
@@ -10,3 +10,27 @@
|
||||
fill: #494949;
|
||||
}
|
||||
}
|
||||
|
||||
.svg-rec {
|
||||
transition-timing-function: ease-out;
|
||||
transition: 0.2s;
|
||||
|
||||
&.active {
|
||||
fill: #4099e5;
|
||||
transition-timing-function: ease-in;
|
||||
transition: 0s;
|
||||
}
|
||||
|
||||
&.blink {
|
||||
animation: blinkingRec 1s 1 ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes blinkingRec {
|
||||
0% {
|
||||
fill: #ffffff;
|
||||
}
|
||||
100% {
|
||||
fill: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
+36
-57
@@ -1,13 +1,17 @@
|
||||
import {
|
||||
Component, ElementRef, EventEmitter, HostListener, Input, OnChanges, OnDestroy, OnInit, Output,
|
||||
SimpleChange, ChangeDetectionStrategy
|
||||
Component,
|
||||
ElementRef,
|
||||
EventEmitter,
|
||||
HostListener,
|
||||
Input,
|
||||
OnChanges,
|
||||
Output,
|
||||
ChangeDetectionStrategy,
|
||||
SimpleChanges,
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
import { animate, group, state, style, transition, trigger } from '@angular/animations';
|
||||
|
||||
import { animate, state, style, transition, trigger } from '@angular/animations';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
|
||||
import { Key } from 'ts-keycode-enum';
|
||||
|
||||
import {
|
||||
@@ -26,7 +30,7 @@ import {
|
||||
import { CaptureService } from '../../../../services/capture.service';
|
||||
import { MapperService } from '../../../../services/mapper.service';
|
||||
|
||||
import { AppState, getMacros } from '../../../../store';
|
||||
import { AppState } from '../../../../store';
|
||||
import { SvgKeyCaptureEvent, SvgKeyClickEvent } from '../../../../models/svg-key-events';
|
||||
import { OperatingSystem } from '../../../../models/operating-system';
|
||||
import { KeyModifierModel } from '../../../../models/key-modifier-model';
|
||||
@@ -45,22 +49,6 @@ enum LabelTypes {
|
||||
|
||||
@Component({
|
||||
animations: [
|
||||
trigger('change', [
|
||||
transition('inactive => active', [
|
||||
style({ fill: '#fff' }),
|
||||
group([
|
||||
animate('1s ease-out', style({
|
||||
fill: '#333'
|
||||
}))
|
||||
])
|
||||
])
|
||||
]),
|
||||
trigger('active', [
|
||||
// http://colorblendy.com/#!/multiply/4099e5/cccccc
|
||||
state('1', style({ fill: '#4099e5' })), // Signature blue color blending
|
||||
transition('1 => *', animate('200ms')),
|
||||
transition('* => 1', animate('0ms')) // Instant color to blue
|
||||
]),
|
||||
trigger('recording', [
|
||||
state('inactive', style({
|
||||
fill: 'rgba(204, 0, 0, 1)'
|
||||
@@ -76,32 +64,32 @@ enum LabelTypes {
|
||||
styleUrls: ['./svg-keyboard-key.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
|
||||
export class SvgKeyboardKeyComponent implements OnChanges {
|
||||
@Input() id: string;
|
||||
@Input() rx: string;
|
||||
@Input() ry: string;
|
||||
@Input() height: number;
|
||||
@Input() width: number;
|
||||
@Input() keyAction: KeyAction;
|
||||
@Input() keybindAnimationEnabled: boolean;
|
||||
@Input() capturingEnabled: boolean;
|
||||
@Input() active: boolean;
|
||||
@Input() macroMap = new Map<number, Macro>();
|
||||
@Input() blink: boolean;
|
||||
|
||||
@Output() keyClick = new EventEmitter<SvgKeyClickEvent>();
|
||||
@Output() capture = new EventEmitter<SvgKeyCaptureEvent>();
|
||||
|
||||
@ViewChild('svgRec') svgRec: ElementRef<HTMLElement>;
|
||||
|
||||
enumLabelTypes = LabelTypes;
|
||||
|
||||
changeAnimation: string = 'inactive';
|
||||
recordAnimation: string;
|
||||
recording: boolean;
|
||||
labelType: LabelTypes;
|
||||
|
||||
labelSource: any;
|
||||
secondaryText: string;
|
||||
macros: Macro[];
|
||||
private subscription: Subscription;
|
||||
private scanCodePressed: boolean;
|
||||
private scanCodePressed = false;
|
||||
private pressedShiftLocation = -1;
|
||||
private pressedAltLocation = -1;
|
||||
private altPressed = false;
|
||||
@@ -113,12 +101,6 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
|
||||
private element: ElementRef,
|
||||
private captureService: CaptureService
|
||||
) {
|
||||
this.subscription = store.select(getMacros)
|
||||
.subscribe((macros: Macro[]) => this.macros = macros);
|
||||
|
||||
this.reset();
|
||||
this.captureService.populateMapping();
|
||||
this.scanCodePressed = false;
|
||||
}
|
||||
|
||||
@HostListener('click', ['$event'])
|
||||
@@ -156,12 +138,10 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
|
||||
if (e.keyCode === Key.Alt && this.pressedAltLocation > -1) {
|
||||
this.pressedAltLocation = -1;
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (e.keyCode === Key.Shift && this.pressedShiftLocation > -1) {
|
||||
} else if (e.keyCode === Key.Shift && this.pressedShiftLocation > -1) {
|
||||
this.pressedShiftLocation = -1;
|
||||
e.preventDefault();
|
||||
}
|
||||
else if (this.scanCodePressed) {
|
||||
} else if (this.scanCodePressed) {
|
||||
e.preventDefault();
|
||||
this.scanCodePressed = false;
|
||||
} else if (this.recording) {
|
||||
@@ -209,25 +189,14 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.setLabels();
|
||||
}
|
||||
|
||||
ngOnChanges(changes: { [propertyName: string]: SimpleChange }) {
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes['keyAction']) {
|
||||
this.setLabels();
|
||||
if (this.keybindAnimationEnabled) {
|
||||
this.changeAnimation = 'active';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
onChangeAnimationDone() {
|
||||
this.changeAnimation = 'inactive';
|
||||
if (changes['blink'] && changes['blink'].currentValue) {
|
||||
this.blinkSvgRec();
|
||||
}
|
||||
}
|
||||
|
||||
onRecordingAnimationDone() {
|
||||
@@ -240,7 +209,6 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
private reset() {
|
||||
this.recording = false;
|
||||
this.changeAnimation = 'inactive';
|
||||
this.captureService.initModifiers();
|
||||
this.shiftPressed = false;
|
||||
this.altPressed = false;
|
||||
@@ -363,7 +331,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.labelSource = keyAction.keymapAbbreviation;
|
||||
} else if (this.keyAction instanceof PlayMacroAction) {
|
||||
const keyAction: PlayMacroAction = this.keyAction as PlayMacroAction;
|
||||
const macro: Macro = this.macros.find((_macro: Macro) => _macro.id === keyAction.macroId);
|
||||
const macro: Macro = this.macroMap.get(keyAction.macroId);
|
||||
this.labelType = LabelTypes.IconText;
|
||||
this.labelSource = {
|
||||
icon: this.mapper.getIcon('macro'),
|
||||
@@ -376,4 +344,15 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
|
||||
this.labelSource = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private blinkSvgRec(): void {
|
||||
if (this.svgRec) {
|
||||
this.svgRec.nativeElement.classList.remove('blink');
|
||||
setTimeout(() => {
|
||||
if (this.svgRec) {
|
||||
this.svgRec.nativeElement.classList.add('blink');
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<svg:path *ngFor="let path of coverages" [attr.d]="path.$.d" [attr.style]="path.$.style | safeStyle" />
|
||||
<ng-container *ngFor="let key of keyboardKeys; let i = index">
|
||||
<ng-container *ngFor="let key of keyboardKeys; let i = index; trackBy:keyboardKeysTrackBy">
|
||||
<svg:g svg-keyboard-key
|
||||
*ngIf="key"
|
||||
[id]="key.id"
|
||||
@@ -10,8 +10,9 @@
|
||||
tabindex="-1"
|
||||
[keyAction]="keyActions[i]"
|
||||
[active]="selected && i == selectedKey.keyId"
|
||||
[keybindAnimationEnabled]="keybindAnimationEnabled"
|
||||
[capturingEnabled]="capturingEnabled"
|
||||
[macroMap]="macroMap"
|
||||
[blink]="lastEdited && lastEditedKeyId === key.id"
|
||||
(keyClick)="onKeyClick(i, $event)"
|
||||
(capture)="onCapture(i, $event)"
|
||||
(mouseenter)="onKeyHover(i, $event, true)"
|
||||
|
||||
|
Before Width: | Height: | Size: 910 B After Width: | Height: | Size: 972 B |
@@ -1,13 +1,23 @@
|
||||
import { Component, EventEmitter, Input, Output, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { KeyAction } from 'uhk-common';
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnDestroy,
|
||||
Output,
|
||||
ChangeDetectionStrategy
|
||||
} from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { KeyAction, Macro } from 'uhk-common';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
import { SvgKeyboardKey } from '../keys';
|
||||
import {
|
||||
SvgKeyCaptureEvent,
|
||||
SvgKeyClickEvent,
|
||||
SvgModuleCaptureEvent,
|
||||
SvgModuleCaptureEvent,
|
||||
SvgModuleKeyClickEvent
|
||||
} from '../../../models/svg-key-events';
|
||||
import { AppState, getMacroMap } from '../../../store';
|
||||
|
||||
@Component({
|
||||
selector: 'g[svg-module]',
|
||||
@@ -15,20 +25,30 @@ import {
|
||||
styleUrls: ['./svg-module.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class SvgModuleComponent {
|
||||
export class SvgModuleComponent implements OnDestroy {
|
||||
@Input() coverages: any[];
|
||||
@Input() keyboardKeys: SvgKeyboardKey[];
|
||||
@Input() keyActions: KeyAction[];
|
||||
@Input() selectedKey: { layerId: number, moduleId: number, keyId: number };
|
||||
@Input() selected: boolean;
|
||||
@Input() keybindAnimationEnabled: boolean;
|
||||
@Input() capturingEnabled: boolean;
|
||||
@Input() lastEdited: boolean;
|
||||
@Input() lastEditedKeyId: string;
|
||||
@Output() keyClick = new EventEmitter<SvgModuleKeyClickEvent>();
|
||||
@Output() keyHover = new EventEmitter();
|
||||
@Output() capture = new EventEmitter<SvgModuleCaptureEvent>();
|
||||
|
||||
constructor() {
|
||||
private macroMap: Map<number, Macro>;
|
||||
private macroMapSubscription: Subscription;
|
||||
|
||||
constructor(private store: Store<AppState>) {
|
||||
this.keyboardKeys = [];
|
||||
this.macroMapSubscription = store.select(getMacroMap)
|
||||
.subscribe(map => this.macroMap = map);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.macroMapSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
onKeyClick(keyId: number, event: SvgKeyClickEvent): void {
|
||||
@@ -52,4 +72,8 @@ export class SvgModuleComponent {
|
||||
keyId
|
||||
});
|
||||
}
|
||||
|
||||
keyboardKeysTrackBy(index: number, key: SvgKeyboardKey): string {
|
||||
return `${index}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<layers [class.disabled]="popoverShown" (select)="selectLayer($event.index)" [current]="currentLayer"></layers>
|
||||
<keyboard-slider [layers]="layers"
|
||||
[currentLayer]="currentLayer"
|
||||
[keybindAnimationEnabled]="keybindAnimationEnabled"
|
||||
[capturingEnabled]="popoverEnabled"
|
||||
[selectedKey]="selectedKey"
|
||||
[halvesSplit]="halvesSplit"
|
||||
[keyboardLayout]="keyboardLayout"
|
||||
[description]="keymap.description"
|
||||
[lastEditedKey]="lastEditedKey"
|
||||
(keyClick)="onKeyClick($event)"
|
||||
(keyHover)="onKeyHover($event)"
|
||||
(capture)="onCapture($event)"
|
||||
|
||||
@@ -13,8 +13,7 @@ import {
|
||||
ViewChild
|
||||
} from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs/observable/of';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
@@ -49,6 +48,7 @@ import {
|
||||
} from '../../../models/svg-key-events';
|
||||
import { RemapInfo } from '../../../models/remap-info';
|
||||
import { mapLeftRigthModifierToKeyActionModifier } from '../../../util';
|
||||
import { LastEditedKey } from '../../../models';
|
||||
|
||||
interface NameValuePair {
|
||||
name: string;
|
||||
@@ -68,6 +68,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
|
||||
@Input() halvesSplit: boolean;
|
||||
@Input() keyboardLayout: KeyboardLayout.ANSI;
|
||||
@Input() allowLayerDoubleTap: boolean;
|
||||
@Input() lastEditedKey: LastEditedKey;
|
||||
|
||||
@Output() descriptionChanged = new EventEmitter<ChangeKeymapDescription>();
|
||||
|
||||
@@ -77,7 +78,6 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
|
||||
keyEditConfig: { moduleId: number, keyId: number };
|
||||
selectedKey: { layerId: number, moduleId: number, keyId: number };
|
||||
popoverInitKeyAction: KeyAction;
|
||||
keybindAnimationEnabled: boolean;
|
||||
currentLayer: number = 0;
|
||||
tooltipData: {
|
||||
posTop: number,
|
||||
@@ -109,7 +109,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
|
||||
this.tooltipData = {
|
||||
posTop: 0,
|
||||
posLeft: 0,
|
||||
content: Observable.of([]),
|
||||
content: of([]),
|
||||
show: false
|
||||
};
|
||||
}
|
||||
@@ -139,14 +139,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
|
||||
if (keymapChanges) {
|
||||
this.popoverShown = false;
|
||||
this.layers = this.keymap.layers;
|
||||
if (keymapChanges.isFirstChange() ||
|
||||
keymapChanges.previousValue.abbreviation !== keymapChanges.currentValue.abbreviation) {
|
||||
this.keybindAnimationEnabled = keymapChanges.isFirstChange();
|
||||
} else {
|
||||
this.keybindAnimationEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onKeyClick(event: SvgKeyboardKeyClickEvent): void {
|
||||
@@ -302,7 +295,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
|
||||
value: SecondaryRoleAction[keystrokeAction.secondaryRoleAction]
|
||||
});
|
||||
}
|
||||
return Observable.of(content);
|
||||
return of(content);
|
||||
} else if (keyAction instanceof MouseAction) {
|
||||
const mouseAction: MouseAction = keyAction;
|
||||
const content: NameValuePair[] =
|
||||
@@ -316,7 +309,7 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
|
||||
value: camelCaseToSentence(MouseActionParam[mouseAction.mouseAction])
|
||||
}
|
||||
];
|
||||
return Observable.of(content);
|
||||
return of(content);
|
||||
} else if (keyAction instanceof PlayMacroAction) {
|
||||
const playMacroAction: PlayMacroAction = keyAction;
|
||||
return this.store
|
||||
|
||||
Reference in New Issue
Block a user