luci-app-ttyd: add option for UNIX socket and URL override
[project/luci.git] / applications / luci-app-ttyd / htdocs / luci-static / resources / view / ttyd / config.js
1 'use strict';
2 'require view';
3 'require form';
4 'require tools.widgets as widgets';
5
6 return view.extend({
7 render: function() {
8 var m, s, o;
9
10 m = new form.Map('ttyd');
11
12 s = m.section(form.TypedSection, 'ttyd', _('ttyd Instance'));
13 s.anonymous = true;
14 s.addremove = true;
15 s.addbtntitle = _('Add instance');
16
17 o = s.option(form.Flag, 'enable', _('Enable'));
18 o.default = true;
19
20 s.option(form.Flag, 'unix_sock', _('UNIX socket'), _('Bind to UNIX domain socket instead of IP port'));
21
22 o = s.option(form.Value, 'port', _('Port'), _('Port to listen (default: 7681, use `0` for random port)'));
23 o.depends('unix_sock', '0');
24 o.datatype = 'port';
25 o.placeholder = 7681;
26
27 o = s.option(widgets.DeviceSelect, 'interface', _('Interface'), _('Network interface to bind (eg: eth0)'));
28 o.depends('unix_sock', '0');
29 o.nocreate = true;
30
31 o = s.option(form.Value, '_unix_sock_path', _('UNIX socket path'), _('UNIX domain socket path (eg: /var/run/ttyd.sock)'));
32 o.depends('unix_sock', '1');
33 o.ucioption = 'interface';
34 o.retain = true;
35
36 o = s.option(form.Value, 'credential', _('Credential'), _('Credential for Basic Authentication'));
37 o.placeholder = 'username:password';
38
39 o = s.option(form.Value, 'uid', _('User ID'), _('User id to run with'));
40 o.datatype = 'uinteger';
41
42 o = s.option(form.Value, 'gid', _('Group ID'), _('Group id to run with'));
43 o.datatype = 'uinteger';
44
45 o = s.option(form.Value, 'signal', _('Signal'), _('Signal to send to the command when exit it (default: 1, SIGHUP)'));
46 o.datatype = 'uinteger';
47
48 s.option(form.Flag, 'url_arg', _('Allow URL args'), _('Allow client to send command line arguments in URL (eg: http://localhost:7681?arg=foo&arg=bar)'));
49
50 s.option(form.Flag, 'readonly', _('Read-only'), _('Do not allow clients to write to the TTY'));
51
52 o = s.option(form.DynamicList, 'client_option', _('Client option'), _('Send option to client'));
53 o.placeholder = 'key=value';
54
55 o = s.option(form.Value, 'terminal_type', _('Terminal type'), _('Terminal type to report (default: xterm-256color)'));
56 o.placeholder = 'xterm-256color';
57
58 s.option(form.Flag, 'check_origin', _('Check origin'), _('Do not allow websocket connection from different origin'));
59
60 o = s.option(form.Value, 'max_clients', _('Max clients'), _('Maximum clients to support (default: 0, no limit)'));
61 o.datatype = 'uinteger';
62 o.placeholder = '0';
63
64 s.option(form.Flag, 'once', _('Once'), _('Accept only one client and exit on disconnection'));
65
66 s.option(form.Value, 'index', _('Index'), _('Custom index.html path'));
67
68 s.option(form.Flag, 'ipv6', _('IPv6'), _('Enable IPv6 support'));
69
70 s.option(form.Flag, 'ssl', _('SSL'), _('Enable SSL'));
71
72 o = s.option(form.Value, 'ssl_cert', _('SSL cert'), _('SSL certificate file path'));
73 o.depends('ssl', '1');
74
75 o = s.option(form.Value, 'ssl_key', _('SSL key'), _('SSL key file path'));
76 o.depends('ssl', '1');
77
78 o = s.option(form.Value, 'ssl_ca', _('SSL ca'), _('SSL CA file path for client certificate verification'));
79 o.depends('ssl', '1');
80
81 o = s.option(form.ListValue, 'debug', _('Debug'), _('Set log level (default: 7)'));
82 o.value('1', _('Error'));
83 o.value('3', _('Warning'));
84 o.value('7', _('Notice'));
85 o.value('15', _('Info'));
86 o.default = '7';
87
88 s.option(form.Value, 'command', _('Command'));
89
90 s.option(form.Value, 'url_override', _('URL override'),
91 _('Override URL in Terminal tab. For use with reverse proxy.') + '<br />' +
92 _('Note that reverse proxied pages is NOT protected by password like LuCI.') + '<br />' +
93 _('Make sure to set up another authorization method.'));
94
95 return m.render();
96 }
97 });