2018-01-23 14:36:03 +00:00
< %#
Copyright 2008 Steven Barth < steven @ midlink . org >
Copyright 2008-2010 Jo-Philipp Wich < jow @ openwrt . org >
Licensed to the public under the Apache License 2.0.
-%>
< %-
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
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
local filter = { }
local opkg_list = luci.model.ipkg.list_all
local querypat
if query and #query > 0 then
querypat = '*%s*' % query
opkg_list = luci.model.ipkg.find
end
local letterpat
if letter == 35 then
letterpat = "[^a-z]*"
else
letterpat = string.char(letter, 42) -- 'A' '*'
end
-%>
< %+header%>
2018-07-03 14:03:20 +00:00
< script type = "text/javascript" src = "<%=resource%>/cbi.js" > < / script >
2018-01-23 14:36:03 +00:00
< h2 name = "content" > < %:Software%>< / h2 >
< div class = "cbi-map" >
< 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 >
< form method = "post" action = "<%=REQUEST_URI%>" >
< input type = "hidden" name = "exec" value = "1" / >
< input type = "hidden" name = "token" value = "<%=token%>" / >
2018-07-03 14:03:20 +00:00
< div class = "cbi-section" >
< div class = "cbi-section-node" >
2018-01-23 14:36:03 +00:00
< % 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 >
2018-05-25 12:36:55 +00:00
< input type = "button" onclick = "location.href='?display=<%=luci.http.urlencode(display)%>'" href = "#" class = "cbi-button cbi-button-reset" style = "margin-left:1em" value = "<%:Reset%>" / >
2018-01-23 14:36:03 +00:00
< 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 = "submit" name = "update" 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 >
2018-07-03 14:03:20 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< br / >
2018-07-03 14:03:20 +00:00
< div class = "cbi-section-node" >
2018-01-23 14:36:03 +00:00
< input type = "hidden" name = "display" value = "<%=pcdata(display)%>" / >
< 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 = "" / >
2018-07-03 14:03:20 +00:00
< input class = "cbi-button cbi-button-save" type = "submit" name = "go" value = "<%:OK%>" / >
2018-01-23 14:36:03 +00:00
< / div >
< / div >
< div class = "cbi-value cbi-value-last" >
< label class = "cbi-value-title" > < %:Filter%>:< / label >
< div class = "cbi-value-field" >
< input type = "text" name = "query" size = "20" value = "<%=pcdata(query)%>" / >
2018-07-03 14:03:20 +00:00
< input type = "submit" class = "cbi-button cbi-button-action" name = "search" value = "<%:Find package%>" / >
2018-01-23 14:36:03 +00:00
< / div >
< / div >
2018-07-03 14:03:20 +00:00
< / div >
< / div >
2018-01-23 14:36:03 +00:00
< / form >
< h3 > < %:Status%>< / h3 >
< ul class = "cbi-tabmenu" >
< 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 >
2018-07-03 14:03:20 +00:00
< 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 >
2018-01-23 14:36:03 +00:00
< / ul >
< % if display ~= "available" then %>
2018-07-03 14:03:20 +00:00
< div class = "cbi-section" >
< div class = "cbi-section-node" >
< div class = "table" >
< div class = "tr cbi-section-table-titles" >
< div class = "th left" > < %:Package name%>< / div >
< div class = "th left" > < %:Version%>< / div >
< div class = "th cbi-section-actions" >   < / div >
2018-05-31 13:44:12 +00:00
< / div >
2018-07-03 14:03:20 +00:00
< % local empty = true; luci.model.ipkg.list_installed(querypat, function(n, v, s, d) empty = false; filter[n] = true %>
< div class = "tr cbi-rowstyle-<%=rowstyle()%>" >
< div class = "td left" > < %=luci.util.pcdata(n)%>< / div >
< div class = "td left" > < %=luci.util.pcdata(v)%>< / div >
< div class = "td cbi-section-actions" >
< form method = "post" class = "inline" action = "<%=REQUEST_URI%>" >
< input type = "hidden" name = "exec" value = "1" / >
< input type = "hidden" name = "token" value = "<%=token%>" / >
< input type = "hidden" name = "remove" value = "<%=pcdata(n)%>" / >
< input class = "cbi-button cbi-button-remove" type = "submit" onclick = "window.confirm('<%:Remove%> "<%=luci.util.pcdata(n)%>" ?') && this.parentNode.submit(); return false" value = "<%:Remove%>" / >
< / form >
< / div >
< / div >
< % end) %>
< % if empty then %>
< div class = "tr cbi-section-table-row" >
< div class = "td left" >   < / div >
< div class = "td left" > < em > < %:none%>< / em > < / div >
< div class = "td left" > < em > < %:none%>< / em > < / div >
< / div >
< % end %>
2018-05-31 13:44:12 +00:00
< / div >
< / div >
2018-07-03 14:03:20 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< % else %>
2018-07-03 14:03:20 +00:00
< div class = "cbi-section" >
2018-01-23 14:36:03 +00:00
< % if not querypat then %>
2018-07-03 14:03:20 +00:00
< ul class = "cbi-tabmenu" style = "flex-wrap:wrap" >
2018-01-23 14:36:03 +00:00
< % 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 >
< % end %>
2018-07-03 14:03:20 +00:00
< div class = "cbi-section-node cbi-section-node-tabbed" >
< div class = "table" >
< div class = "tr cbi-section-table-titles" >
< div class = "th col-2 left" > < %:Package name%>< / div >
< div class = "th col-2 left" > < %:Version%>< / div >
< div class = "th col-1 center" > < %:Size (.ipk)%>< / div >
< div class = "th col-10 left" > < %:Description%>< / div >
< div class = "th cbi-section-actions" >   < / div >
2018-05-31 13:44:12 +00:00
< / div >
2018-07-03 14:03:20 +00:00
< % local empty = true; opkg_list(querypat or letterpat, function(n, v, s, d) if filter[n] then return end; empty = false %>
< div class = "tr cbi-rowstyle-<%=rowstyle()%>" >
< div class = "td col-2 left" > < %=luci.util.pcdata(n)%>< / div >
< div class = "td col-2 left" > < %=luci.util.pcdata(v)%>< / div >
< div class = "td col-1 center" > < %=luci.util.pcdata(s)%>< / div >
< div class = "td col-10 left" > < %=luci.util.pcdata(d)%>< / div >
< div class = "td cbi-section-actions" >
< form method = "post" class = "inline" action = "<%=REQUEST_URI%>" >
< input type = "hidden" name = "exec" value = "1" / >
< input type = "hidden" name = "token" value = "<%=token%>" / >
< input type = "hidden" name = "install" value = "<%=pcdata(n)%>" / >
< input class = "cbi-button cbi-button-apply" type = "submit" onclick = "window.confirm('<%:Install%> "<%=luci.util.pcdata(n)%>" ?') && this.parentNode.submit(); return false" value = "<%:Install%>" / >
< / form >
< / div >
< / div >
< % end) %>
< % if empty then %>
< div class = "tr" >
< div class = "td left" >   < / div >
< div class = "td left" > < em > < %:none%>< / em > < / div >
< div class = "td left" > < em > < %:none%>< / em > < / div >
< div class = "td right" > < em > < %:none%>< / em > < / div >
< div class = "td left" > < em > < %:none%>< / em > < / div >
< / div >
< % end %>
2018-05-31 13:44:12 +00:00
< / div >
< / div >
2018-07-03 14:03:20 +00:00
< / div >
2018-01-23 14:36:03 +00:00
< % end %>
< / div >
< %+footer%>