applications/luci-asterisk: some minor html cleanups
[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 z.localprefix then
37 for _, m in ipairs(z.matches) do
38 html[#html+1] =
39 digit_pattern(z.localprefix, "local prefix") .. " " ..
40 digit_pattern(m)
41 end
42 end
43
44 if #z.intlmatches > 0 then
45 for _, i in ipairs(z.intlmatches) do
46 for _, m in ipairs(z.matches) do
47 html[#html+1] = "%s %s" %{
48 digit_pattern("(%s)" % i, "intl. prefix"),
49 digit_pattern(m)
50 }
51 end
52 end
53 else
54 for _, m in ipairs(z.matches) do
55 html[#html+1] = digit_pattern(m)
56 end
57 end
58
59 return table.concat(html, "; ")
60 end
61 %>
62
63
64 <form method="post" action="<%=luci.dispatcher.build_url("admin", "asterisk", "dialplans")%>" enctype="multipart/form-data">
65 <div>
66 <script type="text/javascript" src="/luci-static/resources/cbi.js"></script>
67 <input type="hidden" name="cbi.submit" value="1" />
68 <input type="submit" value="Save" class="hidden" />
69 </div>
70
71 <div class="cbi-map" id="cbi-asterisk">
72 <h2><a id="content" name="content">Outgoing Call Routing</a></h2>
73 <div class="cbi-map-descr">
74 Here you can manage your dial plans which are used to route outgoing calls from your local extensions.
75 </div>
76 <!-- tblsection -->
77 <fieldset class="cbi-section" id="cbi-asterisk-sip">
78 <!--<legend>Dialplans</legend>-->
79 <div class="cbi-section-descr"></div>
80
81 <% for i, plan in pairs(ast.dialplan.plans()) do %>
82 <div class="cbi-section-node">
83 <table class="cbi-section-table">
84 <tr class="cbi-section-table-titles">
85 <th style="text-align: left; padding: 3px" class="cbi-section-table-cell">
86 <big>Dialplan <em><%=plan.name%></em></big>
87 </th>
88 <td>
89 <a href="<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans')%>?delplan=<%=plan.name%>">
90 <img style="border:none" alt="Remove this dialplan" title="Remove this dialplan" src="/luci-static/resources/cbi/remove.gif" />
91 </a>
92 </td>
93 </tr>
94
95 <!-- dialzones -->
96 <% local zones_used = { } %>
97 <% for i, zone in ipairs(plan.zones) do zones_used[zone.name] = true %>
98 <tr class="cbi-section-table-row <%=rowstyle(i)%>">
99 <td style="text-align: left; padding: 3px" class="cbi-section-table-cell">
100 <strong>&#x2514; Dialzone <em><%=zone.name%></em></strong> (<%=zone.description%>)
101 <p style="padding-left: 1em; margin-bottom:0">
102 Lines:
103 <%=ast.tools.hyperlinks(
104 zone.trunks, function(v)
105 return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
106 end
107 )%><br />
108 Matches:
109 <%=format_matches(zone)%>
110 </p>
111 </td>
112 <td style="width:5%" class="cbi-value-field">
113 <a href="<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans', 'out', zone.name)%>">
114 <img style="border:none" alt="Edit dialzone" title="Edit dialzone" src="/luci-static/resources/cbi/edit.gif" />
115 </a>
116 <a href="<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans')%>?delzone.<%=plan.name%>=<%=zone.name%>">
117 <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
118 </a>
119 </td>
120 </tr>
121 <% end %>
122
123 <tr class="cbi-section-table-row">
124 <td style="text-align: left; padding: 3px" class="cbi-section-table-cell" colspan="2">
125 <hr style="margin-bottom:0.5em; border-width:0 0 1px 0" />
126 <select style="width:30%" name="addzone.<%=plan.name%>">
127 <option value="">-- Add dialzone --</option>
128 <% for _, zone in pairs(ast.dialzone.zones()) do %>
129 <% if not zones_used[zone.name] then %>
130 <option value="<%=zone.name%>"><%=zone.name%> (<%=zone.description%>)</option>
131 <% end %>
132 <% end %>
133 </select>
134 <input type="submit" class="cbi-button cbi-button-add" value=" &raquo; " title="Add Zone ..."/>
135 &nbsp; &nbsp;
136 <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans/zones')%>" class="cbi-title-ref">Manage dialzones</a>
137 </td>
138 </tr>
139 <!-- /dialzones -->
140
141 </table>
142
143 <div class="cbi-section-create cbi-tblsection-create"></div>
144 </div>
145 <br />
146 <% end %>
147
148 <div class="cbi-section-node">
149 <div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
150 <h3>Create a new dialplan</h3>
151 The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
152
153 <%- if create_error then %>
154 <br /><span style="color:red">Invalid name given!</span><br />
155 <% end -%>
156
157 <br />
158 <input type="text" class="cbi-section-create-name" name="addplan" style="width:200px" />
159 <input type="submit" class="cbi-button cbi-button-add" value="Add dialplan" title="Add dialplan"/>
160 </div>
161 </div>
162
163 </fieldset>
164 </div>
165 </form>
166 <div class="clear"></div>
167 <%+footer%>