N°6009 - Fix restore backup button not working when JS dependencies are present

This commit is contained in:
Stephen Abello
2023-05-02 09:24:43 +02:00
parent 3c15186685
commit eebc61385d
2 changed files with 5 additions and 7 deletions

View File

@@ -137,6 +137,9 @@ try
* As a result we're setting a token file to make sure the restore is called by an authenticated user with the correct rights !
*/
case 'restore_get_token':
$oPage = new JsonPage();
$oPage->SetOutputDataOnly(true);
$sEnvironment = utils::ReadParam('environment', 'production', false, 'raw_data');
$oRestoreMutex = new iTopMutex('restore.'.$sEnvironment);
if ($oRestoreMutex->IsLocked())
@@ -149,12 +152,7 @@ try
$sTokenFile = APPROOT.'/data/restore.'.$sToken.'.tok';
file_put_contents($sTokenFile, $sFile);
$oPage->add_ready_script(
<<<JS
$("#restore_token").val('$sToken');
JS
);
$oPage->SetData(['token' => $sToken]);
$oPage->output();
break;

View File

@@ -471,7 +471,7 @@ function LaunchRestoreNow(sBackupFile, sConfirmationMessage)
$.post(GetAbsoluteUrlModulePage('itop-backup', 'ajax.backup.php'), oParams, function(data){
// Get the value of restore_token
$('#backup_errors').append(data);
$('#restore_token').val(data.token);
var oParams = {};
oParams.operation = 'restore_exec';