feat: add clean public routes for alpine ui

This commit is contained in:
a.tolmachev
2026-03-31 22:07:12 +03:00
parent 9cee29d110
commit f5a658b4f0
17 changed files with 198 additions and 115 deletions
+2 -2
View File
@@ -22,11 +22,11 @@
}
function loginUrl() {
return (window.APP_BASE || '') + 'html/login.html';
return (window.CrankRoutes && window.CrankRoutes.login) || '/login';
}
function homeUrl() {
return (window.APP_BASE || '') + 'index.html';
return (window.CrankRoutes && window.CrankRoutes.home) || '/';
}
function clearUserMirror() {
+3 -2
View File
@@ -356,7 +356,8 @@ document.addEventListener('alpine:init', function() {
},
editOperation(operation) {
window.location.href = (window.APP_BASE || '') + 'html/wizard/?mode=edit&operationId=' + encodeURIComponent(operation.id);
window.location.href = ((window.CrankRoutes && window.CrankRoutes.wizard) || '/wizard/')
+ '?mode=edit&operationId=' + encodeURIComponent(operation.id);
},
async deleteOperation(id) {
@@ -428,7 +429,7 @@ document.addEventListener('alpine:init', function() {
},
handleNewOperation() {
window.location.href = (window.APP_BASE || '') + 'html/wizard/';
window.location.href = (window.CrankRoutes && window.CrankRoutes.wizard) || '/wizard/';
},
handleLogout() {
+13 -18
View File
@@ -1,20 +1,15 @@
/**
* config.js — auto-detects base paths based on current page location.
* Must be loaded before workspace.js and other navigation-using scripts.
*/
(function() {
var p = window.location.pathname;
// html/wizard/ is two levels deep from root
if (/\/html\/wizard\//.test(p)) {
window.APP_BASE = '../../';
window.DATA_URL = '../../data/';
// html/*.html is one level deep from root
} else if (/\/html\//.test(p)) {
window.APP_BASE = '../';
window.DATA_URL = '../data/';
// root level (index.html)
} else {
window.APP_BASE = '';
window.DATA_URL = 'data/';
}
window.APP_BASE = '/';
window.DATA_URL = '/data/';
window.CrankRoutes = {
home: '/',
login: '/login',
agents: '/agents',
apiKeys: '/api-keys',
logs: '/logs',
usage: '/usage',
settings: '/settings',
workspaceSetup: '/workspace-setup',
wizard: '/wizard/'
};
}());
+2 -2
View File
@@ -84,7 +84,7 @@
if (dropdown) {
dropdown.style.display = 'none';
}
window.location.href = (window.APP_BASE || '') + 'html/settings.html#profile';
window.location.href = ((window.CrankRoutes && window.CrankRoutes.settings) || '/settings') + '#profile';
});
});
@@ -93,7 +93,7 @@
if (dropdown) {
dropdown.style.display = 'none';
}
window.location.href = (window.APP_BASE || '') + 'html/settings.html';
window.location.href = (window.CrankRoutes && window.CrankRoutes.settings) || '/settings';
});
});
}
+2 -2
View File
@@ -189,14 +189,14 @@ document.addEventListener('DOMContentLoaded', async function() {
var backToCatalog = document.getElementById('back-to-catalog');
if (backToCatalog) {
backToCatalog.addEventListener('click', function() {
window.location.href = (window.APP_BASE || '') + 'index.html';
window.location.href = (window.CrankRoutes && window.CrankRoutes.home) || '/';
});
}
var closeBtn = document.querySelector('.progress-close');
if (closeBtn) {
closeBtn.addEventListener('click', function() {
window.location.href = (window.APP_BASE || '') + 'index.html';
window.location.href = (window.CrankRoutes && window.CrankRoutes.home) || '/';
});
}
+1 -1
View File
@@ -330,7 +330,7 @@ async function submitForm() {
setFormDirty(false);
if (workspaceFormState.isCreateMode) {
window.location.href = (window.APP_BASE || '') + 'html/workspace-setup.html';
window.location.href = (window.CrankRoutes && window.CrankRoutes.workspaceSetup) || '/workspace-setup';
return;
}
+1 -1
View File
@@ -117,7 +117,7 @@ function renderWorkspaceList() {
'</div>';
}).join('') +
'<div class="ws-dropdown-divider"></div>' +
'<a class="ws-dropdown-mgmt-link" href="' + (window.APP_BASE || '') + 'html/workspace-setup.html" onclick="var dd=document.getElementById(\'ws-dropdown\');if(dd)dd.style.display=\'none\'">' +
'<a class="ws-dropdown-mgmt-link" href="' + ((window.CrankRoutes && window.CrankRoutes.workspaceSetup) || '/workspace-setup') + '" onclick="var dd=document.getElementById(\'ws-dropdown\');if(dd)dd.style.display=\'none\'">' +
'<svg width="14" height="14"><use href="' + (window.APP_BASE || '') + 'icons/general/settings.svg#icon"/></svg>' +
'Workspace settings' +
'</a>';