diff --git a/dashboard/src/components/Terminal.vue b/dashboard/src/components/Terminal.vue index ce0a4ed9b..998178191 100644 --- a/dashboard/src/components/Terminal.vue +++ b/dashboard/src/components/Terminal.vue @@ -149,7 +149,7 @@ export default { if (!confirmed) return; this.busyRestart = true; - await this.appsModel.restart(); + await this.appsModel.restart(this.id); this.busyRestart = false; }, async connect(retry = false) { @@ -221,27 +221,27 @@ export default { this.id = id; this.name = id; - this.appsModel = AppsModel.create(API_ORIGIN, this.accessToken, this.id); + this.appsModel = AppsModel.create(API_ORIGIN, this.accessToken); this.directoryModel = createDirectoryModel(API_ORIGIN, this.accessToken, `apps/${id}`); - try { - const app = await this.appsModel.get(); - this.name = `${app.label || app.fqdn} (${app.manifest.title})`; - this.addons = app.manifest.addons; - this.manifestVersion = app.manifest.manifestVersion; - this.showFilemanager = !!app.manifest.addons.localstorage; - - this.schedulerMenuModel = !app.manifest.addons.scheduler ? [] : Object.keys(app.manifest.addons.scheduler).map((k) => { - return { - label: k, - action: () => this.terminalInject('scheduler', app.manifest.addons.scheduler[k].command) - }; - }); - } catch (e) { - console.error(`Failed to get app info for ${this.id}:`, e); + const [error, app] = await this.appsModel.get(this.id); + if (error) { + console.error(`Failed to get app info for ${this.id}:`, error); return this.onFatalError(`Unknown app ${this.id}. Cannot continue.`); } + this.name = `${app.label || app.fqdn} (${app.manifest.title})`; + this.addons = app.manifest.addons; + this.manifestVersion = app.manifest.manifestVersion; + this.showFilemanager = !!app.manifest.addons.localstorage; + + this.schedulerMenuModel = !app.manifest.addons.scheduler ? [] : Object.keys(app.manifest.addons.scheduler).map((k) => { + return { + label: k, + action: () => this.terminalInject('scheduler', app.manifest.addons.scheduler[k].command) + }; + }); + window.document.title = `Terminal - ${this.name}`; window.addEventListener('beforeunload', function (e) { diff --git a/dashboard/src/models/AppsModel.js b/dashboard/src/models/AppsModel.js index 604bd642a..2f337775c 100644 --- a/dashboard/src/models/AppsModel.js +++ b/dashboard/src/models/AppsModel.js @@ -64,7 +64,7 @@ function appProgressMessage(app) { return app.message || (app.error ? app.error.message : ''); } -function create(origin, accessToken, id) { +function create(origin, accessToken) { async function getTask(appId) { let error, result; try { @@ -160,7 +160,7 @@ function create(origin, accessToken, id) { if (error || result.status !== 200) return [error || result]; return [null, result.body]; }, - async restart() { + async restart(id) { let error, result; try { result = await fetcher.post(`${origin}/api/v1/apps/${id}/restart`, null, { access_token: accessToken });