Quellcode durchsuchen

fix: issues

pull/70/head
Tyler Chen vor 4 Jahren
Ursprung
Commit
c6cfaf483f
9 geänderte Dateien mit 582 neuen und 396 gelöschten Zeilen
  1. +3
    -0
      src/_components/layout/Footer.vue
  2. +97
    -1
      src/_components/modals/LaunchBubbleSettingsModal.vue
  3. +9
    -0
      src/_pages/main/account/Policy.vue
  4. +1
    -1
      src/_pages/main/account/Support.vue
  5. +21
    -0
      src/_pages/main/bubble/LaunchBubble.vue
  6. +7
    -0
      src/_pages/main/bubble/Network.vue
  7. +4
    -0
      src/_router/index.js
  8. +3
    -7
      src/_store/account.module.js
  9. +437
    -387
      src/_store/users.module.js

+ 3
- 0
src/_components/layout/Footer.vue Datei anzeigen

@@ -21,6 +21,9 @@
v-for="item in footerLinks"
:key="item"
:href="messages[`link_${item}`]"
:target="
messages[`link_${item}`].startsWith('http') ? '_blank' : '_self'
"
>
{{ messages[`title_${item}`] }}
</a>


+ 97
- 1
src/_components/modals/LaunchBubbleSettingsModal.vue Datei anzeigen

@@ -89,6 +89,49 @@
</div>
</div>

<div class="form-group" v-if="planObjects">
<v-select
v-model="accountPlan.plan"
name="plan"
:class="{ 'is-invalid': submitted && errors.has('plan') }"
:options="planObjects"
label="name"
:placeholder="messages.field_label_plan"
:reduce="(option) => option.name"
>
<template v-slot:option="option">
<span>
{{ messages['plan_name_' + option.name] }} -
{{
messages.price_format.parseExpression({
messages: messages,
...option,
})
}}
</span>
</template>
<template v-slot:selected-option="option">
<span>
{{ messages.field_label_plan }}:
{{ messages['plan_name_' + option.name] }} -
{{
messages.price_format.parseExpression({
messages: messages,
...selectedPlan,
...option,
})
}}
</span>
</template>
</v-select>
<div
v-if="submitted && errors.has('plan')"
class="invalid-feedback d-block"
>
{{ errors.first('plan') }}
</div>
</div>

<div class="form-group" v-if="domains">
<v-select
:clearable="false"
@@ -249,6 +292,7 @@
</div>
<p>{{ messages.field_label_send_errors_description }}</p>
</div>

<!-- metrics reporting -->
<div
class="form-group"
@@ -375,6 +419,7 @@ export default {
'detectedTimezone',
]),
...mapState('domains', ['domains']),
...mapState('plans', ['plans']),
...mapState('networks', ['nearestRegions', 'newNodeNotification']),
...mapState('footprints', ['footprints']),
...mapState('users', ['sshKeys']),
@@ -391,6 +436,30 @@ export default {
return tz_objects;
},

planObjects: function() {
const plans_array = [];
if (this.plans) {
for (let i = 0; i < this.plans.length; i++) {
plans_array.push({
...this.plans[i],
localName: this.messages['plan_name_' + this.plans[i].name],
description: this.messages[
'plan_description_' + this.plans[i].name
],
priceMajorUnits: this.plans[i].price / 100,
priceMinorUnits: this.plans[i].price % 100,
});
}
}
return plans_array;
},

selectedPlan: function() {
return this.accountPlan && this.accountPlan.plan
? this.findPlan(this.accountPlan.plan)
: null;
},

