Blame view
src/pages/Login.vue
5.24 KB
93a68cfa1
|
1 |
<template> |
03dcbf0c1
|
2 |
<v-app id="login"> |
93a68cfa1
|
3 4 |
<v-toolbar color="grey lighten"> <v-toolbar-items> |
03dcbf0c1
|
5 6 7 |
<img src="/static/ana@2x.png" height="36" alt="ana"> </v-toolbar-items> </v-toolbar> |
93a68cfa1
|
8 9 |
<v-content> <v-container fluid fill-height> |
03dcbf0c1
|
10 11 12 13 14 15 16 17 |
<v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" :color="color" >{{ text }}</v-snackbar> |
93a68cfa1
|
18 |
<v-layout align-center justify-center> |
03dcbf0c1
|
19 20 21 22 23 24 |
<v-flex xs12 sm10 md6 lg4> <v-toolbar color="black" dark> <v-spacer></v-spacer> <v-toolbar-title>Admin Login</v-toolbar-title> <v-spacer></v-spacer> </v-toolbar> |
04e3fbc56
|
25 |
<v-card class="elevation-1 pa-1"> |
03dcbf0c1
|
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
<v-card-text> <v-flex xs12 sm12 md12 lg12> <v-form ref="form" v-model="valid" lazy-validation> <v-text-field v-model="userLogincredentials.userName" :rules="nameRules" label="Username" required ></v-text-field> <v-text-field :rules="[rules.required, rules.min]" v-model="userLogincredentials.password" :append-icon="e1 ? 'visibility_off' : 'visibility'" :append-icon-cb="() => (e1 = !e1)" :type="e1 ? 'password' : 'text'" name="input-10-1" label="Password" counter ></v-text-field> </v-form> <v-layout row wrap> <v-flex xs6> <v-checkbox :label="`Remember me`" v-model="remember"></v-checkbox> </v-flex> <v-flex xs6> |
ac10393a4
|
51 |
<h5 class="right mt-4"> <router-link class="link" to="/forgetpassword" style="border-bottom: 2px solid #aaa;">Forgot Password</router-link></h5> |
03dcbf0c1
|
52 53 |
</v-flex> </v-layout> |
93a68cfa1
|
54 |
</v-flex> |
03dcbf0c1
|
55 56 |
</v-card-text> <v-layout> |
03dcbf0c1
|
57 58 59 60 |
<v-flex sm12 class="my-3"> <v-btn style="margin: auto;display: block;" round color="black" dark large @click="login" :loading="loading">Login</v-btn> </v-flex> </v-layout> |
c7a4fe86a
|
61 62 63 64 65 66 67 68 |
<v-layout> <v-flex sm12> <v-text-field label="Username" required ></v-text-field> </v-flex> </v-layout> |
93a68cfa1
|
69 70 71 72 73 |
</v-card> </v-flex> </v-layout> </v-container> </v-content> |
03dcbf0c1
|
74 75 |
<v-footer class="pa-4" color="grey darken-2"></v-footer> </v-app> |
93a68cfa1
|
76 77 78 |
</template> <script> |
03dcbf0c1
|
79 |
import http from "@/Services/http.js"; |
93a68cfa1
|
80 |
export default { |
03dcbf0c1
|
81 |
data() { |
93a68cfa1
|
82 |
return { |
03dcbf0c1
|
83 84 85 86 87 88 |
snackbar: false, y: "top", x: "right", mode: "", timeout: 3000, text: "", |
93a68cfa1
|
89 90 91 92 |
e1: true, loading: false, remember: false, valid: false, |
b34ed827a
|
93 |
userLogincredentials: {}, |
03dcbf0c1
|
94 |
username: "", |
04e3fbc56
|
95 |
nameRules: [ |
03dcbf0c1
|
96 97 |
v => !!v || "Username is required" // v => v.length >0 |
04e3fbc56
|
98 99 100 |
], // email: '', // erules: { |
03dcbf0c1
|
101 102 |
// required: value => !!value || 'This email field is Required.', // em: v => (v.length > 0 && /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) || 'Email must be valid') |
04e3fbc56
|
103 |
// }, |
03dcbf0c1
|
104 |
password: "", |
07095d4d8
|
105 |
rules: { |
03dcbf0c1
|
106 107 108 109 110 111 112 113 |
required: value => !!value || "password is Required.", min: v => (/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/.test( v ) && v.length >= 8) || "Min 8 characters upper case lower case symbol required" } |
93a68cfa1
|
114 115 116 |
}; }, methods: { |
03dcbf0c1
|
117 |
login() { |
e173bab21
|
118 |
var userdata = { |
03dcbf0c1
|
119 120 121 122 123 |
userName: this.userLogincredentials.userName, password: this.userLogincredentials.password }; http() .post("/adminLogin", userdata) |
e173bab21
|
124 |
.then(response => { |
03dcbf0c1
|
125 |
this.$store.dispatch("setToken", response.data.data.token); |
eba96ec51
|
126 |
this.$store.dispatch("setName", response.data.data.name); |
03dcbf0c1
|
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
this.loading = true; if ((this.snackbar = true)) { this.text = "Successfully Login"; } setTimeout(() => { this.$router.push("/dashboard"); }, 2000); }) .catch(err => { this.text = "Email or Password not matched !!"; this.snackbar = true; this.loading = false; }); } }, computed: { color() { return this.loading ? "success" : "error"; |
4413a8d93
|
145 |
} |
93a68cfa1
|
146 147 |
} }; |
93a68cfa1
|
148 149 150 |
</script> <style scoped lang="css"> |
03dcbf0c1
|
151 152 153 154 155 156 157 158 |
#login { width: 100%; position: absolute; top: 0; left: 0; content: ""; z-index: 0; } |
93a68cfa1
|
159 |
</style> |
04e3fbc56
|
160 |
<style scoped> |
03dcbf0c1
|
161 162 163 164 |
img { position: absolute; top: 13px; left: 50px; |
04e3fbc56
|
165 166 |
} .v-btn--large { |
03dcbf0c1
|
167 |
padding: 0px 84px; |
93a68cfa1
|
168 |
} |
03dcbf0c1
|
169 170 |
.link{ text-decoration:none; |
04e3fbc56
|
171 |
} |
03dcbf0c1
|
172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
a { color: #696969; } .forget{ margin-top:20px; } .mt-4 { margin-top: 21px !important; } @media screen and (max-width: 600px) { .forget{ margin-top:none; margin-left:18px; } |
a0fe54618
|
186 187 188 189 190 191 |
img{ top:16px; left:10px; height: 24px; width: 66px;; } |
4413a8d93
|
192 |
} |
93a68cfa1
|
193 |
</style> |