Blame view

src/pages/Library/eBook.vue 22.4 KB
687e0b929   Neeraj Sharma   add user,attenden...
1
  <template>
68d742034   Neeraj Sharma   implement new des...
2
3
    <v-container fluid class="body-color">
      <!-- ****** EDITS EBOOK DETAILS ****** -->
710438de6   Shikha Mishra   added teacher mod...
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
      <v-dialog v-model="editEbookDialog" max-width="600px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Edit E-Book</label>
              <v-icon size="24" class="right" @click="editEbookDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-card-text>
            <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center mr-4">
              <input
                type="file"
                style="display: none"
                ref="image"
                accept="image/*"
                multiple
                @change="onImagePicked"
              />
              <v-layout justify-center>
                <v-flex v-if="files != ''">
                  <img :src="files" height="200" width="160;" />
                </v-flex>
              </v-layout>
              <img
                v-if="editedItem.coverPhotoUrl && files == '' "
                :src="editedItem.coverPhotoUrl"
                height="200"
                width="160"
                alt="eBooks"
                class="pa-2"
              />
              <v-layout justify-center>
                <v-flex
                  xs3
                  v-for="Image in editedItem.newsImageUrl"
                  :key="Image._id"
                  class="profile-image-wrapper"
                >
                  <v-icon
                    class="red edit-profile-icon"
                    dark
                    @click="deleteImage(Image._id,editedItem._id)"
                  >close</v-icon>
                </v-flex>
                <v-flex v-for="(file, index) in files" :key="index">
                  <img :src="file" height="160" width="160" class="pa-2" />
                </v-flex>
              </v-layout>
              <img
                src="/static/icon/user.png"
                v-if="editedItem.coverPhotoUrl == ''"
                height="160"
                width="160"
                alt="Books"
              />
            </v-flex>
            <v-container grid-list-md>
              <v-flex xs12 sm6>
68d742034   Neeraj Sharma   implement new des...
62
                <v-layout>
710438de6   Shikha Mishra   added teacher mod...
63
64
65
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Name :</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Name :</label>
68d742034   Neeraj Sharma   implement new des...
66
                  </v-flex>
710438de6   Shikha Mishra   added teacher mod...
67
68
69
70
71
72
73
74
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      v-model="editedItem.name"
                      placeholder="fill your full Name"
                      name="name"
                      type="text"
                      required
                    ></v-text-field>
68d742034   Neeraj Sharma   implement new des...
75
                  </v-flex>
710438de6   Shikha Mishra   added teacher mod...
76
77
78
79
80
81
82
                </v-layout>
              </v-flex>
              <v-flex xs12 sm6>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Author :</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Author :</label>
68d742034   Neeraj Sharma   implement new des...
83
                  </v-flex>
710438de6   Shikha Mishra   added teacher mod...
84
85
86
87
88
89
90
91
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      v-model="editedItem.author"
                      placeholder="fill your full author"
                      name="name"
                      type="text"
                      required
                    ></v-text-field>
68d742034   Neeraj Sharma   implement new des...
92
93
                  </v-flex>
                </v-layout>
710438de6   Shikha Mishra   added teacher mod...
94
95
              </v-flex>
              <v-flex xs12 sm6>
68d742034   Neeraj Sharma   implement new des...
96
                <v-layout>
710438de6   Shikha Mishra   added teacher mod...
97
98
99
100
101
102
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Class :</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Class :</label>
                  </v-flex>
                  <v-flex xs8 class="ml-3">
                    <v-text-field
7281a47c4   Shikha Mishra   show class name a...
103
                      v-model="editedItem.classId.classNum"
710438de6   Shikha Mishra   added teacher mod...
104
105
106
107
108
                      placeholder="fill your full class"
                      name="classNum"
                      type="_id"
                      required
                    ></v-text-field>
68d742034   Neeraj Sharma   implement new des...
109
110
                  </v-flex>
                </v-layout>
710438de6   Shikha Mishra   added teacher mod...
111
112
              </v-flex>
            </v-container>
