summaryrefslogtreecommitdiffstats
path: root/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js
blob: dbd95c9a6ce1f1218832efd4c53f235ada136879 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
'use strict';
'require baseclass';
'require form';

return baseclass.extend({
    title: _('Mqtt Plugin Configuration'),

    addFormOptions(s) {
        let o, ss;

        o = s.option(form.Flag, 'enable', _('Sends or receives data via mqtt'));

        o = s.option(form.SectionValue, '__blocks', form.GridSection, 'collectd_mqtt_block');
        o.depends('enable', '1');

        ss = o.subsection;
        ss.anonymous = true;
        ss.addremove = true;

        o = ss.option(form.ListValue, 'blocktype', _('Type'));
        o.value('Publish', _('Publish'));
        o.value('Subscribe', _('Subscribe'));
        o.default = 'Publish';

        o = ss.option(form.Value, 'name', _('Name'));
        o.optional = false;
        o.rmempty = false;

        o = ss.option(form.Value, 'Host', _('Host'));
        o.datatype = 'host';
        o.optional = false;
        o.rmempty = false;

        o = ss.option(form.Value, 'Port', _('Port'));
        o.datatype = 'port';
        o.optional = true;

        o = ss.option(form.Value, 'User', _('User'));
        o.optional = true;

        o = ss.option(form.Value, 'Password', _('Password'));
        o.password = true;
        o.optional = true;
        o.modalonly = true;

        o = ss.option(form.ListValue, 'Qos', _('QoS'));
        o.value('0', _('0 - At most once'));
        o.value('1', _('1 - At least once'));
        o.value('2', _('2 - Exactly once'));
        o.modalonly = true;
        o.optional = true;

        o = ss.option(form.Value, 'Prefix', _('Prefix'));
        o.depends('blocktype', 'Publish');
        o.optional = true;
        o.modalonly = true;

        o = ss.option(form.ListValue, 'Retain', _('Retain'));
        o.depends('blocktype', 'Publish');
        o.value('true', _('True'));
        o.value('false', _('False'));
        o.optional = true;
        o.modalonly = true;

        o = ss.option(form.ListValue, 'StoreRates', _('StoreRates'));
        o.depends('blocktype', 'Publish');
        o.value('true', _('True'));
        o.value('false', _('False'));
        o.modalonly = true;
        o.optional = true;
        
        o = ss.option(form.ListValue, 'TLSProtocol', _('TLSProtocol'));
        o.depends('blocktype', 'Publish');
        o.value('tlsv1.2', _('TLS 1.2'));
        o.value('tlsv1.3', _('TLS 1.3'));
        o.modalonly = true;
        o.optional = true;

        o = ss.option(form.Value, 'CACert', _('CACert'));
        o.depends({'TLSProtocol': 'tls', '!contains': true });
        o.optional = true;
        o.modalonly = true;
        o.default = '/etc/ssl/certs/ca-certificates.crt';

        o = ss.option(form.ListValue, 'CleanSession', _('CleanSession'));
        o.depends('blocktype', 'Subscribe');
        o.value('true', _('True'));
        o.value('false', _('False'));
        o.optional = true;
        o.modalonly = true;

        o = ss.option(form.Value, 'Topic', _('Topic'));
        o.depends('blocktype', 'Subscribe');
        o.optional = true;
        o.modalonly = true;
    },

    configSummary(section) {
        return _('Mqtt plugin enabled');
    }
});