50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { Component } from '@angular/core';
|
|
import { Store } from '@ngrx/store';
|
|
|
|
import { AppState } from '../../../store';
|
|
import { ResetUserConfigurationAction } from '../../../store/actions/device';
|
|
import {
|
|
LoadUserConfigurationFromFileAction,
|
|
SaveUserConfigInBinaryFileAction,
|
|
SaveUserConfigInJsonFileAction
|
|
} from '../../../store/actions/user-config';
|
|
import { UploadFileData } from '../../../models/upload-file-data';
|
|
|
|
@Component({
|
|
selector: 'device-settings',
|
|
templateUrl: './device-configuration.component.html',
|
|
styleUrls: ['./device-configuration.component.scss'],
|
|
host: {
|
|
'class': 'container-fluid'
|
|
}
|
|
})
|
|
export class DeviceConfigurationComponent {
|
|
|
|
constructor(private store: Store<AppState>) {
|
|
}
|
|
|
|
resetUserConfiguration() {
|
|
this.store.dispatch(new ResetUserConfigurationAction());
|
|
}
|
|
|
|
saveConfigurationInJSONFormat() {
|
|
this.store.dispatch(new SaveUserConfigInJsonFileAction());
|
|
}
|
|
|
|
saveConfigurationInBINFormat() {
|
|
this.store.dispatch(new SaveUserConfigInBinaryFileAction());
|
|
}
|
|
|
|
exportUserConfiguration(event: MouseEvent) {
|
|
if (event.shiftKey) {
|
|
this.saveConfigurationInBINFormat();
|
|
} else {
|
|
this.saveConfigurationInJSONFormat();
|
|
}
|
|
}
|
|
|
|
changeFile(data: UploadFileData): void {
|
|
this.store.dispatch(new LoadUserConfigurationFromFileAction(data));
|
|
}
|
|
}
|