2008-07-07 22:00:56 +00:00
< %#
2015-01-16 22:38:38 +00:00
Copyright 2008 Steven Barth < steven @ midlink . org >
2015-01-16 22:46:42 +00:00
Copyright 2008-2010 Jo-Philipp Wich < jow @ openwrt . org >
2015-01-16 22:38:38 +00:00
Licensed to the public under the Apache License 2.0.
2008-08-16 15:37:28 +00:00
-%>
2015-01-16 22:38:38 +00:00
2008-08-16 15:37:28 +00:00
< %-
2010-04-18 22:55:59 +00:00
local opkg = require "luci.model.ipkg"
local fs = require "nixio.fs"
local wa = require "luci.tools.webadmin"
2008-08-16 15:37:28 +00:00
local rowcnt = 1
2009-03-28 20:15:53 +00:00
2008-08-16 15:37:28 +00:00
function rowstyle()
rowcnt = rowcnt + 1
return (rowcnt % 2) + 1
end
2009-03-28 20:15:53 +00:00
2010-04-18 22:55:59 +00:00
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
2011-06-17 14:20:08 +00:00
local filter = { }
2011-10-15 03:13:49 +00:00
2012-11-15 20:59:09 +00:00
local opkg_list = luci.model.ipkg.list_all
2011-10-15 03:13:49 +00:00
local querypat
if query and #query > 0 then
2012-11-15 20:59:09 +00:00
querypat = '*%s*' % query
opkg_list = luci.model.ipkg.find
2011-10-15 03:13:49 +00:00
end
local letterpat
if letter == 35 then
2012-11-15 20:59:09 +00:00
letterpat = "[^a-z]*"
2011-10-15 03:13:49 +00:00
else
2012-11-15 20:59:09 +00:00
letterpat = string.char(letter, 42) -- 'A' '*'
2011-10-15 03:13:49 +00:00
end
2008-07-07 22:00:56 +00:00
-%>
2011-10-26 23:43:04 +00:00
2008-04-11 18:24:25 +00:00
< %+header%>
2011-10-26 23:43:04 +00:00
2015-10-06 11:29:43 +00:00
< h2 name = "content" > < %:Software%>< / h2 >
2008-04-11 18:24:25 +00:00
2008-08-16 15:37:28 +00:00
< form method = "post" action = "<%=REQUEST_URI%>" >
< div class = "cbi-map" >
2011-10-24 01:10:34 +00:00
< ul class = "cbi-tabmenu" >
< li class = "cbi-tab" > < a href = "#" > < %:Actions%>< / a > < / li >
< li class = "cbi-tab-disabled" > < a href = "<%=REQUEST_URI%>/ipkg" > < %:Configuration%>< / a > < / li >
< / ul >
2008-08-16 15:37:28 +00:00
< fieldset class = "cbi-section" >
2011-10-24 01:10:34 +00:00
< fieldset class = "cbi-section-node" >
< % if (install and next(install)) or (remove and next(remove)) or update or upgrade then %>
< div class = "cbi-value" >
< % if #stdout > 0 then %>< pre > < %=pcdata(stdout)%>< / pre > < % end %>
< % if #stderr > 0 then %>< pre class = "error" > < %=pcdata(stderr)%>< / pre > < % end %>
< / div >
< % end %>
< % if querypat then %>
< div class = "cbi-value" >
< %:Displaying only packages containing%> < strong > "< %=pcdata(query)%>"< / strong >
< input type = "button" onclick = "location.href='?display=<%=pcdata(display)%>'" href = "#" class = "cbi-button cbi-button-reset" style = "margin-left:1em" value = "<%:Reset%>" / >
< br style = "clear:both" / >
< / div >
< % end %>
< % if no_lists or old_lists then %>
< div class = "cbi-value" >
< % if old_lists then %>
< %:Package lists are older than 24 hours%>
< % else %>
< %:No package lists available%>
< % end %>
< input type = "button" onclick = "location.href='?update=1'" href = "#" class = "cbi-button cbi-button-apply" style = "margin-left:3em" value = "<%:Update lists%>" / >
< / div >
< % end %>
< div class = "cbi-value cbi-value-last" >
< %: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 >
< / div >
< / fieldset >
2008-08-16 15:37:28 +00:00
< br / >
2011-10-24 01:10:34 +00:00
2008-08-16 15:37:28 +00:00
< fieldset class = "cbi-section-node" >
2011-10-24 01:10:34 +00:00
< input type = "hidden" name = "display" value = "<%=pcdata(display)%>" / >
2010-04-18 22:55:59 +00:00
< 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 = "" / >
2011-09-22 13:25:48 +00:00
< input class = "cbi-button cbi-input-save" type = "submit" name = "submit" value = "<%:OK%>" / >
2010-04-18 22:55:59 +00:00
< / div >
2008-08-16 15:37:28 +00:00
< / div >
2008-09-07 20:12:24 +00:00
2011-10-15 03:13:49 +00:00
< div class = "cbi-value cbi-value-last" >
2010-04-18 22:55:59 +00:00
< label class = "cbi-value-title" > < %:Filter%>:< / label >
< div class = "cbi-value-field" >
2010-11-13 13:58:30 +00:00
< input type = "text" name = "query" size = "20" value = "<%=pcdata(query)%>" / >
2011-09-22 13:25:48 +00:00
< input type = "submit" class = "cbi-button cbi-input-find" name = "search" value = "<%:Find package%>" / >
2010-04-18 22:55:59 +00:00
< / div >
2008-08-16 15:37:28 +00:00
< / div >
2010-04-18 22:55:59 +00:00
< / fieldset >
< / fieldset >
< br / >
< h3 > < %:Status%>< / h3 >
2011-10-24 01:10:34 +00:00
2010-04-18 22:55:59 +00:00
2011-10-15 03:13:49 +00:00
< ul class = "cbi-tabmenu" >
< li class = "cbi-tab<% if display ~= " installed " then % > -disabled< % end %>">< a href = "?display=installed&query=<%=pcdata(query)%>" > < %:Installed packages%>< % if query then %> (< %=pcdata(query)%>)< % end %>< / a > < / li >
< li class = "cbi-tab<% if display ~= " available " then % > -disabled< % end %>">< a href = "?display=available&query=<%=pcdata(query)%>" > < %:Available packages%>< % if query then %> (< %=pcdata(query)%>)< % end %>< / a > < / li >
< / ul >
2011-10-24 01:10:34 +00:00
2011-10-15 03:13:49 +00:00
< % if display ~= "available" then %>
< 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 >
2015-09-16 09:47:48 +00:00
< % local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, s, d) empty = false; filter[n] = true %>
2011-10-15 03:13:49 +00:00
< 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 >
< % else %>
< fieldset class = "cbi-section" >
< % if not querypat then %>
< ul class = "cbi-tabmenu" >
< % local i; for i = 65, 90 do %>
< li class = "cbi-tab<% if letter ~= i then %>-disabled<% end %>" > < a href = "?display=available&letter=<%=string.char(i)%>" > < %=string.char(i)%>< / a > < / li >
< % end %>
< li class = "cbi-tab<% if letter ~= 35 then %>-disabled<% end %>" > < a href = "?display=available&letter=%23" > #< / a > < / li >
< / ul >
< div class = "cbi-section-node" >
< % end %>
< 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 >
2015-09-16 09:47:48 +00:00
< th class = "cbi-section-table-cell" style = "text-align:right" > < %:Size (.ipk)%>< / th >
2011-10-15 03:13:49 +00:00
< th class = "cbi-section-table-cell" style = "text-align:left" > < %:Description%>< / th >
< / tr >
2015-09-16 09:47:48 +00:00
< % local empty = true; opkg_list(querypat or letterpat, function(n, v, s, d) if filter[n] then return end; empty = false %>
2011-10-15 03:13:49 +00:00
< 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 >
2015-09-16 09:47:48 +00:00
< td style = "text-align:right" > < %=luci.util.pcdata(s)%>< / td >
2011-10-15 03:13:49 +00:00
< 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 >
2015-09-16 09:47:48 +00:00
< td style = "text-align:right" > < em > < %:none%>< / em > < / td >
2011-10-15 03:13:49 +00:00
< td style = "text-align:left" > < em > < %:none%>< / em > < / td >
< / tr >
< % end %>
< / table >
< % if not querypat then %>
< / div >
< % end %>
< / fieldset >
< % end %>
2008-04-11 18:24:25 +00:00
< / div >
< / form >
2008-09-07 20:12:24 +00:00
< %+footer%>