Merge pull request #1735 from sumpfralle/olsr-jsoninfo-parser-handle-empty-result
[oweals/luci.git] / applications / luci-app-firewall / htdocs / luci-static / resources / view / firewall / rules.js
index d2d191632243f029c51bcc82cb1cd094ad350536..6df3bc7f8550bf425674ee44f1bb8b82d168504e 100644 (file)
@@ -42,7 +42,8 @@ function fmt(fmt /*, ...*/) {
 }
 
 function forward_proto_txt(s) {
-       return fmt('%s-%s', _('IPv4'),
+       return fmt('%s-%s',
+               fwtool.fmt_family(uci.get('firewall', s, 'family')),
                fwtool.fmt_proto(uci.get('firewall', s, 'proto'),
                                 uci.get('firewall', s, 'icmp_type')) || 'TCP+UDP');
 }
@@ -111,7 +112,8 @@ function rule_target_txt(s) {
 return L.view.extend({
        callHostHints: rpc.declare({
                object: 'luci',
-               method: 'host_hints'
+               method: 'getHostHints',
+               expect: { '': {} }
        }),
 
        load: function() {
@@ -143,6 +145,27 @@ return L.view.extend({
                        return uci.get('firewall', section_id, 'name') || _('Unnamed rule');
                };
 
+               s.handleAdd = function(ev) {
+                       var config_name = this.uciconfig || this.map.config,
+                           section_id = uci.add(config_name, this.sectiontype),
+                           opt1, opt2;
+
+                       for (var i = 0; i < this.children.length; i++)
+                               if (this.children[i].option == 'src')
+                                       opt1 = this.children[i];
+                               else if (this.children[i].option == 'dest')
+                                       opt2 = this.children[i];
+
+                       opt1.default = 'wan';
+                       opt2.default = 'lan';
+
+                       this.addedSection = section_id;
+                       this.renderMoreOptionsModal(section_id);
+
+                       delete opt1.default;
+                       delete opt2.default;
+               };
+
                o = s.taboption('general', form.Value, 'name', _('Name'));
                o.placeholder = _('Unnamed rule');
                o.modalonly = true;
@@ -199,42 +222,44 @@ return L.view.extend({
                o.cast = 'table';
                o.placeholder = _('any');
                o.value('', 'any');
-               o.value('echo-reply');
+               o.value('address-mask-reply');
+               o.value('address-mask-request');
+               o.value('communication-prohibited');
                o.value('destination-unreachable');
-               o.value('network-unreachable');
-               o.value('host-unreachable');
-               o.value('protocol-unreachable');
-               o.value('port-unreachable');
+               o.value('echo-reply');
+               o.value('echo-request');
                o.value('fragmentation-needed');
-               o.value('source-route-failed');
-               o.value('network-unknown');
+               o.value('host-precedence-violation');
+               o.value('host-prohibited');
+               o.value('host-redirect');
                o.value('host-unknown');
+               o.value('host-unreachable');
+               o.value('ip-header-bad');
+               o.value('neighbour-advertisement');
+               o.value('neighbour-solicitation');
                o.value('network-prohibited');
-               o.value('host-prohibited');
-               o.value('TOS-network-unreachable');
-               o.value('TOS-host-unreachable');
-               o.value('communication-prohibited');
-               o.value('host-precedence-violation');
+               o.value('network-redirect');
+               o.value('network-unknown');
+               o.value('network-unreachable');
+               o.value('parameter-problem');
+               o.value('port-unreachable');
                o.value('precedence-cutoff');
-               o.value('source-quench');
+               o.value('protocol-unreachable');
                o.value('redirect');
-               o.value('network-redirect');
-               o.value('host-redirect');
-               o.value('TOS-network-redirect');
-               o.value('TOS-host-redirect');
-               o.value('echo-request');
+               o.value('required-option-missing');
                o.value('router-advertisement');
                o.value('router-solicitation');
+               o.value('source-quench');
+               o.value('source-route-failed');
                o.value('time-exceeded');
-               o.value('ttl-zero-during-transit');
-               o.value('ttl-zero-during-reassembly');
-               o.value('parameter-problem');
-               o.value('ip-header-bad');
-               o.value('required-option-missing');
-               o.value('timestamp-request');
                o.value('timestamp-reply');
-               o.value('address-mask-request');
-               o.value('address-mask-reply');
+               o.value('timestamp-request');
+               o.value('TOS-host-redirect');
+               o.value('TOS-host-unreachable');
+               o.value('TOS-network-redirect');
+               o.value('TOS-network-unreachable');
+               o.value('ttl-zero-during-reassembly');
+               o.value('ttl-zero-during-transit');
                o.depends('proto', 'icmp');
 
                o = s.taboption('general', widgets.ZoneSelect, 'src', _('Source zone'));
@@ -242,7 +267,6 @@ return L.view.extend({
                o.nocreate = true;
                o.allowany = true;
                o.allowlocal = 'src';
-               o.default = 'wan';
 
                o = s.taboption('advanced', form.Value, 'src_mac', _('Source MAC address'));
                o.modalonly = true;
@@ -275,22 +299,11 @@ return L.view.extend({
                o.depends('proto', 'tcp udp');
                o.depends('proto', 'tcpudp');
 
-               o = s.taboption('general', widgets.ZoneSelect, 'dest_local', _('Output zone'));
-               o.modalonly = true;
-               o.nocreate = true;
-               o.allowany = true;
-               o.alias = 'dest';
-               o.default = 'wan';
-               o.depends('src', '');
-
-               o = s.taboption('general', widgets.ZoneSelect, 'dest_remote', _('Destination zone'));
+               o = s.taboption('general', widgets.ZoneSelect, 'dest', _('Destination zone'));
                o.modalonly = true;
                o.nocreate = true;
                o.allowany = true;
                o.allowlocal = true;
-               o.alias = 'dest';
-               o.default = 'lan';
-               o.depends({'src': '', '!reverse': true});
 
                o = s.taboption('general', form.Value, 'dest_ip', _('Destination address'));
                o.modalonly = true;
@@ -365,9 +378,6 @@ return L.view.extend({
                o.modalonly = true;
                o.default = o.disabled;
 
-               return m.render().catch(function(e) {
-                       console.debug('render fail')
-               });
-
+               return m.render();
        }
 });