Read tarball into in-memory config provider
This commit is contained in:
parent
8aa18a29a8
commit
bb2b28cd11
5 changed files with 83 additions and 9 deletions
|
@ -8,7 +8,7 @@ const styleUrl = require('./load-config.css');
|
|||
styleUrls: [ styleUrl ],
|
||||
})
|
||||
export class LoadConfigComponent {
|
||||
private isReady: boolean = false;
|
||||
private readyToSubmit: boolean = false;
|
||||
private uploadFunc: Function;
|
||||
private state: 'load' | 'validate' = 'load';
|
||||
|
||||
|
@ -16,12 +16,12 @@ export class LoadConfigComponent {
|
|||
}
|
||||
|
||||
private handleTarballSelected(files: File[], callback: Function) {
|
||||
this.isReady = true;
|
||||
this.readyToSubmit = true;
|
||||
callback(true)
|
||||
}
|
||||
|
||||
private handleTarballCleared() {
|
||||
this.isReady = false;
|
||||
this.readyToSubmit = false;
|
||||
}
|
||||
|
||||
private uploadTarball() {
|
||||
|
@ -30,7 +30,8 @@ export class LoadConfigComponent {
|
|||
this.state = 'validate';
|
||||
}
|
||||
else {
|
||||
this.apiService.errorDisplay('Could not upload configuration. Please reload the page and try again.\n' +
|
||||
this.apiService.errorDisplay('Error loading configuration',
|
||||
'Could not upload configuration. Please reload the page and try again.\n' +
|
||||
'If this problem persists, please contact support')();
|
||||
}
|
||||
});
|
||||
|
@ -42,7 +43,7 @@ export class LoadConfigComponent {
|
|||
* @param files: files to upload
|
||||
* @param uploadFiles: function to call to upload files
|
||||
*/
|
||||
private filesValidated(files, uploadFiles) {
|
||||
private tarballValidatedByUploadBox(files, uploadFiles) {
|
||||
this.uploadFunc = uploadFiles;
|
||||
}
|
||||
}
|
|
@ -14,11 +14,11 @@
|
|||
select-message="Select a previous configuration to modify. Must be in tar.gz format"
|
||||
files-selected="$ctrl.handleTarballSelected(files, callback)"
|
||||
files-cleared="$ctrl.handleFilesCleared()"
|
||||
files-validated="$ctrl.filesValidated(files, uploadFiles)"
|
||||
files-validated="$ctrl.tarballValidatedByUploadBox(files, uploadFiles)"
|
||||
extensions="['application/gzip', '.gz']"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" ng-click="$ctrl.uploadTarball()" ng-disabled="!$ctrl.isReady">
|
||||
<button type="button" class="btn btn-primary" ng-click="$ctrl.uploadTarball()" ng-disabled="!$ctrl.readyToSubmit">
|
||||
Upload Configuration
|
||||
</button>
|
||||
</div>
|
||||
|
|
Reference in a new issue