Files
agent/packages/uhk-web/src/app/components/device/configuration/device-configuration.component.ts
Róbert Kiss 8e20c85e07 feat: add file upload component (#655)
The component allow upload the same file multiple times
2018-05-26 22:46:41 +02:00

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));
}
}