Guillaume Vincent пре 8 година
родитељ
комит
e1516b658a
2 измењених фајлова са 28 додато и 9 уклоњено
  1. +10
    -4
      src/store.js
  2. +18
    -5
      src/views/PasswordGenerator.vue

+ 10
- 4
src/store.js Прегледај датотеку

@@ -22,6 +22,7 @@ const defaultPassword = {
length: 12,
counter: 1
};

function getDefaultPasswordProfile(version, passwordProfile = {}) {
if (version === 1) {
return Object.assign({}, defaultPassword, passwordProfile, {version: 1, length: 12});
@@ -31,7 +32,7 @@ function getDefaultPasswordProfile(version, passwordProfile = {}) {
}
}

const versionLoadedByDefault = 1;
const versionLoadedByDefault = storage.json().version || 1;
const state = {
authenticated: auth.isAuthenticated(),
email: '',
@@ -67,7 +68,7 @@ const mutations = {
}
},
PASSWORD_CLEAN(state){
setTimeout(()=> {
setTimeout(() => {
state.passwordStatus = 'CLEAN';
}, 5000);
},
@@ -90,6 +91,11 @@ const mutations = {
state.password = getDefaultPasswordProfile(version, state.password);
state.version = version;
},
SAVE_DEFAULT_OPTIONS: (state) => {
const password = new Password(state.password);
const jsonPassword = password.json();
storage.save({password: jsonPassword, version: jsonPassword.version});
}
};

const actions = {
@@ -137,11 +143,11 @@ const actions = {
PasswordsAPI.get({id}).then(response => commit('SET_PASSWORD', {password: response.data}));
},
DELETE_PASSWORD: ({commit}, {id}) => {
PasswordsAPI.remove({id}).then(()=> {
PasswordsAPI.remove({id}).then(() => {
commit('DELETE_PASSWORD', {id});
});
},
LOAD_DEFAULT_PASSWORD: ({commit})=> {
LOAD_DEFAULT_PASSWORD: ({commit}) => {
commit('SET_DEFAULT_PASSWORD');
}
};


+ 18
- 5
src/views/PasswordGenerator.vue Прегледај датотеку

@@ -130,10 +130,7 @@
</div>
</div>
</div>
<div class="form-group" v-if="showOptions">
Options
</div>
<div class="form-group" v-if="showOptions">
<div class="form-group pt-1" v-if="showOptions">
<label class="form-check-inline">
<input class="form-check-input" type="checkbox" id="lowercase"
v-model="password.lowercase"> abc
@@ -179,6 +176,14 @@
</div>
</div>
</div>
<div class="form-group" v-if="showOptions">
<button type="button" class="btn btn-secondary btn-sm" v-on:click="saveDefault">
save as default
</button>
<span class="text-success" v-if="optionsSaved">
<i class="fa fa-check" aria-hidden="true"></i>
</span>
</div>
<div class="form-group" v-if="showError">
<div class="alert alert-danger" role="alert">
site, login and master password fields are mandatory
@@ -254,7 +259,8 @@
cleanTimeout: null,
showOptions: false,
showError: false,
generatingPassword: false
generatingPassword: false,
optionsSaved: false,
}
},
watch: {
@@ -393,6 +399,13 @@
},
incrementCounter(){
this.password.counter += 1
},
saveDefault(){
this.$store.commit('SAVE_DEFAULT_OPTIONS');
this.optionsSaved = true;
setTimeout(() => {
this.optionsSaved = false;
}, 3000);
}
}
}


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