* 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="col-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="file">2. {{ "selectImportFile" | i18n }}</label>
|
<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
|
<input
|
||||||
|
#fileSelector
|
||||||
type="file"
|
type="file"
|
||||||
id="file"
|
id="file"
|
||||||
class="form-control-file"
|
class="form-control-file"
|
||||||
name="file"
|
name="file"
|
||||||
|
(change)="setSelectedFile($event)"
|
||||||
|
hidden
|
||||||
[disabled]="importBlockedByPolicy"
|
[disabled]="importBlockedByPolicy"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,6 +25,7 @@ export class ImportComponent implements OnInit {
|
||||||
importOptions: ImportOption[];
|
importOptions: ImportOption[];
|
||||||
format: ImportType = null;
|
format: ImportType = null;
|
||||||
fileContents: string;
|
fileContents: string;
|
||||||
|
fileSelected: File;
|
||||||
formPromise: Promise<ImportError>;
|
formPromise: Promise<ImportError>;
|
||||||
loading = false;
|
loading = false;
|
||||||
importBlockedByPolicy = 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) {
|
private async error(error: Error) {
|
||||||
await Swal.fire({
|
await Swal.fire({
|
||||||
heightAuto: false,
|
heightAuto: false,
|
||||||
|
|
Loading…
Reference in New Issue