Globally reduce copyright headers
[project/luci.git] / applications / luci-app-diag-devinfo / luasrc / view / diag / smapsection.htm
1 <%#
2  Copyright 2009 Daniel Dickinson
3  Licensed to the public under the Apache License 2.0.
4 -%>
5
6 <%-
7 local rowcnt = 1
8 function rowstyle()
9         rowcnt = rowcnt + 1
10         return (rowcnt % 2) + 1
11 end
12 -%>
13
14 <!-- smapsection -->
15 <fieldset class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
16         <% if self.title and #self.title > 0 then -%>
17                 <legend><%=self.title%></legend>
18         <%- end %>
19         <div class="cbi-section-descr"><%=self.description%></div>
20         <div class="cbi-section-node">
21                 <%- local count = 0 -%>
22                 <table class="cbi-section-table">
23                         <tr class="cbi-section-table-titles">
24                         <%- if not self.anonymous then -%>
25                                 <%- if self.sectionhead then -%>
26                                         <th class="cbi-section-table-cell"><%=self.sectionhead%></th>
27                                 <%- else -%>
28                                         <th>&#160;</th>
29                                 <%- end -%>
30                         <%- end -%>
31                         <%- for i, k in pairs(self.children) do if not k.optional then -%>
32                                 <th class="cbi-section-table-cell">
33                                 <%- if k.titleref then -%><a title="<%=self.titledesc or translate('Go to relevant configuration page')%>" class="cbi-title-ref" href="<%=k.titleref%>"><%- end -%>
34                                         <%-=k.title-%>
35                                 <%- if k.titleref then -%></a><%- end -%>
36                                 </th>
37                         <%- count = count + 1; end; end; if self.extedit or self.addremove then -%>
38                                 <th class="cbi-section-table-cell">&#160;</th>
39                         <%- count = count + 1; end -%>
40                         </tr>
41                         <tr class="cbi-section-table-descr">
42                         <%- if not self.anonymous then -%>
43                                 <%- if self.sectiondesc then -%>
44                                         <th class="cbi-section-table-cell"><%=self.sectiondesc%></th>
45                                 <%- else -%>
46                                         <th></th>
47                                 <%- end -%>
48                         <%- end -%>
49                         <%- for i, k in pairs(self.children) do if not k.optional then -%>
50                                 <th class="cbi-section-table-cell"><%=k.description%></th>
51                         <%- end; end; if self.extedit or self.addremove then -%>
52                                 <th class="cbi-section-table-cell"></th>
53                         <%- end -%>
54                         </tr>
55                         <%- local isempty = true
56                             for i, k in ipairs(self:cfgsections()) do
57                                         section = k
58                                         isempty = false
59                                         scope = { valueheader = "cbi/cell_valueheader", valuefooter = "cbi/cell_valuefooter" }
60                         -%>
61                         <tr class="cbi-section-table-row<% if self.extedit or self.rowcolors then %> cbi-rowstyle-<%=rowstyle()%><% end %>" id="cbi-<%=self.config%>-<%=section%>">
62                                 <% if not self.anonymous then -%>
63                                         <th><h3><%=k%></h3></th>
64                                 <%- end %>
65
66                                 <%-     for k, node in ipairs(self.children) do -%>
67                                         <%-    if not node.optional then -%>
68                                                <%- nodevalue = node:cfgvalue(section) -%>
69                                                <%- if nodevalue and ( nodevalue ~= "" ) and string.find(nodevalue, 'http://', 1, plain) then
70                                                        node.href = nodevalue
71                                                        node.template = "diag/smapvalue"
72                                                     end 
73                                                -%>
74                                                <%- node:render(section, scope or {}) -%>
75                                         <%- end -%>
76                                 <%- end -%>
77
78                                 <%- if self.extedit or self.addremove then -%>
79                                         <td class="cbi-section-table-cell">
80                                                 <%- if self.extedit then -%>
81                                                         <a href="
82                                                         <%- if type(self.extedit) == "string" then -%>
83                                                                 <%=self.extedit:format(section)%>
84                                                         <%- elseif type(self.extedit) == "function" then -%>
85                                                                 <%=self:extedit(section)%>
86                                                         <%- end -%>
87                                                         " title="<%:Edit%>"><img style="border: none" src="<%=resource%>/cbi/edit.gif" alt="<%:Edit%>" /></a>
88                                                 <%- end; if self.addremove then %>
89                                                         <input type="image" value="<%:Delete%>" name="cbi.rts.<%=self.config%>.<%=k%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
90                                                 <%- end -%>
91                                         </td>
92                                 <%- end -%>
93                         </tr>
94                         <%- end -%>
95
96                         <%- if isempty then -%>
97                         <tr class="cbi-section-table-row">
98                                 <td colspan="<%=count%>"><em><br /><%:This section contains no values yet%></em></td>
99                         </tr>
100                         <%- end -%>
101                 </table>
102
103                 <% if self.error then %>
104                         <div class="cbi-section-error">
105                                 <ul><% for _, c in pairs(self.error) do for _, e in ipairs(c) do -%>
106                                         <li><%=luci.util.pcdata(e):gsub("\n","<br />")%></li>
107                                 <%- end end %></ul>
108                         </div>
109                 <% end %>
110
111                 <%- if self.addremove then -%>
112                         <% if self.template_addremove then include(self.template_addremove) else -%>
113                         <div class="cbi-section-create cbi-smapsection-create">
114                                 <% if self.anonymous then %>
115                                         <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" title="<%:Add%>" />
116                                 <% else %>
117                                         <% if self.invalid_cts then -%><div class="cbi-section-error"><% end %>
118                                         <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
119                                         <input class="cbi-button cbi-button-add" type="submit" value="<%:Add%>" title="<%:Add%>" />
120                                         <% if self.invalid_cts then -%>
121                                                 <br /><%:Invalid%></div>
122                                         <%- end %>
123                                 <% end %>
124                         </div>
125                         <%- end %>
126                 <%- end -%>
127         </div>
128 </fieldset>
129 <!-- /smapsection -->