Blame view

src/pages/Authentication/Login.vue 6.58 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>
03dcbf0c1   Neeraj Sharma   fix all api and r...
14
            <v-flex xs12 sm10 md6 lg4>
7d0816758   Shikha Mishra   show dashboard wh...
15
16
17
18
19
              <v-toolbar dense flat class="transparent mb-4">
                <v-toolbar-items class="mx-auto">
                  <img src="/static/icon.png" height="40" width="140" alt="logo" class="logo"/>
                  <!-- <h3 class="white--text my-3 ml-5 logoSchool">School-Management</h3> -->
                </v-toolbar-items>
03dcbf0c1   Neeraj Sharma   fix all api and r...
20
              </v-toolbar>
7d0816758   Shikha Mishra   show dashboard wh...
21
22
23
24
25
26
27
28
29
              <v-card class="elevation-1 pa-1 card" style="background-color: #7852cc" dark>
                <img
                  src="/static/intrackIllustration.png"
                  class="mx-auto logoSchool"
                  style="display:block"
                  width="400"
                />
                <v-card-text align-center justify-center>
                  <v-toolbar-title class="text-xs-center my-4 subheadline">SCHOOL LOGIN</v-toolbar-title>
03dcbf0c1   Neeraj Sharma   fix all api and r...
30
31
                  <v-flex xs12 sm12 md12 lg12>
                    <v-form ref="form" v-model="valid" lazy-validation>
7d0816758   Shikha Mishra   show dashboard wh...
32
                      <label class="title">Email</label>
03dcbf0c1   Neeraj Sharma   fix all api and r...
33
                      <v-text-field
96f88269a   Neeraj Sharma   implement Student...
34
                        v-model.trim="userLogincredentials.email"
03dcbf0c1   Neeraj Sharma   fix all api and r...
35
                        :rules="nameRules"
7d0816758   Shikha Mishra   show dashboard wh...
36
                        placeholder="Enter your email"
03dcbf0c1   Neeraj Sharma   fix all api and r...
37
38
                        required
                      ></v-text-field>
7d0816758   Shikha Mishra   show dashboard wh...
39
                      <label class="title">Password</label>
03dcbf0c1   Neeraj Sharma   fix all api and r...
40
                      <v-text-field
e3e2a04c6   Neeraj Sharma   first commit
41
                        :rules="[rules.required]"
96f88269a   Neeraj Sharma   implement Student...
42
                        v-model.trim="userLogincredentials.password"
03dcbf0c1   Neeraj Sharma   fix all api and r...
43
44
45
46
                        :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...
47
                        placeholder="Enter Your password"
654e1501d   Neeraj Sharma   remove school-man...
48
                        @keyup.enter="login"
03dcbf0c1   Neeraj Sharma   fix all api and r...
49
50
51
                        counter
                      ></v-text-field>
                    </v-form>
a17c68a03   Neeraj Sharma   implement two rou...
52
53
                    <v-layout row wrap>
                      <v-flex xs6>
603a06702   Neeraj Sharma   implemented chang...
54
                        <!-- <v-checkbox :label="`Remember me`" v-model="remember"></v-checkbox> -->
03dcbf0c1   Neeraj Sharma   fix all api and r...
55
56
                      </v-flex>
                      <v-flex xs6>
a17c68a03   Neeraj Sharma   implement two rou...
57
                        <h5 class="right mt-4">
7d0816758   Shikha Mishra   show dashboard wh...
58
                          <router-link class="link" to="/forgetpassword">Forgot password</router-link>
a17c68a03   Neeraj Sharma   implement two rou...
59
60
61
                        </h5>
                      </v-flex>
                    </v-layout>
93a68cfa1   Jatinder Singh   first commit
62
                  </v-flex>
03dcbf0c1   Neeraj Sharma   fix all api and r...
63
64
                </v-card-text>
                <v-layout>
a17c68a03   Neeraj Sharma   implement two rou...
65
66
                  <v-flex sm12 class="my-3">
                    <v-btn
7d0816758   Shikha Mishra   show dashboard wh...
67
                      style="margin: auto;display: block;background-color: #71d9ea; color: #0c0754;"
a17c68a03   Neeraj Sharma   implement two rou...
68
                      dark
7d0816758   Shikha Mishra   show dashboard wh...
69
                      flat
a17c68a03   Neeraj Sharma   implement two rou...
70
71
72
73
                      @click="login"
                      :loading="loading"
                    >Login</v-btn>
                  </v-flex>
c7a4fe86a   Neeraj Sharma   responsive admin ...
74
                </v-layout>
a17c68a03   Neeraj Sharma   implement two rou...
75
                <v-layout></v-layout>
93a68cfa1   Jatinder Singh   first commit
76
77
78
79
80
              </v-card>
            </v-flex>
          </v-layout>
        </v-container>
      </v-content>
03dcbf0c1   Neeraj Sharma   fix all api and r...
81
    </v-app>
93a68cfa1   Jatinder Singh   first commit
82
83
84
  </template>
  
  <script>
03dcbf0c1   Neeraj Sharma   fix all api and r...
85
  import http from "@/Services/http.js";
