Преглед изворни кода

add support for flex regions, better error reporting

pull/16/head
Jonathan Cobb пре 4 година
родитељ
комит
e2fe4f4711
4 измењених фајлова са 37 додато и 24 уклоњено
  1. +6
    -6
      src/_services/network.service.js
  2. +3
    -3
      src/_store/networks.module.js
  3. +20
    -15
      src/account/NetworkPage.vue
  4. +8
    -0
      src/account/NewNetworkPage.vue

+ 6
- 6
src/_services/network.service.js Прегледај датотеку

@@ -35,17 +35,17 @@ function getNearestRegions(footprint, messages, errors) {
return fetch(`${config.apiUrl}/me/regions/closest${footprintParam}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getCloudAndRegion(cloud, region) {
return (typeof cloud === 'undefined' || typeof region === 'undefined' || cloud === null || region === null) ? "" : `?cloud=${cloud}&region=${region}`;
function getCloudAndRegion(cloud, region, exactRegion) {
return `?cloud=${cloud}&region=${region}&exactRegion=${exactRegion}`;
}

function startNetwork(userId, planId, cloud, region, messages, errors) {
const cloudAndRegion = getCloudAndRegion(cloud, region);
function startNetwork(userId, planId, cloud, region, exactRegion, messages, errors) {
const cloudAndRegion = getCloudAndRegion(cloud, region, exactRegion);
return fetch(`${config.apiUrl}/users/${userId}/networks/${planId}/actions/start${cloudAndRegion}`, util.postWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function forkNetwork(userId, planId, forkHost, cloud, region, messages, errors) {
const cloudAndRegion = getCloudAndRegion(cloud, region);
function forkNetwork(userId, planId, forkHost, cloud, region, exactRegion, messages, errors) {
const cloudAndRegion = getCloudAndRegion(cloud, region, exactRegion);
return fetch(`${config.apiUrl}/users/${userId}/networks/${planId}/actions/fork/${forkHost}${cloudAndRegion}`, util.putWithAuth()).then(util.handleCrudResponse(messages, errors));
}



+ 3
- 3
src/_store/networks.module.js Прегледај датотеку

@@ -51,20 +51,20 @@ const actions = {
error => commit('getNetworkByIdFailure', error));
},

addPlanAndStartNetwork({ commit }, {userId, accountPlan, cloud, region, messages, errors}) {
addPlanAndStartNetwork({ commit }, {userId, accountPlan, cloud, region, exactRegion, messages, errors}) {
commit('addPlanAndStartNetworkRequest');
accountPlanService.newAccountPlan(userId, accountPlan, messages, errors)
.then(
plan => {
if (accountPlan.forkHost && accountPlan.forkHost !== '') {
networkService.forkNetwork(userId, plan.name, accountPlan.forkHost, cloud, region, messages, errors)
networkService.forkNetwork(userId, plan.name, accountPlan.forkHost, cloud, exactRegion, region, messages, errors)
.then(
newNodeNotification => commit('addPlanAndStartNetworkSuccess', newNodeNotification),
error => commit('addPlanSuccessStartNetworkFailure', error)
);

} else {
networkService.startNetwork(userId, plan.name, cloud, region, messages, errors)
networkService.startNetwork(userId, plan.name, cloud, region, exactRegion, messages, errors)
.then(
newNodeNotification => commit('addPlanAndStartNetworkSuccess', newNodeNotification),
error => commit('addPlanSuccessStartNetworkFailure', error)


+ 20
- 15
src/account/NetworkPage.vue Прегледај датотеку

@@ -2,6 +2,9 @@
<template>
<div v-if="network">
<h4>{{ network.nickname }} - <i>{{ messages['msg_network_state_'+network.state] }}</i></h4>

<h6 class="alert-danger" v-if="stats && statsError">{{messages[stats.messageKey]}}</h6>

<h6 v-if="this.isNotSelfNet && (isInReadyToRestoreState || this.network.state === 'running')">
<button v-if="this.network.state === 'running'" :title="messages.message_network_connect"
:onclick="'window.open(\'' + networkAppLoginUrl + '\', \'_blank\')'">
@@ -15,11 +18,11 @@

<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 v-if="stats.percent" class="progress-wrap">
<div class="progress-bar" :style="'width: '+stats.percent+'%'" :id="'progressBar_'+networkId"></div>
<div class="progress-text">{{messages.label_percent.parseMessage(this, {percent: stats.percent})}}</div>
</div>
<div :id="'progressBar_details_'+networkId">{{messages[stats.messageKey]}}</div>
<div v-if="!statsError" :id="'progressBar_details_'+networkId">{{messages[stats.messageKey]}}</div>
<hr/>
</div>

@@ -130,8 +133,7 @@
</div>
{{ messages.button_description_restore }}
</div>
<div v-else v-html="messages.restore_not_possible_nodes_exist_html" />

<div v-else-if="this.statsError === null" v-html="messages.restore_not_possible_nodes_exist_html" />
</div>

<div v-if="configs.sageLauncher">
@@ -176,6 +178,9 @@
networkId: this.$route.params.id,
networkUuid: null,
stats: null,
statsError: false,
statsCompleted: false,
statsErrorRetry: false,
refresher: null,
stopRefresher: null,
restoreKeyCode: null,
@@ -374,8 +379,7 @@
if (net) {
if (net.uuid === 'Not Found') this.$router.replace({path: '/bubbles'});
this.networkUuid = net.uuid;

if (net.state !== 'created' && net.state !== 'starting' && net.state !== 'restoring') {
if ((this.statsError && !this.statsErrorRetry) || this.statsCompleted) {
this.clearRefresherInterval(this.refresher);
}
if (net.state !== 'stopping') this.clearRefresherInterval(this.stopRefresher);
@@ -385,6 +389,7 @@
// console.log('watch.networkNodes: received: '+JSON.stringify(nodes));
},
networkStatuses (stats) {
// console.log('watch.networkStatuses received: '+JSON.stringify(stats));
if (this.network && stats && stats.length && stats.length > 0) {
let latestStats = null;
for (let i=0; i<stats.length; i++) {
@@ -395,7 +400,9 @@
}
if (latestStats !== null) {
this.stats = latestStats;
if (this.stats.percent === 100) this.clearRefresherInterval(this.refresher);
this.statsError = this.stats.messageKey.startsWith('meter_error_');
this.statsErrorRetry = this.stats.messageKey.startsWith('meter_error_retry_');
this.statsCompleted = (this.stats.percent === 100) || this.stats.messageKey.startsWith('meter_completed_');
} else {
// status not found for our network
this.clearRefresherInterval(this.refresher);
@@ -413,29 +420,27 @@
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));
// 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');
// console.log('watch.configs: user is not admin, not checking for upgrade');
}
}
},
upgrading (u) {
console.log('watch.upgrading received: '+JSON.stringify(u));
// console.log('watch.upgrading received: '+JSON.stringify(u));
if (u) {
if (u && this.upgradeRefresher === null) {
console.log('watch.upgrading: starting refresher');
// console.log('watch.upgrading: starting refresher');
const vue = this;
this.upgradeRefresher = window.setInterval(() => {
vue.loadSystemConfigs();
@@ -445,11 +450,11 @@
},
upgradeCheck (u) {
if (u) {
console.log('watch.upgradeCheck received: '+JSON.stringify(u)+', setting checkingForUpgrade = true');
// 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')
// console.log('reloading system configs in response to upgrade check')
vue.loadSystemConfigs();
this.checkingForUpgrade = false;
}, 10000);


+ 8
- 0
src/account/NewNetworkPage.vue Прегледај датотеку

@@ -188,6 +188,12 @@
<select name="region" v-validate="'required'" v-model="cloudRegionUuid" v-if="regions" class="form-control" :class="{ 'is-invalid': submitted && errors.has('region') }">
<option v-for="region in regions" :value="region.uuid">{{region.name}} {{regionDistance(region.uuid)}}</option>
</select>

<label for="flexRegion"><b>{{messages.field_label_flex_region}}</b></label>
<input type="checkbox" name="exactRegion" v-model="flexRegion"/>
<p v-if="flexRegion">{{messages.field_label_flex_region_description}}</p>
<p v-else>{{messages.field_label_exact_region_description}}</p>

<div v-if="submitted && errors.has('region')" class="invalid-feedback d-block">{{ errors.first('region') }}</div>
<button @click="customize.region = false">{{messages.button_label_use_default}}</button>
</div>
@@ -413,6 +419,7 @@
region: '',
sshKey: ''
},
flexRegion: true,
submitted: false,
status: {
creating: false
@@ -668,6 +675,7 @@
accountPlan: this.accountPlan,
cloud: cloudRegion.cloud,
region: cloudRegion.internalName,
exactRegion: !this.flexRegion,
messages: this.messages,
errors: this.errors
});


Loading…
Откажи
Сачувај