diff --git a/dashboard/src/components/AppInstallDialog.vue b/dashboard/src/components/AppInstallDialog.vue index 15d51f049..968a0efa9 100644 --- a/dashboard/src/components/AppInstallDialog.vue +++ b/dashboard/src/components/AppInstallDialog.vue @@ -60,6 +60,9 @@ const secondaryDomains = ref({}); const upstreamUri = ref(''); async function submit() { + formError.value = {}; + busy.value = true; + const config = { subdomain: location.value, domain: domain.value.domain, @@ -88,25 +91,23 @@ async function submit() { } config.secondaryDomains = finalSecondaryDomains; - if (manifest.value.id === PROXY_APP_ID) { - config.upstreamUri = upstreamUri.value; - } + if (manifest.value.id === PROXY_APP_ID) config.upstreamUri = upstreamUri.value; - busy.value = true; - const error = await appsModel.install(manifest.value, config); - busy.value = false; + const [error] = await appsModel.install(manifest.value, config); if (!error) { dialog.value.close(); return window.location.href = '#/apps'; } - formError.value = {}; + busy.value = false; if (error.status === 'Conflict' && error.message.indexOf('port') !== -1) { const match = error.message.match(/.*port.(.*)/); formError.value.port = match ? parseInt(match[1]) : null; } else if (error.status === 'Conflict' && error.message.indexOf('primary location') !== -1) { formError.value.location = true; + } else if (error.status === 412) { + formError.value.generic = error.body.message; } else { console.error('Failed to install:', error); } @@ -182,6 +183,8 @@ defineExpose({
+
{{ formError.generic }}
+
diff --git a/dashboard/src/models/AppsModel.js b/dashboard/src/models/AppsModel.js index 3e4187218..ddbe4be9f 100644 --- a/dashboard/src/models/AppsModel.js +++ b/dashboard/src/models/AppsModel.js @@ -176,19 +176,16 @@ function create() { backupId: config.backupId // when restoring from archive }; - let error, result; + let result; try { result = await fetcher.post(`${API_ORIGIN}/api/v1/apps`, data, { access_token: accessToken }); } catch (e) { - error = e; + return [e]; } - if (error || result.status !== 202) { - console.error('Failed to install app.', error || result.status); - return error || result.body; - } + if (result.status !== 202) return [result]; - return ''; + return [null]; }, async list() { let error, result;