8cba08a109fd46cf7bbcf682ff8be07ae0c038da
[project/luci.git] / modules / admin-full / luasrc / view / admin_system / packages.htm
1 <%#
2 LuCI - Lua Configuration Interface
3 Copyright 2008 Steven Barth <steven@midlink.org>
4 Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 $Id$
13
14 -%>
15 <%-
16 local bit = require "bit"
17 local rowcnt = 1
18
19 function rowstyle()
20         rowcnt = rowcnt + 1
21         return (rowcnt % 2) + 1
22 end
23
24 function opkg_error(code)
25         code = bit.rshift(tonumber(code), 8)
26         return translate(
27                 'a_s_packages_code%i' % code,
28                 '%s %i' % { translate('code'), code }
29         )
30 end
31 -%>
32 <%+header%>
33 <h2><a id="content" name="content"><%:system%> - <%:a_s_packages%></a></h2>
34
35 <form method="post" action="<%=REQUEST_URI%>">
36         <div class="cbi-map">
37                 <fieldset class="cbi-section">
38                         <ul>
39                                 <li><a href="<%=REQUEST_URI%>/ipkg"><%:a_s_packages_ipkg%></a></li>
40                                 <li><a href="<%=REQUEST_URI%>?update=1"><%:a_s_packages_updatelist%></a></li>
41                         </ul>
42                         <br />
43                         <fieldset class="cbi-section-node">
44                         <div class="cbi-value">
45                                 <label class="cbi-value-title"><%:a_s_packages_installurl%>:</label>
46                                 <div class="cbi-value-field">
47                                         <input type="text" name="url" size="30" value="" />
48                                         <input class="cbi-input-save" type="submit" name="submit" value="<%:ok%>" />
49                                 </div>
50                         </div>
51
52                         <div class="cbi-value">
53                                 <label class="cbi-value-title"><%:filter%>:</label>
54                                 <div class="cbi-value-field">
55                                         <input type="text" name="query" size="20" value="<%=query%>" />
56                                         <input type="submit" class="cbi-input-find" name="search" value="<%:a_s_packages_search%>" />
57                                 </div>
58                         </div>
59                         </fieldset>
60                 </fieldset>
61
62                 <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %>
63                 <h2><%:status%></h2>
64                 <fieldset class="cbi-section">
65                         <% if update then %>
66                                 <%:a_s_packages_update%>: <% if update == 0 then %><span class="ok"><%:ok%></span><% else %><span class="error"><%:error%> (<%=opkg_error(update)%>)</span><% end %><br />
67                         <% end %>
68                         <% if upgrade then%>
69                                 <%:a_s_packages_upgrade%>: <% if upgrade == 0 then %><span class="ok"><%:ok%></span><% else %><span class="error"><%:error%> (<%=opkg_error(upgrade)%>)</span><% end %><br />
70                         <% end %>
71                         <% if install then for k,v in pairs(install) do %>
72                                 <%:a_s_packages_install%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:ok%></span><% else %><span class="error"><%:error%> (<%=opkg_error(v)%>)</span><% end %><br />
73                         <% end end %>
74                         <% if remove then for k,v in pairs(remove) do %>
75                                 <%:a_s_packages_remove%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:ok%></span><% else %><span class="error"><%:error%> (<%=opkg_error(v)%>)</span><% end %><br />
76                         <% end end %>
77                 </fieldset>
78                 <br />
79                 <% end %>
80
81                 <h2><%:a_s_packages_installed Installed packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %></h2>
82
83                 <fieldset class="cbi-section">
84                         <table class="cbi-section-table" style="width:100%">
85                                 <tr class="cbi-section-table-titles">
86                                         <th class="cbi-section-table-cell" style="text-align:left">&nbsp;</th>
87                                         <th class="cbi-section-table-cell" style="text-align:left"><%:a_s_packages_name%></th>
88                                         <th class="cbi-section-table-cell" style="text-align:left"><%:version%></th>
89                                 </tr>
90                                 <% local empty = true; luci.model.ipkg.list_installed(query, function(n, v, d) empty = false %>
91                                 <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
92                                         <td style="text-align:left; width:10%"><a href="<%=REQUEST_URI%>?submit=1&amp;remove=<%=luci.util.pcdata(n)%>"><%:delete%></a></td>
93                                         <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
94                                         <td style="text-align:left"><%=luci.util.pcdata(v)%></td>
95                                 </tr>
96                                 <% end) %>
97                                 <% if empty then %>
98                                 <tr class="cbi-section-table-row">
99                                         <td style="text-align:left">&nbsp;</td>
100                                         <td style="text-align:left"><em><%:none%></em></td>
101                                         <td style="text-align:left"><em><%:none%></em></td>
102                                 </tr>
103                                 <% end %>
104                         </table>
105                 </fieldset>
106
107
108                 <h2><%:a_s_packages_available Available packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %></h2>
109
110                 <fieldset class="cbi-section">
111                         <table class="cbi-section-table" style="width:100%">
112                                 <tr class="cbi-section-table-titles">
113                                         <th class="cbi-section-table-cell" style="text-align:left">&nbsp;</th>
114                                         <th class="cbi-section-table-cell" style="text-align:left"><%:a_s_packages_name%></th>
115                                         <th class="cbi-section-table-cell" style="text-align:left"><%:version%></th>
116                                         <th class="cbi-section-table-cell" style="text-align:left"><%:descr%></th>
117                                 </tr>
118                                 <% local empty = true; luci.model.ipkg.list_all(query, function(n, v, d) empty = false %>
119                                 <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
120                                         <td style="text-align:left; width:10%"><a href="<%=REQUEST_URI%>?submit=1&amp;install=<%=luci.util.pcdata(n)%>"><%:install%></a></td>
121                                         <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
122                                         <td style="text-align:left"><%=luci.util.pcdata(v)%></td>
123                                         <td style="text-align:left"><%=luci.util.pcdata(d)%></td>
124                                 </tr>
125                                 <% end) %>
126                                 <% if empty then %>
127                                 <tr class="cbi-section-table-row">
128                                         <td style="text-align:left">&nbsp;</td>
129                                         <td style="text-align:left"><em><%:none%></em></td>
130                                         <td style="text-align:left"><em><%:none%></em></td>
131                                         <td style="text-align:left"><em><%:none%></em></td>
132                                 </tr>
133                                 <% end %>
134                         </table>
135                 </fieldset>
136         </div>
137 </form>
138 <%+footer%>