Blame view

src/pages/Academic/assignment.vue 29.9 KB
710438de6   Shikha Mishra   added teacher mod...
1
2
3
  <template>
    <v-container fluid class="body-color">
      <!-- ****** EDIT  Assignment ****** -->
db965de89   Amber Dev   added dialog pers...
4
      <v-dialog v-model="editAssignmentDialog" max-width="400px" persistent>
710438de6   Shikha Mishra   added teacher mod...
5
6
7
8
9
10
11
12
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Edit Assignment</label>
              <v-icon size="24" class="right" @click="editAssignmentDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-container fluid>
b039d39fb   Shikha Mishra   Hide Edit functio...
13
            <v-form ref="formEditAssignment" v-model="validEditAssignment" lazy-validation>
710438de6   Shikha Mishra   added teacher mod...
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-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right">Title:</label>
                </v-flex>
                <v-flex xs8 class="ml-3">
                  <v-text-field v-model="editedItem.title" type="text" :rules="titleRules" required></v-text-field>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right">Description:</label>
                </v-flex>
                <v-flex xs8 class="ml-3">
                  <v-text-field
                    v-model="editedItem.description"
                    type="text"
                    :rules="deadlineRules"
                    required
                  ></v-text-field>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right">Deadline:</label>
                </v-flex>
b039d39fb   Shikha Mishra   Hide Edit functio...
39
                <v-flex xs8 class="ml-3">
710438de6   Shikha Mishra   added teacher mod...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
                  <v-menu
                    ref="menu1"
                    :close-on-content-click="false"
                    v-model="menu1"
                    :nudge-right="40"
                    :return-value.sync="menu1"
                    lazy
                    transition="scale-transition"
                    offset-y
                    full-width
                    min-width="290px"
                  >
                    <v-text-field
                      slot="activator"
                      v-model="editedItem.deadline"
8888e892f   Amber Dev   added label changes
55
                      placeholder="Select Date"
710438de6   Shikha Mishra   added teacher mod...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
                      :rules="deadlineRules"
                      append-icon="event"
                      required
                    ></v-text-field>
                    <v-date-picker v-model="editedItem.date" @input="menu1 = false"></v-date-picker>
                  </v-menu>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right">Class:</label>
                </v-flex>
                <v-flex xs8 class="ml-3">
                  <v-select
                    :items="classList"
                    item-text="classNum"
                    item-value="_id"
                    :rules="classRules"
                    v-model="editedItem.classId"
b039d39fb   Shikha Mishra   Hide Edit functio...
75
                    @change="getSections(editedItem.classId)"
710438de6   Shikha Mishra   added teacher mod...
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
                    required
                  ></v-select>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right">Section:</label>
                </v-flex>
                <v-flex xs8 class="ml-3">
                  <v-select
                    :items="addSection"
                    item-text="name"
                    item-value="_id"
                    v-model="editedItem.sectionId"
                    :rules="sectionRules"
b039d39fb   Shikha Mishra   Hide Edit functio...
91
                    @change="getClassSubject(editedItem.classId)"
710438de6   Shikha Mishra   added teacher mod...
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
                    required
                  ></v-select>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
                  <label class="right">Subject</label>
                </v-flex>
                <v-flex xs8 class="ml-3">
                  <v-select
                    :items="subjectList.subjects"
                    v-model="editedItem.subjectName"
                    item-text="subjectName"
                    item-value="_id"
                    :rules="subjectRules"
                    required
                  ></v-select>
                </v-flex>
              </v-layout>
              <v-layout>
                <v-flex xs4 class="pt-4 subheading">
fa4edf929   Shikha Mishra   added option of u...
113
114
                  <label class="right hidden-xs-only hidden-sm-only">Uplaod File:</label>
                  <label class="right hidden-lg-only hidden-md-only hidden-xl-only">File :</label>
710438de6   Shikha Mishra   added teacher mod...
115
                </v-flex>
fa4edf929   Shikha Mishra   added option of u...
116
                <v-flex xs8 sm8 class="ml-3">
710438de6   Shikha Mishra   added teacher mod...
117
                  <v-text-field
fa4edf929   Shikha Mishra   added option of u...
118
                    label="Select File"
710438de6   Shikha Mishra   added teacher mod...
119
                    @click="pickFile"
