# HG changeset patch
# User Edouard Tisserant
# Date 1598012943 -7200
# Node ID 793ce211725820eb71fb6e379f6623eaa330cf60
# Parent 52f6548982d4730d7d58881ae3ed58098c3b1593
SVGHMI: JsonTable now makes meaningfull JSON request : all arguments and variables are passed in.
diff -r 52f6548982d4 -r 793ce2117258 svghmi/gen_index_xhtml.xslt
--- a/svghmi/gen_index_xhtml.xslt Fri Aug 21 13:22:54 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Fri Aug 21 14:29:03 2020 +0200
@@ -3337,7 +3337,7 @@
", "
- ", this, this.last_val,size);
+ ", this, this.last_val, size);
},
@@ -3351,15 +3351,15 @@
class JsonTableWidget extends Widget{
+ cache = [];
+
do_http_request() {
const query = {
- offset: '42',
-
- filter: '*powerloss*',
-
- args: this.args
+ args: this.args,
+
+ vars: this.cache
};
@@ -3373,7 +3373,7 @@
headers: {'Content-Type': 'application/json'}
- }
+ };
@@ -3387,7 +3387,11 @@
}
- dispatch(value) {
+ dispatch(value, oldval, index) {
+
+ console.log("mhooo", index);
+
+ this.cache[index] = value;
this.do_http_request();
@@ -4017,11 +4021,23 @@
on_Enter_click() {
- end_modal.call(this);
-
- let callback_obj = this.result_callback_obj;
-
- callback_obj.edit_callback(this.editstr);
+ let coercedval = (typeof this.initial) == "number" ? Number(this.editstr) : this.editstr;
+
+ if(isNaN(coercedval)){
+
+ this.editstr = String(this.initial);
+
+ this.update();
+
+ } else { // revert to initial so it explicitely shows input was ignored
+
+ let callback_obj = this.result_callback_obj;
+
+ end_modal.call(this);
+
+ callback_obj.edit_callback(coercedval);
+
+ }
}
@@ -4115,7 +4131,7 @@
show_modal.call(this,size);
- this.editstr = initial;
+ this.editstr = String(initial);
this.result_callback_obj = callback_obj;
@@ -4125,6 +4141,10 @@
this.caps = false;
+ this.initial = initial;
+
+
+
this.update();
}
diff -r 52f6548982d4 -r 793ce2117258 svghmi/widget_input.ysl2
--- a/svghmi/widget_input.ysl2 Fri Aug 21 13:22:54 2020 +0200
+++ b/svghmi/widget_input.ysl2 Fri Aug 21 14:29:03 2020 +0200
@@ -35,7 +35,7 @@
| },
| on_edit_click: function(opstr) {
| var size = (typeof this.key_pos_elt !== 'undefined') ? this.key_pos_elt.getBBox() : undefined
- | edit_value("«path/@value»", "«path/@type»", this, this.last_val,size);
+ | edit_value("«path/@value»", "«path/@type»", this, this.last_val, size);
| },
| edit_callback: function(new_val) {
diff -r 52f6548982d4 -r 793ce2117258 svghmi/widget_jsontable.ysl2
--- a/svghmi/widget_jsontable.ysl2 Fri Aug 21 13:22:54 2020 +0200
+++ b/svghmi/widget_jsontable.ysl2 Fri Aug 21 14:29:03 2020 +0200
@@ -3,25 +3,27 @@
template "widget[@type='JsonTable']", mode="widget_class"
||
class JsonTableWidget extends Widget{
+ cache = [];
do_http_request() {
const query = {
- offset: '42',
- filter: '*powerloss*',
- args: this.args
+ args: this.args,
+ vars: this.cache
};
const options = {
method: 'POST',
body: JSON.stringify(query),
headers: {'Content-Type': 'application/json'}
- }
+ };
fetch(this.args[0], options)
.then(res => res.json())
.then(this.spread_json_data);
}
- dispatch(value) {
+ dispatch(value, oldval, index) {
+ console.log("mhooo", index);
+ this.cache[index] = value;
this.do_http_request();
}
on_click(evt) {
diff -r 52f6548982d4 -r 793ce2117258 tests/svghmi/py_ext_0@py_ext/pyfile.xml
--- a/tests/svghmi/py_ext_0@py_ext/pyfile.xml Fri Aug 21 13:22:54 2020 +0200
+++ b/tests/svghmi/py_ext_0@py_ext/pyfile.xml Fri Aug 21 14:29:03 2020 +0200
@@ -2,7 +2,7 @@
-
+
+ inkscape:label="HMI:Keypad:HMI_STRING:HMI_LOCAL:PAGE_LOCAL">
+ inkscape:label="HMI:JsonTable:/alarms@/ALARMNOTIFY@.position@.range"
+ transform="matrix(0.5,0,0,0.5,515.30409,71.500438)">
@@ -3145,12 +3145,13 @@
sodipodi:role="line">information
+ transform="matrix(0.16718216,0,0,0.16718216,1142.9386,20.988849)"
+ inkscape:label="HMI:Input@/ALARMNOTIFY"
+ id="g5222"
+ style="stroke-width:1.51188684">
8888
+ style="stroke-width:1.51188684px">8888
+ style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ff00ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:7.55943441;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
8888
+ transform="matrix(0.14295135,0,0,0.14295135,489.21833,37.615184)">
8888
+ style="stroke-width:4px">8888
-
+
@@ -4269,21 +4270,21 @@
id="path1465"
d="m 797.19546,145.18619 -80.62929,0.60214 -0.60215,-80.629288 80.6293,-0.60214 z"
inkscape:transform-center-y="-14.956361"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
+ style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:20;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
dhu
@@ -4302,12 +4303,12 @@
sodipodi:cx="596.74072"
sodipodi:sides="3"
id="path1473"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:20;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
sodipodi:type="star"
transform="matrix(0,-2.0000001,1.9999999,0,1034.195,1298.6541)" />
plop
-
- plop
+
+
@@ -4326,7 +4327,7 @@
inkscape:transform-center-x="14.956364"
transform="rotate(-90,746.45698,-44.543641)"
sodipodi:type="star"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:20;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="path1481"
sodipodi:sides="3"
sodipodi:cx="596.74072"
@@ -4344,16 +4345,16 @@
id="text1485"
y="111.05016"
x="537.25018"
- style="font-style:normal;font-weight:normal;font-size:20px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ style="font-style:normal;font-weight:normal;font-size:20px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve">mhoo
@@ -4373,22 +4374,22 @@
sodipodi:cx="596.74072"
sodipodi:sides="3"
id="path1489"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:20;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
sodipodi:type="star" />
yodl
@@ -4396,7 +4397,7 @@
inkscape:transform-center-x="-14.956349"
transform="matrix(0,-2.0000001,-1.9999999,0,1122.1514,1298.6541)"
sodipodi:type="star"
- style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:10;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
+ style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:20;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="path1497"
sodipodi:sides="3"
sodipodi:cx="596.74072"
@@ -4412,7 +4413,7 @@
inkscape:transform-center-y="-3.3040441e-05" />
mhe
+ style="stroke-width:2px">mhe
HMI_LOCAL variables
+ x="509.67926"
+ y="43.42762">HMI_LOCAL variables
@@ -4465,35 +4466,35 @@
8888
+ style="stroke-width:4">
8888
-
+
dhu
+ style="stroke-width:2px">dhu
+ style="stroke-width:4">
+ style="stroke-width:4">
mhoo
+ style="stroke-width:2px">mhoo
+ style="stroke-width:4">
yodl
+ style="stroke-width:2px">yodl
+ style="stroke-width:4">
@@ -4656,9 +4657,9 @@
id="text1601"
y="111.05016"
x="842.71497"
- style="font-style:normal;font-weight:normal;font-size:20px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ style="font-style:normal;font-weight:normal;font-size:20px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve">
PAGE_LOCAL variables
@@ -5822,4 +5823,167 @@
transform="translate(-573,80.999998)"
inkscape:label="disabled" />
+
+ 8888
+
+
+
+
+
+ 8888
+
+
+
+
+ range
+ position
+ notify
+
+