dialplans.htm 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <%#
  2. Copyright 2008 Steven Barth <steven@midlink.org>
  3. Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
  4. Licensed to the public under the Apache License 2.0.
  5. -%>
  6. <%+header%>
  7. <%
  8. local uci = luci.model.uci.cursor_state()
  9. local ast = require "luci.asterisk"
  10. function digit_pattern(s,t)
  11. return "<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'%s>%s</code>"
  12. %{ t and " title='" .. t .. "'" or "", s }
  13. end
  14. function rowstyle(i)
  15. return "cbi-rowstyle-%i" %{
  16. ( i % 2 ) == 0 and 2 or 1
  17. }
  18. end
  19. function format_matches(z)
  20. local html = { }
  21. if type(z) ~= "table" then
  22. z = { matches = { z } }
  23. end
  24. if z.localprefix then
  25. for _, m in ipairs(z.matches) do
  26. html[#html+1] =
  27. digit_pattern(z.localprefix, "local prefix") .. " " ..
  28. digit_pattern(m)
  29. end
  30. end
  31. if z.intlmatches and #z.intlmatches > 0 then
  32. for _, i in ipairs(z.intlmatches) do
  33. for _, m in ipairs(z.matches) do
  34. html[#html+1] = "%s %s" %{
  35. digit_pattern("(%s)" % i, "intl. prefix"),
  36. digit_pattern(m)
  37. }
  38. end
  39. end
  40. else
  41. for _, m in ipairs(z.matches) do
  42. html[#html+1] = digit_pattern(m)
  43. end
  44. end
  45. return table.concat(html, "; ")
  46. end
  47. %>
  48. <form method="post" action="<%=luci.dispatcher.build_url("admin", "asterisk", "dialplans")%>" enctype="multipart/form-data">
  49. <div>
  50. <script type="text/javascript" src="/luci-static/resources/cbi.js"></script>
  51. <input type="hidden" name="cbi.submit" value="1" />
  52. <input type="submit" value="Save" class="hidden" />
  53. </div>
  54. <div class="cbi-map" id="cbi-asterisk">
  55. <h2><a id="content" name="content">Outgoing Call Routing</a></h2>
  56. <div class="cbi-map-descr">
  57. Here you can manage your dial plans which are used to route outgoing calls from your local extensions.<br /><br />
  58. Related tasks:<br />
  59. <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans/zones')%>" class="cbi-title-ref">Manage dialzones</a> |
  60. <a href="<%=luci.dispatcher.build_url('admin/asterisk/voicemail/mailboxes')%>" class="cbi-title-ref">Manage voicemail boxes</a> |
  61. <a href="<%=luci.dispatcher.build_url('admin/asterisk/meetme/rooms')%>" class="cbi-title-ref">Manage meetme rooms</a>
  62. </div>
  63. <!-- tblsection -->
  64. <fieldset class="cbi-section" id="cbi-asterisk-sip">
  65. <!--<legend>Dialplans</legend>-->
  66. <div class="cbi-section-descr"></div>
  67. <% for i, plan in pairs(ast.dialplan.plans()) do %>
  68. <div class="cbi-section-node">
  69. <table class="cbi-section-table">
  70. <tr class="cbi-section-table-titles">
  71. <th style="text-align: left; padding: 3px" class="cbi-section-table-cell">
  72. <big>Dialplan <em><%=plan.name%></em></big>
  73. </th>
  74. <td>
  75. <a href="<%=luci.dispatcher.build_url('admin', 'asterisk', 'dialplans')%>?delplan=<%=plan.name%>">
  76. <img style="border:none" alt="Remove this dialplan" title="Remove this dialplan" src="/luci-static/resources/cbi/remove.gif" />
  77. </a>
  78. </td>
  79. </tr>
  80. <!-- dialzones -->
  81. <% local zones_used = { }; local row = 0 %>
  82. <% for i, zone in ipairs(plan.zones) do zones_used[zone.name] = true %>
  83. <tr class="cbi-section-table-row <%=rowstyle(row)%>">
  84. <td style="text-align: left; padding: 3px" class="cbi-section-table-cell">
  85. <strong>&#x2514; Dialzone <em><%=zone.name%></em></strong> (<%=zone.description%>)
  86. <p style="padding-left: 1em; margin-bottom:0">
  87. Lines:
  88. <%=ast.tools.hyperlinks(
  89. zone.trunks, function(v)
  90. return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
  91. end
  92. )%><br />
  93. Matches:
  94. <%=format_matches(zone)%>
  95. </p>
  96. </td>
  97. <td style="width:5%" class="cbi-value-field">
  98. <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans/out', zone.name)%>">
  99. <img style="border:none" alt="Edit dialzone" title="Edit dialzone" src="/luci-static/resources/cbi/edit.gif" />
  100. </a>
  101. <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delzone.<%=plan.name%>=<%=zone.name%>">
  102. <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
  103. </a>
  104. </td>
  105. </tr>
  106. <% row = row + 1; end %>
  107. <!-- /dialzones -->
  108. <!-- voicemail -->
  109. <% local boxes_used = { } %>
  110. <% for ext, box in luci.util.kspairs(plan.voicemailboxes) do boxes_used[box.id] = true %>
  111. <tr class="cbi-section-table-row <%=rowstyle(row)%>">
  112. <td style="text-align: left; padding: 3px" class="cbi-section-table-cell">
  113. <strong>&#x2514; Voicemailbox <em><%=box.id%></em></strong> (<%=box.name%>)
  114. <p style="padding-left: 1em; margin-bottom:0">
  115. Owner: <%=box.name%> |
  116. eMail: <%=#box.email > 0 and box.email or 'n/a'%> |
  117. Pager: <%=#box.page > 0 and box.page or 'n/a'%><br />
  118. Matches: <%=format_matches(ext)%>
  119. </p>
  120. </td>
  121. <td style="width:5%" class="cbi-value-field">
  122. <a href="<%=luci.dispatcher.build_url('admin/asterisk/voicemail/mailboxes')%>">
  123. <img style="border:none" alt="Manage mailboxes ..." title="Manage mailboxes ..." src="/luci-static/resources/cbi/edit.gif" />
  124. </a>
  125. <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delvbox.<%=plan.name%>=<%=ext%>">
  126. <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
  127. </a>
  128. </td>
  129. </tr>
  130. <% row = row + 1; end %>
  131. <!-- /voicemail -->
  132. <!-- meetme -->
  133. <% local rooms_used = { } %>
  134. <% for ext, room in luci.util.kspairs(plan.meetmerooms) do rooms_used[room.room] = true %>
  135. <tr class="cbi-section-table-row <%=rowstyle(row)%>">
  136. <td style="text-align: left; padding: 3px" class="cbi-section-table-cell">
  137. <strong>&#x2514; MeetMe Room <em><%=room.room%></em></strong>
  138. <% if room.description and #room.description > 0 then %> (<%=room.description%>)<% end %>
  139. <p style="padding-left: 1em; margin-bottom:0">
  140. Matches: <%=format_matches(ext)%>
  141. </p>
  142. </td>
  143. <td style="width:5%" class="cbi-value-field">
  144. <a href="<%=luci.dispatcher.build_url('admin/asterisk/meetme/rooms')%>">
  145. <img style="border:none" alt="Manage conferences ..." title="Manage conferences ..." src="/luci-static/resources/cbi/edit.gif" />
  146. </a>
  147. <a href="<%=luci.dispatcher.build_url('admin/asterisk/dialplans')%>?delmeetme.<%=plan.name%>=<%=ext%>">
  148. <img style="border:none" alt="Remove from this dialplan" title="Remove from this dialplan" src="/luci-static/resources/cbi/remove.gif" />
  149. </a>
  150. </td>
  151. </tr>
  152. <% row = row + 1; end %>
  153. <!-- /meetme -->
  154. <tr class="cbi-section-table-row">
  155. <td style="text-align: left; padding: 3px" class="cbi-section-table-cell" colspan="2">
  156. <hr style="margin-bottom:0.5em; border-width:0 0 1px 0" />
  157. Add Dialzone:<br />
  158. <select style="width:30%" name="addzone.<%=plan.name%>">
  159. <option value="">-- please select --</option>
  160. <% for _, zone in luci.util.kspairs(ast.dialzone.zones()) do %>
  161. <% if not zones_used[zone.name] then %>
  162. <option value="<%=zone.name%>"><%=zone.name%> (<%=zone.description%>)</option>
  163. <% end %>
  164. <% end %>
  165. </select>
  166. <br /><br />
  167. Add Voicemailbox:<br />
  168. <select style="width:20%" name="addvbox.<%=plan.name%>" onchange="this.form['addvboxext.<%=plan.name%>'].value=this.options[this.selectedIndex].value.split('@')[0]">
  169. <option value="">-- please select --</option>
  170. <% for ext, box in luci.util.kspairs(ast.voicemail.boxes()) do %>
  171. <% if not boxes_used[box.id] then %>
  172. <option value="<%=box.id%>"><%=box.id%> (<%=box.name%>)</option>
  173. <% end %>
  174. <% end %>
  175. </select>
  176. as extension
  177. <input type="text" style="width:5%" name="addvboxext.<%=plan.name%>" />
  178. <br /><br />
  179. Add MeetMe Conference:<br />
  180. <select style="width:20%" name="addmeetme.<%=plan.name%>" onchange="this.form['addmeetmeext.<%=plan.name%>'].value=this.options[this.selectedIndex].value">
  181. <option value="">-- please select --</option>
  182. <% for ext, room in luci.util.kspairs(ast.meetme.rooms()) do %>
  183. <%# if not rooms_used[room.room] then %>
  184. <option value="<%=room.room%>">
  185. <%=room.room%>
  186. <% if room.description and #room.description > 0 then %>(<%=room.description%>)<% end %>
  187. </option>
  188. <%# end %>
  189. <% end %>
  190. </select>
  191. as extension
  192. <input type="text" style="width:5%" name="addmeetmeext.<%=plan.name%>" />
  193. <br /><br />
  194. <input type="submit" class="cbi-button cbi-button-add" value="Add item &raquo;" title="Add item ..."/>
  195. </td>
  196. </tr>
  197. </table>
  198. <div class="cbi-section-create cbi-tblsection-create"></div>
  199. </div>
  200. <br />
  201. <% end %>
  202. <div class="cbi-section-node">
  203. <div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
  204. <h3>Create a new dialplan</h3>
  205. The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
  206. <%- if create_error then %>
  207. <br /><span style="color:red">Invalid name given!</span><br />
  208. <% end -%>
  209. <br />
  210. <input type="text" class="cbi-section-create-name" name="addplan" style="width:200px" />
  211. <input type="submit" class="cbi-button cbi-button-add" value="Add dialplan" title="Add dialplan"/>
  212. </div>
  213. </div>
  214. </fieldset>
  215. </div>
  216. </form>
  217. <div class="clear"></div>
  218. <%+footer%>