From f3cb6d7b36740707ebeb2c712458f700de6b416a Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sat, 30 Jul 2016 00:01:26 +0200
Subject: [PATCH] gluon-luci-portconfig: add setting for PoE passthrough

Fixes #328
---
 package/gluon-luci-portconfig/i18n/de.po            |  9 ++++++---
 package/gluon-luci-portconfig/i18n/fr.po            | 10 ++++++----
 .../i18n/gluon-luci-portconfig.pot                  |  5 ++++-
 .../usr/lib/lua/luci/model/cbi/admin/portconfig.lua | 13 +++++++++++++
 4 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/package/gluon-luci-portconfig/i18n/de.po b/package/gluon-luci-portconfig/i18n/de.po
index 2197fdbec..a94e7d41d 100644
--- a/package/gluon-luci-portconfig/i18n/de.po
+++ b/package/gluon-luci-portconfig/i18n/de.po
@@ -1,12 +1,12 @@
 msgid ""
 msgstr ""
-"Content-Type: text/plain; charset=UTF-8\n"
 "Project-Id-Version: PACKAGE VERSION\n"
 "PO-Revision-Date: 2015-05-04 02:08+0200\n"
 "Last-Translator:  <mschiffer@universe-factory.net>\n"
 "Language-Team: German\n"
 "Language: de\n"
 "MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
@@ -16,12 +16,15 @@ msgstr "Automatisch (DHCP)"
 msgid "Automatic (RA/DHCPv6)"
 msgstr "Automatisch (RA/DHCPv6)"
 
-msgid "Enable meshing on the WAN interface"
-msgstr "Mesh auf dem WAN-Port aktivieren"
+msgid "Enable PoE passthrough"
+msgstr "PoE-Passthrough aktivieren"
 
 msgid "Enable meshing on the LAN interface"
 msgstr "Mesh auf dem LAN-Port aktivieren"
 
+msgid "Enable meshing on the WAN interface"
+msgstr "Mesh auf dem WAN-Port aktivieren"
+
 msgid "Static"
 msgstr "Statisch"
 
diff --git a/package/gluon-luci-portconfig/i18n/fr.po b/package/gluon-luci-portconfig/i18n/fr.po
index b5f7405db..3ec593959 100644
--- a/package/gluon-luci-portconfig/i18n/fr.po
+++ b/package/gluon-luci-portconfig/i18n/fr.po
@@ -1,28 +1,30 @@
 msgid ""
 msgstr ""
-"Content-Type: text/plain; charset=UTF-8\n"
 "Project-Id-Version: PACKAGE VERSION\n"
 "PO-Revision-Date: 2015-08-19 23:30+0100\n"
 "Last-Translator:Tobias Bernot <tqbs@airmail.cc>\n"
 "Language-Team: French\n"
 "Language: fr\n"
 "MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-
 msgid "Automatic (DHCP)"
 msgstr "Automatique (DHCP)"
 
 msgid "Automatic (RA/DHCPv6)"
 msgstr "Automatique (RA/DHCPv6)"
 
-msgid "Enable meshing on the WAN interface"
-msgstr "Activer le réseau MESH sur les ports WAN"
+msgid "Enable PoE passthrough"
+msgstr ""
 
 msgid "Enable meshing on the LAN interface"
 msgstr "Activer le réseau MESH sur le port LAN"
 
+msgid "Enable meshing on the WAN interface"
+msgstr "Activer le réseau MESH sur les ports WAN"
+
 msgid "Static"
 msgstr "Statique"
 
diff --git a/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot b/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot
index 31ac71d3b..5945016be 100644
--- a/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot
+++ b/package/gluon-luci-portconfig/i18n/gluon-luci-portconfig.pot
@@ -7,12 +7,15 @@ msgstr ""
 msgid "Automatic (RA/DHCPv6)"
 msgstr ""
 
-msgid "Enable meshing on the WAN interface"
+msgid "Enable PoE passthrough"
 msgstr ""
 
 msgid "Enable meshing on the LAN interface"
 msgstr ""
 
+msgid "Enable meshing on the WAN interface"
+msgstr ""
+
 msgid "Static"
 msgstr ""
 
diff --git a/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua b/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua
index 994f30773..2e40577a7 100644
--- a/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua
+++ b/package/gluon-luci-portconfig/luasrc/usr/lib/lua/luci/model/cbi/admin/portconfig.lua
@@ -94,6 +94,13 @@ if sysconfig.lan_ifname then
   o.rmempty = false
 end
 
+if uci:get('system', 'gpio_switch_poe_passthrough') then
+  s = f:section(SimpleSection, nil, nil)
+  o = s:option(Flag, "poe_passthrough", translate("Enable PoE passthrough"))
+  o.default = uci:get_bool("system", "gpio_switch_poe_passthrough", "value") and o.enabled or o.disabled
+  o.rmempty = false
+end
+
 
 function f.handle(self, state, data)
   if state == FORM_VALID then
@@ -137,6 +144,12 @@ function f.handle(self, state, data)
     uci:save("network")
     uci:commit("network")
 
+    if uci:get('system', 'gpio_switch_poe_passthrough') then
+        uci:set('system', 'gpio_switch_poe_passthrough', 'value', data.poe_passthrough)
+        uci:save('system')
+        uci:commit('system')
+    end
+
     if dns then
       if #data.dns > 0 then
         uci:set("gluon-wan-dnsmasq", dns, "server", data.dns)
-- 
GitLab