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)
23 return "<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'>%s</code>" % s
27 return "cbi-rowstyle-%i" %{
28 ( i % 2 ) == 0 and 2 or 1
32 local function find_trunks()
35 uci:foreach("asterisk", "sip",
37 if uci:get_bool("asterisk", s['.name'], "provider") then
39 "SIP/%s" % s['.name'],
40 "SIP: %s" % s['.name']
45 uci:foreach("asterisk", "iax",
48 "IAX/%s" % s['.name'],
49 "IAX: %s" % s.extension or s['.name']
59 <form method="post" action="<%=luci.dispatcher.build_url("admin", "asterisk", "dialplans", "zones")%>" enctype="multipart/form-data">
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" />
66 <div class="cbi-map" id="cbi-asterisk">
67 <h2><a id="content" name="content">Dial Zone Management</a></h2>
68 <div class="cbi-map-descr">
69 <a href="<%=luci.dispatcher.build_url("admin/asterisk/dialplans")%>" class="cbi-title-ref">Back to dialplan overview</a><br /><br />
70 Here you can manage your dial zones. The zones are used to route outgoing calls to the destination.
71 Each zone groups multiple trunks and number matches to represent a logical destination. Zones can
72 also be used to enforce certain dial restrictions on selected extensions.
76 <fieldset class="cbi-section" id="cbi-asterisk-sip">
77 <div class="cbi-section-node">
78 <table class="cbi-section-table">
79 <tr class="cbi-section-table-titles">
80 <th style="text-align: left; padding: 3px" class="cbi-section-table-cell" colspan="6">
81 <h3>Dialzone Overview</h3>
85 <tr class="cbi-section-table-descr">
86 <th style="width: 5%; text-align:right" class="cbi-section-table-cell">Name</th>
87 <th style="width: 5%; text-align:right" class="cbi-section-table-cell">Prepend</th>
88 <th style="width: 20%; text-align:left" class="cbi-section-table-cell">- Match</th>
89 <th style="text-align:left" class="cbi-section-table-cell">Trunk</th>
90 <th style="width: 35%; text-align:left" class="cbi-section-table-cell">Description</th>
91 <th style="width: 4%; text-align:left" class="cbi-section-table-cell"></th>
94 <% for i, rule in pairs(ast.dialzone.zones()) do %>
95 <tr class="cbi-section-table-row <%=rowstyle(i)%>">
96 <td style="text-align:right" class="cbi-value-field">
99 <td style="text-align:right" class="cbi-value-field">
100 <% for _ in ipairs(rule.matches) do %>
101 <%=rule.addprefix and digit_pattern(rule.addprefix)%> <br />
104 <td style="text-align:left" class="cbi-value-field">
105 <% for _, m in ipairs(rule.matches) do %>
106 <%=rule.localprefix and "%s " % digit_pattern(rule.localprefix)%>
107 <%=digit_pattern(m)%><br />
110 <td style="text-align:left" class="cbi-value-field">
111 <%=ast.tools.hyperlinks(
112 rule.trunks, function(v)
113 return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
117 <td style="text-align:left" class="cbi-value-field">
118 <%=rule.description or rule.name%>
120 <td style="text-align:left" class="cbi-value-field">
121 <a href="<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans', 'out', rule.name)%>">
122 <img style="border:none" alt="Edit entry" title="Edit entry" src="/luci-static/resources/cbi/edit.gif" />
124 <a href="<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans', 'zones')%>?delzone=<%=rule.name%>">
125 <img style="border:none" alt="Delete entry" title="Delete entry" src="/luci-static/resources/cbi/remove.gif" />
131 <div class="cbi-section-create cbi-tblsection-create"></div>
135 <div class="cbi-section-node">
136 <div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
137 <h3>Create a new dialzone</h3>
138 The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
139 You can specifiy multiple number matches by separating them with spaces.<br />
141 <%- if create_error then %>
142 <br /><span style="color:red">Invalid name given!</span><br />
147 <td style="padding:3px">
148 <label for="create1">1) Name</label><br />
149 <input type="text" class="cbi-section-create-name" id="create1" name="newzone_name" style="width:200px" />
152 <label for="create2">2) Number Match</label><br />
153 <input type="text" class="cbi-section-create-name" id="create2" name="newzone_match" style="width:200px" />
155 <td style="padding:3px">
156 <label for="create3">3) Trunks</label><br />
157 <select class="cbi-input-select" multiple="multiple" id="create3" name="newzone_uses" size="4" style="width:200px">
158 <% for i, t in ipairs(find_trunks()) do %>
159 <option value="<%=t[1]%>"><%=t[2]%></option>
167 <input type="submit" class="cbi-button cbi-button-add" name="newzone" value="Add entry" title="Add entry"/>
173 <div class="clear"></div>