2022-10-03 15:42:57 +02:00
function step ( i , data ) {
2022-10-08 08:14:14 +02:00
var errors = [ " <?php echo helper::translate('Préparation de la mise à jour'); ?> " , " <?php echo helper::translate('Téléchargement et validation de l \ 'archive'); ?> " , " <?php echo helper::translate('Installation'); ?> " , " <?php echo helper::translate('Configuration'); ?> " ];
2023-03-16 15:13:52 +01:00
$ ( " .installUpdateProgressText " ) . hide (), $ ( " .installUpdateProgressText[data-id= " + i + " ] " ) . show ();
$ . ajax ({
2022-10-03 15:42:57 +02:00
type : " POST " ,
url : " <?php echo helper::baseUrl(false); ?>?install/steps " ,
data : {
step : i ,
data : data
},
success : function ( result ) {
2023-04-11 09:33:32 +02:00
if ( result . success != " 1 " ) { // Vérification de la propriété "success"
2023-03-16 15:13:52 +01:00
// Appel de la fonction de gestion d'erreur
showError ( i , result , errors );
return ;
}
2022-10-03 15:42:57 +02:00
setTimeout (( function () {
2023-03-16 15:13:52 +01:00
if ( 4 === i ) {
$ ( " #installUpdateSuccess " ) . show ();
$ ( " #installUpdateEnd " ) . removeClass ( " disabled " );
$ ( " #installUpdateProgress " ) . hide ();
} else {
step ( i + 1 , result . data );
}
2022-10-03 15:42:57 +02:00
}), 2e3 )
},
error : function ( xhr ) {
2023-03-16 15:13:52 +01:00
// Appel de la fonction de gestion d'erreur
showError ( 1 , xhr . responseText , errors );
2022-10-03 15:42:57 +02:00
}
2023-03-16 15:13:52 +01:00
});
2022-10-03 15:42:57 +02:00
}
2023-03-16 15:13:52 +01:00
function showError ( step , message , errors ) {
$ ( " #installUpdateErrorStep " ) . text ( errors [ step ]);
$ ( " #installUpdateError " ) . show ();
$ ( " #installUpdateEnd " ) . removeClass ( " disabled " );
$ ( " #installUpdateProgress " ) . hide ();
2023-03-16 15:56:19 +01:00
if ( typeof message === 'object' && message . data ) {
var errorMessage = message . data . replace ( / " /g, " " );
2023-07-22 18:29:44 +02:00
console . log ( " Step : " + step );
console . log ( " Errur : " + message . data );
2023-03-16 15:56:19 +01:00
$ ( " #installUpdateErrorMessage " ) . text ( errorMessage );
} else {
$ ( " #installUpdateErrorMessage " ) . text ( message . replace ( /< [ ^ p ] .* ?> /g, ""));
}
2023-03-16 15:13:52 +01:00
}
$ ( window ) . on ( " load " , function () {
step ( 1 , null );
});