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