68d742034   Neeraj Sharma   implement new des...
113
114
115
116
117
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** PROFILE VIEW ALL NEWS DEATILS ******  -->
710438de6   Shikha Mishra   added teacher mod...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
      <v-dialog v-model="viewEbookDialog" max-width="800px" scrollable>
        <v-card flat class="card-style pa-3" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">View E-book Details</label>
              <v-icon size="24" class="right" @click="viewEbookDialog = false">cancel</v-icon>
            </v-flex>
          </v-layout>
          <v-layout>
            <v-flex align-center justify-center layout text-xs-center class="mt-3">
              <v-avatar size="100px">
                <img src="/static/icon/user.png" v-if="!editedItem.fileUrl" />
                <img :src="editedItem.fileUrl" v-else-if="editedItem.fileUrl" />
              </v-avatar>
            </v-flex>
          </v-layout>
          <v-container grid-list-md>
            <v-layout wrap>
              <v-flex xs12 sm5>
                <v-layout>
                  <v-flex xs6 sm6>
                    <h5 class="right my-1">
                      <b>Name:</b>
                    </h5>
                  </v-flex>
                  <v-flex sm6 xs6>
                    <h5 class="my-1 left">{{ editedItem.name }}</h5>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm7>
                <v-layout>
                  <v-flex xs6 sm4>
                    <h5 class="right my-1">
                      <b>Author:</b>
                    </h5>
                  </v-flex>
                  <v-flex sm8 xs6>
                    <h5 class="my-1 left">{{ editedItem.author }}</h5>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
            <v-layout wrap>
              <v-flex xs12 sm5>
                <v-layout>
                  <v-flex xs6 sm6>
                    <h5 class="right my-1">
                      <b>Class:</b>
                    </h5>
                  </v-flex>
                  <v-flex sm6 xs6>
7281a47c4   Shikha Mishra   show class name a...
170
                    <h5 class="my-1 left">{{ editedItem.classId .classNum}}</h5>
710438de6   Shikha Mishra   added teacher mod...
171
172
173
174
175
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
          </v-container>
68d742034   Neeraj Sharma   implement new des...
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
        </v-card>
      </v-dialog>
      <!-- ****** EXISTING-USERS NEWS 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="addEBookDialog = true"
        >
          <v-icon dark>add</v-icon>
        </v-btn>
        <v-btn
          round
          class="open-dialog-button hidden-sm-only hidden-xs-only"
          dark
          @click="addEBookDialog = true"
        >
          <v-icon class="white--text pr-1" size="20">add</v-icon>Add E-Book
        </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...
202
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
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
            </v-avatar>
          </v-btn>
        </v-card-title>
        <v-flex xs8 sm8 md3 lg2 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="eBookData"
        :pagination.sync="pagination"
        :search="search"
      >
        <template slot="items" slot-scope="props">
          <tr class="tr">
            <td class="td td-row">{{ props.index + 1}}</td>
            <td class="td td-row text-xs-center">
              <img :src="props.item.coverPhotoUrl" alt="newsImage" width="100" height="70" />
            </td>
            <td class="td td-row text-xs-center">{{ props.item.name}}</td>
            <td class="td td-row text-xs-center">{{ props.item.author}}</td>
            <td class="td td-row text-xs-center">{{ props.item.classId.classNum}}</td>
            <td class="td td-row text-xs-center">
              <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...
236
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
237
238
239
240
241
242
243
244
245
                  />
                  <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...
246
                    src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
247
248
249
250
251
252
253
254
                  />
                  <span>Edit</span>
                </v-tooltip>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:20px; "
                    @click="deleteItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
255
                    src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
                  />
                  <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 E-BOOK ****** -->
      <v-dialog v-model="addEBookDialog" max-width="600px">
        <v-card flat class="card-style pa-2" dark>
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add E-Book</label>
              <v-icon size="24" class="right" @click="addEBookDialog = false">cancel</v-icon>
687e0b929   Neeraj Sharma   add user,attenden...
277
            </v-flex>
68d742034   Neeraj Sharma   implement new des...
278
279
280
281
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-layout>
710438de6   Shikha Mishra   added teacher mod...
282
                <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center">
