From 2b64fd6c6c8f48b56e84fee3e5c4c51971b82210 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 31 Mar 2020 21:30:38 +0200 Subject: docs: update js api docs Signed-off-by: Jo-Philipp Wich --- docs/jsapi/network.js.html | 709 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 679 insertions(+), 30 deletions(-) (limited to 'docs/jsapi/network.js.html') diff --git a/docs/jsapi/network.js.html b/docs/jsapi/network.js.html index 4a306a23ad..07aca9adde 100644 --- a/docs/jsapi/network.js.html +++ b/docs/jsapi/network.js.html @@ -498,6 +498,8 @@
  • containsDevice
  • +
  • deleteConfiguration
  • +
  • deleteDevice
  • get
  • @@ -556,6 +558,8 @@
  • isBridge
  • +
  • isCreateable
  • +
  • isDynamic
  • isEmpty
  • @@ -1002,6 +1006,610 @@ +
  • + + LuCI.ui + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.AbstractElement + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.changes + + +
      + +
    +
      + +
    +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.Checkbox + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.Combobox + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.ComboButton + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.Dropdown + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.DynamicList + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.FileUpload + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.Hiddenfield + + +
      + +
    +
      + +
    +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.Select + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.tabs + + +
      + +
    +
      + +
    +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.Textarea + + +
      + +
    + +
      + +
    + +
      + +
    +
  • + +
  • + + LuCI.ui.Textfield + + +
      + +
    + +
      + +
    + +
      + +
    +
  • +
  • LuCI.view @@ -2064,47 +2672,52 @@ Network = L.Class.extend(/** @lends LuCI.Network.prototype */ { * `false` if the given network could not be found. */ deleteNetwork: function(name) { - var requireFirewall = Promise.resolve(L.require('firewall')).catch(function() {}); + var requireFirewall = Promise.resolve(L.require('firewall')).catch(function() {}), + network = this.instantiateNetwork(name); return Promise.all([ requireFirewall, initNetworkState() ]).then(function() { var uciInterface = uci.get('network', name); if (uciInterface != null && uciInterface['.type'] == 'interface') { - uci.remove('network', name); + return Promise.resolve(network ? network.deleteConfiguration() : null).then(function() { + uci.remove('network', name); - uci.sections('luci', 'ifstate', function(s) { - if (s.interface == name) - uci.remove('luci', s['.name']); - }); + uci.sections('luci', 'ifstate', function(s) { + if (s.interface == name) + uci.remove('luci', s['.name']); + }); - uci.sections('network', 'alias', function(s) { - if (s.interface == name) - uci.remove('network', s['.name']); - }); + uci.sections('network', 'alias', function(s) { + if (s.interface == name) + uci.remove('network', s['.name']); + }); - uci.sections('network', 'route', function(s) { - if (s.interface == name) - uci.remove('network', s['.name']); - }); + uci.sections('network', 'route', function(s) { + if (s.interface == name) + uci.remove('network', s['.name']); + }); - uci.sections('network', 'route6', function(s) { - if (s.interface == name) - uci.remove('network', s['.name']); - }); + uci.sections('network', 'route6', function(s) { + if (s.interface == name) + uci.remove('network', s['.name']); + }); - uci.sections('wireless', 'wifi-iface', function(s) { - var networks = L.toArray(s.network).filter(function(network) { return network != name }); + uci.sections('wireless', 'wifi-iface', function(s) { + var networks = L.toArray(s.network).filter(function(network) { return network != name }); - if (networks.length > 0) - uci.set('wireless', s['.name'], 'network', networks.join(' ')); - else - uci.unset('wireless', s['.name'], 'network'); - }); + if (networks.length > 0) + uci.set('wireless', s['.name'], 'network', networks.join(' ')); + else + uci.unset('wireless', s['.name'], 'network'); + }); - if (L.firewall) - return L.firewall.deleteNetwork(name).then(function() { return true }); + if (L.firewall) + return L.firewall.deleteNetwork(name).then(function() { return true }); - return true; + return true; + }).catch(function() { + return false; + }); } return false; @@ -3383,6 +3996,23 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { return null; }, + /** + * Check function for the protocol handler if a new interface is createable. + * + * This function should be overwritten by protocol specific subclasses. + * + * @abstract + * + * @param {string} ifname + * The name of the interface to be created. + * + * @returns {Promise<null|string>} + * Returns `null` if new interface is createable, else returns (error) message. + */ + isCreateable: function(ifname) { + return Promise.resolve(null); + }, + /** * Checks whether the protocol functionality is installed. * @@ -3724,7 +4354,26 @@ Protocol = L.Class.extend(/** @lends LuCI.Network.Protocol.prototype */ { } return false; - } + }, + + /** + * Cleanup related configuration entries. + * + * This function will be invoked if an interface is about to be removed + * from the configuration and is responsible for performing any required + * cleanup tasks, such as unsetting uci entries in related configurations. + * + * It should be overwritten by protocol specific subclasses. + * + * @abstract + * + * @returns {*|Promise<*>} + * This function may return a promise which is awaited before the rest of + * the configuration is removed. Any non-promise return value and any + * resolved promise value is ignored. If the returned promise is rejected, + * the interface removal will be aborted. + */ + deleteConfiguration: function() {} }); /** @@ -5195,7 +5844,7 @@ return Network; -- cgit v1.2.3