Blame view

src/pages/Library/eBook.vue 25.7 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 ****** -->
db965de89   Amber Dev   added dialog pers...
4
      <v-dialog v-model="editEbookDialog" max-width="600px" persistent>
4dd422bef   Shikha Mishra   change ui of card...
5
        <v-card flat class="Card-style pa-2">
710438de6   Shikha Mishra   added teacher mod...
6
7
8
9
10
11
12
          <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>
109a6218c   Neeraj Sharma   solve issue/bugs ...
13
            <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center">
710438de6   Shikha Mishra   added teacher mod...
14
15
16
              <input
                type="file"
                style="display: none"
109a6218c   Neeraj Sharma   solve issue/bugs ...
17
                ref="editImage"
710438de6   Shikha Mishra   added teacher mod...
18
                accept="image/*"
109a6218c   Neeraj Sharma   solve issue/bugs ...
19
                @change="onEditImagePicked"
710438de6   Shikha Mishra   added teacher mod...
20
              />
710438de6   Shikha Mishra   added teacher mod...
21
              <img
109a6218c   Neeraj Sharma   solve issue/bugs ...
22
                v-if="editedItem.coverPhotoUrl"
710438de6   Shikha Mishra   added teacher mod...
23
                :src="editedItem.coverPhotoUrl"
109a6218c   Neeraj Sharma   solve issue/bugs ...
24
                height="160"
710438de6   Shikha Mishra   added teacher mod...
25
26
27
28
                width="160"
                alt="eBooks"
                class="pa-2"
              />
710438de6   Shikha Mishra   added teacher mod...
29
30
31
32
33
34
35
36
37
              <img
                src="/static/icon/user.png"
                v-if="editedItem.coverPhotoUrl == ''"
                height="160"
                width="160"
                alt="Books"
              />
            </v-flex>
            <v-container grid-list-md>
109a6218c   Neeraj Sharma   solve issue/bugs ...
38
              <v-flex xs12 sm12>
68d742034   Neeraj Sharma   implement new des...
39
                <v-layout>
710438de6   Shikha Mishra   added teacher mod...
40
41
42
                  <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...
43
                  </v-flex>
710438de6   Shikha Mishra   added teacher mod...
44
45
46
47
48
49
50
51
                  <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...
52
                  </v-flex>
710438de6   Shikha Mishra   added teacher mod...
53
54
                </v-layout>
              </v-flex>
109a6218c   Neeraj Sharma   solve issue/bugs ...
55
              <v-flex xs12 sm12>
710438de6   Shikha Mishra   added teacher mod...
56
57
58
59
                <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...
60
                  </v-flex>
710438de6   Shikha Mishra   added teacher mod...
61
62
63
64
65
66
67
68
                  <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...
69
70
                  </v-flex>
                </v-layout>
710438de6   Shikha Mishra   added teacher mod...
71
              </v-flex>
109a6218c   Neeraj Sharma   solve issue/bugs ...
72
              <v-flex xs12 sm12>
68d742034   Neeraj Sharma   implement new des...
73
                <v-layout>
710438de6   Shikha Mishra   added teacher mod...
74
75
76
77
78
                  <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">
109a6218c   Neeraj Sharma   solve issue/bugs ...
79
80
81
82
83
84
                    <v-select
                      v-model="editedItem.classId"
                      :items="addClass"
                      label="Select Class"
                      item-text="classNum"
                      item-value="_id"
710438de6   Shikha Mishra   added teacher mod...
85
86
                      type="_id"
                      required
109a6218c   Neeraj Sharma   solve issue/bugs ...
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
                    ></v-select>
                  </v-flex>
                </v-layout>
              </v-flex>
              <v-flex xs12 sm12>
                <v-layout>
                  <v-flex xs4 class="pt-4 subheading">
                    <label class="right hidden-xs-only hidden-sm-only">Upload Image :</label>
                    <label class="right hidden-lg-only hidden-md-only hidden-xl-only">UploadImage :</label>
                  </v-flex>
                  <v-flex xs8 class="ml-3">
                    <v-text-field
                      label="Select Image"
                      @click="editPickImage"
                      v-model="editImageName"
                      append-icon="attach_file"
                    ></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 xs8 class="ml-3">
                    <input
                      type="file"
                      style="display: none"
                      ref="editFile"
                      @change="onEditFilePicked"
                    />
                    <v-text-field
                      label="Select File"
                      @click="editPickFile"
                      v-model="editFileName"
                      append-icon="attach_file"
710438de6   Shikha Mishra   added teacher mod...
124
                    ></v-text-field>
68d742034   Neeraj Sharma   implement new des...
125
126
                  </v-flex>
                </v-layout>
710438de6   Shikha Mishra   added teacher mod...
127
              </v-flex>
109a6218c   Neeraj Sharma   solve issue/bugs ...
128
129
130
131
132
              <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn round dark @click="save" :loading="editLoading" class="add-button">Save</v-btn>
                <v-spacer></v-spacer>
              </v-card-actions>
710438de6   Shikha Mishra   added teacher mod...
133
            </v-container>
68d742034   Neeraj Sharma   implement new des...
134
135
136
137
138
          </v-card-text>
        </v-card>
      </v-dialog>
  
      <!-- ****** PROFILE VIEW ALL NEWS DEATILS ******  -->
db965de89   Amber Dev   added dialog pers...
139
      <v-dialog v-model="viewEbookDialog" max-width="600px" scrollable persistent>
4dd422bef   Shikha Mishra   change ui of card...
140
        <v-card flat class="Card-style pa-3">
710438de6   Shikha Mishra   added teacher mod...
141
142
          <v-layout>
            <v-flex xs12>
59793b95a   Neeraj Sharma   complete design a...
143
              <label class="title text-xs-center">View E-book</label>
710438de6   Shikha Mishra   added teacher mod...
144
145
146
147
148
149
              <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">
59793b95a   Neeraj Sharma   complete design a...
150
151
                <img src="/static/icon/user.png" v-if="!editedItem.coverPhotoUrl" />
                <img :src="editedItem.coverPhotoUrl" v-else-if="editedItem.coverPhotoUrl" />
710438de6   Shikha Mishra   added teacher mod...
152
153
154
155
156
              </v-avatar>
            </v-flex>
          </v-layout>
          <v-container grid-list-md>
            <v-layout wrap>
59793b95a   Neeraj Sharma   complete design a...
157
              <v-flex xs12 sm12>
710438de6   Shikha Mishra   added teacher mod...
158
159
160
161
162
163
164
165
166
167
168
                <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>
59793b95a   Neeraj Sharma   complete design a...
169
              <v-flex xs12 sm12>
710438de6   Shikha Mishra   added teacher mod...
170
                <v-layout>
59793b95a   Neeraj Sharma   complete design a...
171
                  <v-flex xs6 sm6>
710438de6   Shikha Mishra   added teacher mod...
172
173
174
175
                    <h5 class="right my-1">
                      <b>Author:</b>
                    </h5>
                  </v-flex>
59793b95a   Neeraj Sharma   complete design a...
176
                  <v-flex sm6 xs6>
710438de6   Shikha Mishra   added teacher mod...
177
178
179
180
181
                    <h5 class="my-1 left">{{ editedItem.author }}</h5>
                  </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
058c4a6cf   Shikha Mishra   Improve the funct...
182
183
184
185
186
187
188
189
190
191
192
193
            <v-flex xs12 sm12>
              <v-layout>
                <v-flex xs6 sm6>
                  <h5 class="right my-1">
                    <b>Class:</b>
                  </h5>
                </v-flex>
                <v-flex sm6 xs6>
                  <h5 class="my-1 left">{{ editedItem.classId .classNum}}</h5>
                </v-flex>
              </v-layout>
            </v-flex>
710438de6   Shikha Mishra   added teacher mod...
194
          </v-container>
68d742034   Neeraj Sharma   implement new des...
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
        </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...
221
              <img src="/static/icon/search.png" alt="icon" />
68d742034   Neeraj Sharma   implement new des...
222
223
224
            </v-avatar>
          </v-btn>
        </v-card-title>
612b79bb4   Amber Dev   made serch auto f...
225
        <v-flex xs8 sm8 md3 lg2 v-if="showSearch">
68d742034   Neeraj Sharma   implement new des...
226
          <v-layout>
8e8d14254   Shikha Mishra   Cleared data whil...
227
228
229
230
231
232
233
            <v-text-field
              autofocus
              v-model="search"
              label="Search"
              prepend-inner-icon="search"
              color="primary"
            ></v-text-field>
68d742034   Neeraj Sharma   implement new des...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
            <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">
109a6218c   Neeraj Sharma   solve issue/bugs ...
248
249
250
251
              <v-avatar size="40">
                <img :src="props.item.coverPhotoUrl" v-if="props.item.coverPhotoUrl" alt="ebooks" />
                <img src="/static/icon/user.png" v-if="!props.item.coverPhotoUrl" />
              </v-avatar>
68d742034   Neeraj Sharma   implement new des...
252
253
254
255
256
257
258
259
260
261
262
263
            </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...
264
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
265
266
267
268
269
270
271
272
273
                  />
                  <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...
274
                    src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
275
276
277
                  />
                  <span>Edit</span>
                </v-tooltip>
058c4a6cf   Shikha Mishra   Improve the funct...
278
                <v-tooltip top v-if="role != 'TEACHER' ">
68d742034   Neeraj Sharma   implement new des...
279
280
281
282
                  <img
                    slot="activator"
                    style="cursor:pointer; width:20px; height:20px; "
                    @click="deleteItem(props.item)"
aa310d61a   Shikha Mishra   added functionali...
283
                    src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
                  />
                  <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 ****** -->
db965de89   Amber Dev   added dialog pers...
299
      <v-dialog v-model="addEBookDialog" max-width="600px" v-if="addEBookDialog" persistent>
4dd422bef   Shikha Mishra   change ui of card...
300
        <v-card flat class="Card-style pa-2">
68d742034   Neeraj Sharma   implement new des...
301
302
303
          <v-layout>
            <v-flex xs12>
              <label class="title text-xs-center">Add E-Book</label>
8e8d14254   Shikha Mishra   Cleared data whil...
304
              <v-icon size="24" class="right" @click="closeAddEBookModel">cancel</v-icon>
687e0b929   Neeraj Sharma   add user,attenden...
305
            </v-flex>
68d742034   Neeraj Sharma   implement new des...
306
307
308
309
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-layout>
710438de6   Shikha Mishra   added teacher mod...
310
                <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center">
68d742034   Neeraj Sharma   implement new des...
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
                  <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...
334
                      placeholder="fill name"
68d742034   Neeraj Sharma   implement new des...
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
                      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"
109a6218c   Neeraj Sharma   solve issue/bugs ...
387
                      v-model="imageName"
68d742034   Neeraj Sharma   implement new des...
388
                      append-icon="attach_file"
68d742034   Neeraj Sharma   implement new des...
389
390
391
392
393
394
395
396
397
                    ></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>
109a6218c   Neeraj Sharma   solve issue/bugs ...
398
                  <v-flex xs8 class="ml-3">
68d742034   Neeraj Sharma   implement new des...
399
400
401
402
                    <input type="file" style="display: none" ref="file" @change="onFilePicked" />
                    <v-text-field
                      label="Select File"
                      @click="pickFile"
109a6218c   Neeraj Sharma   solve issue/bugs ...
403
                      v-model="fileName"
68d742034   Neeraj Sharma   implement new des...
404
                      append-icon="attach_file"
68d742034   Neeraj Sharma   implement new des...
405
406
407
408
409
410
411
412
413
414
                    ></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">
a76a6f135   Neeraj Sharma   implelement task
415
                    <v-checkbox v-model="addEBooks.private" :rules="uploadPrivateRule"></v-checkbox>
68d742034   Neeraj Sharma   implement new des...
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
                  </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...
432
433
434
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
435
    </v-container>
687e0b929   Neeraj Sharma   add user,attenden...
436
437
438
439
440
441
442
443
444
445
446
447
448
449
  </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...
450
451
      show: true,
      showSearch: false,
687e0b929   Neeraj Sharma   add user,attenden...
452
      loading: false,
6c05a9f84   Neeraj Sharma   add functionalit ...
453
      loadingUpadte: false,
687e0b929   Neeraj Sharma   add user,attenden...
454
455
456
      date: null,
      search: "",
      showLoader: false,
710438de6   Shikha Mishra   added teacher mod...
457
458
      editEbookDialog: false,
      viewEbookDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
459
      valid: true,
68d742034   Neeraj Sharma   implement new des...
460
      addEBookDialog: false,
109a6218c   Neeraj Sharma   solve issue/bugs ...
461
      editLoading: false,
ab54b5656   Neeraj Sharma   implement library...
462
      addClass: [],
687e0b929   Neeraj Sharma   add user,attenden...
463
      addSection: [],
687e0b929   Neeraj Sharma   add user,attenden...
464
      pagination: {
058c4a6cf   Shikha Mishra   Improve the funct...
465
        rowsPerPage: 10,
687e0b929   Neeraj Sharma   add user,attenden...
466
467
      },
      imageName: "",
ab54b5656   Neeraj Sharma   implement library...
468
      fileName: "",
687e0b929   Neeraj Sharma   add user,attenden...
469
470
471
472
      imageUrl: "",
      imageFile: "",
      image: [],
      upload: "",
ab54b5656   Neeraj Sharma   implement library...
473
474
      files: "",
      anyFile: "",
058c4a6cf   Shikha Mishra   Improve the funct...
475
476
477
478
479
      titleRules: [(v) => !!v || " Tilte is required"],
      descriptionRules: [(v) => !!v || " Description is required"],
      uploadImageRule: [(v) => !!v || " field is required"],
      uploadFileRule: [(v) => !!v || " fied is required"],
      uploadPrivateRule: [(v) => !!v || " fied is required"],
a76a6f135   Neeraj Sharma   implelement task
480

687e0b929   Neeraj Sharma   add user,attenden...
481
482
      headers: [
        {
109a6218c   Neeraj Sharma   solve issue/bugs ...
483
          align: "left",
687e0b929   Neeraj Sharma   add user,attenden...
484
485
          text: "No",
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
486
          value: "No",
687e0b929   Neeraj Sharma   add user,attenden...
487
        },
ab54b5656   Neeraj Sharma   implement library...
488
489
490
        { 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...
491
        {
ab54b5656   Neeraj Sharma   implement library...
492
493
          text: "Class",
          value: "classId",
687e0b929   Neeraj Sharma   add user,attenden...
494
          sortable: false,
058c4a6cf   Shikha Mishra   Improve the funct...
495
          align: "center",
687e0b929   Neeraj Sharma   add user,attenden...
496
        },
058c4a6cf   Shikha Mishra   Improve the funct...
497
        { text: "Action", value: "", sortable: false, align: "center" },
687e0b929   Neeraj Sharma   add user,attenden...
498
      ],
ab54b5656   Neeraj Sharma   implement library...
499
      eBookData: [],
687e0b929   Neeraj Sharma   add user,attenden...
500
      editedIndex: -1,
ab54b5656   Neeraj Sharma   implement library...
501
      addEBooks: {
058c4a6cf   Shikha Mishra   Improve the funct...
502
        private: false,
ab54b5656   Neeraj Sharma   implement library...
503
504
      },
      editedItem: {},
d5fcb1cd1   Shikha Mishra   issues resolved
505
506
      editedItem: {
        classId: {
058c4a6cf   Shikha Mishra   Improve the funct...
507
508
          classNum: "",
        },
d5fcb1cd1   Shikha Mishra   issues resolved
509
      },
710438de6   Shikha Mishra   added teacher mod...
510
      token: "",
109a6218c   Neeraj Sharma   solve issue/bugs ...
511
512
513
514
      uploadCover: {},
      editImageName: "",
      editFiles: "",
      editAnyFile: "",
058c4a6cf   Shikha Mishra   Improve the funct...
515
      editFileName: "",
687e0b929   Neeraj Sharma   add user,attenden...
516
    }),
8e8d14254   Shikha Mishra   Cleared data whil...
517
518
519
520
521
522
523
524
525
526
    watch: {
      addEBookDialog: function (val) {
        if (!val) {
          this.addEBooks = [];
          this.imageName = "";
          this.fileName = "";
          this.files = "";
        }
      },
    },
687e0b929   Neeraj Sharma   add user,attenden...
527
    methods: {
109a6218c   Neeraj Sharma   solve issue/bugs ...
528
529
530
      editPickImage() {
        this.$refs.editImage.click();
      },
ab54b5656   Neeraj Sharma   implement library...
531
      pickImage() {
687e0b929   Neeraj Sharma   add user,attenden...
532
533
        this.$refs.image.click();
      },
ab54b5656   Neeraj Sharma   implement library...
534
535
536
      pickFile() {
        this.$refs.file.click();
      },
109a6218c   Neeraj Sharma   solve issue/bugs ...
537
538
539
      editPickFile() {
        this.$refs.editFile.click();
      },
ab54b5656   Neeraj Sharma   implement library...
540
      onImagePicked(e) {
687e0b929   Neeraj Sharma   add user,attenden...
541
542
543
544
545
546
547
548
        // 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...
549
          /** Select many image and showing many image add to news card **/
687e0b929   Neeraj Sharma   add user,attenden...
550
551
552
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
ab54b5656   Neeraj Sharma   implement library...
553
            this.files = fr.result;
687e0b929   Neeraj Sharma   add user,attenden...
554
555
556
557
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
ab54b5656   Neeraj Sharma   implement library...
558
          this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
559
560
561
          this.imageUrl = "";
        }
      },
109a6218c   Neeraj Sharma   solve issue/bugs ...
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
      onEditImagePicked(e) {
        // console.log(e)
        const files = e.target.files;
        /** fetch Image Name **/
        if (files[0] !== undefined) {
          this.editImageName = files[0].name;
          if (this.editImageName.lastIndexOf(".") <= 0) {
            return;
          }
          /** Select many image and showing many image add to news card **/
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
            this.editFiles = fr.result;
          });
        } else {
          this.editImageName = "";
          this.editFiles = "";
        }
      },
6c05a9f84   Neeraj Sharma   add functionalit ...
582
      getEBooksList() {
687e0b929   Neeraj Sharma   add user,attenden...
583
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
584
        http()
ab54b5656   Neeraj Sharma   implement library...
585
          .get("/getEBooksList", {
99cd79184   Neeraj Sharma   implement all tas...
586
            params: { schoolId: this.$store.state.schoolId },
058c4a6cf   Shikha Mishra   Improve the funct...
587
            headers: { Authorization: "Bearer " + this.token },
687e0b929   Neeraj Sharma   add user,attenden...
588
          })
058c4a6cf   Shikha Mishra   Improve the funct...
589
          .then((response) => {
ab54b5656   Neeraj Sharma   implement library...
590
            this.eBookData = response.data.data;
687e0b929   Neeraj Sharma   add user,attenden...
591
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
592
          })
058c4a6cf   Shikha Mishra   Improve the funct...
593
          .catch((error) => {
687e0b929   Neeraj Sharma   add user,attenden...
594
595
            // console.log("err====>", err);
            this.showLoader = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
596
597
598
599
600
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
ab54b5656   Neeraj Sharma   implement library...
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
          });
      },
      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...
617
          });
ab54b5656   Neeraj Sharma   implement library...
618
619
620
621
        } else {
          this.anyFile = "";
          this.fileName = "";
        }
687e0b929   Neeraj Sharma   add user,attenden...
622
      },
109a6218c   Neeraj Sharma   solve issue/bugs ...
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
      onEditFilePicked(e) {
        // console.log(e)
        const files = e.target.files;
        /** fetch Image Name **/
        if (files[0] !== undefined) {
          this.editFileName = files[0].name;
          if (this.editFileName.lastIndexOf(".") <= 0) {
            return;
          }
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
            this.editAnyFile = fr.result;
            // console.log(" this.anyFile Url", this.anyFile )
          });
        } else {
          this.editAnyFile = "";
          this.editFileName = "";
        }
      },
687e0b929   Neeraj Sharma   add user,attenden...
643
644
      editItem(item) {
        this.files = [];
ab54b5656   Neeraj Sharma   implement library...
645
        this.editedIndex = this.eBookData.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
646
        this.editedItem = Object.assign({}, item);
6c05a9f84   Neeraj Sharma   add functionalit ...
647
        this.editedItem.className = item.classId.classNum;
710438de6   Shikha Mishra   added teacher mod...
648
        this.editEbookDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
649
650
      },
      profile(item) {
ab54b5656   Neeraj Sharma   implement library...
651
        this.editedIndex = this.eBookData.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
652
        this.editedItem = Object.assign({}, item);
710438de6   Shikha Mishra   added teacher mod...
653
        this.viewEbookDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
654
655
      },
      deleteItem(item) {
6c05a9f84   Neeraj Sharma   add functionalit ...
656
        let deleteEBooks = {
058c4a6cf   Shikha Mishra   Improve the funct...
657
          ebookId: item._id,
687e0b929   Neeraj Sharma   add user,attenden...
658
659
660
        };
        http()
          .delete(
6c05a9f84   Neeraj Sharma   add functionalit ...
661
            "/deleteEBook",
687e0b929   Neeraj Sharma   add user,attenden...
662
            confirm("Are you sure you want to delete this?") && {
058c4a6cf   Shikha Mishra   Improve the funct...
663
              params: deleteEBooks,
687e0b929   Neeraj Sharma   add user,attenden...
664
665
            }
          )
058c4a6cf   Shikha Mishra   Improve the funct...
666
          .then((response) => {
6c05a9f84   Neeraj Sharma   add functionalit ...
667
668
669
            this.snackbar = true;
            this.text = "Successfully delete Existing News";
            this.getEBooksList();
687e0b929   Neeraj Sharma   add user,attenden...
670
          })
058c4a6cf   Shikha Mishra   Improve the funct...
671
          .catch((error) => {
6c05a9f84   Neeraj Sharma   add functionalit ...
672
673
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
674
675
          });
      },
687e0b929   Neeraj Sharma   add user,attenden...
676
      close() {
710438de6   Shikha Mishra   added teacher mod...
677
        this.editEbookDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
678
679
      },
      close1() {
710438de6   Shikha Mishra   added teacher mod...
680
        this.viewEbookDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
681
      },
8e8d14254   Shikha Mishra   Cleared data whil...
682
683
      closeAddEBookModel() {
        this.addEBookDialog = false;
2f9211c74   Shikha Mishra   done one round of...
684
        //   this.eBookData = [];
8e8d14254   Shikha Mishra   Cleared data whil...
685
686
687
688
689
        this.addEBooks = [];
        this.imageName = "";
        this.fileName = "";
        this.files = "";
      },
