blob: a1a8d698f74cb0246374fd779971f89cfdcb6eb1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
<%#
LuCI - Lua Configuration Interface
Copyright 2008 Steven Barth <steven@midlink.org>
Copyright 2008-2010 Jo-Philipp Wich <xm@subsignal.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
$Id$
-%>
<%-
local bit = require "bit"
local opkg = require "luci.model.ipkg"
local fs = require "nixio.fs"
local wa = require "luci.tools.webadmin"
local rowcnt = 1
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
end
function opkg_error(code)
code = bit.rshift(tonumber(code), 8)
return translate("OPKG error code %i" % code)
end
local fstat = fs.statvfs(opkg.overlay_root())
local space_total = fstat and fstat.blocks or 0
local space_free = fstat and fstat.bfree or 0
local space_used = space_total - space_free
local used_perc = math.floor(0.5 + ((space_total > 0) and ((100 / space_total) * space_used) or 100))
local free_byte = space_free * fstat.frsize
-%>
<%+header%>
<h2><a id="content" name="content"><%:System%> - <%:Software%></a></h2>
<form method="post" action="<%=REQUEST_URI%>">
<div class="cbi-map">
<fieldset class="cbi-section">
<ul>
<li><a href="<%=REQUEST_URI%>/ipkg"><%:Edit package lists and installation targets%></a></li>
<li><a href="<%=REQUEST_URI%>?update=1"><%:Update package lists%></a></li>
</ul>
<br />
<fieldset class="cbi-section-node">
<div class="cbi-value">
<label class="cbi-value-title"><%:Download and install package%>:</label>
<div class="cbi-value-field">
<input type="text" name="url" size="30" value="" />
<input class="cbi-input-save" type="submit" name="submit" value="<%:OK%>" />
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Filter%>:</label>
<div class="cbi-value-field">
<input type="text" name="query" size="20" value="<%=query%>" />
<input type="submit" class="cbi-input-find" name="search" value="<%:Find package%>" />
</div>
</div>
</fieldset>
</fieldset>
<br />
<h3><%:Status%></h3>
<fieldset class="cbi-section">
<%:Free space%>: <strong><%=(100-used_perc)%>%</strong> (<strong><%=wa.byte_format(free_byte)%></strong>)
<div style="margin:3px 0; width:300px; height:10px; border:1px solid #000000; background-color:#80C080">
<div style="background-color:#F08080; border-right:1px solid #000000; height:100%; width:<%=used_perc%>%"> </div>
</div>
<% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %>
<br /><hr /><br />
<% if update then %>
<%:Package lists updated%>: <% if update == 0 then %><span class="ok"><%:OK%></span><% else %><span class="error"><%:Error%> (<%=opkg_error(update)%>)</span><% end %><br />
<% end %>
<% if upgrade then%>
<%:Upgrade installed packages%>: <% if upgrade == 0 then %><span class="ok"><%:OK%></span><% else %><span class="error"><%:Error%> (<%=opkg_error(upgrade)%>)</span><% end %><br />
<% end %>
<% if install then for k,v in pairs(install) do %>
<%:Install%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:OK%></span><% else %><span class="error"><%:Error%> (<%=opkg_error(v)%>)</span><% end %><br />
<% end end %>
<% if remove then for k,v in pairs(remove) do %>
<%:Remove%> '<%=k%>': <% if v == 0 then %><span class="ok"><%:OK%></span><% else %><span class="error"><%:Error%> (<%=opkg_error(v)%>)</span><% end %><br />
<% end end %>
<% end %>
</fieldset>
<br />
<h3><%:Installed packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %></h3>
<fieldset class="cbi-section">
<table class="cbi-section-table" style="width:100%">
<tr class="cbi-section-table-titles">
<th class="cbi-section-table-cell" style="text-align:left"> </th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th>
</tr>
<% local empty = true; luci.model.ipkg.list_installed(query, function(n, v, d) empty = false %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
<td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Remove%> "<%=luci.util.pcdata(n)%>" ?')" href="<%=REQUEST_URI%>?submit=1&remove=<%=luci.util.pcdata(n)%>"><%:Remove%></a></td>
<td style="text-align:left"><%=luci.util.pcdata(n)%></td>
<td style="text-align:left"><%=luci.util.pcdata(v)%></td>
</tr>
<% end) %>
<% if empty then %>
<tr class="cbi-section-table-row">
<td style="text-align:left"> </td>
<td style="text-align:left"><em><%:none%></em></td>
<td style="text-align:left"><em><%:none%></em></td>
</tr>
<% end %>
</table>
</fieldset>
<br />
<h3><%:Available packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %></h3>
<fieldset class="cbi-section">
<table class="cbi-section-table" style="width:100%">
<tr class="cbi-section-table-titles">
<th class="cbi-section-table-cell" style="text-align:left"> </th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Package name%></th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Version%></th>
<th class="cbi-section-table-cell" style="text-align:left"><%:Description%></th>
</tr>
<% local empty = true; luci.model.ipkg.list_all(query, function(n, v, d) empty = false %>
<tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
<td style="text-align:left; width:10%"><a onclick="return window.confirm('<%:Install%> "<%=luci.util.pcdata(n)%>" ?')" href="<%=REQUEST_URI%>?submit=1&install=<%=luci.util.pcdata(n)%>"><%:Install%></a></td>
<td style="text-align:left"><%=luci.util.pcdata(n)%></td>
<td style="text-align:left"><%=luci.util.pcdata(v)%></td>
<td style="text-align:left"><%=luci.util.pcdata(d)%></td>
</tr>
<% end) %>
<% if empty then %>
<tr class="cbi-section-table-row">
<td style="text-align:left"> </td>
<td style="text-align:left"><em><%:none%></em></td>
<td style="text-align:left"><em><%:none%></em></td>
<td style="text-align:left"><em><%:none%></em></td>
</tr>
<% end %>
</table>
</fieldset>
</div>
</form>
<%+footer%>
|