modules/admin-full: improve opkg error reporting
[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                 translate(
29                         'a_s_packages_code%i' % code,
30                         '%s %i' % { translate('code'), code }
31                 )
32         )
33 end
34 -%>
35 <%+header%>
36 <h2><a id="content" name="content"><%:system%></a></h2>
37 <h3><%:a_s_packages%></h3>
38
39 <br />
40
41 <% if install or remove or update or upgrade then %>
42 <div class="code"><strong><%:status%>:</strong><br />
43 <% if update then %>
44         <%:a_s_packages_update%>: <% if update == 0 then %><span class="ok"><%:ok%></span><% else %><span class="error"><%:error%> (<%=opkg_error(update)%>)</span><% end %><br />
45 <% end %>
46 <% if upgrade then%>
47         <%:a_s_packages_upgrade%>: <% if upgrade == 0 then %><span class="ok"><%:ok%></span><% else %><span class="error"><%:error%> (<%=opkg_error(upgrade)%>)</span><% end %><br />
48 <% end %>
49 <% if install then for k,v in pairs(install) do %>
50         <%: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 />
51 <% end end %>
52 <% if remove then for k,v in pairs(remove) do %>
53         <%: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 />
54 <% end end %>
55 </div>
56 <br />
57 <% end %>
58
59 <form method="post" action="<%=REQUEST_URI%>">
60         <div class="cbi-map">
61                 <fieldset class="cbi-section">
62                         <ul>
63                                 <li><a href="<%=REQUEST_URI%>/ipkg"><%:a_s_packages_ipkg%></a></li>
64                                 <li><a href="<%=REQUEST_URI%>?update=1"><%:a_s_packages_updatelist%></a></li>
65                         </ul>
66                         <br />
67                         <fieldset class="cbi-section-node">
68                         <div class="cbi-value">
69                                 <label class="cbi-value-title"><%:a_s_packages_installurl%>:</label>
70                                 <div class="cbi-value-field">
71                                         <input type="text" name="url" size="30" value="" />
72                                         <input class="cbi-input-save" type="submit" name="submit" value="<%:ok%>" />
73                                 </div>
74                         </div>
75
76                         <div class="cbi-value">
77                                 <label class="cbi-value-title"><%:filter%>:</label>
78                                 <div class="cbi-value-field">
79                                         <input type="text" name="query" size="20" value="<%=query%>" />
80                                         <input type="submit" class="cbi-input-find" name="search" value="<%:a_s_packages_search%>" />
81                                 </div>
82                         </div>
83
84                         <table class="cbi-section-table">
85                                 <tr class="cbi-section-table-titles">
86                                         <th class="cbi-section-table-cell"><%:a_s_packages_name%></th>
87                                         <th class="cbi-section-table-cell"><%:version%></th>
88                                         <th class="cbi-section-table-cell"><%:install%></th>
89                                         <th class="cbi-section-table-cell"><%:delete%></th>
90                                         <th class="cbi-section-table-cell"><%:descr%></th>
91                                 </tr>
92                                 <% for k, pkg in pairs(pkgs) do %>
93                                 <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
94                                         <td><%=luci.util.pcdata(pkg.Package)%></td>
95                                         <td><%=luci.util.pcdata(pkg.Version)%></td>
96                                         <td><% if not pkg.Status or not pkg.Status.installed then %><input type="checkbox" name="install.<%=pkg.Package%>" value="1" /><% else %><%:installed%><% end %></td>
97                                         <td><% if pkg.Status and pkg.Status.installed then %><input type="checkbox" name="remove.<%=pkg.Package%>" value="1" /><% else %><%:notinstalled%><% end %></td>
98                                         <td><%=luci.util.pcdata(pkg.Description)%></td>
99                                 </tr>
100                                 <% end %>
101                         </table>
102
103                         <br />
104
105                         <div style="text-align: right">
106                                 <input type="submit" class="cbi-input-apply" name="submit" value="<%:a_s_packages_do%>" />
107                         </div>
108                 </fieldset></fieldset>
109         </div>
110 </form>
111 <%+footer%>