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-03-16 15:13:52 +01:00
if ( ! result . success ) { // Vérification de la propriété "success"
// 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 ();
console . error ( message );
$ ( " #installUpdateErrorMessage " ) . text ( message . replace ( /< [ ^ p ] .* ?> /g, ""));
}
$ ( window ) . on ( " load " , function () {
step ( 1 , null );
});