From cc52ede23c6b5aee1fd69864956aa546b9ab9477 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Thu, 23 Apr 2020 17:32:05 +0200 Subject: [PATCH 01/21] Use proper available errData instead of data --- src/_helpers/util.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/_helpers/util.js b/src/_helpers/util.js index 236e2a0..06512bf 100644 --- a/src/_helpers/util.js +++ b/src/_helpers/util.js @@ -155,18 +155,18 @@ export const util = { return function (response) { return response.text().then(text => { if (!response.ok) { + const errData = JSON.parse('' + text) || text; + if (response.status === 404) { // todo: show nicer error message - const errData = JSON.parse(''+text); - console.log('handleCrudResponse: received 404: ' + text); + console.log('handleCrudResponse: received 404: ' + (errData.resource || errData)); } else if (response.status === 422) { - const errData = JSON.parse(''+text); console.log('handleCrudResponse: received 422, error: ' + text); util.setValidationErrors(errData, messages, errors); } - const error = (data && data.message) || response.statusText; + const error = errData.message || errData || response.statusText; return Promise.reject(error); } return text; -- 2.17.1 From 7fedd9e53888974c1639125c1fd7591407e58722 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Thu, 23 Apr 2020 17:32:59 +0200 Subject: [PATCH 02/21] Ass initial support for downloading account data --- src/_services/user.service.js | 5 +++++ src/_store/account.module.js | 28 +++++++++++++++++++++++++++- src/account/profile/PolicyPage.vue | 20 ++++++++++++++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/_services/user.service.js b/src/_services/user.service.js index e35d556..d1e7bb6 100644 --- a/src/_services/user.service.js +++ b/src/_services/user.service.js @@ -12,6 +12,7 @@ export const userService = { register, searchAccounts, getMe, + requireAccountDownload, getUserById, getPolicyByUserId, updatePolicyByUserId, @@ -91,6 +92,10 @@ function getMe(messages, errors) { ).then(util.handleCrudResponse(messages, errors)); } +function requireAccountDownload(messages, errors) { + return fetch(`${config.apiUrl}/me/download`, util.postWithAuth()).then(util.handlePlaintextResponse(messages, errors)); +} + function getUserById(userId, messages, errors) { return fetch(`${config.apiUrl}/users/${userId}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors)); } diff --git a/src/_store/account.module.js b/src/_store/account.module.js index 7ebba7f..611f854 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -19,6 +19,7 @@ const defaultStatus = { authenticating: false, sendingVerification: false, sendingResetPasswordMessage: false, + requiringAccountDownload: false, registrationError: null }; @@ -29,6 +30,7 @@ const state = { actionStatus: {}, loginError: null, resetPasswordMessageSent: false, + requiringAccountDownloadRequestSent: false, locale: user == null ? 'detect' : (typeof user.locale !== 'undefined' && user.locale !== null ? user.locale : 'detect') }; @@ -179,6 +181,14 @@ const actions = { }, error => commit('resendVerificationCodeFailure', error) ); + }, + requireAccountDownload({ commit }, {messages, errors}) { + commit('requiringAccountDownloadRequest'); + userService.requireAccountDownload(messages, errors) + .then( + ok => commit('requiringAccountDownloadSuccess'), + error => commit('requiringAccountDownloadFailure', error) + ); } }; @@ -367,7 +377,23 @@ const mutations = { resendVerificationCodeFailure(state, error) { state.status = Object.assign({}, state.status, {sendingVerification: false}); state.actionStatus = { error: error, type: 'verify' }; - } + }, + + requiringAccountDownloadRequest(state) { + state.status = Object.assign({}, {requiringAccountDownload: true}); + state.actionStatus = { requesting: true, type: 'download' }; + state.requiringAccountDownloadRequestSent = false; + }, + requiringAccountDownloadSuccess(state) { + state.status = Object.assign({}, {requiringAccountDownload: false}); + state.actionStatus = { success: true, type: 'download' }; + state.requiringAccountDownloadRequestSent = true; + }, + requiringAccountDownloadFailure(state, error) { + state.status = Object.assign({}, {requiringAccountDownload: false}); + state.actionStatus = { error: error, type: 'download' }; + console.log('requiringAccountDownloadFailure failed: ' + JSON.stringify(error)); + }, }; export const account = { diff --git a/src/account/profile/PolicyPage.vue b/src/account/profile/PolicyPage.vue index 5248ad7..1268232 100644 --- a/src/account/profile/PolicyPage.vue +++ b/src/account/profile/PolicyPage.vue @@ -10,6 +10,15 @@

{{messages.form_title_account_policy}} - {{this.userId}}

+
+
+ + + +
{{ errors }}
+ {{messages.field_label_account_download_requested_notice}} +
+
@@ -390,7 +399,7 @@ } }, computed: { - ...mapState('account', ['actionStatus']), + ...mapState('account', ['actionStatus', 'requiringAccountDownloadRequestSent']), ...mapState('system', [ 'messages', 'accountDeletionOptions', 'timeDurationOptions', 'timeDurationOptionsReversed', 'contactTypes', 'detectedLocale', 'countries' @@ -425,7 +434,9 @@ } }, methods: { - ...mapActions('account', ['approveAction', 'denyAction', 'sendAuthenticatorCode', 'resendVerificationCode']), + ...mapActions('account', [ + 'approveAction', 'denyAction', 'sendAuthenticatorCode', 'resendVerificationCode', 'requireAccountDownload' + ]), ...mapActions('users', [ 'getPolicyByUserId', 'updatePolicyByUserId', 'addPolicyContactByUserId', 'removePolicyContactByUserId', ]), @@ -519,6 +530,11 @@ errors: this.errors }); }, + downloadAccount() { + this.errors.clear(); + this.requireAccountDownload({ messages: this.messages, errors: this.errors }); + return false; // do not follow the click + }, startVerifyContact(contact) { // console.log('startVerifyContact: '+JSON.stringify(contact)); this.verifyingContact = contact.uuid; -- 2.17.1 From becccf8dff2d7928436692c7e4a8b342ff08989e Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Thu, 23 Apr 2020 17:33:08 +0200 Subject: [PATCH 03/21] Remove not needed comma --- src/account/profile/PolicyPage.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/account/profile/PolicyPage.vue b/src/account/profile/PolicyPage.vue index 1268232..739c8fd 100644 --- a/src/account/profile/PolicyPage.vue +++ b/src/account/profile/PolicyPage.vue @@ -438,7 +438,7 @@ 'approveAction', 'denyAction', 'sendAuthenticatorCode', 'resendVerificationCode', 'requireAccountDownload' ]), ...mapActions('users', [ - 'getPolicyByUserId', 'updatePolicyByUserId', 'addPolicyContactByUserId', 'removePolicyContactByUserId', + 'getPolicyByUserId', 'updatePolicyByUserId', 'addPolicyContactByUserId', 'removePolicyContactByUserId' ]), ...mapGetters('users', ['loading']), isAuthenticator(val) { return window.isAuthenticator(val); }, -- 2.17.1 From 2da9cb655a2a47206f30fe05dffaa04750b3e34e Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Fri, 24 Apr 2020 09:01:52 +0200 Subject: [PATCH 04/21] Fix log lines' prefix --- src/_helpers/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_helpers/util.js b/src/_helpers/util.js index 06512bf..a7cc89b 100644 --- a/src/_helpers/util.js +++ b/src/_helpers/util.js @@ -159,10 +159,10 @@ export const util = { if (response.status === 404) { // todo: show nicer error message - console.log('handleCrudResponse: received 404: ' + (errData.resource || errData)); + console.log('handlePlaintextResponse: received 404: ' + (errData.resource || errData)); } else if (response.status === 422) { - console.log('handleCrudResponse: received 422, error: ' + text); + console.log('handlePlaintextResponse: received 422, error: ' + text); util.setValidationErrors(errData, messages, errors); } -- 2.17.1 From 80126794d4a346c22289c2bdec469e238b961fe9 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Fri, 24 Apr 2020 11:42:08 +0200 Subject: [PATCH 05/21] Better log line on HTTP 422 error --- src/_helpers/util.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/_helpers/util.js b/src/_helpers/util.js index a7cc89b..068af8f 100644 --- a/src/_helpers/util.js +++ b/src/_helpers/util.js @@ -162,7 +162,8 @@ export const util = { console.log('handlePlaintextResponse: received 404: ' + (errData.resource || errData)); } else if (response.status === 422) { - console.log('handlePlaintextResponse: received 422, error: ' + text); + console.log('handlePlaintextResponse: received 422, error: ' + + ((errData.message + ": " + errData.invalidValue) || errData)); util.setValidationErrors(errData, messages, errors); } -- 2.17.1 From f5100c38999227e24e53db483a109f6396b680b5 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Fri, 24 Apr 2020 11:42:36 +0200 Subject: [PATCH 06/21] Fix error and description line for new account download button --- src/account/profile/PolicyPage.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/account/profile/PolicyPage.vue b/src/account/profile/PolicyPage.vue index 739c8fd..cf0217c 100644 --- a/src/account/profile/PolicyPage.vue +++ b/src/account/profile/PolicyPage.vue @@ -15,8 +15,8 @@ -
{{ errors }}
- {{messages.field_label_account_download_requested_notice}} +
{{ errors.first('download') }}
+
{{messages.field_label_account_download_requested_notice}}

-- 2.17.1 From 52dd0ad8337aee0d2a92e459840d8c23659c269a Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Fri, 24 Apr 2020 11:54:14 +0200 Subject: [PATCH 07/21] Hide download account button for root and other users --- src/account/profile/PolicyPage.vue | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/account/profile/PolicyPage.vue b/src/account/profile/PolicyPage.vue index cf0217c..304c174 100644 --- a/src/account/profile/PolicyPage.vue +++ b/src/account/profile/PolicyPage.vue @@ -10,14 +10,16 @@

{{messages.form_title_account_policy}} - {{this.userId}}

-
-
- - - -
{{ errors.first('download') }}
-
{{messages.field_label_account_download_requested_notice}}
-
+ +
+
+ + + +
{{ errors.first('download') }}
+
{{messages.field_label_account_download_requested_notice}}
+
+

-- 2.17.1 From dc0f327dc19dbae625979c34cf4ec538560dea66 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Fri, 24 Apr 2020 12:23:23 +0200 Subject: [PATCH 08/21] Remove not needed status flag --- src/_store/account.module.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/_store/account.module.js b/src/_store/account.module.js index 611f854..fc6c075 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -19,7 +19,6 @@ const defaultStatus = { authenticating: false, sendingVerification: false, sendingResetPasswordMessage: false, - requiringAccountDownload: false, registrationError: null }; @@ -380,17 +379,14 @@ const mutations = { }, requiringAccountDownloadRequest(state) { - state.status = Object.assign({}, {requiringAccountDownload: true}); state.actionStatus = { requesting: true, type: 'download' }; state.requiringAccountDownloadRequestSent = false; }, requiringAccountDownloadSuccess(state) { - state.status = Object.assign({}, {requiringAccountDownload: false}); state.actionStatus = { success: true, type: 'download' }; state.requiringAccountDownloadRequestSent = true; }, requiringAccountDownloadFailure(state, error) { - state.status = Object.assign({}, {requiringAccountDownload: false}); state.actionStatus = { error: error, type: 'download' }; console.log('requiringAccountDownloadFailure failed: ' + JSON.stringify(error)); }, -- 2.17.1 From 83375cf379a17f631865ff6e634c025f10bc584d Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Mon, 27 Apr 2020 16:50:00 +0200 Subject: [PATCH 09/21] Load account data as JSON on request in background --- src/_helpers/router.js | 4 ++++ src/_services/user.service.js | 5 +++++ src/_store/account.module.js | 22 +++++++++++++++++++++- src/account/profile/PolicyPage.vue | 13 +++++++++---- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/_helpers/router.js b/src/_helpers/router.js index aee0e2f..850470a 100644 --- a/src/_helpers/router.js +++ b/src/_helpers/router.js @@ -69,6 +69,10 @@ export const router = new Router({ { path: '/me', component: ProfilePage }, { path: '/me/policy', component: PolicyPage }, + { + path: '/me/download/:uuid', + redirect: r => { return { path: '/me/policy', query: { download: r.params.uuid } } } + }, { path: '/me/action', component: ActionPage }, { path: '/me/changePassword', component: ChangePasswordPage }, { path: '/me/setPassword/:code', component: SetPasswordPage }, diff --git a/src/_services/user.service.js b/src/_services/user.service.js index d1e7bb6..d3e5afc 100644 --- a/src/_services/user.service.js +++ b/src/_services/user.service.js @@ -13,6 +13,7 @@ export const userService = { searchAccounts, getMe, requireAccountDownload, + downloadAccount, getUserById, getPolicyByUserId, updatePolicyByUserId, @@ -96,6 +97,10 @@ function requireAccountDownload(messages, errors) { return fetch(`${config.apiUrl}/me/download`, util.postWithAuth()).then(util.handlePlaintextResponse(messages, errors)); } +function downloadAccount(token, messages, errors) { + return fetch(`${config.apiUrl}/me/download/${token}`, util.postWithAuth()).then(util.handlePlaintextResponse(messages, errors)); +} + function getUserById(userId, messages, errors) { return fetch(`${config.apiUrl}/users/${userId}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors)); } diff --git a/src/_store/account.module.js b/src/_store/account.module.js index fc6c075..6301645 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -188,6 +188,14 @@ const actions = { ok => commit('requiringAccountDownloadSuccess'), error => commit('requiringAccountDownloadFailure', error) ); + }, + downloadAccount({ commit }, {token, messages, errors}) { + commit('downloadAccountRequest'); + userService.downloadAccount(token, messages, errors) + .then( + ok => commit('downloadAccountSuccess'), + error => commit('downloadAccountFailure', error) + ); } }; @@ -388,8 +396,20 @@ const mutations = { }, requiringAccountDownloadFailure(state, error) { state.actionStatus = { error: error, type: 'download' }; - console.log('requiringAccountDownloadFailure failed: ' + JSON.stringify(error)); + console.log('requiringAccountDownloadFailure: ' + JSON.stringify(error)); + }, + + // using the same type for action status as in requiringDownload... intentionally to reuse errors field: + downloadAccountRequest(state) { + state.actionStatus = { requesting: true, type: 'download' }; + }, + downloadAccountSuccess(state) { + state.actionStatus = { success: true, type: 'download' }; }, + downloadAccountFailure(state, error) { + state.actionStatus = { error: error, type: 'download' }; + console.log('downloadAccountFailure: ' + JSON.stringify(error)); + } }; export const account = { diff --git a/src/account/profile/PolicyPage.vue b/src/account/profile/PolicyPage.vue index 304c174..f36adc2 100644 --- a/src/account/profile/PolicyPage.vue +++ b/src/account/profile/PolicyPage.vue @@ -14,7 +14,7 @@
- +
{{ errors.first('download') }}
{{messages.field_label_account_download_requested_notice}}
@@ -437,7 +437,8 @@ }, methods: { ...mapActions('account', [ - 'approveAction', 'denyAction', 'sendAuthenticatorCode', 'resendVerificationCode', 'requireAccountDownload' + 'approveAction', 'denyAction', 'sendAuthenticatorCode', 'resendVerificationCode', + 'requireAccountDownload', 'downloadAccount' ]), ...mapActions('users', [ 'getPolicyByUserId', 'updatePolicyByUserId', 'addPolicyContactByUserId', 'removePolicyContactByUserId' @@ -532,7 +533,7 @@ errors: this.errors }); }, - downloadAccount() { + clickRequireAccountDownload() { this.errors.clear(); this.requireAccountDownload({ messages: this.messages, errors: this.errors }); return false; // do not follow the click @@ -670,6 +671,10 @@ // console.log('PolicyPage.created: $route.params='+JSON.stringify(this.$route.query)); this.inboundAction = util.setInboundAction(this.$route); this.newContactSmsCountry = countryFromLocale(this.detectedLocale); + + if (this.$route.query.hasOwnProperty('download')) { + this.downloadAccount({ token: this.$route.query.download, messages: this.messages, errors: this.errors }); + } } }; - \ No newline at end of file + -- 2.17.1 From 293250788be680c5a3cd98686581eb1565c1ba59 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Tue, 28 Apr 2020 16:46:25 +0200 Subject: [PATCH 10/21] Force download of account data json as file --- src/_helpers/util.js | 14 ++++++++++++++ src/_services/user.service.js | 8 ++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/_helpers/util.js b/src/_helpers/util.js index 068af8f..e262f6c 100644 --- a/src/_helpers/util.js +++ b/src/_helpers/util.js @@ -175,6 +175,20 @@ export const util = { } }, + handleDataToDownloadAsFile: function(fileName) { + return function(data) { + const link = document.createElement('a'); + link.href = window.URL.createObjectURL(new Blob([data])); + link.setAttribute('download', fileName); + + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + + return 'ok'; + }; + }, + setValidationErrors: function(data, messages, errors, enableTotpModal) { const errs = []; for (let i=0; i Date: Wed, 29 Apr 2020 11:44:08 +0200 Subject: [PATCH 11/21] Beautify JSON before downloading it as file --- src/_helpers/util.js | 12 +++++------- src/_services/user.service.js | 10 +++++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/_helpers/util.js b/src/_helpers/util.js index e262f6c..33ae621 100644 --- a/src/_helpers/util.js +++ b/src/_helpers/util.js @@ -175,16 +175,14 @@ export const util = { } }, - handleDataToDownloadAsFile: function(fileName) { + handleDataToDownloadAsFile: function(fileName, mimeType) { return function(data) { + // Original taken from: https://javascript.info/blob#blob-as-url const link = document.createElement('a'); - link.href = window.URL.createObjectURL(new Blob([data])); - link.setAttribute('download', fileName); - - document.body.appendChild(link); + link.download = fileName; + link.href = URL.createObjectURL(new Blob([data], {type: mimeType})); link.click(); - document.body.removeChild(link); - + URL.revokeObjectURL(link.href); return 'ok'; }; }, diff --git a/src/_services/user.service.js b/src/_services/user.service.js index b276da6..932b7c1 100644 --- a/src/_services/user.service.js +++ b/src/_services/user.service.js @@ -102,7 +102,15 @@ function downloadAccount(token, messages, errors) { return fetch(`${config.apiUrl}/me/download/${token}`, util.postWithAuth()) .then(util.handlePlaintextResponse(messages, errors)) - .then(util.handleDataToDownloadAsFile(fileName)); + .then(text => { + try { + return JSON.stringify(JSON.parse(text, (_, v) => typeof v === 'string' ? (JSON.parse(v) || v) : v), + null, '\t'); + } catch(err) { + Promise.reject(text || err); + } + }) + .then(util.handleDataToDownloadAsFile(fileName, 'application/json')); } function getUserById(userId, messages, errors) { -- 2.17.1 From be98ab96d1dff24229909990d3758e90e662a2d9 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 29 Apr 2020 13:07:18 +0200 Subject: [PATCH 12/21] Use state's new property instead of status' property --- src/_store/account.module.js | 9 +++++---- src/account/profile/PolicyPage.vue | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/_store/account.module.js b/src/_store/account.module.js index 6301645..a250021 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -19,7 +19,8 @@ const defaultStatus = { authenticating: false, sendingVerification: false, sendingResetPasswordMessage: false, - registrationError: null + registrationError: null, + requiringAccountDownloadRequestSent: false, }; const state = { @@ -29,7 +30,6 @@ const state = { actionStatus: {}, loginError: null, resetPasswordMessageSent: false, - requiringAccountDownloadRequestSent: false, locale: user == null ? 'detect' : (typeof user.locale !== 'undefined' && user.locale !== null ? user.locale : 'detect') }; @@ -387,12 +387,13 @@ const mutations = { }, requiringAccountDownloadRequest(state) { + state.status = Object.assign({}, state.status, + { downloadingAccount: false, requiringAccountDownloadRequestSent: false }); state.actionStatus = { requesting: true, type: 'download' }; - state.requiringAccountDownloadRequestSent = false; }, requiringAccountDownloadSuccess(state) { + state.status = Object.assign({}, state.status, { requiringAccountDownloadRequestSent: true }); state.actionStatus = { success: true, type: 'download' }; - state.requiringAccountDownloadRequestSent = true; }, requiringAccountDownloadFailure(state, error) { state.actionStatus = { error: error, type: 'download' }; diff --git a/src/account/profile/PolicyPage.vue b/src/account/profile/PolicyPage.vue index f36adc2..e2a8584 100644 --- a/src/account/profile/PolicyPage.vue +++ b/src/account/profile/PolicyPage.vue @@ -17,7 +17,7 @@
{{ errors.first('download') }}
-
{{messages.field_label_account_download_requested_notice}}
+
{{messages.field_label_account_download_requested_notice}}
@@ -401,7 +401,7 @@ } }, computed: { - ...mapState('account', ['actionStatus', 'requiringAccountDownloadRequestSent']), + ...mapState('account', ['actionStatus', 'status']), ...mapState('system', [ 'messages', 'accountDeletionOptions', 'timeDurationOptions', 'timeDurationOptionsReversed', 'contactTypes', 'detectedLocale', 'countries' -- 2.17.1 From 0619841714c7e729faafd2400833bcf79377fa79 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 29 Apr 2020 13:07:36 +0200 Subject: [PATCH 13/21] Better indent --- src/_store/account.module.js | 12 ++++-------- src/account/profile/PolicyPage.vue | 4 +++- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/_store/account.module.js b/src/_store/account.module.js index a250021..f78bb34 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -184,18 +184,14 @@ const actions = { requireAccountDownload({ commit }, {messages, errors}) { commit('requiringAccountDownloadRequest'); userService.requireAccountDownload(messages, errors) - .then( - ok => commit('requiringAccountDownloadSuccess'), - error => commit('requiringAccountDownloadFailure', error) - ); + .then(ok => commit('requiringAccountDownloadSuccess'), + error => commit('requiringAccountDownloadFailure', error)); }, downloadAccount({ commit }, {token, messages, errors}) { commit('downloadAccountRequest'); userService.downloadAccount(token, messages, errors) - .then( - ok => commit('downloadAccountSuccess'), - error => commit('downloadAccountFailure', error) - ); + .then(ok => commit('downloadAccountSuccess'), + error => commit('downloadAccountFailure', error)); } }; diff --git a/src/account/profile/PolicyPage.vue b/src/account/profile/PolicyPage.vue index e2a8584..8e951a3 100644 --- a/src/account/profile/PolicyPage.vue +++ b/src/account/profile/PolicyPage.vue @@ -673,7 +673,9 @@ this.newContactSmsCountry = countryFromLocale(this.detectedLocale); if (this.$route.query.hasOwnProperty('download')) { - this.downloadAccount({ token: this.$route.query.download, messages: this.messages, errors: this.errors }); + this.downloadAccount({ + token: this.$route.query.download, messages: this.messages, errors: this.errors + }); } } }; -- 2.17.1 From 80312010f86914e200a6147098aa10922ba37298 Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Wed, 29 Apr 2020 13:09:08 +0200 Subject: [PATCH 14/21] Show download account file status on page --- src/_store/account.module.js | 3 +++ src/account/profile/PolicyPage.vue | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/_store/account.module.js b/src/_store/account.module.js index f78bb34..053af98 100644 --- a/src/_store/account.module.js +++ b/src/_store/account.module.js @@ -21,6 +21,7 @@ const defaultStatus = { sendingResetPasswordMessage: false, registrationError: null, requiringAccountDownloadRequestSent: false, + downloadingAccount: false }; const state = { @@ -398,9 +399,11 @@ const mutations = { // using the same type for action status as in requiringDownload... intentionally to reuse errors field: downloadAccountRequest(state) { + state.status = Object.assign({}, state.status, { downloadingAccount: true }); state.actionStatus = { requesting: true, type: 'download' }; }, downloadAccountSuccess(state) { + state.status = Object.assign({}, state.status, { downloadingAccount: false }); state.actionStatus = { success: true, type: 'download' }; }, downloadAccountFailure(state, error) { diff --git a/src/account/profile/PolicyPage.vue b/src/account/profile/PolicyPage.vue index 8e951a3..1a4f281 100644 --- a/src/account/profile/PolicyPage.vue +++ b/src/account/profile/PolicyPage.vue @@ -1,6 +1,14 @@