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