Blame view

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