networkTypeOptions: function() {
return [
{
@@ -460,8 +529,19 @@ export default {
...mapActions('footprints', ['getAllFootprints']),
...mapActions('users', ['listSshKeysByUserId']),
...mapGetters('networks', ['loading']),
...mapActions('plans', ['getAllPlans']),
...mapActions('paymentMethods', ['getAllAccountPaymentMethods']),

findPlan(name) {
const plans = this.planObjects;
if (plans) {
for (let i = 0; i < plans.length; i++) {
if (plans[i].name === name) return plans[i];
}
}
return null;
},

setAccountPaymentMethod(apm) {
this.accountPlan.paymentMethodObject = {
uuid: apm.uuid,
@@ -511,6 +591,7 @@ export default {
messages: this.messages,
errors: this.errors,
});
this.getAllPlans(this.messages, this.errors);
this.onUpdateSSH();
},

@@ -603,7 +684,6 @@ export default {

watch: {
'accountPlan.name'(newVal) {
console.log('--changed--', newVal);
if (newVal === '') {
this.$nextTick(() => {
this.accountPlan.name = this.getDefaultName();
@@ -690,6 +770,22 @@ export default {
}
}
},

plans(p) {
if (p) {
if (this.user && this.user.preferredPlan) {
const plans = this.planObjects;
if (plans) {
for (let i = 0; i < plans.length; i++) {
if (plans[i].uuid === this.user.preferredPlan) {
this.defaults.plan = plans[i].name;
this.accountPlan.plan = plans[i].name;
}
}
}
}
}
},
},
};
</script>

+ 9
- 0
src/_pages/main/account/Policy.vue Datei anzeigen

@@ -1131,6 +1131,7 @@ export default {
email: null,
sync: null,
showBlockStats: null,
admin: null,
},
};
},
@@ -1188,6 +1189,7 @@ export default {
'resendVerificationCode',
'requestAccountDownload',
'downloadAccount',
'checkSession',
]),
...mapActions('users', [
'getUserById',
@@ -1198,6 +1200,7 @@ export default {
'removePolicyContactByUserId',
]),
...mapGetters('users', ['loading']),

isAuthenticator(val) {
return window.isAuthenticator(val);
},
@@ -1235,6 +1238,11 @@ export default {
user: this.profile,
messages: this.messages,
errors: this.errors,
}).then(() => {
this.checkSession({
messages: this.messages,
errors: this.errors,
});
});
},
addContact(e) {
@@ -1521,6 +1529,7 @@ export default {
this.profile.email = this.currentUser.email;
this.profile.showBlockStats = this.currentUser.showBlockStats;
this.profile.sync = this.currentUser.sync;
this.profile.admin = this.currentUser.admin;
},
};
</script>

+ 1
- 1
src/_pages/main/account/Support.vue Datei anzeigen

@@ -12,7 +12,7 @@
class="col-lg-6 col-md-6 col-sm-12 my-4 px-3"
v-if="configs && configs.support && configs.support.site"
>
<a :href="configs.support.site">
<a :href="configs.support.site" target="_blank">
<div class="h-100 card-container">
<div class="d-flex justify-content-between align-items-center">
<span>{{ messages.support_site_link }}</span>


+ 21
- 0
src/_pages/main/bubble/LaunchBubble.vue Datei anzeigen

@@ -135,6 +135,7 @@ export default {
...mapState('footprints', ['footprints']),
...mapState('users', ['sshKeys']),
...mapState('paymentMethods', ['accountPaymentMethods']),
...mapState('plans', ['plans']),
},

methods: {
@@ -143,6 +144,7 @@ export default {
...mapActions('footprints', ['getAllFootprints']),
...mapActions('users', ['listSshKeysByUserId']),
...mapGetters('networks', ['loading']),
...mapActions('plans', ['getAllPlans']),
...mapActions('paymentMethods', ['getAllAccountPaymentMethods']),

openSettingsModal(ev) {
@@ -178,6 +180,10 @@ export default {
messages: this.messages,
errors: this.errors,
});
this.getAllPlans({
messages: this.messages,
errors: this.errors,
});
},

findRegion(uuid) {
@@ -316,6 +322,21 @@ export default {
}
}
},
plans(p) {
if (p) {
if (this.user && this.user.preferredPlan) {
const plans = this.planObjects;
if (plans) {
for (let i = 0; i < plans.length; i++) {
if (plans[i].uuid === this.user.preferredPlan) {
this.defaults.plan = plans[i].name;
this.accountPlan.plan = plans[i].name;
}
}
}
}
}
},
},
};
</script>

+ 7
- 0
src/_pages/main/bubble/Network.vue Datei anzeigen

@@ -627,6 +627,7 @@ export default {
]),
...mapActions('users', ['updateUser']),
...mapGetters('users', { loadingUser: 'loading' }),
...mapActions('account', ['checkSession']),

refreshStatus(userId) {
if (!this.lottie && this.$refs.lottie) {
@@ -832,9 +833,15 @@ export default {
user: {
email: this.user.email,
autoUpdatePolicy: this.autoUpdatePolicy,
admin: this.user.admin,
},
messages: this.messages,
errors: this.errors,
}).then(() => {
this.checkSession({
messages: this.messages,
errors: this.errors,
});
});
},
},


