diff --git a/src/_services/system.service.js b/src/_services/system.service.js index c36039f..62f6df2 100644 --- a/src/_services/system.service.js +++ b/src/_services/system.service.js @@ -17,7 +17,8 @@ export const systemService = { loadTimezones, detectTimezone, detectLocale, - getAppLinks + getAppLinks, + upgradeJar }; function loadIsActivated () { @@ -116,3 +117,10 @@ function getAppLinks (locale) { .then(util.handleBasicResponse) .then(links => { return links; }); } + +function upgradeJar() { + 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 d48892d..e3a5fef 100644 --- a/src/_store/system.module.js +++ b/src/_store/system.module.js @@ -24,11 +24,13 @@ const state = { awaitingRestore: false, restoringInProgress: false, support: {}, - securityLevels: null + securityLevels: null, + jarVersion: null, + jarUpgradeAvailable: null }, entityConfigs: {}, searchResults: [], - status: { activating: false, searching: false, creatingEntity: false, modelSetupInProgress: false }, + status: { activating: false, searching: false, creatingEntity: false, modelSetupInProgress: false, upgrading: false }, activated: null, error: null, messages: { @@ -156,6 +158,13 @@ const actions = { links => commit('getAppLinksSuccess', links), error => commit('getAppLinksFailure', error) ) + }, + upgradeJar({ commit }) { + commit('upgradeJarRequest'); + systemService.upgradeJar(locale).then( + configs => commit('upgradeJarSuccess', configs), + error => commit('upgradeJarFailure', error) + ) } }; @@ -412,6 +421,15 @@ const mutations = { }, getAppLinksFailure(state, error) { state.error = error; + }, + + upgradeJarRequest(state) {}, + upgradeJarSuccess(state, configs) { + state.configs = configs; + state.status = Object.assign(state.status, {upgrading: true}); + }, + upgradeJarFailure(state, error) { + state.error = error; } }; diff --git a/src/account/NetworkPage.vue b/src/account/NetworkPage.vue index 03b0fa8..22d7d4a 100644 --- a/src/account/NetworkPage.vue +++ b/src/account/NetworkPage.vue @@ -13,7 +13,7 @@ -
+
@@ -349,7 +349,7 @@ if (net.uuid === 'Not Found') this.$router.replace({path: '/bubbles'}); this.networkUuid = net.uuid; - if (net.state !== 'starting' && net.state !== 'restoring') { + if (net.state !== 'created' && net.state !== 'starting' && net.state !== 'restoring') { this.clearRefresherInterval(this.refresher); } if (net.state !== 'stopping') this.clearRefresherInterval(this.stopRefresher); diff --git a/src/account/profile/ProfilePage.vue b/src/account/profile/ProfilePage.vue index 617f2d2..7796b35 100644 --- a/src/account/profile/ProfilePage.vue +++ b/src/account/profile/ProfilePage.vue @@ -20,6 +20,17 @@
+
+
+

{{messages.message_jar_upgrade_available}}

+

{{messages.message_jar_upgrade_version}} {{configs.jarUpgradeAvailable.version}}

+

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

+ + +

{{messages.message_jar_upgrading}}

+
+
+
{{ errors.first('user') }}
@@ -131,15 +142,18 @@ newUser: null, submitted: false, subject: Object.assign({}, BLANK_SUBJECT), - loadingImgSrc: loadingImgSrc + loadingImgSrc: loadingImgSrc, + upgrading: false, + upgradeRefresher: null }; }, computed: { ...mapState('users', ['user']), - ...mapState('system', ['messages', 'configs']) + ...mapState('system', ['messages', 'configs', 'status']) }, created () { this.me = this.$route.path === '/me' || this.$route.path.startsWith('/me/'); + this.loadSystemConfigs(); if (this.me) { this.linkPrefix = '/me'; if (this.currentUser === null) { @@ -186,6 +200,7 @@ next(); }, methods: { + ...mapActions('system', ['loadSystemConfigs', 'upgradeJar']), ...mapActions('users', ['createUser', 'updateUser', 'updateSelf', 'getUserById']), ...mapGetters('users', ['loading']), handleSubmit (e) { @@ -214,6 +229,10 @@ console.log('invalid!'); } }); + }, + doUpgradeJar () { + this.upgrading = true; + this.upgradeJar(); } }, watch: { @@ -233,6 +252,28 @@ this.subject = u; } } + }, + configs (c) { + if (c) { + console.log('watch.configs received: '+JSON.stringify(c)); + if (this.upgradeRefresher !== null) { + // does the new server version match our version? + if (c.jarVersion && c.jarUpgradeAvailable && c.jarUpgradeAvailable.version && c.jarVersion === c.jarUpgradeAvailable.version) { + window.clearInterval(this.upgradeRefresher); + } + } + } + }, + status (s) { + if (s) { + console.log('watch.status received: '+JSON.stringify(s)); + if (s.upgrading && this.upgradeRefresher === null) { + const vue = this; + this.upgradeRefresher = window.setInterval(() => { + vue.loadSystemConfigs(); + }, 5000); + } + } } } };