* Fix file selector input * Add file selector state changes back * Remove async pipe
This commit is contained in:
parent
fa110a21d0
commit
b5e927c2c8
|
@ -291,11 +291,26 @@
|
|||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label for="file">2. {{ "selectImportFile" | i18n }}</label>
|
||||
<br />
|
||||
<div class="file-selector">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
(click)="fileSelector.click()"
|
||||
[disabled]="importBlockedByPolicy"
|
||||
>
|
||||
{{ "chooseFile" | i18n }}
|
||||
</button>
|
||||
{{ this.fileSelected ? this.fileSelected.name : ("noFileChosen" | i18n) }}
|
||||
</div>
|
||||
<input
|
||||
#fileSelector
|
||||
type="file"
|
||||
id="file"
|
||||
class="form-control-file"
|
||||
name="file"
|
||||
(change)="setSelectedFile($event)"
|
||||
hidden
|
||||
[disabled]="importBlockedByPolicy"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -25,6 +25,7 @@ export class ImportComponent implements OnInit {
|
|||
importOptions: ImportOption[];
|
||||
format: ImportType = null;
|
||||
fileContents: string;
|
||||
fileSelected: File;
|
||||
formPromise: Promise<ImportError>;
|
||||
loading = false;
|
||||
importBlockedByPolicy = false;
|
||||
|
@ -179,6 +180,11 @@ export class ImportComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
setSelectedFile(event: Event) {
|
||||
const fileInputEl = <HTMLInputElement>event.target;
|
||||
this.fileSelected = fileInputEl.files.length > 0 ? fileInputEl.files[0] : null;
|
||||
}
|
||||
|
||||
private async error(error: Error) {
|
||||
await Swal.fire({
|
||||
heightAuto: false,
|
||||
|
|
Loading…
Reference in New Issue