Blame view

src/pages/User/user.vue 38.3 KB
687e0b929   Neeraj Sharma   add user,attenden...
1
  <template>
68d742034   Neeraj Sharma   implement new des...
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    <v-container fluid class="body-color">
      <!-- ****** EDIT USERS DETAILS ****** -->
      <v-dialog v-model="editUserDialog" max-width="1100px" scrollable>
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Edit User</label>
              <v-icon size="24" class="right" @click="editUserDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-layout>
              <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center my-4">
                <v-avatar size="120px">
                  <img src="/static/icon/user.png" v-if="!editedItem.profilePicUrl && !imageUrl" />
                  <img
                    :src="editedItem.profilePicUrl"
                    v-else-if="editedItem.profilePicUrl && !imageUrl"
                  />
                  <img
                    v-if="imageUrl"
                    :src="imageUrl"
                    height="150"
                    style="border-radius:50%; width:150px"
                  />
                </v-avatar>
                <input
                  type="file"
                  style="display:none"
                  ref="image"
                  accept="image/*"
                  @change="onFilePicked"
                />
              </v-flex>
            </v-layout>
            <v-layout wrap>
              <v-flex xs12 sm6>
0551a0f15   Neeraj Sharma   implemnet functio...
39
                <v-layout>
68d742034   Neeraj Sharma   implement new des...
40
41
42
43
44
45
46
47
48
49
50
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Name:</label>
                  </v-flex>
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      v-model="editedItem.name"
                      placeholder="fill your Name"
                      name="name"
                      type="text"
                      required
                    ></v-text-field>
0551a0f15   Neeraj Sharma   implemnet functio...
51
52
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
53
54
55
56
57
              </v-flex>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Email ID:</label>
0551a0f15   Neeraj Sharma   implemnet functio...
58
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
59
60
61
62
63
64
65
66
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      placeholder="fill your email"
                      v-model="editedItem.email"
                      type="text"
                      name="email"
                      required
                    ></v-text-field>
0551a0f15   Neeraj Sharma   implemnet functio...
67
68
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
69
70
71
72
73
74
75
76
              </v-flex>
            </v-layout>
            <v-layout wrap>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-sm-only hidden-xs-only">Date of Birth:</label>
                    <label class="right hidden-lg-only hidden-xl-only hidden-md-only">D.O.B:</label>
0551a0f15   Neeraj Sharma   implemnet functio...
77
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
                  <v-flex xs8 class="ml-3">
                    <v-menu
                      ref="menu"
                      :close-on-content-click="false"
                      v-model="menu2"
                      :nudge-right="40"
                      lazy
                      transition="scale-transition"
                      offset-y
                      full-width
                      min-width="290px"
                    >
                      <v-text-field
                        slot="activator"
                        v-model="editedItem.dob"
                        placeholder="Select date"
                      ></v-text-field>
                      <v-date-picker
                        ref="picker"
                        v-model="editedItem.dob"
                        :max="new Date().toISOString().substr(0, 10)"
                        min="1950-01-01"
                        @input="menu2 = false"
                      ></v-date-picker>
                    </v-menu>
0551a0f15   Neeraj Sharma   implemnet functio...
103
104
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
105
106
107
108
109
              </v-flex>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Gender:</label>
0551a0f15   Neeraj Sharma   implemnet functio...
110
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
111
112
113
114
115
116
117
118
                  <v-flex xs8 class="ml-3">
                    <v-select
                      :items="gender"
                      v-model="editedItem.gender"
                      label="Select gender"
                      name="gender"
                      required
                    ></v-select>
0551a0f15   Neeraj Sharma   implemnet functio...
119
120
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
121
122
123
124
125
126
127
              </v-flex>
            </v-layout>
            <v-layout wrap>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Religion:</label>
0551a0f15   Neeraj Sharma   implemnet functio...
128
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
129
130
131
132
133
134
135
136
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      v-model="editedItem.religion"
                      placeholder="fill your Religion"
                      name="religion"
                      type="text"
                      required
                    ></v-text-field>
0551a0f15   Neeraj Sharma   implemnet functio...
137
138
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
139
140
141
142
143
              </v-flex>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">JoiningDate:</label>
0551a0f15   Neeraj Sharma   implemnet functio...
144
                  </v-flex>
68d742034   Neeraj Sharma   implement new des...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
                  <v-flex xs8 class="ml-3">
                    <v-menu
                      ref="menu"
                      :close-on-content-click="false"
                      v-model="menu3"
                      :nudge-right="40"
                      lazy
                      transition="scale-transition"
                      offset-y
                      full-width
                      min-width="290px"
                    >
                      <v-text-field
                        slot="activator"
                        v-model="editedItem.joiningDate"
                        placeholder="Select date"
                      ></v-text-field>
                      <v-date-picker
                        ref="picker"
                        v-model="editedItem.joiningDate"
                        :max="new Date().toISOString().substr(0, 10)"
                        min="1950-01-01"
                        @input="menu3 = false"
                      ></v-date-picker>
                    </v-menu>
0551a0f15   Neeraj Sharma   implemnet functio...
170
171
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
172
173
174
175
              </v-flex>
            </v-layout>
            <v-layout wrap>
              <v-flex xs12 sm6>
0551a0f15   Neeraj Sharma   implemnet functio...
176
                <v-layout>
68d742034   Neeraj Sharma   implement new des...
177
178
179
180
181
182
183
184
185
186
187
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Phone:</label>
                  </v-flex>
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      v-model="editedItem.phone"
                      placeholder="fill your MobileNo"
                      name="mobileNo"
                      type="number"
                      required
                    ></v-text-field>
0551a0f15   Neeraj Sharma   implemnet functio...
188
189
                  </v-flex>
                </v-layout>
68d742034   Neeraj Sharma   implement new des...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
              </v-flex>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-sm-only hidden-xs-only">Select Role:</label>
                    <label class="right hidden-lg-only hidden-xl-only hidden-md-only">Role:</label>
                  </v-flex>
                  <v-flex xs8 class="ml-3">
                    <v-autocomplete
                      v-model="editedItem.role"
                      :label="editedItem.role"
                      :items="userRole"
                      item-text="name"
                      item-value="role"
                      required
                    ></v-autocomplete>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
            <v-layout wrap>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-sm-only hidden-xs-only">Uplaod Image:</label>
                    <label class="right hidden-lg-only hidden-xl-only hidden-md-only">Uplaod:</label>
                  </v-flex>
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      label="Select Image"
                      @click="pickFile"
                      v-model="imageName"
                      append-icon="attach_file"
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Address:</label>
                  </v-flex>
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      name="input-4-3"
                      v-model="editedItem.address"
                      placeholder="fill Your  Address"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
            <v-layout>
              <v-flex xs12 sm12>
                <v-card-actions class="hidden-sm-only hidden-xs-only">
                  <v-spacer></v-spacer>
                  <v-btn round dark :loading="loading" @click="save" class="add-button">Save</v-btn>
                </v-card-actions>
                <v-card-actions class="hidden-lg-only hidden-xl-only hidden-md-only">
                  <v-spacer></v-spacer>
                  <v-btn round dark :loading="loading" @click="save" class="add-button">Save</v-btn>
                  <v-spacer></v-spacer>
                </v-card-actions>
              </v-flex>
            </v-layout>
          </v-card-text>
        </v-card>
      </v-dialog>
      <!-- ****** PROFILE User DETAILS ******  -->
      <v-dialog v-model="viewUserDialog" max-width="560px" scrollable>
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View User</label>
              <v-icon size="24" class="right" @click="viewUserDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-container grid-list-md>
              <v-layout wrap>
                <v-flex>
                  <v-flex align-center justify-center layout text-xs-center>
                    <v-avatar size="100px">
                      <img src="/static/icon/user.png" v-if="!editedItem.profilePicUrl" />
                      <img :src="editedItem.profilePicUrl" v-else-if="editedItem.profilePicUrl" />
                    </v-avatar>
                  </v-flex>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Name:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.name }}</h5>
687e0b929   Neeraj Sharma   add user,attenden...
286
287
                    </v-flex>
                  </v-layout>
