Blame view

src/pages/Library/eBook.vue 25.2 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
      <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>
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 ******  -->
59793b95a   Neeraj Sharma   complete design a...
139
      <v-dialog v-model="viewEbookDialog" max-width="600px" scrollable>
710438de6   Shikha Mishra   added teacher mod...
140
141
142
        <v-card flat class="card-style pa-3" dark>
          <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>
59793b95a   Neeraj Sharma   complete design a...
182
              <v-flex xs12 sm12>
710438de6   Shikha Mishra   added teacher mod...
183
184
185
186
187
188
189
                <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...
190
                    <h5 class="my-1 left">{{ editedItem.classId .classNum}}</h5>
710438de6   Shikha Mishra   added teacher mod...
191
192
193
                  </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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
            </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">
109a6218c   Neeraj Sharma   solve issue/bugs ...
242
243
244
245
              <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...
246
247
248
249
250
251
252
253
254
255
256
257
            </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...
258
                    src="/static/icon/view.png"
68d742034   Neeraj Sharma   implement new des...
259
260
261
262
263
264
265
266
267
                  />
                  <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...
268
                    src="/static/icon/edit.png"
68d742034   Neeraj Sharma   implement new des...
269
270
271
272
273
274
275
276
                  />
                  <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...
277
                    src="/static/icon/delete.png"
68d742034   Neeraj Sharma   implement new des...
278
279
280
281
282
283
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 ****** -->
      <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...
299
            </v-flex>
68d742034   Neeraj Sharma   implement new des...
300
301
302
303
          </v-layout>
          <v-form ref="form" v-model="valid" lazy-validation>
            <v-container fluid>
              <v-layout>
710438de6   Shikha Mishra   added teacher mod...
304
                <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center">
68d742034   Neeraj Sharma   implement new des...
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
                  <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...
328
                      placeholder="fill name"
68d742034   Neeraj Sharma   implement new des...
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
                      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 ...
381
                      v-model="imageName"
a76a6f135   Neeraj Sharma   implelement task
382
                      :rules="uploadImageRule"
68d742034   Neeraj Sharma   implement new des...
383
                      append-icon="attach_file"
68d742034   Neeraj Sharma   implement new des...
384
385
386
387
388
389
390
391
392
                    ></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 ...
393
                  <v-flex xs8 class="ml-3">
68d742034   Neeraj Sharma   implement new des...
394
395
396
397
                    <input type="file" style="display: none" ref="file" @change="onFilePicked" />
                    <v-text-field
                      label="Select File"
                      @click="pickFile"
109a6218c   Neeraj Sharma   solve issue/bugs ...
398
                      v-model="fileName"
a76a6f135   Neeraj Sharma   implelement task
399
                      :rules="uploadFileRule"
68d742034   Neeraj Sharma   implement new des...
400
                      append-icon="attach_file"
68d742034   Neeraj Sharma   implement new des...
401
402
403
404
405
406
407
408
409
410
                    ></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
411
                    <v-checkbox v-model="addEBooks.private" :rules="uploadPrivateRule"></v-checkbox>
68d742034   Neeraj Sharma   implement new des...
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
                  </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...
428
429
430
      <div class="loader" v-if="showLoader">
        <v-progress-circular indeterminate color="white"></v-progress-circular>
      </div>
68d742034   Neeraj Sharma   implement new des...
431
    </v-container>
687e0b929   Neeraj Sharma   add user,attenden...
432
433
434
435
436
437
438
439
440
441
442
443
444
445
  </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...
446
447
      show: true,
      showSearch: false,
687e0b929   Neeraj Sharma   add user,attenden...
448
      loading: false,
6c05a9f84   Neeraj Sharma   add functionalit ...
449
      loadingUpadte: false,
687e0b929   Neeraj Sharma   add user,attenden...
450
451
452
      date: null,
      search: "",
      showLoader: false,
710438de6   Shikha Mishra   added teacher mod...
453
454
      editEbookDialog: false,
      viewEbookDialog: false,