68d742034   Neeraj Sharma   implement new des...
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
                  <input
                    type="file"
                    style="display: none"
                    ref="image"
                    accept="image/*"
                    @change="onImagePicked"
                  />
                  <v-layout justify-center>
                    <v-flex v-if="files != ''">
                      <img :src="files" height="150" width="150" />
                    </v-flex>
                  </v-layout>
                  <img src="/static/icon/user.png" v-if="files ==''" height="80" width="80px;" />
                </v-flex>
              </v-layout>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Name:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-text-field
                      v-model="addEBooks.name"
710438de6   Shikha Mishra   added teacher mod...
306
                      placeholder="fill name"
68d742034   Neeraj Sharma   implement new des...
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
                      name="name"
                      type="text"
                      :rules="titleRules"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Author:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-text-field
                      v-model="addEBooks.author"
                      placeholder="fill your Author Name"
                      name="name"
                      type="text"
                      :rules="titleRules"
                      required
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Class:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-select
                      v-model="addEBooks.classId"
                      :items="addClass"
                      label="Select Class"
                      item-text="classNum"
                      item-value="_id"
                      :rules="titleRules"
                      required
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Upload Image:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-text-field
                      label="Select Image"
                      @click="pickImage"
710438de6   Shikha Mishra   added teacher mod...
359
                      v-model="addEBooks.uploadCover"
68d742034   Neeraj Sharma   implement new des...
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
                      append-icon="attach_file"
                      multiple
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right">Upload File:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <input type="file" style="display: none" ref="file" @change="onFilePicked" />
                    <v-text-field
                      label="Select File"
                      @click="pickFile"
710438de6   Shikha Mishra   added teacher mod...
376
                      v-model="addEBooks.uploadFile"
68d742034   Neeraj Sharma   implement new des...
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
                      append-icon="attach_file"
                      multiple
                    ></v-text-field>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12>
                <v-layout>
                  <v-flex xs4 class="pt-3 subheading">
                    <label class="right">Private:</label>
                  </v-flex>
                  <v-flex xs7 class="ml-3">
                    <v-checkbox v-model="addEBooks.private"></v-checkbox>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-layout>
                <v-flex xs12>
                  <v-card-actions>
                    <v-spacer></v-spacer>
                    <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-card-actions>
                </v-flex>
              </v-layout>
            </v-container>
          </v-form>
        </v-card>
      </v-dialog>
687e0b929   Neeraj Sharma   add user,attenden...
406
407
408
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
409
    </v-container>
