Blame view

src/pages/Authentication/Login.vue 6.72 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-content>
        <v-container fluid fill-height>
03dcbf0c1   Neeraj Sharma   fix all api and r...
5
6
7
8
9
10
11
12
          <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
13
          <v-layout align-center justify-center>
9b444e5c3   Neeraj Sharma   add logo in login...
14
15
16
            <v-flex xs12 sm10 md5 lg4>
              <img src="/static/icon.png" height="40" width="140" alt="logo" class="logo mx-auto mb-2" />
              <v-card class="elevation-1 px-2 py-3 card" style="background-color: #7852cc" dark>
7d0816758   Shikha Mishra   show dashboard wh...
17
18
19
20
                <img
                  src="/static/intrackIllustration.png"
                  class="mx-auto logoSchool"
                  style="display:block"
9b444e5c3   Neeraj Sharma   add logo in login...
21
                  width="280"
7d0816758   Shikha Mishra   show dashboard wh...
22
23
                />
                <v-card-text align-center justify-center>
e8965626f   Shikha Mishra   set login design ...
24
                  <v-toolbar-title class="text-xs-center subheadline">SCHOOL LOGIN</v-toolbar-title>
03dcbf0c1   Neeraj Sharma   fix all api and r...
25
26
                  <v-flex xs12 sm12 md12 lg12>
                    <v-form ref="form" v-model="valid" lazy-validation>
7d0816758   Shikha Mishra   show dashboard wh...
27
                      <label class="title">Email</label>
03dcbf0c1   Neeraj Sharma   fix all api and r...
28
                      <v-text-field
af414ec9c   Shikha Mishra   set style in text...
29
                        style="padding: 0px; margin: 0px;"
96f88269a   Neeraj Sharma   implement Student...
30
                        v-model.trim="userLogincredentials.email"
03dcbf0c1   Neeraj Sharma   fix all api and r...
31
                        :rules="nameRules"
7d0816758   Shikha Mishra   show dashboard wh...
32
                        placeholder="Enter your email"
03dcbf0c1   Neeraj Sharma   fix all api and r...
33
34
                        required
                      ></v-text-field>
7d0816758   Shikha Mishra   show dashboard wh...
35
                      <label class="title">Password</label>
03dcbf0c1   Neeraj Sharma   fix all api and r...
36
                      <v-text-field
af414ec9c   Shikha Mishra   set style in text...
37
                        style="padding: 0px; margin: 0px;"
e3e2a04c6   Neeraj Sharma   first commit
38
                        :rules="[rules.required]"
96f88269a   Neeraj Sharma   implement Student...
39
                        v-model.trim="userLogincredentials.password"
03dcbf0c1   Neeraj Sharma   fix all api and r...
40
41
42
43
                        :append-icon="e1 ? 'visibility_off' : 'visibility'"
                        :append-icon-cb="() => (e1 = !e1)"
                        :type="e1 ? 'password' : 'text'"
                        name="input-10-1"
7d0816758   Shikha Mishra   show dashboard wh...
44
                        placeholder="Enter Your password"
654e1501d   Neeraj Sharma   remove school-man...
45
                        @keyup.enter="login"
03dcbf0c1   Neeraj Sharma   fix all api and r...
46
47
                      ></v-text-field>
                    </v-form>
9b444e5c3   Neeraj Sharma   add logo in login...
48
49
                    <v-layout>
                      <v-flex xs12 class="pa-0 ma-0">
a17c68a03   Neeraj Sharma   implement two rou...
50
                        <h5 class="right mt-4">
7d0816758   Shikha Mishra   show dashboard wh...
51
                          <router-link class="link" to="/forgetpassword">Forgot password</router-link>
a17c68a03   Neeraj Sharma   implement two rou...
52
53
54
                        </h5>
                      </v-flex>
                    </v-layout>
93a68cfa1   Jatinder Singh   first commit
55
                  </v-flex>
03dcbf0c1   Neeraj Sharma   fix all api and r...
56
57
                </v-card-text>
                <v-layout>
9b444e5c3   Neeraj Sharma   add logo in login...
58
                  <v-flex sm12>
a17c68a03   Neeraj Sharma   implement two rou...
59
                    <v-btn
7d0816758   Shikha Mishra   show dashboard wh...
60
                      style="margin: auto;display: block;background-color: #71d9ea; color: #0c0754;"
a17c68a03   Neeraj Sharma   implement two rou...
61
                      dark
7d0816758   Shikha Mishra   show dashboard wh...
62
                      flat
a17c68a03   Neeraj Sharma   implement two rou...
63
64
65
66
                      @click="login"
                      :loading="loading"
                    >Login</v-btn>
                  </v-flex>
