* 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
94 lines
3.2 KiB
TypeScript
94 lines
3.2 KiB
TypeScript
import { Component, HostListener, ViewEncapsulation } from '@angular/core';
|
|
import { Observable } from 'rxjs/Observable';
|
|
import { Store } from '@ngrx/store';
|
|
|
|
import { DoNotUpdateAppAction, UpdateAppAction } from './store/actions/app-update.action';
|
|
import {
|
|
AppState,
|
|
getShowAppUpdateAvailable,
|
|
deviceConnected,
|
|
runningInElectron
|
|
} from './store';
|
|
import { getUserConfiguration } from './store/reducers/user-configuration';
|
|
import { UhkBuffer } from './config-serializer/uhk-buffer';
|
|
import { SaveConfigurationAction } from './store/actions/device';
|
|
|
|
@Component({
|
|
selector: 'main-app',
|
|
templateUrl: './app.component.html',
|
|
styleUrls: ['./app.component.scss'],
|
|
encapsulation: ViewEncapsulation.None
|
|
})
|
|
export class MainAppComponent {
|
|
showUpdateAvailable$: Observable<boolean>;
|
|
deviceConnected$: Observable<boolean>;
|
|
runningInElectron$: Observable<boolean>;
|
|
|
|
constructor(private store: Store<AppState>) {
|
|
this.showUpdateAvailable$ = store.select(getShowAppUpdateAvailable);
|
|
this.deviceConnected$ = store.select(deviceConnected);
|
|
this.runningInElectron$ = store.select(runningInElectron);
|
|
}
|
|
|
|
updateApp() {
|
|
this.store.dispatch(new UpdateAppAction());
|
|
}
|
|
|
|
doNotUpdateApp() {
|
|
this.store.dispatch(new DoNotUpdateAppAction());
|
|
}
|
|
|
|
@HostListener('window:keydown.control.o', ['$event'])
|
|
onCtrlO(event: KeyboardEvent): void {
|
|
console.log('ctrl + o pressed');
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
this.sendUserConfiguration();
|
|
}
|
|
|
|
@HostListener('window:keydown.alt.j', ['$event'])
|
|
onAltJ(event: KeyboardEvent): void {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
this.store
|
|
.let(getUserConfiguration())
|
|
.first()
|
|
.subscribe(userConfiguration => {
|
|
const asString = JSON.stringify(userConfiguration.toJsonObject());
|
|
const asBlob = new Blob([asString], { type: 'text/plain' });
|
|
saveAs(asBlob, 'UserConfiguration.json');
|
|
});
|
|
}
|
|
|
|
@HostListener('window:keydown.alt.b', ['$event'])
|
|
onAltB(event: KeyboardEvent): void {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
this.store
|
|
.let(getUserConfiguration())
|
|
.first()
|
|
.map(userConfiguration => {
|
|
const uhkBuffer = new UhkBuffer();
|
|
userConfiguration.toBinary(uhkBuffer);
|
|
return new Blob([uhkBuffer.getBufferContent()]);
|
|
})
|
|
.subscribe(blob => saveAs(blob, 'UserConfiguration.bin'));
|
|
}
|
|
|
|
private sendUserConfiguration(): void {
|
|
this.store
|
|
.let(getUserConfiguration())
|
|
.first()
|
|
.map(userConfiguration => {
|
|
const uhkBuffer = new UhkBuffer();
|
|
userConfiguration.toBinary(uhkBuffer);
|
|
return uhkBuffer.getBufferContent();
|
|
})
|
|
.subscribe(
|
|
buffer => this.store.dispatch(new SaveConfigurationAction(buffer)),
|
|
error => console.error('Error during uploading user configuration', error),
|
|
() => console.log('User configuration has been successfully uploaded')
|
|
);
|
|
}
|
|
}
|