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>
84 <fieldset class=
"cbi-section" id=
"cbi-asterisk-sip">
85 <!--<legend>Dialplans</legend>-->
86 <div class=
"cbi-section-descr"></div>
88 <% for i, plan in pairs(ast.dialplan.plans()) do %
>
89 <div class=
"cbi-section-node">
90 <table class=
"cbi-section-table">
91 <tr class=
"cbi-section-table-titles">
92 <th style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell">
93 <big>Dialplan
<em><%=plan.name%
></em></big>
96 <a href=
"<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans')%>?delplan=<%=plan.name%>">
97 <img style=
"border:none" alt=
"Remove this dialplan" title=
"Remove this dialplan" src=
"/luci-static/resources/cbi/remove.gif" />
103 <% local zones_used = { }; local row =
0 %
>
104 <% for i, zone in ipairs(plan.zones) do zones_used[zone.name] = true %
>
105 <tr class=
"cbi-section-table-row <%=rowstyle(row)%>">
106 <td style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell">
107 <strong>└ Dialzone
<em><%=zone.name%
></em></strong> (<%=zone.description%
>)
108 <p style=
"padding-left: 1em; margin-bottom:0">
110 <%=ast.tools.hyperlinks(
111 zone.trunks, function(v)
112 return luci.dispatcher.build_url(
"admin",
"asterisk",
"trunks",
"%s") % v:lower()
116 <%=format_matches(zone)%
>
119 <td style=
"width:5%" class=
"cbi-value-field">
120 <a href=
"<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans', 'out', zone.name)%>">
121 <img style=
"border:none" alt=
"Edit dialzone" title=
"Edit dialzone" src=
"/luci-static/resources/cbi/edit.gif" />
123 <a href=
"<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans')%>?delzone.<%=plan.name%>=<%=zone.name%>">
124 <img style=
"border:none" alt=
"Remove from this dialplan" title=
"Remove from this dialplan" src=
"/luci-static/resources/cbi/remove.gif" />
128 <% row = row +
1; end %
>
132 <% local boxes_used = { } %
>
133 <% for ext, box in luci.util.kspairs(plan.voicemailboxes) do boxes_used[box.id] = true %
>
134 <tr class=
"cbi-section-table-row <%=rowstyle(row)%>">
135 <td style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell">
136 <strong>└ Voicemailbox
<em><%=box.id%
></em></strong> (<%=box.name%
>)
137 <p style=
"padding-left: 1em; margin-bottom:0">
138 Owner: <%=box.name%
> |
139 eMail: <%=#box.email
> 0 and box.email or 'n/a'%
> |
140 Pager: <%=#box.page
> 0 and box.page or 'n/a'%
><br />
141 Matches: <%=format_matches(ext)%
>
144 <td style=
"width:5%" class=
"cbi-value-field">
145 <a href=
"<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans', 'out', box.name)%>">
146 <img style=
"border:none" alt=
"Edit dialzone" title=
"Edit dialzone" src=
"/luci-static/resources/cbi/edit.gif" />
148 <a href=
"<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans')%>?delvbox.<%=plan.name%>=<%=ext%>">
149 <img style=
"border:none" alt=
"Remove from this dialplan" title=
"Remove from this dialplan" src=
"/luci-static/resources/cbi/remove.gif" />
153 <% row = row +
1; end %
>
156 <tr class=
"cbi-section-table-row">
157 <td style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell" colspan=
"2">
158 <hr style=
"margin-bottom:0.5em; border-width:0 0 1px 0" />
161 <select style=
"width:30%" name=
"addzone.<%=plan.name%>">
162 <option value=
"">-- please select --
</option>
163 <% for _, zone in luci.util.kspairs(ast.dialzone.zones()) do %
>
164 <% if not zones_used[zone.name] then %
>
165 <option value=
"<%=zone.name%>"><%=zone.name%
> (<%=zone.description%
>)
</option>
171 Add Voicemailbox:
<br />
172 <select style=
"width:20%" name=
"addvbox.<%=plan.name%>" onchange=
"this.form['addvboxext.<%=plan.name%>'].value=this.options[this.selectedIndex].value.split('@')[0]">
173 <option value=
"">-- please select --
</option>
174 <% for ext, box in luci.util.kspairs(ast.voicemail.boxes()) do %
>
175 <% if not boxes_used[box.id] then %
>
176 <option value=
"<%=box.id%>"><%=box.id%
> (<%=box.name%
>)
</option>
181 <input type=
"text" style=
"width:5%" name=
"addvboxext.<%=plan.name%>" />
184 <input type=
"submit" class=
"cbi-button cbi-button-add" value=
"Add item »" title=
"Add item ..."/>
190 <div class=
"cbi-section-create cbi-tblsection-create"></div>
195 <div class=
"cbi-section-node">
196 <div class=
"cbi-section-create cbi-tblsection-create" style=
"padding: 3px">
197 <h3>Create a new dialplan
</h3>
198 The name is required and must be unique. It may only contain the characters A-Z, a-z,
0-
9 and _ .
<br />
200 <%- if create_error then %
>
201 <br /><span style=
"color:red">Invalid name given!
</span><br />
205 <input type=
"text" class=
"cbi-section-create-name" name=
"addplan" style=
"width:200px" />
206 <input type=
"submit" class=
"cbi-button cbi-button-add" value=
"Add dialplan" title=
"Add dialplan"/>
213 <div class=
"clear"></div>