Fix compare problem in Excel files

This commit is contained in:
2023-05-30 00:47:24 +02:00
parent 40af738ed9
commit dd3cb91951
3 changed files with 16 additions and 6 deletions

View File

@@ -63,7 +63,7 @@ def index(compare="False"):
@app.route("/show", methods=["post"]) @app.route("/show", methods=["post"])
def show(): def show():
selected_file = request.form["selected-file"] selected_file = request.form["selected-file"]
compare = request.form["compare"] == "true" compare = request.form["compare"].capitalize() == "True"
with open(os.path.join(Folders.results, selected_file)) as f: with open(os.path.join(Folders.results, selected_file)) as f:
data = json.load(f) data = json.load(f)
try: try:
@@ -82,8 +82,8 @@ def show():
@app.route("/excel", methods=["post"]) @app.route("/excel", methods=["post"])
def excel(): def excel():
selected_files = request.json["selected-files"] selected_files = request.json["selectedFiles"]
compare = request.json["compare"] == "true" compare = request.json["compare"]
book = None book = None
try: try:
for file_name in selected_files: for file_name in selected_files:

View File

@@ -17,11 +17,16 @@ $(document).ready(function () {
}); });
function excelFile() { function excelFile() {
var selectedFiles = ["{{ file }}"]; var selectedFiles = ["{{ file }}"];
var compare = "{{ compare }}" == "True";
var data = {
"selectedFiles": selectedFiles,
"compare": compare
};
// send data to server with ajax post // send data to server with ajax post
$.ajax({ $.ajax({
type:'POST', type:'POST',
url:'/excel', url:'/excel',
data: JSON.stringify(selectedFiles), data: JSON.stringify(data),
contentType: "application/json", contentType: "application/json",
dataType: 'json', dataType: 'json',
success: function(data){ success: function(data){

View File

@@ -54,11 +54,16 @@ function excel() {
alert("Select at least one file"); alert("Select at least one file");
return; return;
} }
// send data to server with ajax post var compare = $("#compare").is(':checked');
// send data to server with ajax post
var data = {
selectedFiles: selectedFiles,
compare: compare
};
$.ajax({ $.ajax({
type:'POST', type:'POST',
url:'/excel', url:'/excel',
data: JSON.stringify(selectedFiles), data: JSON.stringify(data),
contentType: "application/json", contentType: "application/json",
dataType: 'json', dataType: 'json',
success: function(data){ success: function(data){