index.html.j2 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initialscale=1.0">
  6. <title>IPERION-HS Semantic Data Integrator (task 5.4)</title>
  7. <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  8. <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  9. <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  10. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  11. </head>
  12. <body>
  13. {% include 'main_header.html.j2' %}
  14. <form id="fileForm" method="POST" enctype = "multipart/form-data" style="margin: 2em; border-style: groove; padding: 2em;">
  15. <div>
  16. Upload a CSV file:
  17. <fieldset>
  18. <input type="file" id="FILE" name="FILE"><br/><br/>
  19. </fieldset>
  20. <input id="submitted" type="submit" value="Activate Transformation" >
  21. </div>
  22. <div>
  23. <br/>... or manually enter the data of a record:<br/><br/>
  24. <fieldset>
  25. <legend>Record:</legend>
  26. {% for entry in data: %}
  27. <label for="nome">{{entry}}</label><br>
  28. <input type="text" id="{{entry}}" name="{{entry}}" placeholder="data"><br><br>
  29. {% endfor %}
  30. </fieldset>
  31. </div>
  32. </form>
  33. <script>
  34. const params = new URLSearchParams(window.location.search);
  35. const downloadName = params.get('download');
  36. if(downloadName){
  37. document.getElementById("fileForm").reset()
  38. $.get('/download', { filename: downloadName }).done(function(data){
  39. let link = document.createElement('a');
  40. link.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(data);
  41. link.download = downloadName;
  42. link.click();
  43. }
  44. );
  45. alert("Transformation carried out successfully");
  46. }
  47. </script>
  48. </body>
  49. </html>