diff --git a/app/main.py b/app/main.py index 031fa8d..bbeae8c 100644 --- a/app/main.py +++ b/app/main.py @@ -42,7 +42,7 @@ async def lifespan(_app: FastAPI): app = FastAPI( title="FlowDeck", - version="2.4.6", + version="patch", docs_url="/docs" if settings.log_level == "DEBUG" else None, redoc_url=None, lifespan=lifespan, diff --git a/app/templates/base.html b/app/templates/base.html index b57274c..46ff33a 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -877,14 +877,28 @@ .catch(err => { this.toast('Failed to create sub-page: ' + err.message, 'error'); }); }, loadGiteaTree() { - if (!this.giteaWorkspace || !this.giteaOwner || !this.giteaRepo) return; + if (!this.giteaWorkspace || !this.giteaOwner || !this.giteaRepo) { + console.log('loadGiteaTree: skipped (giteaWorkspace=' + this.giteaWorkspace + ', owner=' + this.giteaOwner + ', repo=' + this.giteaRepo + ')'); + return; + } + // Skip if giteaWorkspace component already loaded the tree (has data-gitea-path items) + var container = document.getElementById('sidebar-workspace-items'); + if (container && container.querySelector('[data-gitea-path]')) { + console.log('loadGiteaTree: skipped (tree already loaded by giteaWorkspace component)'); + return; + } + console.log('loadGiteaTree: fetching /api/gitea/projects/' + this.giteaOwner + '/' + this.giteaRepo + '/tree'); fetch('/api/gitea/projects/' + this.giteaOwner + '/' + this.giteaRepo + '/tree') - .then(r => r.json()) - .then(data => { + .then(function(r) { + if (!r.ok) throw new Error('HTTP ' + r.status + ': ' + r.statusText); + return r.json(); + }) + .then(function(data) { this.giteaTree = data.tree || []; - // Render tree items into the sidebar workspace section - var container = document.getElementById('sidebar-workspace-items'); - if (!container) return; + if (!container) { + console.log('loadGiteaTree: #sidebar-workspace-items not found'); + return; + } container.innerHTML = ''; if (!this.giteaTree.length) { container.innerHTML = ''; @@ -897,8 +911,14 @@ li.innerHTML = '' + icon + '' + item.name + ''; container.appendChild(li); }); - }) - .catch(function() { /* silently ignore */ }); + console.log('loadGiteaTree: rendered ' + this.giteaTree.length + ' items'); + }.bind(this)) + .catch(function(err) { + console.error('loadGiteaTree failed:', err.message || err); + if (container) { + container.innerHTML = ''; + } + }); }, newPageInWorkspace() { const name = prompt('File name:'); diff --git a/app/templates/gitea_workspace.html b/app/templates/gitea_workspace.html index 27a0dd5..9eda4fa 100644 --- a/app/templates/gitea_workspace.html +++ b/app/templates/gitea_workspace.html @@ -218,8 +218,7 @@ function giteaWorkspace() { cb.style.cssText = 'flex-shrink:0;margin:0;display:none;'; cb.addEventListener('click', function(ev) { ev.stopPropagation(); - var gw = document.querySelector('[x-data]').__x.$data; - gw.selectItem(item.path, li, ev); + self.selectItem(item.path, li, ev); }); li.appendChild(cb); // Icon @@ -234,8 +233,7 @@ function giteaWorkspace() { nameSpan.addEventListener('dblclick', function(ev) { ev.preventDefault(); ev.stopPropagation(); - var gw = document.querySelector('[x-data]').__x.$data; - gw.startInlineRename(nameSpan, item.path, li); + self.startInlineRename(nameSpan, item.path, li); }); li.appendChild(nameSpan); container.appendChild(li); @@ -250,9 +248,8 @@ function giteaWorkspace() { pli.innerHTML = '🔒Private Pages'; pli.addEventListener('click', function(e) { e.preventDefault(); e.stopPropagation(); - var gw = document.querySelector('[x-data]').__x.$data; - gw.showPrivate = true; gw.showFile = false; gw.showEditor = false; - gw.loadPrivatePages(); + self.showPrivate = true; self.showFile = false; self.showEditor = false; + self.loadPrivatePages(); }); container.appendChild(pli); } catch(e) { console.error('Sidebar tree load failed:', e); } @@ -314,6 +311,7 @@ function giteaWorkspace() { }, async loadSubdir(path, el) { + var self = this; // Check if already loaded var ul = el.querySelector('ul'); if (ul) { @@ -343,8 +341,7 @@ function giteaWorkspace() { cb.style.cssText = 'flex-shrink:0;margin:0;display:none;'; cb.addEventListener('click', function(ev) { ev.stopPropagation(); - var gw = document.querySelector('[x-data]').__x.$data; - gw.selectItem(child.path, li, ev); + self.selectItem(child.path, li, ev); }); li.appendChild(cb); // Icon @@ -358,8 +355,7 @@ function giteaWorkspace() { nameSpan.addEventListener('dblclick', function(ev) { ev.preventDefault(); ev.stopPropagation(); - var gw = document.querySelector('[x-data]').__x.$data; - gw.startInlineRename(nameSpan, child.path, li); + self.startInlineRename(nameSpan, child.path, li); }); li.appendChild(nameSpan); ul.appendChild(li);