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 <script type=
"text/javascript" src=
"/luci-static/resources/cbi.js"></script>
53 <input type=
"hidden" name=
"cbi.submit" value=
"1" />
54 <input type=
"submit" value=
"Save" class=
"hidden" />
57 <div class=
"cbi-map" id=
"cbi-asterisk">
58 <h2 name=
"content">Dial Zone Management
</h2>
59 <div class=
"cbi-map-descr">
60 <a href=
"<%=url("admin/asterisk/dialplans
")%>" class=
"cbi-title-ref">Back to dialplan overview
</a><br /><br />
61 Here you can manage your dial zones. The zones are used to route outgoing calls to the destination.
62 Each zone groups multiple trunks and number matches to represent a logical destination. Zones can
63 also be used to enforce certain dial restrictions on selected extensions.
67 <fieldset class=
"cbi-section" id=
"cbi-asterisk-sip">
68 <div class=
"cbi-section-node">
69 <table class=
"cbi-section-table">
70 <tr class=
"cbi-section-table-titles">
71 <th style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell" colspan=
"6">
72 <h3>Dialzone Overview
</h3>
76 <tr class=
"cbi-section-table-descr">
77 <th style=
"width: 5%; text-align:right" class=
"cbi-section-table-cell">Name
</th>
78 <th style=
"width: 5%; text-align:right" class=
"cbi-section-table-cell">Prepend
</th>
79 <th style=
"width: 20%; text-align:left" class=
"cbi-section-table-cell">- Match
</th>
80 <th style=
"text-align:left" class=
"cbi-section-table-cell">Trunk
</th>
81 <th style=
"width: 35%; text-align:left" class=
"cbi-section-table-cell">Description
</th>
82 <th style=
"width: 4%; text-align:left" class=
"cbi-section-table-cell"></th>
85 <% for i, rule in pairs(ast.dialzone.zones()) do %
>
86 <tr class=
"cbi-section-table-row <%=rowstyle(i)%>">
87 <td style=
"text-align:right" class=
"cbi-value-field">
90 <td style=
"text-align:right" class=
"cbi-value-field">
91 <% for _ in ipairs(rule.matches) do %
>
92 <%=rule.addprefix and digit_pattern(rule.addprefix)%
> <br />
95 <td style=
"text-align:left" class=
"cbi-value-field">
96 <% for _, m in ipairs(rule.matches) do %
>
97 <%=rule.localprefix and
"%s " % digit_pattern(rule.localprefix)%
>
98 <%=digit_pattern(m)%
><br />
101 <td style=
"text-align:left" class=
"cbi-value-field">
102 <%=ast.tools.hyperlinks(
103 rule.trunks, function(v)
104 return luci.dispatcher.build_url(
"admin",
"asterisk",
"trunks",
"%s") % v:lower()
108 <td style=
"text-align:left" class=
"cbi-value-field">
109 <%=rule.description or rule.name%
>
111 <td style=
"text-align:left" class=
"cbi-value-field">
112 <a href=
"<%=url('admin/asterisk/dialplans/out', rule.name)%>">
113 <img style=
"border:none" alt=
"Edit entry" title=
"Edit entry" src=
"/luci-static/resources/cbi/edit.gif" />
115 <a href=
"<%=url('admin/asterisk/dialplans/zones')%>?delzone=<%=rule.name%>">
116 <img style=
"border:none" alt=
"Delete entry" title=
"Delete entry" src=
"/luci-static/resources/cbi/remove.gif" />
122 <div class=
"cbi-section-create cbi-tblsection-create"></div>
126 <div class=
"cbi-section-node">
127 <div class=
"cbi-section-create cbi-tblsection-create" style=
"padding: 3px">
128 <h3>Create a new dialzone
</h3>
129 The name is required and must be unique. It may only contain the characters A-Z, a-z,
0-
9 and _ .
<br />
130 You can specifiy multiple number matches by separating them with spaces.
<br />
132 <%- if create_error then %
>
133 <br /><span style=
"color:red">Invalid name given!
</span><br />
138 <td style=
"padding:3px">
139 <label for=
"create1">1) Name
</label><br />
140 <input type=
"text" class=
"cbi-section-create-name" id=
"create1" name=
"newzone_name" style=
"width:200px" />
143 <label for=
"create2">2) Number Match
</label><br />
144 <input type=
"text" class=
"cbi-section-create-name" id=
"create2" name=
"newzone_match" style=
"width:200px" />
146 <td style=
"padding:3px">
147 <label for=
"create3">3) Trunks
</label><br />
148 <select class=
"cbi-input-select" multiple=
"multiple" id=
"create3" name=
"newzone_uses" size=
"4" style=
"width:200px">
149 <% for i, t in ipairs(find_trunks()) do %
>
150 <option value=
"<%=t[1]%>"><%=t[
2]%
></option>
158 <input type=
"submit" class=
"cbi-button cbi-button-add" name=
"newzone" value=
"Add entry" title=
"Add entry"/>
164 <div class=
"clear"></div>