Author: jfthomps Date: Wed Mar 21 18:13:57 2012 New Revision: 1303484 URL: http://svn.apache.org/viewvc?rev=1303484&view=rev Log: VCL-527 Allow users to reinstall newer revisions
requests.php: -modified viewRequests - added state to detailed status for server requests; changed shared reboot/reinstall dialog to be just for reboots; added reinstall dialog -modified getViewRequestHTMLitem - added state to detailed status for server requests -modified AJsubmitEditRequest - added call to addChangeLogEntryOther when changing admin or login group -modified AJrebootRequest - added code to check for request being expired; added call to addChangeLogEntryOther -added AJshowReinstallRequest -modified AJreinstallRequest - added code to check for request being expired; added code to handle revisionid being passed as something to change states.php: added AJshowReinstallRequest utils.php: added addChangeLogEntryOther code.js: added recenterDijitDialog requests.js: -modified showSuggestedTimesCB - changed inline recentering of dijit dialogs to call recenterDijitDialog; added 'edit' argument to resGone -modified editReservationCB - added 'edit' argument to resGone -modified resGone - added argument that allows different text to be displayed so function can be called for other reasons than a normal edit; changed inline recentering of dijit dialogs to call recenterDijitDialog -changed functions shared between reboot and reinstall to be only for reboot and added new ones for reinstalls Modified: incubator/vcl/trunk/web/.ht-inc/requests.php incubator/vcl/trunk/web/.ht-inc/states.php incubator/vcl/trunk/web/.ht-inc/utils.php incubator/vcl/trunk/web/js/code.js incubator/vcl/trunk/web/js/requests.js Modified: incubator/vcl/trunk/web/.ht-inc/requests.php URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/requests.php?rev=1303484&r1=1303483&r2=1303484&view=diff ============================================================================== --- incubator/vcl/trunk/web/.ht-inc/requests.php (original) +++ incubator/vcl/trunk/web/.ht-inc/requests.php Wed Mar 21 18:13:57 2012 @@ -841,7 +841,6 @@ function viewRequests() { if(checkUserHasPerm('View Debug Information')) $nodes = getManagementNodes(); if($count = count($requests)) { - # TODO display admin and login groups somewhere $now = time(); for($i = 0, $failed = 0, $timedout = 0, $text = '', $showcreateimage = 0, $cluster = 0; $i < $count; @@ -993,7 +992,7 @@ function viewRequests() { $requests[$i]['laststateid'] != 27) { $cont = addContinuationsEntry('AJrebootRequest', $cdata, SECINDAY); $text .= getViewRequestHTMLitem('rebootoption', $cont); - $cont = addContinuationsEntry('AJreinstallRequest', $cdata, SECINDAY); + $cont = addContinuationsEntry('AJshowReinstallRequest', $cdata, SECINDAY); $text .= getViewRequestHTMLitem('reinstalloption', $cont); } else { @@ -1049,6 +1048,10 @@ function viewRequests() { 'logingroup' => $requests[$i]['serverlogingroup'], 'image' => $requests[$i]['prettyimage'], 'starttime' => $requests[$i]['start']); + if($requests[$i]['currstateid'] == 14) + $data['stateid'] = $requests[$i]['laststateid']; + else + $data['stateid'] = $requests[$i]['currstateid']; $text .= getViewRequestHTMLitem('serverdetails', $requests[$i]['id'], $data); } @@ -1191,7 +1194,6 @@ function viewRequests() { $text .= "this may have caused.\n"; } - # TODO problem with auto refresh not happening when server load not ready due to user account? $cont = addContinuationsEntry('AJviewRequests', array(), SECINDAY); $text .= "<INPUT type=hidden id=resRefreshCont value=\"$cont\">\n"; @@ -1226,22 +1228,19 @@ function viewRequests() { $text .= " title=\"Delete Reservation\"\n"; $text .= " duration=250\n"; $text .= " draggable=true>\n"; - #$text .= " <script type=\"dojo/connect\" event=onCancel>\n"; - #$text .= " endResDlgHide();\n"; - #$text .= " </script>\n"; $text .= " <div id=\"endResDlgContent\"></div>\n"; $text .= " <input type=\"hidden\" id=\"endrescont\">\n"; $text .= " <input type=\"hidden\" id=\"endresid\">\n"; $text .= " <div align=\"center\">\n"; $text .= " <button id=\"endResDlgBtn\" dojoType=\"dijit.form.Button\">\n"; $text .= " Delete Reservation\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; $text .= " submitDeleteReservation();\n"; $text .= " </script>\n"; $text .= " </button>\n"; $text .= " <button dojoType=\"dijit.form.Button\">\n"; $text .= " Cancel\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; $text .= " dijit.byId('endResDlg').hide();\n"; $text .= " dojo.byId('endResDlgContent').innerHTML = '';\n"; $text .= " </script>\n"; @@ -1259,13 +1258,13 @@ function viewRequests() { $text .= " <div align=\"center\">\n"; $text .= " <button id=\"remResDlgBtn\" dojoType=\"dijit.form.Button\">\n"; $text .= " Remove Reservation\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; $text .= " submitRemoveReservation();\n"; $text .= " </script>\n"; $text .= " </button>\n"; $text .= " <button dojoType=\"dijit.form.Button\">\n"; $text .= " Cancel\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; $text .= " dijit.byId('remResDlg').hide();\n"; $text .= " dojo.byId('remResDlgContent').innerHTML = '';\n"; $text .= " </script>\n"; @@ -1278,7 +1277,7 @@ function viewRequests() { $text .= " title=\"Modify Reservation\"\n"; $text .= " duration=250\n"; $text .= " draggable=true>\n"; - $text .= " <script type=\"dojo/connect\" event=onHide>\n"; + $text .= " <script type=\"dojo/connect\" event=onHide>\n"; $text .= " hideEditResDlg();\n"; $text .= " </script>\n"; $text .= " <div id=\"editResDlgContent\"></div>\n"; @@ -1288,13 +1287,13 @@ function viewRequests() { $text .= " <div align=\"center\">\n"; $text .= " <button id=\"editResDlgBtn\" dojoType=\"dijit.form.Button\">\n"; $text .= " Modify Reservation\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; $text .= " submitEditReservation();\n"; $text .= " </script>\n"; $text .= " </button>\n"; $text .= " <button dojoType=\"dijit.form.Button\" id=\"editResCancelBtn\">\n"; $text .= " Cancel\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; $text .= " dijit.byId('editResDlg').hide();\n"; $text .= " </script>\n"; $text .= " </button>\n"; @@ -1302,34 +1301,69 @@ function viewRequests() { $text .= "</div>\n"; $text .= "<div dojoType=dijit.Dialog\n"; - $text .= " id=\"rebootreinstalldlg\"\n"; + $text .= " id=\"rebootdlg\"\n"; $text .= " title=\"Reboot Reservation\"\n"; $text .= " duration=250\n"; $text .= " draggable=true>\n"; - $text .= " <script type=\"dojo/connect\" event=onHide>\n"; - $text .= " hideRebReinstResDlg();\n"; + $text .= " <script type=\"dojo/connect\" event=onHide>\n"; + $text .= " hideRebootResDlg();\n"; $text .= " </script>\n"; - $text .= " <div id=\"rebreinstResDlgContent\"></div>\n"; + $text .= " <div id=\"rebootResDlgContent\">You can select either a "; + $text .= "soft or a hard reboot. A soft reboot<br>issues a reboot "; + $text .= "command to the operating system. A hard reboot<br>is akin to "; + $text .= "toggling the power switch on a computer. After<br>issuing the "; + $text .= "reboot, it may take several minutes before the<br>machine is "; + $text .= "available again. It is also possible that it will<br>not come "; + $text .= "back up at all. Are you sure you want to continue?<br><br></div>\n"; $text .= " <div id=\"rebootRadios\" style=\"margin-left: 90px;\">\n"; $text .= " <input type=\"radio\" name=\"reboottype\" id=\"softreboot\" checked>\n"; $text .= " <label for=\"softreboot\">Soft Reboot</label><br>\n"; $text .= " <input type=\"radio\" name=\"reboottype\" id=\"hardreboot\">\n"; $text .= " <label for=\"hardreboot\">Hard Reboot</label><br><br>\n"; $text .= " </div>\n"; - $text .= " <input type=\"hidden\" id=\"rebreinstrescont\">\n"; - #$text .= " <input type=\"hidden\" id=\"rebreinstresid\">\n"; - $text .= " <div id=\"rebreinstResDlgErrMsg\" class=\"rederrormsg\"></div>\n"; + $text .= " <input type=\"hidden\" id=\"rebootrescont\">\n"; + $text .= " <div id=\"rebootResDlgErrMsg\" class=\"rederrormsg\"></div>\n"; $text .= " <div align=\"center\">\n"; - $text .= " <button id=\"rebreinstResDlgBtn\" dojoType=\"dijit.form.Button\">\n"; + $text .= " <button id=\"rebootResDlgBtn\" dojoType=\"dijit.form.Button\">\n"; $text .= " Reboot Reservation\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; - $text .= " submitRebReinstReservation();\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " submitRebootReservation();\n"; $text .= " </script>\n"; $text .= " </button>\n"; - $text .= " <button dojoType=\"dijit.form.Button\" id=\"rebreinstResCancelBtn\">\n"; + $text .= " <button dojoType=\"dijit.form.Button\">\n"; $text .= " Cancel\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; - $text .= " dijit.byId('rebootreinstalldlg').hide();\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " dijit.byId('rebootdlg').hide();\n"; + $text .= " </script>\n"; + $text .= " </button>\n"; + $text .= " </div>\n"; + $text .= "</div>\n"; + + $text .= "<div dojoType=dijit.Dialog\n"; + $text .= " id=\"reinstalldlg\"\n"; + $text .= " title=\"Reinstall Reservation\"\n"; + $text .= " duration=250\n"; + $text .= " draggable=true>\n"; + $text .= " <script type=\"dojo/connect\" event=onHide>\n"; + $text .= " hideReinstallResDlg();\n"; + $text .= " </script>\n"; + $text .= " <div id=\"reinstallloading\" style=\"text-align: center\">"; + $text .= "<img src=\"themes/$skin/css/dojo/images/loading.gif\" "; + $text .= "style=\"vertical-align: middle;\"> Loading...</div>\n"; + $text .= " <div id=\"reinstallResDlgContent\"></div>\n"; + $text .= " <input type=\"hidden\" id=\"reinstallrescont\">\n"; + $text .= " <div id=\"reinstallResDlgErrMsg\" class=\"rederrormsg\"></div>\n"; + $text .= " <div align=\"center\" id=\"reinstallbtns\" class=\"hidden\">\n"; + $text .= " <button id=\"reinstallResDlgBtn\" dojoType=\"dijit.form.Button\">\n"; + $text .= " Reinstall Reservation\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " submitReinstallReservation();\n"; + $text .= " </script>\n"; + $text .= " </button>\n"; + $text .= " <button dojoType=\"dijit.form.Button\">\n"; + $text .= " Cancel\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " dijit.byId('reinstalldlg').hide();\n"; $text .= " </script>\n"; $text .= " </button>\n"; $text .= " </div>\n"; @@ -1349,13 +1383,13 @@ function viewRequests() { $text .= " <div align=\"center\">\n"; $text .= " <button id=\"suggestDlgBtn\" dojoType=\"dijit.form.Button\" disabled>\n"; $text .= " Use Selected Time\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; $text .= " useSuggestedEditSlot();\n"; $text .= " </script>\n"; $text .= " </button>\n"; $text .= " <button id=\"suggestDlgCancelBtn\" dojoType=\"dijit.form.Button\">\n"; $text .= " Cancel\n"; - $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; + $text .= " <script type=\"dojo/method\" event=\"onClick\">\n"; $text .= " dijit.byId('suggestDlgBtn').set('disabled', true);\n"; $text .= " dojo.removeClass('suggestDlgBtn', 'hidden');\n"; $text .= " showDijitButton('suggestDlgBtn');\n"; @@ -1549,7 +1583,7 @@ function getViewRequestHTMLitem($item, $ $r .= " iconClass=\"noicon\"\n"; $r .= " label=\"Reinstall\">\n"; $r .= " <script type=\"dojo/method\" event=\"onClick\">\n"; - $r .= " reinstallRequest('$var1');\n"; + $r .= " showReinstallRequest('$var1');\n"; $r .= " </script>\n"; $r .= " </div>\n"; return $r; @@ -1605,9 +1639,29 @@ function getViewRequestHTMLitem($item, $ else $r .= "<strong>Admin User Group</strong>: {$data['admingroup']}<br>\n"; if(empty($data['logingroup'])) - $r .= "<strong>Access User Group</strong>: (none)\n"; + $r .= "<strong>Access User Group</strong>: (none)<br>\n"; else - $r .= "<strong>Access User Group</strong>: {$data['logingroup']}\n"; + $r .= "<strong>Access User Group</strong>: {$data['logingroup']}<br>\n"; + if($data['stateid'] == 8) + $r .= "<strong>Status</strong>: In Use\n"; + elseif($data['stateid'] == 24) + $r .= "<strong>Status</strong>: Checkpointing\n"; + elseif($data['stateid'] == 5) + $r .= "<strong>Status</strong>: Failed\n"; + elseif($data['stateid'] == 13) + $r .= "<strong>Status</strong>: New\n"; + elseif($data['stateid'] == 28) + $r .= "<strong>Status</strong>: Hard Rebooting\n"; + elseif($data['stateid'] == 26) + $r .= "<strong>Status</strong>: Soft Rebooting\n"; + elseif($data['stateid'] == 27) + $r .= "<strong>Status</strong>: Reinstalling\n"; + elseif($data['stateid'] == 6) + $r .= "<strong>Status</strong>: Loading\n"; + elseif($data['stateid'] == 3) + $r .= "<strong>Status</strong>: In Use\n"; + elseif($data['stateid'] == 11) + $r .= "<strong>Status</strong>: Timed Out\n"; $r .= "</div>\n"; $r .= "</TD>\n"; return $r; @@ -2683,6 +2737,7 @@ function AJsubmitEditRequest() { . "logingroupid = $logingroupid " . "WHERE requestid = $requestid"; doQuery($query, 101); + addChangeLogEntryOther($request['logid'], "event:usergroups|admingroupid:$admingroupid|logingroupid:$logingroupid"); $query = "UPDATE request " . "SET stateid = 29 " . "WHERE id = $requestid"; @@ -2932,10 +2987,21 @@ function AJsubmitRemoveRequest() { //////////////////////////////////////////////////////////////////////////////// function AJrebootRequest() { $requestid = getContinuationVar('requestid'); + $reqdata = getRequestInfo($requestid, 1); + if(is_null($reqdata)) { + print "resGone('reboot'); "; + print "dijit.byId('editResDlg').show();"; + print "setTimeout(resRefresh, 1500);"; + return; + } $reboottype = processInputVar('reboottype', ARG_NUMERIC); $newstateid = 26; - if($reboottype == 1) + if($reboottype == 1) { $newstateid = 28; + addChangeLogEntryOther($reqdata['logid'], "event:reboothard"); + } + else + addChangeLogEntryOther($reqdata['logid'], "event:rebootsoft"); $query = "UPDATE request SET stateid = $newstateid WHERE id = $requestid"; doQuery($query, 101); print "resRefresh();"; @@ -2943,6 +3009,73 @@ function AJrebootRequest() { //////////////////////////////////////////////////////////////////////////////// /// +/// \fn AJshowReinstallRequest() +/// +/// \brief +/// +//////////////////////////////////////////////////////////////////////////////// +function AJshowReinstallRequest() { + global $user; + $requestid = getContinuationVar('requestid'); + $reqdata = getRequestInfo($requestid, 1); + if(is_null($reqdata)) { + sendJSON(array('status' => 'resgone')); + return; + } + $imageid = $reqdata['reservations'][0]['imageid']; + $imgdata = getImages(0, $imageid); + $t = ''; + $cdata = getContinuationVar(); + $cont = addContinuationsEntry('AJreinstallRequest', $cdata, 300, 1, 0); + if(count($reqdata['reservations']) == 1 && + ($imgdata[$imageid]['ownerid'] == $user['id'] || + checkUserHasPerm('View Debug Information')) && + count($imgdata[$imageid]['imagerevision'] > 1)) { + # prompt for which revision to use for reinstall + $t .= "This will cause the reserved machine to be reinstalled. "; + $t .= "You may select which version<br>of the environment you would "; + $t .= "like to use for the reinstall. The currently installed<br>"; + $t .= "version what is selected.<br>"; + $t .= "<table summary=\"lists versions of the environment\">"; + $t .= "<TR>"; + $t .= "<TD></TD>"; + $t .= "<TH>Version</TH>"; + $t .= "<TH>Creator</TH>"; + $t .= "<TH>Created</TH>"; + $t .= "<TH>Currently in Production</TH>"; + $t .= "</TR>"; + foreach($imgdata[$imageid]['imagerevision'] as $revision) { + $t .= "<TR>"; + // if revision was selected or it wasn't selected but it is the production revision, show checked + if($reqdata['reservations'][0]['imagerevisionid'] == $revision['id']) + $t .= "<TD align=center><INPUT type=radio name=revisionid value={$revision['id']} checked></TD>"; + else + $t .= "<TD align=center><INPUT type=radio name=revisionid value={$revision['id']}></TD>"; + $t .= "<TD align=center>{$revision['revision']}</TD>"; + $t .= "<TD align=center>{$revision['user']}</TD>"; + $t .= "<TD align=center>{$revision['prettydate']}</TD>"; + if($revision['production']) + $t .= "<TD align=center>Yes</TD>"; + else + $t .= "<TD align=center>No</TD>"; + $t .= "</TR>"; + } + $t .= "</table><br>"; + $t .= "<strong>NOTE</strong>: Any data saved only to the reserved "; + $t .= "machine <strong>will be lost</strong>. Are you sure you<br>"; + $t .= "want to continue?<br><br>"; + } + else { + # prompt for reinstall confirmation + $t .= "This will cause the reserved machine to be reinstalled. Any<br>"; + $t .= "data saved only to the reserved machine will be lost. Are<br>"; + $t .= "you sure you want to continue?<br><br>"; + } + sendJSON(array('status' => 'success', 'txt' => $t, 'cont' => $cont)); +} + +//////////////////////////////////////////////////////////////////////////////// +/// /// \fn AJreinstallRequest() /// /// \brief sets a reservation to the reinstall state and refreshes the Current @@ -2951,9 +3084,34 @@ function AJrebootRequest() { //////////////////////////////////////////////////////////////////////////////// function AJreinstallRequest() { $requestid = getContinuationVar('requestid'); + $reqdata = getRequestInfo($requestid, 1); + if(is_null($reqdata)) { + sendJSON(array('status' => 'resgone')); + return; + } + $revisionid = processInputVar('revisionid', ARG_NUMERIC, 0); + if($revisionid != 0) { + $imageid = $reqdata['reservations'][0]['imageid']; + $imgdata = getImages(0, $imageid); + if(! array_key_exists($revisionid, $imgdata[$imageid]['imagerevision'])) { + $cdata = getContinuationVar(); + $cont = addContinuationsEntry('AJreinstallRequest', $cdata, 300, 1, 0); + sendJSON(array('status' => 'invalidrevisionid', 'cont' => $cont)); + return; + } + if($reqdata['reservations'][0]['imagerevisionid'] != $revisionid) { + $query = "UPDATE reservation " + . "SET imagerevisionid = $revisionid " + . "WHERE id = {$reqdata['reservations'][0]['reservationid']}"; + doQuery($query, 101); + } + addChangeLogEntryOther($reqdata['logid'], "event:reinstall|revisionid:$revisionid"); + } + else + addChangeLogEntryOther($reqdata['logid'], "event:reinstall"); $query = "UPDATE request SET stateid = 27 WHERE id = $requestid"; doQuery($query, 101); - print "resRefresh();"; + sendJSON(array('status' => 'success')); } //////////////////////////////////////////////////////////////////////////////// Modified: incubator/vcl/trunk/web/.ht-inc/states.php URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/states.php?rev=1303484&r1=1303483&r2=1303484&view=diff ============================================================================== --- incubator/vcl/trunk/web/.ht-inc/states.php (original) +++ incubator/vcl/trunk/web/.ht-inc/states.php Wed Mar 21 18:13:57 2012 @@ -174,6 +174,7 @@ $noHTMLwrappers = array('sendRDPfile', 'AJeditRequest', 'AJsubmitEditRequest', 'AJrebootRequest', + 'AJshowReinstallRequest', 'AJreinstallRequest', 'AJshowRequestSuggestedTimes', 'AJgenerateUtilData', @@ -367,6 +368,7 @@ $actions['mode']['subimageDialogContent' $actions['mode']['AJaddSubimage'] = "AJaddSubimage"; $actions['mode']['AJremSubimage'] = "AJremSubimage"; $actions['mode']['AJrebootRequest'] = "AJrebootRequest"; +$actions['mode']['AJshowReinstallRequest'] = "AJshowReinstallRequest"; $actions['mode']['AJreinstallRequest'] = "AJreinstallRequest"; $actions['pages']['selectImageOption'] = "manageImages"; $actions['pages']['viewImages'] = "manageImages"; @@ -417,6 +419,7 @@ $actions['pages']['subimageDialogContent $actions['pages']['AJaddSubimage'] = "manageImages"; $actions['pages']['AJremSubimage'] = "manageImages"; $actions['pages']['AJrebootRequest'] = "manageImages"; +$actions['pages']['AJshowReinstallRequest'] = "manageImages"; $actions['pages']['AJreinstallRequest'] = "manageImages"; # manage schedules Modified: incubator/vcl/trunk/web/.ht-inc/utils.php URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/utils.php?rev=1303484&r1=1303483&r2=1303484&view=diff ============================================================================== --- incubator/vcl/trunk/web/.ht-inc/utils.php (original) +++ incubator/vcl/trunk/web/.ht-inc/utils.php Wed Mar 21 18:13:57 2012 @@ -6548,9 +6548,15 @@ function showTimeTable($links) { /// \param $ip - (optional, default='') desired IP address /// \param $mac - (optional, default='') desired MAC address /// -/// \return +/// \return an array where each key is a unix timestamp for the start time of +/// the available slot and each element is an array with these items:\n +/// \b start - start of slot in datetime format\n +/// \b startts - start of slot in unix timestamp format\n +/// \b duration - length of slot in minutes\n +/// \b compid - id of computer for slot /// -/// \brief +/// \brief builds an array of available time slots close to the submitted +/// parameters /// //////////////////////////////////////////////////////////////////////////////// function findAvailableTimes($start, $end, $imageid, $userid, $usedaysahead, @@ -8490,6 +8496,29 @@ function addChangeLogEntry($logid, $remo //////////////////////////////////////////////////////////////////////////////// /// +/// \fn addChangeLogEntryOther($logid, $data) +/// +/// \param $logid - id matching entry in log table +/// \param $data - data to be inserted in the other field +/// +/// \brief adds an entry to the other field in the changelog table +/// +//////////////////////////////////////////////////////////////////////////////// +function addChangeLogEntryOther($logid, $data) { + $data = mysql_real_escape_string($data); + $query = "INSERT INTO changelog " + . "(logid, " + . "timestamp, " + . "other) " + . "VALUES " + . "($logid, " + . "NOW(), " + . "'$data')"; + doQuery($query); +} + +//////////////////////////////////////////////////////////////////////////////// +/// /// \fn addSublogEntry($logid, $imageid, $imagerevisionid, $computerid, /// $mgmtnodeid) /// Modified: incubator/vcl/trunk/web/js/code.js URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/js/code.js?rev=1303484&r1=1303483&r2=1303484&view=diff ============================================================================== --- incubator/vcl/trunk/web/js/code.js (original) +++ incubator/vcl/trunk/web/js/code.js Wed Mar 21 18:13:57 2012 @@ -331,3 +331,9 @@ function showDijitButton(id) { display: 'inline' }); } + +function recenterDijitDialog(id) { + if(dijit.byId(id)._relativePosition) + delete dijit.byId(id)._relativePosition; + dijit.byId(id)._position(); +} Modified: incubator/vcl/trunk/web/js/requests.js URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/js/requests.js?rev=1303484&r1=1303483&r2=1303484&view=diff ============================================================================== --- incubator/vcl/trunk/web/js/requests.js (original) +++ incubator/vcl/trunk/web/js/requests.js Wed Mar 21 18:13:57 2012 @@ -107,7 +107,7 @@ function showSuggestedTimesCB(data, ioAr dojo.byId('suggestContent').innerHTML = data.items.html; if(data.items.status == 'resgone') { dijit.byId('suggestedTimes').hide(); - resGone(); + resGone('edit'); resRefresh(); return; } @@ -122,14 +122,10 @@ function showSuggestedTimesCB(data, ioAr dojo.byId('editResDlgErrMsg').innerHTML = ''; dijit.byId('editResDlgBtn').set('style', 'display: none'); dijit.byId('editResCancelBtn').set('label', 'Okay'); - if(dijit.byId('editResDlg')._relativePosition) - delete dijit.byId('editResDlg')._relativePosition; - dijit.byId('editResDlg')._position(); + recenterDijitDialog('editResDlg'); return; } - if(dijit.byId('suggestedTimes')._relativePosition) - delete dijit.byId('suggestedTimes')._relativePosition; - dijit.byId('suggestedTimes')._position(); + recenterDijitDialog('suggestedTimes'); suggestTimeData = data.items.data; } @@ -389,7 +385,7 @@ function editReservationCB(data, ioArgs) if(data.items.status == 'resgone') { document.body.style.cursor = 'default'; dijit.byId('editResDlg').show(); - resGone(); + resGone('edit'); resRefresh(); return; } @@ -598,71 +594,113 @@ function checkResGone(reqids) { if(editresid == reqids[i]) return; } - resGone(); + resGone('edit'); } -function resGone() { +function resGone(type) { + if(type == 'edit') { + dojo.byId('editResDlgContent').innerHTML = "The reservation you selected<br>to edit has expired.<br><br>"; + } + else if(type == 'reboot') { + dojo.byId('editResDlgContent').innerHTML = "The reservation you selected<br>to reboot has expired.<br><br>"; + } + else if(type == 'reinstall') { + dojo.byId('editResDlgContent').innerHTML = "The reservation you selected<br>to reinstall has expired.<br><br>"; + } dojo.byId('editresid').value = ''; - dojo.byId('editResDlgContent').innerHTML = "The reservation you selected<br>to edit has expired.<br><br>"; dojo.byId('editResDlgErrMsg').innerHTML = ''; dijit.byId('editResDlgBtn').set('style', 'display: none'); dijit.byId('editResCancelBtn').set('label', 'Okay'); - if(dijit.byId('editResDlg')._relativePosition) - delete dijit.byId('editResDlg')._relativePosition; - dijit.byId('editResDlg')._position(); + recenterDijitDialog('editResDlg'); } -function hideRebReinstResDlg() { - dijit.byId('rebootreinstalldlg').set('title', 'Reboot Reservation'); - dojo.byId('rebreinstResDlgContent').innerHTML = ''; - dojo.removeClass('rebootRadios', 'hidden'); +function hideRebootResDlg() { dojo.byId('softreboot').checked = true; - dojo.byId('rebreinstrescont').value = ''; - //dojo.byId('rebreinstresid').value = ''; - dojo.byId('rebreinstResDlgErrMsg').innerHTML = ''; - dijit.byId('rebreinstResDlgBtn').set('label', 'Reboot Reservation'); + dojo.byId('rebootrescont').value = ''; + dojo.byId('rebootResDlgErrMsg').innerHTML = ''; } function rebootRequest(cont) { - dijit.byId('rebootreinstalldlg').set('title', 'Reboot Reservation'); - var txt = 'You can select either a soft or a hard reboot. A soft reboot<br>' - + 'issues a reboot command to the operating system. A hard reboot<br>' - + 'is akin to toggling the power switch on a computer. After<br>' - + 'issuing the reboot, it may take several minutes before the<br>' - + 'machine is available again. It is also possible that it will<br>' - + 'not come back up at all. Are you sure you want to continue?<br><br>'; - dojo.removeClass('rebootRadios', 'hidden'); - dojo.byId('rebreinstResDlgContent').innerHTML = txt; - dojo.byId('rebreinstrescont').value = cont; - dijit.byId('rebreinstResDlgBtn').set('label', 'Reboot Reservation'); - dijit.byId('rebootreinstalldlg').show(); -} - -function reinstallRequest(cont) { - dijit.byId('rebootreinstalldlg').set('title', 'Reinstall Reservation'); - var txt = 'This will cause the reserved machine to be reinstalled. Any<br>' - + 'data saved only to the reserved machine will be lost. Are<br>' - + 'you sure you want to continue?<br><br>'; - dojo.addClass('rebootRadios', 'hidden'); - dojo.byId('rebreinstResDlgContent').innerHTML = txt; - dojo.byId('rebreinstrescont').value = cont; - dijit.byId('rebreinstResDlgBtn').set('label', 'Reinstall Reservation'); - dijit.byId('rebootreinstalldlg').show(); + dojo.byId('rebootrescont').value = cont; + dijit.byId('rebootdlg').show(); } -function submitRebReinstReservation() { - var data = {continuation: dojo.byId('rebreinstrescont').value}; +function submitRebootReservation() { + var data = {continuation: dojo.byId('rebootrescont').value}; document.body.style.cursor = 'wait'; - if(dijit.byId('rebreinstResDlgBtn').get('label') == 'Reboot Reservation') { - if(dojo.byId('hardreboot').checked) - data.reboottype = 1; - else - data.reboottype = 0; - } - dijit.byId('rebootreinstalldlg').hide(); + if(dojo.byId('hardreboot').checked) + data.reboottype = 1; + else + data.reboottype = 0; + dijit.byId('rebootdlg').hide(); RPCwrapper(data, generalReqCB); } +function hideReinstallResDlg() { + dijit.byId('reinstalldlg').hide(); + dojo.addClass('reinstallbtns', 'hidden'); + dojo.byId('reinstallResDlgContent').innerHTML = ''; + dojo.byId('reinstallResDlgErrMsg').innerHTML = ''; + dojo.byId('reinstallrescont').value = ''; +} + +function showReinstallRequest(cont) { + dojo.removeClass('reinstallloading', 'hidden'); + dijit.byId('reinstalldlg').show(); + var data = {continuation: cont}; + RPCwrapper(data, showReinstallRequestCB, 1); + document.body.style.cursor = 'wait'; +} + +function showReinstallRequestCB(data, ioArgs) { + document.body.style.cursor = 'default'; + if(data.items.status == 'resgone') { + dijit.byId('reinstalldlg').hide(); + resGone('reinstall'); + dijit.byId('editResDlg').show(); + setTimeout(resRefresh, 1500); + return; + } + dojo.addClass('reinstallloading', 'hidden'); + dojo.removeClass('reinstallbtns', 'hidden'); + dojo.byId('reinstallrescont').value = data.items.cont; + dojo.byId('reinstallResDlgContent').innerHTML = data.items.txt; + recenterDijitDialog('reinstalldlg'); +} + +function submitReinstallReservation() { + var data = {continuation: dojo.byId('reinstallrescont').value}; + var inputs = document.getElementsByName('revisionid'); + for(var i = 0; i < inputs.length; i++) { + if(inputs[i].checked) { + data.revisionid = inputs[i].value; + break; + } + } + document.body.style.cursor = 'wait'; + RPCwrapper(data, submitReinstallReservationCB, 1); +} + +function submitReinstallReservationCB(data, ioArgs) { + document.body.style.cursor = 'default'; + if(data.items.status == 'resgone') { + dijit.byId('reinstalldlg').hide(); + resGone('reinstall'); + dijit.byId('editResDlg').show(); + setTimeout(resRefresh, 1500); + return; + } + if(data.items.status == 'invalidrevisionid') { + dojo.byId('reinstallResDlgErrMsg').innerHTML = 'An invalid version was submitted.'; + dojo.byId('reinstallrescont').value = data.items.cont; + return; + } + if(data.items.status == 'success') { + dijit.byId('reinstalldlg').hide(); + resRefresh(); + } +} + function showRDPbutton() { // submitted by Gerhard Harti from ODU if(! dojo.byId('counterdiv') || ! dojo.byId('connectdiv'))