dialzones.htm 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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)
  11. return "<code style='padding: 2px; border:1px solid #CCCCCC; background-color: #FFFFFF'>%s</code>" % s
  12. end
  13. function rowstyle(i)
  14. return "cbi-rowstyle-%i" %{
  15. ( i % 2 ) == 0 and 2 or 1
  16. }
  17. end
  18. local function find_trunks()
  19. local t = { }
  20. uci:foreach("asterisk", "sip",
  21. function(s)
  22. if uci:get_bool("asterisk", s['.name'], "provider") then
  23. t[#t+1] = {
  24. "SIP/%s" % s['.name'],
  25. "SIP: %s" % s['.name']
  26. }
  27. end
  28. end)
  29. uci:foreach("asterisk", "iax",
  30. function(s)
  31. t[#t+1] = {
  32. "IAX/%s" % s['.name'],
  33. "IAX: %s" % s.extension or s['.name']
  34. }
  35. end)
  36. return t
  37. end
  38. %>
  39. <form method="post" action="<%=url('admin/asterisk/dialplans/zones')%>" enctype="multipart/form-data">
  40. <div>
  41. <script type="text/javascript" src="/luci-static/resources/cbi.js"></script>
  42. <input type="hidden" name="cbi.submit" value="1" />
  43. <input type="submit" value="Save" class="hidden" />
  44. </div>
  45. <div class="cbi-map" id="cbi-asterisk">
  46. <h2 name="content">Dial Zone Management</h2>
  47. <div class="cbi-map-descr">
  48. <a href="<%=url("admin/asterisk/dialplans")%>" class="cbi-title-ref">Back to dialplan overview</a><br /><br />
  49. Here you can manage your dial zones. The zones are used to route outgoing calls to the destination.
  50. Each zone groups multiple trunks and number matches to represent a logical destination. Zones can
  51. also be used to enforce certain dial restrictions on selected extensions.
  52. </div>
  53. <!-- tblsection -->
  54. <fieldset class="cbi-section" id="cbi-asterisk-sip">
  55. <div class="cbi-section-node">
  56. <table class="cbi-section-table">
  57. <tr class="cbi-section-table-titles">
  58. <th style="text-align: left; padding: 3px" class="cbi-section-table-cell" colspan="6">
  59. <h3>Dialzone Overview</h3>
  60. </th>
  61. </tr>
  62. <tr class="cbi-section-table-descr">
  63. <th style="width: 5%; text-align:right" class="cbi-section-table-cell">Name</th>
  64. <th style="width: 5%; text-align:right" class="cbi-section-table-cell">Prepend</th>
  65. <th style="width: 20%; text-align:left" class="cbi-section-table-cell">- Match</th>
  66. <th style="text-align:left" class="cbi-section-table-cell">Trunk</th>
  67. <th style="width: 35%; text-align:left" class="cbi-section-table-cell">Description</th>
  68. <th style="width: 4%; text-align:left" class="cbi-section-table-cell"></th>
  69. </tr>
  70. <% for i, rule in pairs(ast.dialzone.zones()) do %>
  71. <tr class="cbi-section-table-row <%=rowstyle(i)%>">
  72. <td style="text-align:right" class="cbi-value-field">
  73. <%=rule.name%>
  74. </td>
  75. <td style="text-align:right" class="cbi-value-field">
  76. <% for _ in ipairs(rule.matches) do %>
  77. <%=rule.addprefix and digit_pattern(rule.addprefix)%>&#160;<br />
  78. <% end %>
  79. </td>
  80. <td style="text-align:left" class="cbi-value-field">
  81. <% for _, m in ipairs(rule.matches) do %>
  82. <%=rule.localprefix and "%s " % digit_pattern(rule.localprefix)%>
  83. <%=digit_pattern(m)%><br />
  84. <% end %>
  85. </td>
  86. <td style="text-align:left" class="cbi-value-field">
  87. <%=ast.tools.hyperlinks(
  88. rule.trunks, function(v)
  89. return luci.dispatcher.build_url("admin", "asterisk", "trunks", "%s") % v:lower()
  90. end
  91. )%>
  92. </td>
  93. <td style="text-align:left" class="cbi-value-field">
  94. <%=rule.description or rule.name%>
  95. </td>
  96. <td style="text-align:left" class="cbi-value-field">
  97. <a href="<%=url('admin/asterisk/dialplans/out', rule.name)%>">
  98. <img style="border:none" alt="Edit entry" title="Edit entry" src="/luci-static/resources/cbi/edit.gif" />
  99. </a>
  100. <a href="<%=url('admin/asterisk/dialplans/zones')%>?delzone=<%=rule.name%>">
  101. <img style="border:none" alt="Delete entry" title="Delete entry" src="/luci-static/resources/cbi/remove.gif" />
  102. </a>
  103. </td>
  104. </tr>
  105. <% end %>
  106. </table>
  107. <div class="cbi-section-create cbi-tblsection-create"></div>
  108. </div>
  109. <br />
  110. <div class="cbi-section-node">
  111. <div class="cbi-section-create cbi-tblsection-create" style="padding: 3px">
  112. <h3>Create a new dialzone</h3>
  113. The name is required and must be unique. It may only contain the characters A-Z, a-z, 0-9 and _ .<br />
  114. You can specifiy multiple number matches by separating them with spaces.<br />
  115. <%- if create_error then %>
  116. <br /><span style="color:red">Invalid name given!</span><br />
  117. <% end -%>
  118. <table>
  119. <tr>
  120. <td style="padding:3px">
  121. <label for="create1">1) Name</label><br />
  122. <input type="text" class="cbi-section-create-name" id="create1" name="newzone_name" style="width:200px" />
  123. <br /><br />
  124. <label for="create2">2) Number Match</label><br />
  125. <input type="text" class="cbi-section-create-name" id="create2" name="newzone_match" style="width:200px" />
  126. </td>
  127. <td style="padding:3px">
  128. <label for="create3">3) Trunks</label><br />
  129. <select class="cbi-input-select" multiple="multiple" id="create3" name="newzone_uses" size="4" style="width:200px">
  130. <% for i, t in ipairs(find_trunks()) do %>
  131. <option value="<%=t[1]%>"><%=t[2]%></option>
  132. <% end %>
  133. </select>
  134. </td>
  135. </tr>
  136. </table>
  137. <br />
  138. <input type="submit" class="cbi-button cbi-button-add" name="newzone" value="Add entry" title="Add entry"/>
  139. </div>
  140. </div>
  141. </fieldset>
  142. </div>
  143. </form>
  144. <div class="clear"></div>
  145. <%+footer%>