Author: jfthomps
Date: Mon Jul 31 18:40:08 2017
New Revision: 1803562

URL: http://svn.apache.org/viewvc?rev=1803562&view=rev
Log:
VCL-1064 - Show reservations being captured or in maintenance on Reservations 
page

requests.php:
-modified viewRequests: changed $failed and $timedout flags to $noedit (this 
also fixed a bug where $failed was being used for 2 separate things that were 
in conflict with each other); added $col3 flag to track when a message should 
be displayed across all 3 columns where the buttons are displayed; changed 
checks for reservations being timed out to check for state name instead of id; 
added cases to handle reservations in maintenance and image states; don't 
include empty 3rd cell instead of a button when $col3 is set
-modified getViewRequestHTMLitem: added blocks for maintenanceblock and 
imageblock

utils.php: modified getUserRequests: added currstate and laststate to provide 
state names in addition to ids; modified query to no longer exlude reservations 
in image and maintenance states

vcl.css: added rescapture

Modified:
    vcl/trunk/web/.ht-inc/requests.php
    vcl/trunk/web/.ht-inc/utils.php
    vcl/trunk/web/css/vcl.css

Modified: vcl/trunk/web/.ht-inc/requests.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/requests.php?rev=1803562&r1=1803561&r2=1803562&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/requests.php (original)
+++ vcl/trunk/web/.ht-inc/requests.php Mon Jul 31 18:40:08 2017
@@ -124,9 +124,9 @@ function viewRequests() {
                $nodes = getManagementNodes();
        if($count = count($requests)) {
                $now = time();
-               for($i = 0, $failed = 0, $timedout = 0, $text = '', 
$showcreateimage = 0, $cluster = 0;
+               for($i = 0, $noedit = 0, $text = '', $showcreateimage = 0, 
$cluster = 0, $col3 = 0;
                   $i < $count;
-                  $i++, $failed = 0, $timedout = 0, $text = '', $cluster = 0) {
+                  $i++, $noedit = 0, $text = '', $cluster = 0, $col3 = 0) {
                        if($requests[$i]['forcheckout'] == 0 &&
                           $requests[$i]['forimaging'] == 0)
                                continue;
@@ -167,18 +167,19 @@ function viewRequests() {
                                }
                                else
                                        $text .= "    <TD></TD>\n";
+                               $noedit = 1;
                                $failed = 1;
                        }
                        elseif(datetimeToUnix($requests[$i]["start"]) < $now) {
                                # other cases where the reservation start time 
has been reached
-                               if(($requests[$i]["currstateid"] == 12 &&
-                                  $requests[$i]['laststateid'] == 11) ||
-                                       $requests[$i]["currstateid"] == 11 ||
-                                       ($requests[$i]["currstateid"] == 14 &&
-                                       $requests[$i]["laststateid"] == 11)) {
+                               if(($requests[$i]["currstate"] == 'complete' &&
+                                  $requests[$i]['laststate'] == 'timeout') ||
+                                       $requests[$i]["currstate"] == 'timeout' 
||
+                                       ($requests[$i]["currstate"] == 
'pending' &&
+                                       $requests[$i]["laststate"] == 
'timeout')) {
                                        # request has timed out
                                        $text .= 
getViewRequestHTMLitem('timeoutblock');
-                                       $timedout = 1;
+                                       $noedit = 1;
                                        if($requests[$i]['serveradmin']) {
                                                $cont = 
addContinuationsEntry('AJconfirmRemoveRequest', $cdata, SECINDAY);
                                                $text .= 
getViewRequestHTMLitem('removebtn', $cont);
@@ -186,6 +187,25 @@ function viewRequests() {
                                        else
                                                $text .= "    <TD></TD>\n";
                                }
+                               elseif($requests[$i]['currstate'] == 
'maintenance' ||
+                                      ($requests[$i]['currstate'] == 'pending' 
&&
+                                                $requests[$i]['laststate'] == 
'maintenance')) {
+                                       # request is in maintenance
+                                       $text .= 
getViewRequestHTMLitem('maintenanceblock');
+                                       $noedit = 1;
+                                       $col3 = 1;
+                               }
+                               elseif($requests[$i]['currstate'] == 'image' ||
+                                      $requests[$i]['currstate'] == 
'checkpoint' ||
+                                      ($requests[$i]['currstate'] == 'pending' 
&&
+                                                ($requests[$i]['laststate'] == 
'image' ||
+                                                $requests[$i]['laststate'] == 
'checkpoint'))) {
+                                       # request is in image
+                                       $text .= 
getViewRequestHTMLitem('imageblock');
+                                       $noedit = 1;
+                                       $col3 = 1;
+                                       $refresh = 1;
+                               }
                                else {
                                        # computer is loading, print Pending... 
and Delete button
                                        # TODO figure out a different way to 
estimate for reboot and reinstall states
@@ -248,7 +268,7 @@ function viewRequests() {
                                else
                                        $text .= "    <TD></TD>\n";
                        }
-                       if(! $failed && ! $timedout) {
+                       if(! $noedit) {
                                # print edit button
                                $editcont = 
addContinuationsEntry('AJeditRequest', $cdata, SECINDAY);
                                $imgcont = 
addContinuationsEntry('AJstartImage', $cdata, SECINDAY);
@@ -308,7 +328,7 @@ function viewRequests() {
                                        $text .= "</TD>\n";
                                }
                        }
-                       else
+                       elseif($col3 == 0)
                                $text .= "    <TD></TD>\n";
 
                        # print name of server request
@@ -1044,6 +1064,18 @@ function getViewRequestHTMLitem($item, $
                $r .= "    </TD>\n";
                return $r;
        }
+       if($item == 'maintenanceblock') {
+               $r .= "    <TD colspan=\"3\">\n";
+               $r .= "      <span class=compstatelink>" . i("Reservation is in 
maintenance - Contact admin for help") . "</span>\n";
+               $r .= "    </TD>\n";
+               return $r;
+       }
+       if($item == 'imageblock') {
+               $r .= "    <TD colspan=\"3\">\n";
+               $r .= "      <span class=rescapture>" . i("Reservation is being 
captured") . "</span>\n";
+               $r .= "    </TD>\n";
+               return $r;
+       }
        if($item == 'pendingblock') {
                $r .= "    <TD>\n";
                $r .= "      <span class=scriptonly>\n";

Modified: vcl/trunk/web/.ht-inc/utils.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1803562&r1=1803561&r2=1803562&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Mon Jul 31 18:40:08 2017
@@ -794,7 +794,7 @@ function maintenanceCheck() {
                                if(! is_dir($item))
                                        continue;
                                $tmp = explode('/', $item);
-                               $item = $tmp[1];
+                               $item = array_pop($tmp);
                                $allskins[$item] = 1;
                        }
                        if(! array_key_exists($skin, $allskins))
@@ -6716,7 +6716,9 @@ function updateExistingToState($compid,
 /// \b end - end time of request\n
 /// \b daterequested - date request was made\n
 /// \b currstateid - current stateid of request\n
+/// \b currstate - current state of request\n
 /// \b laststateid - last stateid of request\n
+/// \b laststate - last state of request\n
 /// \b forimaging - 0 if an normal request, 1 if imaging request\n
 /// \b forcheckout - 1 if image is available for reservations, 0 if not\n
 /// \b test - test flag - 0 or 1\n
@@ -6785,7 +6787,9 @@ function getUserRequests($type, $id=0) {
               .        "o.type AS ostype, "
               .        "o.installtype AS OSinstalltype, "
               .        "rq.stateid AS currstateid, "
+              .        "s.name AS currstate, "
               .        "rq.laststateid, "
+              .        "ls.name AS laststate, "
               .        "rs.computerid, "
               .        "rs.id AS resid, "
               .        "c.currentimageid AS compimageid, "
@@ -6813,6 +6817,8 @@ function getUserRequests($type, $id=0) {
               . "FROM image i, "
               .      "OS o, "
               .      "computer c, "
+              .      "state s, "
+              .      "state ls, "
               .      "request rq "
               . "LEFT JOIN serverrequest sp ON (sp.requestid = rq.id) "
               . "LEFT JOIN usergroup uga ON (uga.id = sp.admingroupid) "
@@ -6826,8 +6832,12 @@ function getUserRequests($type, $id=0) {
               .       "rq.end > NOW() AND "
               .       "i.OSid = o.id AND "
               .       "c.id = rs.computerid AND "
-              .       "rq.stateid NOT IN (1, 10, 16, 17) AND "      # deleted, 
maintenance, complete, image, makeproduction
-              .       "rq.laststateid NOT IN (1, 10, 16, 17) ";  # deleted, 
maintenance, complete, image, makeproduction
+              #.       "rq.stateid NOT IN (1, 10, 16, 17) AND "      # 
deleted, maintenance, complete, image, makeproduction
+              #.       "rq.laststateid NOT IN (1, 10, 16, 17) ";  # deleted, 
maintenance, complete, image, makeproduction
+              .       "rq.stateid = s.id AND "
+              .       "s.name NOT IN ('deleted', 'makeproduction') AND "
+              .       "rq.laststateid = ls.id AND "
+              .       "ls.name NOT IN ('deleted', 'makeproduction') ";
        if($type == "normal")
                $query .=   "AND rq.forimaging = 0 "
                       .    "AND i.forcheckout = 1 "

Modified: vcl/trunk/web/css/vcl.css
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/css/vcl.css?rev=1803562&r1=1803561&r2=1803562&view=diff
==============================================================================
--- vcl/trunk/web/css/vcl.css (original)
+++ vcl/trunk/web/css/vcl.css Mon Jul 31 18:40:08 2017
@@ -42,6 +42,12 @@ body {
        text-decoration: none;
 }
 
+.rescapture {
+       border: 1px solid black;
+       background-color: #eee;
+       padding: 5px;
+}
+
 #expauthul li {
        list-style-type: disc;
 }


Reply via email to