diff --git a/dashboard/src/components/LogsViewer.vue b/dashboard/src/components/LogsViewer.vue index d960140ff..9a3baa166 100644 --- a/dashboard/src/components/LogsViewer.vue +++ b/dashboard/src/components/LogsViewer.vue @@ -49,7 +49,8 @@ export default { this.busyRestart = true; - await this.appsModel.restart(); + const [error] = await this.appsModel.restart(this.id); + if (error) return console.error(error); this.busyRestart = false; } @@ -98,15 +99,13 @@ export default { if (this.type === 'app') { this.appsModel = AppsModel.create(); - try { - const app = await this.appsModel.get(); - this.name = `${app.label || app.fqdn} (${app.manifest.title})`; - this.showFilemanager = !!app.manifest.addons.localstorage; - this.showTerminal = app.manifest.id !== 'io.cloudron.builtin.appproxy'; - this.showRestart = app.manifest.id !== 'io.cloudron.builtin.appproxy'; - } catch (e) { - console.error(`Failed to get app info for ${this.id}:`, e); - } + const [error, app] = await this.appsModel.get(this.id); + if (error) return console.error(error); + + this.name = `${app.label || app.fqdn} (${app.manifest.title})`; + this.showFilemanager = !!app.manifest.addons.localstorage; + this.showTerminal = app.manifest.id !== 'io.cloudron.builtin.appproxy'; + this.showRestart = app.manifest.id !== 'io.cloudron.builtin.appproxy'; } window.document.title = `Logs Viewer - ${this.name}`; diff --git a/dashboard/src/components/Terminal.vue b/dashboard/src/components/Terminal.vue index a97b1364a..712bba9e3 100644 --- a/dashboard/src/components/Terminal.vue +++ b/dashboard/src/components/Terminal.vue @@ -149,7 +149,10 @@ export default { if (!confirmed) return; this.busyRestart = true; - await this.appsModel.restart(this.id); + + const [error] = await this.appsModel.restart(this.id); + if (error) return console.error(error); + this.busyRestart = false; }, async connect(retry = false) { diff --git a/dashboard/src/components/app/Repair.vue b/dashboard/src/components/app/Repair.vue new file mode 100644 index 000000000..a18d90f6d --- /dev/null +++ b/dashboard/src/components/app/Repair.vue @@ -0,0 +1,82 @@ + + + diff --git a/dashboard/src/models/AppsModel.js b/dashboard/src/models/AppsModel.js index f1ea120cb..1a97317d8 100644 --- a/dashboard/src/models/AppsModel.js +++ b/dashboard/src/models/AppsModel.js @@ -171,29 +171,28 @@ function create() { return [null, result.body]; }, async restart(id) { - let error, result; + let result; try { result = await fetcher.post(`${origin}/api/v1/apps/${id}/restart`, null, { access_token: accessToken }); } catch (e) { - error = e; + return [e]; } - if (error || result.status !== 202) { - console.error(`Failed to restart app ${this.id}`, error || result.status); - return; - } + if (result.status !== 202) return [result]; while(true) { let result; try { result = await fetcher.get(`${origin}/api/v1/apps/${id}`, { access_token: accessToken }); } catch (e) { - console.error(e); + return [e]; } - if (result && result.status === 200 && result.body.installationState === ISTATES.INSTALLED) break; + if (result.status !== 200) return [result]; - await sleep(2000); + // are we done here? + if (result.body.installationState !== ISTATES.INSTALLED) await sleep(2000); + else return [null]; } }, async start(id) { diff --git a/dashboard/src/views/AppConfigureView.vue b/dashboard/src/views/AppConfigureView.vue index 8381536a1..69915901b 100644 --- a/dashboard/src/views/AppConfigureView.vue +++ b/dashboard/src/views/AppConfigureView.vue @@ -11,6 +11,7 @@ import { Button, ButtonGroup } from 'pankow'; import Info from '../components/app/Info.vue'; import Security from '../components/app/Security.vue'; import Cron from '../components/app/Cron.vue'; +import Repair from '../components/app/Repair.vue'; import Eventlog from '../components/app/Eventlog.vue'; import Updates from '../components/app/Updates.vue'; import Uninstall from '../components/app/Uninstall.vue'; @@ -186,7 +187,7 @@ onBeforeUnmount(() => {
-
+