index.html.j2 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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">
  19. <b>Data Map: </b>
  20. <select name="configs" id="configs" onChange="cambio()">
  21. {% for entry in configs: %}
  22. <option value={{entry}}>{{entry}}</option>
  23. {% endfor %}
  24. </select>
  25. </fieldset>
  26. <input id="submitted" type="submit" value="Activate Transformation" >
  27. </div>
  28. <div>
  29. <br/>... or manually enter the data of a record:<br/><br/>
  30. <fieldset id="fields">
  31. {# <legend>Record:</legend>
  32. {% for entry in data: %}
  33. <label>{{entry}}</label><br>
  34. <input type="text" id="{{entry}}" name="{{entry}}" placeholder="data"><br><br>
  35. {% endfor %} #}
  36. </fieldset>
  37. </div>
  38. </form>
  39. <script>
  40. const params = new URLSearchParams(window.location.search);
  41. const downloadName = params.get('downloadFile');
  42. if(downloadName){
  43. document.getElementById("fileForm").reset()
  44. $.get(params.get('downloadUrl'), { filename: downloadName })
  45. .done(
  46. data => {
  47. let link = document.createElement('a');
  48. link.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(data);
  49. link.download = downloadName;
  50. link.click();
  51. }
  52. );
  53. alert("Transformation carried out successfully");
  54. }
  55. cambio();
  56. function cambio(){
  57. console.log("CAMBIO!");
  58. let fn = document.getElementById("configs").value;
  59. console.log(fn);
  60. $.get('/getdata/', { confFileName: fn })
  61. .done(
  62. data => {
  63. let fields = document.getElementById("fields");
  64. fields.innerHTML = "";
  65. let legend = document.createElement('legend');
  66. legend.appendChild(document.createTextNode('Record:'));
  67. fields.appendChild(legend);
  68. for(let field of data){
  69. console.log('field', field);
  70. let fieldLabel = document.createElement("label");
  71. fieldLabel.appendChild(document.createTextNode(field));
  72. fields.appendChild(fieldLabel);
  73. fields.appendChild(document.createElement('br'));
  74. let fieldInput = document.createElement('input')
  75. fieldInput.setAttribute('type', 'text');
  76. fieldInput.setAttribute('id', field);
  77. fieldInput.setAttribute('name', field);
  78. fieldInput.setAttribute('placeholder', 'data');
  79. fields.appendChild(fieldInput);
  80. fields.appendChild(document.createElement('br'));
  81. fields.appendChild(document.createElement('br'));
  82. }
  83. }
  84. );
  85. var p = $("<p>Paragraph 3</p>");
  86. // append the paragraph to the parent
  87. $("#parent").append(p);
  88. }
  89. </script>
  90. </body>
  91. </html>