X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=luci2%2Fhtdocs%2Fluci2%2Fluci2.js;h=291af572d31119ec0e318aa03a68220b420ff3bd;hb=8f89e46fcaec5cb1deb9e73b9f77b3b1cd0d8ad1;hp=279da1716c0c77767793a87c50f6a2f6bfa83722;hpb=a437b0d71daa0cb9231a165083523bdc6463889a;p=project%2Fluci2%2Fui.git diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js index 279da17..291af57 100644 --- a/luci2/htdocs/luci2/luci2.js +++ b/luci2/htdocs/luci2/luci2.js @@ -977,6 +977,57 @@ function LuCI2() method: 'switch_status', params: [ 'switch' ], expect: { ports: [ ] } + }), + + + runPing: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'ping', + params: [ 'data' ], + expect: { '': { code: -1 } } + }), + + runPing6: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'ping6', + params: [ 'data' ], + expect: { '': { code: -1 } } + }), + + runTraceroute: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'traceroute', + params: [ 'data' ], + expect: { '': { code: -1 } } + }), + + runTraceroute6: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'traceroute6', + params: [ 'data' ], + expect: { '': { code: -1 } } + }), + + runNslookup: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'nslookup', + params: [ 'data' ], + expect: { '': { code: -1 } } + }), + + + setUp: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'ifup', + params: [ 'data' ], + expect: { '': { code: -1 } } + }), + + setDown: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'ifdown', + params: [ 'data' ], + expect: { '': { code: -1 } } }) }; @@ -1137,6 +1188,57 @@ function LuCI2() } }; + this.firewall = { + getZoneColor: function(zone) + { + if ($.isPlainObject(zone)) + zone = zone.name; + + if (zone == 'lan') + return '#90f090'; + else if (zone == 'wan') + return '#f09090'; + + for (var i = 0, hash = 0; + i < zone.length; + hash = zone.charCodeAt(i++) + ((hash << 5) - hash)); + + for (var i = 0, color = '#'; + i < 3; + color += ('00' + ((hash >> i++ * 8) & 0xFF).tozoneing(16)).slice(-2)); + + return color; + }, + + findZoneByNetwork: function(network) + { + var self = this; + var zone = undefined; + + return _luci2.uci.foreach('firewall', 'zone', function(z) { + if (!z.name || !z.network) + return; + + if (!$.isArray(z.network)) + z.network = z.network.split(/\s+/); + + for (var i = 0; i < z.network.length; i++) + { + if (z.network[i] == network) + { + zone = z; + break; + } + } + }).then(function() { + if (zone) + zone.color = self.getZoneColor(zone); + + return zone; + }); + } + }; + this.system = { getSystemInfo: _luci2.rpc.declare({ object: 'system', @@ -2064,9 +2166,14 @@ function LuCI2() .append(_luci2.globals.mainMenu.render(2, 900)); }, - renderView: function(node) + renderView: function() { + var node = arguments[0]; var name = node.view.split(/\//).join('.'); + var args = [ ]; + + for (var i = 1; i < arguments.length; i++) + args.push(arguments[i]); if (_luci2.globals.currentView) _luci2.globals.currentView.finish(); @@ -2081,7 +2188,7 @@ function LuCI2() if (_luci2._views[name] instanceof _luci2.ui.view) { _luci2.globals.currentView = _luci2._views[name]; - return _luci2._views[name].render(); + return _luci2._views[name].render.apply(_luci2._views[name], args); } var url = _luci2.globals.resource + '/view/' + name + '.js'; @@ -2107,7 +2214,7 @@ function LuCI2() }); _luci2.globals.currentView = _luci2._views[name]; - return _luci2._views[name].render(); + return _luci2._views[name].render.apply(_luci2._views[name], args); } catch(e) { alert('Unable to instantiate view "%s": %s'.format(url, e)); @@ -2232,6 +2339,10 @@ function LuCI2() insertInto: function(id) { return $(id).empty().append(this.render()); + }, + + appendTo: function(id) { + return $(id).append(this.render()); } }); @@ -2284,8 +2395,13 @@ function LuCI2() container.append($('
').addClass('cbi-map-descr').append(this.description)); var self = this; + var args = [ ]; + + for (var i = 0; i < arguments.length; i++) + args.push(arguments[i]); + return this._fetch_template().then(function() { - return _luci2.deferrable(self.execute()); + return _luci2.deferrable(self.execute.apply(self, args)); }); }, @@ -2664,7 +2780,9 @@ function LuCI2() this.ui.devicebadge = AbstractWidget.extend({ render: function() { - var dev = this.options.l3_device || this.options.device || '?'; + var l2dev = this.options.l2_device || this.options.device; + var l3dev = this.options.l3_device; + var dev = l3dev || l2dev || '?'; var span = document.createElement('span'); span.className = 'ifacebadge'; @@ -2705,7 +2823,7 @@ function LuCI2() var type = 'ethernet'; var desc = _luci2.tr('Ethernet device'); - if (this.options.l3_device != this.options.device) + if (l3dev != l2dev) { type = 'tunnel'; desc = _luci2.tr('Tunnel interface'); @@ -2955,6 +3073,7 @@ function LuCI2() } } + validation.i18n('Must be a valid IPv6 address'); return false; }, @@ -5604,33 +5723,6 @@ function LuCI2() }); }, - dialog: function(id) - { - var d = $('
'); - var p = $('

'); - - $('') - .attr('src', _luci2.globals.resource + '/icons/loading.gif') - .css('vertical-align', 'middle') - .css('padding-right', '10px') - .appendTo(p); - - p.append(_luci2.tr('Loading data...')); - - p.appendTo(d); - d.appendTo(id); - - return d.dialog({ - modal: true, - draggable: false, - resizable: false, - height: 90, - open: function() { - $(this).parent().children('.ui-dialog-titlebar').hide(); - } - }); - }, - insertInto: function(id) { var self = this;