Merge pull request #1847 from dibdot/lxc_fix
[project/luci.git] / applications / luci-app-asterisk / luasrc / view / asterisk / dialplans.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,t)
14 return "<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'%s>%s</code>"
15 %{ t and " title='" .. t .. "'" or "", s }
16 end
17
18 function rowstyle(i)
19 return "cbi-rowstyle-%i" %{
20 ( i % 2 ) == 0 and 2 or 1
21 }
22 end
23
24 function format_matches(z)
25 local html = { }
26
27 if type(z) ~= "table" then
28 z = { matches = { z } }
29 end
30
31 if z.localprefix then
32 for _, m in ipairs(z.matches) do
33 html[#html+1] =
34 digit_pattern(z.localprefix, "local prefix") .. " " ..
35 digit_pattern(m)
36 end
37 end
38
39 if z.intlmatches and #z.intlmatches > 0 then
40 for _, i in ipairs(z.intlmatches) do
41 for _, m in ipairs(z.matches) do
42 html[#html+1] = "%s %s" %{
43 digit_pattern("(%s)" % i, "intl. prefix"),
44 digit_pattern(m)
45 }
46 end
47 end
48 else
49 for _, m in ipairs(z.matches) do
50 html[#html+1] = digit_pattern(m)
51 end
52 end
53
54 return table.concat(html, "; ")
55 end
56 %>
57
58
59 <form method="post" action="<%=url('admin/asterisk/dialplans')%>" enctype="multipart/form-data">
60 <div>
61 <script type="text/javascript" src="/luci-static/resources/cbi.js"></script>
62 <input type="hidden" name="cbi.submit" value="1" />
63 <input type="submit" value="Save" class="hidden" />
64 </div>
65
66 <div class="cbi-map" id="cbi-asterisk">
67 <h2 name="content">Outgoing Call Routing</h2>
68 <div class="cbi-map-descr">
69 Here you can manage your dial plans which are used to route outgoing calls from your local extensions.<br /><br />
70 Related tasks:<br />
71 <a href="<%=url('admin/asterisk/dialplans/zones')%>" class="cbi-title-ref">Manage dialzones</a> |
72 <a href="<%=url('admin/asterisk/voicemail/mailboxes')%>" class="cbi-title-ref">Manage voicemail boxes</a> |
73 <a href="<%=url('admin/asterisk/meetme/rooms')%>" class="cbi-title-ref">Manage meetme rooms</a>
74 </div>
75 <!-- tblsection -->
76 <fieldset class="cbi-section" id="cbi-asterisk-sip">
77 <!--<legend>Dialplans</legend>-->
78 <div class="cbi-section-descr"></div>
79
80 <% for i, plan in pairs(ast.dialplan.plans()) do %>
81 <div class="cbi-section-node">
82 <div class="table cbi-section-table">
83 <div class="tr cbi-section-table-titles">
84 <div style="text-align: left; padding: 3px" class="th cbi-section-table-cell">
85 <big>Dialplan <em><%=plan.name%></em></big>
86 </div>
87 <div class="td">
88 <a href="<%=url('admin/asterisk/dialplans')%>?delplan=<%=plan.name%>">
89 <img style="border:none" alt="Remove this dialplan" title="Remove this dialplan" src="/luci-static/resources/cbi/remove.gif" />
90 </a>
91 </div>
92 </div>
93
94 <!-- dialzones -->
95 <% local zones_used = { }; local row = 0 %>
96 <% for i, zone in ipairs(plan.zones) do zones_used[zone.name] = true %>
97 <div class="tr cbi-section-table-row <%=rowstyle(row)%>">
98 <div style="text-align: left; padding: 3px" class="td cbi-section-table-cell">
99 <strong>&#x2514; Dialzone <em><%=zone.name%></em></strong> (<%=zone.description%>)
100 <p style="padding-left: 1em; margin-bottom:0">
101 Lines:
102 <%=ast.tools.hyperlinks(
103 zone.trunks, function(v)
104 return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
105 end
106 )%><br />
107 Matches:
108 <%=format_matches(zone)%>
109 </p>
110 </div>
111 <div style="width:5%" class="td cbi-value-field">
112 <a href="<%=url('admin/asterisk/dialplans/out', zone.name)%>">
113 <img style="border:none" alt="Edit dialzone" title="Edit dialzone" src="/luci-static/resources/cbi/edit.gif" />
114 </a>
115 <a href="<%=url('admin/asterisk/dialplans')%>?delzone.<%=plan.name%>=<%=zone.name%>">
116 <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
117 </a>
118 </div>
119 </div>
120 <% row = row + 1; end %>
121 <!-- /dialzones -->
122
123 <!-- voicemail -->
124 <% local boxes_used = { } %>
125 <% for ext, box in luci.util.kspairs(plan.voicemailboxes) do boxes_used[box.id] = true %>
126 <div class="tr cbi-section-table-row <%=rowstyle(row)%>">
127 <div style="text-align: left; padding: 3px" class="td cbi-section-table-cell">
128 <strong>&#x2514; Voicemailbox <em><%=box.id%></em></strong> (<%=box.name%>)
129 <p style="padding-left: 1em; margin-bottom:0">
130 Owner: <%=box.name%> |
131 eMail: <%=#box.email > 0 and box.email or 'n/a'%> |
132 Pager: <%=#box.page > 0 and box.page or 'n/a'%><br />
133 Matches: <%=format_matches(ext)%>
134 </p>
135 </div>
136 <div style="width:5%" class="td cbi-value-field">
137 <a href="<%=url('admin/asterisk/voicemail/mailboxes')%>">
138 <img style="border:none" alt="Manage mailboxes ..." title="Manage mailboxes ..." src="/luci-static/resources/cbi/edit.gif" />
139 </a>
140 <a href="<%=url('admin/asterisk/dialplans')%>?delvbox.<%=plan.name%>=<%=ext%>">
141 <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
142 </a>
143 </div>
144 </div>
145 <% row = row + 1; end %>
146 <!-- /voicemail -->
147
148 <!-- meetme -->
149 <% local rooms_used = { } %>
150 <% for ext, room in luci.util.kspairs(plan.meetmerooms) do rooms_used[room.room] = true %>
151 <div class="tr cbi-section-table-row <%=rowstyle(row)%>">
152 <div style="text-align: left; padding: 3px" class="td cbi-section-table-cell">
153 <strong>&#x2514; MeetMe Room <em><%=room.room%></em></strong>
154 <% if room.description and #room.description > 0 then %> (<%=room.description%>)<% end %>
155 <p style="padding-left: 1em; margin-bottom:0">
156 Matches: <%=format_matches(ext)%>
157 </p>
158 </div>
159 <div style="width:5%" class="td cbi-value-field">
160 <a href="<%=url('admin/asterisk/meetme/rooms')%>">
161 <img style="border:none" alt="Manage conferences ..." title="Manage conferences ..." src="/luci-static/resources/cbi/edit.gif" />
162 </a>
163 <a href="<%=url('admin/asterisk/dialplans')%>?delmeetme.<%=plan.name%>=<%=ext%>">
164 <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
165 </a>
166 </div>
167 </div>
168 <% row = row + 1; end %>
169 <!-- /meetme -->
170
171 <div class="tr cbi-section-table-row">
172 <div style="text-align: left; padding: 3px" class="td cbi-section-table-cell" colspan="2">
173 <hr style="margin-bottom:0.5em; border-width:0 0 1px 0" />
174
175 Add Dialzone:<br />
176 <select style="width:30%" name="addzone.<%=plan.name%>">
177 <option value="">-- please select --</option>
178 <% for _, zone in luci.util.kspairs(ast.dialzone.zones()) do %>
179 <% if not zones_used[zone.name] then %>
180 <option value="<%=zone.name%>"><%=zone.name%> (<%=zone.description%>)</option>
181 <% end %>
182 <% end %>
183 </select>
184 <br /><br />
185
186 Add Voicemailbox:<br />
187 <select style="width:20%" name="addvbox.<%=plan.name%>" onchange="this.form['addvboxext.<%=plan.name%>'].value=this.options[this.selectedIndex].value.split('@')[0]">
188 <option value="">-- please select --</option>
189 <% for ext, box in luci.util.kspairs(ast.voicemail.boxes()) do %>
190 <% if not boxes_used[box.id] then %>
191 <option value="<%=box.id%>"><%=box.id%> (<%=box.name%>)</option>
192 <% end %>
193 <% end %>
194 </select>
195 as extension
196 <input type="text" style="width:5%" name="addvboxext.<%=plan.name%>" />
197 <br /><br />
198
199 Add MeetMe Conference:<br />
200 <select style="width:20%" name="addmeetme.<%=plan.name%>" onchange="this.form['addmeetmeext.<%=plan.name%>'].value=this.options[this.selectedIndex].value">
201 <option value="">-- please select --</option>
202 <% for ext, room in luci.util.kspairs(ast.meetme.rooms()) do %>
203 <%# if not rooms_used[room.room] then %>
204 <option value="<%=room.room%>">
205 <%=room.room%>
206 <% if room.description and #room.description > 0 then %>(<%=room.description%>)<% end %>
207 </option>
208 <%# end %>
209 <% end %>
210 </select>
211 as extension
212 <input type="text" style="width:5%" name="addmeetmeext.<%=plan.name%>" />
213 <br /><br />
214
215 <input type="submit" class="cbi-button cbi-button-add" value="Add item &raquo;" title="Add item ..."/>
216 </div>
217 </div>
218
219 </div>
220
221 <div class="cbi-section-create cbi-tblsection-create"></div>
222 </div>
223 <br />
224 <% end %>
225
226 <div class="cbi-section-node">
227 <div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
228 <h3>Create a new dialplan</h3>
229 The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
230
231 <%- if create_error then %>
232 <br /><span style="color:red">Invalid name given!</span><br />
233 <% end -%>
234
235 <br />
236 <input type="text" class="cbi-section-create-name" name="addplan" style="width:200px" />
237 <input type="submit" class="cbi-button cbi-button-add" value="Add dialplan" title="Add dialplan"/>
238 </div>
239 </div>
240
241 </fieldset>
242 </div>
243 </form>
244 <div class="clear"></div>
245 <%+footer%>