Browse Source

refactor loading flags, start adding support for selecting cloud/region for new network

pull/1/head
Jonathan Cobb 4 years ago
parent
commit
ac8e492b4e
14 changed files with 251 additions and 108 deletions
  1. +9
    -0
      src/_helpers/api-util.js
  2. +5
    -0
      src/_services/network.service.js
  3. +1
    -0
      src/_store/account.module.js
  4. +17
    -11
      src/_store/accountPlans.module.js
  5. +16
    -8
      src/_store/domains.module.js
  6. +14
    -8
      src/_store/footprints.module.js
  7. +42
    -13
      src/_store/networks.module.js
  8. +28
    -19
      src/_store/paymentMethods.module.js
  9. +17
    -11
      src/_store/plans.module.js
  10. +48
    -21
      src/_store/users.module.js
  11. +3
    -3
      src/account/NetworkPage.vue
  12. +3
    -3
      src/account/NetworksPage.vue
  13. +44
    -8
      src/account/NewNetworkPage.vue
  14. +4
    -3
      src/admin/AccountsPage.vue

+ 9
- 0
src/_helpers/api-util.js View File

@@ -101,4 +101,13 @@ export function setValidationErrors(data, messages, errors) {
} }
// todo: else add "global" error message for unrecognized/non-field error // todo: else add "global" error message for unrecognized/non-field error
} }
}

export function checkLoading(loadingArray) {
return function() {
for (const key in loadingArray) {
if (key === true) return true;
}
return false;
};
} }

+ 5
- 0
src/_services/network.service.js View File

@@ -13,3 +13,8 @@ function getAll(userId, messages, errors) {
function getById(userId, networkId, messages, errors) { function getById(userId, networkId, messages, errors) {
return fetch(`${config.apiUrl}/users/${userId}/networks/${networkId}`, getWithAuth()).then(handleCrudResponse(messages, errors)); return fetch(`${config.apiUrl}/users/${userId}/networks/${networkId}`, getWithAuth()).then(handleCrudResponse(messages, errors));
} }

function getNearestRegions(userId, footprint, messages, errors) {
const footprintParam = (typeof footprint === "undefined" || footprint === null || footprint === '') ? "" : `?footprint=${footprint}`;
return fetch(`${config.apiUrl}/me/regions/closest${footprintParam}`, getWithAuth()).then(handleCrudResponse(messages, errors));
}

+ 1
- 0
src/_store/account.module.js View File

@@ -122,6 +122,7 @@ const actions = {


const mutations = { const mutations = {
refreshUser(state, user) { refreshUser(state, user) {
state.status = { loggedIn: (user !== null) };
state.user = user; state.user = user;
}, },
loginRequest(state, user) { loginRequest(state, user) {


+ 17
- 11
src/_store/accountPlans.module.js View File

@@ -1,8 +1,9 @@
import { accountPlanService } from '../_services'; import { accountPlanService } from '../_services';
import { account } from '../_store/account.module'; import { account } from '../_store/account.module';
import { checkLoading } from "../_helpers";


const state = { const state = {
loading: null,
loading: {plans: false, plan: false, deleting: false},
error: null, error: null,
accountPlans: null, accountPlans: null,
accountPlan: null accountPlan: null
@@ -42,47 +43,52 @@ const actions = {


const mutations = { const mutations = {
getAllRequest(state) { getAllRequest(state) {
state.loading = true;
state.loading.plans = true;
}, },
getAllSuccess(state, accountPlans) { getAllSuccess(state, accountPlans) {
state.loading = false;
state.loading.plans = false;
state.accountPlans = accountPlans; state.accountPlans = accountPlans;
}, },
getAllFailure(state, error) { getAllFailure(state, error) {
state.loading = false;
state.loading.plans = false;
state.error = { error }; state.error = { error };
}, },
getByUuidRequest(state) { getByUuidRequest(state) {
state.loading = true;
state.loading.plan = true;
}, },
getByUuidSuccess(state, accountPlan) { getByUuidSuccess(state, accountPlan) {
state.loading = false;
state.loading.plan = false;
state.accountPlan = accountPlan; state.accountPlan = accountPlan;
}, },
getByUuidFailure(state, error) { getByUuidFailure(state, error) {
state.loading = false;
state.loading.plan = false;
state.error = { error }; state.error = { error };
}, },
deleteRequest(state, id) { deleteRequest(state, id) {
state.loading = true;
state.loading.deleting = true;
}, },
deleteSuccess(state, id) { deleteSuccess(state, id) {
state.loading = false;
state.loading.deleting = false;
// remove deleted accountPlan from state // remove deleted accountPlan from state
if (state.accountPlans) { if (state.accountPlans) {
state.accountPlans = state.accountPlans.filter(accountPlan => accountPlan.uuid !== id) state.accountPlans = state.accountPlans.filter(accountPlan => accountPlan.uuid !== id)
} }
}, },
deleteFailure(state, { id, error }) { deleteFailure(state, { id, error }) {
state.loading = false;
state.loading.deleting = false;
// remove 'deleting:true' property and add 'deleteError:[error]' property to accountPlan // remove 'deleting:true' property and add 'deleteError:[error]' property to accountPlan
state.error = error; state.error = error;
} }
}; };


const getters = {
loading: checkLoading(state.loading)
};

export const accountPlans = { export const accountPlans = {
namespaced: true, namespaced: true,
state, state,
actions, actions,
mutations
mutations,
getters
}; };

+ 16
- 8
src/_store/domains.module.js View File

@@ -1,7 +1,10 @@
import { domainService } from '../_services'; import { domainService } from '../_services';
import { checkLoading } from "../_helpers";


const state = { const state = {
loading: null,
loading: {
domains: false, domain: false
},
error: null, error: null,
domains: null, domains: null,
domain: null domain: null
@@ -29,32 +32,37 @@ const actions = {


const mutations = { const mutations = {
getAllRequest(state) { getAllRequest(state) {
state.loading = true;
state.loading.domains = true;
}, },
getAllSuccess(state, domains) { getAllSuccess(state, domains) {
state.loading = false;
state.loading.domains = false;
state.domains = domains; state.domains = domains;
}, },
getAllFailure(state, error) { getAllFailure(state, error) {
state.loading = false;
state.loading.domains = false;
state.error = { error }; state.error = { error };
}, },
getByUuidRequest(state) { getByUuidRequest(state) {
state.loading = true;
state.loading.domain = true;
}, },
getByUuidSuccess(state, domain) { getByUuidSuccess(state, domain) {
state.loading = false;
state.loading.domain = false;
state.domain = domain; state.domain = domain;
}, },
getByUuidFailure(state, error) { getByUuidFailure(state, error) {
state.loading = false;
state.loading.domain = false;
state.error = { error }; state.error = { error };
} }
}; };


const getters = {
loading: checkLoading(state.loading)
};

export const domains = { export const domains = {
namespaced: true, namespaced: true,
state, state,
actions, actions,
mutations
mutations,
getters
}; };

+ 14
- 8
src/_store/footprints.module.js View File

@@ -1,7 +1,8 @@
import { footprintService } from '../_services'; import { footprintService } from '../_services';
import { checkLoading } from "../_helpers";


const state = { const state = {
loading: null,
loading: { footprints: false, footprint: false },
error: null, error: null,
footprints: null, footprints: null,
footprint: null footprint: null
@@ -29,32 +30,37 @@ const actions = {


const mutations = { const mutations = {
getAllRequest(state) { getAllRequest(state) {
state.loading = true;
state.loading.footprints = true;
}, },
getAllSuccess(state, footprints) { getAllSuccess(state, footprints) {
state.loading = false;
state.loading.footprints = false;
state.footprints = footprints; state.footprints = footprints;
}, },
getAllFailure(state, error) { getAllFailure(state, error) {
state.loading = false;
state.loading.footprints = false;
state.error = { error }; state.error = { error };
}, },
getByUuidRequest(state) { getByUuidRequest(state) {
state.loading = true;
state.loading.footprint = true;
}, },
getByUuidSuccess(state, footprint) { getByUuidSuccess(state, footprint) {
state.loading = false;
state.loading.footprint = false;
state.footprint = footprint; state.footprint = footprint;
}, },
getByUuidFailure(state, error) { getByUuidFailure(state, error) {
state.loading = false;
state.loading.footprint = false;
state.error = { error }; state.error = { error };
} }
}; };


const getters = {
loading: checkLoading(state.loading)
};

export const footprints = { export const footprints = {
namespaced: true, namespaced: true,
state, state,
actions, actions,
mutations
mutations,
getters
}; };

+ 42
- 13
src/_store/networks.module.js View File

@@ -1,12 +1,16 @@
import { networkService } from '../_services'; import { networkService } from '../_services';
import { account } from '../_store/account.module'; import { account } from '../_store/account.module';
import { checkLoading } from "../_helpers";


const state = { const state = {
loading: null,
loading: {
networks: false, network: false, deleting: false, nearestRegions: false
},
creating: null, creating: null,
error: null, error: null,
networks: null, networks: null,
network: null
network: null,
nearestRegions: null
}; };


const actions = { const actions = {
@@ -39,52 +43,77 @@ const actions = {
network => commit('deleteSuccess', network), network => commit('deleteSuccess', network),
error => commit('deleteFailure', { id, error: error.toString() }) error => commit('deleteFailure', { id, error: error.toString() })
); );
}
},

getNearestRegions({ commit }, {footprint, messages, errors}) {
commit('getNearestRegionsRequest');
networkService.getNearestRegions(account.state.user.uuid, footprint, messages, errors)
.then(
regions => commit('getNearestRegionsSuccess', regions),
error => commit('getNearestRegionsFailure', error)
);
},
}; };


const mutations = { const mutations = {
getAllRequest(state) { getAllRequest(state) {
state.loading = true;
state.loading.networks = true;
}, },
getAllSuccess(state, networks) { getAllSuccess(state, networks) {
state.loading = false;
state.loading.networks = false;
state.networks = networks; state.networks = networks;
}, },
getAllFailure(state, error) { getAllFailure(state, error) {
state.loading = false;
state.loading.networks = false;
state.error = { error }; state.error = { error };
}, },
getByUuidRequest(state) { getByUuidRequest(state) {
state.loading = true;
state.loading.network = true;
}, },
getByUuidSuccess(state, network) { getByUuidSuccess(state, network) {
state.loading = false;
state.loading.network = false;
state.network = network; state.network = network;
}, },
getByUuidFailure(state, error) { getByUuidFailure(state, error) {
state.loading = false;
state.loading.network = false;
state.error = { error }; state.error = { error };
}, },
deleteRequest(state, id) { deleteRequest(state, id) {
state.loading = true;
state.loading.deleting = true;
}, },
deleteSuccess(state, id) { deleteSuccess(state, id) {
state.loading = false;
state.loading.deleting = false;
// remove deleted network from state // remove deleted network from state
if (state.networks) { if (state.networks) {
state.networks = state.networks.filter(network => network.uuid !== id) state.networks = state.networks.filter(network => network.uuid !== id)
} }
}, },
deleteFailure(state, { id, error }) { deleteFailure(state, { id, error }) {
state.loading = false;
state.loading.deleting = false;
// remove 'deleting:true' property and add 'deleteError:[error]' property to network // remove 'deleting:true' property and add 'deleteError:[error]' property to network
state.error = error; state.error = error;
},
getNearestRegionsRequest(state) {
state.loading.nearestRegions = true;
},
getNearestRegionsSuccess(state, regions) {
state.loading.nearestRegions = false;
state.nearestRegions = regions;
},
getNearestRegionsFailure(state, error) {
state.loading.nearestRegions = false;
state.error = { error };
} }
}; };


const getters = {
loading: checkLoading(state.loading)
};

export const networks = { export const networks = {
namespaced: true, namespaced: true,
state, state,
actions, actions,
mutations
mutations,
getters
}; };

+ 28
- 19
src/_store/paymentMethods.module.js View File

@@ -1,7 +1,12 @@
import {footprintService, paymentMethodService} from '../_services';
import { paymentMethodService } from '../_services';
import { checkLoading } from "../_helpers";


const state = { const state = {
loading: null,
loading: {
paymentMethods: false, paymentMethod: false,
accountPaymentMethods: false, accountPaymentMethod: false,
adding: false
},
paymentStatus: {}, paymentStatus: {},
error: null, error: null,
errors: null, errors: null,
@@ -69,25 +74,25 @@ const actions = {


const mutations = { const mutations = {
getAllRequest(state) { getAllRequest(state) {
state.loading = true;
state.loading.paymentMethods = true;
}, },
getAllSuccess(state, paymentMethods) { getAllSuccess(state, paymentMethods) {
state.loading = false;
state.loading.paymentMethods = false;
state.paymentMethods = paymentMethods; state.paymentMethods = paymentMethods;
}, },
getAllFailure(state, error) { getAllFailure(state, error) {
state.loading = false;
state.loading.paymentMethods = false;
state.error = { error }; state.error = { error };
}, },
getByUuidRequest(state) { getByUuidRequest(state) {
state.loading = true;
state.loading.paymentMethod = true;
}, },
getByUuidSuccess(state, paymentMethod) { getByUuidSuccess(state, paymentMethod) {
state.loading = false;
state.loading.paymentMethod = false;
state.paymentMethod = paymentMethod; state.paymentMethod = paymentMethod;
}, },
getByUuidFailure(state, error) { getByUuidFailure(state, error) {
state.loading = false;
state.loading.paymentMethod = false;
state.error = { error }; state.error = { error };
}, },


@@ -98,44 +103,43 @@ const mutations = {
}, },


getAllByAccountRequest(state) { getAllByAccountRequest(state) {
state.loading = true;
state.loading.accountPaymentMethods = true;
}, },
getAllByAccountSuccess(state, paymentMethods) { getAllByAccountSuccess(state, paymentMethods) {
state.loading = false;
state.loading.accountPaymentMethods = false;
state.accountPaymentMethods = paymentMethods; state.accountPaymentMethods = paymentMethods;
}, },
getAllByAccountFailure(state, error) { getAllByAccountFailure(state, error) {
state.loading = false;
state.loading.accountPaymentMethods = false;
state.error = { error }; state.error = { error };
}, },


getByAccountAndIdRequest(state) { getByAccountAndIdRequest(state) {
state.loading = true;
state.loading.accountPaymentMethod = true;
}, },
getByAccountAndIdSuccess(state, paymentMethod) { getByAccountAndIdSuccess(state, paymentMethod) {
state.loading = false;
state.loading.accountPaymentMethod = false;
state.accountPaymentMethod = paymentMethod; state.accountPaymentMethod = paymentMethod;
}, },
getByAccountAndIdFailure(state, error) { getByAccountAndIdFailure(state, error) {
state.loading = false;
state.loading.accountPaymentMethod = false;
state.error = { error }; state.error = { error };
}, },


addAccountPaymentMethodRequest(state) { addAccountPaymentMethodRequest(state) {
state.loading.adding = true;
state.errors = null; state.errors = null;
state.paymentStatus = { addingPaymentMethod: true }; state.paymentStatus = { addingPaymentMethod: true };
state.loading = true;
}, },
addAccountPaymentMethodSuccess(state, {paymentMethod, originalPaymentMethod}) { addAccountPaymentMethodSuccess(state, {paymentMethod, originalPaymentMethod}) {
state.loading.adding = false;
state.paymentStatus = { addedPaymentMethod: true }; state.paymentStatus = { addedPaymentMethod: true };
state.loading = false;
state.accountPaymentMethod = paymentMethod; state.accountPaymentMethod = paymentMethod;
state.paymentInfo = originalPaymentMethod.paymentInfo; state.paymentInfo = originalPaymentMethod.paymentInfo;
}, },
addAccountPaymentMethodFailure(state, errors) { addAccountPaymentMethodFailure(state, errors) {
console.log("addAccountPaymentMethodFailure: errors="+JSON.stringify(errors));
state.loading.adding = false;
state.paymentStatus = {}; state.paymentStatus = {};
state.loading = false;
state.errors = errors; state.errors = errors;
}, },


@@ -144,9 +148,14 @@ const mutations = {
} }
}; };


const getters = {
loading: checkLoading(state.loading)
};

export const paymentMethods = { export const paymentMethods = {
namespaced: true, namespaced: true,
state, state,
actions, actions,
mutations
mutations,
getters
}; };

+ 17
- 11
src/_store/plans.module.js View File

@@ -1,7 +1,8 @@
import { planService } from '../_services'; import { planService } from '../_services';
import { checkLoading } from "../_helpers";


const state = { const state = {
loading: null,
loading: {plans: false, plan: false, deleting: false},
error: null, error: null,
plans: null, plans: null,
plan: null plan: null
@@ -38,47 +39,52 @@ const actions = {


const mutations = { const mutations = {
getAllRequest(state) { getAllRequest(state) {
state.loading = true;
state.loading.plans = true;
}, },
getAllSuccess(state, plans) { getAllSuccess(state, plans) {
state.loading = false;
state.loading.plans = false;
state.plans = plans; state.plans = plans;
}, },
getAllFailure(state, error) { getAllFailure(state, error) {
state.loading = false;
state.loading.plans = false;
state.error = { error }; state.error = { error };
}, },
getByUuidRequest(state) { getByUuidRequest(state) {
state.loading = true;
state.loading.plan = true;
}, },
getByUuidSuccess(state, plan) { getByUuidSuccess(state, plan) {
state.loading = false;
state.loading.plan = false;
state.plan = plan; state.plan = plan;
}, },
getByUuidFailure(state, error) { getByUuidFailure(state, error) {
state.loading = false;
state.loading.plan = false;
state.error = { error }; state.error = { error };
}, },
deleteRequest(state, id) { deleteRequest(state, id) {
state.loading = true;
state.loading.deleting = true;
}, },
deleteSuccess(state, id) { deleteSuccess(state, id) {
state.loading = false;
state.loading.deleting = false;
// remove deleted plan from state // remove deleted plan from state
if (state.plans) { if (state.plans) {
state.plans = state.plans.filter(plan => plan.uuid !== id) state.plans = state.plans.filter(plan => plan.uuid !== id)
} }
}, },
deleteFailure(state, { id, error }) { deleteFailure(state, { id, error }) {
state.loading = false;
state.loading.deleting = false;
// remove 'deleting:true' property and add 'deleteError:[error]' property to user // remove 'deleting:true' property and add 'deleteError:[error]' property to user
state.error = error; state.error = error;
} }
}; };


const getters = {
loading: checkLoading(state.loading)
};

export const plans = { export const plans = {
namespaced: true, namespaced: true,
state, state,
actions, actions,
mutations
mutations,
getters
}; };

+ 48
- 21
src/_store/users.module.js View File

@@ -1,11 +1,16 @@
import { userService } from '../_services'; import { userService } from '../_services';
import { account } from '../_store/account.module'; import { account } from '../_store/account.module';
import { checkLoading } from "../_helpers";


const state = { const state = {
all: {},
loading: {
users: false, user: false, updating: false, deleting: false,
policy: false, updatingPolicy: false, addPolicyContact: false, removePolicyContact: false
},
errors: {},
users: null,
user: null, user: null,
policy: {}, policy: {},
policyStatus: {},
contact: null, contact: null,
authenticator: {} authenticator: {}
}; };
@@ -120,53 +125,61 @@ const actions = {


const mutations = { const mutations = {
getAllRequest(state) { getAllRequest(state) {
state.all = { loading: true };
state.loading.users = true;
}, },
getAllSuccess(state, users) { getAllSuccess(state, users) {
state.all = { items: users };
state.loading.users = false;
state.users = users;
}, },
getAllFailure(state, error) { getAllFailure(state, error) {
state.all = { error };
state.loading.users = false;
state.errors.all = error;
}, },


getByUuidRequest(state) { getByUuidRequest(state) {
state.user = { loading: true };
state.loading.user = true;
}, },
getByUuidSuccess(state, user) { getByUuidSuccess(state, user) {
state.loading.user = false;
state.user = user; state.user = user;
}, },
getByUuidFailure(state, error) { getByUuidFailure(state, error) {
state.user = { error };
state.loading.user = false;
state.errors.user = error;
}, },


getPolicyByUuidRequest(state) { getPolicyByUuidRequest(state) {
state.loading.policy = true;
state.user = { loading: true }; state.user = { loading: true };
}, },
getPolicyByUuidSuccess(state, policy) { getPolicyByUuidSuccess(state, policy) {
state.loading.policy = false;
state.policy = policy; state.policy = policy;
setAuthenticator(policy); setAuthenticator(policy);
}, },
getPolicyByUuidFailure(state, error) { getPolicyByUuidFailure(state, error) {
state.policy = { error };
state.loading.policy = false;
state.errors.policy = error;
}, },


updatePolicyByUuidRequest(state) { updatePolicyByUuidRequest(state) {
state.policyStatus = { updating: true };
state.loading.updatingPolicy = true;
}, },
updatePolicyByUuidSuccess(state, policy) { updatePolicyByUuidSuccess(state, policy) {
state.policyStatus = {};
state.loading.updatingPolicy = false;
state.policy = policy; state.policy = policy;
setAuthenticator(policy); setAuthenticator(policy);
}, },
updatePolicyByUuidFailure(state, error) { updatePolicyByUuidFailure(state, error) {
state.policyStatus = {};
state.loading.updatingPolicy = false;
state.policy = { error }; state.policy = { error };
}, },


addPolicyContactByUuidRequest(state) { addPolicyContactByUuidRequest(state) {
state.user = { loading: true };
state.loading.addPolicyContact = true;
}, },
addPolicyContactByUuidSuccess(state, contact) { addPolicyContactByUuidSuccess(state, contact) {
state.loading.addPolicyContact = false;
state.contact = contact; state.contact = contact;
if (isAuthenticator(contact)) { if (isAuthenticator(contact)) {
state.authenticator = JSON.parse(contact.info); state.authenticator = JSON.parse(contact.info);
@@ -174,46 +187,55 @@ const mutations = {
} }
}, },
addPolicyContactByUuidFailure(state, error) { addPolicyContactByUuidFailure(state, error) {
state.contact = { error };
state.loading.addPolicyContact = false;
state.errors.contact = error;
}, },


removePolicyContactByUuidRequest(state) { removePolicyContactByUuidRequest(state) {
state.user = { loading: true };
state.loading.removePolicyContact = true;
}, },
removePolicyContactByUuidSuccess(state, policy) { removePolicyContactByUuidSuccess(state, policy) {
state.loading.removePolicyContact = false;
state.policy = policy; state.policy = policy;
}, },
removePolicyContactByUuidFailure(state, error) { removePolicyContactByUuidFailure(state, error) {
state.policy = { error };
state.loading.removePolicyContact = false;
state.errors.policy = error;
}, },


updateRequest(state, user) { updateRequest(state, user) {
// todo: add 'updating:true' property to user being updated
state.loading.updating = true;
}, },
updateSuccess(state, user) { updateSuccess(state, user) {
state.loading.updating = false;
user.token = account.state.user.token; // preserve token user.token = account.state.user.token; // preserve token
state.user = account.state.user = user; state.user = account.state.user = user;
localStorage.setItem('user', JSON.stringify(user)); localStorage.setItem('user', JSON.stringify(user));
}, },
updateFailure(state, { id, error }) { updateFailure(state, { id, error }) {
// todo: remove 'updating:true' property and add 'updateError:[error]' property to user
state.loading.updating = false;
state.errors.update = error;
}, },


deleteRequest(state, id) { deleteRequest(state, id) {
// todo: use proper delete API
// add 'deleting:true' property to user being deleted // add 'deleting:true' property to user being deleted
state.all.items = state.all.items.map(user =>
state.loading.deleting = true;
state.users = state.users.map(user =>
user.uuid === id user.uuid === id
? { ...user, deleting: true } ? { ...user, deleting: true }
: user : user
) )
}, },
deleteSuccess(state, id) { deleteSuccess(state, id) {
state.loading.deleting = false;
// remove deleted user from state // remove deleted user from state
state.all.items = state.all.items.filter(user => user.uuid !== id)
state.users = state.users.filter(user => user.uuid !== id)
}, },
deleteFailure(state, { id, error }) { deleteFailure(state, { id, error }) {
state.loading.deleting = false;
// remove 'deleting:true' property and add 'deleteError:[error]' property to user // remove 'deleting:true' property and add 'deleteError:[error]' property to user
state.all.items = state.items.map(user => {
state.users = state.users.map(user => {
if (user.uuid === id) { if (user.uuid === id) {
// make copy of user without 'deleting:true' property // make copy of user without 'deleting:true' property
const { deleting, ...userCopy } = user; const { deleting, ...userCopy } = user;
@@ -226,9 +248,14 @@ const mutations = {
} }
}; };


const getters = {
loading: checkLoading(state.loading)
};

export const users = { export const users = {
namespaced: true, namespaced: true,
state, state,
actions, actions,
mutations
mutations,
getters
}; };

+ 3
- 3
src/account/NetworkPage.vue View File

@@ -5,12 +5,11 @@
</template> </template>


<script> <script>
import { mapState, mapActions } from 'vuex'
import { mapState, mapActions, mapGetters } from 'vuex'


export default { export default {
computed: { computed: {
...mapState({ ...mapState({
loading: state => state.loading,
network: state => state.network, network: state => state.network,
error: state => state.error error: state => state.error
}) })
@@ -22,7 +21,8 @@
...mapActions('networks', { ...mapActions('networks', {
getById: 'getByUuid', getById: 'getByUuid',
deleteNetwork: 'delete' deleteNetwork: 'delete'
})
}),
...mapGetters('networks', ['loading'])
} }
}; };
</script> </script>

+ 3
- 3
src/account/NetworksPage.vue View File

@@ -41,12 +41,11 @@
</template> </template>


<script> <script>
import { mapState, mapActions } from 'vuex'
import { mapState, mapActions, mapGetters } from 'vuex'


export default { export default {
computed: { computed: {
...mapState({ ...mapState({
loading: state => state.networks.loading,
networks: state => state.networks.networks networks: state => state.networks.networks
}), }),
...mapState('system', ['messages']) ...mapState('system', ['messages'])
@@ -58,7 +57,8 @@
...mapActions('networks', { ...mapActions('networks', {
getAllNetworks: 'getAll', getAllNetworks: 'getAll',
deleteNetwork: 'delete' deleteNetwork: 'delete'
})
}),
...mapGetters('networks', ['loading'])
} }
}; };
</script> </script>

+ 44
- 8
src/account/NewNetworkPage.vue View File

@@ -100,6 +100,24 @@
</div> </div>
<hr/> <hr/>


<!-- cloud+region -->
<div v-if="customize.region === true" class="form-group">
<label htmlFor="region">{{messages.field_label_region}}</label>
<v-select v-validate="'required'" v-if="regionObjects" :options="regionObjects" :reduce="region => region.cloud+':'+region.internalName" label="name" :value="cloudRegion" type="text" v-model="cloudRegion" name="region" class="form-control" :class="{ 'is-invalid': submitted && errors.has('region') }"></v-select>
<div v-if="submitted && errors.has('region')" class="invalid-feedback">{{ errors.first('region') }}</div>
<button @click="customize.region = false">{{messages.button_label_use_default}}</button>
</div>
<div v-if="customize.region === false">
{{messages.field_label_region}}:
<span v-if="defaults.region">{{defaults.region.name}}</span>
<span v-else>{{messages.message_auto_detecting}}</span>
<button @click="customize.region = true">{{messages.button_label_customize}}</button>
</div>
<div>
{{cloudRegion.name}}
</div>
<hr/>

<!-- footprint --> <!-- footprint -->
<div v-if="customize.footprint === true" class="form-group"> <div v-if="customize.footprint === true" class="form-group">
<label htmlFor="footprint">{{messages.field_label_footprint}}</label> <label htmlFor="footprint">{{messages.field_label_footprint}}</label>
@@ -121,7 +139,7 @@
<div class="form-group"> <div class="form-group">
<label htmlFor="paymentMethod">{{messages.field_label_paymentMethod}}</label> <label htmlFor="paymentMethod">{{messages.field_label_paymentMethod}}</label>
<span v-for="pm in paymentMethods"> <span v-for="pm in paymentMethods">
<button class="btn btn-primary" :disabled="status.creating" @click="setPaymentMethod(pm)">{{messages['payment_description_'+pm.paymentMethodType]}}</button>
<button class="btn btn-primary" :disabled="status.loading" @click="setPaymentMethod(pm)">{{messages['payment_description_'+pm.paymentMethodType]}}</button>
</span> </span>
</div> </div>


@@ -136,8 +154,8 @@
<hr/> <hr/>


<div class="form-group"> <div class="form-group">
<button class="btn btn-primary" :disabled="status.creating || !isComplete">{{messages.button_label_create_new_network}}</button>
<img v-show="status.creating" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
<button class="btn btn-primary" :disabled="status.loading || !isComplete">{{messages.button_label_create_new_network}}</button>
<img v-show="status.loading" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
</div> </div>
</form> </form>
</div> </div>
@@ -145,7 +163,7 @@
</template> </template>


<script> <script>
import { mapState, mapActions } from 'vuex'
import { mapState, mapActions, mapGetters } from 'vuex'
import { currentUser } from '../_helpers' import { currentUser } from '../_helpers'


// convenience methods // convenience methods
@@ -178,19 +196,22 @@
paymentInfo: null paymentInfo: null
} }
}, },
cloudRegion: '',
customize: { customize: {
domain: false, domain: false,
locale: false, locale: false,
timezone: false, timezone: false,
plan: false, plan: false,
footprint: false
footprint: false,
region: false
}, },
defaults: { defaults: {
domain: '', domain: '',
locale: '', locale: '',
timezone: '', timezone: '',
plan: 'bubble', plan: 'bubble',
footprint: 'Worldwide'
footprint: 'Worldwide',
region: ''
}, },
user: currentUser(), user: currentUser(),
submitted: false, submitted: false,
@@ -208,8 +229,8 @@
...mapState('plans', ['plans']), ...mapState('plans', ['plans']),
...mapState('footprints', ['footprints']), ...mapState('footprints', ['footprints']),
...mapState('paymentMethods', ['paymentMethods', 'paymentMethod', 'paymentInfo']), ...mapState('paymentMethods', ['paymentMethods', 'paymentMethod', 'paymentInfo']),
...mapState('networks', ['nearestRegions']),
...mapState('networks', { ...mapState('networks', {
creating: state => state.loading,
error: state => state.error error: state => state.error
}), }),
...mapState('users', ['policy']), ...mapState('users', ['policy']),
@@ -259,6 +280,19 @@
} }
} }
return fp_array; return fp_array;
},
regionObjects: function () {
const regions_array = [];
if (this.footprints) {
for (let i = 0; i < this.footprints.length; i++) {
fp_array.push({
...this.footprints[i],
localName: this.messages['footprint_name_' + this.footprints[i].name],
description: this.messages['footprint_description_' + this.footprints[i].name]
})
}
}
return regions_array;
} }
}, },
methods: { methods: {
@@ -266,8 +300,10 @@
...mapActions('account', ['approveAction', 'resendVerificationCode']), ...mapActions('account', ['approveAction', 'resendVerificationCode']),
...mapActions('system', ['detectTimezone', 'detectLocale']), ...mapActions('system', ['detectTimezone', 'detectLocale']),
...mapActions('networks', { ...mapActions('networks', {
createNewNetwork: 'create'
createNewNetwork: 'create',
getNearestRegions: 'getNearestRegions'
}), }),
...mapGetters('networks', ['loading']),
...mapActions('domains', { ...mapActions('domains', {
loadDomains: 'getAll' loadDomains: 'getAll'
}), }),


+ 4
- 3
src/admin/AccountsPage.vue View File

@@ -20,13 +20,13 @@
</template> </template>


<script> <script>
import { mapState, mapActions } from 'vuex'
import { mapState, mapActions, mapGetters } from 'vuex'


export default { export default {
computed: { computed: {
...mapState({ ...mapState({
account: state => state.account, account: state => state.account,
users: state => state.users.all
users: state => state.users
}) })
}, },
created () { created () {
@@ -36,7 +36,8 @@
...mapActions('users', { ...mapActions('users', {
getAllUsers: 'getAll', getAllUsers: 'getAll',
deleteUser: 'delete' deleteUser: 'delete'
})
}),
...mapGetters('users', ['loading'])
} }
}; };
</script> </script>

Loading…
Cancel
Save