Blame view

src/pages/Login.vue 4.89 KB
93a68cfa1   Jatinder Singh   first commit
1
  <template>
03dcbf0c1   Neeraj Sharma   fix all api and r...
2
    <v-app id="login">
93a68cfa1   Jatinder Singh   first commit
3
4
      <v-toolbar color="grey lighten">
        <v-toolbar-items>
03dcbf0c1   Neeraj Sharma   fix all api and r...
5
6
7
          <img src="/static/ana@2x.png" height="36" alt="ana">
        </v-toolbar-items>
      </v-toolbar>
93a68cfa1   Jatinder Singh   first commit
8
9
      <v-content>
        <v-container fluid fill-height>
03dcbf0c1   Neeraj Sharma   fix all api and r...
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   Jatinder Singh   first commit
18
          <v-layout align-center justify-center>
03dcbf0c1   Neeraj Sharma   fix all api and r...
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   Jatinder Singh   minor fix
25
              <v-card class="elevation-1 pa-1">
03dcbf0c1   Neeraj Sharma   fix all api and r...
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
51
52
53
                <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>
                       <h5  class="right mt-4"> <router-link class="link" to="/forgetpassword">Forget Password</router-link></h5>
                    </v-flex>
                     </v-layout>
93a68cfa1   Jatinder Singh   first commit
54
                  </v-flex>
03dcbf0c1   Neeraj Sharma   fix all api and r...
55
56
57
58
59
60
61
62
                </v-card-text>
                <v-layout>
                </v-layout>
                <v-layout>
                <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>
93a68cfa1   Jatinder Singh   first commit
63
64
65
66
67
              </v-card>
            </v-flex>
          </v-layout>
        </v-container>
      </v-content>
03dcbf0c1   Neeraj Sharma   fix all api and r...
68
69
      <v-footer class="pa-4" color="grey darken-2"></v-footer>
    </v-app>
93a68cfa1   Jatinder Singh   first commit
70
71
72
  </template>
  
  <script>
03dcbf0c1   Neeraj Sharma   fix all api and r...
73
  import http from "@/Services/http.js";
93a68cfa1   Jatinder Singh   first commit
74
  export default {
03dcbf0c1   Neeraj Sharma   fix all api and r...
75
    data() {
93a68cfa1   Jatinder Singh   first commit
76
      return {
03dcbf0c1   Neeraj Sharma   fix all api and r...
77
78
79
80
81
82
        snackbar: false,
        y: "top",
        x: "right",
        mode: "",
        timeout: 3000,
        text: "",
93a68cfa1   Jatinder Singh   first commit
83
84
85
86
        e1: true,
        loading: false,
        remember: false,
        valid: false,
b34ed827a   Jatinder Singh   changes
87
        userLogincredentials: {},
03dcbf0c1   Neeraj Sharma   fix all api and r...
88
        username: "",
04e3fbc56   Jatinder Singh   minor fix
89
        nameRules: [
03dcbf0c1   Neeraj Sharma   fix all api and r...
90
91
          v => !!v || "Username is required"
          //  v => v.length >0
04e3fbc56   Jatinder Singh   minor fix
92
93
94
        ],
        // email: '',
        // erules: {
03dcbf0c1   Neeraj Sharma   fix all api and r...
95
96
        //   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   Jatinder Singh   minor fix
97
        // },
03dcbf0c1   Neeraj Sharma   fix all api and r...
98
        password: "",
07095d4d8   Jatinder Singh   regex
99
        rules: {
03dcbf0c1   Neeraj Sharma   fix all api and r...
100
101
102
103
104
105
106
107
          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   Jatinder Singh   first commit
108
109
110
      };
    },
    methods: {
03dcbf0c1   Neeraj Sharma   fix all api and r...
111
      login() {
e173bab21   Jatinder Singh   api
112
        var userdata = {
03dcbf0c1   Neeraj Sharma   fix all api and r...
113
114
115
116
117
          userName: this.userLogincredentials.userName,
          password: this.userLogincredentials.password
        };
        http()
          .post("/adminLogin", userdata)
e173bab21   Jatinder Singh   api
118
          .then(response => {
03dcbf0c1   Neeraj Sharma   fix all api and r...
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
            this.$store.dispatch("setToken", response.data.data.token);
            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   Jatinder Singh   changes
138
      }
93a68cfa1   Jatinder Singh   first commit
139
140
    }
  };
93a68cfa1   Jatinder Singh   first commit
141
142
143
  </script>
  
  <style scoped lang="css">
03dcbf0c1   Neeraj Sharma   fix all api and r...
144
145
146
147
148
149
150
151
  #login {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    content: "";
    z-index: 0;
  }
93a68cfa1   Jatinder Singh   first commit
152
  </style>
04e3fbc56   Jatinder Singh   minor fix
153
  <style scoped>
03dcbf0c1   Neeraj Sharma   fix all api and r...
154
155
156
157
  img {
    position: absolute;
    top: 13px;
    left: 50px;
04e3fbc56   Jatinder Singh   minor fix
158
159
  }
  .v-btn--large {
03dcbf0c1   Neeraj Sharma   fix all api and r...
160
    padding: 0px 84px;
93a68cfa1   Jatinder Singh   first commit
161
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
162
163
  .link{ 
    text-decoration:none;
04e3fbc56   Jatinder Singh   minor fix
164
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
  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;
  }  
4413a8d93   Jatinder Singh   changes
179
  }
93a68cfa1   Jatinder Singh   first commit
180
  </style>