Browse Source

refactor utils

pull/1/head
Jonathan Cobb 4 years ago
parent
commit
2344f3f050
22 changed files with 202 additions and 194 deletions
  1. +0
    -113
      src/_helpers/api-util.js
  2. +1
    -1
      src/_helpers/index.js
  3. +3
    -3
      src/_helpers/router.js
  4. +120
    -0
      src/_helpers/util.js
  5. +5
    -4
      src/_services/accountPlan.service.js
  6. +3
    -3
      src/_services/domain.service.js
  7. +3
    -3
      src/_services/footprint.service.js
  8. +4
    -4
      src/_services/network.service.js
  9. +6
    -6
      src/_services/paymentMethod.service.js
  10. +3
    -3
      src/_services/plan.service.js
  11. +11
    -11
      src/_services/system.service.js
  12. +17
    -17
      src/_services/user.service.js
  13. +3
    -3
      src/_store/account.module.js
  14. +2
    -2
      src/_store/accountPlans.module.js
  15. +2
    -2
      src/_store/domains.module.js
  16. +2
    -2
      src/_store/footprints.module.js
  17. +2
    -2
      src/_store/networks.module.js
  18. +2
    -2
      src/_store/paymentMethods.module.js
  19. +2
    -2
      src/_store/plans.module.js
  20. +2
    -2
      src/_store/users.module.js
  21. +6
    -6
      src/account/NewNetworkPage.vue
  22. +3
    -3
      src/auth/MultifactorAuthPage.vue

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

@@ -1,113 +0,0 @@
let landingPage = null;
export function getLandingPage () { return landingPage; }
export function setLandingPage (page) { landingPage = page; }
export function resetLandingPage () { landingPage = null; }

export function currentUser() {
let userJson = localStorage.getItem('user');
return userJson ? JSON.parse(userJson) : null;
}

export function userLoggedIn() { return !!currentUser(); }

export function authHeader() {
// return authorization header with jwt token
let user = currentUser();

if (user && user.token) {
return { 'X-Bubble-Session': user.token };
} else {
return {};
}
}

export function getWithAuth() {
return {
method: 'GET',
headers: authHeader()
};
}

function entityWithAuth(method, obj) {
if (typeof obj === 'undefined' || obj === null || obj === 'undefined') {
return {
method: method,
headers: { ...authHeader(), 'Content-Type': 'application/json' }
};
} else {
return {
method: method,
headers: { ...authHeader(), 'Content-Type': 'application/json' },
body: JSON.stringify(obj)
};
}
}

export function postWithAuth(obj) { return entityWithAuth('POST', obj); }

export function putWithAuth(obj) { return entityWithAuth('PUT', obj); }

export function deleteWithAuth() {
return {
method: 'DELETE',
headers: authHeader()
};
}

export function handleBasicResponse(response) {
return response.text().then(text => {
const data = text && JSON.parse(text);
if (!response.ok) {
const error = (data && data.message) || response.statusText;
return Promise.reject(error);
}
return data;
});
}

export function handleCrudResponse(messages, errors) {
return function (response) {
return response.text().then(text => {
const data = text && JSON.parse(text);
if (!response.ok) {
if (response.status === 404) {
// todo: show nicer error message
console.log('handleCrudResponse: received 404: ' + JSON.stringify(data));

} else if (response.status === 422) {
console.log('handleCrudResponse: received 422, error: ' + JSON.stringify(data));
setValidationErrors(data, messages, errors);
}

const error = (data && data.message) || response.statusText;
return Promise.reject(error);
}
return data;
});
}
}

export function setValidationErrors(data, messages, errors) {
for (let i=0; i<data.length; i++) {
if (data[i].messageTemplate) {
const parts = data[i].messageTemplate.split(/[._]+/);
if (parts.length === 3 && parts[0] === 'err') {
const field = parts[1];
const messageTemplate = data[i].messageTemplate.replace(/\./g, '_');
const message = messages.hasOwnProperty(messageTemplate) ? messages[messageTemplate] : '???'+messageTemplate;
errors.add({field: field, msg: message});
console.log('>>>>> field '+field+' added error: '+message+', errors='+JSON.stringify(errors));
}
}
// 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;
};
}

