avoid using "Excel" term to enhance comprenshiveness
This commit is contained in:
parent
47fa54fa7b
commit
be74b52b91
2 changed files with 14 additions and 14 deletions
|
|
@ -24,7 +24,7 @@ const CO2_data_form = [
|
|||
"total_people",
|
||||
];
|
||||
|
||||
// Method to upload a valid excel file
|
||||
// Method to upload a valid data file (accepted formats: .xls and .xlsx)
|
||||
function uploadFile(endpoint) {
|
||||
clearFittingResultComponent();
|
||||
const files = $("#file_upload")[0].files;
|
||||
|
|
@ -40,12 +40,12 @@ function uploadFile(endpoint) {
|
|||
.toUpperCase();
|
||||
if (extension !== ".XLS" && extension !== ".XLSX") {
|
||||
$("#upload-error")
|
||||
.text("Please select a valid excel file (.XLS or .XLSX).")
|
||||
.text("Please select a valid data file (.XLS or .XLSX).")
|
||||
.show();
|
||||
return;
|
||||
}
|
||||
|
||||
// FileReader API to read the Excel file
|
||||
// FileReader API to read the data file
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (event) {
|
||||
const fileContent = event.target.result;
|
||||
|
|
@ -79,7 +79,7 @@ function uploadFile(endpoint) {
|
|||
if (data.length <= 1) {
|
||||
$("#upload-error")
|
||||
.text(
|
||||
"The Excel file is empty. Please make sure it contains data below the header row."
|
||||
"The data file is empty. Please make sure it contains data below the header row."
|
||||
)
|
||||
.show();
|
||||
return;
|
||||
|
|
@ -106,9 +106,9 @@ function uploadFile(endpoint) {
|
|||
}
|
||||
}
|
||||
|
||||
// Validate Excel times input encompass simulation time
|
||||
const firstTimeInExcel = parseFloat((data[1][timesColumnIndex] * 60).toFixed(2))
|
||||
const lastTimeInExcel = parseFloat((data[data.length - 1][timesColumnIndex] * 60).toFixed(2))
|
||||
// Validate times data encompass simulation time
|
||||
const firstTimeInData = parseFloat((data[1][timesColumnIndex] * 60).toFixed(2))
|
||||
const lastTimeInData = parseFloat((data[data.length - 1][timesColumnIndex] * 60).toFixed(2))
|
||||
// Validate start time
|
||||
const infected_start = $(`[name=infected_start]`).first().val();
|
||||
const exposed_start = $(`[name=exposed_start]`).first().val();
|
||||
|
|
@ -132,14 +132,14 @@ function uploadFile(endpoint) {
|
|||
elapsed_time_exposed = hours_exposed * 60 + minutes_exposed;
|
||||
|
||||
const max_presence_time = parseFloat((Math.max(elapsed_time_infected, elapsed_time_exposed)).toFixed(2));
|
||||
if (firstTimeInExcel > min_presence_time || lastTimeInExcel < max_presence_time) {
|
||||
if (firstTimeInData > min_presence_time || lastTimeInData < max_presence_time) {
|
||||
$("#upload-error")
|
||||
.text(`The Excel times should encompass the entire simulation time (from ${min_presence_time/60} to ${max_presence_time/60}).
|
||||
Got Excel times from ${firstTimeInExcel/60} to ${lastTimeInExcel/60}. Either adapt the simulation presence times, or the Excel data.`).show();
|
||||
.text(`The times data of the file should encompass the entire simulation time (from ${min_presence_time/60} to ${max_presence_time/60}).
|
||||
Got times from ${firstTimeInData/60} to ${lastTimeInData/60}. Either adapt the simulation presence times, or the times data of the file.`).show();
|
||||
return;
|
||||
}
|
||||
|
||||
// Convert Excel file to JSON and further processing
|
||||
// Convert data file to JSON and further processing
|
||||
try {
|
||||
generateJSONStructure(endpoint, data);
|
||||
// If all validations pass, process the file here or display a success message
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex d-row justify-content-between">
|
||||
<h5 class="mt-auto mb-auto">Upload an Excel file:</h5>
|
||||
<h5 class="mt-auto mb-auto">Upload a valid data file (.xls or .xlsx):</h5>
|
||||
<a class="btn btn-primary btn-sm" href="https://caimira-resources.web.cern.ch/CO2_template.xlsx">Download template</a>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
|
|
@ -333,12 +333,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<!-- Input element to upload an excel file -->
|
||||
<!-- Input element to upload a data file -->
|
||||
<input type="file" id="file_upload" accept=".xlsx, .xls"/>
|
||||
<button type="button" class="btn btn-primary btn-sm" onclick="uploadFile('{{ get_calculator_url() }}/co2-fit/plot');">Upload</button>
|
||||
<div id="upload-error" class="mb-0 mt-2 alert alert-danger" style="display: none" role="alert"></div>
|
||||
<br>
|
||||
<!-- Formatted excel data -->
|
||||
<!-- Formatted data from input -->
|
||||
<input id="CO2_data" type="text" name="CO2_data" form="not-submitted" class="form-control d-none" placeholder='{"times": [...], "concentrations": [...]}' value="{}"><br>
|
||||
<div id="CO2_input_data_div" style="display: none"></div>
|
||||
<input type="text" class="form-control d-none" name="CO2_fitting_result" id="CO2_fitting_result">
|
||||
|
|
|
|||
Loading…
Reference in a new issue