AJAX был отключён для страниц с загрузками и мастером VM
Этот коммит содержится в:
@@ -4,6 +4,8 @@
|
|||||||
refreshTimers: [],
|
refreshTimers: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fullLoadPages = ['/iso', '/disk-images', '/vm/create'];
|
||||||
|
|
||||||
function qs(selector, root = document) {
|
function qs(selector, root = document) {
|
||||||
return root.querySelector(selector);
|
return root.querySelector(selector);
|
||||||
}
|
}
|
||||||
@@ -18,9 +20,14 @@
|
|||||||
return url.origin === window.location.origin;
|
return url.origin === window.location.origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function requiresFullLoad(pathname) {
|
||||||
|
return fullLoadPages.some((path) => pathname === path || pathname.startsWith(path + '/'));
|
||||||
|
}
|
||||||
|
|
||||||
function isAjaxSafeLink(link) {
|
function isAjaxSafeLink(link) {
|
||||||
if (!sameOriginLink(link)) return false;
|
if (!sameOriginLink(link)) return false;
|
||||||
const url = new URL(link.href, window.location.href);
|
const url = new URL(link.href, window.location.href);
|
||||||
|
if (requiresFullLoad(url.pathname)) return false;
|
||||||
if (url.pathname.startsWith('/vm/') && url.pathname.endsWith('/console')) return false;
|
if (url.pathname.startsWith('/vm/') && url.pathname.endsWith('/console')) return false;
|
||||||
if (url.pathname.startsWith('/static/')) return false;
|
if (url.pathname.startsWith('/static/')) return false;
|
||||||
if (url.pathname.startsWith('/api/')) return false;
|
if (url.pathname.startsWith('/api/')) return false;
|
||||||
@@ -59,6 +66,11 @@
|
|||||||
function swapPage(html, url, push = true) {
|
function swapPage(html, url, push = true) {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
const doc = parser.parseFromString(html, 'text/html');
|
const doc = parser.parseFromString(html, 'text/html');
|
||||||
|
const targetPath = new URL(url, window.location.href).pathname;
|
||||||
|
if (requiresFullLoad(targetPath)) {
|
||||||
|
window.location.href = url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const newMain = qs('.v-main', doc) || qs('.shell', doc);
|
const newMain = qs('.v-main', doc) || qs('.shell', doc);
|
||||||
const currentMain = qs('.v-main') || qs('.shell');
|
const currentMain = qs('.v-main') || qs('.shell');
|
||||||
|
|
||||||
@@ -74,7 +86,7 @@
|
|||||||
currentMain.replaceWith(newMain);
|
currentMain.replaceWith(newMain);
|
||||||
newMain.classList.add('page-enter');
|
newMain.classList.add('page-enter');
|
||||||
setTimeout(() => newMain.classList.remove('page-enter'), 220);
|
setTimeout(() => newMain.classList.remove('page-enter'), 220);
|
||||||
activeSidebar(new URL(url, window.location.href).pathname);
|
activeSidebar(targetPath);
|
||||||
if (push) history.pushState({ ajax: true }, '', url);
|
if (push) history.pushState({ ajax: true }, '', url);
|
||||||
initDynamicPage();
|
initDynamicPage();
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
@@ -82,6 +94,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function ajaxNavigate(url, push = true) {
|
async function ajaxNavigate(url, push = true) {
|
||||||
|
const targetPath = new URL(url, window.location.href).pathname;
|
||||||
|
if (requiresFullLoad(targetPath)) {
|
||||||
|
window.location.href = url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (app.loading) return;
|
if (app.loading) return;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user