687e0b929   Neeraj Sharma   add user,attenden...
455
      valid: true,
68d742034   Neeraj Sharma   implement new des...
456
      addEBookDialog: false,
109a6218c   Neeraj Sharma   solve issue/bugs ...
457
      editLoading: false,
ab54b5656   Neeraj Sharma   implement library...
458
      addClass: [],
687e0b929   Neeraj Sharma   add user,attenden...
459
      addSection: [],
687e0b929   Neeraj Sharma   add user,attenden...
460
      pagination: {
68d742034   Neeraj Sharma   implement new des...
461
        rowsPerPage: 10
687e0b929   Neeraj Sharma   add user,attenden...
462
463
      },
      imageName: "",
ab54b5656   Neeraj Sharma   implement library...
464
      fileName: "",
687e0b929   Neeraj Sharma   add user,attenden...
465
466
467
468
      imageUrl: "",
      imageFile: "",
      image: [],
      upload: "",
ab54b5656   Neeraj Sharma   implement library...
469
470
      files: "",
      anyFile: "",
687e0b929   Neeraj Sharma   add user,attenden...
471
472
      titleRules: [v => !!v || " Tilte is required"],
      descriptionRules: [v => !!v || " Description is required"],
a76a6f135   Neeraj Sharma   implelement task
473
474
475
      uploadImageRule: [v => !!v || " field is required"],
      uploadFileRule: [v => !!v || " fied is required"],
      uploadPrivateRule: [v => !!v || " fied is required"],
687e0b929   Neeraj Sharma   add user,attenden...
476
477
      headers: [
        {
109a6218c   Neeraj Sharma   solve issue/bugs ...
478
          align: "left",
687e0b929   Neeraj Sharma   add user,attenden...
479
480
481
482
          text: "No",
          sortable: false,
          value: "No"
        },
ab54b5656   Neeraj Sharma   implement library...
483
484
485
        { 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...
486
        {
ab54b5656   Neeraj Sharma   implement library...
487
488
          text: "Class",
          value: "classId",
687e0b929   Neeraj Sharma   add user,attenden...
489
490
491
492
493
          sortable: false,
          align: "center"
        },
        { text: "Action", value: "", sortable: false, align: "center" }
      ],
ab54b5656   Neeraj Sharma   implement library...
494
      eBookData: [],
687e0b929   Neeraj Sharma   add user,attenden...
495
      editedIndex: -1,
ab54b5656   Neeraj Sharma   implement library...
496
497
498
499
      addEBooks: {
        private: false
      },
      editedItem: {},
d5fcb1cd1   Shikha Mishra   issues resolved
500
501
502
503
504
      editedItem: {
        classId: {
          classNum: ""
        }
      },
710438de6   Shikha Mishra   added teacher mod...
505
      token: "",
109a6218c   Neeraj Sharma   solve issue/bugs ...
506
507
508
509
510
      uploadCover: {},
      editImageName: "",
      editFiles: "",
      editAnyFile: "",
      editFileName: ""
687e0b929   Neeraj Sharma   add user,attenden...
511
512
    }),
    methods: {
109a6218c   Neeraj Sharma   solve issue/bugs ...
513
514
515
      editPickImage() {
        this.$refs.editImage.click();
      },
ab54b5656   Neeraj Sharma   implement library...
516
      pickImage() {
687e0b929   Neeraj Sharma   add user,attenden...
517
518
        this.$refs.image.click();
      },
ab54b5656   Neeraj Sharma   implement library...
519
520
521
      pickFile() {
        this.$refs.file.click();
      },
109a6218c   Neeraj Sharma   solve issue/bugs ...
522
523
524
      editPickFile() {
        this.$refs.editFile.click();
      },
ab54b5656   Neeraj Sharma   implement library...
525
      onImagePicked(e) {
687e0b929   Neeraj Sharma   add user,attenden...
526
527
528
529
530
531
532
533
        // 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...
534
          /** Select many image and showing many image add to news card **/
687e0b929   Neeraj Sharma   add user,attenden...
535
536
537
          const fr = new FileReader();
          fr.readAsDataURL(files[0]);
          fr.addEventListener("load", () => {
ab54b5656   Neeraj Sharma   implement library...
538
            this.files = fr.result;
687e0b929   Neeraj Sharma   add user,attenden...
539
540
541
542
          });
        } else {
          this.imageName = "";
          this.imageFile = "";
ab54b5656   Neeraj Sharma   implement library...
543
          this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
544
545
546
          this.imageUrl = "";
        }
      },
109a6218c   Neeraj Sharma   solve issue/bugs ...
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
      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 ...
567
      getEBooksList() {
687e0b929   Neeraj Sharma   add user,attenden...
568
        this.showLoader = true;
687e0b929   Neeraj Sharma   add user,attenden...
569
        http()
ab54b5656   Neeraj Sharma   implement library...
570
          .get("/getEBooksList", {
99cd79184   Neeraj Sharma   implement all tas...
571
            params: { schoolId: this.$store.state.schoolId },
ab54b5656   Neeraj Sharma   implement library...
572
            headers: { Authorization: "Bearer " + this.token }
687e0b929   Neeraj Sharma   add user,attenden...
573
574
          })
          .then(response => {
ab54b5656   Neeraj Sharma   implement library...
575
            this.eBookData = response.data.data;
687e0b929   Neeraj Sharma   add user,attenden...
576
            this.showLoader = false;
687e0b929   Neeraj Sharma   add user,attenden...
577
          })
00e4bc4e1   Neeraj Sharma   fixed auntentication
578
          .catch(error => {
687e0b929   Neeraj Sharma   add user,attenden...
579
580
            // console.log("err====>", err);
            this.showLoader = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
581
582
583
584
585
            if (error.response.status === 401) {
              this.$router.replace({ path: "/" });
              this.$store.dispatch("setToken", null);
              this.$store.dispatch("Id", null);
            }
ab54b5656   Neeraj Sharma   implement library...
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
          });
      },
      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...
602
          });
ab54b5656   Neeraj Sharma   implement library...
603
604
605
606
        } else {
          this.anyFile = "";
          this.fileName = "";
        }
687e0b929   Neeraj Sharma   add user,attenden...
607
      },
109a6218c   Neeraj Sharma   solve issue/bugs ...
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
      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...
628
629
      editItem(item) {
        this.files = [];
ab54b5656   Neeraj Sharma   implement library...
630
        this.editedIndex = this.eBookData.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
631
        this.editedItem = Object.assign({}, item);
6c05a9f84   Neeraj Sharma   add functionalit ...
632
        this.editedItem.className = item.classId.classNum;
710438de6   Shikha Mishra   added teacher mod...
633
        this.editEbookDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
634
635
      },
      profile(item) {
ab54b5656   Neeraj Sharma   implement library...
636
        this.editedIndex = this.eBookData.indexOf(item);
687e0b929   Neeraj Sharma   add user,attenden...
637
        this.editedItem = Object.assign({}, item);
710438de6   Shikha Mishra   added teacher mod...
638
        this.viewEbookDialog = true;
687e0b929   Neeraj Sharma   add user,attenden...
639
640
      },
      deleteItem(item) {
6c05a9f84   Neeraj Sharma   add functionalit ...
641
642
        let deleteEBooks = {
          ebookId: item._id
687e0b929   Neeraj Sharma   add user,attenden...
643
644
645
        };
        http()
          .delete(
6c05a9f84   Neeraj Sharma   add functionalit ...
646
            "/deleteEBook",
687e0b929   Neeraj Sharma   add user,attenden...
647
            confirm("Are you sure you want to delete this?") && {
6c05a9f84   Neeraj Sharma   add functionalit ...
648
              params: deleteEBooks
687e0b929   Neeraj Sharma   add user,attenden...
649
650
651
            }
          )
          .then(response => {
6c05a9f84   Neeraj Sharma   add functionalit ...
652
653
654
            this.snackbar = true;
            this.text = "Successfully delete Existing News";
            this.getEBooksList();
687e0b929   Neeraj Sharma   add user,attenden...
655
656
          })
          .catch(error => {
6c05a9f84   Neeraj Sharma   add functionalit ...
657
658
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
659
660
          });
      },
687e0b929   Neeraj Sharma   add user,attenden...
661
      close() {
710438de6   Shikha Mishra   added teacher mod...
662
        this.editEbookDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
663
664
      },
      close1() {
710438de6   Shikha Mishra   added teacher mod...
665
        this.viewEbookDialog = false;
687e0b929   Neeraj Sharma   add user,attenden...
666
667
      },
      submit() {
687e0b929   Neeraj Sharma   add user,attenden...
668
        if (this.$refs.form.validate()) {
109a6218c   Neeraj Sharma   solve issue/bugs ...
669
          this.loading = true;
a76a6f135   Neeraj Sharma   implelement task
670
671
          var uploadCover = "";
          var uploadFile = "";
687e0b929   Neeraj Sharma   add user,attenden...
672
          if (this.files) {
ab54b5656   Neeraj Sharma   implement library...
673
            const [baseUrl, imageUrl] = this.files.split(/,/);
a76a6f135   Neeraj Sharma   implelement task
674
675
            uploadCover = imageUrl;
            console.log("anyFile.split(/,/)", uploadCover);
ab54b5656   Neeraj Sharma   implement library...
676
677
678
          }
          if (this.anyFile) {
            const [baseUrl, fileUrl] = this.anyFile.split(/,/);
a76a6f135   Neeraj Sharma   implelement task
679
680
            uploadFile = fileUrl;
            console.log("anyFile.split(/,/)", uploadFile);
687e0b929   Neeraj Sharma   add user,attenden...
681
          }
710438de6   Shikha Mishra   added teacher mod...
682
683
684
685
686
          let data = {
            classId: this.addEBooks.classId,
            name: this.addEBooks.name,
            author: this.addEBooks.author,
            private: this.addEBooks.private,
a76a6f135   Neeraj Sharma   implelement task
687
688
            uploadCover: uploadCover,
            uploadFile: uploadFile
710438de6   Shikha Mishra   added teacher mod...
689
          };
687e0b929   Neeraj Sharma   add user,attenden...
690
          http()
710438de6   Shikha Mishra   added teacher mod...
691
            .post("/createEBook", data)
687e0b929   Neeraj Sharma   add user,attenden...
692
            .then(response => {
a76a6f135   Neeraj Sharma   implelement task
693
694
              this.getEBooksList();
              // this.getEBooksList = [];
68d742034   Neeraj Sharma   implement new des...
695
              this.addEBookDialog = false;
109a6218c   Neeraj Sharma   solve issue/bugs ...
696
              this.snackbar = true;
710438de6   Shikha Mishra   added teacher mod...
697
698
              this.text = response.data.message;
              this.color = "green";
687e0b929   Neeraj Sharma   add user,attenden...
699
              this.loading = false;
109a6218c   Neeraj Sharma   solve issue/bugs ...
700
              (this.imageName = ""), (this.fileName = "");
687e0b929   Neeraj Sharma   add user,attenden...
701
702
            })
            .catch(error => {
6c05a9f84   Neeraj Sharma   add functionalit ...
703
704
              this.snackbar = true;
              this.text = error.response.data.message;
710438de6   Shikha Mishra   added teacher mod...
705
              this.color = "red";
687e0b929   Neeraj Sharma   add user,attenden...
706
707
708
709
710
            });
        }
      },
      clear() {
        this.$refs.form.reset();
495e4037c   Neeraj Sharma   update
711
712
        this.addEBooks.uploadCover = "";
        this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
713
714
      },
      save() {
109a6218c   Neeraj Sharma   solve issue/bugs ...
715
        this.editLoading = true;
6c05a9f84   Neeraj Sharma   add functionalit ...
716
        this.loadingUpadte = true;
109a6218c   Neeraj Sharma   solve issue/bugs ...
717
718
        if (this.editFiles) {
          const [baseUrl, imageUrl] = this.editFiles.split(/,/);
6c05a9f84   Neeraj Sharma   add functionalit ...
719
720
          this.editedItem.uploadCover = imageUrl;
          // console.log("anyFile.split(/,/)", this.addEBooks.uploadCover);
687e0b929   Neeraj Sharma   add user,attenden...
721
        }
109a6218c   Neeraj Sharma   solve issue/bugs ...
722
723
        if (this.editAnyFile) {
          const [baseUrl, fileUrl] = this.editAnyFile.split(/,/);
6c05a9f84   Neeraj Sharma   add functionalit ...
724
725
          this.editedItem.uploadFile = fileUrl;
          // console.log("anyFile.split(/,/)", this.addEBooks.uploadFile);
ab54b5656   Neeraj Sharma   implement library...
726
        }
109a6218c   Neeraj Sharma   solve issue/bugs ...
727
728
729
        if (this.editedItem.classId._id) {
          this.editedItem.classId = this.editedItem.classId._id;
        }
6c05a9f84   Neeraj Sharma   add functionalit ...
730
        this.editedItem.ebookId = this.editedItem._id;
109a6218c   Neeraj Sharma   solve issue/bugs ...
731
        console.log("this.editedItem", this.editedItem);
687e0b929   Neeraj Sharma   add user,attenden...
732
        http()
6c05a9f84   Neeraj Sharma   add functionalit ...
733
          .put("/updateEBook", this.editedItem)
687e0b929   Neeraj Sharma   add user,attenden...
734
          .then(response => {
6c05a9f84   Neeraj Sharma   add functionalit ...
735
736
737
738
            this.loadingUpadte = false;
            this.snackbar = true;
            this.text = "Successfully Edit Existing E-Book";
            this.getEBooksList();
109a6218c   Neeraj Sharma   solve issue/bugs ...
739
            this.editLoading = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
740
741
742
743
            this.editedItem.uploadFile = "";
            this.editedItem.uploadCover = "";
            this.anyFile = "";
            this.files = "";
687e0b929   Neeraj Sharma   add user,attenden...
744
745
746
            this.close();
          })
          .catch(error => {
109a6218c   Neeraj Sharma   solve issue/bugs ...
747
            this.editLoading = false;
6c05a9f84   Neeraj Sharma   add functionalit ...
748
749
750
            this.loadingUpadte = false;
            this.snackbar = true;
            this.text = error.response.data.message;
687e0b929   Neeraj Sharma   add user,attenden...
751
752
            // console.log(error);
          });
ab54b5656   Neeraj Sharma   implement library...
753
754
755
756
757
758
759
760
761
762
763
764
765
      },
      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...
766
767
768
769
770
771
772
773
      },
      displaySearch() {
        (this.show = false), (this.showSearch = true);
      },
      closeSearch() {
        this.showSearch = false;
        this.show = true;
        this.search = "";
687e0b929   Neeraj Sharma   add user,attenden...
774
775
776
      }
    },
    mounted() {
ab54b5656   Neeraj Sharma   implement library...
777
      this.token = this.$store.state.token;
6c05a9f84   Neeraj Sharma   add functionalit ...
778
      this.getEBooksList();
ab54b5656   Neeraj Sharma   implement library...
779
      this.getAllClass();
006544386   Neeraj Sharma   implement task
780
      // this.getBookData();
ab54b5656   Neeraj Sharma   implement library...
781
      // this.editItem;
687e0b929   Neeraj Sharma   add user,attenden...
782
783
    }
  };
68d742034   Neeraj Sharma   implement new des...
784
  </script>