68d742034   Neeraj Sharma   implement new des...
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Email:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.email }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Gender:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.gender }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Religion:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.religion }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Role:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.role }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Phone:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.phone }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>JoiningDate:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ dates(editedItem.joiningDate) }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <label class="right hidden-sm-only hidden-xs-only">
                          <b>Date of Birth:</b>
                        </label>
                        <label class="right hidden-lg-only hidden-xl-only hidden-md-only">
                          <b>D.O.B:</b>
                        </label>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ dates(editedItem.dob) }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm6>
                      <h5 class="right my-1">
                        <b>Address:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm6 xs8>
                      <h5 class="my-1">{{ editedItem.address }}</h5>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-card-text>
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
379

68d742034   Neeraj Sharma   implement new des...
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
      <!-- ****** EXISTING-USER TABLE DATA****** -->
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addUserDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addUserDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add User
        </v-btn>
        <v-spacer></v-spacer>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon large flat @click="displaySearch">
            <v-avatar size="27">
aa310d61a   Shikha Mishra   added functionali...
403
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
            </v-avatar>
          </v-btn>
        </v-card-title>
        <v-flex xs8 sm8 lg2 md3 v-show="showSearch">
          <v-layout>
            <v-text-field v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field>
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
      <v-data-table :headers="headers" :items="Users" :pagination.sync="pagination" :search="search">
        <template slot="items" slot-scope="props">
          <td class="td td-row">{{ props.index + 1 }}</td>
          <td class="td td-row text-xs-center">
            <v-avatar size="40">
              <img :src="props.item.profilePicUrl" v-if="props.item.profilePicUrl" />
              <img src="/static/icon/user.png" v-else-if="!props.item.profilePicUrl" />
            </v-avatar>
          </td>
          <td class="text-xs-center td td-row">{{ props.item.name}}</td>
          <td class="text-xs-center td td-row">{{ props.item.email }}</td>
          <td class="text-xs-center td td-row">{{ dates(props.item.dob) }}</td>
          <td class="text-xs-center td td-row">{{ dates(props.item.joiningDate)}}</td>
          <td class="text-xs-center td td-row">{{ props.item.phone }}</td>
          <td class="text-xs-center td td-row">
            <v-switch
              class="pl-3"
              v-model="props.item.status"
              @change="suspendStatus(props.item.status,props.item._id)"
            ></v-switch>
          </td>
          <td class="text-xs-center td td-row">
            <span>
              <v-tooltip top>
                <img
                  slot="activator"
                  style="cursor:pointer; width:25px; height:25px; "
                  class="mr-3"
                  @click="profile(props.item)"
aa310d61a   Shikha Mishra   added functionali...
443
                  src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
444
445
446
447
448
449
450
451
452
                />
                <span>View</span>
              </v-tooltip>
              <v-tooltip top>
                <img
                  slot="activator"
                  style="cursor:pointer; width:20px; height:18px; "
                  class="mr-3"
                  @click="editItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
453
                  src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
454
455
456
457
458
459
460
461
462
                />
                <span>Edit</span>
              </v-tooltip>
              <v-tooltip top>
                <img
                  slot="activator"
                  style="cursor:pointer; width:20px; height:20px; "
                  class="mr-3"
                  @click="deleteItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
463
                  src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
                />
                <span>Delete</span>
              </v-tooltip>
            </span>
          </td>
        </template>
        <v-alert
          slot="no-results"
          :value="true"
          color="error"
          icon="warning"
        >Your search for "{{ search }}" found no results.</v-alert>
      </v-data-table>
      <!-- ****** Add User Data****** -->
      <v-dialog v-model="addUserDialog" max-width="900px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add User</label>
              <v-icon size="24" class="right" @click="addUserDialog = false">cancel</v-icon>
687e0b929   Neeraj Sharma   add user,attenden...
484
            </v-flex>
