applications/luci-asterisk:
[project/luci.git] / applications / luci-asterisk / luasrc / model / cbi / asterisk / trunks.lua
index 02576b5..3a993da 100644 (file)
@@ -30,19 +30,15 @@ cbimap.uci:foreach("asterisk", "sip",
 
 
 sip_table = cbimap:section(TypedSection, "sip", "SIP Trunks")
-sip_table.template  = "cbi/tblsection"
-sip_table.extedit   = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip", "%s")
-sip_table.addremove = true
-
-sip_table.hidden = {
-       type    = "peer",
-       qualify = "yes"
-}
+sip_table.template    = "cbi/tblsection"
+sip_table.extedit     = luci.dispatcher.build_url("admin", "asterisk", "trunks", "sip", "%s")
+sip_table.addremove   = true
+sip_table.sectionhead = "Extension"
 
 function sip_table.filter(self, s)
        return s and (
-               cbimap.uci:get("asterisk", s, "type") == "peer" or
-               cbimap.uci:get("asterisk", s, "type") == nil
+               cbimap.uci:get("asterisk", s, "type") == nil or
+               cbimap.uci:get_bool("asterisk", s, "provider")
        )
 end
 
@@ -57,6 +53,12 @@ end
 function sip_table.parse(self, ...)
        TypedSection.parse(self, ...)
        if created then
+               cbimap.uci:tset("asterisk", created, {
+                       type     = "friend",
+                       qualify  = "yes",
+                       provider = "yes"
+               })
+
                cbimap.uci:save("asterisk")
                luci.http.redirect(luci.dispatcher.build_url(
                        "admin", "asterisk", "trunks", "sip", created
@@ -65,9 +67,9 @@ function sip_table.parse(self, ...)
 end
 
 
-user = sip_table:option(DummyValue, "username")
+user = sip_table:option(DummyValue, "username", "Username")
 
-host = sip_table:option(DummyValue, "host")
+host = sip_table:option(DummyValue, "host", "Hostname")
 function host.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.address then
                return "%s:%i" %{ sip_peers[s].info.address, sip_peers[s].info.port }
@@ -76,18 +78,13 @@ function host.cfgvalue(self, s)
        end
 end
 
-context = sip_table:option(DummyValue, "context")
+context = sip_table:option(DummyValue, "context", "Dialplan")
 context.href = luci.dispatcher.build_url("admin", "asterisk", "dialplan")
 function context.cfgvalue(...)
        return AbstractValue.cfgvalue(...) or "(default)"
 end
 
-nat = sip_table:option(DummyValue, "nat")
-function nat.cfgvalue(self, s)
-       return sip_peers[s] and sip_peers[s].info.Nat or "none"
-end
-
-online = sip_table:option(DummyValue, "online")
+online = sip_table:option(DummyValue, "online", "Registered")
 function online.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.online == nil then
                return "n/a"
@@ -99,7 +96,7 @@ function online.cfgvalue(self, s)
        end
 end
 
-delay = sip_table:option(DummyValue, "delay")
+delay = sip_table:option(DummyValue, "delay", "Delay")
 function delay.cfgvalue(self, s)
        if sip_peers[s] and sip_peers[s].info.online then
                return "%i ms" % sip_peers[s].info.delay