c7a4fe86a   Neeraj Sharma   responsive admin ...
67
                </v-layout>
a17c68a03   Neeraj Sharma   implement two rou...
68
                <v-layout></v-layout>
93a68cfa1   Jatinder Singh   first commit
69
70
71
72
73
              </v-card>
            </v-flex>
          </v-layout>
        </v-container>
      </v-content>
03dcbf0c1   Neeraj Sharma   fix all api and r...
74
    </v-app>
93a68cfa1   Jatinder Singh   first commit
75
76
77
  </template>
  
  <script>
03dcbf0c1   Neeraj Sharma   fix all api and r...
78
  import http from "@/Services/http.js";
93a68cfa1   Jatinder Singh   first commit
79
  export default {
03dcbf0c1   Neeraj Sharma   fix all api and r...
80
    data() {
93a68cfa1   Jatinder Singh   first commit
81
      return {
03dcbf0c1   Neeraj Sharma   fix all api and r...
82
83
84
85
86
87
        snackbar: false,
        y: "top",
        x: "right",
        mode: "",
        timeout: 3000,
        text: "",
080d88547   Shikha Mishra   issues solved
88
        append: "",
93a68cfa1   Jatinder Singh   first commit
89
90
91
92
        e1: true,
        loading: false,
        remember: false,
        valid: false,
b34ed827a   Jatinder Singh   changes
93
        userLogincredentials: {},
a17c68a03   Neeraj Sharma   implement two rou...
94
        nameRules: [v => !!v || "Username is required"],
03dcbf0c1   Neeraj Sharma   fix all api and r...
95
        password: "",
a17c68a03   Neeraj Sharma   implement two rou...
96
        email: "",
07095d4d8   Jatinder Singh   regex
97
        rules: {
a17c68a03   Neeraj Sharma   implement two rou...
98
          required: value => !!value || "password is Required."
03dcbf0c1   Neeraj Sharma   fix all api and r...
99
        }
93a68cfa1   Jatinder Singh   first commit
100
101
102
      };
    },
    methods: {
03dcbf0c1   Neeraj Sharma   fix all api and r...
103
      login() {
a17c68a03   Neeraj Sharma   implement two rou...
104
        this.loading = true;
e173bab21   Jatinder Singh   api
105
        var userdata = {
e3e2a04c6   Neeraj Sharma   first commit
106
          email: this.userLogincredentials.email,
99cd79184   Neeraj Sharma   implement all tas...
107
          password: this.userLogincredentials.password
03dcbf0c1   Neeraj Sharma   fix all api and r...
108
109
        };
        http()
e3e2a04c6   Neeraj Sharma   first commit
110
          .post("/schoolLogin", userdata)
e173bab21   Jatinder Singh   api
111
          .then(response => {
710438de6   Shikha Mishra   added teacher mod...
112
            // console.log("token",response.data.data);
55f72b7d7   Neeraj Sharma   add new page are ...
113
            this.loading = false;
68d742034   Neeraj Sharma   implement new des...
114
115
116
117
            if (response.data.data.role === "ADMIN") {
              this.$store.dispatch("setToken", response.data.data.token);
              this.$store.dispatch("Id", response.data.data.id);
              this.$store.dispatch("Role", response.data.data.role);
37150e7c1   Neeraj Sharma   implement school ...
118
              this.$router.push("/dashboard");
68d742034   Neeraj Sharma   implement new des...
119
120
121
            } else if (response.data.data.role === "SUPERADMIN") {
              this.$store.dispatch("setSchoolRole", response.data.data.role);
              this.$store.dispatch("setSchoolToken", response.data.data.token);
46993dc1d   Shikha Mishra   solve issue login
122
              this.$router.push("/schooldashboard");
710438de6   Shikha Mishra   added teacher mod...
123
124
125
126
127
128
            } else if (response.data.data.role === "TEACHER") {
              // console.log("teacher", response.data.data.role);
              this.$store.dispatch("setToken", response.data.data.token);
              this.$store.dispatch("Id", response.data.data.id);
              this.$store.dispatch("Role", response.data.data.role);
              this.$router.push("/dashboard");
68d742034   Neeraj Sharma   implement new des...
129
130
131
132
            } else if (response.data.data.role === "LIBRARIAN") {
              this.$store.dispatch("setToken", response.data.data.token);
              this.$store.dispatch("Id", response.data.data.id);
              this.$store.dispatch("Role", response.data.data.role);
7d0816758   Shikha Mishra   show dashboard wh...
133
              this.$router.push("/dashboard");
68d742034   Neeraj Sharma   implement new des...
134
135
136
137
            } else if (response.data.data.role === "ACCOUNTANT") {
              this.$store.dispatch("setToken", response.data.data.token);
              this.$store.dispatch("Id", response.data.data.id);
              this.$store.dispatch("Role", response.data.data.role);
7d0816758   Shikha Mishra   show dashboard wh...
138
              this.$router.push("/dashboard");
37150e7c1   Neeraj Sharma   implement school ...
139
            }
03dcbf0c1   Neeraj Sharma   fix all api and r...
140
          })
55f72b7d7   Neeraj Sharma   add new page are ...
141
          .catch(error => {
a17c68a03   Neeraj Sharma   implement two rou...
142
143
144
            if (error) {
              this.text = "Server appears to be offline";
              this.snackbar = true;
1571e40b5   Neeraj Sharma   gallery and socia...
145
              this.loading = false;
a17c68a03   Neeraj Sharma   implement two rou...
146
147
148
149
150
            }
            if (error.response.data.message) {
              this.text = error.response.data.message;
              this.snackbar = true;
            }
03dcbf0c1   Neeraj Sharma   fix all api and r...
151
152
153
154
            this.loading = false;
          });
      }
    },
a17c68a03   Neeraj Sharma   implement two rou...
155
    mounted() {
ff30cbe86   Neeraj Sharma   remove discount p...
156
157
      if (this.$store.state.isUserLoggedIn == true) {
        this.$router.push("/dashboard");
9b444e5c3   Neeraj Sharma   add logo in login...
158
      } else if (this.$store.state.isSchoolLoggedIn == true) {
ff30cbe86   Neeraj Sharma   remove discount p...
159
160
        this.$router.push("/dashboard");
      }
a17c68a03   Neeraj Sharma   implement two rou...
161
    },
03dcbf0c1   Neeraj Sharma   fix all api and r...
162
163
164
    computed: {
      color() {
        return this.loading ? "success" : "error";
4413a8d93   Jatinder Singh   changes
165
      }
93a68cfa1   Jatinder Singh   first commit
166
167
    }
  };
93a68cfa1   Jatinder Singh   first commit
168
169
170
  </script>
  
  <style scoped lang="css">
03dcbf0c1   Neeraj Sharma   fix all api and r...
171
172
173
174
175
176
177
178
  #login {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    content: "";
    z-index: 0;
  }
93a68cfa1   Jatinder Singh   first commit
179
  </style>
04e3fbc56   Jatinder Singh   minor fix
180
  <style scoped>
7d0816758   Shikha Mishra   show dashboard wh...
181
182
183
184
185
  .schoolLogo {
    height: 60%;
    padding-left: 31%;
  }
  /* img {
03dcbf0c1   Neeraj Sharma   fix all api and r...
186
187
    position: absolute;
    top: 13px;
55f72b7d7   Neeraj Sharma   add new page are ...
188
    left: 8px;
7d0816758   Shikha Mishra   show dashboard wh...
189
  } */
04e3fbc56   Jatinder Singh   minor fix
190
  .v-btn--large {
03dcbf0c1   Neeraj Sharma   fix all api and r...
191
    padding: 0px 84px;
93a68cfa1   Jatinder Singh   first commit
192
  }
a17c68a03   Neeraj Sharma   implement two rou...
193
194
  .link {
    text-decoration: none;
04e3fbc56   Jatinder Singh   minor fix
195
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
196
  a {
7d0816758   Shikha Mishra   show dashboard wh...
197
    color: #fff;
a17c68a03   Neeraj Sharma   implement two rou...
198
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
199
  .mt-4 {
a17c68a03   Neeraj Sharma   implement two rou...
200
    margin-top: 21px !important;
03dcbf0c1   Neeraj Sharma   fix all api and r...
201
  }
9b444e5c3   Neeraj Sharma   add logo in login...
202
203
204
  .logo {
    display: block;
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
205
  @media screen and (max-width: 600px) {
a17c68a03   Neeraj Sharma   implement two rou...
206
207
208
209
210
    img {
      left: 10px;
      height: 34px;
      width: 120px;
    }
7d0816758   Shikha Mishra   show dashboard wh...
211
212
213
214
    .logo {
      height: 56px;
      left: 10px;
      width: 120px;
9b444e5c3   Neeraj Sharma   add logo in login...
215
      display: block;
a17c68a03   Neeraj Sharma   implement two rou...
216
    }
7d0816758   Shikha Mishra   show dashboard wh...
217
218
219
220
    .logoSchool {
      height: 87px;
      left: 10px;
      width: 120px;
a17c68a03   Neeraj Sharma   implement two rou...
221
    }
4413a8d93   Jatinder Singh   changes
222
  }
93a68cfa1   Jatinder Singh   first commit
223
  </style>