local def = fwm:get_defaults()
local zone = fwm:get_zone(value)
local empty = true
+
+ local function render_zone(zone)
+-%>
+ <label class="zonebadge" style="background-color:<%=zone:get_color()%>">
+ <strong><%=zone:name()%></strong>
+ <div class="cbi-tooltip">
+ <%-
+ local zempty = true
+ for _, net in ipairs(zone:get_networks()) do
+ net = nwm:get_network(net)
+ if net then
+ zempty = false
+ -%>
+ <span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>: 
+ <%
+ local nempty = true
+ for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
+ nempty = false
+ %>
+ <img<%=attr("title", iface:get_i18n())%> src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
+ <% end %>
+ <% if nempty then %><em><%:(empty)%></em><% end %>
+ </span>
+ <%- end end -%>
+ <% if zempty then %><span class="ifacebadge"><em><%:(empty)%></em></span><% end %>
+ </div>
+ </label>
+<%-
+ end
-%>
<% if zone then %>
-<div style="white-space:nowrap">
- <label class="zonebadge" style="background-color:<%=zone:get_color()%>">
- <strong><%=zone:name()%>:</strong>
- <%-
- local zempty = true
- for _, net in ipairs(zone:get_networks()) do
- net = nwm:get_network(net)
- if net then
- zempty = false
- -%>
- <span class="ifacebadge<% if net:name() == self.network then %> ifacebadge-active<% end %>"><%=net:name()%>:
- <%
- local nempty = true
- for _, iface in ipairs(net:is_bridge() and net:get_interfaces() or { net:get_interface() }) do
- nempty = false
- %>
- <img<%=attr("title", iface:get_i18n())%> style="width:16px; height:16px; vertical-align:middle" src="<%=resource%>/icons/<%=iface:type()%><%=iface:is_up() and "" or "_disabled"%>.png" />
- <% end %>
- <% if nempty then %><em><%:(empty)%></em><% end %>
- </span>
- <%- end end -%>
- <%- if zempty then %><em><%:(empty)%></em><% end -%>
- </label>
-  ⇒ 
- <% for _, fwd in ipairs(zone:get_forwardings_by("src")) do
- fz = fwd:dest_zone()
- if fz then
- empty = false %>
- <label class="zonebadge" style="background-color:<%=fz:get_color()%>">
- <strong><%=fz:name()%></strong>
- </label> 
- <% end end %>
- <% if empty then %>
+<div class="zone-forwards">
+ <div class="zone-src">
+ <%=render_zone(zone)%>
+ </div>
+ <span>⇒</span>
+ <div class="zone-dest">
+ <%
+ for _, fwd in ipairs(zone:get_forwardings_by("src")) do
+ fz = fwd:dest_zone()
+ if fz then
+ empty = false
+ render_zone(fz)
+ end
+ end
+ if empty then
+ %>
<label class="zonebadge zonebadge-empty">
<strong><%=zone:forward():upper()%></strong>
</label>
<% end %>
+ </div>
</div>
<% end %>
end
return ''
end
+
-%>
<!-- tblsection -->
-<fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
+<div class="cbi-section cbi-tblsection" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
<input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
<%- end -%>
<div class="cbi-section-descr"><%=self.description%></div>
- <div class="cbi-section-node">
- <%- local count = 0 -%>
- <div class="table cbi-section-table">
- <div class="tr cbi-section-table-titles">
- <%- if not self.anonymous then -%>
- <%- if self.sectionhead then -%>
- <div class="th cbi-section-table-cell"><%=self.sectionhead%></div>
- <%- else -%>
- <div class="th"> </div>
- <%- end -%>
- <%- count = count +1; end -%>
- <%- for i, k in pairs(self.children) do if not k.optional then -%>
- <div class="th cbi-section-table-cell"<%=width(k)%>>
- <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
- <%-=k.title-%>
- <%- if k.titleref then -%></a><%- end -%>
- </div>
- <%- count = count + 1; end; end; if self.sortable then -%>
- <div class="th cbi-section-table-cell"><%:Sort%></div>
- <%- count = count + 1; end; if self.extedit or self.addremove then -%>
- <div class="th cbi-section-table-cell"> </div>
- <%- count = count + 1; end -%>
- </div>
- <div class="tr cbi-section-table-descr">
- <%- if not self.anonymous then -%>
- <%- if self.sectiondesc then -%>
- <div class="th cbi-section-table-cell"><%=self.sectiondesc%></div>
- <%- else -%>
- <div class="th"></div>
- <%- end -%>
- <%- end -%>
- <%- for i, k in pairs(self.children) do if not k.optional then -%>
- <div class="th cbi-section-table-cell"<%=width(k)%>><%=k.description%></div>
- <%- end; end; if self.sortable then -%>
- <div class="th cbi-section-table-cell"></div>
- <%- end; if self.extedit or self.addremove then -%>
- <div class="th cbi-section-table-cell"></div>
- <%- end -%>
+ <%- local count = 0 -%>
+ <div class="table cbi-section-table">
+ <div class="tr cbi-section-table-titles <%=(not self.anonymous or self.sectiontitle) and "named" or "anonymous"%>">
+ <%- for i, k in pairs(self.children) do if not k.optional then -%>
+ <div class="th cbi-section-table-cell"<%=
+ width(k) ..
+ attr("data-type", k.template and k.template:gsub("^.+/", "") or "")
+ %>>
+ <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
+ <%-=k.title-%>
+ <%- if k.titleref then -%></a><%- end -%>
</div>
- <%- local isempty = true
- for i, k in ipairs(self:cfgsections()) do
- section = k
- isempty = false
- scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
- -%>
- <div class="tr cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
- <% if not self.anonymous then -%>
- <div class="th"><h3><%=(type(self.sectiontitle) == "function") and self:sectiontitle(section) or k%></h3></div>
- <%- end %>
-
-
- <%-
- for k, node in ipairs(self.children) do
- if not node.optional then
- node:render(section, scope or {})
- end
+ <%- count = count + 1; end; end; if self.sortable or self.extedit or self.addremove then -%>
+ <div class="th cbi-section-table-cell cbi-section-actions"></div>
+ <%- count = count + 1; end -%>
+ </div>
+ <div class="tr cbi-section-table-descr">
+ <%- for i, k in pairs(self.children) do if not k.optional then -%>
+ <div class="th cbi-section-table-cell"<%=
+ width(k) ..
+ attr("data-type", k.template and k.template:gsub("^.+/", "") or "")
+ %>><%=k.description%></div>
+ <%- end; end; if self.sortable or self.extedit or self.addremove then -%>
+ <div class="th cbi-section-table-cell cbi-section-actions"></div>
+ <%- end -%>
+ </div>
+ <%- local isempty = true
+ for i, k in ipairs(self:cfgsections()) do
+ section = k
+ isempty = false
+ title = striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k)
+ scope = {
+ valueheader = "cbi/cell_valueheader",
+ valuefooter = "cbi/cell_valuefooter"
+ }
+ -%>
+ <div class="tr cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>"<%=ifattr(title and (not self.anonymous or self.sectiontitle), "data-title", striptags((type(self.sectiontitle) == "function") and self:sectiontitle(section) or k))%>>
+ <%-
+ for k, node in ipairs(self.children) do
+ if not node.optional then
+ node:render(section, scope or {})
end
- -%>
-
- <%- if self.sortable then -%>
- <div class="td cbi-section-table-cell">
- <input class="cbi-button cbi-button-up" type="button" value="" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move up%>" title="<%:Move up%>" />
- <input class="cbi-button cbi-button-down" type="button" value="" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" alt="<%:Move down%>" title="<%:Move down%>" />
- </div>
- <%- end -%>
-
- <%- if self.extedit or self.addremove then -%>
- <div class="td cbi-section-table-cell">
- <%- if self.extedit then -%>
- <input class="cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
- <%- if type(self.extedit) == "string" then
- %> onclick="location.href='<%=self.extedit:format(section)%>'"
- <%- elseif type(self.extedit) == "function" then
- %> onclick="location.href='<%=self:extedit(section)%>'"
- <%- end
- %> alt="<%:Edit%>" title="<%:Edit%>" />
- <%- end; if self.addremove then %>
- <input class="cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
- <%- end -%>
- </div>
- <%- end -%>
- </div>
- <%- end -%>
+ end
+ -%>
- <%- if isempty then -%>
- <div class="tr cbi-section-table-row">
- <div class="td" colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></div>
- </div>
+ <%- if self.sortable or self.extedit or self.addremove then -%>
+ <div class="td cbi-section-table-cell nowrap cbi-section-actions">
+ <%- if self.sortable then -%>
+ <input class="cbi-button cbi-button-up" type="button" value="<%:Up%>" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move up%>" />
+ <input class="cbi-button cbi-button-down" type="button" value="<%:Down%>" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move down%>" />
+ <% end; if self.extedit then -%>
+ <input class="cbi-button cbi-button-edit" type="button" value="<%:Edit%>"
+ <%- if type(self.extedit) == "string" then
+ %> onclick="location.href='<%=self.extedit:format(section)%>'"
+ <%- elseif type(self.extedit) == "function" then
+ %> onclick="location.href='<%=self:extedit(section)%>'"
+ <%- end
+ %> alt="<%:Edit%>" title="<%:Edit%>" />
+ <% end; if self.addremove then %>
+ <input class="cbi-button cbi-button-remove" type="submit" value="<%:Delete%>" onclick="this.form.cbi_state='del-section'; return true" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" />
+ <%- end -%>
+ </div>
<%- end -%>
</div>
+ <%- end -%>
- <% if self.error then %>
- <div class="cbi-section-error">
- <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
- <li><%=pcdata(e):gsub("\n","<br />")%></li>
- <%- end end %></ul>
- </div>
- <% end %>
-
- <%- if self.addremove then -%>
- <% if self.template_addremove then include(self.template_addremove) else -%>
- <div class="cbi-section-create cbi-tblsection-create">
- <% if self.anonymous then %>
- <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
- <% else %>
- <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
- <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" data-type="uciname" data-optional="true" />
- <input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
- <% if self.invalid_cts then -%>
- <br /><%:Invalid%></div>
- <%- end %>
- <% end %>
- </div>
- <%- end %>
+ <%- if isempty then -%>
+ <div class="tr cbi-section-table-row placeholder">
+ <div class="td"><em><%:This section contains no values yet%></em></div>
+ </div>
<%- end -%>
</div>
-</fieldset>
+
+ <% if self.error then %>
+ <div class="cbi-section-error">
+ <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
+ <li><%=pcdata(e):gsub("\n","<br />")%></li>
+ <%- end end %></ul>
+ </div>
+ <% end %>
+
+ <%- if self.addremove then -%>
+ <% if self.template_addremove then include(self.template_addremove) else -%>
+ <div class="cbi-section-create cbi-tblsection-create">
+ <% if self.anonymous then %>
+ <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>.<%=section%>" title="<%:Add%>" />
+ <% else %>
+ <% if self.invalid_cts then -%>
+ <div class="cbi-section-error"><%:Invalid%></div>
+ <%- end %>
+ <div>
+ <input type="text" class="cbi-section-create-name" id="cbi.cts.<%=self.config%>.<%=self.sectiontype%>." name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>." data-type="uciname" data-optional="true" />
+ </div>
+ <input class="cbi-button cbi-button-add" type="submit" onclick="this.form.cbi_state='add-section'; return true" value="<%:Add%>" title="<%:Add%>" />
+ <% end %>
+ </div>
+ <%- end %>
+ <%- end -%>
+</div>
<!-- /tblsection -->