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)
37 for _, m in ipairs(z.matches) do
39 digit_pattern(z.localprefix,
"local prefix") ..
" " ..
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"),
54 for _, m in ipairs(z.matches) do
55 html[#html+
1] = digit_pattern(m)
59 return table.concat(html,
"; ")
64 <form method=
"post" action=
"<%=luci.dispatcher.build_url("admin
", "asterisk
", "dialplans
")%>" enctype=
"multipart/form-data">
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" />
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"></div><!-- tblsection -->
74 <fieldset class=
"cbi-section" id=
"cbi-asterisk-sip">
75 <!--<legend>Dialplans</legend>-->
76 <div class=
"cbi-section-descr">
77 Here you can manage your dial plans which are used to route outgoing calls from your local extensions.
80 <% for i, plan in pairs(ast.dialplan.plans()) do %
>
81 <div class=
"cbi-section-node">
82 <table class=
"cbi-section-table">
83 <tr class=
"cbi-section-table-titles">
84 <th style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell">
85 <big>Dialplan
<em><%=plan.name%
></em></big>
88 <a href=
"<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans')%>?delplan=<%=plan.name%>">
89 <img style=
"border:none" alt=
"Remove this dialplan" title=
"Remove this dialplan" src=
"/luci-static/resources/cbi/remove.gif" />
95 <% local zones_used = { } %
>
96 <% for i, zone in ipairs(plan.zones) do zones_used[zone.name] = true %
>
97 <tr class=
"cbi-section-table-row <%=rowstyle(i)%>">
98 <td style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell">
99 <strong>└ Dialzone
<em><%=zone.name%
></em></strong>
100 <p style=
"padding-left: 1em; margin-bottom:0">
101 Description: <%=zone.description%
><br />
103 <%=ast.tools.hyperlinks(
104 zone.trunks, function(v)
105 return luci.dispatcher.build_url(
"admin",
"asterisk",
"trunks",
"%s") % v:lower()
109 <%=format_matches(zone)%
>
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" />
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" />
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>
134 <input type=
"submit" class=
"cbi-button cbi-button-add" value=
" » " title=
"Add Zone ..."/>
136 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/dialplans/zones')%>" class=
"cbi-title-ref">Manage dialzones
</a>
143 <div class=
"cbi-section-create cbi-tblsection-create"></div>
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 />
153 <%- if create_error then %
>
154 <br /><span style=
"color:red">Invalid name given!
</span><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"/>
166 <div class=
"clear"></div>