2 Copyright
2008 Steven Barth
<steven@midlink.org
>
3 Copyright
2008 Jo-Philipp Wich
<jow@openwrt.org
>
4 Licensed to the public under the Apache License
2.0.
10 local uci = luci.model.uci.cursor_state()
11 local ast = require(
"luci.asterisk")
13 function digit_pattern(s)
14 return
"<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'>%s</code>" % s
18 return
"cbi-rowstyle-%i" %{
19 ( i %
2 ) ==
0 and
2 or
1
23 local function find_trunks()
26 uci:foreach(
"asterisk",
"sip",
28 if uci:get_bool(
"asterisk", s['.name'],
"provider") then
30 "SIP/%s" % s['.name'],
31 "SIP: %s" % s['.name']
36 uci:foreach(
"asterisk",
"iax",
39 "IAX/%s" % s['.name'],
40 "IAX: %s" % s.extension or s['.name']
50 <form method=
"post" action=
"<%=url('admin/asterisk/dialplans/zones')%>" enctype=
"multipart/form-data">
52 <input type=
"hidden" name=
"cbi.submit" value=
"1" />
53 <input type=
"submit" value=
"Save" class=
"hidden" />
56 <div class=
"cbi-map" id=
"cbi-asterisk">
57 <h2 name=
"content">Dial Zone Management
</h2>
58 <div class=
"cbi-map-descr">
59 <a href=
"<%=url("admin/asterisk/dialplans
")%>" class=
"cbi-title-ref">Back to dialplan overview
</a><br /><br />
60 Here you can manage your dial zones. The zones are used to route outgoing calls to the destination.
61 Each zone groups multiple trunks and number matches to represent a logical destination. Zones can
62 also be used to enforce certain dial restrictions on selected extensions.
66 <fieldset class=
"cbi-section" id=
"cbi-asterisk-sip">
67 <div class=
"cbi-section-node">
68 <div class=
"table cbi-section-table">
69 <div class=
"tr cbi-section-table-titles">
70 <div style=
"text-align: left; padding: 3px" class=
"th cbi-section-table-cell" colspan=
"6">
71 <h3>Dialzone Overview
</h3>
75 <div class=
"tr cbi-section-table-descr">
76 <div style=
"width: 5%; text-align:right" class=
"th cbi-section-table-cell">Name
</div>
77 <div style=
"width: 5%; text-align:right" class=
"th cbi-section-table-cell">Prepend
</div>
78 <div style=
"width: 20%; text-align:left" class=
"th cbi-section-table-cell">- Match
</div>
79 <div style=
"text-align:left" class=
"th cbi-section-table-cell">Trunk
</div>
80 <div style=
"width: 35%; text-align:left" class=
"th cbi-section-table-cell">Description
</div>
81 <div style=
"width: 4%; text-align:left" class=
"th cbi-section-table-cell"></div>
84 <% for i, rule in pairs(ast.dialzone.zones()) do %
>
85 <div class=
"tr cbi-section-table-row <%=rowstyle(i)%>">
86 <div style=
"text-align:right" class=
"td cbi-value-field">
89 <div style=
"text-align:right" class=
"td cbi-value-field">
90 <% for _ in ipairs(rule.matches) do %
>
91 <%=rule.addprefix and digit_pattern(rule.addprefix)%
> <br />
94 <div style=
"text-align:left" class=
"td cbi-value-field">
95 <% for _, m in ipairs(rule.matches) do %
>
96 <%=rule.localprefix and
"%s " % digit_pattern(rule.localprefix)%
>
97 <%=digit_pattern(m)%
><br />
100 <div style=
"text-align:left" class=
"td cbi-value-field">
101 <%=ast.tools.hyperlinks(
102 rule.trunks, function(v)
103 return luci.dispatcher.build_url(
"admin",
"asterisk",
"trunks",
"%s") % v:lower()
107 <div style=
"text-align:left" class=
"td cbi-value-field">
108 <%=rule.description or rule.name%
>
110 <div style=
"text-align:left" class=
"td cbi-value-field">
111 <a href=
"<%=url('admin/asterisk/dialplans/out', rule.name)%>">
112 <img style=
"border:none" alt=
"Edit entry" title=
"Edit entry" src=
"/luci-static/resources/cbi/edit.gif" />
114 <a href=
"<%=url('admin/asterisk/dialplans/zones')%>?delzone=<%=rule.name%>">
115 <img style=
"border:none" alt=
"Delete entry" title=
"Delete entry" src=
"/luci-static/resources/cbi/remove.gif" />
121 <div class=
"cbi-section-create cbi-tblsection-create"></div>
125 <div class=
"cbi-section-node">
126 <div class=
"cbi-section-create cbi-tblsection-create" style=
"padding: 3px">
127 <h3>Create a new dialzone
</h3>
128 The name is required and must be unique. It may only contain the characters A-Z, a-z,
0-
9 and _ .
<br />
129 You can specifiy multiple number matches by separating them with spaces.
<br />
131 <%- if create_error then %
>
132 <br /><span style=
"color:red">Invalid name given!
</span><br />
137 <div class=
"td" style=
"padding:3px">
138 <label for=
"create1">1) Name
</label><br />
139 <input type=
"text" class=
"cbi-section-create-name" id=
"create1" name=
"newzone_name" style=
"width:200px" />
142 <label for=
"create2">2) Number Match
</label><br />
143 <input type=
"text" class=
"cbi-section-create-name" id=
"create2" name=
"newzone_match" style=
"width:200px" />
145 <div class=
"td" style=
"padding:3px">
146 <label for=
"create3">3) Trunks
</label><br />
147 <select class=
"cbi-input-select" multiple=
"multiple" id=
"create3" name=
"newzone_uses" size=
"4" style=
"width:200px">
148 <% for i, t in ipairs(find_trunks()) do %
>
149 <option value=
"<%=t[1]%>"><%=t[
2]%
></option>
157 <input type=
"submit" class=
"cbi-button cbi-button-add" name=
"newzone" value=
"Add entry" title=
"Add entry"/>
163 <div class=
"clear"></div>