68d742034   Neeraj Sharma   implement new des...
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-layout>
                <v-flex
                  xs12
                  class="text-xs-center text-sm-center text-md-center text-lg-center my-4 mr-4"
                >
                  <v-avatar size="80px">
                    <img src="/static/icon/user.png" v-if="!imageUrl" />
                  </v-avatar>
                  <img
                    :src="imageUrl"
                    height="150"
                    v-if="imageUrl"
                    style="border-radius:50%; width:150px"
                  />
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Name:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-text-field
                        v-model="addUser.name"
                        placeholder="fill your Name"
                        name="name"
                        type="text"
                        :rules="nameRules"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                </v-flex>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Email ID:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-text-field
                        placeholder="fill your email"
                        :rules="emailRules"
                        v-model="addUser.email"
                        type="text"
                        name="email"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right hidden-sm-only hidden-xs-only">Date of Birth:</label>
                      <label class="right hidden-lg-only hidden-xl-only hidden-md-only">D.O.B:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-menu
                        ref="menu"
                        :close-on-content-click="false"
                        v-model="menu"
                        :nudge-right="40"
                        lazy
                        transition="scale-transition"
                        offset-y
                        full-width
                        min-width="290px"
                      >
                        <v-text-field
                          slot="activator"
                          :rules="dateRules"
                          v-model="addUser.dob"
                          placeholder="Select DOB"
                        ></v-text-field>
                        <v-date-picker
                          ref="picker"
                          v-model="addUser.dob"
                          :max="new Date().toISOString().substr(0, 10)"
                          min="1950-01-01"
                          @input="menu = false"
                        ></v-date-picker>
                      </v-menu>
                    </v-flex>
                  </v-layout>
                </v-flex>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Gender:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-select
                        v-model="addUser.gender"
                        :items="gender"
                        label="Selct Gender "
                        :rules="genderRules"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Religion:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-text-field
                        v-model="addUser.religion"
                        placeholder="fill your Religion"
                        name="Religion"
                        type="text"
                        :rules="religionRules"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                </v-flex>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">JoiningDate:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-menu
                        ref="menu1"
                        :close-on-content-click="false"
                        v-model="menu1"
                        :nudge-right="40"
                        lazy
                        transition="scale-transition"
                        offset-y
                        full-width
                        min-width="290px"
                      >
                        <v-text-field
                          slot="activator"
                          :rules="joinDateRules"
                          v-model="addUser.joinDate"
                          placeholder="Select date"
                        ></v-text-field>
                        <v-date-picker
                          ref="picker"
                          v-model="addUser.joinDate"
                          :max="new Date().toISOString().substr(0, 10)"
                          min="1950-01-01"
                          @input="menu1 = false"
                        ></v-date-picker>
                      </v-menu>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Phone :</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-text-field
                        v-model="addUser.mobileNo"
                        placeholder="fill your Phone Number"
                        name="mobileNo"
                        type="number"
                        :rules="mobileNoRules"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                </v-flex>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right hidden-sm-only hidden-xs-only">Select Role:</label>
                      <label class="right hidden-lg-only hidden-xl-only hidden-md-only">Role:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-autocomplete
                        v-model="addUser.role"
                        :rules="role"
                        :items="userRole"
                        item-text="name"
                        item-value="name"
                        placeholder="Select Role Name"
                        required
                      ></v-autocomplete>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
              <v-layout wrap>
710438de6   Shikha Mishra   added teacher mod...
685
                <!-- <v-flex xs12 sm6>
68d742034   Neeraj Sharma   implement new des...
686
687
688
689
690
691
692
693
694
695
696
697
698
699
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Username:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-text-field
                        v-model="addUser.userName"
                        placeholder="fill your User Name"
                        type="text"
                        :rules="userNameRules"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
710438de6   Shikha Mishra   added teacher mod...
700
                </v-flex> -->
68d742034   Neeraj Sharma   implement new des...
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right hidden-sm-only hidden-xs-only">Uplaod Image:</label>
                      <label class="right hidden-lg-only hidden-xl-only hidden-md-only">Image:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-text-field
                        label="Select Image"
                        @click="pickFile"
                        v-model="imageName"
                        append-icon="attach_file"
                      ></v-text-field>
                      <input
                        type="file"
                        style="display:none"
                        ref="image"
                        accept="image/*"
                        @change="onFilePicked"
                      />
                    </v-flex>
                  </v-layout>
                </v-flex>
                <v-flex xs12 sm6>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
                      <label class="right">Address:</label>
                    </v-flex>
                    <v-flex xs8 class="ml-3">
                      <v-text-field
                        name="input-4-3"
                        v-model="addUser.presentAddress"
                        :rules="presentAddress"
                        placeholder="fill Your present Address"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs12 sm12>
                  <v-layout class="right">
                    <v-btn @click="clear" round dark class="clear-button">Clear</v-btn>
                    <v-btn @click="submit" round dark :loading="loading" class="add-button">Add</v-btn>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-form>
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
753
754
755
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
756
757
758
759
760
761
762
763
764
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        :color="color"
      >{{ text }}</v-snackbar>
    </v-container>