5ceb88b44   Shikha Mishra   added pdf option ...
120
                    v-model="imageName"
710438de6   Shikha Mishra   added teacher mod...
121
122
                    append-icon="attach_file"
                  ></v-text-field>
d10c26632   Shikha Mishra   Improve updateBoo...
123
124
125
126
127
128
129
                  <input
                    type="file"
                    style="display:none"
                    ref="image"
                    accept="image/*"
                    @change="onFilePicked"
                  />
710438de6   Shikha Mishra   added teacher mod...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
                </v-flex>
              </v-layout>
              <v-flex xs12 sm12>
                <v-card-actions>
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" :loading="editLoading" class="add-button">Save</v-btn>
                </v-card-actions>
              </v-flex>
            </v-form>
          </v-container>
        </v-card>
      </v-dialog>
  
      <!-- ****** VIEW PROFIL NOTICE BOARD ******  -->
db965de89   Amber Dev   added dialog pers...
144
      <v-dialog v-model="viewAssignmentDialog" max-width="500px" persistent>
710438de6   Shikha Mishra   added teacher mod...
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View Attendence</label>
              <v-icon size="24" class="right" @click="viewAssignmentDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-container grid-list-md>
              <v-layout wrap>
                <v-flex>
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Title:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.title }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Description:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ editedItem.description }}</h5>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs6 sm4>
                      <h5 class="right my-1">
                        <b>Deadline:</b>
                      </h5>
                    </v-flex>
                    <v-flex sm8 xs6>
                      <h5 class="my-1">{{ dates(editedItem.deadline) }}</h5>
                    </v-flex>
                  </v-layout>
                </v-flex>
              </v-layout>
            </v-container>
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** EXISTING ASSIGNMENT TABLE ****** -->
      <v-toolbar color="transparent" flat>
        <v-btn
          fab
          dark
          class="open-dialog-button hidden-xl-only hidden-md-only hidden-lg-only"
          small
          @click="addAssignmentDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-flex xs1 class="hidden-sm-only hidden-xs-only">
          <v-btn round class="open-dialog-button" dark @click="addAssignmentDialog = true">
            <v-icon class="white--text pr-1" size="20">add</v-icon>Add Assignment
          </v-btn>
        </v-flex>
        <v-spacer></v-spacer>
        <v-flex lg2 md2 xs12 v-show="show">
          <v-select
            :items="classList"
8888e892f   Amber Dev   added label changes
213
            placeholder="Select Your Class"
b039d39fb   Shikha Mishra   Hide Edit functio...
214
            v-model="showAssignment.classId"
710438de6   Shikha Mishra   added teacher mod...
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
            item-text="classNum"
            item-value="_id"
            name="Select Class"
            :rules="classRules"
            @change="getAssignmentList()"
            class="pl-2"
            required
          ></v-select>
        </v-flex>
        <v-card-title class="body-1" v-show="show">
          <v-btn icon flat @click="displaySearch">
            <v-avatar size="27">
              <img src="/static/icon/search.png" alt="icon" />
            </v-avatar>
          </v-btn>
        </v-card-title>
612b79bb4   Amber Dev   made serch auto f...
231
        <v-flex xs9 sm9 md2 lg2 xl2 v-if="showSearch">
710438de6   Shikha Mishra   added teacher mod...
232
233
234
          <v-layout>
            <v-text-field
              v-model="search"
8888e892f   Amber Dev   added label changes
235
              placeholder="Search"
710438de6   Shikha Mishra   added teacher mod...
236
237
              prepend-inner-icon="search"
              color="primary"
612b79bb4   Amber Dev   made serch auto f...
238
              autofocus
710438de6   Shikha Mishra   added teacher mod...
239
240
241
242
243
244
245
246
247
248
249
250
251
              style="transition: 0.8s cubic-bezier(0.25, 0.8, 0.25, 1); !important"
            ></v-text-field>
            <v-icon @click="closeSearch" color="error">close</v-icon>
          </v-layout>
        </v-flex>
      </v-toolbar>
      <v-data-table
        :headers="headers"
        :items="assignmentData"
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
d5fcb1cd1   Shikha Mishra   issues resolved
252
          <tr class="tr">