687e0b929   Neeraj Sharma   add user,attenden...
690
      submit() {
687e0b929   Neeraj Sharma   add user,attenden...
691
        if (this.$refs.form.validate()) {
109a6218c   Neeraj Sharma   solve issue/bugs ...
692
          this.loading = true;
a76a6f135   Neeraj Sharma   implelement task
693
694
          var uploadCover = "";
          var uploadFile = "";
687e0b929   Neeraj Sharma   add user,attenden...
695
          if (this.files) {
ab54b5656   Neeraj Sharma   implement library...
696
            const [baseUrl, imageUrl] = this.files.split(/,/);
a76a6f135   Neeraj Sharma   implelement task
697
            uploadCover = imageUrl;
860da881d   Shikha Mishra   comment all consoles
698
            //   console.log("anyFile.split(/,/)", uploadCover);
ab54b5656   Neeraj Sharma   implement library...
699
700
701
          }
          if (this.anyFile) {
            const [baseUrl, fileUrl] = this.anyFile.split(/,/);
a76a6f135   Neeraj Sharma   implelement task
702
            uploadFile = fileUrl;
860da881d   Shikha Mishra   comment all consoles
703
            //   console.log("anyFile.split(/,/)", uploadFile);
687e0b929   Neeraj Sharma   add user,attenden...
704
          }
710438de6   Shikha Mishra   added teacher mod...
705
706
707
708
709
          let data = {
            classId: this.addEBooks.classId,
            name: this.addEBooks.name,
            author: this.addEBooks.author,
            private: this.addEBooks.private,
a76a6f135   Neeraj Sharma   implelement task
710
            uploadCover: uploadCover,
058c4a6cf   Shikha Mishra   Improve the funct...
711
            uploadFile: uploadFile,
710438de6   Shikha Mishra   added teacher mod...
712
          };
687e0b929   Neeraj Sharma   add user,attenden...
713
          http()
710438de6   Shikha Mishra   added teacher mod...
714
            .post("/createEBook", data)
058c4a6cf   Shikha Mishra   Improve the funct...
715
            .then((response) => {
a76a6f135   Neeraj Sharma   implelement task
716
717
              this.getEBooksList();
              // this.getEBooksList = [];
68d742034   Neeraj Sharma   implement new des...
718
              this.addEBookDialog = false;
109a6218c   Neeraj Sharma   solve issue/bugs ...
719
              this.snackbar = true;
710438de6   Shikha Mishra   added teacher mod...
720
721
              this.text = response.data.message;
              this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
722
              this.loading = false;
109a6218c   Neeraj Sharma   solve issue/bugs ...
723
              (this.imageName = ""), (this.fileName = "");
687e0b929   Neeraj Sharma   add user,attenden...
724
            })
058c4a6cf   Shikha Mishra   Improve the funct...
725
            .catch((error) => {
6c05a9f84   Neeraj Sharma   add functionalit ...
726
727
              this.snackbar = true;
              this.text = error.response.data.message;
710438de6   Shikha Mishra   added teacher mod...
728
              this.color = "red";
687e0b929   Neeraj Sharma   add user,attenden...
729
730
731
732
733
            });
        }
      },
      clear() {
        this.$refs.form.reset();
495e4037c   Neeraj Sharma   update
734
735
        this.addEBooks.uploadCover = "";
        this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
736
737
      },
      save() {
109a6218c   Neeraj Sharma   solve issue/bugs ...
738
        this.editLoading = true;
6c05a9f84   Neeraj Sharma   add functionalit ...
739
        this.loadingUpadte = true;
109a6218c   Neeraj Sharma   solve issue/bugs ...
740
741
        if (this.editFiles) {
          const [baseUrl, imageUrl] = this.editFiles.split(/,/);
6c05a9f84   Neeraj Sharma   add functionalit ...
742
743
          this.editedItem.uploadCover = imageUrl;
          // console.log("anyFile.split(/,/)", this.addEBooks.uploadCover);
687e0b929   Neeraj Sharma   add user,attenden...
744
        }
109a6218c   Neeraj Sharma   solve issue/bugs ...
745
746
        if (this.editAnyFile) {
          const [baseUrl, fileUrl] = this.editAnyFile.split(/,/);
6c05a9f84   Neeraj Sharma   add functionalit ...
747
748
          this.editedItem.uploadFile = fileUrl;
          // console.log("anyFile.split(/,/)", this.addEBooks.uploadFile);
ab54b5656   Neeraj Sharma   implement library...
749
        }
109a6218c   Neeraj Sharma   solve issue/bugs ...
750
751
752
        if (this.editedItem.classId._id) {
          this.editedItem.classId = this.editedItem.classId._id;
        }
6c05a9f84   Neeraj Sharma   add functionalit ...
753
        this.editedItem.ebookId = this.editedItem._id;
860da881d   Shikha Mishra   comment all consoles
754
        //   console.log("this.editedItem", this.editedItem);
687e0b929   Neeraj Sharma   add user,attenden...
755
        http()
6c05a9f84   Neeraj Sharma   add functionalit ...
756
          .put("/updateEBook", this.editedItem)
058c4a6cf   Shikha Mishra   Improve the funct...
757
          .then((response) => {
6c05a9f84   Neeraj Sharma   add functionalit ...
758
759
760
761
            this.loadingUpadte = false;
            this.snackbar = true;
            this.text = "Successfully Edit Existing E-Book";
            this.getEBooksList();
109a6218c   Neeraj Sharma   solve issue/bugs ...
762
            this.editLoading = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
763
764
765
766
            this.editedItem.uploadFile = "";
            this.editedItem.uploadCover = "";
            this.anyFile = "";
            this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
767
768
            this.close();
          })
058c4a6cf   Shikha Mishra   Improve the funct...
769
          .catch((error) => {
109a6218c   Neeraj Sharma   solve issue/bugs ...
770
            this.editLoading = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
771
772
773
            this.loadingUpadte = false;
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
774
775
            // console.log(error);
          });
ab54b5656   Neeraj Sharma   implement library...
776
777
778
779
      },
      getAllClass() {
        http()
          .get("/getClassesList", {
058c4a6cf   Shikha Mishra   Improve the funct...
780
            headers: { Authorization: "Bearer " + this.token },
ab54b5656   Neeraj Sharma   implement library...
781
          })
058c4a6cf   Shikha Mishra   Improve the funct...
782
          .then((response) => {
ab54b5656   Neeraj Sharma   implement library...
783
784
            this.addClass = response.data.data;
          })
058c4a6cf   Shikha Mishra   Improve the funct...
785
          .catch((err) => {
ab54b5656   Neeraj Sharma   implement library...
786
787
788
            // console.log("err====>", err);
            // this.$router.replace({ path: "/" });
          });
68d742034   Neeraj Sharma   implement new des...
789
790
791
792
793
794
795
796
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
058c4a6cf   Shikha Mishra   Improve the funct...
797
      },
687e0b929   Neeraj Sharma   add user,attenden...
798
799
    },
    mounted() {
ab54b5656   Neeraj Sharma   implement library...
800
      this.token = this.$store.state.token;
6c05a9f84   Neeraj Sharma   add functionalit ...
801
      this.getEBooksList();
ab54b5656   Neeraj Sharma   implement library...
802
      this.getAllClass();
058c4a6cf   Shikha Mishra   Improve the funct...
803
      this.role = this.$store.state.role;
006544386   Neeraj Sharma   implement task
804
      // this.getBookData();
ab54b5656   Neeraj Sharma   implement library...
805
      // this.editItem;
058c4a6cf   Shikha Mishra   Improve the funct...
806
    },
687e0b929   Neeraj Sharma   add user,attenden...
807
  };
68d742034   Neeraj Sharma   implement new des...
808
  </script>