From cebe6f031bc475e8e21102c4b5e378e1fa7bcf54 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 24 Feb 2009 01:09:51 +0000 Subject: applications/luci-asterisk: - initial dialplan management - disabled uci scheme - improved context handling in sip and trunk settings --- .../luasrc/view/asterisk/dialplans.htm | 171 +++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 applications/luci-asterisk/luasrc/view/asterisk/dialplans.htm (limited to 'applications/luci-asterisk/luasrc/view/asterisk') diff --git a/applications/luci-asterisk/luasrc/view/asterisk/dialplans.htm b/applications/luci-asterisk/luasrc/view/asterisk/dialplans.htm new file mode 100644 index 0000000000..7432cebf37 --- /dev/null +++ b/applications/luci-asterisk/luasrc/view/asterisk/dialplans.htm @@ -0,0 +1,171 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2008 Steven Barth +Copyright 2008 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ + +-%> + +<%+header%> + +<% + local uci = luci.model.uci.cursor_state() + + function find_rules(plan) + local r = { } + if plan and plan.include then + local i = luci.util.split(plan.include, "%s+", nil, true) + for _, i in ipairs(i) do + i = uci:get("asterisk", "dialzone", i) + if i then + r[#r+1] = i + end + end + end + return r + end + + dp_lookup_table = { } + + function dialplan_lookup(s) + if not dp_lookup_table[s['.name']] then + s.childs = { } + s.matches = type(s.match) == "table" and s.match or { s.match } + s.name, s.type = s['.name'], s['.type'] + s['.name'], s['.type'] = nil, nil + dp_lookup_table[s.name] = s + end + end + + uci:foreach("asterisk", "dialplan", dialplan_lookup) + uci:foreach("asterisk", "dialzone", dialplan_lookup) + + for k, p in pairs(dp_lookup_table) do + if p.include then + local i = type(p.include) == "string" + and luci.util.split(p.include, "%s+", nil, true) or p.include + + for _, i in ipairs(i) do + i = dp_lookup_table[i] + if i then + p.childs[#p.childs+1] = i + i.parent = p + end + end + end + end + + function digit_pattern(s) + return "%s" % s + end + + function rowstyle(i) + return "cbi-rowstyle-%i" %{ + ( i % 2 ) == 0 and 2 or 1 + } + end + + function link_trunks(s) + local l = { } + for s in s:gmatch("(%S+)") do + if s:match("^[sS][iI][pP]/") then + l[#l+1] = '%s' %{ + luci.dispatcher.build_url("admin", "asterisk", "trunks", + "sip", (s:gsub("^.+/",""))), + (s:gsub("^.+/","SIP: ")) + } + end + end + return '%s' % table.concat(l, ", ") + end +%> + + +
" enctype="multipart/form-data"> +
+ + + +
+ +
+

Outgoing Call Routing

+
+
+ +
+ + + + + + <% for name, plan in luci.util.kspairs(dp_lookup_table) do + if plan.type == "dialplan" then %> +
+ + + + + + + + + + + + + + <% for i, rule in pairs(plan.childs) do + if rule.type == "dialzone" then %> + + + + + + + + <% end end %> +
+  Dialplan <%=name%> +
Prepend- MatchTrunkDescription
+ <% for _ in ipairs(rule.matches) do %> + <%=rule.addprefix and digit_pattern(rule.addprefix)%> 
+ <% end %> +
+ <% for _, m in ipairs(rule.matches) do %> + <%=rule.localprefix and "%s " % digit_pattern(rule.localprefix)%> + <%=digit_pattern(m)%>
+ <% end %> +
+ <%=rule.uses and link_trunks(rule.uses)%> + + <%=rule.description or rule.name%> + + + Edit entry + + + Delete entry + +
+ +
+ + +
+
+
+ <% end end %> + +
+
+
+
+<%+footer%> -- cgit v1.2.3