710438de6   Shikha Mishra   added teacher mod...
253
254
255
256
257
            <td class="td-row td">{{ props.index + 1 }}</td>
            <td class="text-xs-center td td-row">{{ props.item.title }}</td>
            <td class="text-xs-center td td-row">{{ props.item.description }}</td>
            <td class="text-xs-center td td-row">{{ props.item.deadline }}</td>
            <td class="text-xs-center td td-row">{{ props.item.sectionId.name }}</td>
5ceb88b44   Shikha Mishra   added pdf option ...
258
259
            <td
              class="text-xs-center td td-row"
dbcbd11f4   Shikha Mishra   improve filename ...
260
              v-if="props.item.teacherId"
5ceb88b44   Shikha Mishra   added pdf option ...
261
262
263
            >{{ props.item.teacherId.name }}</td>
            <td
              class="text-xs-center td td-row"
dbcbd11f4   Shikha Mishra   improve filename ...
264
              v-if="!props.item.teacherId"
57a3ca1d6   Shikha Mishra   show uploader nam...
265
            >{{ props.item.schoolId.name }}</td>
710438de6   Shikha Mishra   added teacher mod...
266
            <td class="text-xs-center td td-row">
25766f5a4   Shikha Mishra   make filename vie...
267
268
269
270
271
272
273
274
275
276
277
              <a
                class="hover"
                :href="props.item.file"
                target="_blank"
                style="text-decoration: none!important; color: grey"
                @click="generatePDF2Canvas(props.item)"
                :loading="loadingPdf"
              >
                <!-- <span> -->
                <h5>{{props.item.fileName}}</h5>
                <!-- </span> -->
ab4a9d6ee   Shikha Mishra   file name issue s...
278
              </a>
5ceb88b44   Shikha Mishra   added pdf option ...
279
280
            </td>
            <td class="text-xs-center td td-row">
710438de6   Shikha Mishra   added teacher mod...
281
282
283
284
285
286
287
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
              <span>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:25px; height:25px; "
                    class="mr-3"
                    @click="profile(props.item)"
                    src="/static/icon/view.png"
                  />
                  <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)"
                    src="/static/icon/edit.png"
                  />
                  <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)"
                    src="/static/icon/delete.png"
                  />
                  <span>Delete</span>
                </v-tooltip>
              </span>
            </td>
          </tr>
        </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 MULTIPLE Subject ****** -->
      <v-snackbar
        :timeout="timeout"
        :top="y === 'top'"
        :right="x === 'right'"
        :vertical="mode === 'vertical'"
        v-model="snackbar"
        :color="color"
      >{{ text }}</v-snackbar>
db965de89   Amber Dev   added dialog pers...
332
      <v-dialog v-model="addAssignmentDialog" max-width="400px" v-if="addAssignmentDialog" persistent>
710438de6   Shikha Mishra   added teacher mod...
333
334
335
336
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add Assignment</label>
8e8d14254   Shikha Mishra   Cleared data whil...
337
              <v-icon size="24" class="right" @click="closeAddAssignmentModel">cancel</v-icon>
710438de6   Shikha Mishra   added teacher mod...
338
339
340
341
342
343
344
345
346
347
348
349
350
351
            </v-flex>
          </v-layout>
          <v-container fluid fill-height>
            <v-layout align-center>
              <v-flex xs12>
                <v-form ref="form" v-model="valid" lazy-validation>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Title :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-text-field
                        name="name"
                        type="text"
8888e892f   Amber Dev   added label changes
352
                        placeholder="Select Title"
710438de6   Shikha Mishra   added teacher mod...
353
354
355
356
357
358
359
360
361
362
363
364
365
366
                        :rules="titleRules"
                        v-model="addAssignment.title"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Description :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-text-field
                        name="name"
                        type="text"
8888e892f   Amber Dev   added label changes
367
                        placeholder="Select Description"
710438de6   Shikha Mishra   added teacher mod...
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
                        :rules="descriptionRules"
                        v-model="addAssignment.description"
                        required
                      ></v-text-field>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Deadline :</label>
                    </v-flex>
                    <v-flex xs8 sm7 class="ml-3">
                      <v-menu
                        ref="menu2"
                        :close-on-content-click="false"
                        v-model="menu2"
                        :nudge-right="40"
                        :return-value.sync="addAssignment.date"
                        lazy
                        transition="scale-transition"
                        offset-y
                        full-width
                        min-width="290px"
                      >
                        <v-text-field
                          slot="activator"
                          v-model="addAssignment.deadline"
                          :rules="deadlineRules"
8888e892f   Amber Dev   added label changes
395
                          placeholder="Select Date"
710438de6   Shikha Mishra   added teacher mod...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
                          append-icon="event"
                          readonly
                        ></v-text-field>
                        <v-date-picker
                          v-model="addAssignment.deadline"
                          @input="$refs.menu2.save(addAssignment.date)"
                        ></v-date-picker>
                      </v-menu>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Class :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-select
                        :items="classList"
8888e892f   Amber Dev   added label changes
413
                        placeholder="Select Class"
710438de6   Shikha Mishra   added teacher mod...
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
                        item-text="classNum"
                        item-value="_id"
                        v-model="addAssignment.classId"
                        name="Select Class"
                        :rules="classRules"
                        @change="getSections(addAssignment.classId)"
                        class="pl-2"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 sm4 class="pt-4 subheading">
                      <label class="right">Section :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-3">
                      <v-select
                        :items="addSection"
8888e892f   Amber Dev   added label changes
432
                        placeholder="Select Section"
710438de6   Shikha Mishra   added teacher mod...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
                        item-text="name"
                        item-value="_id"
                        v-model="addAssignment.sectionId"
                        name="Select Section"
                        :rules="sectionRules"
                        @change="getClassSubject(addAssignment.classId)"
                        class="px-2"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs3 sm4 class="pt-4 subheading">
                      <label class="right">Subject :</label>
                    </v-flex>
                    <v-flex xs8 sm8 class="ml-2">
                      <v-select
                        :items="subjectList.subjects"
8888e892f   Amber Dev   added label changes
451
                        placeholder="Select your subject"
710438de6   Shikha Mishra   added teacher mod...
452
453
454
455
456
457
458
459
460
461
                        v-model="addAssignment.subjectName"
                        item-text="subjectName"
                        item-value="_id"
                        :rules="subjectRules"
                        required
                      ></v-select>
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs4 class="pt-4 subheading">
fa4edf929   Shikha Mishra   added option of u...
462
463
                      <label class="right hidden-xs-only hidden-sm-only">Uplaod File:</label>
                      <label class="right hidden-lg-only hidden-md-only hidden-xl-only">File:</label>
710438de6   Shikha Mishra   added teacher mod...
464
                    </v-flex>
fa4edf929   Shikha Mishra   added option of u...
465
                    <v-flex xs8 class="ml-3">
710438de6   Shikha Mishra   added teacher mod...
466
                      <v-text-field
8888e892f   Amber Dev   added label changes
467
                        placeholder="Select File"
710438de6   Shikha Mishra   added teacher mod...
468
                        @click="pickFile"
5ceb88b44   Shikha Mishra   added pdf option ...
469
                        v-model="imageName"
710438de6   Shikha Mishra   added teacher mod...
470
471
472
473
474
475
476
477
478
479
480
481
482
483
                        append-icon="attach_file"
                      ></v-text-field>
                      <input
                        type="file"
                        style="display:none"
                        ref="image"
                        accept="image/*"
                        @change="onFilePicked"
                      />
                    </v-flex>
                  </v-layout>
                  <v-layout>
                    <v-flex xs12 sm12>
                      <v-card-actions>
710438de6   Shikha Mishra   added teacher mod...
484
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
                        <v-spacer></v-spacer>
                        <v-btn
                          @click="submit"
                          round
                          dark
                          :loading="loading"
                          class="add-button"
                        >Add Assignment</v-btn>
                      </v-card-actions>
                    </v-flex>
                  </v-layout>
                </v-form>
              </v-flex>
            </v-layout>
          </v-container>
        </v-card>
      </v-dialog>
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
    </v-container>
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import Util from "@/util";
  import moment from "moment";
fa4edf929   Shikha Mishra   added option of u...
511
  import jsPDF from "jspdf";
d5fcb1cd1   Shikha Mishra   issues resolved
512
  import { saveAs } from "file-saver";
