fix: chargement tree sidebar 100% client-side (pas de asyncio.run)
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

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:
2026-07-13 16:43:34 -04:00
parent e78ca4b775
commit 6b000d892b
3 changed files with 29 additions and 26 deletions
+1 -1
View File
@@ -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 %}
+26
View File
@@ -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) {