luci2-p910nd: LuCI2 module for p910nd maganement
[project/luci2/ui.git] / luci2-p910nd / files / www / luci2 / view / services.p910nd.js
1 L.ui.view.extend({
2         PortValue: L.cbi.InputValue.extend({
3                 ucivalue: function(sid)
4                 {
5                         var v = this.callSuper('ucivalue', sid);
6                         if (typeof v == 'undefined')
7                                 return '';
8
9                         return 9100 + parseInt(v);
10                 },
11
12                 formvalue: function(sid)
13                 {
14                         var v = $('#' + this.id(sid)).val();
15
16                         return parseInt(v) - 9100;
17                 }
18         }),
19
20         execute: function() {
21                 var self = this;
22
23                 var m = new L.cbi.Map('p910nd', {
24                         caption:     L.tr('p910nd printer daemon')
25                 });
26
27                 var s = m.section(L.cbi.TypedSection, 'p910nd', {
28                         caption:      L.tr('Printers'),
29                         addremove:    true,
30                         add_caption:  L.tr('Add shared printer …'),
31                 });
32
33                 s.option(L.cbi.CheckboxValue, 'enabled', {
34                         caption:     L.tr('Enabled'),
35                         initial:     0,
36                         enabled:     '1',
37                         disabled:    '0'
38                 });
39
40                 s.option(self.PortValue, 'port', {
41                         caption:     L.tr('Port'),
42                         description: L.tr('Specifies the listening port'),
43                         datatype:    'range(9100, 65535)'
44                 });
45
46                 s.option(L.cbi.InputValue, 'device', {
47                         caption:     L.tr('Device'),
48                         description: L.tr('Printer device path in the filesystem')
49                 });
50
51                 s.option(L.cbi.CheckboxValue, 'bidirectional', {
52                         caption:     L.tr('Bidirectional'),
53                         description: L.tr('Bidirectional copying'),
54                         initial:     1,
55                         enabled:     '1',
56                         disabled:    '0'
57                 });
58
59                 return m.insertInto('#map');
60         }
61 });