luci-base: network.js: add hacks to enable relay protocol support
authorJo-Philipp Wich <jo@mein.io>
Tue, 20 Aug 2019 13:17:24 +0000 (15:17 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 10 Sep 2019 13:28:16 +0000 (15:28 +0200)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/network.js

index fb23fba857a24c77293df98445bbe2c0aae69712..05510d828cbbf8d6120bb2a8ebac0f3dde44ecc3 100644 (file)
@@ -160,6 +160,10 @@ function getProtocolHandlers(cache) {
                if (!L.isObject(protos))
                        throw !1;
 
+               /* Hack: emulate relayd protocol */
+               if (!protos.hasOwnProperty('relay'))
+                       Object.assign(protos, { relay: { no_device: true } });
+
                Object.assign(_protospecs, protos);
 
                return Promise.all(Object.keys(protos).map(function(p) {
@@ -1187,7 +1191,10 @@ Network = L.Class.extend({
                return new protoClass(name);
        },
 
-       instantiateDevice: function(name, network) {
+       instantiateDevice: function(name, network, extend) {
+               if (extend != null)
+                       return new (Device.extend(extend))(name, network);
+
                return new Device(name, network);
        },