Blame view

src/pages/Library/eBook.vue 23.1 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
39
40
41
42
    <v-container fluid class="body-color">
      <!-- ****** EDITS EBOOK DETAILS ****** -->
      <v-dialog v-model="dialog" max-width="1000px" scrollable>
        <v-card flat>
          <v-toolbar class="grey lighten-2" flat>
            <v-spacer></v-spacer>
            <v-toolbar-title>
              <h3>Edit E-Books</h3>
            </v-toolbar-title>
            <v-spacer></v-spacer>
          </v-toolbar>
          <v-card-text style="height:760px;">
            <v-form ref="form">
              <v-container fluid>
                <v-layout row>
                  <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>
687e0b929   Neeraj Sharma   add user,attenden...
43
44
45
46
47
48
49
                          <v-flex
                            xs3
                            v-for="Image in editedItem.newsImageUrl"
                            :key="Image._id"
                            v-if="editedItem.newsImageUrl"
                            class="profile-image-wrapper"
                          >
6c05a9f84   Neeraj Sharma   add functionalit ...
50
                           
687e0b929   Neeraj Sharma   add user,attenden...
51
52
53
54
55
56
57
58
59
                            <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>
68d742034   Neeraj Sharma   implement new des...
60
61
62
63
64
65
66
67
68
69
70
71
                    </v-layout>-->
                    <img
                      src="/static/icon/user.png"
                      v-if="editedItem.coverPhotoUrl == ''"
                      height="160"
                      width="160"
                      alt="Books"
                    />
                  </v-flex>
                </v-layout>
                <v-layout>
                  <v-flex xs12 sm12>
687e0b929   Neeraj Sharma   add user,attenden...
72
                    <v-layout>
68d742034   Neeraj Sharma   implement new des...
73
74
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Name:</label>
687e0b929   Neeraj Sharma   add user,attenden...
75
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
76
77
78
79
80
81
                      <v-flex xs5 class="ml-3">
                        <v-text-field
                          v-model="editedItem.name"
                          placeholder="fill your Name"
                          type="text"
                        ></v-text-field>
6c05a9f84   Neeraj Sharma   add functionalit ...
82
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
83
84
85
86
87
88
                    </v-layout>
                  </v-flex>
                  <v-flex xs12 sm12>
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Author:</label>
687e0b929   Neeraj Sharma   add user,attenden...
89
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
90
91
                      <v-flex xs5 class="ml-3">
                        <v-text-field placeholder="fill your Author" v-model="editedItem.author"></v-text-field>
687e0b929   Neeraj Sharma   add user,attenden...
92
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
93
94
95
96
97
98
                    </v-layout>
                  </v-flex>
                  <v-flex xs12 sm12>
                    <v-layout>
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Class:</label>
6c05a9f84   Neeraj Sharma   add functionalit ...
99
                      </v-flex>
68d742034   Neeraj Sharma   implement new des...
100
101
102
103
104
105
106
107
                      <v-flex xs5 class="ml-3">
                        <v-text-field
                          v-model="editedItem.className"
                          :items="addClass"
                          label="Select Class"
                          item-text="classNum"
                          item-value="_id"
                        ></v-text-field>
6c05a9f84   Neeraj Sharma   add functionalit ...
108
                      </v-flex>
687e0b929   Neeraj Sharma   add user,attenden...
109
                    </v-layout>
68d742034   Neeraj Sharma   implement new des...
110
111
                  </v-flex>
                  <v-flex xs12 sm12>
687e0b929   Neeraj Sharma   add user,attenden...
112
                    <v-layout>
68d742034   Neeraj Sharma   implement new des...
113
114
115
116
117
118
119
120
121
122
123
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Upload Image:</label>
                      </v-flex>
                      <v-flex xs5 class="ml-3">
                        <v-text-field
                          label="Select Image"
                          @click="pickImage"
                          v-model="imageName"
                          append-icon="attach_file"
                          multiple
                        ></v-text-field>
687e0b929   Neeraj Sharma   add user,attenden...
124
125
                      </v-flex>
                    </v-layout>
68d742034   Neeraj Sharma   implement new des...
126
127
                  </v-flex>
                  <v-flex xs12 sm12>
687e0b929   Neeraj Sharma   add user,attenden...
128
                    <v-layout>
68d742034   Neeraj Sharma   implement new des...
129
130
131
132
133
134
135
136
137
138
139
140
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Upload File:</label>
                      </v-flex>
                      <v-flex xs5 class="ml-3">
                        <input type="file" style="display: none" ref="file" @change="onFilePicked" />
                        <v-text-field
                          label="Select File"
                          @click="pickFile"
                          v-model="fileName"
                          append-icon="attach_file"
                          multiple
                        ></v-text-field>
687e0b929   Neeraj Sharma   add user,attenden...
141
142
                      </v-flex>
                    </v-layout>
68d742034   Neeraj Sharma   implement new des...
143
144
                  </v-flex>
                  <v-flex xs12 sm12>
687e0b929   Neeraj Sharma   add user,attenden...
145
                    <v-layout>
68d742034   Neeraj Sharma   implement new des...
146
147
148
149
150
                      <v-flex xs4 class="pt-4 subheading">
                        <label class="right">Private:</label>
                      </v-flex>
                      <v-flex xs5 class="ml-3">
                        <v-checkbox v-model="editedItem.private"></v-checkbox>
687e0b929   Neeraj Sharma   add user,attenden...
151
152
                      </v-flex>
                    </v-layout>
68d742034   Neeraj Sharma   implement new des...
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
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
286
287
288
289
290
291
                  </v-flex>
                </v-layout>
                <v-layout>
                  <v-flex xs12 sm8 offset-sm2>
                    <v-card-actions>
                      <v-btn round dark @click.native="close">Cancel</v-btn>
                      <v-spacer></v-spacer>
                      <v-btn round dark @click="save" :loading="loadingUpadte">Save</v-btn>
                    </v-card-actions>
                  </v-flex>
                </v-layout>
              </v-container>
            </v-form>
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** PROFILE VIEW ALL NEWS DEATILS ******  -->
  
      <v-dialog v-model="dialog1" max-width="800px" scrollable>
        <v-card style="height: 700px;">
          <v-toolbar color="grey lighten-2" flat>
            <v-spacer></v-spacer>
            <v-toolbar-title>
              <h3>E-Books</h3>
            </v-toolbar-title>
            <v-spacer></v-spacer>
            <v-icon @click="close1">close</v-icon>
          </v-toolbar>
          <v-card-text>
            <v-container>
              <v-layout wrap>
                <v-flex sm12 xs12>
                  <iframe :src="editedItem.fileUrl" height="600" width="100%"></iframe>
                </v-flex>
              </v-layout>
            </v-container>
          </v-card-text>
        </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">
              <img src="/static/icon/dashboard icons-49.png" alt="icon" />
            </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)"
                    src="/static/icon/dashboard icons-47.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/dashboard icons-50.png"
                  />
                  <span>Edit</span>
                </v-tooltip>
                <v-tooltip top>
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:20px; "
                    @click="deleteItem(props.item)"
                    src="/static/icon/dashboard icons-51.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 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...
292
            </v-flex>
68d742034   Neeraj Sharma   implement new des...
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
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
          </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"
                >
                  <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"
                      placeholder="fill your Title"
                      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"
                      v-model="imageName"
                      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"
                      v-model="fileName"
                      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...
424
425
426
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
427
    </v-container>
687e0b929   Neeraj Sharma   add user,attenden...
428
429
430
431
432
433
434
435
436
437
438
439
440
441
  </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...
442
443
      show: true,
      showSearch: false,
687e0b929   Neeraj Sharma   add user,attenden...
444
      loading: false,
6c05a9f84   Neeraj Sharma   add functionalit ...
445
      loadingUpadte: false,
687e0b929   Neeraj Sharma   add user,attenden...
446
447
448
449
450
451
      date: null,
      search: "",
      showLoader: false,
      dialog: false,
      dialog1: false,
      valid: true,
68d742034   Neeraj Sharma   implement new des...
452
      addEBookDialog: false,
ab54b5656   Neeraj Sharma   implement library...
453
      addClass: [],
687e0b929   Neeraj Sharma   add user,attenden...
454
      addSection: [],
687e0b929   Neeraj Sharma   add user,attenden...
455
      pagination: {
68d742034   Neeraj Sharma   implement new des...
456
        rowsPerPage: 10
687e0b929   Neeraj Sharma   add user,attenden...
457
458
      },
      imageName: "",
ab54b5656   Neeraj Sharma   implement library...
459
      fileName: "",
687e0b929   Neeraj Sharma   add user,attenden...
460
461
462
463
      imageUrl: "",
      imageFile: "",
      image: [],
      upload: "",
ab54b5656   Neeraj Sharma   implement library...
464
465
      files: "",
      anyFile: "",
687e0b929   Neeraj Sharma   add user,attenden...
466
467
468
469
470
471
472
473
474
      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...
475
476
477
        { 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...
478
        {
ab54b5656   Neeraj Sharma   implement library...
479
480
          text: "Class",
          value: "classId",
687e0b929   Neeraj Sharma   add user,attenden...
481
482
483
484
485
          sortable: false,
          align: "center"
        },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
ab54b5656   Neeraj Sharma   implement library...
486
      eBookData: [],
687e0b929   Neeraj Sharma   add user,attenden...
487
      editedIndex: -1,
ab54b5656   Neeraj Sharma   implement library...
488
489
490
491
492
      addEBooks: {
        private: false
      },
      editedItem: {},
      token: ""
687e0b929   Neeraj Sharma   add user,attenden...
493
494
    }),
    methods: {
ab54b5656   Neeraj Sharma   implement library...
495
      pickImage() {
687e0b929   Neeraj Sharma   add user,attenden...
496
497
        this.$refs.image.click();
      },
ab54b5656   Neeraj Sharma   implement library...
498
499
500
501
      pickFile() {
        this.$refs.file.click();
      },
      onImagePicked(e) {
687e0b929   Neeraj Sharma   add user,attenden...
502
503
504
505
506
507
508
509
        // 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...
510
          /** Select many image and showing many image add to news card **/
687e0b929   Neeraj Sharma   add user,attenden...
511
512
513
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
ab54b5656   Neeraj Sharma   implement library...
514
            this.files = fr.result;
687e0b929   Neeraj Sharma   add user,attenden...
515
516
517
518
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
ab54b5656   Neeraj Sharma   implement library...
519
          this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
520
521
522
          this.imageUrl = "";
        }
      },
6c05a9f84   Neeraj Sharma   add functionalit ...
523
      getEBooksList() {
687e0b929   Neeraj Sharma   add user,attenden...
524
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
525
        http()
ab54b5656   Neeraj Sharma   implement library...
526
          .get("/getEBooksList", {
99cd79184   Neeraj Sharma   implement all tas...
527
            params: { schoolId: this.$store.state.schoolId },
ab54b5656   Neeraj Sharma   implement library...
528
            headers: { Authorization: "Bearer " + this.token }
687e0b929   Neeraj Sharma   add user,attenden...
529
530
          })
          .then(response => {
ab54b5656   Neeraj Sharma   implement library...
531
            this.eBookData = response.data.data;
687e0b929   Neeraj Sharma   add user,attenden...
532
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
533
          })
00e4bc4e1   Neeraj Sharma   fixed auntentication
534
          .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
535
536
            // console.log("err====>", err);
            this.showLoader = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
537
538
539
540
541
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
ab54b5656   Neeraj Sharma   implement library...
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
          });
      },
      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...
558
          });
ab54b5656   Neeraj Sharma   implement library...
559
560
561
562
        } else {
          this.anyFile = "";
          this.fileName = "";
        }
687e0b929   Neeraj Sharma   add user,attenden...
563
564
565
      },
      editItem(item) {
        this.files = [];
ab54b5656   Neeraj Sharma   implement library...
566
        this.editedIndex = this.eBookData.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
567
        this.editedItem = Object.assign({}, item);
6c05a9f84   Neeraj Sharma   add functionalit ...
568
        this.editedItem.className = item.classId.classNum;
687e0b929   Neeraj Sharma   add user,attenden...
569
570
571
        this.dialog = true;
      },
      profile(item) {
ab54b5656   Neeraj Sharma   implement library...
572
        this.editedIndex = this.eBookData.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
573
574
575
576
        this.editedItem = Object.assign({}, item);
        this.dialog1 = true;
      },
      deleteItem(item) {
6c05a9f84   Neeraj Sharma   add functionalit ...
577
578
        let deleteEBooks = {
          ebookId: item._id
687e0b929   Neeraj Sharma   add user,attenden...
579
580
581
        };
        http()
          .delete(
6c05a9f84   Neeraj Sharma   add functionalit ...
582
            "/deleteEBook",
687e0b929   Neeraj Sharma   add user,attenden...
583
            confirm("Are you sure you want to delete this?") && {
6c05a9f84   Neeraj Sharma   add functionalit ...
584
              params: deleteEBooks
687e0b929   Neeraj Sharma   add user,attenden...
585
586
587
            }
          )
          .then(response => {
6c05a9f84   Neeraj Sharma   add functionalit ...
588
589
590
            this.snackbar = true;
            this.text = "Successfully delete Existing News";
            this.getEBooksList();
687e0b929   Neeraj Sharma   add user,attenden...
591
592
          })
          .catch(error => {
6c05a9f84   Neeraj Sharma   add functionalit ...
593
594
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
595
596
          });
      },
