Skip to content

Commit 0d2bde7

Browse files
authored
Merge pull request #163 from chinyihan/getIconType
Modified part of the codes in bora_save to retrieve icon type
2 parents 18840d1 + 868f93d commit 0d2bde7

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

blueprint/designer.html

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,9 @@
141141
{% end %}
142142

143143
{% if data['style'][key]['type'] == "icon" %}
144-
<div id='{{ key }}' class='varbox' data-type="{{ data['style'][key]['type'] }}" data-onCondition="{{ data['style'][key]['div']['data-onCondition'] }}" data-link-adei="{{ data['style'][key]['div']['data-link-adei'] }}" data-trend="{{ data['style'][key]['div']['data-trend'] }}"
145-
style='position: absolute; top:{{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }};
146-
icon-type:{{ data['style'][key]['icon-type'] }}; rotate:{{ data['style'][key]['div']['rotate'] }};'>
147-
<img width='{{ data['style'][key]['width'] }}' height='{{ data['style'][key]['height'] }}' src="{{ static_url( data['style'][key]['icon-type'] + '_inactive.png' ) }}"></img>
144+
<div id='{{ key }}' class='varbox' data-type="{{ data['style'][key]['type'] }}" data-icon-type="{{ data['style'][key]['div']['data-icon-type'] }}" data-onCondition="{{ data['style'][key]['div']['data-onCondition'] }}" data-link-adei="{{ data['style'][key]['div']['data-link-adei'] }}" data-trend="{{ data['style'][key]['div']['data-trend'] }}"
145+
style='position: absolute; top:{{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; rotate:{{ data['style'][key]['div']['rotate'] }};'>
146+
<img width='{{ data['style'][key]['width'] }}' height='{{ data['style'][key]['height'] }}' src="{{ static_url( data['style'][key]['div']['data-icon-type'] + '_inactive.png' ) }}"></img>
148147
</div>
149148
{% else %}
150149
{% end %}
@@ -1290,7 +1289,7 @@
12901289

12911290
if (item_array[item_array.length -1] == "nodata") {
12921291

1293-
if (["name", "text_name", "unit_name", "int_to_str", "icon_type"].indexOf(item_array[2]) === -1) {
1292+
if (["name", "text_name", "unit_name", "int_to_str"].indexOf(item_array[2]) === -1) {
12941293
css_property = item_array[2].replace(/_/g, '-');
12951294
div_style += css_property + ":" + params[item] + "; ";
12961295
}
@@ -1347,7 +1346,7 @@
13471346
break;
13481347
case "icon":
13491348
// TODO: NTJ -> Bug
1350-
var icon_src = window.location.origin + "/static/" + params["icon-div-icon_type-must-nodata"] + "_inactive.png";
1349+
var icon_src = window.location.origin + "/static/" + params["icon-div-icon_type-must-data"] + "_inactive.png";
13511350
//var icon_src = "/static/" + params["icon-div-icon_type-must-nodata"] + "_inactive.png";
13521351
html_element += "<img src='" + icon_src + "' width='100%' height='100%'></img>";
13531352
break;
@@ -1389,7 +1388,7 @@
13891388
var div_text = "";
13901389
var div_data = "";
13911390
var div_style = " style='position: absolute; top:200px; left:200px; ";
1392-
1391+
13931392
for (item in params) {
13941393
if (item.startsWith(prefix)) {
13951394
if (!verifyRequiredFields(item, prefix)) { return; }
@@ -1732,8 +1731,8 @@
17321731
};
17331732
}
17341733

1735-
// Helper Function: gets the css style properties of an element
1736-
function collectCssStyles(element_id, category) {
1734+
// Helper Function: gets the div attributes properties of an element
1735+
function collectDivAttributes(element_id, category) {
17371736
let mydiv = {};
17381737
mycat = category.replace(/-/g, '_');
17391738

@@ -1742,7 +1741,7 @@
17421741
var item_array = item.split("-");
17431742
var css_property = item_array[2].replace(/_/g, '-');
17441743

1745-
if (item_array[1] == "div" && item_array[2] !== "icon_type") {
1744+
if (item_array[1] == "div") {
17461745
switch (item_array[2]) {
17471746
case "text_name":
17481747
mydiv[css_property] = $("#" + element_id + "> .text_name").text().trim();
@@ -1795,12 +1794,7 @@
17951794
$('*[data-type="' + mycategory + '"]').each(function() {
17961795
var element_id = $(this).attr('id');
17971796
var attributes = extractElementAttributes(element_id);
1798-
var styles = collectCssStyles(element_id, mycategory);
1799-
1800-
if (attributes["type"] == "icon") {
1801-
// TODO: NTJ: This is a hard code, need to be fixed!!!
1802-
attributes["icon-type"] = "valve"; // hard code
1803-
}
1797+
var styles = collectDivAttributes(element_id, mycategory);
18041798

18051799
attributes["widget"] = mycategory;
18061800
attributes["div"] = styles;

template/icon.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{% if data['style'][key]['type'] == "icon" %}
2-
<div id='{{ key }}' onclick="open_adei_page('{{ key }}')" class="databox" tooltip="" data-icon-type="{{ data['style'][key]['icon-type'] }}" data-query="{{ data['varname'][key]['url'] }}" data-type="{{ data['style'][key]['type'] }}" data-onCondition="{{ data['style'][key]['div']['data-onCondition'] }}" data-link-adei="{{ data['style'][key]['div']['data-link-adei'] }}" data-trend="{{ data['style'][key]['div']['data-trend'] }}"
3-
style='position: absolute; top:{{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }};
4-
icon-type:{{ data['style'][key]['icon-type'] }};'>
5-
<img width='{{ data['style'][key]['width'] }}' height='{{ data['style'][key]['height'] }}' style='rotate:{{ data['style'][key]['div']['rotate'] }}' src="{{ static_url( data['style'][key]['icon-type'] + '_inactive.png' ) }}"></img>
2+
<div id='{{ key }}' onclick="open_adei_page('{{ key }}')" class="databox" tooltip="" data-query="{{ data['varname'][key]['url'] }}" data-type="{{ data['style'][key]['type'] }}" data-icon-type="{{ data['style'][key]['div']['data-icon-type'] }}" data-onCondition="{{ data['style'][key]['div']['data-onCondition'] }}" data-link-adei="{{ data['style'][key]['div']['data-link-adei'] }}" data-trend="{{ data['style'][key]['div']['data-trend'] }}"
3+
style='position: absolute; top:{{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }};'>
4+
<img width='{{ data['style'][key]['width'] }}' height='{{ data['style'][key]['height'] }}' style='rotate:{{ data['style'][key]['div']['rotate'] }}' src="{{ static_url( data['style'][key]['div']['data-icon-type'] + '_inactive.png' ) }}"></img>
65
</div>
76
{% else %}
87
{% end %}

typedef/icon.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- "switch"
1111
"type": "select"
1212
"optional": "No"
13-
"data": "No"
13+
"data": "Yes"
1414
"onCondition":
1515
"value": ""
1616
"type": "string"

0 commit comments

Comments
 (0)