Mercurial > gemma
annotate client/src/stores/usermanagement.js @ 317:5cb18bedb3a9
Simplified internal password generator.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 02 Aug 2018 10:18:25 +0200 |
parents | af29878be602 |
children | 1a2ef18e464d |
rev | line source |
---|---|
289
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 import { HTTP } from "../lib/http"; |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
2 |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
3 const UserManagement = { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
4 namespaced: true, |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
5 state: { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
6 users: null |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
7 }, |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
8 getters: { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
9 users: state => { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
10 return state.users; |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
11 }, |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
12 getUserByName: state => name => { |
300
af29878be602
feat: User table selectable
Thomas Junk <thomas.junk@intevation.de>
parents:
299
diff
changeset
|
13 return state.users.find(user => { |
af29878be602
feat: User table selectable
Thomas Junk <thomas.junk@intevation.de>
parents:
299
diff
changeset
|
14 return user.user === name; |
af29878be602
feat: User table selectable
Thomas Junk <thomas.junk@intevation.de>
parents:
299
diff
changeset
|
15 }); |
289
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
16 } |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
17 }, |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
18 mutations: { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 usersLoaded: (state, data) => { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
20 state.users = data.users; |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
21 } |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
22 }, |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
23 actions: { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
24 loadUsers({ commit }) { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
25 return new Promise((resolve, reject) => { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
26 HTTP.get("/users", { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
27 headers: { "X-Gemma-Auth": localStorage.getItem("token") } |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 }) |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
29 .then(response => { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
30 commit("usersLoaded", response.data); |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
31 resolve(response); |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
32 }) |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
33 .catch(error => { |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
34 reject(error); |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
35 }); |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
36 }); |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
37 } |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
38 } |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
39 }; |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
40 |
aee175e3f82c
feat: Listing of users on management page
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
41 export default UserManagement; |