fix(user-config): Fix user configuration savings (#433)
* test(user-config): Fix saveAs functionality * feat(user-config): Add 2 space indent when save user-config to json file * refactor(user-config): Move user config savings into user config effect * build: Remove unused package
This commit is contained in:
committed by
László Monda
parent
35c0d98cd2
commit
23af522a48
@@ -2,7 +2,6 @@ import { Component, HostListener, ViewEncapsulation } from '@angular/core';
|
||||
import { animate, style, transition, trigger } from '@angular/animations';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Action, Store } from '@ngrx/store';
|
||||
import { UhkBuffer } from 'uhk-common';
|
||||
|
||||
import 'rxjs/add/operator/last';
|
||||
|
||||
@@ -14,8 +13,8 @@ import {
|
||||
runningInElectron,
|
||||
saveToKeyboardState
|
||||
} from './store';
|
||||
import { getUserConfiguration } from './store/reducers/user-configuration';
|
||||
import { ProgressButtonState } from './store/reducers/progress-button-state';
|
||||
import { SaveUserConfigInBinaryFileAction, SaveUserConfigInJsonFileAction } from './store/actions/user-config';
|
||||
|
||||
@Component({
|
||||
selector: 'main-app',
|
||||
@@ -65,28 +64,13 @@ export class MainAppComponent {
|
||||
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');
|
||||
});
|
||||
this.store.dispatch(new SaveUserConfigInJsonFileAction());
|
||||
}
|
||||
|
||||
@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'));
|
||||
this.store.dispatch(new SaveUserConfigInBinaryFileAction());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user