summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-asterisk/luasrc/view
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-asterisk/luasrc/view')
-rw-r--r--applications/luci-app-asterisk/luasrc/view/asterisk/cbi/cell.htm22
-rw-r--r--applications/luci-app-asterisk/luasrc/view/asterisk/dialplans.htm254
-rw-r--r--applications/luci-app-asterisk/luasrc/view/asterisk/dialzones.htm174
3 files changed, 450 insertions, 0 deletions
diff --git a/applications/luci-app-asterisk/luasrc/view/asterisk/cbi/cell.htm b/applications/luci-app-asterisk/luasrc/view/asterisk/cbi/cell.htm
new file mode 100644
index 0000000000..b5d618ff95
--- /dev/null
+++ b/applications/luci-app-asterisk/luasrc/view/asterisk/cbi/cell.htm
@@ -0,0 +1,22 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id: dvalue.htm 3367 2008-09-19 10:42:02Z Cyrus $
+
+-%>
+
+<%+cbi/valueheader%>
+<% if self.href then %><a href="<%=self.href%>"><% end -%>
+ <%=self:cfgvalue(section)%>
+<%- if self.href then %></a><%end%>
+&#160;
+<input type="hidden" id="<%=cbid%>" value="<%=luci.util.pcdata(self:cfgvalue(section))%>" />
+<%+cbi/valuefooter%>
diff --git a/applications/luci-app-asterisk/luasrc/view/asterisk/dialplans.htm b/applications/luci-app-asterisk/luasrc/view/asterisk/dialplans.htm
new file mode 100644
index 0000000000..a46a8db179
--- /dev/null
+++ b/applications/luci-app-asterisk/luasrc/view/asterisk/dialplans.htm
@@ -0,0 +1,254 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%+header%>
+
+<%
+ local uci = luci.model.uci.cursor_state()
+ local ast = require "luci.asterisk"
+
+ function digit_pattern(s,t)
+ return "<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'%s>%s</code>"
+ %{ t and " title='" .. t .. "'" or "", s }
+ end
+
+ function rowstyle(i)
+ return "cbi-rowstyle-%i" %{
+ ( i % 2 ) == 0 and 2 or 1
+ }
+ end
+
+ function format_matches(z)
+ local html = { }
+
+ if type(z) ~= "table" then
+ z = { matches = { z } }
+ end
+
+ if z.localprefix then
+ for _, m in ipairs(z.matches) do
+ html[#html+1] =
+ digit_pattern(z.localprefix, "local prefix") .. " " ..
+ digit_pattern(m)
+ end
+ end
+
+ if z.intlmatches and #z.intlmatches > 0 then
+ for _, i in ipairs(z.intlmatches) do
+ for _, m in ipairs(z.matches) do
+ html[#html+1] = "%s %s" %{
+ digit_pattern("(%s)" % i, "intl. prefix"),
+ digit_pattern(m)
+ }
+ end
+ end
+ else
+ for _, m in ipairs(z.matches) do
+ html[#html+1] = digit_pattern(m)
+ end
+ end
+
+ return table.concat(html, "; ")
+ end
+%>
+
+
+<form method="post" action="<%=luci.dispatcher.build_url("admin", "asterisk", "dialplans")%>" 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><a id="content" name="content">Outgoing Call Routing</a></h2>
+ <div class="cbi-map-descr">
+ Here you can manage your dial plans which are used to route outgoing calls from your local extensions.<br /><br />
+ Related tasks:<br />
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans/zones')%>" class="cbi-title-ref">Manage dialzones</a> |
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/voicemail/mailboxes')%>" class="cbi-title-ref">Manage voicemail boxes</a> |
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/meetme/rooms')%>" class="cbi-title-ref">Manage meetme rooms</a>
+ </div>
+ <!-- tblsection -->
+ <fieldset class="cbi-section" id="cbi-asterisk-sip">
+ <!--<legend>Dialplans</legend>-->
+ <div class="cbi-section-descr"></div>
+
+ <% for i, plan in pairs(ast.dialplan.plans()) do %>
+ <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">
+ <big>Dialplan <em><%=plan.name%></em></big>
+ </th>
+ <td>
+ <a href="<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans')%>?delplan=<%=plan.name%>">
+ <img style="border:none" alt="Remove this dialplan" title="Remove this dialplan" src="/luci-static/resources/cbi/remove.gif" />
+ </a>
+ </td>
+ </tr>
+
+ <!-- dialzones -->
+ <% local zones_used = { }; local row = 0 %>
+ <% for i, zone in ipairs(plan.zones) do zones_used[zone.name] = true %>
+ <tr class="cbi-section-table-row <%=rowstyle(row)%>">
+ <td style="text-align: left; padding: 3px" class="cbi-section-table-cell">
+ <strong>&#x2514; Dialzone <em><%=zone.name%></em></strong> (<%=zone.description%>)
+ <p style="padding-left: 1em; margin-bottom:0">
+ Lines:
+ <%=ast.tools.hyperlinks(
+ zone.trunks, function(v)
+ return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
+ end
+ )%><br />
+ Matches:
+ <%=format_matches(zone)%>
+ </p>
+ </td>
+ <td style="width:5%" class="cbi-value-field">
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans/out', zone.name)%>">
+ <img style="border:none" alt="Edit dialzone" title="Edit dialzone" src="/luci-static/resources/cbi/edit.gif" />
+ </a>
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delzone.<%=plan.name%>=<%=zone.name%>">
+ <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
+ </a>
+ </td>
+ </tr>
+ <% row = row + 1; end %>
+ <!-- /dialzones -->
+
+ <!-- voicemail -->
+ <% local boxes_used = { } %>
+ <% for ext, box in luci.util.kspairs(plan.voicemailboxes) do boxes_used[box.id] = true %>
+ <tr class="cbi-section-table-row <%=rowstyle(row)%>">
+ <td style="text-align: left; padding: 3px" class="cbi-section-table-cell">
+ <strong>&#x2514; Voicemailbox <em><%=box.id%></em></strong> (<%=box.name%>)
+ <p style="padding-left: 1em; margin-bottom:0">
+ Owner: <%=box.name%> |
+ eMail: <%=#box.email > 0 and box.email or 'n/a'%> |
+ Pager: <%=#box.page > 0 and box.page or 'n/a'%><br />
+ Matches: <%=format_matches(ext)%>
+ </p>
+ </td>
+ <td style="width:5%" class="cbi-value-field">
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/voicemail/mailboxes')%>">
+ <img style="border:none" alt="Manage mailboxes ..." title="Manage mailboxes ..." src="/luci-static/resources/cbi/edit.gif" />
+ </a>
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delvbox.<%=plan.name%>=<%=ext%>">
+ <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
+ </a>
+ </td>
+ </tr>
+ <% row = row + 1; end %>
+ <!-- /voicemail -->
+
+ <!-- meetme -->
+ <% local rooms_used = { } %>
+ <% for ext, room in luci.util.kspairs(plan.meetmerooms) do rooms_used[room.room] = true %>
+ <tr class="cbi-section-table-row <%=rowstyle(row)%>">
+ <td style="text-align: left; padding: 3px" class="cbi-section-table-cell">
+ <strong>&#x2514; MeetMe Room <em><%=room.room%></em></strong>
+ <% if room.description and #room.description > 0 then %> (<%=room.description%>)<% end %>
+ <p style="padding-left: 1em; margin-bottom:0">
+ Matches: <%=format_matches(ext)%>
+ </p>
+ </td>
+ <td style="width:5%" class="cbi-value-field">
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/meetme/rooms')%>">
+ <img style="border:none" alt="Manage conferences ..." title="Manage conferences ..." src="/luci-static/resources/cbi/edit.gif" />
+ </a>
+ <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delmeetme.<%=plan.name%>=<%=ext%>">
+ <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
+ </a>
+ </td>
+ </tr>
+ <% row = row + 1; end %>
+ <!-- /meetme -->
+
+ <tr class="cbi-section-table-row">
+ <td style="text-align: left; padding: 3px" class="cbi-section-table-cell" colspan="2">
+ <hr style="margin-bottom:0.5em; border-width:0 0 1px 0" />
+
+ Add Dialzone:<br />
+ <select style="width:30%" name="addzone.<%=plan.name%>">
+ <option value="">-- please select --</option>
+ <% for _, zone in luci.util.kspairs(ast.dialzone.zones()) do %>
+ <% if not zones_used[zone.name] then %>
+ <option value="<%=zone.name%>"><%=zone.name%> (<%=zone.description%>)</option>
+ <% end %>
+ <% end %>
+ </select>
+ <br /><br />
+
+ Add Voicemailbox:<br />
+ <select style="width:20%" name="addvbox.<%=plan.name%>" onchange="this.form['addvboxext.<%=plan.name%>'].value=this.options[this.selectedIndex].value.split('@')[0]">
+ <option value="">-- please select --</option>
+ <% for ext, box in luci.util.kspairs(ast.voicemail.boxes()) do %>
+ <% if not boxes_used[box.id] then %>
+ <option value="<%=box.id%>"><%=box.id%> (<%=box.name%>)</option>
+ <% end %>
+ <% end %>
+ </select>
+ as extension
+ <input type="text" style="width:5%" name="addvboxext.<%=plan.name%>" />
+ <br /><br />
+
+ Add MeetMe Conference:<br />
+ <select style="width:20%" name="addmeetme.<%=plan.name%>" onchange="this.form['addmeetmeext.<%=plan.name%>'].value=this.options[this.selectedIndex].value">
+ <option value="">-- please select --</option>
+ <% for ext, room in luci.util.kspairs(ast.meetme.rooms()) do %>
+ <%# if not rooms_used[room.room] then %>
+ <option value="<%=room.room%>">
+ <%=room.room%>
+ <% if room.description and #room.description > 0 then %>(<%=room.description%>)<% end %>
+ </option>
+ <%# end %>
+ <% end %>
+ </select>
+ as extension
+ <input type="text" style="width:5%" name="addmeetmeext.<%=plan.name%>" />
+ <br /><br />
+
+ <input type="submit" class="cbi-button cbi-button-add" value="Add item &raquo;" title="Add item ..."/>
+ </td>
+ </tr>
+
+ </table>
+
+ <div class="cbi-section-create cbi-tblsection-create"></div>
+ </div>
+ <br />
+ <% end %>
+
+ <div class="cbi-section-node">
+ <div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
+ <h3>Create a new dialplan</h3>
+ The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
+
+ <%- if create_error then %>
+ <br /><span style="color:red">Invalid name given!</span><br />
+ <% end -%>
+
+ <br />
+ <input type="text" class="cbi-section-create-name" name="addplan" style="width:200px" />
+ <input type="submit" class="cbi-button cbi-button-add" value="Add dialplan" title="Add dialplan"/>
+ </div>
+ </div>
+
+ </fieldset>
+</div>
+</form>
+<div class="clear"></div>
+<%+footer%>
diff --git a/applications/luci-app-asterisk/luasrc/view/asterisk/dialzones.htm b/applications/luci-app-asterisk/luasrc/view/asterisk/dialzones.htm
new file mode 100644
index 0000000000..f93496df8b
--- /dev/null
+++ b/applications/luci-app-asterisk/luasrc/view/asterisk/dialzones.htm
@@ -0,0 +1,174 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+
+<%+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="<%=luci.dispatcher.build_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><a id="content" name="content">Dial Zone Management</a></h2>
+ <div class="cbi-map-descr">
+ <a href="<%=luci.dispatcher.build_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)%>&#160;<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="<%=luci.dispatcher.build_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="<%=luci.dispatcher.build_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%>