Split index.js
to separate files (#17315)
* split `index.js` to separate files * tune clipboard * fix promise * fix document * remove intermediate empty file * fix async event listener * use `export function` instead of `export {}`, add more comments Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
3728f1daa0
commit
1a7473ff45
42 changed files with 3686 additions and 3501 deletions
48
web_src/js/features/repo-migrate.js
Normal file
48
web_src/js/features/repo-migrate.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
const {AppSubUrl, csrf} = window.config;
|
||||
|
||||
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');
|
||||
if (typeof task === 'undefined') {
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: `${AppSubUrl}/user/task/${task}`,
|
||||
data: {
|
||||
_csrf: csrf,
|
||||
},
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue