Parcourir la source

move upgrade from profile to my bubble screen, now works

pull/16/head
Jonathan Cobb il y a 4 ans
Parent
révision
d9d5146ff2
4 fichiers modifiés avec 138 ajouts et 60 suppressions
  1. +11
    -3
      src/_services/system.service.js
  2. +45
    -11
      src/_store/system.module.js
  3. +79
    -4
      src/account/NetworkPage.vue
  4. +3
    -42
      src/account/profile/ProfilePage.vue

+ 11
- 3
src/_services/system.service.js Voir le fichier

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


+ 45
- 11
src/_store/system.module.js Voir le fichier

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


+ 79
- 4
src/account/NetworkPage.vue Voir le fichier

@@ -47,6 +47,26 @@
</div>

<div v-if="isSelfNetAndRunning">

<div v-if="user.admin === true && configs && configs.jarVersion && configs.jarUpgradeAvailable && configs.jarUpgradeAvailable.version">
<hr/>
<h4>{{messages.message_jar_upgrade_available}}</h4>
<p>
{{messages.message_jar_upgrade_version}} {{configs.jarUpgradeAvailable.version}}<br/>
{{messages.message_jar_current_version}} {{configs.jarVersion}}
</p>
<button v-if="!upgrading" :disabled="upgrading" @click="doUpgrade()">{{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>
<div v-else-if="user.admin === true && configs && configs.jarVersion">
<hr/>
<h6>{{messages.message_jar_current_version}} {{configs.jarVersion}}</h6>
<p v-if="checkingForUpgrade">{{messages.message_jar_checking_for_upgrade}}</p>
<hr/>
</div>

<button class="btn btn-secondary" @click="requestRestoreKey()"
:disabled="loading && loading.requestNetworkKeys">
{{messages.link_network_action_request_keys}}
@@ -145,7 +165,7 @@
</template>

<script>
import { mapState, mapActions, mapGetters } from 'vuex';
import { mapState, mapActions } from 'vuex';
import { util } from '../_helpers';
import { loadingImgSrc } from '../_store';

@@ -160,7 +180,9 @@
stopRefresher: null,
restoreKeyCode: null,
restoreKeyPassword: null,
loadingImgSrc: loadingImgSrc
loadingImgSrc: loadingImgSrc,
checkingForUpgrade: false,
upgradeRefresher: null
};
},
computed: {
@@ -168,7 +190,7 @@
'network', 'newNodeNotification', 'networkStatuses', 'networkNodes', 'networkKeysRequested',
'deletedNetworkUuid', 'networkKeys', 'loading', 'restoreKey', 'backups'
]),
...mapState('system', ['messages', 'configs', 'appLinks']),
...mapState('system', ['messages', 'configs', 'appLinks', 'upgradeCheck', 'upgrading']),
showSetupHelp () {
return (this.network !== null && this.network.uuid !== this.configs.networkUuid
&& (this.network.state === 'running' || this.network.state === 'starting'
@@ -228,7 +250,7 @@
'stopNetwork', 'queueBackup', 'restoreNetwork', 'deleteNetwork', 'requestNetworkKeys',
'retrieveNetworkKeys', 'getBackups', 'resetRestoreKey'
]),
...mapActions('system', ['getAppLinks']),
...mapActions('system', ['getAppLinks', 'loadSystemConfigs', 'checkForUpgrade', 'upgrade']),
refreshStatus (userId) {
this.getNetworkById({userId: userId, networkId: this.networkId, messages: this.messages, errors: this.errors});
this.getStatusesByNetworkId({
@@ -329,6 +351,9 @@
messages: this.messages,
errors: this.errors
});
},
doUpgrade () {
this.upgrade();
}
},
created () {
@@ -337,6 +362,7 @@
this.startStatusRefresher(user);
this.restoreKeyCode = this.$route.query.keys_code;
this.getAppLinks(user.locale);
this.loadSystemConfigs();
},
beforeDestroy () {
this.clearRefresherInterval(this.refresher);
@@ -380,6 +406,55 @@
if (uuid && this.networkUuid && (uuid === this.networkUuid)) {
this.$router.replace({path: '/bubbles'});
}
},
configs (c) {
if (c) {
// console.log('watch.configs received: '+JSON.stringify(c));
if (this.user.admin) {
if (this.upgradeRefresher !== null) {
this.checkingForUpgrade = false;
console.log('watch.configs: found c.jarVersion=' + c.jarVersion + ', c.jarUpgradeAvailable=' + JSON.stringify(c.jarUpgradeAvailable));
// if there is no longer an upgrade available, then the upgrade succeeded
if (c.jarUpgradeAvailable === null) {
console.log('watch.configs: upgraded, reloading...');
window.location.reload();
// window.clearInterval(this.upgradeRefresher);
}

} else if (c.jarVersion && c.jarUpgradeAvailable === null) {
this.checkingForUpgrade = true;
console.log('watch.configs: checking for upgrade...')
this.checkForUpgrade();
} else {
console.log('watch.config: no need to check for upgrade, sage version info already present');
}
} else {
console.log('watch.configs: user is not admin, not checking for upgrade');
}
}
},
upgrading (u) {
console.log('watch.upgrading received: '+JSON.stringify(u));
if (u) {
if (u && this.upgradeRefresher === null) {
console.log('watch.upgrading: starting refresher');
const vue = this;
this.upgradeRefresher = window.setInterval(() => {
vue.loadSystemConfigs();
}, 5000);
}
}
},
upgradeCheck (u) {
if (u) {
console.log('watch.upgradeCheck received: '+JSON.stringify(u)+', setting checkingForUpgrade = true');
this.checkingForUpgrade = true;
const vue = this;
window.setTimeout(() => {
console.log('reloading system configs in response to upgrade check')
vue.loadSystemConfigs();
}, 10000);
}
}
}
};


+ 3
- 42
src/account/profile/ProfilePage.vue Voir le fichier

@@ -20,17 +20,6 @@
</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>

@@ -142,14 +131,12 @@
newUser: null,
submitted: false,
subject: Object.assign({}, BLANK_SUBJECT),
loadingImgSrc: loadingImgSrc,
upgrading: false,
upgradeRefresher: null
loadingImgSrc: loadingImgSrc
};
},
computed: {
...mapState('users', ['user']),
...mapState('system', ['messages', 'configs', 'status'])
...mapState('system', ['messages', 'configs'])
},
created () {
this.me = this.$route.path === '/me' || this.$route.path.startsWith('/me/');
@@ -200,7 +187,7 @@
next();
},
methods: {
...mapActions('system', ['loadSystemConfigs', 'upgradeJar']),
...mapActions('system', ['loadSystemConfigs']),
...mapActions('users', ['createUser', 'updateUser', 'updateSelf', 'getUserById']),
...mapGetters('users', ['loading']),
handleSubmit (e) {
@@ -229,10 +216,6 @@
console.log('invalid!');
}
});
},
doUpgradeJar () {
this.upgrading = true;
this.upgradeJar();
}
},
watch: {
@@ -252,28 +235,6 @@
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);
}
}
}
}
};

Chargement…
Annuler
Enregistrer