2 Copyright
2008 Steven Barth
<steven@midlink.org
>
3 Copyright
2008 Jo-Philipp Wich
<xm@leipzig.freifunk.net
>
4 Licensed to the public under the Apache License
2.0.
10 local uci = luci.model.uci.cursor_state()
11 local ast = require
"luci.asterisk"
13 function digit_pattern(s,t)
14 return
"<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'%s>%s</code>"
15 %{ t and
" title='" .. t ..
"'" or
"", s }
19 return
"cbi-rowstyle-%i" %{
20 ( i %
2 ) ==
0 and
2 or
1
24 function format_matches(z)
27 if type(z) ~=
"table" then
28 z = { matches = { z } }
32 for _, m in ipairs(z.matches) do
34 digit_pattern(z.localprefix,
"local prefix") ..
" " ..
39 if z.intlmatches and #z.intlmatches
> 0 then
40 for _, i in ipairs(z.intlmatches) do
41 for _, m in ipairs(z.matches) do
42 html[#html+
1] =
"%s %s" %{
43 digit_pattern(
"(%s)" % i,
"intl. prefix"),
49 for _, m in ipairs(z.matches) do
50 html[#html+
1] = digit_pattern(m)
54 return table.concat(html,
"; ")
59 <form method=
"post" action=
"<%=luci.dispatcher.build_url("admin
", "asterisk
", "dialplans
")%>" 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">Outgoing Call Routing
</a></h2>
68 <div class=
"cbi-map-descr">
69 Here you can manage your dial plans which are used to route outgoing calls from your local extensions.
<br /><br />
71 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/dialplans/zones')%>" class=
"cbi-title-ref">Manage dialzones
</a> |
72 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/voicemail/mailboxes')%>" class=
"cbi-title-ref">Manage voicemail boxes
</a> |
73 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/meetme/rooms')%>" class=
"cbi-title-ref">Manage meetme rooms
</a>
76 <fieldset class=
"cbi-section" id=
"cbi-asterisk-sip">
77 <!--<legend>Dialplans</legend>-->
78 <div class=
"cbi-section-descr"></div>
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 = { }; local row =
0 %
>
96 <% for i, zone in ipairs(plan.zones) do zones_used[zone.name] = true %
>
97 <tr class=
"cbi-section-table-row <%=rowstyle(row)%>">
98 <td style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell">
99 <strong>└ Dialzone
<em><%=zone.name%
></em></strong> (<%=zone.description%
>)
100 <p style=
"padding-left: 1em; margin-bottom:0">
102 <%=ast.tools.hyperlinks(
103 zone.trunks, function(v)
104 return luci.dispatcher.build_url(
"admin",
"asterisk",
"trunks",
"%s") % v:lower()
108 <%=format_matches(zone)%
>
111 <td style=
"width:5%" class=
"cbi-value-field">
112 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/dialplans/out', zone.name)%>">
113 <img style=
"border:none" alt=
"Edit dialzone" title=
"Edit dialzone" src=
"/luci-static/resources/cbi/edit.gif" />
115 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delzone.<%=plan.name%>=<%=zone.name%>">
116 <img style=
"border:none" alt=
"Remove from this dialplan" title=
"Remove from this dialplan" src=
"/luci-static/resources/cbi/remove.gif" />
120 <% row = row +
1; end %
>
124 <% local boxes_used = { } %
>
125 <% for ext, box in luci.util.kspairs(plan.voicemailboxes) do boxes_used[box.id] = true %
>
126 <tr class=
"cbi-section-table-row <%=rowstyle(row)%>">
127 <td style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell">
128 <strong>└ Voicemailbox
<em><%=box.id%
></em></strong> (<%=box.name%
>)
129 <p style=
"padding-left: 1em; margin-bottom:0">
130 Owner: <%=box.name%
> |
131 eMail: <%=#box.email
> 0 and box.email or 'n/a'%
> |
132 Pager: <%=#box.page
> 0 and box.page or 'n/a'%
><br />
133 Matches: <%=format_matches(ext)%
>
136 <td style=
"width:5%" class=
"cbi-value-field">
137 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/voicemail/mailboxes')%>">
138 <img style=
"border:none" alt=
"Manage mailboxes ..." title=
"Manage mailboxes ..." src=
"/luci-static/resources/cbi/edit.gif" />
140 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delvbox.<%=plan.name%>=<%=ext%>">
141 <img style=
"border:none" alt=
"Remove from this dialplan" title=
"Remove from this dialplan" src=
"/luci-static/resources/cbi/remove.gif" />
145 <% row = row +
1; end %
>
149 <% local rooms_used = { } %
>
150 <% for ext, room in luci.util.kspairs(plan.meetmerooms) do rooms_used[room.room] = true %
>
151 <tr class=
"cbi-section-table-row <%=rowstyle(row)%>">
152 <td style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell">
153 <strong>└ MeetMe Room
<em><%=room.room%
></em></strong>
154 <% if room.description and #room.description
> 0 then %
> (<%=room.description%
>)<% end %
>
155 <p style=
"padding-left: 1em; margin-bottom:0">
156 Matches: <%=format_matches(ext)%
>
159 <td style=
"width:5%" class=
"cbi-value-field">
160 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/meetme/rooms')%>">
161 <img style=
"border:none" alt=
"Manage conferences ..." title=
"Manage conferences ..." src=
"/luci-static/resources/cbi/edit.gif" />
163 <a href=
"<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delmeetme.<%=plan.name%>=<%=ext%>">
164 <img style=
"border:none" alt=
"Remove from this dialplan" title=
"Remove from this dialplan" src=
"/luci-static/resources/cbi/remove.gif" />
168 <% row = row +
1; end %
>
171 <tr class=
"cbi-section-table-row">
172 <td style=
"text-align: left; padding: 3px" class=
"cbi-section-table-cell" colspan=
"2">
173 <hr style=
"margin-bottom:0.5em; border-width:0 0 1px 0" />
176 <select style=
"width:30%" name=
"addzone.<%=plan.name%>">
177 <option value=
"">-- please select --
</option>
178 <% for _, zone in luci.util.kspairs(ast.dialzone.zones()) do %
>
179 <% if not zones_used[zone.name] then %
>
180 <option value=
"<%=zone.name%>"><%=zone.name%
> (<%=zone.description%
>)
</option>
186 Add Voicemailbox:
<br />
187 <select style=
"width:20%" name=
"addvbox.<%=plan.name%>" onchange=
"this.form['addvboxext.<%=plan.name%>'].value=this.options[this.selectedIndex].value.split('@')[0]">
188 <option value=
"">-- please select --
</option>
189 <% for ext, box in luci.util.kspairs(ast.voicemail.boxes()) do %
>
190 <% if not boxes_used[box.id] then %
>
191 <option value=
"<%=box.id%>"><%=box.id%
> (<%=box.name%
>)
</option>
196 <input type=
"text" style=
"width:5%" name=
"addvboxext.<%=plan.name%>" />
199 Add MeetMe Conference:
<br />
200 <select style=
"width:20%" name=
"addmeetme.<%=plan.name%>" onchange=
"this.form['addmeetmeext.<%=plan.name%>'].value=this.options[this.selectedIndex].value">
201 <option value=
"">-- please select --
</option>
202 <% for ext, room in luci.util.kspairs(ast.meetme.rooms()) do %
>
203 <%# if not rooms_used[room.room] then %
>
204 <option value=
"<%=room.room%>">
206 <% if room.description and #room.description
> 0 then %
>(<%=room.description%
>)<% end %
>
212 <input type=
"text" style=
"width:5%" name=
"addmeetmeext.<%=plan.name%>" />
215 <input type=
"submit" class=
"cbi-button cbi-button-add" value=
"Add item »" title=
"Add item ..."/>
221 <div class=
"cbi-section-create cbi-tblsection-create"></div>
226 <div class=
"cbi-section-node">
227 <div class=
"cbi-section-create cbi-tblsection-create" style=
"padding: 3px">
228 <h3>Create a new dialplan
</h3>
229 The name is required and must be unique. It may only contain the characters A-Z, a-z,
0-
9 and _ .
<br />
231 <%- if create_error then %
>
232 <br /><span style=
"color:red">Invalid name given!
</span><br />
236 <input type=
"text" class=
"cbi-section-create-name" name=
"addplan" style=
"width:200px" />
237 <input type=
"submit" class=
"cbi-button cbi-button-add" value=
"Add dialplan" title=
"Add dialplan"/>
244 <div class=
"clear"></div>