93a68cfa1   Jatinder Singh   first commit
86
  export default {
03dcbf0c1   Neeraj Sharma   fix all api and r...
87
    data() {
93a68cfa1   Jatinder Singh   first commit
88
      return {
03dcbf0c1   Neeraj Sharma   fix all api and r...
89
90
91
92
93
94
        snackbar: false,
        y: "top",
        x: "right",
        mode: "",
        timeout: 3000,
        text: "",
080d88547   Shikha Mishra   issues solved
95
        append: "",
93a68cfa1   Jatinder Singh   first commit
96
97
98
99
        e1: true,
        loading: false,
        remember: false,
        valid: false,
b34ed827a   Jatinder Singh   changes
100
        userLogincredentials: {},
a17c68a03   Neeraj Sharma   implement two rou...
101
        nameRules: [v => !!v || "Username is required"],
03dcbf0c1   Neeraj Sharma   fix all api and r...
102
        password: "",
a17c68a03   Neeraj Sharma   implement two rou...
103
        email: "",
07095d4d8   Jatinder Singh   regex
104
        rules: {
a17c68a03   Neeraj Sharma   implement two rou...
105
          required: value => !!value || "password is Required."
03dcbf0c1   Neeraj Sharma   fix all api and r...
106
        }
93a68cfa1   Jatinder Singh   first commit
107
108
109
      };
    },
    methods: {
03dcbf0c1   Neeraj Sharma   fix all api and r...
110
      login() {
a17c68a03   Neeraj Sharma   implement two rou...
111
        this.loading = true;
e173bab21   Jatinder Singh   api
112
        var userdata = {
e3e2a04c6   Neeraj Sharma   first commit
113
          email: this.userLogincredentials.email,
99cd79184   Neeraj Sharma   implement all tas...
114
          password: this.userLogincredentials.password
03dcbf0c1   Neeraj Sharma   fix all api and r...
115
116
        };
        http()
e3e2a04c6   Neeraj Sharma   first commit
117
          .post("/schoolLogin", userdata)
e173bab21   Jatinder Singh   api
118
          .then(response => {
55f72b7d7   Neeraj Sharma   add new page are ...
119
            this.loading = false;
68d742034   Neeraj Sharma   implement new des...
120
121
122
123
            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 ...
124
              this.$router.push("/dashboard");
68d742034   Neeraj Sharma   implement new des...
125
126
127
            } else if (response.data.data.role === "SUPERADMIN") {
              this.$store.dispatch("setSchoolRole", response.data.data.role);
              this.$store.dispatch("setSchoolToken", response.data.data.token);
7d0816758   Shikha Mishra   show dashboard wh...
128
              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
156
    mounted() {
      if (this.$store.state.isUserLoggedIn == true) {
be1fe29bb   Neeraj Sharma   implement number ...
157
        this.$router.push("/dashboard");
7d0816758   Shikha Mishra   show dashboard wh...
158
      }
8deade193   Shikha Mishra   token issue solved
159
160
161
      else if (this.$store.state.isSchoolLoggedIn == true) {
        this.$router.push("/dashboard");
      }
a17c68a03   Neeraj Sharma   implement two rou...
162
    },
03dcbf0c1   Neeraj Sharma   fix all api and r...
163
164
165
    computed: {
      color() {
        return this.loading ? "success" : "error";
4413a8d93   Jatinder Singh   changes
166
      }
93a68cfa1   Jatinder Singh   first commit
167
168
    }
  };
93a68cfa1   Jatinder Singh   first commit
169
170
171
  </script>
  
  <style scoped lang="css">
03dcbf0c1   Neeraj Sharma   fix all api and r...
172
173
174
175
176
177
178
179
  #login {
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    content: "";
    z-index: 0;
  }
93a68cfa1   Jatinder Singh   first commit
180
  </style>
04e3fbc56   Jatinder Singh   minor fix
181
  <style scoped>
7d0816758   Shikha Mishra   show dashboard wh...
182
183
184
185
186
  .schoolLogo {
    height: 60%;
    padding-left: 31%;
  }
  /* img {
03dcbf0c1   Neeraj Sharma   fix all api and r...
187
188
    position: absolute;
    top: 13px;
55f72b7d7   Neeraj Sharma   add new page are ...
189
    left: 8px;
7d0816758   Shikha Mishra   show dashboard wh...
190
  } */
04e3fbc56   Jatinder Singh   minor fix
191
  .v-btn--large {
03dcbf0c1   Neeraj Sharma   fix all api and r...
192
    padding: 0px 84px;
93a68cfa1   Jatinder Singh   first commit
193
  }
a17c68a03   Neeraj Sharma   implement two rou...
194
195
  .link {
    text-decoration: none;
04e3fbc56   Jatinder Singh   minor fix
196
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
197
  a {
7d0816758   Shikha Mishra   show dashboard wh...
198
    color: #fff;
a17c68a03   Neeraj Sharma   implement two rou...
199
  }
03dcbf0c1   Neeraj Sharma   fix all api and r...
200
  .mt-4 {
a17c68a03   Neeraj Sharma   implement two rou...
201
    margin-top: 21px !important;
03dcbf0c1   Neeraj Sharma   fix all api and r...
202
203
  }
  @media screen and (max-width: 600px) {
a17c68a03   Neeraj Sharma   implement two rou...
204
205
206
207
208
    img {
      left: 10px;
      height: 34px;
      width: 120px;
    }
7d0816758   Shikha Mishra   show dashboard wh...
209
210
211
212
    .logo {
      height: 56px;
      left: 10px;
      width: 120px;
a17c68a03   Neeraj Sharma   implement two rou...
213
    }
7d0816758   Shikha Mishra   show dashboard wh...
214
215
216
217
    .logoSchool {
      height: 87px;
      left: 10px;
      width: 120px;
a17c68a03   Neeraj Sharma   implement two rou...
218
    }
4413a8d93   Jatinder Singh   changes
219
  }
93a68cfa1   Jatinder Singh   first commit
220
  </style>