treewide: Fix typos in comments
[project/luci.git] / applications / luci-app-asterisk / luasrc / view / asterisk / dialzones.htm
1 <%#
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.
5 -%>
6
7 <%+header%>
8
9 <%
10 local uci = luci.model.uci.cursor_state()
11 local ast = require("luci.asterisk")
12
13 function digit_pattern(s)
14 return "<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'>%s</code>" % s
15 end
16
17 function rowstyle(i)
18 return "cbi-rowstyle-%i" %{
19 ( i % 2 ) == 0 and 2 or 1
20 }
21 end
22
23 local function find_trunks()
24 local t = { }
25
26 uci:foreach("asterisk", "sip",
27 function(s)
28 if uci:get_bool("asterisk", s['.name'], "provider") then
29 t[#t+1] = {
30 "SIP/%s" % s['.name'],
31 "SIP: %s" % s['.name']
32 }
33 end
34 end)
35
36 uci:foreach("asterisk", "iax",
37 function(s)
38 t[#t+1] = {
39 "IAX/%s" % s['.name'],
40 "IAX: %s" % s.extension or s['.name']
41 }
42 end)
43
44 return t
45 end
46
47 %>
48
49
50 <form method="post" action="<%=url('admin/asterisk/dialplans/zones')%>" enctype="multipart/form-data">
51 <div>
52 <input type="hidden" name="cbi.submit" value="1" />
53 <input type="submit" value="Save" class="hidden" />
54 </div>
55
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.
63 </div>
64
65 <!-- tblsection -->
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>
72 </div>
73 </div>
74
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>
82 </div>
83
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">
87 <%=rule.name%>
88 </div>
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)%>&#160;<br />
92 <% end %>
93 </div>
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 />
98 <% end %>
99 </div>
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()
104 end
105 )%>
106 </div>
107 <div style="text-align:left" class="td cbi-value-field">
108 <%=rule.description or rule.name%>
109 </div>
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" />
113 </a>
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" />
116 </a>
117 </div>
118 </div>
119 <% end %>
120 </div>
121 <div class="cbi-section-create cbi-tblsection-create"></div>
122 </div>
123 <br />
124
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 specify multiple number matches by separating them with spaces.<br />
130
131 <%- if create_error then %>
132 <br /><span style="color:red">Invalid name given!</span><br />
133 <% end -%>
134
135 <div class="table">
136 <div class="tr">
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" />
140 <br /><br />
141
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" />
144 </div>
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>
150 <% end %>
151 </select>
152 </div>
153 </div>
154 </div>
155 <br />
156
157 <input type="submit" class="cbi-button cbi-button-add" name="newzone" value="Add entry" title="Add entry"/>
158 </div>
159 </div>
160 </fieldset>
161 </div>
162 </form>
163 <div class="clear"></div>
164 <%+footer%>