From fe1f00bfe86c7e028d7d97ac375783955d002780 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Mon, 8 Mar 2010 00:13:43 +0000 Subject: [PATCH] luci-0.9: various improvements in package management ui --- .../luasrc/view/admin_system/packages.htm | 82 ++++++++++++------- 1 file changed, 51 insertions(+), 31 deletions(-) diff --git a/modules/admin-full/luasrc/view/admin_system/packages.htm b/modules/admin-full/luasrc/view/admin_system/packages.htm index 8cba08a10..6b6d51b7c 100644 --- a/modules/admin-full/luasrc/view/admin_system/packages.htm +++ b/modules/admin-full/luasrc/view/admin_system/packages.htm @@ -1,7 +1,7 @@ <%# LuCI - Lua Configuration Interface Copyright 2008 Steven Barth -Copyright 2008 Jo-Philipp Wich +Copyright 2008-2010 Jo-Philipp Wich Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -14,6 +14,9 @@ $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() @@ -28,6 +31,15 @@ function opkg_error(code) '%s %i' % { translate('code'), 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%>

<%:system%> - <%:a_s_packages%>

@@ -41,44 +53,51 @@ end
-
- -
- - +
+ +
+ + +
-
-
- -
- - +
+ +
+ + +
-
+
- <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %> -

<%:status%>

+

<%:status%>

- <% if update then %> - <%:a_s_packages_update%>: <% if update == 0 then %><%:ok%><% else %><%:error%> (<%=opkg_error(update)%>)<% end %>
- <% end %> - <% if upgrade then%> - <%:a_s_packages_upgrade%>: <% if upgrade == 0 then %><%:ok%><% else %><%:error%> (<%=opkg_error(upgrade)%>)<% end %>
+ <%:a_s_packages_freespace Free space%>: <%=(100-used_perc)%>% (<%=wa.byte_format(free_byte)%>) +
+
 
+
+ + <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %> +


+ <% if update then %> + <%:a_s_packages_update%>: <% if update == 0 then %><%:ok%><% else %><%:error%> (<%=opkg_error(update)%>)<% end %>
+ <% end %> + <% if upgrade then%> + <%:a_s_packages_upgrade%>: <% if upgrade == 0 then %><%:ok%><% else %><%:error%> (<%=opkg_error(upgrade)%>)<% end %>
+ <% end %> + <% if install then for k,v in pairs(install) do %> + <%:a_s_packages_install%> '<%=k%>': <% if v == 0 then %><%:ok%><% else %><%:error%> (<%=opkg_error(v)%>)<% end %>
+ <% end end %> + <% if remove then for k,v in pairs(remove) do %> + <%:a_s_packages_remove%> '<%=k%>': <% if v == 0 then %><%:ok%><% else %><%:error%> (<%=opkg_error(v)%>)<% end %>
+ <% end end %> <% end %> - <% if install then for k,v in pairs(install) do %> - <%:a_s_packages_install%> '<%=k%>': <% if v == 0 then %><%:ok%><% else %><%:error%> (<%=opkg_error(v)%>)<% end %>
- <% end end %> - <% if remove then for k,v in pairs(remove) do %> - <%:a_s_packages_remove%> '<%=k%>': <% if v == 0 then %><%:ok%><% else %><%:error%> (<%=opkg_error(v)%>)<% end %>
- <% end end %>

- <% end %> -

<%:a_s_packages_installed Installed packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %>

+

<%:a_s_packages_installed Installed packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %>

@@ -89,7 +108,7 @@ end <% local empty = true; luci.model.ipkg.list_installed(query, function(n, v, d) empty = false %> - + @@ -103,9 +122,10 @@ end <% end %>
<%:delete%><%:delete%> <%=luci.util.pcdata(n)%> <%=luci.util.pcdata(v)%>
+
-

<%:a_s_packages_available Available packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %>

+

<%:a_s_packages_available Available packages%><% if query then %> (<%=luci.util.pcdata(query)%>)<% end %>

@@ -117,7 +137,7 @@ end <% local empty = true; luci.model.ipkg.list_all(query, function(n, v, d) empty = false %> - + -- 2.25.1
<%:install%><%:install%> <%=luci.util.pcdata(n)%> <%=luci.util.pcdata(v)%> <%=luci.util.pcdata(d)%>