+ 4
- 0
src/_router/index.js Datei anzeigen

@@ -99,6 +99,10 @@ export const router = new Router({
path: 'bubble/:id',
component: () => import('~/_pages/main/bubble/Network'),
},
{
path: 'new_bubble',
component: NewNetworkPage,
},
{ path: 'action', component: ActionPage },
{ path: 'resetPassword/:code', component: SetPasswordPage },



+ 3
- 7
src/_store/account.module.js Datei anzeigen

@@ -193,7 +193,7 @@ const actions = {
userService.register(user, messages, errors).then(
(user) => {
commit('registerSuccess', user);
router.push('/bubble');
router.push('/verifyEmail');
setTimeout(() => {
// display success message after route change completes
dispatch('alert/success', messages.alert_registration_success, {
@@ -321,12 +321,8 @@ const mutations = {
},
checkSessionRequest(state) {},
checkSessionSuccess(state, user) {
console.log(
'checkSessionSuccess',
state.user.preferredPlan,
user.preferredPlan
);
if (user.token) {
console.log('checkSessionSuccess', state.user.preferredPlan, user);
if (user) {
if (util.currentUser() === null) {
// we must have logged out while this request was in flight... do nothing
state.user = null;


+ 437
- 387
src/_store/users.module.js Datei anzeigen

@@ -7,414 +7,464 @@ import { account } from '~/_store/account.module';
import { util } from '~/_helpers';

const state = {
loading: {
users: false, user: false, creating: false, updating: false, deleting: false, changingPassword: false,
policy: false, updatingPolicy: false, addPolicyContact: false, removePolicyContact: false,
listSshKeys: false, addSshKey: false, removeSshKey: false, sendingDeleteRequest: false
},
errors: {},
users: null,
user: null,
policy: {},
contact: null,
authenticator: {},
sshKey: null,
sshKeys: [],
changePasswordResponse: null,
deleteRequestSent: false
loading: {
users: false,
user: false,
creating: false,
updating: false,
deleting: false,
changingPassword: false,
policy: false,
updatingPolicy: false,
addPolicyContact: false,
removePolicyContact: false,
listSshKeys: false,
addSshKey: false,
removeSshKey: false,
sendingDeleteRequest: false,
},
errors: {},
users: null,
user: null,
policy: {},
contact: null,
authenticator: {},
sshKey: null,
sshKeys: [],
changePasswordResponse: null,
deleteRequestSent: false,
};

export const CONTACT_TYPE_AUTHENTICATOR = 'authenticator';
export function isAuthenticator (val) {
return val === CONTACT_TYPE_AUTHENTICATOR || (val != null && typeof val.type !== 'undefined' && val.type === CONTACT_TYPE_AUTHENTICATOR);
export function isAuthenticator(val) {
return (
val === CONTACT_TYPE_AUTHENTICATOR ||
(val != null &&
typeof val.type !== 'undefined' &&
val.type === CONTACT_TYPE_AUTHENTICATOR)
);
}
export function isNotAuthenticator(val) {
return !isAuthenticator(val);
}
export function isNotAuthenticator (val) { return !isAuthenticator(val); }

const LOCALSTORAGE_AUTHENTICATOR = 'authenticator';

function setAuthenticator(policy) {
const storedAuthJson = localStorage.getItem(LOCALSTORAGE_AUTHENTICATOR);
const storedAuth = storedAuthJson !== null ? JSON.parse(storedAuthJson) : null;
if (policy && policy.accountContacts) {
const contacts = policy.accountContacts;
for (let i=0; i<contacts.length; i++) {
if (isAuthenticator(contacts[i])) {
const newAuth = JSON.parse(contacts[i].info);
if (newAuth.masked) {
if (storedAuth != null) {
state.authenticator = contacts[i].info = storedAuth;
return;
} else {
contacts[i].masked = true;
}
} else {
state.authenticator = contacts[i].info = storedAuth;
localStorage.setItem(LOCALSTORAGE_AUTHENTICATOR, JSON.stringify(state.authenticator));
}
}
const storedAuthJson = localStorage.getItem(LOCALSTORAGE_AUTHENTICATOR);
const storedAuth =
storedAuthJson !== null ? JSON.parse(storedAuthJson) : null;
if (policy && policy.accountContacts) {
const contacts = policy.accountContacts;
for (let i = 0; i < contacts.length; i++) {
if (isAuthenticator(contacts[i])) {
const newAuth = JSON.parse(contacts[i].info);
if (newAuth.masked) {
if (storedAuth != null) {
state.authenticator = contacts[i].info = storedAuth;
return;
} else {
contacts[i].masked = true;
}
} else {
state.authenticator = contacts[i].info = storedAuth;
localStorage.setItem(
LOCALSTORAGE_AUTHENTICATOR,
JSON.stringify(state.authenticator)
);
}
}
}
state.authenticator = {};
return state.authenticator;
}
state.authenticator = {};
return state.authenticator;
}

const actions = {
searchAccounts({ commit }, {query, messages, errors}) {
commit('searchAccountsRequest');
userService.searchAccounts(query, messages, errors)
.then(
users => commit('searchAccountsSuccess', users),
error => commit('searchAccountsFailure', error)
);
},

getUserById({ commit }, {userId, messages, errors}) {
commit('getUserByIdRequest');
userService.getUserById(userId, messages, errors)
.then(
users => commit('getUserByIdSuccess', users),
error => commit('getUserByIdFailure', error)
);
},

createUser({ commit }, {user, messages, errors}) {
commit('createUserRequest', user);
userService.createUser(user, messages, errors)
.then(
user => commit('createUserSuccess', user),
error => commit('createUserFailure', { user, error: error.toString() })
);
},

updateUser({ commit }, {user, messages, errors}) {
commit('updateUserRequest', user);
userService.updateUser(user, messages, errors)
.then(
user => commit('updateUserSuccess', user),
error => commit('updateUserFailure', { user, error: error.toString() })
);
},

updateSelf({ commit }, {user, messages, errors}) {
commit('updateSelfRequest', user);
userService.updateUser(user, messages, errors)
.then(
user => commit('updateSelfSuccess', user),
error => commit('updateSelfFailure', { user, error: error.toString() })
);
},

getPolicyByUserId({ commit }, {userId, messages, errors}) {
commit('getPolicyByUserIdRequest');
userService.getPolicyByUserId(userId, messages, errors)
.then(
policy => commit('getPolicyByUserIdSuccess', policy),
error => commit('getPolicyByUserIdFailure', error)
);
},

updatePolicyByUserId({ commit }, {userId, policy, messages, errors}) {
commit('updatePolicyByUserIdRequest');
userService.updatePolicyByUserId(userId, policy, messages, errors)
.then(
policy => commit('updatePolicyByUserIdSuccess', policy),
error => commit('updatePolicyByUserIdFailure', error)
);
},

addPolicyContactByUserId({ commit }, {userId, contact, messages, errors}) {
commit('addPolicyContactByUserIdRequest');
userService.addPolicyContactById(userId, contact, messages, errors)
.then(
contact => commit('addPolicyContactByUserIdSuccess', contact),
error => commit('addPolicyContactByUserIdFailure', error)
);
},

removePolicyContactByUserId({ commit }, {userId, contactUuid, messages, errors}) {
commit('removePolicyContactByUserIdRequest');
userService.removePolicyContactByUserId(userId, contactUuid, messages, errors)
.then(
policy => commit('removePolicyContactByUserIdSuccess', policy),
error => commit('removePolicyContactByUserIdFailure', error)
);
},

addSshKeyByUserId({ commit }, {userId, sshKey, messages, errors}) {
commit('addSshKeyByUserIdRequest');
return userService.addSshKeyByUserId(userId, sshKey, messages, errors)
.then(
key => {
commit('addSshKeyByUserIdSuccess', key);
return Promise.resolve();
},
error => {
commit('addSshKeyByUserIdFailure', error);
return Promise.reject();
}
);
},

removeSshKeyByUserId({ commit }, {userId, sshKeyId, messages, errors}) {
commit('removeSshKeyByUserIdRequest');
userService.removeSshKeyByUserId(userId, sshKeyId, messages, errors)
.then(
ok => commit('removeSshKeyByUserIdSuccess', sshKeyId),
error => commit('removeSshKeyByUserIdFailure', error)
);
},

listSshKeysByUserId({ commit }, {userId, messages, errors}) {
commit('listSshKeysByUserIdRequest');
userService.listSshKeysByUserId(userId, messages, errors)
.then(
sshKeys => commit('listSshKeysByUserIdSuccess', sshKeys),
error => commit('listSshKeysByUserIdFailure', error)
);
},

deleteUser({ commit }, {userId, messages, errors}) {
commit('deleteRequest', userId);
userService.deleteUser(userId, messages, errors)
.then(
id => commit('deleteSuccess', id),
error => commit('deleteFailure', { userId, error: error.toString() })
);
},

requestUserDeletion({ commit }, { userId, messages, errors }) {
commit("requestUserDeletionRequest", userId);
userService.requestUserDeletion(userId, messages, errors)
.then((id) => commit("requestUserDeletionSuccess", id),
(error) => commit("requestUserDeletionFailure",
{ userId, error: error.toString() })
);
},

changePassword({ commit }, {request, messages, errors}) {
commit('changePasswordRequest', request);
userService.changePassword(request, messages, errors)
.then(
response => commit('changePasswordSuccess', response),
error => commit('changePasswordFailure', { error: error.toString() })
);
},

adminChangePassword({ commit }, {userId, request, messages, errors}) {
commit('changePasswordRequest', userId);
userService.adminChangePassword(userId, request, messages, errors)
.then(
id => commit('changePasswordSuccess', id),
error => commit('changePasswordFailure', { error: error.toString() })
);
}

searchAccounts({ commit }, { query, messages, errors }) {
commit('searchAccountsRequest');
userService
.searchAccounts(query, messages, errors)
.then(
(users) => commit('searchAccountsSuccess', users),
(error) => commit('searchAccountsFailure', error)
);
},

getUserById({ commit }, { userId, messages, errors }) {
commit('getUserByIdRequest');
userService
.getUserById(userId, messages, errors)
.then(
(users) => commit('getUserByIdSuccess', users),
(error) => commit('getUserByIdFailure', error)
);
},

createUser({ commit }, { user, messages, errors }) {
commit('createUserRequest', user);
userService
.createUser(user, messages, errors)
.then(
(user) => commit('createUserSuccess', user),
(error) =>
commit('createUserFailure', { user, error: error.toString() })
);
},

updateUser({ commit }, { user, messages, errors }) {
commit('updateUserRequest', user);
return userService
.updateUser(user, messages, errors)
.then(
(user) => commit('updateUserSuccess', user),
(error) =>
commit('updateUserFailure', { user, error: error.toString() })
);
},

updateSelf({ commit }, { user, messages, errors }) {
commit('updateSelfRequest', user);
userService
.updateUser(user, messages, errors)
.then(
(user) => commit('updateSelfSuccess', user),
(error) =>
commit('updateSelfFailure', { user, error: error.toString() })
);
},

getPolicyByUserId({ commit }, { userId, messages, errors }) {
commit('getPolicyByUserIdRequest');
userService
.getPolicyByUserId(userId, messages, errors)
.then(
(policy) => commit('getPolicyByUserIdSuccess', policy),
(error) => commit('getPolicyByUserIdFailure', error)
);
},

updatePolicyByUserId({ commit }, { userId, policy, messages, errors }) {
commit('updatePolicyByUserIdRequest');
userService
.updatePolicyByUserId(userId, policy, messages, errors)
.then(
(policy) => commit('updatePolicyByUserIdSuccess', policy),
(error) => commit('updatePolicyByUserIdFailure', error)
);
},

addPolicyContactByUserId({ commit }, { userId, contact, messages, errors }) {
commit('addPolicyContactByUserIdRequest');
userService
.addPolicyContactById(userId, contact, messages, errors)
.then(
(contact) => commit('addPolicyContactByUserIdSuccess', contact),
(error) => commit('addPolicyContactByUserIdFailure', error)
);
},

removePolicyContactByUserId(
{ commit },
{ userId, contactUuid, messages, errors }
) {
commit('removePolicyContactByUserIdRequest');
userService
.removePolicyContactByUserId(userId, contactUuid, messages, errors)
.then(
(policy) => commit('removePolicyContactByUserIdSuccess', policy),
(error) => commit('removePolicyContactByUserIdFailure', error)
);
},

addSshKeyByUserId({ commit }, { userId, sshKey, messages, errors }) {
commit('addSshKeyByUserIdRequest');
return userService.addSshKeyByUserId(userId, sshKey, messages, errors).then(
(key) => {
commit('addSshKeyByUserIdSuccess', key);
return Promise.resolve();
},
(error) => {
commit('addSshKeyByUserIdFailure', error);
return Promise.reject();
}
);
},

removeSshKeyByUserId({ commit }, { userId, sshKeyId, messages, errors }) {
commit('removeSshKeyByUserIdRequest');
userService
.removeSshKeyByUserId(userId, sshKeyId, messages, errors)
.then(
(ok) => commit('removeSshKeyByUserIdSuccess', sshKeyId),
(error) => commit('removeSshKeyByUserIdFailure', error)
);
},

listSshKeysByUserId({ commit }, { userId, messages, errors }) {
commit('listSshKeysByUserIdRequest');
userService
.listSshKeysByUserId(userId, messages, errors)
.then(
(sshKeys) => commit('listSshKeysByUserIdSuccess', sshKeys),
(error) => commit('listSshKeysByUserIdFailure', error)
);
},

deleteUser({ commit }, { userId, messages, errors }) {
commit('deleteRequest', userId);
userService
.deleteUser(userId, messages, errors)
.then(
(id) => commit('deleteSuccess', id),
(error) => commit('deleteFailure', { userId, error: error.toString() })
);
},

requestUserDeletion({ commit }, { userId, messages, errors }) {
commit('requestUserDeletionRequest', userId);
userService
.requestUserDeletion(userId, messages, errors)
.then(
(id) => commit('requestUserDeletionSuccess', id),
(error) =>
commit('requestUserDeletionFailure', {
userId,
error: error.toString(),
})
);
},

changePassword({ commit }, { request, messages, errors }) {
commit('changePasswordRequest', request);
userService
.changePassword(request, messages, errors)
.then(
(response) => commit('changePasswordSuccess', response),
(error) => commit('changePasswordFailure', { error: error.toString() })
);
},

adminChangePassword({ commit }, { userId, request, messages, errors }) {
commit('changePasswordRequest', userId);
userService
.adminChangePassword(userId, request, messages, errors)
.then(
(id) => commit('changePasswordSuccess', id),
(error) => commit('changePasswordFailure', { error: error.toString() })
);
},
};

const mutations = {
searchAccountsRequest(state) {
state.loading.users = true;
},
searchAccountsSuccess(state, users) {
state.loading.users = false;
state.users = users;
},
searchAccountsFailure(state, error) {
state.loading.users = false;
state.errors.all = error;
},

getUserByIdRequest(state) {
state.loading.user = true;
},
getUserByIdSuccess(state, user) {
state.loading.user = false;
state.user = user;
},
getUserByIdFailure(state, error) {
state.loading.user = false;
state.errors.user = error;
},

getPolicyByUserIdRequest(state) {
state.loading.policy = true;
},
getPolicyByUserIdSuccess(state, policy) {
state.loading.policy = false;
state.policy = policy;
setAuthenticator(policy);
},
getPolicyByUserIdFailure(state, error) {
state.loading.policy = false;
state.errors.policy = error;
},

updatePolicyByUserIdRequest(state) {
state.loading.updatingPolicy = true;
},
updatePolicyByUserIdSuccess(state, policy) {
state.loading.updatingPolicy = false;
state.policy = policy;
setAuthenticator(policy);
},
updatePolicyByUserIdFailure(state, error) {
state.loading.updatingPolicy = false;
state.errors.policy = { error };
},

addPolicyContactByUserIdRequest(state) {
state.loading.addPolicyContact = true;
},
addPolicyContactByUserIdSuccess(state, contact) {
state.loading.addPolicyContact = false;
state.contact = contact;
if (isAuthenticator(contact)) {
state.authenticator = JSON.parse(contact.info);
localStorage.setItem(LOCALSTORAGE_AUTHENTICATOR, JSON.stringify(state.authenticator));
}
},
addPolicyContactByUserIdFailure(state, error) {
state.loading.addPolicyContact = false;
state.errors.contact = error;
},

removePolicyContactByUserIdRequest(state) {
state.loading.removePolicyContact = true;
},
removePolicyContactByUserIdSuccess(state, policy) {
state.loading.removePolicyContact = false;
state.policy = policy;
},
removePolicyContactByUserIdFailure(state, error) {
state.loading.removePolicyContact = false;
state.errors.policy = error;
},

createUserRequest(state, user) {
state.loading.creating = true;
},
createUserSuccess(state, user) {
state.loading.creating = false;
state.user = user;
},
createUserFailure(state, { id, error }) {
state.loading.creating = false;
state.errors.create = error;
},

updateUserRequest(state, user) {
state.loading.updating = true;
},
updateUserSuccess(state, user) {
state.loading.updating = false;
state.user = user;
},
updateUserFailure(state, { id, error }) {
state.loading.updating = false;
state.errors.update = error;
},

updateSelfRequest(state, user) {
state.loading.updating = true;
},
updateSelfSuccess(state, user) {
state.loading.updating = false;
user.token = account.state.user.token; // preserve token
state.user = account.state.user = user;
localStorage.setItem(util.USER_KEY, JSON.stringify(user));
},
updateSelfFailure(state, { id, error }) {
state.loading.updating = false;
state.errors.update = error;
},

addSshKeyByUserIdRequest(state) {
state.loading.addSshKey = true;
},
addSshKeyByUserIdSuccess(state, sshKey) {
state.loading.addSshKey = false;
state.sshKey = sshKey;
state.sshKeys.push(sshKey);
},
addSshKeyByUserIdFailure(state, error) {
state.loading.addSshKey = false;
state.errors.sshKey = error;
},

removeSshKeyByUserIdRequest(state) {
state.loading.removeSshKey = true;
},
removeSshKeyByUserIdSuccess(state, sshKeyId) {
state.loading.removeSshKey = false;
state.sshKey = null;
state.sshKeys = state.sshKeys.filter(function(k) { return k.uuid !== sshKeyId; })
},
removeSshKeyByUserIdFailure(state, error) {
state.loading.removeSshKey = false;
state.errors.sshKey = error;
},

listSshKeysByUserIdRequest(state) {
state.loading.listSshKeys = true;
},
listSshKeysByUserIdSuccess(state, sshKeys) {
state.loading.listSshKeys = false;
state.sshKeys = sshKeys;
},
listSshKeysByUserIdFailure(state, error) {
state.loading.listSshKeys = false;
state.errors.sshKey = error;
},

deleteRequest(state, id) {
// todo: use proper delete API
// add 'deleting:true' property to user being deleted
state.loading.deleting = true;
},
deleteSuccess(state, id) {
state.loading.deleting = false;
state.users = [];
},
deleteFailure(state, { id, error }) {
state.loading.deleting = false;
state.errors.deleteUser = error;
},

requestUserDeletionRequest(state, id) {
state.loading.sendingDeleteRequest = true;
state.deleteRequestSent = false;
},
requestUserDeletionSuccess(state, id) {
state.loading.sendingDeleteRequest = false;
state.deleteRequestSent = true;
},
requestUserDeletionFailure(state, { id, error }) {
state.loading.sendingDeleteRequest = false;
state.deleteRequestSent = false;
state.errors.requestUserDeletion = error;
},

changePasswordRequest(state, id) {
state.loading.changingPassword = true;
},
changePasswordSuccess(state, response) {
state.loading.changingPassword = false;
state.changePasswordResponse = response;
},
changePasswordFailure(state, { error }) {
state.loading.changingPassword = false;
state.errors.changePassword = error;
searchAccountsRequest(state) {
state.loading.users = true;
},
searchAccountsSuccess(state, users) {
state.loading.users = false;
state.users = users;
},
searchAccountsFailure(state, error) {
state.loading.users = false;
state.errors.all = error;
},

getUserByIdRequest(state) {
state.loading.user = true;
},
getUserByIdSuccess(state, user) {
state.loading.user = false;
state.user = user;
},
getUserByIdFailure(state, error) {
state.loading.user = false;
state.errors.user = error;
},

getPolicyByUserIdRequest(state) {
state.loading.policy = true;
},
getPolicyByUserIdSuccess(state, policy) {
state.loading.policy = false;
state.policy = policy;
setAuthenticator(policy);
},
getPolicyByUserIdFailure(state, error) {
state.loading.policy = false;
state.errors.policy = error;
},

updatePolicyByUserIdRequest(state) {
state.loading.updatingPolicy = true;
},
updatePolicyByUserIdSuccess(state, policy) {
state.loading.updatingPolicy = false;
state.policy = policy;
setAuthenticator(policy);
},
updatePolicyByUserIdFailure(state, error) {
state.loading.updatingPolicy = false;
state.errors.policy = { error };
},

addPolicyContactByUserIdRequest(state) {
state.loading.addPolicyContact = true;
},
addPolicyContactByUserIdSuccess(state, contact) {
state.loading.addPolicyContact = false;
state.contact = contact;
if (isAuthenticator(contact)) {
state.authenticator = JSON.parse(contact.info);
localStorage.setItem(
LOCALSTORAGE_AUTHENTICATOR,
JSON.stringify(state.authenticator)
);
}
},
addPolicyContactByUserIdFailure(state, error) {
state.loading.addPolicyContact = false;
state.errors.contact = error;
},

removePolicyContactByUserIdRequest(state) {
state.loading.removePolicyContact = true;
},
removePolicyContactByUserIdSuccess(state, policy) {
state.loading.removePolicyContact = false;
state.policy = policy;
},
removePolicyContactByUserIdFailure(state, error) {
state.loading.removePolicyContact = false;
state.errors.policy = error;
},

createUserRequest(state, user) {
state.loading.creating = true;
},
createUserSuccess(state, user) {
state.loading.creating = false;
state.user = user;
},
createUserFailure(state, { id, error }) {
state.loading.creating = false;
state.errors.create = error;
},

updateUserRequest(state, user) {
state.loading.updating = true;
},
updateUserSuccess(state, user) {
state.loading.updating = false;
state.user = user;
},
updateUserFailure(state, { id, error }) {
state.loading.updating = false;
state.errors.update = error;
},

updateSelfRequest(state, user) {
state.loading.updating = true;
},
updateSelfSuccess(state, user) {
state.loading.updating = false;
user.token = account.state.user.token; // preserve token
state.user = account.state.user = user;
localStorage.setItem(util.USER_KEY, JSON.stringify(user));
},
updateSelfFailure(state, { id, error }) {
state.loading.updating = false;
state.errors.update = error;
},

addSshKeyByUserIdRequest(state) {
state.loading.addSshKey = true;
},
addSshKeyByUserIdSuccess(state, sshKey) {
state.loading.addSshKey = false;
state.sshKey = sshKey;
state.sshKeys.push(sshKey);
},
addSshKeyByUserIdFailure(state, error) {
state.loading.addSshKey = false;
state.errors.sshKey = error;
},

removeSshKeyByUserIdRequest(state) {
state.loading.removeSshKey = true;
},
removeSshKeyByUserIdSuccess(state, sshKeyId) {
state.loading.removeSshKey = false;
state.sshKey = null;
state.sshKeys = state.sshKeys.filter(function(k) {
return k.uuid !== sshKeyId;
});
},
removeSshKeyByUserIdFailure(state, error) {
state.loading.removeSshKey = false;
state.errors.sshKey = error;
},

listSshKeysByUserIdRequest(state) {
state.loading.listSshKeys = true;
},
listSshKeysByUserIdSuccess(state, sshKeys) {
state.loading.listSshKeys = false;
state.sshKeys = sshKeys;
},
listSshKeysByUserIdFailure(state, error) {
state.loading.listSshKeys = false;
state.errors.sshKey = error;
},

deleteRequest(state, id) {
// todo: use proper delete API
// add 'deleting:true' property to user being deleted
state.loading.deleting = true;
},
deleteSuccess(state, id) {
state.loading.deleting = false;
state.users = [];
},
deleteFailure(state, { id, error }) {
state.loading.deleting = false;
state.errors.deleteUser = error;
},

requestUserDeletionRequest(state, id) {
state.loading.sendingDeleteRequest = true;
state.deleteRequestSent = false;
},
requestUserDeletionSuccess(state, id) {
state.loading.sendingDeleteRequest = false;
state.deleteRequestSent = true;
},
requestUserDeletionFailure(state, { id, error }) {
state.loading.sendingDeleteRequest = false;
state.deleteRequestSent = false;
state.errors.requestUserDeletion = error;
},

changePasswordRequest(state, id) {
state.loading.changingPassword = true;
},
changePasswordSuccess(state, response) {
state.loading.changingPassword = false;
state.changePasswordResponse = response;
},
changePasswordFailure(state, { error }) {
state.loading.changingPassword = false;
state.errors.changePassword = error;
},
};

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

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

Laden…
Abbrechen
Speichern