mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
64 lines
1.8 KiB
5 months ago
|
import {hideElem, showElem} from '../utils/dom.ts';
|
||
|
import {GET, POST} from '../modules/fetch.ts';
|
||
3 years ago
|
|
||
1 year ago
|
const {appSubUrl} = window.config;
|
||
3 years ago
|
|
||
|
export function initRepoMigrationStatusChecker() {
|
||
6 months ago
|
const repoMigrating = document.querySelector('#repo_migrating');
|
||
9 months ago
|
if (!repoMigrating) return;
|
||
2 years ago
|
|
||
6 months ago
|
document.querySelector('#repo_migrating_retry').addEventListener('click', doMigrationRetry);
|
||
1 year ago
|
|
||
9 months ago
|
const task = repoMigrating.getAttribute('data-migrating-task-id');
|
||
2 years ago
|
|
||
9 months ago
|
// returns true if the refresh still needs to be called after a while
|
||
2 years ago
|
const refresh = async () => {
|
||
1 year ago
|
const res = await GET(`${appSubUrl}/user/task/${task}`);
|
||
2 years ago
|
if (res.status !== 200) return true; // continue to refresh if network error occurs
|
||
|
|
||
|
const data = await res.json();
|
||
|
|
||
|
// for all status
|
||
|
if (data.message) {
|
||
6 months ago
|
document.querySelector('#repo_migrating_progress_message').textContent = data.message;
|
||
2 years ago
|
}
|
||
|
|
||
|
// TaskStatusFinished
|
||
|
if (data.status === 4) {
|
||
|
window.location.reload();
|
||
|
return false;
|
||
3 years ago
|
}
|
||
2 years ago
|
|
||
|
// TaskStatusFailed
|
||
|
if (data.status === 3) {
|
||
|
hideElem('#repo_migrating_progress');
|
||
|
hideElem('#repo_migrating');
|
||
1 year ago
|
showElem('#repo_migrating_retry');
|
||
2 years ago
|
showElem('#repo_migrating_failed');
|
||
|
showElem('#repo_migrating_failed_image');
|
||
6 months ago
|
document.querySelector('#repo_migrating_failed_error').textContent = data.message;
|
||
2 years ago
|
return false;
|
||
|
}
|
||
|
|
||
|
return true; // continue to refresh
|
||
|
};
|
||
|
|
||
|
const syncTaskStatus = async () => {
|
||
|
let doNextRefresh = true;
|
||
|
try {
|
||
|
doNextRefresh = await refresh();
|
||
|
} finally {
|
||
|
if (doNextRefresh) {
|
||
|
setTimeout(syncTaskStatus, 2000);
|
||
3 years ago
|
}
|
||
2 years ago
|
}
|
||
|
};
|
||
|
|
||
|
syncTaskStatus(); // no await
|
||
3 years ago
|
}
|
||
1 year ago
|
|
||
|
async function doMigrationRetry(e) {
|
||
9 months ago
|
await POST(e.target.getAttribute('data-migrating-task-retry-url'));
|
||
1 year ago
|
window.location.reload();
|
||
|
}
|