687e0b929   Neeraj Sharma   add user,attenden...
410
411
412
413
414
415
416
417
418
419
420
421
422
423
  </template>
  
  <script>
  import http from "@/Services/http.js";
  import Util from "@/util";
  
  export default {
    data: () => ({
      snackbar: false,
      y: "top",
      x: "right",
      mode: "",
      timeout: 3000,
      text: "",
68d742034   Neeraj Sharma   implement new des...
424
425
      show: true,
      showSearch: false,
687e0b929   Neeraj Sharma   add user,attenden...
426
      loading: false,
6c05a9f84   Neeraj Sharma   add functionalit ...
427
      loadingUpadte: false,
687e0b929   Neeraj Sharma   add user,attenden...
428
429
430
      date: null,
      search: "",
      showLoader: false,
710438de6   Shikha Mishra   added teacher mod...
431
432
      editEbookDialog: false,
      viewEbookDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
433
      valid: true,
68d742034   Neeraj Sharma   implement new des...
434
      addEBookDialog: false,
ab54b5656   Neeraj Sharma   implement library...
435
      addClass: [],
687e0b929   Neeraj Sharma   add user,attenden...
436
      addSection: [],
687e0b929   Neeraj Sharma   add user,attenden...
437
      pagination: {
68d742034   Neeraj Sharma   implement new des...
438
        rowsPerPage: 10
687e0b929   Neeraj Sharma   add user,attenden...
439
440
      },
      imageName: "",
ab54b5656   Neeraj Sharma   implement library...
441
      fileName: "",
687e0b929   Neeraj Sharma   add user,attenden...
442
443
444
445
      imageUrl: "",
      imageFile: "",
      image: [],
      upload: "",
ab54b5656   Neeraj Sharma   implement library...
446
447
      files: "",
      anyFile: "",
687e0b929   Neeraj Sharma   add user,attenden...
448
449
450
451
452
453
454
455
456
      titleRules: [v => !!v || " Tilte is required"],
      descriptionRules: [v => !!v || " Description is required"],
      headers: [
        {
          align: "justify-center",
          text: "No",
          sortable: false,
          value: "No"
        },
ab54b5656   Neeraj Sharma   implement library...
457
458
459
        { text: "Photo", vaue: "fileUrl", sortable: false, align: "center" },
        { text: "Name", vaue: "name", sortable: false, align: "center" },
        { text: "Author", value: "author", sortable: false, align: "center" },
687e0b929   Neeraj Sharma   add user,attenden...
460
        {
ab54b5656   Neeraj Sharma   implement library...
461
462
          text: "Class",
          value: "classId",
687e0b929   Neeraj Sharma   add user,attenden...
463
464
465
466
467
          sortable: false,
          align: "center"
        },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
ab54b5656   Neeraj Sharma   implement library...
468
      eBookData: [],
687e0b929   Neeraj Sharma   add user,attenden...
469
      editedIndex: -1,
ab54b5656   Neeraj Sharma   implement library...
470
471
472
473
      addEBooks: {
        private: false
      },
      editedItem: {},
d5fcb1cd1   Shikha Mishra   issues resolved
474
475
476
477
478
      editedItem: {
        classId: {
          classNum: ""
        }
      },
710438de6   Shikha Mishra   added teacher mod...
479
480
      token: "",
      uploadCover: {}
687e0b929   Neeraj Sharma   add user,attenden...
481
482
    }),
    methods: {
ab54b5656   Neeraj Sharma   implement library...
483
      pickImage() {
687e0b929   Neeraj Sharma   add user,attenden...
484
485
        this.$refs.image.click();
      },
ab54b5656   Neeraj Sharma   implement library...
486
487
488
489
      pickFile() {
        this.$refs.file.click();
      },
      onImagePicked(e) {
687e0b929   Neeraj Sharma   add user,attenden...
490
491
492
493
494
495
496
497
        // console.log(e)
        const files = e.target.files;
        /** fetch Image Name **/
        if (files[0] !== undefined) {
          this.imageName = files[0].name;
          if (this.imageName.lastIndexOf(".") <= 0) {
            return;
          }
687e0b929   Neeraj Sharma   add user,attenden...
498
          /** Select many image and showing many image add to news card **/
687e0b929   Neeraj Sharma   add user,attenden...
499
500
501
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
ab54b5656   Neeraj Sharma   implement library...
502
            this.files = fr.result;
687e0b929   Neeraj Sharma   add user,attenden...
503
504
505
506
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
ab54b5656   Neeraj Sharma   implement library...
507
          this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
508
509
510
          this.imageUrl = "";
        }
      },
6c05a9f84   Neeraj Sharma   add functionalit ...
511
      getEBooksList() {
687e0b929   Neeraj Sharma   add user,attenden...
512
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
513
        http()
ab54b5656   Neeraj Sharma   implement library...
514
          .get("/getEBooksList", {
99cd79184   Neeraj Sharma   implement all tas...
515
            params: { schoolId: this.$store.state.schoolId },
ab54b5656   Neeraj Sharma   implement library...
516
            headers: { Authorization: "Bearer " + this.token }
687e0b929   Neeraj Sharma   add user,attenden...
517
518
          })
          .then(response => {
ab54b5656   Neeraj Sharma   implement library...
519
            this.eBookData = response.data.data;
687e0b929   Neeraj Sharma   add user,attenden...
520
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
521
          })
00e4bc4e1   Neeraj Sharma   fixed auntentication
522
          .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
523
524
            // console.log("err====>", err);
            this.showLoader = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
525
526
527
528
529
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
ab54b5656   Neeraj Sharma   implement library...
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
          });
      },
      onFilePicked(e) {
        // console.log(e)
        const files = e.target.files;
        /** fetch Image Name **/
        if (files[0] !== undefined) {
          this.fileName = files[0].name;
          if (this.fileName.lastIndexOf(".") <= 0) {
            return;
          }
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
            this.anyFile = fr.result;
            // console.log(" this.anyFile Url", this.anyFile )
687e0b929   Neeraj Sharma   add user,attenden...
546
          });
ab54b5656   Neeraj Sharma   implement library...
547
548
549
550
        } else {
          this.anyFile = "";
          this.fileName = "";
        }
