From 2a8325c6ce39e0910780dec66f2c3b3738e298f9 Mon Sep 17 00:00:00 2001 From: Alex H Date: Thu, 13 Apr 2023 17:52:13 +0000 Subject: [PATCH] initial server side processing --- ui/src/router/views/import-generic.vue | 29 +++++++++----------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/ui/src/router/views/import-generic.vue b/ui/src/router/views/import-generic.vue index 2aec1d1..3b01d36 100644 --- a/ui/src/router/views/import-generic.vue +++ b/ui/src/router/views/import-generic.vue @@ -76,26 +76,17 @@ export default { Papa.parse(this.file, this.papaConfig) }, importData() { - const fillups = [] - for (let i = 1; i < this.fileData.length; i++) { - const fillup = { - date: this.fillupModel.date !== null ? this.fileData[i][this.fillupModel.date] : null, - fuelSubType: this.fillupModel.fuelsubtype !== null ? this.fileData[i][this.fillupModel.fuelSubType] : null, - fuelQuantity: this.fillupModel.fuelQuantity !== null ? this.fileData[i][this.fillupModel.fuelQuantity] : null, - perUnitPrice: this.fillupModel.perUnitPrice !== null ? this.fileData[i][this.fillupModel.perUnitPrice] : null, - totalAmount: this.fillupModel.totalAmount > -1 ? this.fileData[i][this.fillupModel.totalAmount] : (this.fileData[i][this.fillupModel.fuelQuantity] * this.fileData[i][this.fillupModel.perUnitPrice]).toFixed(2), - odoReading: this.fillupModel.odoReading !== null ? this.fileData[i][this.fillupModel.odoReading] : null, - isTankFull: this.fillupModel.isTankFull !== null ? this.fileData[i][this.fillupModel.isTankFull] : null, - hasMissedFillup: this.fillupModel.hasMissedFillup !== null ? this.fileData[i][this.fillupModel.hasMissedFillup] : null, - comments: this.fillupModel.comments.length === 1 ? this.fileData[i][this.fillupModel.comments] : '', - fillingStation: this.fillupModel.fillingStation !== null ? this.fileData[i][this.fillupModel.fillingStation] : null, - } - if (this.inverted) { - fillup.isTankFull = !fillup.isTankFull - } - fillups.push(fillup) + if (typeof this.fileData[1][this.fillupModel.isTankFull] !== "boolean") { + this.errors.push('The value of Tank Full needs to be a boolean (true,false).') + return } - alert(JSON.stringify(fillups[1])) + const content = { + headings: this.fillupModel, + data: this.fileData.splice(1, this.fileData.length), + fullTankInverted: this.inverted, + vehicleId: this.selectedVehicle.id + } + alert(JSON.stringify(content)) }, } }