710438de6   Shikha Mishra   added teacher mod...
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
  export default {
    data: () => ({
      snackbar: false,
      role: "",
      menu1: false,
      menu2: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
      color: "",
      show: true,
      showSearch: false,
      showLoader: false,
      loading: false,
      editLoading: false,
      date: null,
      search: "",
      viewAssignmentDialog: false,
      editAssignmentDialog: false,
      valid: true,
      validEditAssignment: true,
      addAssignmentDialog: false,
fa4edf929   Shikha Mishra   added option of u...
537

710438de6   Shikha Mishra   added teacher mod...
538
      pagination: {
b0e0491ab   Shikha Mishra   solve the issue o...
539
        rowsPerPage: 10,
710438de6   Shikha Mishra   added teacher mod...
540
541
542
543
544
545
546
      },
      token: "",
      headers: [
        {
          text: "No",
          align: "",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
547
          value: "No",
710438de6   Shikha Mishra   added teacher mod...
548
549
550
551
552
        },
        {
          text: "Title",
          value: "title",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
553
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
554
555
556
557
558
        },
        {
          text: "Description",
          value: "description",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
559
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
560
561
562
563
564
        },
        {
          text: "Deadline",
          value: "deadline",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
565
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
566
567
568
569
570
        },
        {
          text: "Section",
          value: "name",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
571
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
572
573
574
575
576
        },
        {
          text: "Uploader",
          value: "name",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
577
          align: "center",
710438de6   Shikha Mishra   added teacher mod...
578
        },
5ceb88b44   Shikha Mishra   added pdf option ...
579
580
581
582
        {
          text: "File",
          value: "file",
          sortable: false,
b0e0491ab   Shikha Mishra   solve the issue o...
583
          align: "center",
5ceb88b44   Shikha Mishra   added pdf option ...
584
        },
b0e0491ab   Shikha Mishra   solve the issue o...
585
        { text: "Action", value: "", sortable: false, align: "center" },
710438de6   Shikha Mishra   added teacher mod...
586
      ],
fa4edf929   Shikha Mishra   added option of u...
587
588
589
590
  
      showPdfData: false,
      loadingPdf: false,
      hideData: true,
710438de6   Shikha Mishra   added teacher mod...
591
592
593
594
595
596
597
598
599
600
601
602
603
604
      assignmentData: [],
      subjectList: [],
      classList: [],
      addSection: [],
      editedIndex: -1,
      addSubject: {},
  
      editedItem: {
        title: "",
        description: "",
        deadline: "",
        classId: "",
        sectionId: "",
        subjectName: "",
b0e0491ab   Shikha Mishra   solve the issue o...
605
        fileType: "",
710438de6   Shikha Mishra   added teacher mod...
606
607
      },
      addAssignment: {},
b039d39fb   Shikha Mishra   Hide Edit functio...
608
      showAssignment: {},
5ceb88b44   Shikha Mishra   added pdf option ...
609

710438de6   Shikha Mishra   added teacher mod...
610
611
612
613
      imageData: {},
      imageName: "",
      imageUrl: "",
      imageFile: "",
b0e0491ab   Shikha Mishra   solve the issue o...
614
615
616
617
618
619
620
      titleRules: [(v) => !!v || " Title is required"],
      descriptionRules: [(v) => !!v || " Description is required"],
      deadlineRules: [(v) => !!v || " Deadline is required"],
      classRules: [(v) => !!v || "Class is required"],
      sectionRules: [(v) => !!v || "Section is required"],
      subjectRules: [(v) => !!v || "Student is required"],
      fileRules: [(v) => !!v || "File is required"],
710438de6   Shikha Mishra   added teacher mod...
621
    }),
8e8d14254   Shikha Mishra   Cleared data whil...
622
623
624
625
626
627
628
629
    watch: {
      addAssignmentDialog: function (val) {
        if (!val) {
          this.addAssignment = [];
          this.imageName = "";
        }
      },
    },
710438de6   Shikha Mishra   added teacher mod...
630
    methods: {
b0e0491ab   Shikha Mishra   solve the issue o...
631
      dates: function (date) {
710438de6   Shikha Mishra   added teacher mod...
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
        return moment(date).format("MMMM DD, YYYY");
      },
      pickFile() {
        this.$refs.image.click();
      },
      editItem(item) {
        this.editedIndex = this.assignmentData;
        this.editedItem = Object.assign({}, item);
        this.dialog = true;
        this.editAssignmentDialog = true;
      },
      profile(item) {
        this.editedIndex = this.assignmentData;
        this.editedItem = Object.assign({}, item);
        this.dialog1 = true;
        this.viewAssignmentDialog = true;
      },
      deleteItem(item) {
        let deleteAssignment = {
b0e0491ab   Shikha Mishra   solve the issue o...
651
          assignmentId: item._id,
710438de6   Shikha Mishra   added teacher mod...
652
653
654
655
656
        };
        http()
          .delete(
            "/deleteAssignment",
            confirm("Are you sure you want to delete this?") && {
b0e0491ab   Shikha Mishra   solve the issue o...
657
              params: deleteAssignment,
710438de6   Shikha Mishra   added teacher mod...
658
659
            },
            {
b0e0491ab   Shikha Mishra   solve the issue o...
660
              headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
661
662
            }
          )
b0e0491ab   Shikha Mishra   solve the issue o...
663
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
664
665
666
667
668
            this.getAssignmentList();
            this.snackbar = true;
            this.text = "Successfully delete Existing Assignment";
            this.color = "green";
          })
b0e0491ab   Shikha Mishra   solve the issue o...
669
          .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
670
671
672
673
674
675
676
677
678
679
680
            this.snackbar = true;
            this.text = error.response.data.message;
            this.color = "error";
          });
      },
      close() {
        this.editAssignmentDialog = false;
      },
      close1() {
        this.viewAssignmentDialog = false;
      },
