Files
agent/packages/uhk-web/src/app/app.component.ts
Róbert Kiss 13ec617d58 Make saving the configuration more robust (#594)
* feat: Make saving the configuration more robust

* parse backup user config before return

* fix some bug

* Add write-userconfig.js and invalid-config.bin

* throw exception if failed user config parsing

* Merge branch 'master' into feat-467-make-save-more-robust

* hide keymaps and macros if agent in restore mode

* fix Device name settings
2018-04-09 10:11:26 +02:00

62 lines
2.1 KiB
TypeScript

import { Component, ViewEncapsulation } from '@angular/core';
import { animate, style, transition, trigger } from '@angular/animations';
import { Observable } from 'rxjs/Observable';
import { Action, Store } from '@ngrx/store';
import 'rxjs/add/operator/last';
import { DoNotUpdateAppAction, UpdateAppAction } from './store/actions/app-update.action';
import {
AppState,
getShowAppUpdateAvailable,
deviceConfigurationLoaded,
runningInElectron,
saveToKeyboardState
} from './store';
import { ProgressButtonState } from './store/reducers/progress-button-state';
@Component({
selector: 'main-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
encapsulation: ViewEncapsulation.None,
animations: [
trigger(
'showSaveToKeyboardButton', [
transition(':enter', [
style({transform: 'translateY(100%)'}),
animate('400ms ease-in-out', style({transform: 'translateY(0)'}))
]),
transition(':leave', [
style({transform: 'translateY(0)'}),
animate('400ms ease-in-out', style({transform: 'translateY(100%)'}))
])
])
]
})
export class MainAppComponent {
showUpdateAvailable$: Observable<boolean>;
deviceConfigurationLoaded$: Observable<boolean>;
runningInElectron$: Observable<boolean>;
saveToKeyboardState$: Observable<ProgressButtonState>;
constructor(private store: Store<AppState>) {
this.showUpdateAvailable$ = store.select(getShowAppUpdateAvailable);
this.deviceConfigurationLoaded$ = store.select(deviceConfigurationLoaded);
this.runningInElectron$ = store.select(runningInElectron);
this.saveToKeyboardState$ = store.select(saveToKeyboardState);
}
updateApp() {
this.store.dispatch(new UpdateAppAction());
}
doNotUpdateApp() {
this.store.dispatch(new DoNotUpdateAppAction());
}
clickedOnProgressButton(action: Action) {
return this.store.dispatch(action);
}
}