diff --git a/custom_components/bahmcloud_store/panel/app.js b/custom_components/bahmcloud_store/panel/app.js index 588f59e..f625111 100644 --- a/custom_components/bahmcloud_store/panel/app.js +++ b/custom_components/bahmcloud_store/panel/app.js @@ -29,6 +29,7 @@ class BahmcloudStorePanel extends HTMLElement { this._installingRepoId = null; this._updatingRepoId = null; + this._uninstallingRepoId = null; this._restartRequired = false; this._lastActionMsg = null; } @@ -141,6 +142,36 @@ class BahmcloudStorePanel extends HTMLElement { } } + async _uninstallRepo(repoId) { + if (!repoId) return; + if (this._installingRepoId || this._updatingRepoId || this._uninstallingRepoId) return; + + const r = this._repoById(repoId); + const name = this._safeText(r?.name) || repoId; + + const ok = window.confirm(`Uninstall "${name}"?\n\nThis will delete the integration folder(s) from /config/custom_components. A restart will be required.`); + if (!ok) return; + + this._uninstallingRepoId = repoId; + this._lastActionMsg = null; + this.requestUpdate(); + + try { + const resp = await this._hass.callApi("post", `bcs/uninstall?repo_id=${encodeURIComponent(repoId)}`, {}); + if (resp && resp.ok) { + this._restartRequired = !!resp.restart_required; + this._lastActionMsg = "Uninstalled. Restart required."; + } else { + this._lastActionMsg = (resp && resp.message) ? String(resp.message) : "Uninstall failed."; + } + } catch (e) { + this._lastActionMsg = e && e.message ? e.message : "Uninstall failed."; + } finally { + this._uninstallingRepoId = null; + await this._load(); + } + } + async _restartHA() { if (!this._hass) return; try { @@ -436,15 +467,15 @@ class BahmcloudStorePanel extends HTMLElement {
@@ -506,7 +537,7 @@ class BahmcloudStorePanel extends HTMLElement { : ""; if (this._loading) { - content.innerHTML = `${err}