8e8d14254   Shikha Mishra   Cleared data whil...
681
682
      closeAddAssignmentModel() {
        this.addAssignmentDialog = false;
01a4a5246   Shikha Mishra   When the modal wa...
683
        //   this.assignmentData = [];
8e8d14254   Shikha Mishra   Cleared data whil...
684
685
686
        this.addAssignment = [];
        this.imageName = "";
      },
710438de6   Shikha Mishra   added teacher mod...
687
688
689
690
691
692
693
694
      submit() {
        var addAssignment = {
          title: this.addAssignment.title,
          description: this.addAssignment.description,
          deadline: this.addAssignment.deadline,
          classId: this.addAssignment.classId,
          sectionId: this.addAssignment.sectionId,
          subjectName: this.addAssignment.subjectName,
ef672f260   Neeraj Sharma   add file name in ...
695
          file: this.addAssignment.imageName,
b0e0491ab   Shikha Mishra   solve the issue o...
696
          fileName: this.imageName,
710438de6   Shikha Mishra   added teacher mod...
697
        };
fa4edf929   Shikha Mishra   added option of u...
698
        var signatures = {
d5fcb1cd1   Shikha Mishra   issues resolved
699
700
701
          JVBERi0: "other",
          iVBORw0KGgo: "image",
          UEsDBBQ: "other",
fa4edf929   Shikha Mishra   added option of u...
702
          "/": "image",
d5fcb1cd1   Shikha Mishra   issues resolved
703
704
          AAABAA: "image",
          IywiV2hhdC: "other",
b0e0491ab   Shikha Mishra   solve the issue o...
705
          bmFtZSxl: "other",
fa4edf929   Shikha Mishra   added option of u...
706
707
708
709
710
711
712
713
        };
        function detectMimeType(b64) {
          for (var s in signatures) {
            if (b64.indexOf(s) === 0) {
              return signatures[s];
            }
          }
        }
710438de6   Shikha Mishra   added teacher mod...
714
        if (this.$refs.form.validate()) {
fa4edf929   Shikha Mishra   added option of u...
715
716
717
718
719
720
          if (this.imageUrl) {
            var str = this.imageUrl;
            const [baseUrl, imageUrl] = str.split(/,/);
            addAssignment.upload = imageUrl;
            addAssignment.fileType = detectMimeType(imageUrl);
          }
ab4a9d6ee   Shikha Mishra   file name issue s...
721
          // console.log("data===>", addAssignment);
710438de6   Shikha Mishra   added teacher mod...
722
723
          http()
            .post("/createAssignment", addAssignment)
b0e0491ab   Shikha Mishra   solve the issue o...
724
            .then((response) => {
ef672f260   Neeraj Sharma   add file name in ...
725
              this.getAssignmentList();
710438de6   Shikha Mishra   added teacher mod...
726
              this.snackbar = true;
ab4a9d6ee   Shikha Mishra   file name issue s...
727
              this.text = "Assignment added successfully";
710438de6   Shikha Mishra   added teacher mod...
728
729
              this.color = "green";
              this.addAssignmentDialog = false;
ef672f260   Neeraj Sharma   add file name in ...
730
              this.clear();
710438de6   Shikha Mishra   added teacher mod...
731
            })
b0e0491ab   Shikha Mishra   solve the issue o...
732
            .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
733
734
735
736
737
738
739
740
              // console.log(error);
              this.snackbar = true;
              this.text = error.response.data.message;
              this.color = "red";
            });
        }
      },
      getAssignmentList() {
ef672f260   Neeraj Sharma   add file name in ...
741
742
743
        if (this.addAssignment.classId) {
          this.addAssignment.classId = this.addAssignment.classId;
        }
710438de6   Shikha Mishra   added teacher mod...
744
745
746
747
748
        this.showLoader = true;
        http()
          .get(
            "/getAssignmentList",
            {
b0e0491ab   Shikha Mishra   solve the issue o...
749
              params: { classId: this.showAssignment.classId },
710438de6   Shikha Mishra   added teacher mod...
750
751
            },
            {
b0e0491ab   Shikha Mishra   solve the issue o...
752
              headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
753
754
            }
          )
b0e0491ab   Shikha Mishra   solve the issue o...
755
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
756
757
758
759
            this.assignmentData = response.data.data;
            this.showLoader = false;
            this.loadingSearch = false;
          })
