svghmi/widget_jsontable.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 17 Jul 2020 12:19:53 +0200
branchsvghmi
changeset 2995 7769e7c7f925
parent 2994 b6a9ef7f7e43
child 2996 14635b09d329
permissions -rw-r--r--
SVGHMI: Minimal support for HMI:List : clones pointing to elements of any HMI:List are never unlinked, widgets using HMI:List will rely on this.
// widget_jsontable.ysl2

template "widget[@type='JsonTable']", mode="widget_class"
    ||
    class JsonTableWidget extends Widget{
        on_click(evt) {
            const query = {
                 offset: '42',
                 filter: '*powerloss*',
                 args: this.args
            };

            const options = {
                 method: 'POST',
                 body: JSON.stringify(query),
                 headers: {'Content-Type': 'application/json'}
            }

            fetch(this.args[0], options)
                .then(res => res.json())
                .then(res => console.log(res));

        }
        init() {
            this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
        }
    }
    ||