81829ef7b8807635c59cb74dd38f0ddd31fed151
[openwrt-luci.git] /
1 'use strict';
2 'require baseclass';
3 'require form';
4
5 /*
6 class, type, name and id are used to build a reference for the uci config. E.g.
7
8 config http_headers '263fe72d7e834fa99a82639ed0d9e3bd'
9         option name 'X-Example'
10         ...
11
12 */
13
14 return baseclass.extend({
15
16         class: 'http',
17         class_i18n: _('HTTP'),
18
19         type: 'headers',
20         type_i18n: _('Headers'),
21
22         name: 'X-Example', // to make visual ID in UCI config easy
23         id: '263fe72d7e834fa99a82639ed0d9e3bd', // cat /proc/sys/kernel/random/uuid | tr -d -
24         title: _('X-Example Example Plugin'),
25         description: _('This plugin sets an X-Example HTTP header.'),
26
27         addFormOptions(s) {
28                 let o;
29
30                 o = s.option(form.Flag, 'enabled', _('Enabled'));
31
32                 o = s.option(form.Value, 'foo', _('Foo'));
33                 o.default = 'foo';
34                 o.depends('enabled', '1');
35
36                 o = s.option(form.Value, 'bar', _('Bar'));
37                 o.default = '3000';
38                 o.depends('enabled', '1');
39         },
40
41         configSummary(section) {
42                 return _('I am class %s, type %s, name %s, bar: %d').format(this.class_i18n, this.type_i18n, this.name, section.bar || 1000);
43         }
44 });
git clone https://git.99rst.org/PROJECT