b0e0491ab   Shikha Mishra   solve the issue o...
760
          .catch((error) => {
fa4edf929   Shikha Mishra   added option of u...
761
            // console.log("err====>", err);
710438de6   Shikha Mishra   added teacher mod...
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
            this.showLoader = false;
            this.loadingSearch = false;
            this.snackbar = true;
            this.text = error.response.data.message;
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
      clear() {
        this.$refs.form.reset();
      },
      save() {
        if (this.$refs.formEditAssignment.validate()) {
          let editAssignment = {
            assignmentId: this.editedItem._id,
            title: this.addAssignment.title,
            description: this.addAssignment.description,
            deadline: this.addAssignment.deadline,
            classId: this.addAssignment.classId,
            sectionId: this.addAssignment.sectionId,
            subjectName: this.addAssignment.subjectName,
ef672f260   Neeraj Sharma   add file name in ...
786
            file: this.addAssignment.imageName,
b0e0491ab   Shikha Mishra   solve the issue o...
787
            fileName: this.imageName,
710438de6   Shikha Mishra   added teacher mod...
788
789
          };
          this.editLoading = true;
fa4edf929   Shikha Mishra   added option of u...
790
          var signatures = {
d5fcb1cd1   Shikha Mishra   issues resolved
791
792
793
            JVBERi0: "other",
            iVBORw0KGgo: "image",
            UEsDBBQ: "other",
fa4edf929   Shikha Mishra   added option of u...
794
            "/": "image",
d5fcb1cd1   Shikha Mishra   issues resolved
795
796
            AAABAA: "image",
            IywiV2hhdC: "other",
b0e0491ab   Shikha Mishra   solve the issue o...
797
            bmFtZSxl: "other",
fa4edf929   Shikha Mishra   added option of u...
798
799
800
801
802
803
804
805
806
807
808
809
810
811
          };
          function detectMimeType(b64) {
            for (var s in signatures) {
              if (b64.indexOf(s) === 0) {
                return signatures[s];
              }
            }
          }
          if (this.imageUrl) {
            var str = this.imageUrl;
            const [baseUrl, imageUrl] = str.split(/,/);
            editAssignment.upload = imageUrl;
            editAssignment.fileType = detectMimeType(imageUrl);
          }
710438de6   Shikha Mishra   added teacher mod...
812
813
          http()
            .put("/updateAssignment", editAssignment)
b0e0491ab   Shikha Mishra   solve the issue o...
814
            .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
815
816
817
              this.snackbar = true;
              this.text = "Successfully Edit Existing Assignment";
              this.color = "green";
b0e0491ab   Shikha Mishra   solve the issue o...
818
              this.getAssignmentList();
710438de6   Shikha Mishra   added teacher mod...
819
820
              this.editLoading = false;
              this.editAssignmentDialog = false;
710438de6   Shikha Mishra   added teacher mod...
821
            })
b0e0491ab   Shikha Mishra   solve the issue o...
822
            .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
823
824
825
826
827
828
829
830
              this.editLoading = false;
              // console.log(error);
            });
        }
      },
      getClass() {
        http()
          .get("/getClassesList", {
b0e0491ab   Shikha Mishra   solve the issue o...
831
            headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
832
          })
b0e0491ab   Shikha Mishra   solve the issue o...
833
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
834
835
            this.classList = response.data.data;
          })
