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