# HG changeset patch
# User Dino Kosic <44305363+kraskrom@users.noreply.github.com>
# Date 1733135599 -3600
# Node ID 4b2de1a0fbf9ce02e3341dc7f3fb35369530255c
# Parent c325749651d1162223ce156db6eef44007e903bd
Extend HMI:JsonTable, create Edit CSV POU, create example, add some doc (#41)
* Extend Jsontable widget, create Edit CSV POU, create example for both
* Add doc for HMI:Image and HMI:JsonTable
* Expand example to include HMI:Image
diff -r c325749651d1 -r 4b2de1a0fbf9 doc/svghmi/widgets.rst
--- a/doc/svghmi/widgets.rst Thu Nov 28 14:46:50 2024 +0100
+++ b/doc/svghmi/widgets.rst Mon Dec 02 11:33:19 2024 +0100
@@ -50,13 +50,39 @@
-----------
+HMI:Image
+---------
+| It is an SVG Image element with label
+| ``HMI:Image:variable``
+| where ``variable`` contains the HTTP GET path to the image it should display.
+
+
HMI:Input
---------
-HMI:Jsontable
+HMI:JsonTable
-------------
-
+| It is a SVG (group) element with label
+| ``HMI:JsonTable:path@notify_var@range_var@position_var@visible_var@filter_var``
+| where:
+* ``path`` is HTTP POST path used to fetch JSON list response
+* ``range_var`` is a variable containing number of elements in a list
+* ``position_var`` is a variable containing index of the first element from the list shown in the table
+* ``visible_var`` is a variable with number of elements to be displayed in the table
+* ``filter_var`` is a variable containing the string which is posted in a request for JSON response, and it's used to filter the results
+| On render request, the widget does a POST request to the path. That request contains all the variables listed above.
+| Handler for the request should be written in such manner that it returns a JSON list containing defined number of elements.
+| Elements are objects with keys and values defined by a user.
+| SVG element itself contains another element group ``data``. All of the elements in that group are also groups, with name ``[i]`` where ``i`` goes from 0 to ``visible_var - 1``. Only the last one is actually created, others are just copy of it.
+| Elements from ``data`` can be placed in such manner to depict table rows.
+| Elements in ``[i]`` can emulate columns. They can be:
+* HMI:TextStyleList (label dictates the style and text content)
+* Image (label dictates path to the image)
+* Other SVG elements
+| Any of the above elements can have label with ``onClick[acknowledge]=var`` which means that on a click on such element, the same POST request is invoked, but among ``options`` posted now there is a variable ``onClick[acknowledge]`` and its value is ``var``
+| Beside ``data`` element, there can also be ``action_reset`` group element with similar behavior as stated above: click invokes POST with ``action_reset`` among ``options``.
+| If it's needed to display images in a table, and those images should be loaded dynamically, one may use GET handler to load and return appropriate image.
HMI:Jump
--------
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/beremiz.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/beremiz.xml Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,5 @@
+
+
+
+
+
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/plc.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/plc.xml Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,337 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FILENAME
+
+
+
+
+
+
+ CSV_ROWIDX
+
+
+
+
+
+
+ CSV_COLIDX
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CSV_ACK
+
+
+
+
+
+
+
+
+
+
+
+
+ CSV_RES
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ FILENAME
+
+
+
+
+
+
+ CSV_ROWIDX
+
+
+
+
+
+
+ CSV_COLIDX
+
+
+
+
+
+
+ CONTENT
+
+
+
+
+
+
+ SAVE
+
+
+
+
+
+
+
+
+
+
+ SEC_ACK
+
+
+
+
+
+
+
+
+
+
+
+
+ SEC_RES
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/project_files/beremiz.png
Binary file exemples/svghmi_csv_json_img_table/project_files/beremiz.png has changed
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/project_files/file.png
Binary file exemples/svghmi_csv_json_img_table/project_files/file.png has changed
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/project_files/folder.png
Binary file exemples/svghmi_csv_json_img_table/project_files/folder.png has changed
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/project_files/test1.csv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/project_files/test1.csv Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,4 @@
+id,value
+1,First
+2,Second
+
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/project_files/test2.csv
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/project_files/test2.csv Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,4 @@
+id,name,value
+1,x,15
+2,11,11
+
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/py_ext_0@py_ext/baseconfnode.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/py_ext_0@py_ext/baseconfnode.xml Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,2 @@
+
+
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/py_ext_0@py_ext/pyfile.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/py_ext_0@py_ext/pyfile.xml Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,144 @@
+
+
+
+
+
+
+
+
+ 0 and extra[0] != "":
+ fFiles = [fl for fl in FileList if extra[0] in fl]
+ else:
+ fFiles = FileList[:]
+ new_range = len(fFiles)
+ delta = new_range - visible
+ new_position = 0 if delta <= 0 else delta if old_position > delta else old_position
+ new_visible = new_range if delta <= 0 else visible
+
+ visible_files = []
+ for desc in fFiles[new_position:new_position + new_visible]:
+ visible_files.append(desc)
+
+ return new_range, new_position, visible_files
+
+
+]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/svghmi_0@svghmi/baseconfnode.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/svghmi_0@svghmi/baseconfnode.xml Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,2 @@
+
+
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/svghmi_0@svghmi/confnode.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/svghmi_0@svghmi/confnode.xml Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,2 @@
+
+
diff -r c325749651d1 -r 4b2de1a0fbf9 exemples/svghmi_csv_json_img_table/svghmi_0@svghmi/svghmi.svg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/svghmi_csv_json_img_table/svghmi_0@svghmi/svghmi.svg Mon Dec 02 11:33:19 2024 +0100
@@ -0,0 +1,1802 @@
+
+
+
+
diff -r c325749651d1 -r 4b2de1a0fbf9 py_ext/pous.xml
--- a/py_ext/pous.xml Thu Nov 28 14:46:50 2024 +0100
+++ b/py_ext/pous.xml Mon Dec 02 11:33:19 2024 +0100
@@ -1657,6 +1657,810 @@