687e0b929   Neeraj Sharma   add user,attenden...
551
552
553
      },
      editItem(item) {
        this.files = [];
ab54b5656   Neeraj Sharma   implement library...
554
        this.editedIndex = this.eBookData.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
555
        this.editedItem = Object.assign({}, item);
6c05a9f84   Neeraj Sharma   add functionalit ...
556
        this.editedItem.className = item.classId.classNum;
710438de6   Shikha Mishra   added teacher mod...
557
        this.editEbookDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
558
559
      },
      profile(item) {
ab54b5656   Neeraj Sharma   implement library...
560
        this.editedIndex = this.eBookData.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
561
        this.editedItem = Object.assign({}, item);
710438de6   Shikha Mishra   added teacher mod...
562
        this.viewEbookDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
563
564
      },
      deleteItem(item) {
6c05a9f84   Neeraj Sharma   add functionalit ...
565
566
        let deleteEBooks = {
          ebookId: item._id
687e0b929   Neeraj Sharma   add user,attenden...
567
568
569
        };
        http()
          .delete(
6c05a9f84   Neeraj Sharma   add functionalit ...
570
            "/deleteEBook",
687e0b929   Neeraj Sharma   add user,attenden...
571
            confirm("Are you sure you want to delete this?") && {
6c05a9f84   Neeraj Sharma   add functionalit ...
572
              params: deleteEBooks
687e0b929   Neeraj Sharma   add user,attenden...
573
574
575
            }
          )
          .then(response => {
6c05a9f84   Neeraj Sharma   add functionalit ...
576
577
578
            this.snackbar = true;
            this.text = "Successfully delete Existing News";
            this.getEBooksList();
687e0b929   Neeraj Sharma   add user,attenden...
579
580
          })
          .catch(error => {
6c05a9f84   Neeraj Sharma   add functionalit ...
581
582
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
583
584
          });
      },
