Mercurial > gemma
annotate client/src/views/Login.vue @ 326:a7b2db8b3d18
Added type for roles.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 02 Aug 2018 18:39:01 +0200 |
parents | 8f49ba6cddd9 |
children | 7a8644e9e50e |
rev | line source |
---|---|
154
2ba329e82fb0
Wrap vue templates with translation in parentheses
Thomas Junk <thomas.junk@intevation.de>
parents:
150
diff
changeset
|
1 (<template> |
32
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
2 <div :class="loginStyle"> |
3 | 3 <div> |
25
a728610b3812
Add Light visual hints
Thomas Junk <thomas.junk@intevation.de>
parents:
24
diff
changeset
|
4 <div class="logogroup d-flex flex-row justify-content-center"> |
a728610b3812
Add Light visual hints
Thomas Junk <thomas.junk@intevation.de>
parents:
24
diff
changeset
|
5 <div class="logo"><img src="../assets/logo.png"></div> |
9
ee6d3836014e
current version of login
Thomas Junk <thomas.junk@intevation.de>
parents:
6
diff
changeset
|
6 <div class="title"><h1>{{ appTitle }}</h1></div> |
3 | 7 </div> |
8 </div> | |
17
7d242100af46
Adjusted the look and feel of the login page according to ISC
Thomas Junk <thomas.junk@intevation.de>
parents:
13
diff
changeset
|
9 <div class="login-wrapper d-flex flex-row justify-content-center"> |
9
ee6d3836014e
current version of login
Thomas Junk <thomas.junk@intevation.de>
parents:
6
diff
changeset
|
10 <form class="loginform form-signin" @submit.prevent="login"> |
166
8f49ba6cddd9
test: login now as e2e test
Thomas Junk <thomas.junk@intevation.de>
parents:
158
diff
changeset
|
11 <div id="alert" v-if="loginFailed" class="loginerrormessage alert alert-danger" role="alert"> |
150
44a7e27a0816
Added missing translation for loginerror
Thomas Junk <thomas.junk@intevation.de>
parents:
141
diff
changeset
|
12 <span class="loginerror"><translate>Login failed</translate></span> |
32
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
13 </div> |
25
a728610b3812
Add Light visual hints
Thomas Junk <thomas.junk@intevation.de>
parents:
24
diff
changeset
|
14 <div class="input-group mb-3 emailgroup"> |
158
992e17912405
feat: Improve login against real db
Thomas Junk <thomas.junk@intevation.de>
parents:
154
diff
changeset
|
15 <input type="text" v-model="user" id="inputEmail" class="form-control" :placeholder="emailLabel" required autofocus> |
11
e0b5dd98665e
current frontend with asset server configured
Thomas Junk <thomas.junk@intevation.de>
parents:
10
diff
changeset
|
16 </div> |
25
a728610b3812
Add Light visual hints
Thomas Junk <thomas.junk@intevation.de>
parents:
24
diff
changeset
|
17 <div class="input-group mb-3 passwordgroup"> |
158
992e17912405
feat: Improve login against real db
Thomas Junk <thomas.junk@intevation.de>
parents:
154
diff
changeset
|
18 <input :type="isPasswordVisible" v-model="password" id="inputPassword" class="form-control" :placeholder='passwordLabel' required> |
11
e0b5dd98665e
current frontend with asset server configured
Thomas Junk <thomas.junk@intevation.de>
parents:
10
diff
changeset
|
19 <div class="input-group-append"> |
122
da279a0ce127
The "eye" icon changes into a "crossed out eye" icon
Thomas Junk <thomas.junk@intevation.de>
parents:
117
diff
changeset
|
20 <span class="input-group-text" id="basic-addon2" @click="showPassword"><i :class="eyeIcon"></i></span> |
11
e0b5dd98665e
current frontend with asset server configured
Thomas Junk <thomas.junk@intevation.de>
parents:
10
diff
changeset
|
21 </div> |
e0b5dd98665e
current frontend with asset server configured
Thomas Junk <thomas.junk@intevation.de>
parents:
10
diff
changeset
|
22 </div> |
141 | 23 <button class="submitbutton btn btn-primary btn-block" :disabled="submitted" type="submit"><translate>Login</translate></button> |
24 <div class="forgottenlink small"><a href="#"><translate>Forgot password</translate></a></div> | |
24
10ebbf197523
Rework layout of login page
Thomas Junk <thomas.junk@intevation.de>
parents:
22
diff
changeset
|
25 <div class="secondary-logo"><img :src="secondaryLogo"></div> |
3 | 26 </form> |
27 </div> | |
28 </div> | |
154
2ba329e82fb0
Wrap vue templates with translation in parentheses
Thomas Junk <thomas.junk@intevation.de>
parents:
150
diff
changeset
|
29 </template>) |
3 | 30 |
9
ee6d3836014e
current version of login
Thomas Junk <thomas.junk@intevation.de>
parents:
6
diff
changeset
|
31 <style lang="scss"> |
117
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
32 @import "../assets/application.scss"; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
33 $logincollapsed: 470px; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
34 $loginextended: 550px; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
35 |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
36 .emailgroup { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
37 box-shadow: $basic-shadow-light !important; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
38 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
39 .forgottenlink { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
40 text-align: right; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
41 margin-top: $small-offset; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
42 margin-bottom: $small-offset; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
43 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
44 #inputPassword { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
45 border-right: none; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
46 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
47 .input-group-text { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
48 background-color: white !important; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
49 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
50 |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
51 .login { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
52 width: 375px; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
53 @extend %fully-centered; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
54 padding-top: $offset; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
55 padding-bottom: $offset; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
56 box-shadow: $basic-shadow; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
57 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
58 .logincollapsed { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
59 height: $logincollapsed; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
60 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
61 |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
62 .loginextended { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
63 height: $loginextended; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
64 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
65 .loginerror { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
66 white-space: pre; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
67 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
68 .loginerrormessage { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
69 box-shadow: $basic-shadow-light !important; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
70 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
71 .loginform { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
72 width: 300px; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
73 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
74 .logogroup { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
75 margin-top: $offset; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
76 margin-bottom: $offset; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
77 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
78 .mail-icon { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
79 width: $iconwidth; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
80 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
81 .passwordgroup { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
82 box-shadow: $basic-shadow-light !important; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
83 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
84 .password-icon { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
85 position: relative; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
86 top: 10px; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
87 font-size: $iconsize; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
88 line-height: $iconLineHeight; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
89 width: $iconwidth; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
90 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
91 .submitbutton { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
92 box-shadow: $basic-shadow-light !important; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
93 } |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
94 .title { |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
95 margin-left: $offset; |
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
96 } |
3 | 97 </style> |
98 | |
99 <script> | |
100 import { mapGetters } from "vuex"; | |
101 | |
102 export default { | |
103 name: "login", | |
104 data() { | |
105 return { | |
158
992e17912405
feat: Improve login against real db
Thomas Junk <thomas.junk@intevation.de>
parents:
154
diff
changeset
|
106 user: "", |
6 | 107 password: "", |
10
361ae8211991
refactored to component local state
Thomas Junk <thomas.junk@intevation.de>
parents:
9
diff
changeset
|
108 submitted: false, |
33
ae6535d44563
Make password readable. Moved Layout to separate file.
Thomas Junk <thomas.junk@intevation.de>
parents:
32
diff
changeset
|
109 loginFailed: false, |
ae6535d44563
Make password readable. Moved Layout to separate file.
Thomas Junk <thomas.junk@intevation.de>
parents:
32
diff
changeset
|
110 readablePassword: false |
3 | 111 }; |
112 }, | |
113 computed: { | |
154
2ba329e82fb0
Wrap vue templates with translation in parentheses
Thomas Junk <thomas.junk@intevation.de>
parents:
150
diff
changeset
|
114 passwordLabel() { |
2ba329e82fb0
Wrap vue templates with translation in parentheses
Thomas Junk <thomas.junk@intevation.de>
parents:
150
diff
changeset
|
115 return this.$gettext("Enter passphrase"); |
2ba329e82fb0
Wrap vue templates with translation in parentheses
Thomas Junk <thomas.junk@intevation.de>
parents:
150
diff
changeset
|
116 }, |
2ba329e82fb0
Wrap vue templates with translation in parentheses
Thomas Junk <thomas.junk@intevation.de>
parents:
150
diff
changeset
|
117 emailLabel() { |
2ba329e82fb0
Wrap vue templates with translation in parentheses
Thomas Junk <thomas.junk@intevation.de>
parents:
150
diff
changeset
|
118 return this.$gettext("Enter email"); |
2ba329e82fb0
Wrap vue templates with translation in parentheses
Thomas Junk <thomas.junk@intevation.de>
parents:
150
diff
changeset
|
119 }, |
117
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
120 isPasswordVisible() { |
33
ae6535d44563
Make password readable. Moved Layout to separate file.
Thomas Junk <thomas.junk@intevation.de>
parents:
32
diff
changeset
|
121 return this.readablePassword ? "text" : "password"; |
ae6535d44563
Make password readable. Moved Layout to separate file.
Thomas Junk <thomas.junk@intevation.de>
parents:
32
diff
changeset
|
122 }, |
122
da279a0ce127
The "eye" icon changes into a "crossed out eye" icon
Thomas Junk <thomas.junk@intevation.de>
parents:
117
diff
changeset
|
123 eyeIcon() { |
da279a0ce127
The "eye" icon changes into a "crossed out eye" icon
Thomas Junk <thomas.junk@intevation.de>
parents:
117
diff
changeset
|
124 return { |
da279a0ce127
The "eye" icon changes into a "crossed out eye" icon
Thomas Junk <thomas.junk@intevation.de>
parents:
117
diff
changeset
|
125 fa: true, |
da279a0ce127
The "eye" icon changes into a "crossed out eye" icon
Thomas Junk <thomas.junk@intevation.de>
parents:
117
diff
changeset
|
126 "fa-eye": !this.readablePassword, |
da279a0ce127
The "eye" icon changes into a "crossed out eye" icon
Thomas Junk <thomas.junk@intevation.de>
parents:
117
diff
changeset
|
127 "fa-eye-slash": this.readablePassword |
da279a0ce127
The "eye" icon changes into a "crossed out eye" icon
Thomas Junk <thomas.junk@intevation.de>
parents:
117
diff
changeset
|
128 }; |
da279a0ce127
The "eye" icon changes into a "crossed out eye" icon
Thomas Junk <thomas.junk@intevation.de>
parents:
117
diff
changeset
|
129 }, |
117
5e95c62a7e74
Move component. Re-add Css.
Thomas Junk <thomas.junk@intevation.de>
parents:
33
diff
changeset
|
130 loginStyle() { |
32
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
131 return { |
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
132 login: true, |
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
133 logincollapsed: !this.loginFailed, |
33
ae6535d44563
Make password readable. Moved Layout to separate file.
Thomas Junk <thomas.junk@intevation.de>
parents:
32
diff
changeset
|
134 loginextended: this.loginFailed, |
32
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
135 "bg-white": true, |
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
136 rounded: true |
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
137 }; |
0c19dcc352f9
Dynamic height of dialogbox
Thomas Junk <thomas.junk@intevation.de>
parents:
25
diff
changeset
|
138 }, |
141 | 139 ...mapGetters("application", ["appTitle", "secondaryLogo"]) |
3 | 140 }, |
141 methods: { | |
142 login() { | |
6 | 143 this.submitted = true; |
158
992e17912405
feat: Improve login against real db
Thomas Junk <thomas.junk@intevation.de>
parents:
154
diff
changeset
|
144 const { user, password } = this; |
6 | 145 this.$store |
158
992e17912405
feat: Improve login against real db
Thomas Junk <thomas.junk@intevation.de>
parents:
154
diff
changeset
|
146 .dispatch("user/login", { user, password }) |
6 | 147 .then(() => { |
10
361ae8211991
refactored to component local state
Thomas Junk <thomas.junk@intevation.de>
parents:
9
diff
changeset
|
148 this.loginFailed = false; |
6 | 149 this.$router.push("/"); |
150 }) | |
151 .catch(() => { | |
10
361ae8211991
refactored to component local state
Thomas Junk <thomas.junk@intevation.de>
parents:
9
diff
changeset
|
152 this.loginFailed = true; |
6 | 153 this.submitted = false; |
154 }); | |
33
ae6535d44563
Make password readable. Moved Layout to separate file.
Thomas Junk <thomas.junk@intevation.de>
parents:
32
diff
changeset
|
155 }, |
ae6535d44563
Make password readable. Moved Layout to separate file.
Thomas Junk <thomas.junk@intevation.de>
parents:
32
diff
changeset
|
156 showPassword() { |
ae6535d44563
Make password readable. Moved Layout to separate file.
Thomas Junk <thomas.junk@intevation.de>
parents:
32
diff
changeset
|
157 this.readablePassword = !this.readablePassword; |
3 | 158 } |
159 } | |
160 }; | |
161 </script> |