- Improved file input handling in bulk operations: added in-memory blob storage, reset on re-selection, and error handling for file reading. Adjusted indentation and refined event logic.
This commit is contained in:
parent
f9828029a9
commit
ee989d1bfc
1 changed files with 53 additions and 14 deletions
|
|
@ -26,13 +26,13 @@
|
||||||
<div class="bulk-operation-caption">validity period</div>
|
<div class="bulk-operation-caption">validity period</div>
|
||||||
<div class="bulk-operation-data">
|
<div class="bulk-operation-data">
|
||||||
<div class="period-select-container">
|
<div class="period-select-container">
|
||||||
<dropdown :options="periods"
|
<dropdown :options="periods"
|
||||||
emptyText="No property set available"
|
emptyText="No property set available"
|
||||||
class="period-select"
|
class="period-select"
|
||||||
placeholder="Select a property set"
|
placeholder="Select a property set"
|
||||||
v-model="selectedPeriod"
|
v-model="selectedPeriod"
|
||||||
:disabled="!showValidityPeriod"
|
:disabled="!showValidityPeriod"
|
||||||
></dropdown>
|
></dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -77,11 +77,11 @@
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<div class="bulk-operation-box-status-container">
|
<div class="bulk-operation-box-status-container">
|
||||||
<div class="bulk-operation-status">
|
<div class="bulk-operation-status">
|
||||||
<div class="bulk-operation-header">History</div>
|
<div class="bulk-operation-header">History</div>
|
||||||
<div v-if="this.bulkOperationStore.getBulkOperations.length === 0" class="empty-container">No recent bulk operations</div>
|
<div v-if="this.bulkOperationStore.getBulkOperations.length === 0" class="empty-container">No recent bulk operations</div>
|
||||||
<bulk-operation v-else v-for="bulk in this.bulkOperationStore.getBulkOperations" :key="bulk.id" :operation="bulk" @download="fetchFile"></bulk-operation>
|
<bulk-operation v-else v-for="bulk in this.bulkOperationStore.getBulkOperations" :key="bulk.id" :operation="bulk" @download="fetchFile"></bulk-operation>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -112,6 +112,7 @@ export default {
|
||||||
importDataset: "NODE",
|
importDataset: "NODE",
|
||||||
selectedFileName: null,
|
selectedFileName: null,
|
||||||
selectedFile: null,
|
selectedFile: null,
|
||||||
|
fileBlob: null, // Blob im RAM gespeichert
|
||||||
uploading: false,
|
uploading: false,
|
||||||
processId: null,
|
processId: null,
|
||||||
}
|
}
|
||||||
|
|
@ -126,7 +127,7 @@ export default {
|
||||||
async isSelected(newVal) {
|
async isSelected(newVal) {
|
||||||
if(newVal === true)
|
if(newVal === true)
|
||||||
await this.validityPeriodStore.loadPeriods();
|
await this.validityPeriodStore.loadPeriods();
|
||||||
await this.bulkOperationStore.manageStatus();
|
await this.bulkOperationStore.manageStatus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -185,22 +186,60 @@ export default {
|
||||||
await this.bulkOperationStore.scheduleDownload(this.exportDataset, isCurrent ? null : this.selectedPeriod);
|
await this.bulkOperationStore.scheduleDownload(this.exportDataset, isCurrent ? null : this.selectedPeriod);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputFile(event) {
|
async inputFile(event) {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
|
|
||||||
if (file) {
|
if (file) {
|
||||||
this.selectedFile = file;
|
try {
|
||||||
this.selectedFileName = file.name;
|
// Datei sofort in den RAM laden als Blob
|
||||||
|
this.fileBlob = await this.readFileAsBlob(file);
|
||||||
|
|
||||||
|
// File-Objekt mit dem Blob erstellen, das den originalen Namen und Typ behält
|
||||||
|
this.selectedFile = new File([this.fileBlob], file.name, { type: file.type });
|
||||||
|
this.selectedFileName = file.name;
|
||||||
|
|
||||||
|
logger.info(`File loaded into memory: ${file.name} (${(file.size / 1024).toFixed(2)} KB)`);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('Error reading file:', error);
|
||||||
|
this.selectedFile = null;
|
||||||
|
this.selectedFileName = null;
|
||||||
|
this.fileBlob = null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.selectedFile = null;
|
this.selectedFile = null;
|
||||||
this.selectedFileName = null;
|
this.selectedFileName = null;
|
||||||
|
this.fileBlob = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Input zurücksetzen, damit dieselbe Datei erneut ausgewählt werden kann
|
||||||
|
event.target.value = '';
|
||||||
|
},
|
||||||
|
readFileAsBlob(file) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
|
||||||
|
reader.onload = (e) => {
|
||||||
|
// ArrayBuffer in Blob konvertieren
|
||||||
|
const blob = new Blob([e.target.result], { type: file.type });
|
||||||
|
resolve(blob);
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.onerror = (error) => {
|
||||||
|
reject(error);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Datei als ArrayBuffer lesen
|
||||||
|
reader.readAsArrayBuffer(file);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
async uploadFile() {
|
async uploadFile() {
|
||||||
if (!this.selectedFile)
|
if (!this.selectedFile)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await this.bulkOperationStore.scheduleUpload(this.importDataset, this.selectedFile);
|
const file = this.selectedFile;
|
||||||
|
this.selectedFile = null;
|
||||||
|
this.selectedFileName = null;
|
||||||
|
await this.bulkOperationStore.scheduleUpload(this.importDataset, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue