Blame view

src/pages/Library/eBook.vue 25.3 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>
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>
612b79bb4   Amber Dev   made serch auto f...
227
            <v-text-field autofocus v-model="search" label="Search" prepend-inner-icon="search" color="primary"></v-text-field>
68d742034   Neeraj Sharma   implement new des...
228
229
230
231
232
233
234
235
236
237
238
239
240
241
            <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
                  />
                  <span>Edit</span>
                </v-tooltip>
058c4a6cf   Shikha Mishra   Improve the funct...
272
                <v-tooltip top v-if="role != 'TEACHER' ">
68d742034   Neeraj Sharma   implement new des...
273
274
275
276
                  <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: {
058c4a6cf   Shikha Mishra   Improve the funct...
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: "",
058c4a6cf   Shikha Mishra   Improve the funct...
471
472
473
474
475
      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
476

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