modules/admin-full: use luci.model.ipkg.find() to support searching packages by descr...
[project/luci.git] / modules / admin-full / luasrc / view / admin_system / packages.htm
index e78f1c2..00b4be4 100644 (file)
@@ -9,8 +9,6 @@ You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
 
        http://www.apache.org/licenses/LICENSE-2.0
 
-$Id$
-
 -%>
 <%-
 local bit = require "bit"
 -%>
 <%-
 local bit = require "bit"
@@ -35,31 +33,77 @@ local free_byte = space_free * fstat.frsize
 local filter = { }
 
 
 local filter = { }
 
 
+local opkg_list = luci.model.ipkg.list_all
 local querypat
 if query and #query > 0 then
 local querypat
 if query and #query > 0 then
-       querypat = "*%s*" % query
+       querypat = '*%s*' % query
+       opkg_list = luci.model.ipkg.find
 end
 
 local letterpat
 if letter == 35 then
 end
 
 local letterpat
 if letter == 35 then
-       letterpat = "[^a-zA-Z]*"
+       letterpat = "[^a-z]*"
 else
 else
-       letterpat = string.char(91, letter, letter + 32, 93, 42) -- '[' 'A' 'a' ']' '*'
+       letterpat = string.char(letter, 42) -- 'A' '*'
 end
 
 -%>
 end
 
 -%>
+
 <%+header%>
 <%+header%>
-<h2><a id="content" name="content"><%:System%> - <%:Software%></a></h2>
+
+<h2><a id="content" name="content"><%:Software%></a></h2>
 
 <form method="post" action="<%=REQUEST_URI%>">
        <div class="cbi-map">
 
 <form method="post" action="<%=REQUEST_URI%>">
        <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>
+
                <fieldset class="cbi-section">
                <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>
+
+
+                       <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%>%">&#160;</div>
+                                       </div>
+                               </div>
+                       </fieldset>
+
                        <br />
                        <br />
+
                        <fieldset class="cbi-section-node">
                        <fieldset class="cbi-section-node">
+                               <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">
                                <div class="cbi-value">
                                        <label class="cbi-value-title"><%:Download and install package%>:</label>
                                        <div class="cbi-value-field">
@@ -71,7 +115,6 @@ end
                                <div class="cbi-value cbi-value-last">
                                        <label class="cbi-value-title"><%:Filter%>:</label>
                                        <div class="cbi-value-field">
                                <div class="cbi-value cbi-value-last">
                                        <label class="cbi-value-title"><%:Filter%>:</label>
                                        <div class="cbi-value-field">
-                                               <input type="hidden" name="display" value="<%=pcdata(display)%>" />
                                                <input type="text" name="query" size="20" value="<%=pcdata(query)%>" />
                                                <input type="submit" class="cbi-button cbi-input-find" name="search" value="<%:Find package%>" />
                                        </div>
                                                <input type="text" name="query" size="20" value="<%=pcdata(query)%>" />
                                                <input type="submit" class="cbi-button cbi-input-find" name="search" value="<%:Find package%>" />
                                        </div>
@@ -81,31 +124,13 @@ end
                <br />
 
                <h3><%:Status%></h3>
                <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%>%">&#160;</div>
-                       </div>
-
-                       <% if querypat then %>
-                               <br /><hr /><br />
-                               <%: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:3em" value="Reset" />
-                       <% end %>
 
 
-                       <% if (install and next(install)) or (remove and next(remove)) or update or upgrade then %>
-                               <br /><hr /><br />
-                               <% if #stdout > 0 then %><pre><%=pcdata(stdout)%></pre><% end %>
-                               <% if #stderr > 0 then %><pre class="error"><%=pcdata(stderr)%></pre><% end %>
-                       <% end %>
-               </fieldset>
-               <br />
 
                <ul class="cbi-tabmenu">
                        <li class="cbi-tab<% if display ~= "installed" then %>-disabled<% end %>"><a href="?display=installed&amp;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&amp;query=<%=pcdata(query)%>"><%:Available packages%><% if query then %> (<%=pcdata(query)%>)<% end %></a></li>
                </ul>
 
                <ul class="cbi-tabmenu">
                        <li class="cbi-tab<% if display ~= "installed" then %>-disabled<% end %>"><a href="?display=installed&amp;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&amp;query=<%=pcdata(query)%>"><%:Available packages%><% if query then %> (<%=pcdata(query)%>)<% end %></a></li>
                </ul>
-               
+
                <% if display ~= "available" then %>
                        <fieldset class="cbi-section">
                                <table class="cbi-section-table" style="width:100%">
                <% if display ~= "available" then %>
                        <fieldset class="cbi-section">
                                <table class="cbi-section-table" style="width:100%">
@@ -148,7 +173,7 @@ end
                                                <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>
                                                <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(querypat or letterpat, function(n, v, d) if filter[n] then return end; empty = false %>
+                                       <% local empty = true; opkg_list(querypat or letterpat, function(n, v, d) if filter[n] then return end; empty = false %>
                                        <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
                                                <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>
                                                <td style="text-align:left"><%=luci.util.pcdata(n)%></td>
                                        <tr class="cbi-section-table-row cbi-rowstyle-<%=rowstyle()%>">
                                                <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>
                                                <td style="text-align:left"><%=luci.util.pcdata(n)%></td>