Blame view
src/pages/NoticeBoard/noticeBoard.vue
19 KB
beb598536
|
1 2 |
<template> <v-app id="pages-dasboard"> |
687e0b929
|
3 |
<v-tabs grow slider-color="gray"> |
beb598536
|
4 5 6 7 8 9 |
<v-tab ripple @click="activeTab('existing')" v-bind:class="{ active: isActive }" id="tab" class="subheading" |
46db0a3b5
|
10 |
>Existing Notice Board</v-tab> |
beb598536
|
11 12 13 14 15 16 17 |
<v-tab ripple @click="activeTab('new')" v-bind:class="{ active: newActive }" id="tab1" User class="subheading" |
46db0a3b5
|
18 |
>Add New Notice Board</v-tab> |
beb598536
|
19 |
|
f4df757fe
|
20 |
<!-- ****** Edit Notice Board ****** --> |
beb598536
|
21 22 23 24 25 26 27 28 29 30 |
<v-tab-item> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" color="success" >{{ text }}</v-snackbar> |
756b14fe2
|
31 |
<v-dialog v-model="dialog" max-width="640px" scrollable> |
f4df757fe
|
32 |
<v-card> |
756b14fe2
|
33 |
<v-toolbar color="grey lighten-2" flat> |
beb598536
|
34 |
<v-spacer></v-spacer> |
46db0a3b5
|
35 |
<v-toolbar-title> |
756b14fe2
|
36 |
<h3>Edit Notice Board</h3> |
46db0a3b5
|
37 |
</v-toolbar-title> |
beb598536
|
38 39 |
<v-spacer></v-spacer> </v-toolbar> |
756b14fe2
|
40 |
<v-card-text> |
f4df757fe
|
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
<v-layout> <v-flex xs12 class="text-xs-center text-sm-center text-md-center text-lg-center"> <img src="/static/icon/user.png" v-if="!editedItem.eventImageUrl && !imageUrl" width="150px" /> <img :src="editedItem.eventImageUrl" height="150" v-else-if="editedItem.eventImageUrl && !imageUrl" width="180px" /> <img v-if="imageUrl" :src="imageUrl" height="150" style="border-radius:50%; width:200px" /> <input type="file" style="display: none" ref="image" accept="image/*" @change="onFilePicked" /> </v-flex> </v-layout> <v-layout wrap> <v-flex xs12> |
beb598536
|
71 |
<v-layout> |
f4df757fe
|
72 73 74 75 76 77 78 79 80 81 82 |
<v-flex xs4 class="pt-4 subheading"> <label class="right">Title:</label> </v-flex> <v-flex xs6 class="ml-3"> <v-text-field v-model="editedItem.title" placeholder="fill your Title" name="name" type="text" required ></v-text-field> |
beb598536
|
83 84 |
</v-flex> </v-layout> |
f4df757fe
|
85 86 |
</v-flex> <v-flex xs12> |
beb598536
|
87 |
<v-layout> |
f4df757fe
|
88 89 |
<v-flex xs4 class="pt-4 subheading"> <label class="right">Description:</label> |
756b14fe2
|
90 |
</v-flex> |
f4df757fe
|
91 92 93 94 95 96 97 98 |
<v-flex xs6 class="ml-3"> <v-text-field placeholder="fill your Description" v-model="editedItem.description" type="text" name="email" required ></v-text-field> |
756b14fe2
|
99 |
</v-flex> |
f4df757fe
|
100 101 102 103 104 105 106 |
</v-layout> </v-flex> <v-flex xs12> <v-layout> <v-flex xs4 class="pt-4 subheading"> <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> |
756b14fe2
|
107 |
</v-flex> |
f4df757fe
|
108 109 110 111 112 113 114 |
<v-flex xs6 class="ml-3"> <v-text-field label="Select Image" @click="pickFile" v-model="imageName" append-icon="attach_file" ></v-text-field> |
beb598536
|
115 116 |
</v-flex> </v-layout> |
f4df757fe
|
117 118 119 120 121 122 123 124 125 |
</v-flex> <v-flex xs12 sm9 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> |
756b14fe2
|
126 127 |
</v-card-text> </v-card> |
beb598536
|
128 |
</v-dialog> |
46db0a3b5
|
129 |
<!-- ****** VIEW PROFIL NOTICE BOARD ****** --> |
beb598536
|
130 |
|
2d0fc1144
|
131 |
<v-dialog v-model="dialog1" max-width="640px" scrollable> |
f4df757fe
|
132 |
<v-card> |
2d0fc1144
|
133 134 135 136 137 138 139 140 |
<v-toolbar color="grey lighten-2" flat> <v-spacer></v-spacer> <v-toolbar-title> <h3>Notice Board</h3> </v-toolbar-title> <v-spacer></v-spacer> <v-icon @click="close1">close</v-icon> </v-toolbar> |
beb598536
|
141 |
<v-card-text> |
f4df757fe
|
142 143 144 145 146 147 148 149 150 151 152 |
<v-layout> <v-flex align-center justify-center layout text-xs-center class="mt-2"> <img src="/static/icon/user.png" v-if="!editedItem.eventImageUrl" width="130px" /> <img :src="editedItem.eventImageUrl" v-else-if="editedItem.eventImageUrl" class="img" width="200" /> </v-flex> </v-layout> |
beb598536
|
153 154 155 |
<v-container grid-list-md> <v-layout wrap> <v-flex> |
beb598536
|
156 157 |
<v-layout> <v-flex xs5 sm6> |
f4df757fe
|
158 159 160 |
<h5 class="right my-1"> <b>Title:</b> </h5> |
beb598536
|
161 162 163 164 165 166 167 |
</v-flex> <v-flex sm6 xs8> <h5 class="my-1">{{ editedItem.title }}</h5> </v-flex> </v-layout> <v-layout> <v-flex xs5 sm6> |
f4df757fe
|
168 169 170 |
<h5 class="right my-1"> <b>Description:</b> </h5> |
beb598536
|
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
</v-flex> <v-flex sm6 xs8> <h5 class="my-1">{{ editedItem.description }}</h5> </v-flex> </v-layout> </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> |
46db0a3b5
|
191 |
<!-- ****** EXISTING-USERS Notice Board TABLE ****** --> |
2b0e316ee
|
192 |
|
beb598536
|
193 194 195 196 197 198 199 |
<v-data-table :headers="headers" :items="desserts" :pagination.sync="pagination" :search="search" > <template slot="items" slot-scope="props"> |
f4df757fe
|
200 |
<td id="td" class="text-xs-center">{{ props.index + 1}}</td> |
beb598536
|
201 202 203 204 205 |
<td id="td" class="text-xs-center">{{ props.item.title}}</td> <td id="td" class="text-xs-center">{{ props.item.description}}</td> <td class="text-xs-center"> <span> |
495e4037c
|
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
<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> |
beb598536
|
236 237 238 239 240 241 242 243 244 245 246 |
</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> |
46db0a3b5
|
247 |
<!-- ****** ADD MULTIPLE Notice Board ****** --> |
beb598536
|
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
<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 sm8 offset-sm2 class="top"> <v-card flat> <v-container fluid fill-height> <v-layout align-center> <v-flex xs12> <v-form ref="form" v-model="valid" lazy-validation> <v-layout> <v-flex xs12 |
0551a0f15
|
268 |
class="text-xs-center text-sm-center text-md-center text-lg-center my-4" |
beb598536
|
269 270 |
> <v-avatar size="100px"> |
46db0a3b5
|
271 |
<img src="/static/icon/user.png" v-if="!imageUrl" /> |
beb598536
|
272 |
</v-avatar> |
2d0fc1144
|
273 |
<input |
beb598536
|
274 275 276 277 278 |
type="file" style="display: none" ref="image" accept="image/*" @change="onFilePicked" |
46db0a3b5
|
279 |
/> |
beb598536
|
280 |
<img |
2b0e316ee
|
281 |
:src="imageUrl" |
beb598536
|
282 283 284 |
height="150" v-if="imageUrl" style="border-radius:50%; width:200px" |
2d0fc1144
|
285 |
/> |
beb598536
|
286 287 288 289 290 291 292 293 |
</v-flex> </v-layout> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Title:</label> </v-flex> <v-flex xs6 class="ml-3"> <v-text-field |
46db0a3b5
|
294 |
v-model="addNoticeBoard.title" |
beb598536
|
295 296 297 298 299 300 301 302 |
placeholder="fill your Title" name="name" type="text" :rules="titleRules" required ></v-text-field> </v-flex> </v-layout> |
46db0a3b5
|
303 |
<v-layout> |
beb598536
|
304 305 306 307 308 |
<v-flex xs4 class="pt-4 subheading"> <label class="right">Description:</label> </v-flex> <v-flex xs6 class="ml-3"> <v-text-field |
46db0a3b5
|
309 |
v-model="addNoticeBoard.description" |
beb598536
|
310 311 312 313 314 315 316 317 |
placeholder="fill your Description" name="name" type="text" :rules="descriptionRules" required ></v-text-field> </v-flex> </v-layout> |
2d0fc1144
|
318 |
<v-layout> |
2b0e316ee
|
319 |
<v-flex xs4 class="pt-4 subheading"> |
aa8fc5033
|
320 321 |
<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> |
2b0e316ee
|
322 323 324 325 326 327 328 329 330 |
</v-flex> <v-flex xs6 class="ml-3"> <v-text-field label="Select Image" @click="pickFile" v-model="imageName" append-icon="attach_file" ></v-text-field> </v-flex> |
2d0fc1144
|
331 |
</v-layout> |
2b0e316ee
|
332 |
<v-layout> |
beb598536
|
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
<v-flex xs12 sm9 offset-sm2> <v-card-actions> <v-btn @click="clear" round dark>clear</v-btn> <v-spacer></v-spacer> <v-btn @click="submit" round dark :loading="loading">Add</v-btn> </v-card-actions> </v-flex> </v-layout> </v-form> </v-flex> </v-layout> </v-container> </v-card> </v-flex> </v-container> </v-tab-item> </v-tabs> |
36fc987df
|
350 351 352 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
beb598536
|
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
</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: "", |
fc82ac667
|
368 |
showLoader: false, |
beb598536
|
369 370 371 |
loading: false, date: null, search: "", |
beb598536
|
372 373 374 375 376 377 378 379 380 381 |
dialog: false, dialog1: false, valid: true, isActive: true, newActive: false, addclass: [], addSection: [], gender: ["Male", "Female"], AddUsercredentials: {}, pagination: { |
2b0e316ee
|
382 |
rowsPerPage: 19 |
beb598536
|
383 |
}, |
beb598536
|
384 385 386 |
imageName: "", imageUrl: "", imageFile: "", |
46db0a3b5
|
387 |
upload: "", |
beb598536
|
388 389 390 391 392 393 394 395 396 397 |
titleRules: [v => !!v || " Title is required"], descriptionRules: [v => !!v || " Description is required"], headers: [ { text: "No", align: "center", sortable: false, value: "No" }, { text: "Title", value: "title", sortable: false, align: "center" }, |
fc82ac667
|
398 399 400 401 402 403 |
{ text: "Description", value: "description", sortable: false, align: "center" }, |
beb598536
|
404 405 406 407 |
{ text: "Action", value: "", sortable: false, align: "center" } ], desserts: [], editedIndex: -1, |
46db0a3b5
|
408 |
addNoticeBoard: {}, |
beb598536
|
409 410 411 412 413 414 415 |
editedItem: { title: "", description: "" }, defaultItem: { title: "", description: "" |
a17c68a03
|
416 |
} |
beb598536
|
417 |
}), |
beb598536
|
418 419 420 421 |
methods: { pickFile() { this.$refs.image.click(); }, |
2d0fc1144
|
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 |
onFilePicked(e) { // console.log(e) const files = e.target.files; this.upload = e.target.files[0]; console.log("thisupload==>", this.upload); if (files[0] !== undefined) { this.imageName = files[0].name; if (this.imageName.lastIndexOf(".") <= 0) { return; } const fr = new FileReader(); fr.readAsDataURL(files[0]); fr.addEventListener("load", () => { this.imageUrl = fr.result; this.imageFile = files[0]; // this is an image file that can be sent to server... |
2d0fc1144
|
437 438 439 440 441 442 443 |
}); } else { this.imageName = ""; this.imageFile = ""; this.imageUrl = ""; } }, |
46db0a3b5
|
444 |
getNoticeDataList() { |
36fc987df
|
445 |
this.showLoader = true; |
beb598536
|
446 447 448 449 450 451 452 |
var token = this.$store.state.token; http() .get("/getEventsList", { headers: { Authorization: "Bearer " + token } }) .then(response => { this.desserts = response.data.data; |
36fc987df
|
453 |
this.showLoader = false; |
beb598536
|
454 |
}) |
00e4bc4e1
|
455 |
.catch(error => { |
36fc987df
|
456 |
this.showLoader = false; |
a17c68a03
|
457 458 459 460 461 |
if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } |
beb598536
|
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
}); }, editItem(item) { 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 deleteEvent = { eventId: item._id }; http() .delete( "/deleteEvent", confirm("Are you sure you want to delete this?") && { params: deleteEvent } ) .then(response => { // console.log("deleteUers",deleteEvent) if ((this.snackbar = true)) { |
46db0a3b5
|
488 |
this.text = "Successfully delete Existing Notice Data"; |
beb598536
|
489 |
} |
2d0fc1144
|
490 |
this.getNoticeDataList(); |
beb598536
|
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
}) .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() { if (this.$refs.form.validate()) { |
2d0fc1144
|
521 522 523 524 525 |
if (this.imageUrl) { var str = this.imageUrl; const [baseUrl, imageUrl] = str.split(/,/); this.addNoticeBoard.upload = imageUrl; } |
beb598536
|
526 |
http() |
46db0a3b5
|
527 |
.post("/createEvent", this.addNoticeBoard) |
beb598536
|
528 |
.then(response => { |
0551a0f15
|
529 530 531 |
this.imageUrl = ""; this.snackbar = true; this.text = "New Notice added successfully"; |
2d0fc1144
|
532 |
this.getNoticeDataList(); |
beb598536
|
533 534 535 536 |
this.clear(); }) .catch(error => { // console.log(error); |
0551a0f15
|
537 538 |
this.snackbar = true; this.text = error.response.data.message; |
beb598536
|
539 540 541 |
}); } }, |
beb598536
|
542 543 |
clear() { this.$refs.form.reset(); |
0551a0f15
|
544 |
this.imageUrl = ""; |
beb598536
|
545 546 |
}, save() { |
2d0fc1144
|
547 |
let editNoticeBoard = { |
beb598536
|
548 549 |
eventId: this.editedItem._id, title: this.editedItem.title, |
2d0fc1144
|
550 |
description: this.editedItem.description |
beb598536
|
551 |
}; |
2d0fc1144
|
552 553 554 555 556 |
if (this.imageUrl) { var str = this.imageUrl; const [baseUrl, imageUrl] = str.split(/,/); editNoticeBoard.upload = imageUrl; } |
beb598536
|
557 |
http() |
2d0fc1144
|
558 |
.put("/updateEvent", editNoticeBoard) |
beb598536
|
559 |
.then(response => { |
beb598536
|
560 |
if ((this.snackbar = true)) { |
46db0a3b5
|
561 |
this.text = "Successfully Edit Existing Notice Data"; |
beb598536
|
562 |
} |
2d0fc1144
|
563 |
this.getNoticeDataList(); |
a17c68a03
|
564 |
this.close(); |
beb598536
|
565 566 567 568 |
}) .catch(error => { // console.log(error); }); |
beb598536
|
569 570 571 |
} }, mounted() { |
46db0a3b5
|
572 |
this.getNoticeDataList(); |
beb598536
|
573 |
}, |
a17c68a03
|
574 575 576 577 578 579 580 581 |
created() { this.$root.$on("app:search", search => { this.search = search; }); }, beforeDestroy() { // dont forget to remove the listener this.$root.$off("app:search"); |
beb598536
|
582 583 584 585 |
} }; </script> <style scoped> |
beb598536
|
586 |
.active { |
687e0b929
|
587 |
background-color: gray; |
beb598536
|
588 589 590 591 592 |
color: white !important; } .activebtn { color: black !important; } |
beb598536
|
593 |
</style> |