|
@@ -15,22 +15,29 @@
|
|
|
|
|
|
{% include 'main_header.html.j2' %}
|
|
{% include 'main_header.html.j2' %}
|
|
|
|
|
|
|
|
+
|
|
<form id="fileForm" method="POST" enctype = "multipart/form-data" style="margin: 2em; border-style: groove; padding: 2em;">
|
|
<form id="fileForm" method="POST" enctype = "multipart/form-data" style="margin: 2em; border-style: groove; padding: 2em;">
|
|
<div>
|
|
<div>
|
|
Upload a CSV file:
|
|
Upload a CSV file:
|
|
<fieldset>
|
|
<fieldset>
|
|
- <input type="file" id="FILE" name="FILE"><br/><br/>
|
|
+ <input type="file" id="FILE" name="FILE">
|
|
|
|
+ <b>Data Map: </b>
|
|
|
|
+ <select name="configs" id="configs" onChange="cambio()">
|
|
|
|
+ {% for entry in configs: %}
|
|
|
|
+ <option value={{entry}}>{{entry}}</option>
|
|
|
|
+ {% endfor %}
|
|
|
|
+ </select>
|
|
</fieldset>
|
|
</fieldset>
|
|
<input id="submitted" type="submit" value="Activate Transformation" >
|
|
<input id="submitted" type="submit" value="Activate Transformation" >
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div>
|
|
<br/>... or manually enter the data of a record:<br/><br/>
|
|
<br/>... or manually enter the data of a record:<br/><br/>
|
|
- <fieldset>
|
|
+ <fieldset id="fields">
|
|
- <legend>Record:</legend>
|
|
+ {# <legend>Record:</legend>
|
|
{% for entry in data: %}
|
|
{% for entry in data: %}
|
|
- <label for="nome">{{entry}}</label><br>
|
|
+ <label>{{entry}}</label><br>
|
|
<input type="text" id="{{entry}}" name="{{entry}}" placeholder="data"><br><br>
|
|
<input type="text" id="{{entry}}" name="{{entry}}" placeholder="data"><br><br>
|
|
- {% endfor %}
|
|
+ {% endfor %} #}
|
|
</fieldset>
|
|
</fieldset>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</form>
|
|
@@ -40,15 +47,53 @@
|
|
const downloadName = params.get('downloadFile');
|
|
const downloadName = params.get('downloadFile');
|
|
if(downloadName){
|
|
if(downloadName){
|
|
document.getElementById("fileForm").reset()
|
|
document.getElementById("fileForm").reset()
|
|
- $.get(params.get('downloadUrl'), { filename: downloadName }).done(function(data){
|
|
+ $.get(params.get('downloadUrl'), { filename: downloadName })
|
|
- let link = document.createElement('a');
|
|
+ .done(
|
|
- link.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(data);
|
|
+ data => {
|
|
- link.download = downloadName;
|
|
+ let link = document.createElement('a');
|
|
- link.click();
|
|
+ link.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(data);
|
|
- }
|
|
+ link.download = downloadName;
|
|
- );
|
|
+ link.click();
|
|
|
|
+ }
|
|
|
|
+ );
|
|
alert("Transformation carried out successfully");
|
|
alert("Transformation carried out successfully");
|
|
}
|
|
}
|
|
|
|
+ cambio();
|
|
|
|
+
|
|
|
|
+ function cambio(){
|
|
|
|
+ console.log("CAMBIO!");
|
|
|
|
+ let fn = document.getElementById("configs").value;
|
|
|
|
+ console.log(fn);
|
|
|
|
+ $.get('/getdata/', { confFileName: fn })
|
|
|
|
+ .done(
|
|
|
|
+ data => {
|
|
|
|
+ let fields = document.getElementById("fields");
|
|
|
|
+ fields.innerHTML = "";
|
|
|
|
+ let legend = document.createElement('legend');
|
|
|
|
+ legend.appendChild(document.createTextNode('Record:'));
|
|
|
|
+ fields.appendChild(legend);
|
|
|
|
+ for(let field of data){
|
|
|
|
+ console.log('field', field);
|
|
|
|
+ let fieldLabel = document.createElement("label");
|
|
|
|
+ fieldLabel.appendChild(document.createTextNode(field));
|
|
|
|
+ fields.appendChild(fieldLabel);
|
|
|
|
+ fields.appendChild(document.createElement('br'));
|
|
|
|
+ let fieldInput = document.createElement('input')
|
|
|
|
+ fieldInput.setAttribute('type', 'text');
|
|
|
|
+ fieldInput.setAttribute('id', field);
|
|
|
|
+ fieldInput.setAttribute('name', field);
|
|
|
|
+ fieldInput.setAttribute('placeholder', 'data');
|
|
|
|
+ fields.appendChild(fieldInput);
|
|
|
|
+ fields.appendChild(document.createElement('br'));
|
|
|
|
+ fields.appendChild(document.createElement('br'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ var p = $("<p>Paragraph 3</p>");
|
|
|
|
+ // append the paragraph to the parent
|
|
|
|
+ $("#parent").append(p);
|
|
|
|
+ }
|
|
</script>
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</body>
|