2 LuCI - Lua Configuration Interface
4 Copyright 2008 Jo-Philipp Wich <xm@subsignal.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 $Id: trunks.lua 4025 2009-01-11 23:37:21Z jow $
16 local ast = require("luci.asterisk")
17 local uci = require("luci.model.uci").cursor()
20 Dialzone overview table
24 zonemap = Map("asterisk", "Dial Zones", [[
25 Dial zones hold patterns of dialed numbers to match.
26 Each zone has one or more trunks assigned. If the first trunk is
27 congested, Asterisk will try to use the next available connection.
28 If all trunks fail, then the following zones in the parent dialplan
32 local zones, znames = ast.dialzone.zones()
34 zonetbl = zonemap:section(Table, zones, "Zone Overview")
35 zonetbl.sectionhead = "Zone"
36 zonetbl.addremove = true
37 zonetbl.anonymous = false
38 zonetbl.extedit = luci.dispatcher.build_url(
39 "admin", "asterisk", "dialplans", "zones", "%s"
42 function zonetbl.cfgsections(self)
46 function zonetbl.parse(self)
47 for k, v in pairs(self.map:formvaluetable(
48 luci.cbi.REMOVE_PREFIX .. self.config
50 if k:sub(-2) == ".x" then k = k:sub(1, #k - 2) end
51 uci:delete("asterisk", k)
55 if znames[i] == k then
56 table.remove(znames, i)
65 zonetbl:option(DummyValue, "description", "Description")
66 zonetbl:option(DummyValue, "addprefix")
68 match = zonetbl:option(DummyValue, "matches")
69 function match.cfgvalue(self, s)
70 return table.concat(zones[s].matches, ", ")
73 trunks = zonetbl:option(DummyValue, "trunk")
74 trunks.template = "asterisk/cbi/cell"
75 function trunks.cfgvalue(self, s)
76 return ast.tools.hyperlinks(zones[s].trunks)
86 zoneedit = Map("asterisk", "Edit Dialzone")
88 entry = zoneedit:section(NamedSection, arg[1])
89 entry.title = "Zone %q" % arg[1];
91 back = entry:option(DummyValue, "_overview", "Back to dialzone overview")
93 back.titleref = luci.dispatcher.build_url(
94 "admin", "asterisk", "dialplans", "zones"
97 desc = entry:option(Value, "description", "Description")
98 function desc.cfgvalue(self, s, ...)
99 return Value.cfgvalue(self, s, ...) or s
102 trunks = entry:option(MultiValue, "uses", "Used trunks")
103 trunks.widget = "checkbox"
104 uci:foreach("asterisk", "sip",
106 if s.provider == "yes" then
108 "SIP/%s" % s['.name'],
109 "SIP/%s (%s)" %{ s['.name'], s.host or 'n/a' }
115 match = entry:option(DynamicList, "match", "Number matches")
117 intl = entry:option(DynamicList, "international", "Intl. prefix matches (optional)")
119 aprefix = entry:option(Value, "addprefix", "Add prefix to dial out (optional)")
120 ccode = entry:option(Value, "countrycode", "Effective countrycode (optional)")
122 lzone = entry:option(ListValue, "localzone", "Dialzone for local numbers")
123 lzone:value("", "no special treatment of local numbers")
124 for _, z in ipairs(ast.dialzone.zones()) do
125 lzone:value(z.name, "%q (%s)" %{ z.name, z.description })
127 --for _, v in ipairs(find_outgoing_contexts(zoneedit.uci)) do
128 -- lzone:value(unpack(v))
131 lprefix = entry:option(Value, "localprefix", "Prefix for local calls (optional)")