summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/store.js22
-rw-r--r--src/views/Home.vue6
2 files changed, 27 insertions, 1 deletions
diff --git a/src/store.js b/src/store.js
index 9080bd0..888add2 100644
--- a/src/store.js
+++ b/src/store.js
@@ -7,16 +7,24 @@ export default new Vuex.Store({
state: {
api: process.env.VUE_APP_BACKEND_URL,
commits: [],
+ emails: {},
},
get: {
commits: state => {
return state.commits
},
+ emails: state => {
+ return state.emails
+ },
},
mutations: {
load_commits: (state, value) => {
state.commits = value
},
+ load_emails: (state, value) => {
+ console.log(JSON.stringify(value))
+ state.emails = value
+ },
},
actions: {
// Get all commits from the api backend
@@ -26,6 +34,20 @@ export default new Vuex.Store({
commit('load_commits', await response.json());
})
},
+ // Get all emails and map them like an hash
+ async get_emails({commit}) {
+ await fetch(`${this.state.api}/email/`)
+ .then(async response => {
+ const emails_list = await response.json();
+ const emails_obj = emails_list
+ .reduce((dict, elem) => {
+ dict[elem['email']] = elem['hash_md5']
+ return dict;
+ }, {})
+
+ commit('load_emails', emails_obj);
+ })
+ },
},
modules: {
}
diff --git a/src/views/Home.vue b/src/views/Home.vue
index 28da86b..e507ef8 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -15,11 +15,15 @@ export default {
},
mounted() {
this.$store.dispatch('get_commits');
+ this.$store.dispatch('get_emails');
},
computed: {
commits: () => {
return this.$store.get.commits;
- }
+ },
+ emails: () => {
+ return this.$store.get.emails;
+ },
}
}
</script>