Commit 6658c0da authored by Roque Porchetto's avatar Roque Porchetto

erp5_wendelin_telecom_UI: render metadata of csv files

parent add91219
......@@ -22,7 +22,7 @@
<div class="center">
<div class="ui-field-contain" style="margin-top:25px">
<label for="field_my_title" id="text_content_title"></label>
<div style="white-space:pre-wrap" id="text_content"/>
<div style="white-space:pre-wrap" id="text_content"><table style="width:100%" id="csv_table"></table></div>
</div>
</div>
</body>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.17679.31334.49186</string> </value>
<value> <string>969.17813.55030.4608</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1533042241.37</float>
<float>1533050893.62</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -41,37 +41,51 @@
var view_dict = {},
group_list = [],
metadata = gadget.state.metadata;
view_dict["my_title"] = {
view_dict.my_title = {
"title": "Title",
"default": gadget.state.document_title,
"key": "field_my_title"
};
group_list.push(["left", [["my_title"]]])
view_dict["my_reference"] = {
group_list.push(["left", [["my_title"]]]);
view_dict.my_reference = {
"title": "Reference",
"default": gadget.state.reference,
"key": "field_my_reference"
};
group_list.push(["right",[["my_reference"]]])
if (metadata != null) {
group_list.push(["right", [["my_reference"]]]);
if (metadata !== undefined) {
if (Object.keys(metadata).length == 1) {
var key = Object.keys(metadata)[0]
document.getElementById("text_content_title").innerHTML = key;
document.getElementById("text_content").innerHTML = metadata[key];
var akey = Object.keys(metadata)[0];
if (akey == "csv") {
var table = document.getElementById("csv_table"),
array = metadata[akey];
document.getElementById("text_content_title").innerHTML = "CSV file content sample:";
for (var i = 0; i < array.length; i++) {
var newRow = table.insertRow(table.length);
for (var j = 0; j < array[i].length; j++) {
var cell = newRow.insertCell(j);
cell.innerHTML = array[i][j];
}
}
}
else {
document.getElementById("text_content_title").innerHTML = akey;
document.getElementById("text_content").innerHTML = metadata[akey];
}
}
else {
var i = 0
var nkey = 0;
for (var key in metadata) {
if (metadata.hasOwnProperty(key)) {
var side = (i % 2 == 0) ? "left" : "right" ;
view_dict[key] = {
"title": key,
"default": metadata[key],
"key": "field_" + key
};
group_list.push([side,[[key]]])
}
i++;
if (metadata.hasOwnProperty(key)) {
var side = (nkey % 2 === 0) ? "left" : "right";
view_dict[key] = {
"title": key,
"default": metadata[key],
"key": "field_" + key
};
group_list.push([side, [[key]]]);
}
nkey++;
}
}
}
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.17646.40993.45789</string> </value>
<value> <string>969.17819.38822.28450</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1533040886.97</float>
<float>1533050930.1</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment