2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
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
10 http://www.apache.org/licenses/LICENSE-2.0
19 local uci = luci.model.uci.cursor_state()
20 local ast = require "luci.asterisk"
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 }
28 return "cbi-rowstyle-%i" %{
29 ( i % 2 ) == 0 and 2 or 1
33 function format_matches(z)
36 if type(z) ~= "table" then
37 z = { matches = { z } }
41 for _, m in ipairs(z.matches) do
43 digit_pattern(z.localprefix, "local prefix") .. " " ..
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"),
58 for _, m in ipairs(z.matches) do
59 html[#html+1] = digit_pattern(m)
63 return table.concat(html, "; ")
68 <form method="post" action="<%=luci.dispatcher.build_url("admin", "asterisk", "dialplans")%>" enctype="multipart/form-data">
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" />
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 />
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>
85 <fieldset class="cbi-section" id="cbi-asterisk-sip">
86 <!--<legend>Dialplans</legend>-->
87 <div class="cbi-section-descr"></div>
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>
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" />
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>└ Dialzone <em><%=zone.name%></em></strong> (<%=zone.description%>)
109 <p style="padding-left: 1em; margin-bottom:0">
111 <%=ast.tools.hyperlinks(
112 zone.trunks, function(v)
113 return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
117 <%=format_matches(zone)%>
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" />
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" />
129 <% row = row + 1; end %>
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>└ 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)%>
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="Edit dialzone" title="Edit dialzone" src="/luci-static/resources/cbi/edit.gif" />
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" />
154 <% row = row + 1; end %>
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>└ MeetMe Room <em><%=room.room%></em></strong> (<%=room.description%>)
163 <p style="padding-left: 1em; margin-bottom:0">
164 Matches: <%=format_matches(ext)%>
167 <td style="width:5%" class="cbi-value-field">
168 <a href="<%=luci.dispatcher.build_url('admin/asterisk/meetme/rooms')%>">
169 <img style="border:none" alt="Edit dialzone" title="Edit dialzone" src="/luci-static/resources/cbi/edit.gif" />
171 <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delmeetme.<%=plan.name%>=<%=ext%>">
172 <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
176 <% row = row + 1; end %>
179 <tr class="cbi-section-table-row">
180 <td style="text-align: left; padding: 3px" class="cbi-section-table-cell" colspan="2">
181 <hr style="margin-bottom:0.5em; border-width:0 0 1px 0" />
184 <select style="width:30%" name="addzone.<%=plan.name%>">
185 <option value="">-- please select --</option>
186 <% for _, zone in luci.util.kspairs(ast.dialzone.zones()) do %>
187 <% if not zones_used[zone.name] then %>
188 <option value="<%=zone.name%>"><%=zone.name%> (<%=zone.description%>)</option>
194 Add Voicemailbox:<br />
195 <select style="width:20%" name="addvbox.<%=plan.name%>" onchange="this.form['addvboxext.<%=plan.name%>'].value=this.options[this.selectedIndex].value.split('@')[0]">
196 <option value="">-- please select --</option>
197 <% for ext, box in luci.util.kspairs(ast.voicemail.boxes()) do %>
198 <% if not boxes_used[box.id] then %>
199 <option value="<%=box.id%>"><%=box.id%> (<%=box.name%>)</option>
204 <input type="text" style="width:5%" name="addvboxext.<%=plan.name%>" />
207 Add MeetMe Conference:<br />
208 <select style="width:20%" name="addmeetme.<%=plan.name%>" onchange="this.form['addmeetmeext.<%=plan.name%>'].value=this.options[this.selectedIndex].value">
209 <option value="">-- please select --</option>
210 <% for ext, room in luci.util.kspairs(ast.meetme.rooms()) do %>
211 <%# if not rooms_used[room.room] then %>
212 <option value="<%=room.room%>"><%=room.room%> (<%=room.description%>)</option>
217 <input type="text" style="width:5%" name="addmeetmeext.<%=plan.name%>" />
220 <input type="submit" class="cbi-button cbi-button-add" value="Add item »" title="Add item ..."/>
226 <div class="cbi-section-create cbi-tblsection-create"></div>
231 <div class="cbi-section-node">
232 <div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
233 <h3>Create a new dialplan</h3>
234 The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
236 <%- if create_error then %>
237 <br /><span style="color:red">Invalid name given!</span><br />
241 <input type="text" class="cbi-section-create-name" name="addplan" style="width:200px" />
242 <input type="submit" class="cbi-button cbi-button-add" value="Add dialplan" title="Add dialplan"/>
249 <div class="clear"></div>