Make mire default for APT requests
authoradamch <adamch>
Mon, 15 Oct 2007 23:59:54 +0000 (23:59 +0000)
committeradamch <adamch>
Mon, 15 Oct 2007 23:59:54 +0000 (23:59 +0000)
apt.mlt

diff --git a/apt.mlt b/apt.mlt
index d51c509..6ef3346 100644 (file)
--- a/apt.mlt
+++ b/apt.mlt
@@ -2,15 +2,18 @@
 
 val admin = Group.inGroupName "server";
 
+val nodeNum = case $"node" of
+                 "" => 2
+               | node => Web.stoi node;
+
 if $"new" <> "" then
-       val node = Web.stoi ($"node");
        val pkgs = String.tokens Char.isSpace ($"new");
 
        ref ok = true;
        ref infos = [];
 
        foreach pkg in pkgs do
-               switch AptQuery.query {node = node, pkg = pkg} of
+               switch AptQuery.query {node = nodeNum, pkg = pkg} of
                  NONE =>
                        ok := false;
                        %><b>Error</b>: Unknown package "<% Web.html pkg %>."<br><%
@@ -25,7 +28,7 @@ if $"new" <> "" then
        end;
 
        if ok then
-               val debian = Init.nodeDebian node %>
+               val debian = Init.nodeDebian nodeNum %>
 Are you sure these are the packages you wanted?<br><br>
 <table>
 <%             foreach info in infos do %>
@@ -35,18 +38,17 @@ Are you sure these are the packages you wanted?<br><br>
        </table><br>
        <br>
        <b>Reason:</b> <blockquote><% Web.htmlNl ($"msg") %></blockquote><br>
-       <a href="apt?node=<% node %>&req=<% foreach info in infos do %><% #name info %>+<% end %>&msg=<% Web.urlEncode ($"msg") %>">Yes, I want to request these packages.</a>
+       <a href="apt?node=<% nodeNum %>&req=<% foreach info in infos do %><% #name info %>+<% end %>&msg=<% Web.urlEncode ($"msg") %>">Yes, I want to request these packages.</a>
 
 <%     end
 
 elseif $"req" <> "" then
-       val node = Web.stoi ($"node");
        val pkgs = String.tokens Char.isSpace ($"req");
 
        ref ok = true;
 
        foreach pkg in pkgs do
-               switch AptQuery.query {node = node, pkg = pkg} of
+               switch AptQuery.query {node = nodeNum, pkg = pkg} of
                  NONE =>
                        ok := false;
                        %><b>Error</b>: Unknown package "<% Web.html pkg %>."<br><%
@@ -59,7 +61,7 @@ elseif $"req" <> "" then
        end;
 
        if ok then
-               val id = Apt.add {usr = Init.getUserId(), node = node, data = $"req", msg = $"msg"};
+               val id = Apt.add {usr = Init.getUserId(), node = nodeNum, data = $"req", msg = $"msg"};
                if not (Apt.notifyNew id) then
                        %><h3>Error sending e-mail notification</h3><%
                end
@@ -219,7 +221,7 @@ List the package names you'd like, separated by any whitespace characters.
 <table class="blanks">
 <tr> <td>Machine:</td> <td><select name="node">
 <% foreach node in Init.listNodes () do %>
-       <option value="<% #id node %>"><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
+       <option value="<% #id node %>"<% if #id node = nodeNum then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
 <% end %>
 </select></td></tr>
 <tr> <td>Packages:</td> <td><textarea name="new" rows="10" cols="40" wrap="soft"></textarea></td> </tr>