From d9d5146ff2229942ec0637b43ebd927d2f7ebb1e Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sat, 11 Jul 2020 01:15:41 -0400 Subject: [PATCH 1/3] move upgrade from profile to my bubble screen, now works --- src/_services/system.service.js | 14 +++-- src/_store/system.module.js | 56 +++++++++++++++---- src/account/NetworkPage.vue | 83 +++++++++++++++++++++++++++-- src/account/profile/ProfilePage.vue | 45 ++-------------- 4 files changed, 138 insertions(+), 60 deletions(-) diff --git a/src/_services/system.service.js b/src/_services/system.service.js index 62f6df2..e945bcd 100644 --- a/src/_services/system.service.js +++ b/src/_services/system.service.js @@ -18,7 +18,8 @@ export const systemService = { detectTimezone, detectLocale, getAppLinks, - upgradeJar + checkForUpgrade, + upgrade }; function loadIsActivated () { @@ -118,8 +119,15 @@ function getAppLinks (locale) { .then(links => { return links; }); } -function upgradeJar() { - const requestOptions =util.postWithAuth(); +function checkForUpgrade() { + const requestOptions = util.getWithAuth(); + return fetch(`${config.apiUrl}/me/upgrade`, requestOptions) + .then(util.handleBasicResponse) + .then(ok => { return true; }); +} + +function upgrade() { + const requestOptions = util.postWithAuth(); return fetch(`${config.apiUrl}/me/upgrade`, requestOptions) .then(util.handleBasicResponse) .then(configs => { return configs; }); diff --git a/src/_store/system.module.js b/src/_store/system.module.js index 61bd092..68c5f34 100644 --- a/src/_store/system.module.js +++ b/src/_store/system.module.js @@ -30,7 +30,7 @@ const state = { }, entityConfigs: {}, searchResults: [], - status: { activating: false, searching: false, creatingEntity: false, modelSetupInProgress: false, upgrading: false }, + status: { activating: false, searching: false, creatingEntity: false, modelSetupInProgress: false }, activated: null, error: null, messages: { @@ -59,7 +59,9 @@ const state = { timeDurationOptions: [], timeDurationOptionsReversed: [], contactTypes: [], - appLinks: null + appLinks: null, + upgradeCheck: null, + upgrading: null }; const actions = { @@ -159,12 +161,27 @@ const actions = { error => commit('getAppLinksFailure', error) ) }, - upgradeJar({ commit }) { - commit('upgradeJarRequest'); - systemService.upgradeJar(locale).then( - configs => commit('upgradeJarSuccess', configs), - error => commit('upgradeJarFailure', error) + checkForUpgrade({ commit }) { + if (this.state.upgradeCheck === null) { + commit('checkForUpgradeRequest'); + systemService.checkForUpgrade().then( + configs => commit('checkForUpgradeSuccess', configs), + error => commit('checkForUpgradeFailure', error) + ); + } else { + console.log('checkForUpgrade: already checked, not checking again'); + } + }, + upgrade({ commit }) { + commit('upgradeRequest'); + systemService.upgrade().then( + configs => commit('upgradeSuccess', configs), + error => commit('upgradeFailure', error) ) + }, + upgradeComplete({ commit }) { + commit('upgradeCompleteRequest'); + commit('upgradeCompleteSuccess'); } }; @@ -423,12 +440,29 @@ const mutations = { state.error = error; }, - upgradeJarRequest(state) {}, - upgradeJarSuccess(state, configs) { + checkForUpgradeRequest(state) {}, + checkForUpgradeSuccess(state, ok) { + state.upgradeCheck = true; + }, + checkForUpgradeFailure(state, error) { + state.error = error; + }, + + upgradeRequest(state) {}, + upgradeSuccess(state, configs) { state.configs = configs; - state.status = Object.assign(state.status, {upgrading: true}); + state.upgrading = true; + }, + upgradeFailure(state, error) { + state.error = error; + }, + + upgradeCompleteRequest(state) {}, + upgradeCompleteSuccess(state) { + state.upgrading = false; }, - upgradeJarFailure(state, error) { + upgradeCompleteFailure(state, error) { + state.upgrading = false; state.error = error; } }; diff --git a/src/account/NetworkPage.vue b/src/account/NetworkPage.vue index 22d7d4a..3356e5f 100644 --- a/src/account/NetworkPage.vue +++ b/src/account/NetworkPage.vue @@ -47,6 +47,26 @@
+ +
+
+

{{messages.message_jar_upgrade_available}}

+

+ {{messages.message_jar_upgrade_version}} {{configs.jarUpgradeAvailable.version}}
+ {{messages.message_jar_current_version}} {{configs.jarVersion}} +

+ + +

{{messages.message_jar_upgrading}}

+
+
+
+
+
{{messages.message_jar_current_version}} {{configs.jarVersion}}
+

{{messages.message_jar_checking_for_upgrade}}

+
+
+