@@ -17,7 +17,8 @@ export const systemService = { | |||||
loadTimezones, | loadTimezones, | ||||
detectTimezone, | detectTimezone, | ||||
detectLocale, | detectLocale, | ||||
getAppLinks | |||||
getAppLinks, | |||||
upgradeJar | |||||
}; | }; | ||||
function loadIsActivated () { | function loadIsActivated () { | ||||
@@ -116,3 +117,10 @@ function getAppLinks (locale) { | |||||
.then(util.handleBasicResponse) | .then(util.handleBasicResponse) | ||||
.then(links => { return links; }); | .then(links => { return links; }); | ||||
} | } | ||||
function upgradeJar() { | |||||
const requestOptions =util.postWithAuth(); | |||||
return fetch(`${config.apiUrl}/me/upgrade`, requestOptions) | |||||
.then(util.handleBasicResponse) | |||||
.then(configs => { return configs; }); | |||||
} |
@@ -23,11 +23,13 @@ const state = { | |||||
requireSendMetrics: null, | requireSendMetrics: null, | ||||
awaitingRestore: false, | awaitingRestore: false, | ||||
support: {}, | support: {}, | ||||
securityLevels: null | |||||
securityLevels: null, | |||||
jarVersion: null, | |||||
jarUpgradeAvailable: null | |||||
}, | }, | ||||
entityConfigs: {}, | entityConfigs: {}, | ||||
searchResults: [], | searchResults: [], | ||||
status: { activating: false, searching: false, creatingEntity: false, modelSetupInProgress: false }, | |||||
status: { activating: false, searching: false, creatingEntity: false, modelSetupInProgress: false, upgrading: false }, | |||||
activated: null, | activated: null, | ||||
error: null, | error: null, | ||||
messages: { | messages: { | ||||
@@ -155,6 +157,13 @@ const actions = { | |||||
links => commit('getAppLinksSuccess', links), | links => commit('getAppLinksSuccess', links), | ||||
error => commit('getAppLinksFailure', error) | error => commit('getAppLinksFailure', error) | ||||
) | ) | ||||
}, | |||||
upgradeJar({ commit }) { | |||||
commit('upgradeJarRequest'); | |||||
systemService.upgradeJar(locale).then( | |||||
configs => commit('upgradeJarSuccess', configs), | |||||
error => commit('upgradeJarFailure', error) | |||||
) | |||||
} | } | ||||
}; | }; | ||||
@@ -411,6 +420,15 @@ const mutations = { | |||||
}, | }, | ||||
getAppLinksFailure(state, error) { | getAppLinksFailure(state, error) { | ||||
state.error = 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; | |||||
} | } | ||||
}; | }; | ||||
@@ -13,7 +13,7 @@ | |||||
</button> | </button> | ||||
</h6> | </h6> | ||||
<div v-if="stats && (network.state === 'starting' || network.state === 'restoring')"> | |||||
<div v-if="stats && (network.state === 'created' || network.state === 'starting' || network.state === 'restoring')"> | |||||
<!-- adapted from: https://code-boxx.com/simple-vanilla-javascript-progress-bar/ --> | <!-- adapted from: https://code-boxx.com/simple-vanilla-javascript-progress-bar/ --> | ||||
<div class="progress-wrap"> | <div class="progress-wrap"> | ||||
<div class="progress-bar" :style="'width: '+stats.percent+'%'" :id="'progressBar_'+networkId"></div> | <div class="progress-bar" :style="'width: '+stats.percent+'%'" :id="'progressBar_'+networkId"></div> | ||||
@@ -349,7 +349,7 @@ | |||||
if (net.uuid === 'Not Found') this.$router.replace({path: '/bubbles'}); | if (net.uuid === 'Not Found') this.$router.replace({path: '/bubbles'}); | ||||
this.networkUuid = net.uuid; | 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); | this.clearRefresherInterval(this.refresher); | ||||
} | } | ||||
if (net.state !== 'stopping') this.clearRefresherInterval(this.stopRefresher); | if (net.state !== 'stopping') this.clearRefresherInterval(this.stopRefresher); | ||||
@@ -20,6 +20,17 @@ | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<div v-if="admin === true && configs && configs.jarVersion && configs.jarUpgradeAvailable && configs.jarUpgradeAvailable.version"> | |||||
<hr/> | |||||
<h2>{{messages.message_jar_upgrade_available}}</h2> | |||||
<p>{{messages.message_jar_upgrade_version}} {{configs.jarUpgradeAvailable.version}}</p> | |||||
<p>{{messages.message_jar_current_version}} {{configs.jarVersion}}</p> | |||||
<button v-if="!upgrading" :disabled="loading()" @click="doUpgradeJar()">{{messages.button_label_jar_upgrade}}</button> | |||||
<button v-else-if="upgrading" :disabled="true">{{messages.button_label_jar_upgrading}}</button> | |||||
<p v-if="upgrading">{{messages.message_jar_upgrading}}</p> | |||||
<hr/> | |||||
</div> | |||||
<form @submit.prevent="handleSubmit"> | <form @submit.prevent="handleSubmit"> | ||||
<div v-if="submitted && errors.has('user')" class="invalid-feedback d-block"><h5>{{ errors.first('user') }}</h5></div> | <div v-if="submitted && errors.has('user')" class="invalid-feedback d-block"><h5>{{ errors.first('user') }}</h5></div> | ||||
@@ -131,15 +142,18 @@ | |||||
newUser: null, | newUser: null, | ||||
submitted: false, | submitted: false, | ||||
subject: Object.assign({}, BLANK_SUBJECT), | subject: Object.assign({}, BLANK_SUBJECT), | ||||
loadingImgSrc: loadingImgSrc | |||||
loadingImgSrc: loadingImgSrc, | |||||
upgrading: false, | |||||
upgradeRefresher: null | |||||
}; | }; | ||||
}, | }, | ||||
computed: { | computed: { | ||||
...mapState('users', ['user']), | ...mapState('users', ['user']), | ||||
...mapState('system', ['messages', 'configs']) | |||||
...mapState('system', ['messages', 'configs', 'status']) | |||||
}, | }, | ||||
created () { | created () { | ||||
this.me = this.$route.path === '/me' || this.$route.path.startsWith('/me/'); | this.me = this.$route.path === '/me' || this.$route.path.startsWith('/me/'); | ||||
this.loadSystemConfigs(); | |||||
if (this.me) { | if (this.me) { | ||||
this.linkPrefix = '/me'; | this.linkPrefix = '/me'; | ||||
if (this.currentUser === null) { | if (this.currentUser === null) { | ||||
@@ -186,6 +200,7 @@ | |||||
next(); | next(); | ||||
}, | }, | ||||
methods: { | methods: { | ||||
...mapActions('system', ['loadSystemConfigs', 'upgradeJar']), | |||||
...mapActions('users', ['createUser', 'updateUser', 'updateSelf', 'getUserById']), | ...mapActions('users', ['createUser', 'updateUser', 'updateSelf', 'getUserById']), | ||||
...mapGetters('users', ['loading']), | ...mapGetters('users', ['loading']), | ||||
handleSubmit (e) { | handleSubmit (e) { | ||||
@@ -214,6 +229,10 @@ | |||||
console.log('invalid!'); | console.log('invalid!'); | ||||
} | } | ||||
}); | }); | ||||
}, | |||||
doUpgradeJar () { | |||||
this.upgrading = true; | |||||
this.upgradeJar(); | |||||
} | } | ||||
}, | }, | ||||
watch: { | watch: { | ||||
@@ -233,6 +252,28 @@ | |||||
this.subject = u; | 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); | |||||
} | |||||
} | |||||
} | } | ||||
} | } | ||||
}; | }; |