diff --git a/src/_services/accountPlan.service.js b/src/_services/accountPlan.service.js
index 8e32d19..eb69fb4 100644
--- a/src/_services/accountPlan.service.js
+++ b/src/_services/accountPlan.service.js
@@ -17,5 +17,5 @@ function getById(userId, accountPlanId, messages, errors) {
}
function newAccountPlan(userId, accountPlan, messages, errors) {
- return fetch(`${config.apiUrl}/users/${userId}/accountPlans`, util.putWithAuth(accountPlan)).then(util.handleCrudResponse(messages, errors));
+ return fetch(`${config.apiUrl}/me/plans`, util.putWithAuth(accountPlan)).then(util.handleCrudResponse(messages, errors));
}
diff --git a/src/_services/network.service.js b/src/_services/network.service.js
index 91a2e4c..6556ec7 100644
--- a/src/_services/network.service.js
+++ b/src/_services/network.service.js
@@ -4,7 +4,8 @@ import { util } from '../_helpers';
export const networkService = {
getAll,
getById,
- getNearestRegions
+ getNearestRegions,
+ startNetwork
};
function getAll(userId, messages, errors) {
@@ -16,6 +17,11 @@ function getById(userId, networkId, messages, errors) {
}
function getNearestRegions(userId, footprint, messages, errors) {
- const footprintParam = (typeof footprint === "undefined" || footprint === null || footprint === '') ? "" : `?footprint=${footprint}`;
+ const footprintParam = (typeof footprint === 'undefined' || footprint === null || footprint === '') ? "" : `?footprint=${footprint}`;
return fetch(`${config.apiUrl}/me/regions/closest${footprintParam}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}
+
+function startNetwork(userId, planId, cloud, region) {
+ const cloudAndRegion = (typeof cloud === 'undefined' || typeof region === 'undefined' || cloud === null || region === null) ? "" : `?cloud=${cloud}®ion=${region}`;
+ return fetch(`${config.apiUrl}/networks/${planId}/actions/start${cloudAndRegion}`, util.postWithAuth()).then(util.handleCrudResponse(messages, errors));
+}
\ No newline at end of file
diff --git a/src/_store/networks.module.js b/src/_store/networks.module.js
index 2db826c..04d69eb 100644
--- a/src/_store/networks.module.js
+++ b/src/_store/networks.module.js
@@ -1,16 +1,18 @@
import { networkService } from '../_services';
+import { accountPlanService } from '../_services';
import { account } from '../_store/account.module';
import { util } from '../_helpers';
const state = {
loading: {
- networks: false, network: false, deleting: false, nearestRegions: false
+ networks: false, network: false, deleting: false, nearestRegions: false, startingNetwork: false
},
creating: null,
error: null,
networks: null,
network: null,
- nearestRegions: null
+ nearestRegions: null,
+ newNodeNotification: null
};
const actions = {
@@ -32,8 +34,19 @@ const actions = {
);
},
- create({ commit }, {accountPlan, messages, errors}) {
- // todo: create account plan, then start network
+ addPlanAndStartNetwork({ commit }, {accountPlan, cloud, region, messages, errors}) {
+ commit('addPlanAndStartNetworkRequest');
+ accountPlanService.newAccountPlan(account.state.user.uuid, accountPlan, messages, errors)
+ .then(
+ plan => {
+ networkService.startNetwork(account.state.user.uuid, plan.name, cloud, region)
+ .then(
+ network => commit('addPlanAndStartNetworkSuccess', network),
+ error => commit('addPlanSuccessStartNetworkFailure', error)
+ );
+ },
+ error => commit('addPlanFailure', error)
+ );
},
delete({ commit }, {id, messages, errors}) {
@@ -78,6 +91,23 @@ const mutations = {
state.loading.network = false;
state.error = { error };
},
+
+ addPlanAndStartNetworkRequest(state) {
+ state.loading.startingNetwork = true;
+ },
+ addPlanAndStartNetworkSuccess(state, newNodeNotification) {
+ state.loading.startingNetwork = false;
+ state.newNodeNotification = newNodeNotification;
+ },
+ addPlanSuccessStartNetworkFailure(state, error) {
+ state.loading.startingNetwork = false;
+ state.error = { error };
+ },
+ addPlanFailure(state, error) {
+ state.loading.startingNetwork = false;
+ state.error = { error };
+ },
+
deleteRequest(state, id) {
state.loading.deleting = true;
},
diff --git a/src/account/NewNetworkPage.vue b/src/account/NewNetworkPage.vue
index 1080725..897a5f1 100644
--- a/src/account/NewNetworkPage.vue
+++ b/src/account/NewNetworkPage.vue
@@ -33,14 +33,14 @@
@@ -55,7 +55,7 @@
@@ -70,7 +70,7 @@
@@ -85,7 +85,7 @@
@@ -96,7 +96,7 @@
- {{messages['plan_description_'+network.plan]}}
+ {{messages['plan_description_'+accountPlan.plan]}}
@@ -120,7 +120,7 @@
@@ -131,7 +131,7 @@
- {{messages['footprint_description_'+network.footprint]}}
+ {{messages['footprint_description_'+accountPlan.footprint]}}
@@ -184,7 +184,7 @@
export default {
data() {
return {
- network: {
+ accountPlan: {
name: '',
domain: '',
locale: '',
@@ -238,14 +238,14 @@
...mapState('users', ['policy']),
...mapState('account', ['actionStatus']),
isComplete() {
- return (this.network.name !== '')
- && (this.customize.domain === false || this.network.domain !== '')
- && (this.customize.locale === false || this.network.locale !== '')
- && (this.customize.timezone === false || this.network.timezone !== '')
- && (this.customize.plan === false || this.network.plan !== '')
- && (this.customize.footprint === false || this.network.footprint !== '')
- && (this.network.paymentMethodObject.paymentMethodType != null)
- && (this.network.paymentMethodObject.paymentInfo != null);
+ return (this.accountPlan.name !== '')
+ && (this.customize.domain === false || this.accountPlan.domain !== '')
+ && (this.customize.locale === false || this.accountPlan.locale !== '')
+ && (this.customize.timezone === false || this.accountPlan.timezone !== '')
+ && (this.customize.plan === false || this.accountPlan.plan !== '')
+ && (this.customize.footprint === false || this.accountPlan.footprint !== '')
+ && (this.accountPlan.paymentMethodObject.paymentMethodType != null)
+ && (this.accountPlan.paymentMethodObject.paymentInfo != null);
},
timezoneObjects: function () {
const tz_objects = [];
@@ -288,10 +288,7 @@
...mapActions('users', ['getPolicyByUuid']),
...mapActions('account', ['approveAction', 'resendVerificationCode']),
...mapActions('system', ['detectTimezone', 'detectLocale']),
- ...mapActions('networks', {
- createNewNetwork: 'create',
- getNearestRegions: 'getNearestRegions'
- }),
+ ...mapActions('networks', ['getNearestRegions', 'addPlanAndStartNetwork']),
...mapGetters('networks', ['loading']),
...mapActions('domains', {
loadDomains: 'getAll'
@@ -392,7 +389,7 @@
this.$validator.validate().then(valid => {
if (valid) {
if (this.paymentInfo) {
- this.network.paymentMethodObject = {
+ this.accountPlan.paymentMethodObject = {
paymentMethodType: this.paymentMethod.paymentMethodType,
paymentInfo: this.paymentInfo
};
@@ -400,9 +397,15 @@
if (cloudRegion === null) {
console.log('no region selected');
} else {
- console.log('sending create network: ' + JSON.stringify(this.network) + ' cloud/region=' + cloudRegion.cloud + '/' + cloudRegion.internalName);
+ console.log('sending accountPlan: ' + JSON.stringify(this.accountPlan) + ' cloud/region=' + cloudRegion.cloud + '/' + cloudRegion.internalName);
+ this.addPlanAndStartNetwork({
+ accountPlan: this.accountPlan,
+ cloud: cloudRegion.cloud,
+ region: cloudRegion.internalName,
+ messages: this.messages,
+ errors: this.errors
+ });
}
- // this.createNewNetwork(this.network);
}
}
});
@@ -411,19 +414,19 @@
watch: {
domains (doms) {
if (doms && doms[0]) {
- if (this.network.domain == null || this.network.domain === '') this.network.domain = doms[0].name;
+ if (this.accountPlan.domain == null || this.accountPlan.domain === '') this.accountPlan.domain = doms[0].name;
this.defaults.domain = doms[0].name;
}
},
detectedTimezone (tz) {
if (tz && tz.timeZoneId) {
- if (this.network.timezone == null || this.network.timezone === '') this.network.timezone = tz.timeZoneId;
+ if (this.accountPlan.timezone == null || this.accountPlan.timezone === '') this.accountPlan.timezone = tz.timeZoneId;
if (this.defaults.timezone == null || this.defaults.timezone === '') this.defaults.timezone = tz.timeZoneId;
}
},
detectedLocale (loc) {
if (loc) {
- if (this.network.locale === null || this.network.locale === '') this.network.locale = loc;
+ if (this.accountPlan.locale === null || this.accountPlan.locale === '') this.accountPlan.locale = loc;
this.defaults.locale = loc;
}
},
@@ -437,13 +440,13 @@
paymentMethod (pm) {
if (pm) {
this.selectedPaymentMethod = pm;
- this.network.paymentMethodObject.paymentMethodType = pm.paymentMethodType;
- this.network.paymentMethodObject.paymentInfo = null;
+ this.accountPlan.paymentMethodObject.paymentMethodType = pm.paymentMethodType;
+ this.accountPlan.paymentMethodObject.paymentInfo = null;
}
},
paymentInfo (info) {
if (info) {
- this.network.paymentMethodObject.paymentInfo = info;
+ this.accountPlan.paymentMethodObject.paymentInfo = info;
}
},
policy (p) {