2022-01-28 16:00:11 -05:00
|
|
|
import $ from 'jquery';
|
|
|
|
|
2021-10-21 03:37:43 -04:00
|
|
|
const {appSubUrl, csrfToken} = window.config;
|
2021-10-16 13:28:04 -04:00
|
|
|
|
|
|
|
export function initRepoMigrationStatusChecker() {
|
|
|
|
const migrating = $('#repo_migrating');
|
|
|
|
$('#repo_migrating_failed').hide();
|
|
|
|
$('#repo_migrating_failed_image').hide();
|
|
|
|
$('#repo_migrating_progress_message').hide();
|
|
|
|
if (migrating) {
|
|
|
|
const task = migrating.attr('task');
|
2022-11-21 19:58:55 -05:00
|
|
|
if (task === undefined) {
|
2021-10-16 13:28:04 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2021-10-21 03:37:43 -04:00
|
|
|
url: `${appSubUrl}/user/task/${task}`,
|
2021-10-16 13:28:04 -04:00
|
|
|
data: {
|
2021-10-21 03:37:43 -04:00
|
|
|
_csrf: csrfToken,
|
2021-10-16 13:28:04 -04:00
|
|
|
},
|
|
|
|
complete(xhr) {
|
|
|
|
if (xhr.status === 200 && xhr.responseJSON) {
|
|
|
|
if (xhr.responseJSON.status === 4) {
|
|
|
|
window.location.reload();
|
|
|
|
return;
|
|
|
|
} else if (xhr.responseJSON.status === 3) {
|
|
|
|
$('#repo_migrating_progress').hide();
|
|
|
|
$('#repo_migrating').hide();
|
|
|
|
$('#repo_migrating_failed').show();
|
|
|
|
$('#repo_migrating_failed_image').show();
|
|
|
|
$('#repo_migrating_failed_error').text(xhr.responseJSON.message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (xhr.responseJSON.message) {
|
|
|
|
$('#repo_migrating_progress_message').show();
|
|
|
|
$('#repo_migrating_progress_message').text(xhr.responseJSON.message);
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
initRepoMigrationStatusChecker();
|
|
|
|
}, 2000);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$('#repo_migrating_progress').hide();
|
|
|
|
$('#repo_migrating').hide();
|
|
|
|
$('#repo_migrating_failed').show();
|
|
|
|
$('#repo_migrating_failed_image').show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|