687e0b929   Neeraj Sharma   add user,attenden...
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import Util from "@/util";
  import moment from "moment";
  
  export default {
    data: () => ({
      component: "report-generate",
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
68d742034   Neeraj Sharma   implement new des...
780
      color: "",
687e0b929   Neeraj Sharma   add user,attenden...
781
      text: "",
68d742034   Neeraj Sharma   implement new des...
782
783
      show: true,
      showSearch: false,
687e0b929   Neeraj Sharma   add user,attenden...
784
785
      showLoader: false,
      loading: false,
68d742034   Neeraj Sharma   implement new des...
786
      addUserDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
787
788
789
790
791
792
      date: null,
      search: "",
      menu: false,
      menu1: false,
      menu2: false,
      menu3: false,
68d742034   Neeraj Sharma   implement new des...
793
794
      viewUserDialog: false,
      editUserDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
795
796
797
798
      valid: true,
      isActive: true,
      newActive: false,
      pagination: {
68d742034   Neeraj Sharma   implement new des...
799
        rowsPerPage: 10
687e0b929   Neeraj Sharma   add user,attenden...
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
      },
      imageData: {},
      imageName: "",
      imageUrl: "",
      imageFile: "",
      nameRules: [v => !!v || "Name is required"],
      dateRules: [v => !!v || " DOB is required"],
      genderRules: [v => !!v || " Gender Name is required"],
      pincode: [v => !!v || " Pincode is required"],
      role: [v => !!v || "Role Name is required"],
      permanentAddress: [v => !!v || " Permanent Address is required"],
      presentAddress: [v => !!v || " Present Address  is required"],
      mobileNoRules: [v => !!v || "Phone Number is required"],
      religionRules: [v => !!v || "Religion Name is required"],
      joinDateRules: [v => !!v || " Join Date is required"],
      userNameRules: [v => !!v || " User Name is required"],
      passwordRules: [v => !!v || " Password is required"],
      errorMessages: "",
      userRole: [],
      emailRules: [
        v => !!v || "E-mail is required",
        v =>
          /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) ||
          "E-mail must be valid"
      ],
      gender: ["Male", "Female"],
      headers: [
        {
          text: "No",
68d742034   Neeraj Sharma   implement new des...
829
          align: "",
687e0b929   Neeraj Sharma   add user,attenden...
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
          sortable: false,
          value: "No"
        },
        {
          text: "Profile Pic",
          value: "profilePicUrl",
          sortable: false,
          align: "center"
        },
        { text: "Name", value: "name", sortable: false, align: "center" },
        { text: "Email", value: "email", sortable: false, align: "center" },
        { text: "DOB", value: "dob", sortable: false, align: "center" },
        {
          text: "Joining Date",
          value: "joiningDate",
          sortable: false,
          align: "center"
        },
        {
          text: "Phone",
          value: "phone",
          sortable: false,
          align: "center"
        },
68d742034   Neeraj Sharma   implement new des...
854
855
856
857
858
859
        {
          text: "Status",
          value: "status",
          sortable: false,
          align: "center"
        },
687e0b929   Neeraj Sharma   add user,attenden...
860
861
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
68d742034   Neeraj Sharma   implement new des...
862
      Users: [],
687e0b929   Neeraj Sharma   add user,attenden...
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
      editedIndex: -1,
      upload: "",
      editedItem: {
        role: "",
        name: "",
        email: "",
        dob: null,
        gender: "",
        role: "",
        address: "",
        phone: "",
        religion: "",
        joiningDate: null
      },
      addUser: {
        role: "",
        name: "",
        email: "",
        dob: null,
        gender: "",
        pincode: "",
        role: "",
        permanentAddress: "",
        presentAddress: "",
        mobileNo: "",
        religion: "",
        joiningDate: null
      }
    }),
    watch: {
      menu(val) {
        val && this.$nextTick(() => (this.$refs.picker.activePicker = "YEAR"));
      },
      menu1(val) {
        val && this.$nextTick(() => (this.$refs.picker.activePicker = "YEAR"));
      }
    },
    methods: {
      save(date) {
        this.$refs.menu.save(date);
      },
      save(date) {
        this.$refs.menu1.save(date);
      },
      pickFile() {
        this.$refs.image.click();
      },
      onFilePicked(e) {
        // console.log(e)
        const files = e.target.files;
        this.upload = e.target.files[0];
        console.log("imageData-upload========>", this.upload);
        if (files[0] !== undefined) {
          this.imageName = files[0].name;
          if (this.imageName.lastIndexOf(".") <= 0) {
            return;
          }
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
            this.imageUrl = fr.result;
            this.imageFile = files[0]; // this is an image file that can be sent to server...
            // this.imageData.imageUrl = URL.createObjectURL(this.imageFile);
            // console.log("upload=======>", this.imageData.imageUrl);
            console.log("imageFile", this.imageUrl);
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
          this.imageUrl = "";
        }
      },
      dates: function(date) {
        return moment(date).format("MMMM DD, YYYY");
      },
      getUsersList() {
        this.showLoader = true;
        var token = this.$store.state.token;
        http()
          .get("/getUsersList", {
            headers: { Authorization: "Bearer " + token }
          })
          .then(response => {
68d742034   Neeraj Sharma   implement new des...
946
            this.Users = response.data.data;
687e0b929   Neeraj Sharma   add user,attenden...
947
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
948
949
950
951
952
953
954
955
956
957
958
          })
          .catch(error => {
            this.showLoader = false;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
      editItem(item) {
68d742034   Neeraj Sharma   implement new des...
959
        this.editedIndex = this.Users.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
960
961
962
963
964
965
966
967
968
969
        this.editedItem = Object.assign({}, item);
        this.editedItem.dob =
          this.editedItem.dob != undefined
            ? (this.editedItem.dob = this.editedItem.dob.substring(0, 10))
            : (this.editedItem.dob = "");
        for (let i = 0; i < this.userRole.length; i++) {
          if (this.userRole[i].role === this.editedItem.role) {
            this.editedItem.role = this.userRole[i].name;
          }
        }
68d742034   Neeraj Sharma   implement new des...
970
        this.editUserDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
971
972
      },
      profile(item) {
68d742034   Neeraj Sharma   implement new des...
973
        this.editedIndex = this.Users.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
974
        this.editedItem = Object.assign({}, item);
68d742034   Neeraj Sharma   implement new des...
975
        this.viewUserDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
976
977
978
979
980
981
982
983
        for (let i = 0; i < this.userRole.length; i++) {
          if (this.userRole[i].role === this.editedItem.role) {
            this.editedItem.role = this.userRole[i].name;
          }
        }
      },
      deleteItem(item) {
        let deleteUser = {
99cd79184   Neeraj Sharma   implement all tas...
984
          userId: item._id
687e0b929   Neeraj Sharma   add user,attenden...
985
        };
687e0b929   Neeraj Sharma   add user,attenden...
986
987
988
989
990
991
992
993
        http()
          .delete(
            "/deleteUser",
            confirm("Are you sure you want to delete this?") && {
              params: deleteUser
            }
          )
          .then(response => {
99cd79184   Neeraj Sharma   implement all tas...
994
            this.snackbar = true;
68d742034   Neeraj Sharma   implement new des...
995
996
            this.text = response.data.message;
            this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
997
998
999
            this.getUsersList();
          })
          .catch(error => {
68d742034   Neeraj Sharma   implement new des...
1000
1001
1002
            this.snackbar = true;
            this.color = "error";
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
1003
1004
          });
      },
687e0b929   Neeraj Sharma   add user,attenden...
1005
      close() {
68d742034   Neeraj Sharma   implement new des...
1006
        this.editUserDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
1007
      },
68d742034   Neeraj Sharma   implement new des...
1008
1009
      closeProfileDialog() {
        this.viewUserDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
      },
      submit() {
        if (this.$refs.form.validate()) {
          let addUserData = {
            name: this.addUser.name,
            email: this.addUser.email,
            dob: this.addUser.dob,
            gender: this.addUser.gender,
            religion: this.addUser.religion,
            role: this.addUser.role,
            address: this.addUser.presentAddress,
            phone: this.addUser.mobileNo,
            religion: this.addUser.religion,
            joiningDate: this.addUser.joinDate
          };
          if (this.imageUrl) {
            var str = this.imageUrl;
            const [baseUrl, imageUrl] = str.split(/,/);
            addUserData.profilePicUrl = imageUrl;
          }
          this.loading = true;
          http()
            .post("/createUser", addUserData)
            .then(response => {
0551a0f15   Neeraj Sharma   implemnet functio...
1034
              this.imageUrl = "";
687e0b929   Neeraj Sharma   add user,attenden...
1035
              this.getUsersList();
0551a0f15   Neeraj Sharma   implemnet functio...
1036
              this.snackbar = true;
67a276510   Shikha Mishra   fixed all bugs
1037
              this.addUserDialog = false;
68d742034   Neeraj Sharma   implement new des...
1038
1039
              this.text = response.data.message;
              this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
1040
1041
1042
1043
              this.clear();
              this.loading = false;
            })
            .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
1044
              this.loading = false;
68d742034   Neeraj Sharma   implement new des...
1045
1046
1047
              this.snackbar = true;
              this.color = "error";
              this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
1048
1049
1050
1051
1052
            });
        }
      },
      clear() {
        this.$refs.form.reset();
0551a0f15   Neeraj Sharma   implemnet functio...
1053
        this.imageUrl = "";
687e0b929   Neeraj Sharma   add user,attenden...
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
      },
      save() {
        this.loading = true;
        for (let i = 0; i < this.userRole.length; i++) {
          if (this.userRole[i].name === this.editedItem.role) {
            this.editedItem.role = this.userRole[i].role;
          }
        }
        this.editedItem.userId = this.editedItem._id;
        if (this.imageUrl) {
          var str = this.imageUrl;
          const [baseUrl, imageUrl] = str.split(/,/);
          this.editedItem.upload = imageUrl;
        }
        http()
          .put("/updateUser", this.editedItem)
          .then(response => {
68d742034   Neeraj Sharma   implement new des...
1071
1072
1073
            this.snackbar = true;
            this.text = response.data.message;
            this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
1074
1075
1076
1077
1078
            this.loading = false;
            this.getUsersList();
            this.close();
          })
          .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
1079
            this.loading = false;
68d742034   Neeraj Sharma   implement new des...
1080
1081
1082
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
687e0b929   Neeraj Sharma   add user,attenden...
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
          });
      },
      getRole() {
        this.showLoader = true;
        var token = this.$store.state.token;
        http()
          .get("/getRolesList", {
            headers: { Authorization: "Bearer " + token }
          })
          .then(response => {
            this.userRole = response.data.data;
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
1095
1096
1097
1098
1099
1100
1101
1102
1103
          })
          .catch(error => {
            this.showLoader = false;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
68d742034   Neeraj Sharma   implement new des...
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
      },
      suspendStatus(suspendStatus, id) {
        let suspendStatusData = {
          userId: id,
          status: suspendStatus
        };
        this.showLoader = true;
        http()
          .put("/suspendUserAccount", suspendStatusData)
          .then(response => {
            this.getUsersList();
            this.text = response.data.message;
            this.snackbar = true;
            this.showLoader = false;
          })
          .catch(error => {
            // console.log(error.response.data.data);
            this.snackbar = true;
            this.text = error.response.data.message;
            this.showLoader = false;
          });
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
687e0b929   Neeraj Sharma   add user,attenden...
1133
1134
1135
1136
1137
      }
    },
    mounted() {
      this.getUsersList();
      this.getRole();
687e0b929   Neeraj Sharma   add user,attenden...
1138
1139
    }
  };
68d742034   Neeraj Sharma   implement new des...
1140
  </script>