b0e0491ab   Shikha Mishra   solve the issue o...
836
          .catch((error) => {
710438de6   Shikha Mishra   added teacher mod...
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
          });
      },
      getSections(_id) {
        var token = this.$store.state.token;
        this.showLoader = true;
        http()
          .get(
            "/getSectionsList",
            { params: { classId: _id } },
            {
b0e0491ab   Shikha Mishra   solve the issue o...
852
              headers: { Authorization: "Bearer " + token },
710438de6   Shikha Mishra   added teacher mod...
853
854
            }
          )
b0e0491ab   Shikha Mishra   solve the issue o...
855
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
856
857
858
            this.addSection = response.data.data;
            this.showLoader = false;
          })
b0e0491ab   Shikha Mishra   solve the issue o...
859
          .catch((err) => {
710438de6   Shikha Mishra   added teacher mod...
860
861
862
863
864
865
866
867
868
869
870
            this.showLoader = false;
          });
      },
      getClassSubject(_id) {
        this.showLoader = true;
        //   this.classId = this.classId;
        http()
          .get(
            "/getParticularClass",
            { params: { classId: _id } },
            {
b0e0491ab   Shikha Mishra   solve the issue o...
871
              headers: { Authorization: "Bearer " + this.token },
710438de6   Shikha Mishra   added teacher mod...
872
873
            }
          )
b0e0491ab   Shikha Mishra   solve the issue o...
874
          .then((response) => {
710438de6   Shikha Mishra   added teacher mod...
875
876
877
            this.subjectList = response.data.data;
            this.showLoader = false;
          })
b0e0491ab   Shikha Mishra   solve the issue o...
878
          .catch((err) => {
710438de6   Shikha Mishra   added teacher mod...
879
880
881
882
            this.showLoader = false;
          });
      },
      onFilePicked(e) {
710438de6   Shikha Mishra   added teacher mod...
883
884
        const files = e.target.files;
        this.upload = e.target.files[0];
710438de6   Shikha Mishra   added teacher mod...
885
886
887
888
889
890
891
892
893
894
        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...
d5fcb1cd1   Shikha Mishra   issues resolved
895
            this.imageData.imageUrl = URL.createObjectURL(this.imageFile);
710438de6   Shikha Mishra   added teacher mod...
896
          });
b0e0491ab   Shikha Mishra   solve the issue o...
897
          // console.log("this.imageName", this.imageName);
710438de6   Shikha Mishra   added teacher mod...
898
899
900
901
902
903
904
905
906
907
908
909
910
        } else {
          this.imageName = "";
          this.imageFile = "";
          this.imageUrl = "";
        }
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
fa4edf929   Shikha Mishra   added option of u...
911
      },
d5fcb1cd1   Shikha Mishra   issues resolved
912
913
914
915
916
917
918
919
      async generatePDF2Canvas(item) {
        var dataType = "";
        var type = "";
        if (item.fileType == "image") {
          dataType = "file.jpg";
        } else if (item.fileType == "other") {
          dataType = "file.pdf";
          type = "application/pdf";
fa4edf929   Shikha Mishra   added option of u...
920
        }
d5fcb1cd1   Shikha Mishra   issues resolved
921
922
        var FileSaver = require("file-saver");
        FileSaver.saveAs(item.file, "image.jpg");
b0e0491ab   Shikha Mishra   solve the issue o...
923
      },
710438de6   Shikha Mishra   added teacher mod...
924
925
926
927
    },
    mounted() {
      this.token = this.$store.state.token;
      this.role = this.$store.state.role;
710438de6   Shikha Mishra   added teacher mod...
928
      this.getClass();
b0e0491ab   Shikha Mishra   solve the issue o...
929
    },
710438de6   Shikha Mishra   added teacher mod...
930
  };
25766f5a4   Shikha Mishra   make filename vie...
931
932
933
934
935
936
937
938
  </script>
  
  <style scoped>
  a:hover :hover {
    text-decoration: underline !important;
    color: blue;
  }
  </style>