modules/admin-full, modules/freifunk, modules/niu, libs/web, applications/luci-upnp...
[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-2010 Jo-Philipp Wich <xm@subsignal.org>
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 opkg = require "luci.model.ipkg"
18 local fs = require "nixio.fs"
19 local wa = require "luci.tools.webadmin"
20 local rowcnt = 1
21
22 function rowstyle()
23         rowcnt = rowcnt + 1
24         return (rowcnt % 2) + 1
25 end
26
27 local fstat = fs.statvfs(opkg.overlay_root())
28 local space_total = fstat and fstat.blocks or 0
29 local space_free  = fstat and fstat.bfree  or 0
30 local space_used  = space_total - space_free
31
32 local used_perc = math.floor(0.5 + ((space_total > 0) and ((100 / space_total) * space_used) or 100))
33 local free_byte = space_free * fstat.frsize
34
35 local filter = { }
36
37 -%>
38 <%+header%>
39 <h2><a id="content" name="content"><%:System%> - <%:Software%></a></h2>
40
41 <form method="post" action="<%=REQUEST_URI%>">
42         <div class="cbi-map">
43                 <fieldset class="cbi-section">
44                         <ul>
45                                 <li><a href="<%=REQUEST_URI%>/ipkg"><%:Edit package lists and installation targets%></a></li>
46                                 <li><a href="<%=REQUEST_URI%>?update=1"><%:Update package lists%></a></li>
47                         </ul>
48                         <br />
49                         <fieldset class="cbi-section-node">
50                                 <div class="cbi-value">
51                                         <label class="cbi-value-title"><%:Download and install package%>:</label>
52                                         <div class="cbi-value-field">
53                                                 <input type="text" name="url" size="30" value="" />
54                                                 <input class="cbi-button cbi-input-save" type="submit" name="submit" value="<%:OK%>" />
55                                         </div>
56                                 </div>
57
58                                 <div class="cbi-value">
59                                         <label class="cbi-value-title"><%:Filter%>:</label>
60                                         <div class="cbi-value-field">
61                                                 <input type="text" name="query" size="20" value="<%=pcdata(query)%>" />
62                                                 <input type="submit" class="cbi-button cbi-input-find" name="search" value="<%:Find package%>" />
63                                         </div>
64                                 </div>
65                         </fieldset>
66                 </fieldset>
67                 <br />
68
69                 <h3><%:Status%></h3>
70                 <fieldset class="cbi-section">
71                         <%:Free space%>: <strong><%=(100-used_perc)%>%</strong> (<strong><%=wa.byte_format(free_byte)%></strong>)
72                         <div style="margin:3px 0; width:300px; height:10px; border:1px solid #000000; background-color:#80C080">
73                                 <div style="background-color:#F08080; border-right:1px solid #000000; height:100%; width:<%=used_perc%>%">&#160;</div>
74                         </div>
75
76                         <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %>
77                                 <br /><hr /><br />
78                                 <% if #stdout > 0 then %><pre><%=pcdata(stdout)%></pre><% end %>
79                                 <% if #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
80                         <% end %>
81                 </fieldset>
82                 <br />
83
84                 <h3><%:Installed packages%><% if query then %> (<%=pcdata(query)%>)<% end %></h3>
85
86                 <fieldset class="cbi-section">
87                         <table class="cbi-section-table" style="width:100%">
88                                 <tr class="cbi-section-table-titles">
89                                         <th class="cbi-section-table-cell" style="text-align:left">&#160;</th>
90                                         <th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th>
91                                         <th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th>
92                                 </tr>
93                                 <% local empty = true; luci.model.ipkg.list_installed(query, function(n, v, d) empty = false; filter[n] = true %>
94                                 <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
95                                         <td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Remove%> &quot;<%=luci.util.pcdata(n)%>&quot; ?')" href="<%=REQUEST_URI%>?submit=1&amp;remove=<%=luci.util.pcdata(n)%>"><%:Remove%></a></td>
96                                         <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
97                                         <td style="text-align:left"><%=luci.util.pcdata(v)%></td>
98                                 </tr>
99                                 <% end) %>
100                                 <% if empty then %>
101                                 <tr class="cbi-section-table-row">
102                                         <td style="text-align:left">&#160;</td>
103                                         <td style="text-align:left"><em><%:none%></em></td>
104                                         <td style="text-align:left"><em><%:none%></em></td>
105                                 </tr>
106                                 <% end %>
107                         </table>
108                 </fieldset>
109                 <br />
110
111
112                 <h3><%:Available packages%><% if query then %> (<%=pcdata(query)%>)<% end %></h3>
113
114                 <fieldset class="cbi-section">
115                         <table class="cbi-section-table" style="width:100%">
116                                 <tr class="cbi-section-table-titles">
117                                         <th class="cbi-section-table-cell" style="text-align:left">&#160;</th>
118                                         <th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th>
119                                         <th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th>
120                                         <th class="cbi-section-table-cell" style="text-align:left"><%:Description%></th>
121                                 </tr>
122                                 <% local empty = true; luci.model.ipkg.list_all(query, function(n, v, d) if filter[n] then return end; empty = false %>
123                                 <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
124                                         <td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Install%> &quot;<%=luci.util.pcdata(n)%>&quot; ?')" href="<%=REQUEST_URI%>?submit=1&amp;install=<%=luci.util.pcdata(n)%>"><%:Install%></a></td>
125                                         <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
126                                         <td style="text-align:left"><%=luci.util.pcdata(v)%></td>
127                                         <td style="text-align:left"><%=luci.util.pcdata(d)%></td>
128                                 </tr>
129                                 <% end) %>
130                                 <% if empty then %>
131                                 <tr class="cbi-section-table-row">
132                                         <td style="text-align:left">&#160;</td>
133                                         <td style="text-align:left"><em><%:none%></em></td>
134                                         <td style="text-align:left"><em><%:none%></em></td>
135                                         <td style="text-align:left"><em><%:none%></em></td>
136                                 </tr>
137                                 <% end %>
138                         </table>
139                 </fieldset>
140         </div>
141 </form>
142 <%+footer%>