1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
<%#
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
Licensed to the public under the Apache License 2.0.
-%>
<%+header%>
<%
local uci = luci.model.uci.cursor_state()
local ast = require("luci.asterisk")
function digit_pattern(s)
return "<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'>%s</code>" % s
end
function rowstyle(i)
return "cbi-rowstyle-%i" %{
( i % 2 ) == 0 and 2 or 1
}
end
local function find_trunks()
local t = { }
uci:foreach("asterisk", "sip",
function(s)
if uci:get_bool("asterisk", s['.name'], "provider") then
t[#t+1] = {
"SIP/%s" % s['.name'],
"SIP: %s" % s['.name']
}
end
end)
uci:foreach("asterisk", "iax",
function(s)
t[#t+1] = {
"IAX/%s" % s['.name'],
"IAX: %s" % s.extension or s['.name']
}
end)
return t
end
%>
<form method="post" action="<%=url('admin/asterisk/dialplans/zones')%>" enctype="multipart/form-data">
<div>
<script type="text/javascript" src="/luci-static/resources/cbi.js"></script>
<input type="hidden" name="cbi.submit" value="1" />
<input type="submit" value="Save" class="hidden" />
</div>
<div class="cbi-map" id="cbi-asterisk">
<h2 name="content">Dial Zone Management</h2>
<div class="cbi-map-descr">
<a href="<%=url("admin/asterisk/dialplans")%>" class="cbi-title-ref">Back to dialplan overview</a><br /><br />
Here you can manage your dial zones. The zones are used to route outgoing calls to the destination.
Each zone groups multiple trunks and number matches to represent a logical destination. Zones can
also be used to enforce certain dial restrictions on selected extensions.
</div>
<!-- tblsection -->
<fieldset class="cbi-section" id="cbi-asterisk-sip">
<div class="cbi-section-node">
<table class="cbi-section-table">
<tr class="cbi-section-table-titles">
<th style="text-align: left; padding: 3px" class="cbi-section-table-cell" colspan="6">
<h3>Dialzone Overview</h3>
</th>
</tr>
<tr class="cbi-section-table-descr">
<th style="width: 5%; text-align:right" class="cbi-section-table-cell">Name</th>
<th style="width: 5%; text-align:right" class="cbi-section-table-cell">Prepend</th>
<th style="width: 20%; text-align:left" class="cbi-section-table-cell">- Match</th>
<th style="text-align:left" class="cbi-section-table-cell">Trunk</th>
<th style="width: 35%; text-align:left" class="cbi-section-table-cell">Description</th>
<th style="width: 4%; text-align:left" class="cbi-section-table-cell"></th>
</tr>
<% for i, rule in pairs(ast.dialzone.zones()) do %>
<tr class="cbi-section-table-row <%=rowstyle(i)%>">
<td style="text-align:right" class="cbi-value-field">
<%=rule.name%>
</td>
<td style="text-align:right" class="cbi-value-field">
<% for _ in ipairs(rule.matches) do %>
<%=rule.addprefix and digit_pattern(rule.addprefix)%> <br />
<% end %>
</td>
<td style="text-align:left" class="cbi-value-field">
<% for _, m in ipairs(rule.matches) do %>
<%=rule.localprefix and "%s " % digit_pattern(rule.localprefix)%>
<%=digit_pattern(m)%><br />
<% end %>
</td>
<td style="text-align:left" class="cbi-value-field">
<%=ast.tools.hyperlinks(
rule.trunks, function(v)
return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
end
)%>
</td>
<td style="text-align:left" class="cbi-value-field">
<%=rule.description or rule.name%>
</td>
<td style="text-align:left" class="cbi-value-field">
<a href="<%=url('admin/asterisk/dialplans/out', rule.name)%>">
<img style="border:none" alt="Edit entry" title="Edit entry" src="/luci-static/resources/cbi/edit.gif" />
</a>
<a href="<%=url('admin/asterisk/dialplans/zones')%>?delzone=<%=rule.name%>">
<img style="border:none" alt="Delete entry" title="Delete entry" src="/luci-static/resources/cbi/remove.gif" />
</a>
</td>
</tr>
<% end %>
</table>
<div class="cbi-section-create cbi-tblsection-create"></div>
</div>
<br />
<div class="cbi-section-node">
<div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
<h3>Create a new dialzone</h3>
The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
You can specifiy multiple number matches by separating them with spaces.<br />
<%- if create_error then %>
<br /><span style="color:red">Invalid name given!</span><br />
<% end -%>
<table>
<tr>
<td style="padding:3px">
<label for="create1">1) Name</label><br />
<input type="text" class="cbi-section-create-name" id="create1" name="newzone_name" style="width:200px" />
<br /><br />
<label for="create2">2) Number Match</label><br />
<input type="text" class="cbi-section-create-name" id="create2" name="newzone_match" style="width:200px" />
</td>
<td style="padding:3px">
<label for="create3">3) Trunks</label><br />
<select class="cbi-input-select" multiple="multiple" id="create3" name="newzone_uses" size="4" style="width:200px">
<% for i, t in ipairs(find_trunks()) do %>
<option value="<%=t[1]%>"><%=t[2]%></option>
<% end %>
</select>
</td>
</tr>
</table>
<br />
<input type="submit" class="cbi-button cbi-button-add" name="newzone" value="Add entry" title="Add entry"/>
</div>
</div>
</fieldset>
</div>
</form>
<div class="clear"></div>
<%+footer%>
|