svghmi/widget_jsontable.ysl2
branchsvghmi
changeset 2994 b6a9ef7f7e43
child 2996 14635b09d329
equal deleted inserted replaced
2993:b76f303ffce6 2994:b6a9ef7f7e43
       
     1 // widget_jsontable.ysl2
       
     2 
       
     3 template "widget[@type='JsonTable']", mode="widget_class"
       
     4     ||
       
     5     class JsonTableWidget extends Widget{
       
     6         on_click(evt) {
       
     7             const query = {
       
     8                  offset: '42',
       
     9                  filter: '*powerloss*',
       
    10                  args: this.args
       
    11             };
       
    12 
       
    13             const options = {
       
    14                  method: 'POST',
       
    15                  body: JSON.stringify(query),
       
    16                  headers: {'Content-Type': 'application/json'}
       
    17             }
       
    18 
       
    19             fetch(this.args[0], options)
       
    20                 .then(res => res.json())
       
    21                 .then(res => console.log(res));
       
    22 
       
    23         }
       
    24         init() {
       
    25             this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
       
    26         }
       
    27     }
       
    28     ||