Blame view
src/pages/NoticeBoard/noticeBoard.vue
18.6 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 |
|
46db0a3b5
|
20 |
<!-- ****** EDITS 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 32 33 |
<v-dialog v-model="dialog" max-width="640px" scrollable> <v-card style="height: 540px;"> <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> |
beb598536
|
41 42 43 44 45 |
<v-form ref="form"> <v-container fluid> <v-layout> <v-flex xs12 |
756b14fe2
|
46 |
class="text-xs-center text-sm-center text-md-center text-lg-center" |
beb598536
|
47 |
> |
756b14fe2
|
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
<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" /> |
2d0fc1144
|
65 |
<input |
beb598536
|
66 67 68 69 70 |
type="file" style="display: none" ref="image" accept="image/*" @change="onFilePicked" |
2d0fc1144
|
71 |
/> |
beb598536
|
72 73 74 |
</v-flex> </v-layout> <v-layout> |
756b14fe2
|
75 76 77 78 79 80 81 82 83 84 85 86 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 |
<v-flex xs12> <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 v-model="editedItem.title" placeholder="fill your Title" name="name" type="text" 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> <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> </v-flex> </v-layout> </v-flex> <v-flex xs12> <v-layout> <v-flex xs4 class="pt-4 subheading"> <label class="right">Uplaod Image:</label> </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> </v-layout> </v-flex> |
beb598536
|
122 123 124 125 126 127 128 129 130 131 |
<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> </v-container> </v-form> |
756b14fe2
|
132 133 |
</v-card-text> </v-card> |
beb598536
|
134 |
</v-dialog> |
46db0a3b5
|
135 |
<!-- ****** VIEW PROFIL NOTICE BOARD ****** --> |
beb598536
|
136 |
|
2d0fc1144
|
137 |
<v-dialog v-model="dialog1" max-width="640px" scrollable> |
ceb43037a
|
138 |
<v-card style="height: 380px;"> |
2d0fc1144
|
139 140 141 142 143 144 145 146 |
<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
|
147 |
<v-card-text> |
2d0fc1144
|
148 |
<v-flex align-center justify-center layout text-xs-center class="mt-3"> |
756b14fe2
|
149 150 151 152 153 154 |
<img src="/static/icon/user.png" v-if="!editedItem.eventImageUrl" width="130px" /> <img :src="editedItem.eventImageUrl" v-else-if="editedItem.eventImageUrl" width="200px" /> |
2d0fc1144
|
155 |
</v-flex> |
beb598536
|
156 157 158 |
<v-container grid-list-md> <v-layout wrap> <v-flex> |
beb598536
|
159 160 |
<v-layout> <v-flex xs5 sm6> |
ceb43037a
|
161 |
<h5 class="right my-1"><b>Title:</b></h5> |
beb598536
|
162 163 164 165 166 167 168 |
</v-flex> <v-flex sm6 xs8> <h5 class="my-1">{{ editedItem.title }}</h5> </v-flex> </v-layout> <v-layout> <v-flex xs5 sm6> |
ceb43037a
|
169 |
<h5 class="right my-1"><b>Description:</b></h5> |
beb598536
|
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
</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
|
190 |
<!-- ****** EXISTING-USERS Notice Board TABLE ****** --> |
2b0e316ee
|
191 |
|
beb598536
|
192 193 194 195 196 197 198 |
<v-data-table :headers="headers" :items="desserts" :pagination.sync="pagination" :search="search" > <template slot="items" slot-scope="props"> |
687e0b929
|
199 |
<td id="td" class="text-xs-center">{{ props.index + 1}}</td> |
beb598536
|
200 201 202 203 204 205 206 207 208 209 |
<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
|
210 |
/> |
beb598536
|
211 212 213 214 215 |
<img style="cursor:pointer; width:20px; height:18px; " class="mr-5" @click="editItem(props.item)" src="/static/icon/edit1.png" |
46db0a3b5
|
216 |
/> |
beb598536
|
217 |
<img |
b39d2afd2
|
218 |
style="cursor:pointer;width:20px; height:20px; " |
beb598536
|
219 220 221 |
class="mr-5" @click="deleteItem(props.item)" src="/static/icon/delete1.png" |
46db0a3b5
|
222 |
/> |
beb598536
|
223 224 225 226 227 228 229 230 231 232 233 |
</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
|
234 |
<!-- ****** ADD MULTIPLE Notice Board ****** --> |
beb598536
|
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
<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
|
258 |
<img src="/static/icon/user.png" v-if="!imageUrl" /> |
beb598536
|
259 |
</v-avatar> |
2d0fc1144
|
260 |
<input |
beb598536
|
261 262 263 264 265 |
type="file" style="display: none" ref="image" accept="image/*" @change="onFilePicked" |
46db0a3b5
|
266 |
/> |
beb598536
|
267 |
<img |
2b0e316ee
|
268 |
:src="imageUrl" |
beb598536
|
269 270 271 |
height="150" v-if="imageUrl" style="border-radius:50%; width:200px" |
2d0fc1144
|
272 |
/> |
beb598536
|
273 274 275 276 277 278 279 280 |
</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
|
281 |
v-model="addNoticeBoard.title" |
beb598536
|
282 283 284 285 286 287 288 289 |
placeholder="fill your Title" name="name" type="text" :rules="titleRules" required ></v-text-field> </v-flex> </v-layout> |
46db0a3b5
|
290 |
<v-layout> |
beb598536
|
291 292 293 294 295 |
<v-flex xs4 class="pt-4 subheading"> <label class="right">Description:</label> </v-flex> <v-flex xs6 class="ml-3"> <v-text-field |
46db0a3b5
|
296 |
v-model="addNoticeBoard.description" |
beb598536
|
297 298 299 300 301 302 303 304 |
placeholder="fill your Description" name="name" type="text" :rules="descriptionRules" required ></v-text-field> </v-flex> </v-layout> |
2d0fc1144
|
305 |
<v-layout> |
2b0e316ee
|
306 307 308 309 310 311 312 313 314 315 316 |
<v-flex xs4 class="pt-4 subheading"> <label class="right">Uplaod Image:</label> </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
|
317 |
</v-layout> |
2b0e316ee
|
318 |
<v-layout> |
beb598536
|
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
<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
|
336 337 338 |
<div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> |
beb598536
|
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 |
</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
|
354 |
showLoader: false, |
beb598536
|
355 356 357 |
loading: false, date: null, search: "", |
beb598536
|
358 359 360 361 362 363 364 365 366 367 |
dialog: false, dialog1: false, valid: true, isActive: true, newActive: false, addclass: [], addSection: [], gender: ["Male", "Female"], AddUsercredentials: {}, pagination: { |
2b0e316ee
|
368 |
rowsPerPage: 19 |
beb598536
|
369 |
}, |
beb598536
|
370 371 372 |
imageName: "", imageUrl: "", imageFile: "", |
46db0a3b5
|
373 |
upload: "", |
beb598536
|
374 375 376 377 378 379 380 381 382 383 |
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
|
384 385 386 387 388 389 |
{ text: "Description", value: "description", sortable: false, align: "center" }, |
beb598536
|
390 391 392 393 |
{ text: "Action", value: "", sortable: false, align: "center" } ], desserts: [], editedIndex: -1, |
46db0a3b5
|
394 |
addNoticeBoard: {}, |
beb598536
|
395 396 397 398 399 400 401 |
editedItem: { title: "", description: "" }, defaultItem: { title: "", description: "" |
a17c68a03
|
402 |
} |
beb598536
|
403 |
}), |
beb598536
|
404 405 406 407 |
methods: { pickFile() { this.$refs.image.click(); }, |
2d0fc1144
|
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
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
|
423 424 425 426 427 428 429 |
}); } else { this.imageName = ""; this.imageFile = ""; this.imageUrl = ""; } }, |
46db0a3b5
|
430 |
getNoticeDataList() { |
36fc987df
|
431 |
this.showLoader = true; |
beb598536
|
432 433 434 435 436 437 438 |
var token = this.$store.state.token; http() .get("/getEventsList", { headers: { Authorization: "Bearer " + token } }) .then(response => { this.desserts = response.data.data; |
36fc987df
|
439 |
this.showLoader = false; |
beb598536
|
440 441 |
}) .catch(err => { |
36fc987df
|
442 |
this.showLoader = false; |
a17c68a03
|
443 444 445 446 447 |
if (error.response.status === 401) { this.$router.replace({ path: "/" }); this.$store.dispatch("setToken", null); this.$store.dispatch("Id", null); } |
beb598536
|
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
}); }, 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
|
474 |
this.text = "Successfully delete Existing Notice Data"; |
beb598536
|
475 |
} |
2d0fc1144
|
476 |
this.getNoticeDataList(); |
beb598536
|
477 478 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 |
}) .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
|
507 508 509 510 511 |
if (this.imageUrl) { var str = this.imageUrl; const [baseUrl, imageUrl] = str.split(/,/); this.addNoticeBoard.upload = imageUrl; } |
beb598536
|
512 |
http() |
46db0a3b5
|
513 |
.post("/createEvent", this.addNoticeBoard) |
beb598536
|
514 |
.then(response => { |
beb598536
|
515 |
if ((this.snackbar = true)) { |
46db0a3b5
|
516 |
this.text = "New Notice Data added successfully"; |
beb598536
|
517 |
} |
2d0fc1144
|
518 |
this.getNoticeDataList(); |
beb598536
|
519 520 521 522 523 524 525 526 527 528 |
this.clear(); }) .catch(error => { // console.log(error); if ((this.snackbar = true)) { this.text = error.response.data.message; } }); } }, |
beb598536
|
529 530 531 532 |
clear() { this.$refs.form.reset(); }, save() { |
2d0fc1144
|
533 |
let editNoticeBoard = { |
beb598536
|
534 535 |
eventId: this.editedItem._id, title: this.editedItem.title, |
2d0fc1144
|
536 |
description: this.editedItem.description |
beb598536
|
537 |
}; |
2d0fc1144
|
538 539 540 541 542 |
if (this.imageUrl) { var str = this.imageUrl; const [baseUrl, imageUrl] = str.split(/,/); editNoticeBoard.upload = imageUrl; } |
beb598536
|
543 |
http() |
2d0fc1144
|
544 |
.put("/updateEvent", editNoticeBoard) |
beb598536
|
545 |
.then(response => { |
beb598536
|
546 |
if ((this.snackbar = true)) { |
46db0a3b5
|
547 |
this.text = "Successfully Edit Existing Notice Data"; |
beb598536
|
548 |
} |
2d0fc1144
|
549 |
this.getNoticeDataList(); |
a17c68a03
|
550 |
this.close(); |
beb598536
|
551 552 553 554 |
}) .catch(error => { // console.log(error); }); |
beb598536
|
555 556 557 |
} }, mounted() { |
46db0a3b5
|
558 |
this.getNoticeDataList(); |
beb598536
|
559 |
}, |
a17c68a03
|
560 561 562 563 564 565 566 567 |
created() { this.$root.$on("app:search", search => { this.search = search; }); }, beforeDestroy() { // dont forget to remove the listener this.$root.$off("app:search"); |
beb598536
|
568 569 570 571 |
} }; </script> <style scoped> |
beb598536
|
572 |
.active { |
687e0b929
|
573 |
background-color: gray; |
beb598536
|
574 575 576 577 578 |
color: white !important; } .activebtn { color: black !important; } |
beb598536
|
579 |
</style> |