+ 1
- 1
src/_helpers/index.js View File

@@ -1,2 +1,2 @@
export * from './util';
export * from './router';
export * from './api-util';

+ 3
- 3
src/_helpers/router.js View File

@@ -17,7 +17,7 @@ import AccountsPage from '../admin/AccountsPage'
import StripePayment from "../account/payment/StripePayment";
import InviteCodePayment from "../account/payment/InviteCodePayment";
import UnknownPayment from "../account/payment/UnknownPayment";
import { currentUser, setLandingPage } from '../_helpers'
import { util } from '../_helpers'

Vue.use(Router);

@@ -79,12 +79,12 @@ export const router = new Router({
router.beforeEach((to, from, next) => {
const publicPages = ['/login', '/logout', '/register', '/auth'];
const authRequired = !publicPages.includes(to.path);
const user = currentUser();
const user = util.currentUser();

if (authRequired) {
// redirect to login page if not logged in and trying to access a restricted page
if (!user) {
setLandingPage(to);
util.setLandingPage(to);
return next('/login');
}



+ 120
- 0
src/_helpers/util.js View File

@@ -0,0 +1,120 @@
let landingPage = null;

export const util = {
getLandingPage: function () { return landingPage; },
setLandingPage: function (page) { landingPage = page; },
resetLandingPage: function () { landingPage = null; },

currentUser: function() {
let userJson = localStorage.getItem('user');
return userJson ? JSON.parse(userJson) : null;
},

userLoggedIn: function() { return !!util.currentUser(); },

authHeader: function() {
// return authorization header with jwt token
let user = util.currentUser();

if (user && user.token) {
return { 'X-Bubble-Session': user.token };
} else {
return {};
}
},

getWithAuth: function() {
return {
method: 'GET',
headers: authHeader()
};
},

entityWithAuth: function(method, obj) {
if (typeof obj === 'undefined' || obj === null || obj === 'undefined') {
return {
method: method,
headers: { ...authHeader(), 'Content-Type': 'application/json' }
};
} else {
return {
method: method,
headers: { ...authHeader(), 'Content-Type': 'application/json' },
body: JSON.stringify(obj)
};
}
},

postWithAuth: function(obj) { return entityWithAuth('POST', obj); },

putWithAuth: function(obj) { return entityWithAuth('PUT', obj); },

deleteWithAuth: function() {
return {
method: 'DELETE',
headers: authHeader()
};
},

handleBasicResponse: function(response) {
return response.text().then(text => {
const data = text && JSON.parse(text);
if (!response.ok) {
const error = (data && data.message) || response.statusText;
return Promise.reject(error);
}
return data;
});
},

handleCrudResponse: function(messages, errors) {
return function (response) {
return response.text().then(text => {
const data = text && JSON.parse(text);
if (!response.ok) {
if (response.status === 404) {
// todo: show nicer error message
console.log('handleCrudResponse: received 404: ' + JSON.stringify(data));

} else if (response.status === 422) {
console.log('handleCrudResponse: received 422, error: ' + JSON.stringify(data));
setValidationErrors(data, messages, errors);
}

const error = (data && data.message) || response.statusText;
return Promise.reject(error);
}
return data;
});
}
},

setValidationErrors: function(data, messages, errors) {
for (let i=0; i<data.length; i++) {
if (data[i].messageTemplate) {
const parts = data[i].messageTemplate.split(/[._]+/);
if (parts.length === 3 && parts[0] === 'err') {
const field = parts[1];
const messageTemplate = data[i].messageTemplate.replace(/\./g, '_');
const message = messages.hasOwnProperty(messageTemplate) ? messages[messageTemplate] : '???'+messageTemplate;
errors.add({field: field, msg: message});
console.log('>>>>> field '+field+' added error: '+message+', errors='+JSON.stringify(errors));
}
}
// todo: else add "global" error message for unrecognized/non-field error
}
},

checkLoading: function(loadingObject) {
return function() {
for (const key in loadingObject) {
if (loadingObject.hasOwnProperty(key)) {
if (loadingObject[key] === true) {
return true;
}
}
}
return false;
};
},
};

+ 5
- 4
src/_services/accountPlan.service.js View File

@@ -1,5 +1,6 @@
import config from 'config';
import { getWithAuth, putWithAuth, handleCrudResponse } from '../_helpers';
import { util } from '../_helpers';
// import { util.getWithAuth, util.putWithAuth, util.handleCrudResponse } from '../_helpers';

export const accountPlanService = {
getAll,
@@ -8,13 +9,13 @@ export const accountPlanService = {
};

function getAll(userId, messages, errors) {
return fetch(`${config.apiUrl}/users/${userId}/accountPlans`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${userId}/accountPlans`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getById(userId, accountPlanId, messages, errors) {
return fetch(`${config.apiUrl}/users/${userId}/accountPlans/${accountPlanId}`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${userId}/accountPlans/${accountPlanId}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function newAccountPlan(userId, accountPlan, messages, errors) {
return fetch(`${config.apiUrl}/users/${userId}/accountPlans`, putWithAuth(accountPlan)).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${userId}/accountPlans`, util.putWithAuth(accountPlan)).then(util.handleCrudResponse(messages, errors));
}

+ 3
- 3
src/_services/domain.service.js View File

@@ -1,5 +1,5 @@
import config from 'config';
import {currentUser, getWithAuth, handleCrudResponse} from '../_helpers';
import { util } from '../_helpers';

export const domainService = {
getAll,
@@ -7,9 +7,9 @@ export const domainService = {
};

function getAll(messages, errors) {
return fetch(`${config.apiUrl}/me/domains`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/me/domains`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getById(domainId, messages, errors) {
return fetch(`${config.apiUrl}/me/domains/${domainId}`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/me/domains/${domainId}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

+ 3
- 3
src/_services/footprint.service.js View File

@@ -1,5 +1,5 @@
import config from 'config';
import { getWithAuth, handleCrudResponse } from '../_helpers';
import { util } from '../_helpers';

export const footprintService = {
getAll,
@@ -7,9 +7,9 @@ export const footprintService = {
};

function getAll(messages, errors) {
return fetch(`${config.apiUrl}/me/footprints`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/me/footprints`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getById(footprintId, messages, errors) {
return fetch(`${config.apiUrl}/me/footprints/${footprintId}`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/me/footprints/${footprintId}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

+ 4
- 4
src/_services/network.service.js View File

@@ -1,5 +1,5 @@
import config from 'config';
import { getWithAuth, handleCrudResponse } from '../_helpers';
import { util } from '../_helpers';

export const networkService = {
getAll,
@@ -7,14 +7,14 @@ export const networkService = {
};

function getAll(userId, messages, errors) {
return fetch(`${config.apiUrl}/users/${userId}/networks`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${userId}/networks`, util.getWithAuth()).then(util.handleCrudResponse(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}`, util.getWithAuth()).then(util.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));
return fetch(`${config.apiUrl}/me/regions/closest${footprintParam}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

+ 6
- 6
src/_services/paymentMethod.service.js View File

@@ -1,5 +1,5 @@
import config from 'config';
import { getWithAuth, putWithAuth, handleCrudResponse } from '../_helpers';
import { util } from '../_helpers';

export const paymentMethodService = {
getAll,
@@ -10,22 +10,22 @@ export const paymentMethodService = {
};

function getAll(messages, errors) {
return fetch(`${config.apiUrl}/paymentMethods`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/paymentMethods`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getById(paymentMethodId, messages, errors) {
return fetch(`${config.apiUrl}/paymentMethods/${paymentMethodId}`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/paymentMethods/${paymentMethodId}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getAllByAccount(messages, errors) {
return fetch(`${config.apiUrl}/me/paymentMethods`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/me/paymentMethods`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getByAccountAndId(paymentMethodId, messages, errors) {
return fetch(`${config.apiUrl}/me/paymentMethods/${paymentMethodId}`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/me/paymentMethods/${paymentMethodId}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function addAccountPaymentMethod(paymentMethod, messages, errors) {
console.log("pmService: paymentMethod="+JSON.stringify(paymentMethod));
return fetch(`${config.apiUrl}/me/paymentMethods`, putWithAuth(paymentMethod)).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/me/paymentMethods`, util.putWithAuth(paymentMethod)).then(util.handleCrudResponse(messages, errors));
}

+ 3
- 3
src/_services/plan.service.js View File

@@ -1,5 +1,5 @@
import config from 'config';
import { getWithAuth, handleCrudResponse } from '../_helpers';
import { util } from '../_helpers';

export const planService = {
getAll,
@@ -7,9 +7,9 @@ export const planService = {
};

function getAll(messages, errors) {
return fetch(`${config.apiUrl}/plans`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/plans`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getById(planId, messages, errors) {
return fetch(`${config.apiUrl}/plans/${planId}`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/plans/${planId}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

+ 11
- 11
src/_services/system.service.js View File

@@ -1,5 +1,5 @@
import config from 'config';
import { getWithAuth, userLoggedIn, handleBasicResponse } from '../_helpers';
import { util } from '../_helpers';

export const systemService = {
loadSystemConfigs,
@@ -10,37 +10,37 @@ export const systemService = {
};

function loadSystemConfigs() {
const requestOptions = userLoggedIn() ? getWithAuth() : { method: 'GET' };
const requestOptions = util.userLoggedIn() ? util.getWithAuth() : { method: 'GET' };
return fetch(`${config.apiUrl}/auth/configs`, requestOptions)
.then(handleBasicResponse)
.then(util.handleBasicResponse)
.then(configs => { return configs; });
}

function loadMessages(group, locale) {
const requestOptions = userLoggedIn() ? getWithAuth() : { method: 'GET' };
const requestOptions = util.userLoggedIn() ? util.getWithAuth() : { method: 'GET' };
if (!locale || locale === '') locale = 'detect';
return fetch(`${config.apiUrl}/messages/${locale}/${group}`, requestOptions)
.then(handleBasicResponse)
.then(util.handleBasicResponse)
.then(messages => { return messages; });
}

function loadTimezones() {
const requestOptions = userLoggedIn() ? getWithAuth() : { method: 'GET' };
const requestOptions = util.userLoggedIn() ? util.getWithAuth() : { method: 'GET' };
return fetch(`${config.apiUrl}/timezones`, requestOptions)
.then(handleBasicResponse)
.then(util.handleBasicResponse)
.then(timezones => { return timezones; });
}

function detectTimezone() {
const requestOptions = userLoggedIn() ? getWithAuth() : { method: 'GET' };
const requestOptions = util.userLoggedIn() ? util.getWithAuth() : { method: 'GET' };
return fetch(`${config.apiUrl}/detect/timezone`, requestOptions)
.then(handleBasicResponse)
.then(util.handleBasicResponse)
.then(timezone => { return timezone; });
}

function detectLocale () {
const requestOptions = userLoggedIn() ? getWithAuth() : { method: 'GET' };
const requestOptions = util.userLoggedIn() ? util.getWithAuth() : { method: 'GET' };
return fetch(`${config.apiUrl}/detect/locale`, requestOptions)
.then(handleBasicResponse)
.then(util.handleBasicResponse)
.then(locales => { return locales; });
}

+ 17
- 17
src/_services/user.service.js View File

@@ -1,5 +1,5 @@
import config from 'config';
import { getWithAuth, postWithAuth, deleteWithAuth, handleCrudResponse, setValidationErrors } from '../_helpers';
import { util } from '../_helpers';

export const userService = {
login,
@@ -56,61 +56,61 @@ function register(user, messages, errors) {
}

function getAll(messages, errors) {
return fetch(`${config.apiUrl}/users`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getById(id, messages, errors) {
return fetch(`${config.apiUrl}/users/${id}`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${id}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getPolicyById(id, messages, errors) {
return fetch(`${config.apiUrl}/users/${id}/policy`, getWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${id}/policy`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function updatePolicyById(id, policy, messages, errors) {
return fetch(`${config.apiUrl}/users/${id}/policy`, postWithAuth(policy)).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${id}/policy`, util.postWithAuth(policy)).then(util.handleCrudResponse(messages, errors));
}

function addPolicyContactById(id, contact, messages, errors) {
return fetch(`${config.apiUrl}/users/${id}/policy/contacts`, postWithAuth(contact)).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${id}/policy/contacts`, util.postWithAuth(contact)).then(util.handleCrudResponse(messages, errors));
}

function removePolicyContactByUuid(id, uuid, messages, errors) {
return fetch(`${config.apiUrl}/users/${id}/policy/contacts/${uuid}`, deleteWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${id}/policy/contacts/${uuid}`, util.deleteWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function approveAction(id, code, messages, errors) {
return fetch(`${config.apiUrl}/auth/approve/${code}`, postWithAuth([{'name': 'account', 'value': id}]))
.then(handleCrudResponse(messages, errors))
return fetch(`${config.apiUrl}/auth/approve/${code}`, util.postWithAuth([{'name': 'account', 'value': id}]))
.then(util.handleCrudResponse(messages, errors))
.then(setSessionUser);
}

function sendAuthenticatorCode(id, code, verifyOnly, messages, errors) {
return fetch(`${config.apiUrl}/auth/authenticator`, postWithAuth({
return fetch(`${config.apiUrl}/auth/authenticator`, util.postWithAuth({
account: id,
token: code,
verify: verifyOnly
}))
.then(handleCrudResponse(messages, errors))
.then(util.handleCrudResponse(messages, errors))
.then(setSessionUser);
}

function resendVerificationCode(id, contact, messages, errors) {
return fetch(`${config.apiUrl}/users/${id}/policy/contacts/verify`, postWithAuth(contact))
.then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${id}/policy/contacts/verify`, util.postWithAuth(contact))
.then(util.handleCrudResponse(messages, errors));
}

function denyAction(id, code, messages, errors) {
return fetch(`${config.apiUrl}/auth/deny/${code}`, postWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/auth/deny/${code}`, util.postWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function update(user, messages, errors) {
return fetch(`${config.apiUrl}/users/${user.uuid}`, postWithAuth(user)).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${user.uuid}`, util.postWithAuth(user)).then(util.handleCrudResponse(messages, errors));
}

// prefixed function name with underscore because delete is a reserved word in javascript
function _delete(id, messages, errors) {
return fetch(`${config.apiUrl}/users/${id}`, deleteWithAuth()).then(handleCrudResponse(messages, errors));
return fetch(`${config.apiUrl}/users/${id}`, util.deleteWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function handleAuthResponse(messages, errors) {
@@ -129,7 +129,7 @@ function handleAuthResponse(messages, errors) {
console.log('handleAuthResponse: received 404, user not found: '+JSON.stringify(data));

} else if (response.status === 422) {
setValidationErrors(data, messages, errors);
util.setValidationErrors(data, messages, errors);
}
const error = (data && data.message) || response.statusText;
return Promise.reject(error);


+ 3
- 3
src/_store/account.module.js View File

@@ -1,5 +1,5 @@
import { userService } from '../_services';
import { router, getLandingPage, resetLandingPage } from '../_helpers';
import { router, util } from '../_helpers';

// todo: why can't we import currentUser from api-util and use that here?
// when I try to do that, webpack succeeds but then an error occurs loading any page, with the
@@ -22,11 +22,11 @@ const actions = {
user => {
commit('loginSuccess', user);
if (user.token) {
const landing = getLandingPage();
const landing = util.getLandingPage();
if (landing === null) {
router.replace('/');
} else {
resetLandingPage();
util.resetLandingPage();
router.replace(landing.fullPath);
}
} else if (user.multifactorAuth) {


+ 2
- 2
src/_store/accountPlans.module.js View File

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

const state = {
loading: {plans: false, plan: false, deleting: false},
@@ -82,7 +82,7 @@ const mutations = {
};

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

export const accountPlans = {


+ 2
- 2
src/_store/domains.module.js View File

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

const state = {
loading: {
@@ -56,7 +56,7 @@ const mutations = {
};

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

export const domains = {


+ 2
- 2
src/_store/footprints.module.js View File

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

const state = {
loading: { footprints: false, footprint: false },
@@ -54,7 +54,7 @@ const mutations = {
};

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

export const footprints = {


+ 2
- 2
src/_store/networks.module.js View File

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

const state = {
loading: {
@@ -107,7 +107,7 @@ const mutations = {
};

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

export const networks = {


+ 2
- 2
src/_store/paymentMethods.module.js View File

@@ -1,5 +1,5 @@
import { paymentMethodService } from '../_services';
import { checkLoading } from "../_helpers";
import { util } from '../_helpers';

const state = {
loading: {
@@ -149,7 +149,7 @@ const mutations = {
};

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

export const paymentMethods = {


+ 2
- 2
src/_store/plans.module.js View File

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

const state = {
loading: {plans: false, plan: false, deleting: false},
@@ -78,7 +78,7 @@ const mutations = {
};

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

export const plans = {


+ 2
- 2
src/_store/users.module.js View File

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

const state = {
loading: {
@@ -249,7 +249,7 @@ const mutations = {
};

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

export const users = {


+ 6
- 6
src/account/NewNetworkPage.vue View File

@@ -164,7 +164,7 @@

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

// convenience methods
import { isAuthenticator, isNotAuthenticator } from '../_store/users.module';
@@ -172,10 +172,10 @@
window.isNotAuthenticator = isNotAuthenticator;

function initDefaults(comp) {
comp.getPolicyByUuid({uuid: currentUser().uuid, messages: comp.messages, errors: comp.errors});
comp.getPolicyByUuid({uuid: util.currentUser().uuid, messages: comp.messages, errors: comp.errors});
comp.detectTimezone();
comp.detectLocale();
comp.loadDomains(currentUser().uuid, comp.messages, comp.errors);
comp.loadDomains(util.currentUser().uuid, comp.messages, comp.errors);
comp.loadPlans(comp.messages, comp.errors);
comp.loadFootprints(comp.messages, comp.errors);
comp.loadPaymentMethods(comp.messages, comp.errors);
@@ -213,7 +213,7 @@
footprint: 'Worldwide',
region: ''
},
user: currentUser(),
user: util.currentUser(),
submitted: false,
status: {
creating: false
@@ -357,7 +357,7 @@
if (code === null || code === '') return;
this.errors.clear();
this.approveAction({
uuid: currentUser().uuid,
uuid: util.currentUser().uuid,
code: code,
messages: this.messages,
errors: this.errors
@@ -368,7 +368,7 @@
},
resendVerification(contact) {
this.resendVerificationCode({
uuid: currentUser().uuid,
uuid: util.currentUser().uuid,
contact: contact,
messages: this.messages,
errors: this.errors


+ 3
- 3
src/auth/MultifactorAuthPage.vue View File

@@ -33,7 +33,7 @@

<script>
import { mapState, mapActions } from 'vuex'
import { getLandingPage, resetLandingPage } from '../_helpers';
import { util } from '../_helpers';

// convenience methods
import { isAuthenticator, isNotAuthenticator } from '../_store/users.module';
@@ -57,8 +57,8 @@
]),
isAuthenticator(val) { return window.isAuthenticator(val); },
isNotAuthenticator(val) { return window.isNotAuthenticator(val); },
getLandingPage() { return getLandingPage(); },
resetLandingPage() { return resetLandingPage(); },
getLandingPage() { return util.getLandingPage(); },
resetLandingPage() { return util.resetLandingPage(); },
submitVerification(auth) {
const uuid = auth.uuid;
const type = auth.type;


Loading…
Cancel
Save