fix: chargement tree sidebar 100% client-side (pas de asyncio.run)
Avant: _sidebar_data() utilisait asyncio.run() → RuntimeWarning + 302 redirects Après: gitea_workspace.html appelle loadSidebarTree() → fetch API → injecte dans #sidebar-workspace-items - base.html: ajout id='sidebar-workspace-items' sur le <ul> workspace - dashboard.py: _sidebar_data() ne fait plus de fetch serveur, juste passe owner/repo
This commit is contained in:
@@ -167,7 +167,7 @@
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
<div class="sidebar-section-items" x-show="sectionsOpen.workspace" x-transition>
|
||||
<ul class="sidebar-items" data-section="workspace">
|
||||
<ul class="sidebar-items" data-section="workspace" id="sidebar-workspace-items">
|
||||
{% if workspace_pages %}
|
||||
{{ render_workspace_tree(workspace_pages) }}
|
||||
{% else %}
|
||||
|
||||
@@ -113,10 +113,36 @@ function giteaWorkspace() {
|
||||
init() {
|
||||
// Set cookie for sidebar
|
||||
document.cookie = 'flowdeck_workspace=gitea:' + this.owner + ':' + this.repo + ';path=/;SameSite=Lax';
|
||||
// Load root tree into sidebar
|
||||
this.loadSidebarTree();
|
||||
// Listen for sidebar clicks on Gitea items
|
||||
this.setupSidebarClicks();
|
||||
},
|
||||
|
||||
async loadSidebarTree() {
|
||||
try {
|
||||
var r = await fetch('/api/gitea/projects/' + this.owner + '/' + this.repo + '/tree');
|
||||
if (!r.ok) return;
|
||||
var d = await r.json();
|
||||
var items = d.tree || [];
|
||||
var container = document.getElementById('sidebar-workspace-items');
|
||||
if (!container) return;
|
||||
container.innerHTML = '';
|
||||
var self = this;
|
||||
items.forEach(function(item) {
|
||||
var icon = item.type === 'folder' ? '📁' : '📄';
|
||||
var li = document.createElement('li');
|
||||
li.className = 'sidebar-item';
|
||||
li.setAttribute('data-gitea-path', item.path);
|
||||
li.setAttribute('data-gitea-type', item.type === 'folder' ? 'folder' : 'file');
|
||||
li.setAttribute('data-gitea-sha', item.sha || '');
|
||||
li.style.cssText = 'padding-left:12px;cursor:pointer;';
|
||||
li.innerHTML = '<span class=\"page-icon\">' + icon + '</span><span class=\"page-name\">' + item.name + '</span>';
|
||||
container.appendChild(li);
|
||||
});
|
||||
} catch(e) { console.error('Sidebar tree load failed:', e); }
|
||||
},
|
||||
|
||||
setupSidebarClicks() {
|
||||
var self = this;
|
||||
document.addEventListener('click', function(e) {
|
||||
|
||||
Reference in New Issue
Block a user