Enable sending user configuration from every screen
This commit is contained in:
@@ -17,8 +17,6 @@ import { KeymapEditComponent as SharedKeymapEditComponent } from '../../../share
|
|||||||
|
|
||||||
import { UhkDeviceService } from '../../../services/uhk-device.service';
|
import { UhkDeviceService } from '../../../services/uhk-device.service';
|
||||||
|
|
||||||
import { getUserConfiguration } from '../../../shared/store/reducers/user-configuration';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'keymap-edit',
|
selector: 'keymap-edit',
|
||||||
templateUrl: '../../../shared/components/keymap/edit/keymap-edit.component.html',
|
templateUrl: '../../../shared/components/keymap/edit/keymap-edit.component.html',
|
||||||
@@ -55,14 +53,6 @@ export class KeymapEditComponent extends SharedKeymapEditComponent {
|
|||||||
this.sendKeymap();
|
this.sendKeymap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@HostListener('window:keydown.control.o', ['$event'])
|
|
||||||
onCtrlO(event: KeyboardEvent): void {
|
|
||||||
console.log('ctrl + o pressed');
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
this.sendUserConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
private sendLayer(): void {
|
private sendLayer(): void {
|
||||||
const currentLayer: number = this.wrap.getSelectedLayer();
|
const currentLayer: number = this.wrap.getSelectedLayer();
|
||||||
this.keymap$
|
this.keymap$
|
||||||
@@ -101,21 +91,4 @@ export class KeymapEditComponent extends SharedKeymapEditComponent {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendUserConfiguration(): void {
|
|
||||||
this.store
|
|
||||||
.let(getUserConfiguration())
|
|
||||||
.map(userConfiguration => {
|
|
||||||
const uhkBuffer = new UhkBuffer();
|
|
||||||
userConfiguration.toBinary(uhkBuffer);
|
|
||||||
return uhkBuffer.getBufferContent();
|
|
||||||
})
|
|
||||||
.switchMap((buffer: Buffer) => this.uhkDevice.sendConfig(buffer))
|
|
||||||
.do(response => console.log('Sending user configuration finished', response))
|
|
||||||
.switchMap(() => this.uhkDevice.applyConfig())
|
|
||||||
.subscribe(
|
|
||||||
(response) => console.log('Applying user configuration finished', response),
|
|
||||||
error => console.error('Error during uploading user configuration', error),
|
|
||||||
() => console.log('User configuration has been sucessfully uploaded')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
import { Component, ViewEncapsulation, HostListener } from '@angular/core';
|
import { Component, ViewEncapsulation, HostListener } from '@angular/core';
|
||||||
|
|
||||||
// import { Observable } from 'rxjs/Observable';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
// import { Store } from '@ngrx/store';
|
import { AppState } from '../shared/store';
|
||||||
// import { AppState } from '../store';
|
import { getUserConfiguration } from '../shared/store/reducers/user-configuration';
|
||||||
// import { DataStorage } from '../store/storage';
|
|
||||||
// import { getKeymapEntities, getMacroEntities } from '../store/reducers';
|
|
||||||
|
|
||||||
// import { UhkBuffer } from '../config-serializer/UhkBuffer';
|
import { UhkBuffer } from '../shared/config-serializer/UhkBuffer';
|
||||||
// import { UserConfiguration } from '../config-serializer/config-items/UserConfiguration';
|
|
||||||
|
|
||||||
// import { UhkDeviceService } from '../services/uhk-device.service';
|
import { UhkDeviceService } from '../services/uhk-device.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'main-app',
|
selector: 'main-app',
|
||||||
@@ -20,48 +17,32 @@ import { Component, ViewEncapsulation, HostListener } from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class MainAppComponent {
|
export class MainAppComponent {
|
||||||
|
|
||||||
// private configuration$: Observable<UserConfiguration>;
|
constructor(private uhkDevice: UhkDeviceService, private store: Store<AppState>) { }
|
||||||
|
|
||||||
constructor(
|
|
||||||
// private uhkDevice: UhkDeviceService,
|
|
||||||
// store: Store<AppState>,
|
|
||||||
// dataStorage: DataStorage
|
|
||||||
) {
|
|
||||||
// this.configuration$ = store.let(getKeymapEntities())
|
|
||||||
// .combineLatest(store.let(getMacroEntities()))
|
|
||||||
// .map((pair) => {
|
|
||||||
// const config = new UserConfiguration();
|
|
||||||
// Object.assign(config, dataStorage.getConfiguration());
|
|
||||||
// config.keymaps = pair[0];
|
|
||||||
// config.macros = pair[1];
|
|
||||||
// return config;
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
@HostListener('window:keydown.control.o', ['$event'])
|
@HostListener('window:keydown.control.o', ['$event'])
|
||||||
onCtrlO(event: KeyboardEvent): void {
|
onCtrlO(event: KeyboardEvent): void {
|
||||||
console.log('ctrl + o pressed');
|
console.log('ctrl + o pressed');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.sendConfiguration();
|
this.sendUserConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendConfiguration(): void {
|
private sendUserConfiguration(): void {
|
||||||
// this.configuration$
|
this.store
|
||||||
// .first()
|
.let(getUserConfiguration())
|
||||||
// .map(configuration => {
|
.map(userConfiguration => {
|
||||||
// const uhkBuffer = new UhkBuffer();
|
const uhkBuffer = new UhkBuffer();
|
||||||
// configuration.toBinary(uhkBuffer);
|
userConfiguration.toBinary(uhkBuffer);
|
||||||
// return uhkBuffer.getBufferContent();
|
return uhkBuffer.getBufferContent();
|
||||||
// })
|
})
|
||||||
// .switchMap((buffer: Buffer) => this.uhkDevice.sendConfig(buffer))
|
.switchMap((buffer: Buffer) => this.uhkDevice.sendConfig(buffer))
|
||||||
// .do(response => console.log('Sending config finished', response))
|
.do(response => console.log('Sending user configuration finished', response))
|
||||||
// .switchMap(() => this.uhkDevice.applyConfig())
|
.switchMap(() => this.uhkDevice.applyConfig())
|
||||||
// .subscribe(
|
.subscribe(
|
||||||
// (response) => console.log('Applying config finished', response),
|
(response) => console.log('Applying user configuration finished', response),
|
||||||
// error => console.error('Error during uploading config', error),
|
error => console.error('Error during uploading user configuration', error),
|
||||||
// () => console.log('Config has been sucessfully uploaded')
|
() => console.log('User configuration has been sucessfully uploaded')
|
||||||
// );
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user