Blame view
src/pages/Gallery/gallery.vue
31.4 KB
8bb178441
|
1 2 |
<template> <v-app id="pages-dasboard"> |
687e0b929
|
3 |
<v-tabs grow slider-color="gray"> |
8bb178441
|
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<v-tab ripple @click="activeTab('existing')" v-bind:class="{ active: isActive }" id="tab" class="subheading" >Existing Gallery</v-tab> <v-tab ripple @click="activeTab('new')" v-bind:class="{ active: newActive }" id="tab1" User class="subheading" >Add Gallery</v-tab> <!-- ****** EDITS ALL Gallery DETAILS ****** --> <v-tab-item> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> <v-dialog v-model="dialog" max-width="1000px" scrollable> <v-card flat> <v-toolbar class="grey lighten-2" flat> <v-spacer></v-spacer> <v-toolbar-title> <h3>Edit Gallery</h3> </v-toolbar-title> <v-spacer></v-spacer> </v-toolbar> |
a17c68a03
|
40 |
<v-card-text style="height:700px;"> |
f4df757fe
|
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<v-layout row> <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center my-4" > <input type="file" style="display: none" ref="editImage" accept="image/*" multiple @change="editFilePicked" /> <v-layout justify-center> |
8bb178441
|
55 |
<v-flex |
f4df757fe
|
56 57 58 59 60 61 62 |
xs6 sm12 md3 v-for="Image in editedItem.imageUrl" :key="Image._id" v-if="editedItem.imageUrl" class="profile-image-wrapper imgNews" |
8bb178441
|
63 |
> |
8bb178441
|
64 |
<img |
f4df757fe
|
65 |
:src="Image.imageLink" |
8bb178441
|
66 67 68 |
height="160" width="160" alt="Gallery" |
f4df757fe
|
69 |
class="pa-2 imgNews" |
8bb178441
|
70 |
/> |
f4df757fe
|
71 72 73 74 75 76 77 78 |
<v-icon class="red edit-profile-icon" dark @click="deleteImage(Image._id,editedItem._id)" >close</v-icon> </v-flex> <v-flex v-for="(file, index) in editFiles" :key="index"> <img :src="file" height="160" width="160" class="pa-2 imgNews" /> |
8bb178441
|
79 80 |
</v-flex> </v-layout> |
f4df757fe
|
81 82 83 84 85 86 87 88 89 90 91 |
<img src="/static/icon/user.png" v-if="editedItem.imageUrl == '' && editFiles == ''" height="160" width="160" alt="Gallery" /> </v-flex> </v-layout> <v-layout wrap> <v-flex xs12 sm12> |
8bb178441
|
92 |
<v-layout> |
f4df757fe
|
93 94 |
<v-flex xs4 class="pt-4 subheading"> <label class="right">Title:</label> |
8bb178441
|
95 |
</v-flex> |
f4df757fe
|
96 97 98 99 100 101 102 103 |
<v-flex xs8 sm5 class="ml-3"> <v-text-field v-model="editedItem.title" placeholder="fill your Title" name="name" type="text" required ></v-text-field> |
8bb178441
|
104 |
</v-flex> |
f4df757fe
|
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
</v-layout> </v-flex> <v-flex xs12 sm12> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Description:</label> </v-flex> <v-flex xs8 sm5 class="ml-3"> <v-text-field placeholder="fill your Description" v-model="editedItem.description" type="text" name="email" required ></v-text-field> |
8bb178441
|
120 121 |
</v-flex> </v-layout> |
f4df757fe
|
122 123 124 125 126 |
</v-flex> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right hidden-xs-only hidden-sm-only">Select Class:</label> <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Class:</label> |
a17c68a03
|
127 |
</v-flex> |
f4df757fe
|
128 129 130 131 132 133 134 135 136 137 |
<v-flex xs8 sm5 class="ml-3"> <v-select :items="addclass" label="Select Class" v-model="editedItem.classNum" item-text="classNum" item-value="_id" name="Select Class" required ></v-select> |
a17c68a03
|
138 |
</v-flex> |
f4df757fe
|
139 140 |
</v-layout> <v-flex xs12> |
8bb178441
|
141 |
<v-layout> |
f4df757fe
|
142 143 144 145 146 147 148 149 150 151 152 153 |
<v-flex xs4 class="pt-4 subheading"> <label class="right hidden-xs-only hidden-sm-only">Add New Images:</label> <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Upload:</label> </v-flex> <v-flex xs8 sm5 class="ml-3"> <v-text-field label="Select Image" @click="editPickFile" v-model="editImageName" append-icon="attach_file" multiple ></v-text-field> |
8bb178441
|
154 155 |
</v-flex> </v-layout> |
f4df757fe
|
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
</v-flex> </v-layout> <v-flex xs12> <div v-for="(editImage,index) in editedItem.youTubeLinkUrl" :key="index" v-if="editImage.youTubeLink !=[]" > <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">You Tube Link Url:</label> </v-flex> <v-flex xs8 sm5 class="ml-3"> <v-text-field v-model="editImage.youTubeLink" type="text" name="link" required ></v-text-field> </v-flex> <v-flex xs2 class="pt-4"> <v-icon @click="deleteUrl(index,editImage._id,editedItem._id)">cancel</v-icon> </v-flex> </v-layout> </div> </v-flex> <v-flex xs12> <div v-for="(updateImage,index) in updates" :key="index"> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">You Tube Url:</label> </v-flex> <v-flex xs5 sm5 class="ml-3"> <v-text-field v-model="updateImage.youTubeLink" label="Upload new you tube link url" required ></v-text-field> </v-flex> <v-flex xs2 class="pt-4"> <v-icon @click="deleteUpdate(index)" v-if="index !=0">cancel</v-icon> <v-icon @click="update">add_circle</v-icon> </v-flex> </v-layout> </div> </v-flex> <v-layout> <v-flex xs12 sm8 offset-sm2> <v-card-actions> <v-btn round dark @click.native="close">Cancel</v-btn> <v-spacer></v-spacer> <v-btn round dark @click="save">Save</v-btn> </v-card-actions> </v-flex> </v-layout> <!-- </v-container> </v-form>--> |
8bb178441
|
213 214 215 216 217 |
</v-card-text> </v-card> </v-dialog> <!-- ****** PROFILE VIEW Gallery ****** --> |
1571e40b5
|
218 |
<v-dialog v-model="dialog1" max-width="940px"> |
8bb178441
|
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
<v-card> <v-toolbar color="grey lighten-2" flat> <v-spacer></v-spacer> <v-toolbar-title> <h3>Gallery</h3> </v-toolbar-title> <v-spacer></v-spacer> <v-icon @click="close1">close</v-icon> </v-toolbar> <v-flex align-center justify-center layout text-xs-center> <v-avatar size="100" v-if="editedItem.imageUrl == ''" class="mt-4 pa-2"> <img src="/static/icon/user.png" width="240" height="180" /> </v-avatar> <span v-for="(image,i) in editedItem.imageUrl" :key="i" class="mt-4 pa-2" v-if="editedItem.imageUrl" > |
f4df757fe
|
238 |
<img :src="image.imageLink" alt="Gallery" width="240" height="180" class="imgNews" /> |
8bb178441
|
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
</span> </v-flex> <v-card-text> <v-container grid-list-md> <v-layout wrap> <v-flex> <v-layout> <v-flex xs5 sm6> <h5 class="right my-1"> <b>Title:</b> </h5> </v-flex> <v-flex sm6 xs8> <h5 class="my-1">{{ editedItem.title }}</h5> </v-flex> </v-layout> <v-layout> <v-flex xs5 sm6> <h5 class="right my-1"> <b>Description:</b> </h5> </v-flex> <v-flex sm6 xs8> <h5 class="my-1">{{ editedItem.description }}</h5> </v-flex> </v-layout> |
a17c68a03
|
265 266 267 268 269 270 271 |
<v-layout> <v-flex xs5 sm6> <h5 class="right my-1"> <b>You Tube Link Url:</b> </h5> </v-flex> <v-flex sm6 xs8> |
1571e40b5
|
272 273 274 275 |
<h5 class="my-1 ml-3"> <ul v-for="youTubeLinkUrl in editedItem.youTubeLinkUrl"> <li>{{ youTubeLinkUrl.youTubeLink }}</li> </ul> |
a17c68a03
|
276 277 278 |
</h5> </v-flex> </v-layout> |
8bb178441
|
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
</v-flex> </v-layout> </v-container> </v-card-text> </v-card> </v-dialog> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> <!-- ****** EXISTING-USERS Gallery TABLE ****** --> <v-data-table :headers="headers" :items="desserts" :pagination.sync="pagination" :search="search" > <template slot="items" slot-scope="props"> |
aa8fc5033
|
303 |
<td class="text-xs-center">{{ props.index + 1}}</td> |
8bb178441
|
304 305 |
<td id="td" class="text-xs-center"> <span v-for="(image,_id) in props.item.imageUrl" class="pa-2"> |
a17c68a03
|
306 |
<img :src="image.imageLink" alt="newsImage" width="100" height="70" /> |
8bb178441
|
307 308 309 310 |
</span> </td> <td id="td" class="text-xs-center">{{ props.item.title}}</td> <td id="td" class="text-xs-center">{{ props.item.description}}</td> |
a17c68a03
|
311 |
<td id="td" class="text-xs-center"> |
495e4037c
|
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
<span> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:25px; height:18px; " class="mr5" @click="profile(props.item)" src="/static/icon/eye1.png" /> <span>View</span> </v-tooltip> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:20px; height:18px; " class="mr5" @click="editItem(props.item)" src="/static/icon/edit1.png" /> <span>Edit</span> </v-tooltip> <v-tooltip top> <img slot="activator" style="cursor:pointer; width:20px; height:20px; " class="mr5" @click="deleteItem(props.item)" src="/static/icon/delete1.png" /> <span>Delete</span> </v-tooltip> |
8bb178441
|
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 |
</span> </td> </template> <v-alert slot="no-results" :value="true" color="error" icon="warning" >Your search for "{{ search }}" found no results.</v-alert> </v-data-table> </v-tab-item> <!-- ****** ADD MULTIPLE Gallery Data ****** --> <v-tab-item> <v-container> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> <v-flex xs12 sm12 class="my-4"> <v-card flat> <v-form ref="form" v-model="valid" lazy-validation> <v-container fluid> <v-layout> <v-flex xs12 |
f4df757fe
|
374 |
class="text-xs-center text-sm-center text-md-center text-lg-center my-4" |
8bb178441
|
375 376 377 378 379 380 381 382 383 384 385 |
> <input type="file" style="display: none" ref="image" accept="image/*" multiple @change="onFilePicked" /> <v-layout justify-center> <v-flex v-for="(file,index) in files" :key="index" v-if="files"> |
f4df757fe
|
386 |
<img :src="file" height="160" width="160px;" class="imgNews" /> |
8bb178441
|
387 388 389 390 391 392 393 |
</v-flex> </v-layout> <img src="/static/icon/user.png" v-if="files ==''" height="140" width="180px;" |
f4df757fe
|
394 |
class="imgNews" |
8bb178441
|
395 396 397 398 399 400 401 402 |
/> </v-flex> </v-layout> <v-flex xs12> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Title:</label> </v-flex> |
aa8fc5033
|
403 |
<v-flex xs8 sm4 class="ml-3"> |
8bb178441
|
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
<v-text-field v-model="addGallery.title" placeholder="fill your Title" name="name" type="text" :rules="titleRules" required ></v-text-field> </v-flex> </v-layout> </v-flex> <v-flex xs12> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Description:</label> </v-flex> |
aa8fc5033
|
420 |
<v-flex xs8 sm4 class="ml-3"> |
8bb178441
|
421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
<v-text-field placeholder="fill your Description" :rules="descriptionRules" v-model="addGallery.description" type="text" name="email" required ></v-text-field> </v-flex> </v-layout> </v-flex> <v-flex xs12> <v-layout> <v-flex xs4 class="pt-4 subheading"> |
aa8fc5033
|
435 436 |
<label class="right hidden-xs-only hidden-sm-only">Select Class:</label> <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Class:</label> |
8bb178441
|
437 |
</v-flex> |
aa8fc5033
|
438 |
<v-flex xs8 sm4 class="ml-3"> |
8bb178441
|
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
<v-select :items="addclass" label="Select Class" v-model="addGallery.classNum" item-text="classNum" item-value="_id" name="Select Class" required ></v-select> </v-flex> </v-layout> </v-flex> <v-flex xs12> <v-layout> <v-flex xs4 class="pt-4 subheading"> |
aa8fc5033
|
454 455 |
<label class="right hidden-xs-only hidden-sm-only">Uplaod Image:</label> <label class="right hidden-lg-only hidden-md-only hidden-xl-only">Uplaod:</label> |
8bb178441
|
456 |
</v-flex> |
aa8fc5033
|
457 |
<v-flex xs8 sm4 class="ml-3"> |
8bb178441
|
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
<v-text-field label="Select Image" @click="pickFile" v-model="imageName" append-icon="attach_file" multiple ></v-text-field> </v-flex> </v-layout> </v-flex> <v-layout> <v-flex xs12> <div v-for="(youTubeLink,index) in finds" :key="index"> <v-layout> <v-flex xs4 class="pt-4 subheading"> |
f4df757fe
|
473 |
<label class="right">You Tube Url:</label> |
8bb178441
|
474 |
</v-flex> |
f4df757fe
|
475 |
<v-flex xs6 sm4 class="ml-3"> |
8bb178441
|
476 477 478 479 480 481 482 |
<v-text-field placeholder="fill your youtube link" v-model="youTubeLink.value" type="text" name="link" required ></v-text-field> |
8bb178441
|
483 484 |
</v-flex> <v-flex xs2 class="pt-4"> |
a17c68a03
|
485 |
<v-icon @click="deleteFind(index)" v-if="index !=0 ">cancel</v-icon> |
8bb178441
|
486 487 488 489 490 |
<v-icon @click="addFind">add_circle</v-icon> </v-flex> </v-layout> </div> </v-flex> |
f4df757fe
|
491 492 493 494 495 496 497 498 499 500 501 502 |
<v-layout> <v-flex xs12 sm5 offset-sm3> <v-layout> <v-flex xs6> <v-btn @click="clear" round class="ml-3" dark>clear</v-btn> </v-flex> <v-flex xs6> <v-btn @click="submit" round dark :loading="loading" class="right">Add</v-btn> </v-flex> </v-layout> </v-flex> </v-layout> |
8bb178441
|
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
</v-layout> </v-container> </v-form> </v-card> </v-flex> </v-container> </v-tab-item> </v-tabs> <div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> </v-app> </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: "", loading: false, date: null, search: "", showLoader: false, dialog: false, dialog1: false, valid: true, isActive: true, newActive: false, addclass: [], addSection: [], finds: [{ value: "" }], |
a17c68a03
|
541 542 |
updates: [{ youTubeLink: "" }], youTubeLink: {}, |
8bb178441
|
543 544 545 546 547 548 549 550 551 552 553 |
addGallery: { youTubeLinkUrl: [] }, pagination: { rowsPerPage: 15 }, imageName: "", imageUrl: "", imageFile: "", image: [], upload: "", |
a17c68a03
|
554 555 |
editImageName: "", editFiles: [], |
8bb178441
|
556 |
files: [], |
8bb178441
|
557 558 559 560 561 562 563 564 |
token: "", titleRules: [v => !!v || " Tilte is required"], descriptionRules: [v => !!v || " Description is required"], headers: [ { align: "justify-center", text: "No", sortable: false, |
1571e40b5
|
565 |
value: "index" |
8bb178441
|
566 567 568 569 570 571 572 573 574 575 576 577 578 |
}, { text: "Image", vaue: "image", sortable: false, align: "center" }, { text: "Title", value: "title", sortable: false, align: "center" }, { text: "Description", value: "description", sortable: false, align: "center" }, { text: "Action", value: "", sortable: false, align: "center" } ], desserts: [], editedIndex: -1, |
1571e40b5
|
579 580 |
editedItem: {}, index: "" |
8bb178441
|
581 582 |
}), methods: { |
8bb178441
|
583 584 585 |
pickFile() { this.$refs.image.click(); }, |
a17c68a03
|
586 587 588 |
editPickFile() { this.$refs.editImage.click(); }, |
8bb178441
|
589 |
onFilePicked(e) { |
8bb178441
|
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
const files = e.target.files; /** fetch Image Name **/ if (files[0] !== undefined) { this.imageName = files[0].name; if (this.imageName.lastIndexOf(".") <= 0) { return; } this.files = []; // console.log("files", this.files); /** Select many image and showing many image add to Gallery card **/ const test = Array.from(files).forEach((file, idx) => { const fr = new FileReader(); const getResult = new Promise(resolve => { fr.onload = e => { this.files.push( // id: idx, e.target.result ); }; |
a17c68a03
|
609 |
console.log("uploadImage=======>", this.files); |
8bb178441
|
610 611 612 613 614 615 616 617 618 619 |
}); fr.readAsDataURL(file); return getResult.then(file => { return file; }); }); const fr = new FileReader(); fr.readAsDataURL(files[0]); fr.addEventListener("load", () => { this.imageFile = files; // this is an image file that can be sent to server... |
8bb178441
|
620 621 622 623 624 625 626 |
}); } else { this.imageName = ""; this.imageFile = ""; this.imageUrl = ""; } }, |
a17c68a03
|
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
editFilePicked(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 Gallery card **/ const test = Array.from(files).forEach((file, idx) => { const fr = new FileReader(); const getResult = new Promise(resolve => { fr.onload = e => { this.editFiles.push( // id: idx, e.target.result ); }; console.log("uploadImage=======>", this.files); }); fr.readAsDataURL(file); return getResult.then(file => { return file; }); }); const fr = new FileReader(); fr.readAsDataURL(files[0]); // fr.addEventListener("load", () => { // this.imageFile = files; // this is an image file that can be sent to server... // }); } else { this.editImageName = ""; this.editFiles = ""; } }, |
8bb178441
|
662 663 664 665 666 667 668 669 670 671 |
getGalleryList() { this.showLoader = true; http() .get("/getGalleryList", { headers: { Authorization: "Bearer " + this.token } }) .then(response => { this.desserts = response.data.data; this.showLoader = false; }) |
1571e40b5
|
672 |
.catch(error => { |
8bb178441
|
673 674 |
// console.log("err====>", err); this.showLoader = false; |
a17c68a03
|
675 676 677 678 679 |
if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } |
8bb178441
|
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
}); }, editItem(item) { this.files = []; this.editedIndex = this.desserts.indexOf(item); this.editedItem = Object.assign({}, item); this.dialog = true; }, profile(item) { this.editedIndex = this.desserts.indexOf(item); this.editedItem = Object.assign({}, item); this.dialog1 = true; }, deleteItem(item) { let deleteGallery = { |
a17c68a03
|
695 |
galleryId: item._id |
8bb178441
|
696 697 698 |
}; http() .delete( |
a17c68a03
|
699 |
"/deleteGallery", |
8bb178441
|
700 |
confirm("Are you sure you want to delete this?") && { |
a17c68a03
|
701 702 703 704 |
params: deleteGallery, headers: { Authorization: "Bearer " + this.token } |
8bb178441
|
705 706 707 708 |
} ) .then(response => { if ((this.snackbar = true)) { |
2ddcef1ce
|
709 |
this.text = "Successfully delete Existing Gallery"; |
8bb178441
|
710 |
} |
a17c68a03
|
711 |
this.getGalleryList(); |
8bb178441
|
712 713 714 715 716 |
}) .catch(error => { // console.log(error); }); }, |
a17c68a03
|
717 718 |
deleteImage(imageId, id) { console.log("imageId", imageId, "id", id); |
8bb178441
|
719 |
let deleteImages = { |
a17c68a03
|
720 |
galleryId: id, |
8bb178441
|
721 722 723 |
imageId: imageId }; http() |
a17c68a03
|
724 |
.put("/deleteImage", deleteImages) |
8bb178441
|
725 |
.then(response => { |
a17c68a03
|
726 727 728 |
this.snackbar = true; this.text = response.data.message; this.getGalleryList(); |
8bb178441
|
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
this.close(); }) .catch(error => { console.log(error); }); }, activeTab(type) { switch (type) { case "existing": this.newActive = false; this.isActive = true; break; default: this.newActive = true; this.isActive = false; break; } }, close() { this.dialog = false; setTimeout(() => { this.editedItem = Object.assign({}, this.defaultItem); this.editedIndex = -1; }, 300); }, close1() { this.dialog1 = false; }, submit() { this.loading = true; |
a17c68a03
|
760 761 762 |
for (let i = 0; i < this.finds.length; i++) { this.addGallery.youTubeLinkUrl.push(this.finds[i].value); } |
8bb178441
|
763 764 765 766 767 768 769 770 771 772 773 |
if (this.$refs.form.validate()) { if (this.files) { var ary = []; var imageData = []; ary = this.files; for (let i = 0; i < ary.length; i++) { const [baseUrl, imageUrl] = ary[i].split(/,/); imageData.push(imageUrl); this.addGallery.upload = imageData; } } |
2ddcef1ce
|
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
if (this.addGallery.youTubeLinkUrl == "") { var galleryData = { classId: this.addGallery.classNum, title: this.addGallery.title, description: this.addGallery.description, upload: this.addGallery.upload }; http() .post("/createGallery", galleryData) .then(response => { this.getGalleryList(); this.loading = false; this.snackbar = true; this.text = response.data.message; this.clear(); this.files = ""; }) .catch(error => { if ((this.snackbar = true)) { this.text = error.response.data.message; } }); } else if (this.addGallery.youTubeLinkUrl) { http() .post("/createGallery", this.addGallery) .then(response => { this.getGalleryList(); |
0551a0f15
|
801 |
this.files = []; |
2ddcef1ce
|
802 803 804 805 806 807 808 809 810 811 812 813 |
this.loading = false; this.snackbar = true; this.text = response.data.message; this.clear(); this.files = ""; }) .catch(error => { if ((this.snackbar = true)) { this.text = error.response.data.message; } }); } |
8bb178441
|
814 815 816 817 |
} }, clear() { this.$refs.form.reset(); |
0551a0f15
|
818 |
this.files = []; |
8bb178441
|
819 820 821 |
}, save() { this.editedItem.gelleryId = this.editedItem._id; |
1571e40b5
|
822 |
var linkUrl = []; |
a17c68a03
|
823 |
for (let i = 0; i < this.updates.length; i++) { |
1571e40b5
|
824 |
linkUrl.push(this.updates[i].youTubeLink); |
a17c68a03
|
825 |
} |
1571e40b5
|
826 |
if (this.editFiles) { |
8bb178441
|
827 828 |
var ary = []; var imageData = []; |
1571e40b5
|
829 |
ary = this.editFiles; |
8bb178441
|
830 831 832 |
for (let i = 0; i < ary.length; i++) { const [baseUrl, imageUrl] = ary[i].split(/,/); imageData.push(imageUrl); |
1571e40b5
|
833 |
this.editedItem.editFiles = imageData; |
8bb178441
|
834 835 |
} } |
1571e40b5
|
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 |
if (linkUrl != "") { var updateData = { galleryId: this.editedItem._id, description: this.editedItem.description, classId: this.editedItem.classNum, uploadImage: this.editedItem.editFiles, title: this.editedItem.title, updateYouTubeLinkUrl: linkUrl }; } else if (linkUrl == "") { var updateData = { galleryId: this.editedItem._id, description: this.editedItem.description, classId: this.editedItem.classNum, uploadImage: this.editedItem.editFiles, title: this.editedItem.title }; } http() .put("/updateGallery", updateData) .then(response => { this.getGalleryList(); this.close(); this.snackbar = true; this.text = response.data.message; }) .catch(error => { console.log(error); }); |
8bb178441
|
865 866 867 868 869 870 871 872 873 874 875 |
}, getAllClasses() { http() .get("/getClassesList", { headers: { Authorization: "Bearer " + this.token } }) .then(response => { this.addclass = response.data.data; }) .catch(err => { // console.log("err====>", err); |
8bb178441
|
876 877 |
}); }, |
8bb178441
|
878 879 880 |
addFind: function() { this.finds.push({ value: "" }); }, |
a17c68a03
|
881 882 883 |
update: function() { this.updates.push({ youTubeLink: "" }); }, |
8bb178441
|
884 885 886 |
deleteFind: function(index) { this.finds.splice(index, 1); if (index === 0) this.addFind(); |
a17c68a03
|
887 888 889 890 891 |
}, deleteUpdate: function(index) { this.updates.splice(index, 1); if (index === 0) this.update(); }, |
1571e40b5
|
892 |
deleteUrl: function(index, youTubelinkId, id) { |
a17c68a03
|
893 894 |
this.editedItem.youTubeLinkUrl.splice(index, 1); if (index === 0) this.update(); |
a17c68a03
|
895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
let deleteYouTubeUrl = { galleryId: id, youTubeId: youTubelinkId }; http() .put("/deleteYoutubeLink", deleteYouTubeUrl) .then(response => { this.snackbar = true; this.text = response.data.message; this.getGalleryList(); this.close(); }) .catch(error => { console.log(error); }); |
8bb178441
|
910 911 912 913 914 915 |
} }, mounted() { this.token = this.$store.state.token; this.getAllClasses(); this.getGalleryList(); |
1571e40b5
|
916 |
// console.log("index",index); |
8bb178441
|
917 |
}, |
a17c68a03
|
918 919 920 921 922 923 924 925 |
created() { this.$root.$on("app:search", search => { this.search = search; }); }, beforeDestroy() { // dont forget to remove the listener this.$root.$off("app:search"); |
8bb178441
|
926 927 928 929 |
} }; </script> <style scoped> |
8bb178441
|
930 931 932 |
#td { border: 1px solid #dddddd; text-align: left; |
a17c68a03
|
933 934 |
padding: 2px 0px; max-width: 200px; |
8bb178441
|
935 936 |
} .active { |
687e0b929
|
937 |
background-color: gray; |
8bb178441
|
938 939 940 941 942 |
color: white !important; } .activebtn { color: black !important; } |
8bb178441
|
943 |
</style> |