瀏覽代碼

Merge branch 'master' into kris/fix_restore_ui

pull/12/head
Kristijan Mitrovic 4 年之前
父節點
當前提交
d38e758a31
共有 4 個檔案被更改,包括 74 行新增7 行删除
  1. +9
    -1
      src/_services/system.service.js
  2. +20
    -2
      src/_store/system.module.js
  3. +2
    -2
      src/account/NetworkPage.vue
  4. +43
    -2
      src/account/profile/ProfilePage.vue

+ 9
- 1
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; });
}

+ 20
- 2
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;
}
};



+ 2
- 2
src/account/NetworkPage.vue 查看文件

@@ -13,7 +13,7 @@
</button>
</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/ -->
<div class="progress-wrap">
<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'});
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);


+ 43
- 2
src/account/profile/ProfilePage.vue 查看文件

@@ -20,6 +20,17 @@
</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">
<div v-if="submitted && errors.has('user')" class="invalid-feedback d-block"><h5>{{ errors.first('user') }}</h5></div>

@@ -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);
}
}
}
}
};

Loading…
取消
儲存