Mercurial > gemma
annotate client/src/usermanagement/Userdetail.vue @ 904:e4b72a199258
New default bottleneck colors
Mainly to make the stroke color one actually selectable in the ui.
In addition the pink does better match the collors used on the ECDIS layer.
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Tue, 02 Oct 2018 13:34:59 +0200 |
parents | c0bb673d360e |
children | ca628dce90dd |
rev | line source |
---|---|
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
1 <template> |
629
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
2 <div class="userdetails shadow fadeIn animated"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
3 <div class="card"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
4 <div class="card-header shadow-sm text-white bg-info mb-3"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
5 {{ this.cardHeader }} |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
6 <span @click="closeDetailview" class="pull-right"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
7 <i class="fa fa-close"></i> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
8 </span> |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
9 </div> |
629
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
10 <div class="card-body"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
11 <form @submit.prevent="save"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
12 <div class="formfields"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
13 <div v-if="currentUser.isNew" class="form-group row"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
14 <label for="user">Username</label> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
15 <input type="user" :placeholder="userNamePlaceholder" class="form-control form-control-sm" id="user" aria-describedby="userHelp" v-model="currentUser.user"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
16 <div v-show="errors.user" class="text-danger"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
17 <small> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
18 <i class="fa fa-warning"></i> {{ errors.user }}</small> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
19 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
20 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
21 <div class="form-group row"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
22 <label for="country">Country</label> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
23 <select class="form-control form-control-sm" v-on:change="validateCountry" v-model="currentUser.country"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
24 <option disabled value="">Please select one</option> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
25 <option v-for="country in countries" v-bind:value="country" v-bind:key="country">{{country}}</option> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
26 </select> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
27 <div v-show="errors.country" class="text-danger"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
28 <small> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
29 <i class="fa fa-warning"></i> {{ errors.country }}</small> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
30 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
31 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
32 <div class="form-group row"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
33 <label for="email">Email address</label> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
34 <input type="email" v-on:change="validateEmailaddress" class="form-control form-control-sm" id="email" aria-describedby="emailHelp" v-model="currentUser.email"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
35 <div v-show="errors.email" class="text-danger"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
36 <small> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
37 <i class="fa fa-warning"></i> {{ errors.email }}</small> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
38 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
39 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
40 <div class="form-group row"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
41 <label for="role">Role</label> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
42 <select class="form-control form-control-sm" v-on:change="validateRole" v-model="currentUser.role"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
43 <option disabled value="">Please select one</option> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
44 <option value="sys_admin">Sysadmin</option> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
45 <option value="waterway_admin">Waterway Admin</option> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
46 <option value="waterway_user">Waterway User</option> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
47 </select> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
48 <div v-show="errors.role" class="text-danger"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
49 <small> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
50 <i class="fa fa-warning"></i> {{ errors.role }}</small> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
51 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
52 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
53 <div class="form-group row"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
54 <PasswordField @fieldchange="passwordChanged" :placeholder="passwordPlaceholder" :label="passwordLabel" :passworderrors="errors.password"></PasswordField> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
55 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
56 <div class="form-group row"> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
57 <PasswordField @fieldchange="passwordReChanged" :placeholder="passwordRePlaceholder" :label="passwordReLabel" :passworderrors="errors.passwordre"></PasswordField> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
58 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
59 </div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
60 <div> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
61 <button type="submit" :disabled="submitted" class="shadow-sm btn btn-info pull-right">Submit</button> |
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
62 </div> |
851 | 63 <div v-if="currentUser.role !='waterway_user' " class="form-group row d-flex flex-row justify-content-start mailbutton"> |
64 <a @click="sendTestMail" class="btn btn-light"><i class="fa fa-telegram"> Send testmail</i></a> | |
65 <div v-if="mailsent">Mail was sent</div> | |
66 </div> | |
629
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
67 </form> |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
68 </div> |
629
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
69 </div> |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
70 </div> |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
71 </template> |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
72 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
73 <style lang="scss"> |
851 | 74 .mailbutton { |
75 width: 12vw; | |
76 } | |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
77 .formfields { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
78 width: 10vw; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
79 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
80 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
81 .userdetails { |
629
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
82 margin-top: $offset; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
83 min-width: 40vw; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
84 margin-right: auto; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
85 height: 100%; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
86 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
87 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
88 form { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
89 margin-left: $offset; |
629
8278b2fb0c33
refac: UI refactorization
Thomas Junk <thomas.junk@intevation.de>
parents:
585
diff
changeset
|
90 font-size: $smaller; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
91 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
92 </style> |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
93 <script> |
851 | 94 import { HTTP } from "../application/lib/http"; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
95 import { displayError } from "../application/lib/errors.js"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
96 import { mapGetters } from "vuex"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
97 import PasswordField from "./Passwordfield"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
98 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
99 const emptyErrormessages = () => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
100 return { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
101 email: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
102 country: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
103 role: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
104 password: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
105 passwordre: "" |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
106 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
107 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
108 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
109 const isEmailValid = email => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
110 /** |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
111 * |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
112 * For convenience purposes the same regex used as in the go code |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
113 * cf. types.go |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
114 * |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
115 */ |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
116 // eslint-disable-next-line |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
117 return /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/.test( |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
118 email |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
119 ); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
120 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
121 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
122 const violatedPasswordRules = password => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
123 return ( |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
124 // rules according to issue 70 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
125 password.length < 7 || |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
126 /\W/.test(password) == false || |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
127 /\d/.test(password) == false |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
128 ); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
129 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
130 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
131 export default { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
132 name: "userdetail", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
133 components: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
134 PasswordField |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
135 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
136 data() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
137 return { |
851 | 138 mailsent: false, |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
139 passwordLabel: "Password", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
140 passwordReLabel: "Repeat Password", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
141 passwordPlaceholder: "password", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
142 passwordRePlaceholder: "password again", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
143 password: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
144 passwordre: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
145 currentUser: {}, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
146 path: null, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
147 submitted: false, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
148 errors: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
149 email: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
150 country: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
151 role: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
152 password: "", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
153 passwordre: "" |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
154 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
155 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
156 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
157 mounted() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
158 this.currentUser = { ...this.user }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
159 this.path = this.user.name; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
160 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
161 watch: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
162 user() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
163 this.currentUser = { ...this.user }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
164 this.path = this.user.name; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
165 this.clearPassword(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
166 this.clearErrors(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
167 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
168 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
169 computed: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
170 cardHeader() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
171 if (this.currentUser.isNew) return "N.N"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
172 return this.currentUser.user; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
173 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
174 userNamePlaceholder() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
175 if (this.currentUser.isNew) return "N.N"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
176 return ""; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
177 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
178 ...mapGetters("application", ["countries"]), |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
179 user() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
180 return this.$store.getters["usermanagement/currentUser"]; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
181 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
182 isFormValid() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
183 return ( |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
184 isEmailValid(this.currentUser.email) && |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
185 this.currentUser.country && |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
186 this.password === this.passwordre && |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
187 (this.password === "" || !violatedPasswordRules(this.password)) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
188 ); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
189 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
190 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
191 methods: { |
851 | 192 sendTestMail() { |
193 if (this.mailsent) return; | |
194 HTTP.get("/testmail/" + this.currentUser.user, { | |
195 headers: { | |
196 "X-Gemma-Auth": localStorage.getItem("token"), | |
197 "Content-type": "text/xml; charset=UTF-8" | |
198 } | |
199 }) | |
200 .then(() => { | |
201 this.mailsent = true; | |
202 }) | |
203 .catch(error => { | |
204 this.loginFailed = true; | |
205 this.submitted = false; | |
206 const { status, data } = error.response; | |
207 displayError({ | |
208 title: "Backend Error", | |
209 message: `${status}: ${data.message || data}` | |
210 }); | |
211 }); | |
212 }, | |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
213 passwordChanged(value) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
214 this.password = value; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
215 this.validatePassword(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
216 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
217 passwordReChanged(value) { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
218 this.passwordre = value; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
219 this.validatePassword(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
220 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
221 clearErrors() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
222 this.errors = emptyErrormessages(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
223 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
224 clearPassword() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
225 this.password = ""; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
226 this.passwordre = ""; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
227 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
228 closeDetailview() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
229 this.$store.commit("usermanagement/clearCurrentUser"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
230 this.$store.commit("usermanagement/setUserDetailsInvisible"); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
231 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
232 validateCountry() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
233 this.errors.country = this.currentUser.country |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
234 ? "" |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
235 : "Please choose a country"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
236 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
237 validateRole() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
238 this.errors.role = this.currentUser.role ? "" : "Please choose a role"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
239 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
240 validatePassword() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
241 this.errors.passwordre = |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
242 this.password === this.passwordre ? "" : "Passwords do not match!"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
243 this.errors.password = |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
244 this.password === "" || !violatedPasswordRules(this.password) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
245 ? "" |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
246 : "Password should at least be 8 char long including 1 digit and 1 special char like $"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
247 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
248 validateEmailaddress() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
249 this.errors.email = isEmailValid(this.currentUser.email) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
250 ? "" |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
251 : "invalid email"; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
252 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
253 validate() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
254 this.validateCountry(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
255 this.validateRole(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
256 this.validatePassword(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
257 this.validateEmailaddress(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
258 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
259 save() { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
260 this.validate(); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
261 if (!this.isFormValid) return; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
262 if (this.password) this.currentUser.password = this.password; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
263 this.submitted = true; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
264 this.$store |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
265 .dispatch("usermanagement/saveCurrentUser", { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
266 path: this.user.user, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
267 user: this.currentUser |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
268 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
269 .then(() => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
270 this.submitted = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
271 this.$store.dispatch("usermanagement/loadUsers").catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
272 const { status, data } = error.response; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
273 displayError({ |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
274 title: "Backend Error", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
275 message: `${status}: ${data.message || data}` |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
276 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
277 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
278 }) |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
279 .catch(error => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
280 this.submitted = false; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
281 const { status, data } = error.response; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
282 displayError({ |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
283 title: "Error while saving user", |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
284 message: `${status}: ${data.message || data}` |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
285 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
286 }); |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
287 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
288 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
289 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
290 </script> |