diff --git a/src/components/svg-keyboard-key.component.ts b/src/components/svg-keyboard-key.component.ts
index 4e6d9739..786393b5 100644
--- a/src/components/svg-keyboard-key.component.ts
+++ b/src/components/svg-keyboard-key.component.ts
@@ -8,6 +8,19 @@ import { Component, OnInit, Input } from 'angular2/core';
[attr.height]="height" [attr.width]="width"
[attr.fill]="fill"
/>
+ 0">
+ {{asciiCode[0]}}
+
`
})
export class SvgKeyboardKeyComponent implements OnInit {
@@ -16,8 +29,11 @@ export class SvgKeyboardKeyComponent implements OnInit {
@Input() ry: string;
@Input() height: string;
@Input() width: string;
+ @Input() asciiCode: string[];
- constructor() { }
+ constructor() {
+ this.asciiCode = [];
+ }
ngOnInit() { }
diff --git a/src/components/svg-keyboard.component.ts b/src/components/svg-keyboard.component.ts
index 7ef445f9..87c7c149 100644
--- a/src/components/svg-keyboard.component.ts
+++ b/src/components/svg-keyboard.component.ts
@@ -1,19 +1,23 @@
import { Component, OnInit} from 'angular2/core';
import {DataProviderService} from '../services/data-provider.service';
+import {Module} from '../../config-serializer/config-items/Module';
import {SvgModule} from './svg-module.model';
import {SvgModuleComponent} from './svg-module.component';
+import {UhkConfiguration} from '../../config-serializer/config-items/UhkConfiguration';
+
@Component({
selector: 'svg-keyboard',
template:
`
@@ -34,6 +38,7 @@ export class SvgKeyboardComponent implements OnInit {
private svg: any;
private transform: string;
private fill: string;
+ private moduleConfig: Module[];
constructor(private dps: DataProviderService) {
this.modules = [];
@@ -45,6 +50,14 @@ export class SvgKeyboardComponent implements OnInit {
this.transform = this.svg.g[0].$.transform;
this.fill = this.svg.g[0].$.fill;
this.modules = this.svg.g[0].g.map(obj => new SvgModule(obj));
+
+ let uhkConfig: UhkConfiguration = new UhkConfiguration();
+ uhkConfig.fromJsObject(this.dps.getUHKConfig());
+ this.moduleConfig = uhkConfig.keyMaps.elements[0].layers.elements[0].modules.elements;
+ this.modules = this.svg.g[0].g.map(obj => {
+ return new SvgModule(obj);
+ });
+ this.modules = [this.modules[1], this.modules[0]]; // TODO: remove if the svg will be correct
}
}
diff --git a/src/components/svg-module.component.ts b/src/components/svg-module.component.ts
index bd310656..7092a2f7 100644
--- a/src/components/svg-module.component.ts
+++ b/src/components/svg-module.component.ts
@@ -1,32 +1,64 @@
-import { Component, OnInit, Input} from 'angular2/core';
+import { Component, OnInit, OnChanges, Input, SimpleChange} from 'angular2/core';
import {SvgKeyboardKey} from './svg-keyboard-key.model';
import {SvgKeyboardKeyComponent} from './svg-keyboard-key.component';
+import {KeyAction} from '../../config-serializer/config-items/KeyAction';
+import {KeystrokeAction} from '../../config-serializer/config-items/KeystrokeAction';
+import {Mapper} from '../utils/mapper';
@Component({
selector: 'g[svg-module]',
template:
`
-
`,
directives: [SvgKeyboardKeyComponent]
})
-export class SvgModuleComponent implements OnInit {
+export class SvgModuleComponent implements OnInit, OnChanges {
@Input() coverages: any[];
@Input() keyboardKeys: SvgKeyboardKey[];
+ @Input() keyActions: KeyAction[];
+ private asciiCodes: string[][];
constructor() {
this.keyboardKeys = [];
+ this.asciiCodes = [];
}
ngOnInit() {
+ this.setAsciiCodes();
+ console.log(this);
+ }
+
+ ngOnChanges(changes: { [propertyName: string]: SimpleChange }) {
+ /* tslint:disable:no-string-literal */
+ if (changes['keyActions']) {
+ this.setAsciiCodes();
+ }
+ /* tslint:enable:no-string-literal */
}
+ private setAsciiCodes(): void {
+ if (!this.keyActions) {
+ return;
+ }
+ let newAsciiCodes: string[][] = [];
+ this.keyActions.forEach((keyAction: KeyAction) => {
+ if (keyAction instanceof KeystrokeAction) {
+ newAsciiCodes.push(Mapper.scanCodeToText((keyAction as KeystrokeAction).scancode));
+ } else {
+ newAsciiCodes.push([]);
+ }
+ });
+ this.asciiCodes = newAsciiCodes;
+ }
+
}