Blame view
src/pages/NoticeBoard/noticeBoard.vue
18.5 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 206 207 208 209 210 |
<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> <img style="cursor:pointer; width:25px; height:18px; " class="mr-5" @click="profile(props.item)" src="/static/icon/eye1.png" |
46db0a3b5
|
211 |
/> |
beb598536
|
212 213 214 215 216 |
<img style="cursor:pointer; width:20px; height:18px; " class="mr-5" @click="editItem(props.item)" src="/static/icon/edit1.png" |
46db0a3b5
|
217 |
/> |
beb598536
|
218 |
<img |
b39d2afd2
|
219 |
style="cursor:pointer;width:20px; height:20px; " |
beb598536
|
220 221 222 |
class="mr-5" @click="deleteItem(props.item)" src="/static/icon/delete1.png" |
46db0a3b5
|
223 |
/> |
beb598536
|
224 225 226 227 228 229 230 231 232 233 234 |
</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
|
235 |
<!-- ****** ADD MULTIPLE Notice Board ****** --> |
beb598536
|
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
<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 class="text-xs-center text-sm-center text-md-center text-lg-center my-4 mr-4" > <v-avatar size="100px"> |
46db0a3b5
|
259 |
<img src="/static/icon/user.png" v-if="!imageUrl" /> |
beb598536
|
260 |
</v-avatar> |
2d0fc1144
|
261 |
<input |
beb598536
|
262 263 264 265 266 |
type="file" style="display: none" ref="image" accept="image/*" @change="onFilePicked" |
46db0a3b5
|
267 |
/> |
beb598536
|
268 |
<img |
2b0e316ee
|
269 |
:src="imageUrl" |
beb598536
|
270 271 272 |
height="150" v-if="imageUrl" style="border-radius:50%; width:200px" |
2d0fc1144
|
273 |
/> |
beb598536
|
274 275 276 277 278 279 280 281 |
</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
|
282 |
v-model="addNoticeBoard.title" |
beb598536
|
283 284 285 286 287 288 289 290 |
placeholder="fill your Title" name="name" type="text" :rules="titleRules" required ></v-text-field> </v-flex> </v-layout> |
46db0a3b5
|
291 |
<v-layout> |
beb598536
|
292 293 294 295 296 |
<v-flex xs4 class="pt-4 subheading"> <label class="right">Description:</label> </v-flex> <v-flex xs6 class="ml-3"> <v-text-field |
46db0a3b5
|
297 |
v-model="addNoticeBoard.description" |
beb598536
|
298 299 300 301 302 303 304 305 |
placeholder="fill your Description" name="name" type="text" :rules="descriptionRules" required ></v-text-field> </v-flex> </v-layout> |
2d0fc1144
|
306 |
<v-layout> |
2b0e316ee
|
307 |
<v-flex xs4 class="pt-4 subheading"> |
aa8fc5033
|
308 309 |
<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
|
310 311 312 313 314 315 316 317 318 |
</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
|
319 |
</v-layout> |
2b0e316ee
|
320 |
<v-layout> |
beb598536
|
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
<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
|
338 339 340 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
beb598536
|
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
</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
|
356 |
showLoader: false, |
beb598536
|
357 358 359 |
loading: false, date: null, search: "", |
beb598536
|
360 361 362 363 364 365 366 367 368 369 |
dialog: false, dialog1: false, valid: true, isActive: true, newActive: false, addclass: [], addSection: [], gender: ["Male", "Female"], AddUsercredentials: {}, pagination: { |
2b0e316ee
|
370 |
rowsPerPage: 19 |
beb598536
|
371 |
}, |
beb598536
|
372 373 374 |
imageName: "", imageUrl: "", imageFile: "", |
46db0a3b5
|
375 |
upload: "", |
beb598536
|
376 377 378 379 380 381 382 383 384 385 |
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
|
386 387 388 389 390 391 |
{ text: "Description", value: "description", sortable: false, align: "center" }, |
beb598536
|
392 393 394 395 |
{ text: "Action", value: "", sortable: false, align: "center" } ], desserts: [], editedIndex: -1, |
46db0a3b5
|
396 |
addNoticeBoard: {}, |
beb598536
|
397 398 399 400 401 402 403 |
editedItem: { title: "", description: "" }, defaultItem: { title: "", description: "" |
a17c68a03
|
404 |
} |
beb598536
|
405 |
}), |
beb598536
|
406 407 408 409 |
methods: { pickFile() { this.$refs.image.click(); }, |
2d0fc1144
|
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
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
|
425 426 427 428 429 430 431 |
}); } else { this.imageName = ""; this.imageFile = ""; this.imageUrl = ""; } }, |
46db0a3b5
|
432 |
getNoticeDataList() { |
36fc987df
|
433 |
this.showLoader = true; |
beb598536
|
434 435 436 437 438 439 440 |
var token = this.$store.state.token; http() .get("/getEventsList", { headers: { Authorization: "Bearer " + token } }) .then(response => { this.desserts = response.data.data; |
36fc987df
|
441 |
this.showLoader = false; |
beb598536
|
442 443 |
}) .catch(err => { |
36fc987df
|
444 |
this.showLoader = false; |
a17c68a03
|
445 446 447 448 449 |
if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } |
beb598536
|
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
}); }, 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
|
476 |
this.text = "Successfully delete Existing Notice Data"; |
beb598536
|
477 |
} |
2d0fc1144
|
478 |
this.getNoticeDataList(); |
beb598536
|
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
}) .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
|
509 510 511 512 513 |
if (this.imageUrl) { var str = this.imageUrl; const [baseUrl, imageUrl] = str.split(/,/); this.addNoticeBoard.upload = imageUrl; } |
beb598536
|
514 |
http() |
46db0a3b5
|
515 |
.post("/createEvent", this.addNoticeBoard) |
beb598536
|
516 |
.then(response => { |
beb598536
|
517 |
if ((this.snackbar = true)) { |
46db0a3b5
|
518 |
this.text = "New Notice Data added successfully"; |
beb598536
|
519 |
} |
2d0fc1144
|
520 |
this.getNoticeDataList(); |
beb598536
|
521 522 523 524 525 526 527 528 529 530 |
this.clear(); }) .catch(error => { // console.log(error); if ((this.snackbar = true)) { this.text = error.response.data.message; } }); } }, |
beb598536
|
531 532 533 534 |
clear() { this.$refs.form.reset(); }, save() { |
2d0fc1144
|
535 |
let editNoticeBoard = { |
beb598536
|
536 537 |
eventId: this.editedItem._id, title: this.editedItem.title, |
2d0fc1144
|
538 |
description: this.editedItem.description |
beb598536
|
539 |
}; |
2d0fc1144
|
540 541 542 543 544 |
if (this.imageUrl) { var str = this.imageUrl; const [baseUrl, imageUrl] = str.split(/,/); editNoticeBoard.upload = imageUrl; } |
beb598536
|
545 |
http() |
2d0fc1144
|
546 |
.put("/updateEvent", editNoticeBoard) |
beb598536
|
547 |
.then(response => { |
beb598536
|
548 |
if ((this.snackbar = true)) { |
46db0a3b5
|
549 |
this.text = "Successfully Edit Existing Notice Data"; |
beb598536
|
550 |
} |
2d0fc1144
|
551 |
this.getNoticeDataList(); |
a17c68a03
|
552 |
this.close(); |
beb598536
|
553 554 555 556 |
}) .catch(error => { // console.log(error); }); |
beb598536
|
557 558 559 |
} }, mounted() { |
46db0a3b5
|
560 |
this.getNoticeDataList(); |
beb598536
|
561 |
}, |
a17c68a03
|
562 563 564 565 566 567 568 569 |
created() { this.$root.$on("app:search", search => { this.search = search; }); }, beforeDestroy() { // dont forget to remove the listener this.$root.$off("app:search"); |
beb598536
|
570 571 572 573 |
} }; </script> <style scoped> |
beb598536
|
574 |
.active { |
687e0b929
|
575 |
background-color: gray; |
beb598536
|
576 577 578 579 580 |
color: white !important; } .activebtn { color: black !important; } |
beb598536
|
581 |
</style> |