diff --git a/frontend/js/app.js b/frontend/js/app.js index 632a5ae..e8c0219 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -1087,8 +1087,7 @@ document.addEventListener('alpine:init', () => { _pollTimer: null, async init() { - await this.load() // modules installés d'abord (loadStore en a besoin) - await this.loadStore() + await Promise.all([this.load(), this.loadStore()]) }, destroy() { @@ -1108,27 +1107,16 @@ document.addEventListener('alpine:init', () => { async loadStore() { this.storeLoading = true this.storeError = '' - // Fetch directement depuis le navigateur (le backend n'a pas forcément accès internet) - const FORGEJO_URL = 'https://git.geronzi.fr' - const FORGEJO_ORG = 'proxmoxPanel' try { - const res = await fetch(`${FORGEJO_URL}/api/v1/orgs/${FORGEJO_ORG}/repos?limit=50`) - if (!res.ok) { - this.storeError = `Erreur Forgejo (HTTP ${res.status})` + const res = await apiFetch('/api/registry/modules') + if (res.ok) { + const data = await res.json() + this.storeModules = data.modules || [] + if (data.error) this.storeError = data.error + } else { + this.storeError = `Erreur serveur (HTTP ${res.status})` this.storeModules = [] - return } - const repos = await res.json() - const exclude = new Set(['core']) - const installedIDs = new Set(this.modules.map(m => m.id)) - this.storeModules = repos - .filter(r => !exclude.has(r.name)) - .map(r => ({ - id: r.name, - description: r.description || '', - repo_url: r.html_url, - installed: installedIDs.has(r.name), - })) } catch(e) { this.storeError = 'Impossible de joindre le store : ' + e.message this.storeModules = []