X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci2%2Fui.git;a=blobdiff_plain;f=luci2%2Fhtdocs%2Fluci2%2Fluci2.js;h=6481c0bd90416c989d2f6e092e8c482527bc53da;hp=fc5d84a458f71e3799ae5ecb0f15323a0993a831;hb=5c515935eec07a2ca50d539da1c43bfceae5acc9;hpb=bcdd688eb8ef8df4304fd2081a88586ccbd7f222 diff --git a/luci2/htdocs/luci2/luci2.js b/luci2/htdocs/luci2/luci2.js index fc5d84a..6481c0b 100644 --- a/luci2/htdocs/luci2/luci2.js +++ b/luci2/htdocs/luci2/luci2.js @@ -387,7 +387,7 @@ function LuCI2() }; this.globals = { - timeout: 3000, + timeout: 15000, resource: '/luci2', sid: '00000000000000000000000000000000' }; @@ -946,6 +946,88 @@ function LuCI2() object: 'luci2.network', method: 'conntrack_count', expect: { '': { count: 0, limit: 0 } } + }), + + listSwitchNames: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'switch_list', + expect: { switches: [ ] } + }), + + getSwitchInfo: _luci2.rpc.declare({ + object: 'luci2.network', + method: 'switch_info', + params: [ 'switch' ], + expect: { info: { } }, + filter: function(data, params) { + data['attrs'] = data['switch']; + data['vlan_attrs'] = data['vlan']; + data['port_attrs'] = data['port']; + data['switch'] = params['switch']; + + delete data.vlan; + delete data.port; + + return data; + } + }), + + getSwitchStatus: _luci2.rpc.declare({ + object: 'luci2.network', + 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 } } }) }; @@ -1106,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', @@ -1520,29 +1653,22 @@ function LuCI2() var state = _luci2.ui._loading || (_luci2.ui._loading = { modal: $('
') - .addClass('cbi-modal-loader') - .append($('
').text(_luci2.tr('Loading data...'))) + .addClass('modal fade') + .append($('
') + .addClass('modal-dialog') + .append($('
') + .addClass('modal-content luci2-modal-loader') + .append($('
') + .addClass('modal-body') + .text(_luci2.tr('Loading data…'))))) .appendTo(body) + .modal({ + backdrop: 'static', + keyboard: false + }) }); - if (enable) - { - body.css('overflow', 'hidden'); - body.css('padding', 0); - body.css('width', win.width()); - body.css('height', win.height()); - state.modal.css('width', win.width()); - state.modal.css('height', win.height()); - state.modal.show(); - } - else - { - state.modal.hide(); - body.css('overflow', ''); - body.css('padding', ''); - body.css('width', ''); - body.css('height', ''); - } + state.modal.modal(enable ? 'show' : 'hide'); }, dialog: function(title, content, options) @@ -1552,26 +1678,23 @@ function LuCI2() var state = _luci2.ui._dialog || (_luci2.ui._dialog = { dialog: $('
') - .addClass('cbi-modal-dialog') + .addClass('modal fade') .append($('
') + .addClass('modal-dialog') .append($('
') - .addClass('cbi-modal-dialog-header')) - .append($('
') - .addClass('cbi-modal-dialog-body')) - .append($('
') - .addClass('cbi-modal-dialog-footer') - .append($('