Sfoglia il codice sorgente

Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into feat/babel-root-plugin

pull/14/head
Tyler Chen 4 anni fa
parent
commit
6db509f942
4 ha cambiato i file con 267 aggiunte e 220 eliminazioni
  1. +11
    -3
      src/_services/system.service.js
  2. +176
    -172
      src/_store/system.module.js
  3. +77
    -3
      src/account/NetworkPage.vue
  4. +3
    -42
      src/account/profile/ProfilePage.vue

+ 11
- 3
src/_services/system.service.js Vedi File

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


+ 176
- 172
src/_store/system.module.js Vedi File

@@ -9,74 +9,61 @@ import { router } from '~/_router';
import { account } from './account.module';

const state = {
configs: {
networkUuid: null,
allowRegistration: false,
paymentsEnabled: false,
sageLauncher: false,
bubbleNode: null,
entityClasses: [],
locales: ['en_US'],
cloudConfigs: {},
sslPort: null,
locked: null,
launchLock: null,
promoCodePolicy: null,
requireSendMetrics: null,
awaitingRestore: false,
restoreInProgress: false,
support: {},
securityLevels: null,
jarVersion: null,
jarUpgradeAvailable: null,
},
entityConfigs: {},
searchResults: [],
status: {
activating: false,
searching: false,
creatingEntity: false,
modelSetupInProgress: false,
upgrading: false,
},
activated: null,
error: null,
messages: {
durationToMillis: function(count, units) {
if (typeof count === 'undefined' || count === null || count === '')
return null;
return (
parseInt(count) *
parseInt(state.messages['time_duration_' + units + '_factor'])
);
configs: {
networkUuid: null,
allowRegistration: false,
paymentsEnabled: false,
sageLauncher: false,
bubbleNode: null,
entityClasses: [],
locales: ['en_US'],
cloudConfigs: {},
sslPort: null,
locked: null,
launchLock: null,
promoCodePolicy: null,
requireSendMetrics: null,
awaitingRestore: false,
restoreInProgress: false,
support: {},
securityLevels: null,
jarVersion: null,
jarUpgradeAvailable: null
},
millisToDuration: function(ms) {
const durations = state.timeDurationOptionsReversed;
for (let i = 0; i < durations.length; i++) {
const durationMillis = parseInt(
state.messages['time_duration_' + durations[i] + '_factor']
);
if (
ms >= durationMillis &&
(ms % durationMillis === 0 || i === durations.length - 1)
) {
return { count: parseInt(ms) / durationMillis, units: durations[i] };
entityConfigs: {},
searchResults: [],
status: { activating: false, searching: false, creatingEntity: false, modelSetupInProgress: false },
activated: null,
error: null,
messages: {
durationToMillis: function(count, units) {
if (typeof count === 'undefined' || count === null || count === '') return null;
return parseInt(count) * parseInt(state.messages['time_duration_'+units+'_factor']);
},
millisToDuration: function (ms) {
const durations = state.timeDurationOptionsReversed;
for (let i=0; i<durations.length; i++) {
const durationMillis = parseInt(state.messages['time_duration_'+durations[i]+'_factor']);
if (ms >= durationMillis && ((ms % durationMillis) === 0 || i === durations.length-1)) {
return {count: parseInt(ms) / durationMillis, units: durations[i]};
}
}
return {count: parseInt(ms), units: ''};
}
}
return { count: parseInt(ms), units: '' };
},
},
messageGroupsLoaded: [],
countries: [],
locales: [],
timezones: [],
detectedTimezone: null,
detectedLocale: null,
accountDeletionOptions: [],
timeDurationOptions: [],
timeDurationOptionsReversed: [],
contactTypes: [],
appLinks: null,
messageGroupsLoaded: [],
countries: [],
locales: [],
timezones: [],
detectedTimezone: null,
detectedLocale: null,
accountDeletionOptions: [],
timeDurationOptions: [],
timeDurationOptionsReversed: [],
contactTypes: [],
appLinks: null,
upgradeCheck: null,
upgrading: null
};

const actions = {
@@ -100,105 +87,104 @@ const actions = {
);
},

loadSystemConfigs({ commit }) {
commit('loadSystemConfigsRequest');
systemService
.loadSystemConfigs()
.then(
(configs) => commit('loadSystemConfigsSuccess', configs),
(error) => commit('loadSystemConfigsFailure', error)
);
},
loadEntityConfigs({ commit }) {
commit('loadEntityConfigsRequest');
systemService
.loadEntityConfigs()
.then(
(configs) => commit('loadEntityConfigsSuccess', configs),
(error) => commit('loadEntityConfigsFailure', error)
);
},
search({ commit }, type, query) {
commit('searchRequest');
systemService
.search(type, query)
.then(
(results) => commit('searchSuccess', { type, query, results }),
(error) => commit('searchFailure', error)
);
},
createEntity({ commit }, { entityConfig, json, messages, errors }) {
commit('createEntityRequest');
systemService
.createEntity(entityConfig, json, messages, errors)
.then(
(entity) => commit('createEntitySuccess', entity),
(error) => commit('createEntityFailure', error)
);
},
modelSetup({ commit }, { file, messages, errors }) {
commit('modelSetupRequest');
systemService
.modelSetup(file, messages, errors)
.then(
(ok) => commit('modelSetupSuccess'),
(errors) => commit('modelSetupFailure', errors)
);
},
loadMessages({ commit }, group, locale) {
commit('loadMessagesRequest');
systemService
.loadMessages(group, locale)
.then(
(messages) => commit('loadMessagesSuccess', { group, messages }),
(error) => commit('loadMessagesFailure', error)
);
},
loadTimezones({ commit }) {
commit('loadTimezonesRequest');
systemService
.loadTimezones()
.then(
(timezones) => commit('loadTimezonesSuccess', timezones),
(error) => commit('loadTimezonesFailure', error)
);
},
detectTimezone({ commit }) {
commit('detectTimezoneRequest');
systemService
.detectTimezone()
.then(
(timezone) => commit('detectTimezoneSuccess', timezone),
(error) => commit('detectTimezoneFailure', error)
);
},
detectLocale({ commit }) {
commit('detectLocaleRequest');
systemService
.detectLocale()
.then(
(locales) => commit('detectLocaleSuccess', locales),
(error) => commit('detectLocaleFailure', error)
);
},
getAppLinks({ commit }, locale) {
commit('getAppLinksRequest');
systemService
.getAppLinks(locale)
.then(
(links) => commit('getAppLinksSuccess', links),
(error) => commit('getAppLinksFailure', error)
);
},
upgradeJar({ commit }) {
commit('upgradeJarRequest');
systemService
.upgradeJar(locale)
.then(
(configs) => commit('upgradeJarSuccess', configs),
(error) => commit('upgradeJarFailure', error)
);
},
loadSystemConfigs({ commit }) {
commit('loadSystemConfigsRequest');
systemService.loadSystemConfigs()
.then(
configs => commit('loadSystemConfigsSuccess', configs),
error => commit('loadSystemConfigsFailure', error)
);
},
loadEntityConfigs({ commit }) {
commit('loadEntityConfigsRequest');
systemService.loadEntityConfigs()
.then(
configs => commit('loadEntityConfigsSuccess', configs),
error => commit('loadEntityConfigsFailure', error)
);
},
search({ commit }, type, query) {
commit('searchRequest');
systemService.search(type, query)
.then(
results => commit('searchSuccess', {type, query, results}),
error => commit('searchFailure', error)
);
},
createEntity({ commit }, {entityConfig, json, messages, errors}) {
commit('createEntityRequest');
systemService.createEntity(entityConfig, json, messages, errors)
.then(
entity => commit('createEntitySuccess', entity),
error => commit('createEntityFailure', error)
);
},
modelSetup({ commit }, {file, messages, errors}) {
commit('modelSetupRequest');
systemService.modelSetup(file, messages, errors)
.then(
ok => commit('modelSetupSuccess'),
errors => commit('modelSetupFailure', errors)
);
},
loadMessages({ commit }, group, locale) {
commit('loadMessagesRequest');
systemService.loadMessages(group, locale)
.then(
messages => commit('loadMessagesSuccess', {group, messages}),
error => commit('loadMessagesFailure', error)
);
},
loadTimezones({ commit }) {
commit('loadTimezonesRequest');
systemService.loadTimezones().then(
timezones => commit('loadTimezonesSuccess', timezones),
error => commit('loadTimezonesFailure', error)
)
},
detectTimezone({ commit }) {
commit('detectTimezoneRequest');
systemService.detectTimezone().then(
timezone => commit('detectTimezoneSuccess', timezone),
error => commit('detectTimezoneFailure', error)
)
},
detectLocale({ commit }) {
commit('detectLocaleRequest');
systemService.detectLocale().then(
locales => commit('detectLocaleSuccess', locales),
error => commit('detectLocaleFailure', error)
)
},
getAppLinks({ commit }, locale) {
commit('getAppLinksRequest');
systemService.getAppLinks(locale).then(
links => commit('getAppLinksSuccess', links),
error => commit('getAppLinksFailure', error)
)
},
checkForUpgrade({ commit }) {
if (state.upgradeCheck === null) {
commit('checkForUpgradeRequest');
systemService.checkForUpgrade().then(
configs => commit('checkForUpgradeSuccess', configs),
error => commit('checkForUpgradeFailure', error)
);
} else {
console.log('checkForUpgrade: already checked ('+state.upgradeCheck+'), not checking again');
}
},
upgrade({ commit }) {
commit('upgradeRequest');
systemService.upgrade().then(
configs => commit('upgradeSuccess', configs),
error => commit('upgradeFailure', error)
)
},
upgradeComplete({ commit }) {
commit('upgradeCompleteRequest');
commit('upgradeCompleteSuccess');
}
};

const getters = {
@@ -494,14 +480,32 @@ const mutations = {
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;
},
checkForUpgradeRequest(state) {},
checkForUpgradeSuccess(state, ok) {
console.log('checkForUpgradeSuccess: ok');
state.upgradeCheck = true;
},
checkForUpgradeFailure(state, error) {
state.error = error;
},

upgradeRequest(state) {},
upgradeSuccess(state, configs) {
state.configs = configs;
state.upgrading = true;
},
upgradeFailure(state, error) {
state.error = error;
},

upgradeCompleteRequest(state) {},
upgradeCompleteSuccess(state) {
state.upgrading = false;
},
upgradeCompleteFailure(state, error) {
state.upgrading = false;
state.error = error;
}
};

export const system = {


+ 77
- 3
src/account/NetworkPage.vue Vedi File

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

<div v-if="isSelfNetAndRunning">

<div v-if="user.admin === true && checkingForUpgrade !== null && configs && configs.jarVersion && configs.jarUpgradeAvailable && configs.jarUpgradeAvailable.version">
<hr/>
<h4>{{messages.message_jar_upgrade_available}}</h4>
<p>
{{messages.message_jar_current_version}} <b>{{configs.jarVersion}}</b><br/>
{{messages.message_jar_upgrade_version}} <b>{{configs.jarUpgradeAvailable.version}}</b>
</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}} <b>{{configs.jarVersion}}</b></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}}
@@ -160,7 +180,9 @@
stopRefresher: null,
restoreKeyCode: null,
restoreKeyPassword: null,
loadingImgSrc: loadingImgSrc
loadingImgSrc: loadingImgSrc,
checkingForUpgrade: null,
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,54 @@
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 && this.checkingForUpgrade === null) {
this.checkingForUpgrade = true;
console.log('watch.configs: checking for upgrade...')
this.checkForUpgrade();
}
} 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();
this.checkingForUpgrade = false;
}, 10000);
}
}
}
};


+ 3
- 42
src/account/profile/ProfilePage.vue Vedi File

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

Caricamento…
Annulla
Salva