687e0b929   Neeraj Sharma   add user,attenden...
597
598
      close() {
        this.dialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
599
600
601
602
603
      },
      close1() {
        this.dialog1 = false;
      },
      submit() {
687e0b929   Neeraj Sharma   add user,attenden...
604
        if (this.$refs.form.validate()) {
687e0b929   Neeraj Sharma   add user,attenden...
605
          if (this.files) {
ab54b5656   Neeraj Sharma   implement library...
606
607
608
609
610
611
612
613
            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...
614
          }
99cd79184   Neeraj Sharma   implement all tas...
615
          this.addEBooks = this.$store.state.schoolId;
4d1fcaddc   Neeraj Sharma   fixed validation ...
616
          this.loading = true;
687e0b929   Neeraj Sharma   add user,attenden...
617
          http()
ab54b5656   Neeraj Sharma   implement library...
618
            .post("/createEBook", this.addEBooks)
687e0b929   Neeraj Sharma   add user,attenden...
619
            .then(response => {
6c05a9f84   Neeraj Sharma   add functionalit ...
620
621
              this.snackbar = true;
              this.text = "New E-Book added successfully";
ab54b5656   Neeraj Sharma   implement library...
622
              this.addEBooks.uploadCover = "";
6c05a9f84   Neeraj Sharma   add functionalit ...
623
624
625
              this.addEBooks.uploadFile = "";
              this.files = "";
              this.getEBooksList();
68d742034   Neeraj Sharma   implement new des...
626
              this.addEBookDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
627
628
629
630
              this.loading = false;
              this.clear();
            })
            .catch(error => {
6c05a9f84   Neeraj Sharma   add functionalit ...
631
632
              this.snackbar = true;
              this.text = error.response.data.message;
4d1fcaddc   Neeraj Sharma   fixed validation ...
633
              this.loading = false;
687e0b929   Neeraj Sharma   add user,attenden...
634
635
636
637
638
            });
        }
      },
      clear() {
        this.$refs.form.reset();
495e4037c   Neeraj Sharma   update
639
640
        this.addEBooks.uploadCover = "";
        this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
641
642
      },
      save() {
6c05a9f84   Neeraj Sharma   add functionalit ...
643
644
645
646
647
        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...
648
        }
ab54b5656   Neeraj Sharma   implement library...
649
650
        if (this.anyFile) {
          const [baseUrl, fileUrl] = this.anyFile.split(/,/);
6c05a9f84   Neeraj Sharma   add functionalit ...
651
652
          this.editedItem.uploadFile = fileUrl;
          // console.log("anyFile.split(/,/)", this.addEBooks.uploadFile);
ab54b5656   Neeraj Sharma   implement library...
653
        }
6c05a9f84   Neeraj Sharma   add functionalit ...
654
        this.editedItem.ebookId = this.editedItem._id;
687e0b929   Neeraj Sharma   add user,attenden...
655
        http()
6c05a9f84   Neeraj Sharma   add functionalit ...
656
          .put("/updateEBook", this.editedItem)
687e0b929   Neeraj Sharma   add user,attenden...
657
          .then(response => {
6c05a9f84   Neeraj Sharma   add functionalit ...
658
659
660
661
662
663
664
665
            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...
666
667
668
            this.close();
          })
          .catch(error => {
6c05a9f84   Neeraj Sharma   add functionalit ...
669
670
671
            this.loadingUpadte = false;
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
672
673
            // console.log(error);
          });
ab54b5656   Neeraj Sharma   implement library...
674
675
676
677
678
679
680
681
682
683
684
685
686
      },
      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...
687
688
689
690
691
692
693
694
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
687e0b929   Neeraj Sharma   add user,attenden...
695
696
697
      }
    },
    mounted() {
ab54b5656   Neeraj Sharma   implement library...
698
      this.token = this.$store.state.token;
6c05a9f84   Neeraj Sharma   add functionalit ...
699
      this.getEBooksList();
ab54b5656   Neeraj Sharma   implement library...
700
      this.getAllClass();
006544386   Neeraj Sharma   implement task
701
      // this.getBookData();
ab54b5656   Neeraj Sharma   implement library...
702
      // this.editItem;
687e0b929   Neeraj Sharma   add user,attenden...
703
704
    }
  };
68d742034   Neeraj Sharma   implement new des...
705
  </script>