Blame view
src/pages/Library/eBook.vue
25.7 KB
687e0b929
|
1 |
<template> |
68d742034
|
2 3 |
<v-container fluid class="body-color"> <!-- ****** EDITS EBOOK DETAILS ****** --> |
710438de6
|
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
|
13 |
<v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center"> |
710438de6
|
14 15 16 |
<input type="file" style="display: none" |
109a6218c
|
17 |
ref="editImage" |
710438de6
|
18 |
accept="image/*" |
109a6218c
|
19 |
@change="onEditImagePicked" |
710438de6
|
20 |
/> |
710438de6
|
21 |
<img |
109a6218c
|
22 |
v-if="editedItem.coverPhotoUrl" |
710438de6
|
23 |
:src="editedItem.coverPhotoUrl" |
109a6218c
|
24 |
height="160" |
710438de6
|
25 26 27 28 |
width="160" alt="eBooks" class="pa-2" /> |
710438de6
|
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
|
38 |
<v-flex xs12 sm12> |
68d742034
|
39 |
<v-layout> |
710438de6
|
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
|
43 |
</v-flex> |
710438de6
|
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
|
52 |
</v-flex> |
710438de6
|
53 54 |
</v-layout> </v-flex> |
109a6218c
|
55 |
<v-flex xs12 sm12> |
710438de6
|
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
|
60 |
</v-flex> |
710438de6
|
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
|
69 70 |
</v-flex> </v-layout> |
710438de6
|
71 |
</v-flex> |
109a6218c
|
72 |
<v-flex xs12 sm12> |
68d742034
|
73 |
<v-layout> |
710438de6
|
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
|
79 80 81 82 83 84 |
<v-select v-model="editedItem.classId" :items="addClass" label="Select Class" item-text="classNum" item-value="_id" |
710438de6
|
85 86 |
type="_id" required |
109a6218c
|
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
|
124 |
></v-text-field> |
68d742034
|
125 126 |
</v-flex> </v-layout> |
710438de6
|
127 |
</v-flex> |
109a6218c
|
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
|
133 |
</v-container> |
68d742034
|
134 135 136 137 138 |
</v-card-text> </v-card> </v-dialog> <!-- ****** PROFILE VIEW ALL NEWS DEATILS ****** --> |
59793b95a
|
139 |
<v-dialog v-model="viewEbookDialog" max-width="600px" scrollable> |
710438de6
|
140 141 142 |
<v-card flat class="card-style pa-3" dark> <v-layout> <v-flex xs12> |
59793b95a
|
143 |
<label class="title text-xs-center">View E-book</label> |
710438de6
|
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
|
150 151 |
<img src="/static/icon/user.png" v-if="!editedItem.coverPhotoUrl" /> <img :src="editedItem.coverPhotoUrl" v-else-if="editedItem.coverPhotoUrl" /> |
710438de6
|
152 153 154 155 156 |
</v-avatar> </v-flex> </v-layout> <v-container grid-list-md> <v-layout wrap> |
59793b95a
|
157 |
<v-flex xs12 sm12> |
710438de6
|
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
|
169 |
<v-flex xs12 sm12> |
710438de6
|
170 |
<v-layout> |
59793b95a
|
171 |
<v-flex xs6 sm6> |
710438de6
|
172 173 174 175 |
<h5 class="right my-1"> <b>Author:</b> </h5> </v-flex> |
59793b95a
|
176 |
<v-flex sm6 xs6> |
710438de6
|
177 178 179 180 181 |
<h5 class="my-1 left">{{ editedItem.author }}</h5> </v-flex> </v-layout> </v-flex> </v-layout> |
058c4a6cf
|
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
|
194 |
</v-container> |
68d742034
|
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
|
221 |
<img src="/static/icon/search.png" alt="icon" /> |
68d742034
|
222 223 224 |
</v-avatar> </v-btn> </v-card-title> |
612b79bb4
|
225 |
<v-flex xs8 sm8 md3 lg2 v-if="showSearch"> |
68d742034
|
226 |
<v-layout> |
8e8d14254
|
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
|
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
|
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
|
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
|
264 |
src="/static/icon/view.png" |
68d742034
|
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
|
274 |
src="/static/icon/edit.png" |
68d742034
|
275 276 277 |
/> <span>Edit</span> </v-tooltip> |
058c4a6cf
|
278 |
<v-tooltip top v-if="role != 'TEACHER' "> |
68d742034
|
279 280 281 282 |
<img slot="activator" style="cursor:pointer; width:20px; height:20px; " @click="deleteItem(props.item)" |
aa310d61a
|
283 |
src="/static/icon/delete.png" |
68d742034
|
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 ****** --> |
8e8d14254
|
299 |
<v-dialog v-model="addEBookDialog" max-width="600px" v-if="addEBookDialog"> |
68d742034
|
300 301 302 303 |
<v-card flat class="card-style pa-2" dark> <v-layout> <v-flex xs12> <label class="title text-xs-center">Add E-Book</label> |
8e8d14254
|
304 |
<v-icon size="24" class="right" @click="closeAddEBookModel">cancel</v-icon> |
687e0b929
|
305 |
</v-flex> |
68d742034
|
306 307 308 309 |
</v-layout> <v-form ref="form" v-model="valid" lazy-validation> <v-container fluid> <v-layout> |
710438de6
|
310 |
<v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center"> |
68d742034
|
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
|
334 |
placeholder="fill name" |
68d742034
|
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
|
387 |
v-model="imageName" |
68d742034
|
388 |
append-icon="attach_file" |
68d742034
|
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
|
398 |
<v-flex xs8 class="ml-3"> |
68d742034
|
399 400 401 402 |
<input type="file" style="display: none" ref="file" @change="onFilePicked" /> <v-text-field label="Select File" @click="pickFile" |
109a6218c
|
403 |
v-model="fileName" |
68d742034
|
404 |
append-icon="attach_file" |
68d742034
|
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
|
415 |
<v-checkbox v-model="addEBooks.private" :rules="uploadPrivateRule"></v-checkbox> |
68d742034
|
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
|
432 433 434 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
68d742034
|
435 |
</v-container> |
687e0b929
|
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
|
450 451 |
show: true, showSearch: false, |
687e0b929
|
452 |
loading: false, |
6c05a9f84
|
453 |
loadingUpadte: false, |
687e0b929
|
454 455 456 |
date: null, search: "", showLoader: false, |
710438de6
|
457 458 |
editEbookDialog: false, viewEbookDialog: false, |
687e0b929
|
459 |
valid: true, |
68d742034
|
460 |
addEBookDialog: false, |
109a6218c
|
461 |
editLoading: false, |
ab54b5656
|
462 |
addClass: [], |
687e0b929
|
463 |
addSection: [], |
687e0b929
|
464 |
pagination: { |
058c4a6cf
|
465 |
rowsPerPage: 10, |
687e0b929
|
466 467 |
}, imageName: "", |
ab54b5656
|
468 |
fileName: "", |
687e0b929
|
469 470 471 472 |
imageUrl: "", imageFile: "", image: [], upload: "", |
ab54b5656
|
473 474 |
files: "", anyFile: "", |
058c4a6cf
|
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
|
480 |
|
687e0b929
|
481 482 |
headers: [ { |
109a6218c
|
483 |
align: "left", |
687e0b929
|
484 485 |
text: "No", sortable: false, |
058c4a6cf
|
486 |
value: "No", |
687e0b929
|
487 |
}, |
ab54b5656
|
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
|
491 |
{ |
ab54b5656
|
492 493 |
text: "Class", value: "classId", |
687e0b929
|
494 |
sortable: false, |
058c4a6cf
|
495 |
align: "center", |
687e0b929
|
496 |
}, |
058c4a6cf
|
497 |
{ text: "Action", value: "", sortable: false, align: "center" }, |
687e0b929
|
498 |
], |
ab54b5656
|
499 |
eBookData: [], |
687e0b929
|
500 |
editedIndex: -1, |
ab54b5656
|
501 |
addEBooks: { |
058c4a6cf
|
502 |
private: false, |
ab54b5656
|
503 504 |
}, editedItem: {}, |
d5fcb1cd1
|
505 506 |
editedItem: { classId: { |
058c4a6cf
|
507 508 |
classNum: "", }, |
d5fcb1cd1
|
509 |
}, |
710438de6
|
510 |
token: "", |
109a6218c
|
511 512 513 514 |
uploadCover: {}, editImageName: "", editFiles: "", editAnyFile: "", |
058c4a6cf
|
515 |
editFileName: "", |
687e0b929
|
516 |
}), |
8e8d14254
|
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
|
527 |
methods: { |
109a6218c
|
528 529 530 |
editPickImage() { this.$refs.editImage.click(); }, |
ab54b5656
|
531 |
pickImage() { |
687e0b929
|
532 533 |
this.$refs.image.click(); }, |
ab54b5656
|
534 535 536 |
pickFile() { this.$refs.file.click(); }, |
109a6218c
|
537 538 539 |
editPickFile() { this.$refs.editFile.click(); }, |
ab54b5656
|
540 |
onImagePicked(e) { |
687e0b929
|
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
|
549 |
/** Select many image and showing many image add to news card **/ |
687e0b929
|
550 551 552 |
const fr = new FileReader(); fr.readAsDataURL(files[0]); fr.addEventListener("load", () => { |
ab54b5656
|
553 |
this.files = fr.result; |
687e0b929
|
554 555 556 557 |
}); } else { this.imageName = ""; this.imageFile = ""; |
ab54b5656
|
558 |
this.files = ""; |
687e0b929
|
559 560 561 |
this.imageUrl = ""; } }, |
109a6218c
|
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
|
582 |
getEBooksList() { |
687e0b929
|
583 |
this.showLoader = true; |
687e0b929
|
584 |
http() |
ab54b5656
|
585 |
.get("/getEBooksList", { |
99cd79184
|
586 |
params: { schoolId: this.$store.state.schoolId }, |
058c4a6cf
|
587 |
headers: { Authorization: "Bearer " + this.token }, |
687e0b929
|
588 |
}) |
058c4a6cf
|
589 |
.then((response) => { |
ab54b5656
|
590 |
this.eBookData = response.data.data; |
687e0b929
|
591 |
this.showLoader = false; |
687e0b929
|
592 |
}) |
058c4a6cf
|
593 |
.catch((error) => { |
687e0b929
|
594 595 |
// console.log("err====>", err); this.showLoader = false; |
6c05a9f84
|
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
|
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
|
617 |
}); |
ab54b5656
|
618 619 620 621 |
} else { this.anyFile = ""; this.fileName = ""; } |
687e0b929
|
622 |
}, |
109a6218c
|
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
|
643 644 |
editItem(item) { this.files = []; |
ab54b5656
|
645 |
this.editedIndex = this.eBookData.indexOf(item); |
687e0b929
|
646 |
this.editedItem = Object.assign({}, item); |
6c05a9f84
|
647 |
this.editedItem.className = item.classId.classNum; |
710438de6
|
648 |
this.editEbookDialog = true; |
687e0b929
|
649 650 |
}, profile(item) { |
ab54b5656
|
651 |
this.editedIndex = this.eBookData.indexOf(item); |
687e0b929
|
652 |
this.editedItem = Object.assign({}, item); |
710438de6
|
653 |
this.viewEbookDialog = true; |
687e0b929
|
654 655 |
}, deleteItem(item) { |
6c05a9f84
|
656 |
let deleteEBooks = { |
058c4a6cf
|
657 |
ebookId: item._id, |
687e0b929
|
658 659 660 |
}; http() .delete( |
6c05a9f84
|
661 |
"/deleteEBook", |
687e0b929
|
662 |
confirm("Are you sure you want to delete this?") && { |
058c4a6cf
|
663 |
params: deleteEBooks, |
687e0b929
|
664 665 |
} ) |
058c4a6cf
|
666 |
.then((response) => { |
6c05a9f84
|
667 668 669 |
this.snackbar = true; this.text = "Successfully delete Existing News"; this.getEBooksList(); |
687e0b929
|
670 |
}) |
058c4a6cf
|
671 |
.catch((error) => { |
6c05a9f84
|
672 673 |
this.snackbar = true; this.text = error.response.data.message; |
687e0b929
|
674 675 |
}); }, |
687e0b929
|
676 |
close() { |
710438de6
|
677 |
this.editEbookDialog = false; |
687e0b929
|
678 679 |
}, close1() { |
710438de6
|
680 |
this.viewEbookDialog = false; |
687e0b929
|
681 |
}, |
8e8d14254
|
682 683 |
closeAddEBookModel() { this.addEBookDialog = false; |
2f9211c74
|
684 |
// this.eBookData = []; |
8e8d14254
|
685 686 687 688 689 |
this.addEBooks = []; this.imageName = ""; this.fileName = ""; this.files = ""; }, |
687e0b929
|
690 |
submit() { |
687e0b929
|
691 |
if (this.$refs.form.validate()) { |
109a6218c
|
692 |
this.loading = true; |
a76a6f135
|
693 694 |
var uploadCover = ""; var uploadFile = ""; |
687e0b929
|
695 |
if (this.files) { |
ab54b5656
|
696 |
const [baseUrl, imageUrl] = this.files.split(/,/); |
a76a6f135
|
697 698 |
uploadCover = imageUrl; console.log("anyFile.split(/,/)", uploadCover); |
ab54b5656
|
699 700 701 |
} if (this.anyFile) { const [baseUrl, fileUrl] = this.anyFile.split(/,/); |
a76a6f135
|
702 703 |
uploadFile = fileUrl; console.log("anyFile.split(/,/)", uploadFile); |
687e0b929
|
704 |
} |
710438de6
|
705 706 707 708 709 |
let data = { classId: this.addEBooks.classId, name: this.addEBooks.name, author: this.addEBooks.author, private: this.addEBooks.private, |
a76a6f135
|
710 |
uploadCover: uploadCover, |
058c4a6cf
|
711 |
uploadFile: uploadFile, |
710438de6
|
712 |
}; |
687e0b929
|
713 |
http() |
710438de6
|
714 |
.post("/createEBook", data) |
058c4a6cf
|
715 |
.then((response) => { |
a76a6f135
|
716 717 |
this.getEBooksList(); // this.getEBooksList = []; |
68d742034
|
718 |
this.addEBookDialog = false; |
109a6218c
|
719 |
this.snackbar = true; |
710438de6
|
720 721 |
this.text = response.data.message; this.color = "green"; |
687e0b929
|
722 |
this.loading = false; |
109a6218c
|
723 |
(this.imageName = ""), (this.fileName = ""); |
687e0b929
|
724 |
}) |
058c4a6cf
|
725 |
.catch((error) => { |
6c05a9f84
|
726 727 |
this.snackbar = true; this.text = error.response.data.message; |
710438de6
|
728 |
this.color = "red"; |
687e0b929
|
729 730 731 732 733 |
}); } }, clear() { this.$refs.form.reset(); |
495e4037c
|
734 735 |
this.addEBooks.uploadCover = ""; this.files = ""; |
687e0b929
|
736 737 |
}, save() { |
109a6218c
|
738 |
this.editLoading = true; |
6c05a9f84
|
739 |
this.loadingUpadte = true; |
109a6218c
|
740 741 |
if (this.editFiles) { const [baseUrl, imageUrl] = this.editFiles.split(/,/); |
6c05a9f84
|
742 743 |
this.editedItem.uploadCover = imageUrl; // console.log("anyFile.split(/,/)", this.addEBooks.uploadCover); |
687e0b929
|
744 |
} |
109a6218c
|
745 746 |
if (this.editAnyFile) { const [baseUrl, fileUrl] = this.editAnyFile.split(/,/); |
6c05a9f84
|
747 748 |
this.editedItem.uploadFile = fileUrl; // console.log("anyFile.split(/,/)", this.addEBooks.uploadFile); |
ab54b5656
|
749 |
} |
109a6218c
|
750 751 752 |
if (this.editedItem.classId._id) { this.editedItem.classId = this.editedItem.classId._id; } |
6c05a9f84
|
753 |
this.editedItem.ebookId = this.editedItem._id; |
109a6218c
|
754 |
console.log("this.editedItem", this.editedItem); |
687e0b929
|
755 |
http() |
6c05a9f84
|
756 |
.put("/updateEBook", this.editedItem) |
058c4a6cf
|
757 |
.then((response) => { |
6c05a9f84
|
758 759 760 761 |
this.loadingUpadte = false; this.snackbar = true; this.text = "Successfully Edit Existing E-Book"; this.getEBooksList(); |
109a6218c
|
762 |
this.editLoading = false; |
6c05a9f84
|
763 764 765 766 |
this.editedItem.uploadFile = ""; this.editedItem.uploadCover = ""; this.anyFile = ""; this.files = ""; |
687e0b929
|
767 768 |
this.close(); }) |
058c4a6cf
|
769 |
.catch((error) => { |
109a6218c
|
770 |
this.editLoading = false; |
6c05a9f84
|
771 772 773 |
this.loadingUpadte = false; this.snackbar = true; this.text = error.response.data.message; |
687e0b929
|
774 775 |
// console.log(error); }); |
ab54b5656
|
776 777 778 779 |
}, getAllClass() { http() .get("/getClassesList", { |
058c4a6cf
|
780 |
headers: { Authorization: "Bearer " + this.token }, |
ab54b5656
|
781 |
}) |
058c4a6cf
|
782 |
.then((response) => { |
ab54b5656
|
783 784 |
this.addClass = response.data.data; }) |
058c4a6cf
|
785 |
.catch((err) => { |
ab54b5656
|
786 787 788 |
// console.log("err====>", err); // this.$router.replace({ path: "/" }); }); |
68d742034
|
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
|
797 |
}, |
687e0b929
|
798 799 |
}, mounted() { |
ab54b5656
|
800 |
this.token = this.$store.state.token; |
6c05a9f84
|
801 |
this.getEBooksList(); |
ab54b5656
|
802 |
this.getAllClass(); |
058c4a6cf
|
803 |
this.role = this.$store.state.role; |
006544386
|
804 |
// this.getBookData(); |
ab54b5656
|
805 |
// this.editItem; |
058c4a6cf
|
806 |
}, |
687e0b929
|
807 |
}; |
68d742034
|
808 |
</script> |