687e0b929   Neeraj Sharma   add user,attenden...
585
      close() {
710438de6   Shikha Mishra   added teacher mod...
586
        this.editEbookDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
587
588
      },
      close1() {
710438de6   Shikha Mishra   added teacher mod...
589
        this.viewEbookDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
590
591
      },
      submit() {
687e0b929   Neeraj Sharma   add user,attenden...
592
        if (this.$refs.form.validate()) {
687e0b929   Neeraj Sharma   add user,attenden...
593
          if (this.files) {
ab54b5656   Neeraj Sharma   implement library...
594
595
596
597
598
599
600
601
            const [baseUrl, imageUrl] = this.files.split(/,/);
            this.addEBooks.uploadCover = imageUrl;
            // console.log("anyFile.split(/,/)", this.addEBooks.uploadCover);
          }
          if (this.anyFile) {
            const [baseUrl, fileUrl] = this.anyFile.split(/,/);
            this.addEBooks.uploadFile = fileUrl;
            // console.log("anyFile.split(/,/)", this.addEBooks.uploadFile);
687e0b929   Neeraj Sharma   add user,attenden...
602
          }
710438de6   Shikha Mishra   added teacher mod...
603
604
605
606
607
608
609
610
          let data = {
            classId: this.addEBooks.classId,
            name: this.addEBooks.name,
            author: this.addEBooks.author,
            private: this.addEBooks.private,
            uploadCover: this.addEBooks.uploadCover,
            uploadFile: this.addEBooks.uploadFile
          };
687e0b929   Neeraj Sharma   add user,attenden...
611
          http()
710438de6   Shikha Mishra   added teacher mod...
612
            .post("/createEBook", data)
687e0b929   Neeraj Sharma   add user,attenden...
613
            .then(response => {
710438de6   Shikha Mishra   added teacher mod...
614
              this.getEBooksList = [];
6c05a9f84   Neeraj Sharma   add functionalit ...
615
              this.snackbar = true;
68d742034   Neeraj Sharma   implement new des...
616
              this.addEBookDialog = false;
7281a47c4   Shikha Mishra   show class name a...
617
              this.getEBooksList()
710438de6   Shikha Mishra   added teacher mod...
618
619
              this.text = response.data.message;
              this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
620
              this.loading = false;
710438de6   Shikha Mishra   added teacher mod...
621
622
              this.addEBooks.uploadCover = "";
              this.addEBooks.uploadFile = "";
687e0b929   Neeraj Sharma   add user,attenden...
623
624
            })
            .catch(error => {
6c05a9f84   Neeraj Sharma   add functionalit ...
625
626
              this.snackbar = true;
              this.text = error.response.data.message;
710438de6   Shikha Mishra   added teacher mod...
627
              this.color = "red";
687e0b929   Neeraj Sharma   add user,attenden...
628
629
630
631
632
            });
        }
      },
      clear() {
        this.$refs.form.reset();
495e4037c   Neeraj Sharma   update
633
634
        this.addEBooks.uploadCover = "";
        this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
635
636
      },
      save() {
6c05a9f84   Neeraj Sharma   add functionalit ...
637
638
639
640
641
        this.loadingUpadte = true;
        if (this.files.length > 0) {
          const [baseUrl, imageUrl] = this.files.split(/,/);
          this.editedItem.uploadCover = imageUrl;
          // console.log("anyFile.split(/,/)", this.addEBooks.uploadCover);
687e0b929   Neeraj Sharma   add user,attenden...
642
        }
ab54b5656   Neeraj Sharma   implement library...
643
644
        if (this.anyFile) {
          const [baseUrl, fileUrl] = this.anyFile.split(/,/);
6c05a9f84   Neeraj Sharma   add functionalit ...
645
646
          this.editedItem.uploadFile = fileUrl;
          // console.log("anyFile.split(/,/)", this.addEBooks.uploadFile);
ab54b5656   Neeraj Sharma   implement library...
647
        }
6c05a9f84   Neeraj Sharma   add functionalit ...
648
        this.editedItem.ebookId = this.editedItem._id;
687e0b929   Neeraj Sharma   add user,attenden...
649
        http()
6c05a9f84   Neeraj Sharma   add functionalit ...
650
          .put("/updateEBook", this.editedItem)
687e0b929   Neeraj Sharma   add user,attenden...
651
          .then(response => {
6c05a9f84   Neeraj Sharma   add functionalit ...
652
653
654
655
656
657
658
659
            this.loadingUpadte = false;
            this.snackbar = true;
            this.text = "Successfully Edit Existing E-Book";
            this.getEBooksList();
            this.editedItem.uploadFile = "";
            this.editedItem.uploadCover = "";
            this.anyFile = "";
            this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
660
661
662
            this.close();
          })
          .catch(error => {
6c05a9f84   Neeraj Sharma   add functionalit ...
663
664
665
            this.loadingUpadte = false;
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
666
667
            // console.log(error);
          });
ab54b5656   Neeraj Sharma   implement library...
668
669
670
671
672
673
674
675
676
677
678
679
680
      },
      getAllClass() {
        http()
          .get("/getClassesList", {
            headers: { Authorization: "Bearer " + this.token }
          })
          .then(response => {
            this.addClass = response.data.data;
          })
          .catch(err => {
            // console.log("err====>", err);
            // this.$router.replace({ path: "/" });
          });
68d742034   Neeraj Sharma   implement new des...
681
682
683
684
685
686
687
688
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
687e0b929   Neeraj Sharma   add user,attenden...
689
690
691
      }
    },
    mounted() {
ab54b5656   Neeraj Sharma   implement library...
692
      this.token = this.$store.state.token;
6c05a9f84   Neeraj Sharma   add functionalit ...
693
      this.getEBooksList();
ab54b5656   Neeraj Sharma   implement library...
694
      this.getAllClass();
006544386   Neeraj Sharma   implement task
695
      // this.getBookData();
ab54b5656   Neeraj Sharma   implement library...
696
      // this.editItem;
687e0b929   Neeraj Sharma   add user,attenden...
697
698
    }
  };
68d742034   Neeraj Sharma   implement new des...
699
  </script>