get export to CSV working, modify nodelist to use a plekit table
smbaker [Fri, 16 Nov 2012 20:35:31 +0000 (12:35 -0800)]
apps/gacksadmin/action.php
apps/gacksadmin/gacks_functions.php
apps/gacksadmin/user_nodelist.php

index e0fdad3..9d6b05a 100644 (file)
@@ -325,6 +325,21 @@ try {
             break;
         }
 
+        case 'download-nodelist':
+            $account_name = get_query_arg('account_name');
+            $slices=$api->GetSlices($account_name);
+            if ($slices) {
+                $slice = $slices[0];
+                $slice_nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),array("hostname"));
+                header("Content-type: text/ascii");
+                header('Content-Disposition: attachment; filename="nodelist.csv"');
+                foreach ($slice_nodes as $node) {
+                    print $node["hostname"];
+                }
+                exit();
+            }
+            break;
+
         case 'set-advanced': {
             $value = get_query_arg("value");
             $url = get_query_arg("url");
index bde8975..8a553c7 100644 (file)
@@ -30,6 +30,8 @@ function l_gacks_weekly ($y=NULL, $m=NULL, $d=NULL)         { return "/db/gacks/
 function l_gacks_node_status ()    { return "/db/gacks/nodestatus.php"; }
 function l_gacks_wizard ()         { return "/db/gacks/wizard.php"; }
 function l_gacks_nodelist ()         { return "/db/gacks/user_nodelist.php"; }
+function l_gacks_nodelist_download ($acctname) { return "/db/gacks/action.php?action=download-nodelist&account_name=$acctname&format=CSV"; }
+function l_gacks_image ()         { return "/db/gacks/user_image.php"; }
 function l_gacks_user_reservations() { return "/db/gacks/user_reservations.php"; }
 function l_gacks_edit($item)       { return "/db/gacks/edit.php"; }
 function l_gacks_delete($item)     { $timeStart=$item['timeStart']; $timeStop=$item['timeStop']; $id=$item['id']; $lastAllocator=end($item['allocatorHRNs']); return "/db/gacks/action.php?action=delete-reservation&timeStart=$timeStart&timeStop=$timeStop&resource_id=$id&lastAllocator=$lastAllocator"; }
@@ -421,6 +423,14 @@ function find_selector($needle, $selectors)
     return NULL;
 }
 
+function select_selector($needle, $selectors)
+{
+    $selector = find_selector($needle, $selectors);
+    if ($selector) {
+        $selector["selected"] = True;
+    }
+}
+
 function get_gacks_session()
 {
     if (!array_key_exists("gacks", $_SESSION)) {
index 2c402fa..da494a6 100644 (file)
@@ -62,13 +62,22 @@ if ($account_name != NULL) {
 
         $slice = $slices[0];
         $slice_nodes=$api->GetNodes(array('node_id'=>$slice['node_ids']),array("hostname"));
-        print "<br>Nodes:<br>";
-        print "<textarea name=nodelist cols=40 readonly>";
+
+        print "<br><center>";
+        print href(l_gacks_nodelist_download($account_name), "Export as CSV");
+        print "</center>";
+
+        $headers=array();
+        $headers["id"] = "string";
+
+        $table = new PlekitTable("accounts", $headers, 0);
+        $table->start();
         foreach ($slice_nodes as $node) {
-            print $node["hostname"];
-            print "\n";
+            $table->row_start();
+            $table->cell($node["hostname"]);
+            $table->row_end();
         }
-        print "</textarea>";
+        $table->end();
     }
 }