16 headers: {'Content-Type': 'application/json'} |
16 headers: {'Content-Type': 'application/json'} |
17 } |
17 } |
18 |
18 |
19 fetch(this.args[0], options) |
19 fetch(this.args[0], options) |
20 .then(res => res.json()) |
20 .then(res => res.json()) |
21 .then(res => console.log(res)); |
21 .then(this.spread_json_data); |
22 |
22 |
|
23 } |
|
24 dispatch(value) { |
|
25 this.do_http_request(); |
|
26 } |
|
27 on_click(evt) { |
|
28 this.do_http_request(); |
23 } |
29 } |
24 init() { |
30 init() { |
25 this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)"); |
31 this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)"); |
26 } |
32 } |
27 } |
33 } |
28 || |
34 || |
|
35 |
|
36 template "svg:*", mode="json_table_elt_render" { |
|
37 warning > JsonTable Widget can't contain element of type «local-name()». |
|
38 } |
|
39 |
|
40 template "svg:use", mode="json_table_elt_render" { |
|
41 param "value_expr"; |
|
42 | console.log("«@id»", "«$value_expr»", «$value_expr»); |
|
43 } |
|
44 |
|
45 template "svg:text", mode="json_table_elt_render" { |
|
46 param "value_expr"; |
|
47 | console.log("«@id»", "«$value_expr»", «$value_expr»); |
|
48 } |
|
49 |
|
50 template "svg:*", mode="json_table_render" { |
|
51 param "objname"; |
|
52 apply ".", mode="json_table_elt_render" with "value_expr" > «$objname»«@inkscape:label» |
|
53 } |
|
54 |
|
55 template "svg:g", mode="json_table_render" { |
|
56 param "objname"; |
|
57 | let obj_«@id» = «$objname»«@inkscape:label»; |
|
58 apply "*[@inkscape:label]", mode="json_table_render" |
|
59 with "objname" > obj_«@id» |
|
60 } |
|
61 |
|
62 template "widget[@type='JsonTable']", mode="widget_defs" { |
|
63 param "hmi_element"; |
|
64 labels("data"); |
|
65 optional_labels("forward backward cursor"); |
|
66 const "data_elt", "$result_svg_ns//*[@id = $hmi_element/@id]/*[@inkscape:label = 'data']"; |
|
67 | spread_json_data: function(jdata) { |
|
68 | console.log(jdata); |
|
69 apply "$data_elt/*", mode="json_table_render" with "objname","'jdata'"; |
|
70 | } |
|
71 } |