From 6a46132fd7301092b446065b116522b07dcac761 Mon Sep 17 00:00:00 2001 From: Axolotle Date: Mon, 12 Oct 2020 17:36:47 +0200 Subject: [PATCH] modify imports of api module --- app/src/api/api.js | 5 +++++ app/src/api/handlers.js | 3 ++- app/src/components/ApiWaitOverlay.vue | 3 ++- app/src/store/data.js | 2 +- app/src/store/info.js | 3 ++- app/src/views/PostInstall.vue | 2 +- app/src/views/app/AppActions.vue | 3 ++- app/src/views/app/AppCatalog.vue | 2 +- app/src/views/app/AppConfigPanel.vue | 3 ++- app/src/views/app/AppInfo.vue | 2 +- app/src/views/app/AppInstall.vue | 3 ++- app/src/views/app/AppList.vue | 2 +- app/src/views/backup/BackupCreate.vue | 2 +- app/src/views/backup/BackupInfo.vue | 2 +- app/src/views/backup/BackupList.vue | 2 +- app/src/views/diagnosis/Diagnosis.vue | 2 +- app/src/views/domain/DomainCert.vue | 2 +- app/src/views/domain/DomainDns.vue | 2 +- app/src/views/service/ServiceInfo.vue | 2 +- app/src/views/service/ServiceList.vue | 2 +- app/src/views/tool/ToolAdminpw.vue | 2 +- app/src/views/tool/ToolFirewall.vue | 2 +- app/src/views/tool/ToolLog.vue | 3 ++- app/src/views/tool/ToolLogs.vue | 4 ++-- app/src/views/tool/ToolMigrations.vue | 2 +- app/src/views/tool/ToolPower.vue | 2 +- app/src/views/update/SystemUpdate.vue | 4 ++-- 27 files changed, 40 insertions(+), 28 deletions(-) diff --git a/app/src/api/api.js b/app/src/api/api.js index 429443a4..c9bf6932 100644 --- a/app/src/api/api.js +++ b/app/src/api/api.js @@ -7,6 +7,11 @@ import store from '@/store' import { handleResponse, handleError } from './handlers' import { objectToParams } from '@/helpers/commons' +/** + * A digested fetch response as an object, a string or an error. + * @typedef {(Object|string|Error)} DigestedResponse + */ + export default { options: { credentials: 'include', diff --git a/app/src/api/handlers.js b/app/src/api/handlers.js index b248e2a4..6f8bbec3 100644 --- a/app/src/api/handlers.js +++ b/app/src/api/handlers.js @@ -4,9 +4,10 @@ import store from '@/store' * Handler for API responses. * * @param {Response} response - A fetch `Response` object. - * @return {DigestedResponse} Parsed response's json, response's text or an error. + * @return {(Object|String)} Parsed response's json or response's text. */ async function handleResponse (response) { + store.dispatch('SERVER_RESPONDED') if (!response.ok) return handleError(response) // FIXME the api should always return json objects const responseText = await response.text() diff --git a/app/src/components/ApiWaitOverlay.vue b/app/src/components/ApiWaitOverlay.vue index a4eff136..2c1988c8 100644 --- a/app/src/components/ApiWaitOverlay.vue +++ b/app/src/components/ApiWaitOverlay.vue @@ -12,6 +12,7 @@ + @@ -27,7 +28,7 @@ - + ({ diff --git a/app/src/store/info.js b/app/src/store/info.js index 346ddd1d..6e33cdd2 100644 --- a/app/src/store/info.js +++ b/app/src/store/info.js @@ -1,6 +1,7 @@ import Vue from 'vue' -import api, { timeout } from '@/helpers/api' +import api from '@/api' import router from '@/router' +import { timeout } from '@/helpers/commons' export default { state: { diff --git a/app/src/views/PostInstall.vue b/app/src/views/PostInstall.vue index 1913b007..ebf6038c 100644 --- a/app/src/views/PostInstall.vue +++ b/app/src/views/PostInstall.vue @@ -61,7 +61,7 @@