Commit 2b0e316eeb2a5332682d83dc8dc209c9e34b20a8

Authored by Neeraj Sharma
1 parent fc82ac6677

upload mytiple images and others changes

1   -# Vue Material Admin
  1 +# SchoolManagement
2 2  
3 3  
4 4  
... ...
src/Services/http.js
... ... @@ -3,10 +3,12 @@ import store from '@/store/store'
3 3  
4 4 export default () => {
5 5 return axios.create({
6   - baseURL:'http://192.168.4.220:3002/v1',
  6 + // baseURL:'http://d246be2d.ngrok.io/v1',
  7 + baseURL:'http://192.168.4.220:3002/v1',
7 8 // baseURL:'http://139.59.58.160:8001/v1',
8 9 headers: {
9 10 Authorization: `Bearer ${store.state.token}`
  11 + // Authorization:"Basic YWRtaW46b2ZiaXo="
10 12 }
11 13 })
12 14 }
... ...
1 1 const Menu = [
2 2 // { header: 'Apps' },
3   - {
  3 + // {
  4 + // title: 'Dashboard',
  5 + // // group: 'apps',
  6 + // name: 'dashboard',
  7 + // icon: 'view_module',
  8 + // },
  9 + {
4 10 title: 'Class',
5 11 // group: 'apps',
6 12 name: 'addclass',
... ... @@ -24,21 +30,21 @@ const Menu = [
24 30 name: 'Students',
25 31 icon: 'school',
26 32 },
27   - {
28   - title: 'Event',
29   - name: 'event',
30   - icon: 'event_available',
31   - },
  33 + // {
  34 + // title: 'Event',
  35 + // name: 'event',
  36 + // icon: 'event_available',
  37 + // },
32 38 {
33 39 title: 'News',
34 40 name: 'news',
35 41 icon: 'notification_important',
36 42 },
37   - {
38   - title: 'Reminder',
39   - name: 'reminder',
40   - icon: 'alarm_add',
41   - },
  43 + // {
  44 + // title: 'Reminder',
  45 + // name: 'reminder',
  46 + // icon: 'alarm_add',
  47 + // },
42 48 {
43 49 title: 'Time Table',
44 50 name: 'timeTable',
... ...
src/components/pageHeader/AppDrawer.vue
... ... @@ -10,7 +10,7 @@
10 10 >
11 11 <v-toolbar style="background:#39b982" >
12 12 <img v-bind:src="computeLogo" height="30" class="imgLogo" alt="ana">
13   - <h5 class="white--text my-3 ml-2">School-Managament</h5>
  13 + <h5 class="white--text my-3 ml-2">Technology Succes</h5>
14 14 <v-toolbar-title class="ml-0 pl-3" >
15 15 </v-toolbar-title>
16 16 </v-toolbar>
... ...
src/pages/Authentication/Login.vue
... ... @@ -3,7 +3,7 @@
3 3 <v-toolbar class="fixcolor">
4 4 <v-toolbar-items>
5 5 <img src="/static/icon.jpeg" height="36" alt="logo">
6   - <h3 class="white--text my-3 ml-5 logoSchool">School-Management</h3>
  6 + <h3 class="white--text my-3 ml-5 logoSchool">School-Maagement</h3>
7 7 </v-toolbar-items>
8 8 </v-toolbar>
9 9 <v-content>
... ... @@ -126,6 +126,7 @@ export default {
126 126 this.snackbar = true;
127 127 this.loading = false;
128 128 });
  129 + this.$router.push("/teachers");
129 130 }
130 131 },
131 132 computed: {
... ...
src/pages/Authentication/changepassword.vue
... ... @@ -6,7 +6,7 @@
6 6 <v-flex xs12 sm8 md8 lg5 offset-sm2 offset-lg3 class="mt-5">
7 7 <v-toolbar class="fixcolors mt-5" dark>
8 8 <v-spacer></v-spacer>
9   - <v-toolbar-title>Change Password</v-toolbar-title>
  9 + <v-toolbar-title>Technology Succes</v-toolbar-title>
10 10 <v-spacer></v-spacer>
11 11  
12 12 </v-toolbar>
... ...
src/pages/Authentication/forgetpassword.vue
... ... @@ -3,7 +3,7 @@
3 3 <v-toolbar class="fixcolors">
4 4 <v-toolbar-items>
5 5 <img src="/static/icon.jpeg" height="36" alt="logo">
6   - <h3 class="white--text my-3 ml-5 logoSchool">School-Management</h3>
  6 + <h3 class="white--text my-3 ml-5 logoSchool">Technology Succes</h3>
7 7 </v-toolbar-items>
8 8 </v-toolbar>
9 9 <v-container fluid>
... ...
src/pages/Class/addclass.vue
... ... @@ -291,7 +291,8 @@ export default {
291 291 sortable: false,
292 292 value: "No"
293 293 },
294   - { text: "Class Name", value: "classNum", sortable: false, align: "center" },
  294 + { text: "Class No", value: "classNum", sortable: false, align: "center" },
  295 +
295 296 { text: "Action", value: "", sortable: false, align: "center" }
296 297 ],
297 298 desserts: [],
... ... @@ -327,16 +328,14 @@ export default {
327 328 this.showLoader = true;
328 329 var token = this.$store.state.token;
329 330 http()
330   - .get("/getClassesList", {
331   - headers: { Authorization: "Bearer " + token }
332   - })
  331 + .get("/getClassesList")
333 332 .then(response => {
334 333 this.desserts = response.data.data;
335 334 this.showLoader = false;
336   - // console.log("getClassList=====>", this.desserts);
  335 + // console.log("getClassList=====>", response);
337 336 })
338 337 .catch(err => {
339   - // console.log("err====>", err);
  338 + console.log("err====>", err);
340 339 this.showLoader = false;
341 340 this.$router.replace({ path: "/" });
342 341 });
... ...
src/pages/Event/event.vue
... ... @@ -4,7 +4,9 @@
4 4 <v-toolbar-title class="ml-0 pl-3">
5 5 <v-toolbar-side-icon @click.stop="handleDrawerToggle" class="hide"></v-toolbar-side-icon>
6 6 </v-toolbar-title>
  7 +
7 8 <!-- ****** SEARCH ALL EXISTING EVENTS ****** -->
  9 +
8 10 <v-flex xs7 sm3 class="userSearch">
9 11 <v-text-field
10 12 flat
... ... @@ -88,7 +90,7 @@
88 90 class="text-xs-center text-sm-center text-md-center text-lg-center mr-4"
89 91 >
90 92 <v-avatar size="100px">
91   - <img src="/static/icon/user.png" v-if="!imageUrl">
  93 + <!-- <img src="/static/icon/user.png" v-if="!imageUrl"> -->
92 94 </v-avatar>
93 95 <input
94 96 type="file"
... ... @@ -96,11 +98,11 @@
96 98 ref="image"
97 99 accept="image/*"
98 100 @change="onFilePicked"
  101 +
99 102 >
100 103 <img
101   - :src="imageData.imageUrl"
  104 + src="https://kencil.sgp1.digitaloceanspaces.com/1554276999775"
102 105 height="150"
103   - v-if="imageUrl"
104 106 style="border-radius:50%; width:200px"
105 107 >
106 108 </v-flex>
... ... @@ -205,6 +207,7 @@
205 207 >{{ text }}</v-snackbar>
206 208  
207 209 <!-- ****** EXISTING-USERS EVENTS TABLE ****** -->
  210 +
208 211 <v-data-table
209 212 :headers="headers"
210 213 :items="desserts"
... ... @@ -282,7 +285,7 @@
282 285 @change="onFilePicked"
283 286 >
284 287 <img
285   - :src="imageData.imageUrl"
  288 + :src="imageUrl"
286 289 height="150"
287 290 v-if="imageUrl"
288 291 style="border-radius:50%; width:200px"
... ... @@ -304,7 +307,7 @@
304 307 ></v-text-field>
305 308 </v-flex>
306 309 </v-layout>
307   - <v-layout>
  310 + <v-layout>
308 311 <v-flex xs4 class="pt-4 subheading">
309 312 <label class="right">Description:</label>
310 313 </v-flex>
... ... @@ -320,6 +323,19 @@
320 323 </v-flex>
321 324 </v-layout>
322 325 <v-layout>
  326 + <v-flex xs4 class="pt-4 subheading">
  327 + <label class="right">Uplaod Image:</label>
  328 + </v-flex>
  329 + <v-flex xs6 class="ml-3">
  330 + <v-text-field
  331 + label="Select Image"
  332 + @click="pickFile"
  333 + v-model="imageName"
  334 + append-icon="attach_file"
  335 + ></v-text-field>
  336 + </v-flex>
  337 + </v-layout>
  338 + <v-layout>
323 339 <v-flex xs12 sm9 offset-sm2>
324 340 <v-card-actions>
325 341 <v-btn @click="clear" round dark>clear</v-btn>
... ... @@ -369,12 +385,12 @@ export default {
369 385 gender: ["Male", "Female"],
370 386 AddUsercredentials: {},
371 387 pagination: {
372   - rowsPerPage: 15
  388 + rowsPerPage: 19
373 389 },
374   - imageData: {},
375 390 imageName: "",
376 391 imageUrl: "",
377 392 imageFile: "",
  393 + upload: '',
378 394 titleRules: [v => !!v || " Title is required"],
379 395 descriptionRules: [v => !!v || " Description is required"],
380 396 headers: [
... ... @@ -433,7 +449,8 @@ export default {
433 449 onFilePicked(e) {
434 450 // console.log(e)
435 451 const files = e.target.files;
436   - this.imageData.upload = e.target.files[0];
  452 + this.upload = e.target.files[0];
  453 + console.log("thisupload==>", this.upload)
437 454 if (files[0] !== undefined) {
438 455 this.imageName = files[0].name;
439 456 if (this.imageName.lastIndexOf(".") <= 0) {
... ... @@ -444,8 +461,8 @@ export default {
444 461 fr.addEventListener("load", () => {
445 462 this.imageUrl = fr.result;
446 463 this.imageFile = files[0]; // this is an image file that can be sent to server...
447   - this.imageData.imageUrl = URL.createObjectURL(this.imageFile);
448   - console.log("upload=======>", this.imageData.imageUrl);
  464 + // this.imageData.imageUrl = URL.createObjectURL(this.imageFile);
  465 + console.log("upload=======>", this.imageUrl);
449 466 console.log("imageFile", this.imageFile);
450 467 });
451 468 } else {
... ... @@ -531,15 +548,18 @@ export default {
531 548 if (this.$refs.form.validate()) {
532 549 let imageData = new FormData();
533 550 imageData.append("upload", this.imageFile);
  551 + imageData.append("title", this.addEvents.title);
  552 + imageData.append("description", this.addEvents.description);
534 553 console.log(imageData);
535   - let addEvent = {
536   - title: this.addEvents.title,
537   - description: this.addEvents.description
538   - };
  554 + // let addEvent = {
  555 + // title: this.addEvents.title,
  556 + // description: this.addEvents.description,
  557 + // imageData
  558 + // };
539 559 http()
540   - .post("/createEvent", addEvent)
  560 + .post("/createEvent", imageData)
541 561 .then(response => {
542   - // console.log("addEvent=====>",addEvent)
  562 + console.log("addEvent=====>",imageData)
543 563 if ((this.snackbar = true)) {
544 564 this.text = "New user added successfully";
545 565 }
... ... @@ -552,6 +572,15 @@ export default {
552 572 this.text = error.response.data.message;
553 573 }
554 574 });
  575 + var form_data = new FormData();
  576 + for (var key in addEvent) {
  577 + if (key === 'upload') {
  578 + form_data.append(key, this.imageFile);
  579 + }
  580 + else {
  581 + form_data.append(key, addEvent[key])
  582 + }
  583 + }
555 584 }
556 585 },
557 586 mail() {},
... ... @@ -562,7 +591,7 @@ export default {
562 591 save() {
563 592 let imageData = new FormData();
564 593 imageData.append("upload", this.imageFile);
565   - console.log(imageData);
  594 + console.log("imageData",imageData);
566 595 let editEvent = {
567 596 eventId: this.editedItem._id,
568 597 title: this.editedItem.title,
... ...
src/pages/News/news.vue
... ... @@ -5,7 +5,7 @@
5 5 <v-toolbar-side-icon @click.stop="handleDrawerToggle" class="hide"></v-toolbar-side-icon>
6 6 </v-toolbar-title>
7 7 <!-- ****** SEARCH ALL EXISTING NEWS ****** -->
8   - <v-flex xs7 sm3 class="userSearch">
  8 + <v-flex xs7 sm3 class="userSearch ml-3">
9 9 <v-text-field
10 10 flat
11 11 append-icon="search"
... ... @@ -98,7 +98,7 @@
98 98 @change="onFilePicked"
99 99 >
100 100 <img
101   - :src="imageData.imageUrl"
  101 + :src="editItem.newsImageUrl"
102 102 height="150"
103 103 v-if="imageUrl"
104 104 style="border-radius:50%; width:200px"
... ... @@ -318,53 +318,23 @@
318 318 style="display: none"
319 319 ref="image"
320 320 accept="image/*"
  321 + multiple
321 322 @change="onFilePicked"
322 323 >
323 324 <img
324   - :src="imageData.imageUrl"
  325 + :src="imageUrl"
325 326 height="150"
326 327 v-if="imageUrl"
327 328 style="border-radius:50%; width:200px"
328   - >
329   - </v-flex>
330   - </v-layout>
331   - <v-flex xs12>
  329 + >
332 330 <v-layout>
333   - <v-flex xs4 class="pt-4 subheading">
334   - <label class="right">Select Class:</label>
335   - </v-flex>
336   - <v-flex xs4 class="ml-3">
337   - <v-select
338   - :items="addclass"
339   - label="Select Class"
340   - v-model="editedItem.select"
341   - item-text="classNum"
342   - item-value="_id"
343   - name="Select Class"
344   - @change="getSections(editedItem.select)"
345   - required
346   - ></v-select>
347   - </v-flex>
348   - </v-layout>
349   - </v-flex>
350   - <v-flex xs12>
351   - <v-layout>
352   - <v-flex xs4 class="pt-4 subheading">
353   - <label class="right">Select Section:</label>
354   - </v-flex>
355   - <v-flex xs4 class="ml-3">
356   - <v-select
357   - :items="addSection"
358   - label="Select Section"
359   - v-model="editedItem.selectSection"
360   - item-text="name"
361   - item-value="_id"
362   - name="Select Section"
363   - required
364   - ></v-select>
365   - </v-flex>
366   - </v-layout>
  331 + <v-flex
  332 + xs4 v-for="(file, index) in files" :key="index">
  333 + <img :src="file.url" height="200" width="320px;">
  334 + </v-flex>
  335 + </v-layout>
367 336 </v-flex>
  337 + </v-layout>
368 338 <v-flex xs12>
369 339 <v-layout>
370 340 <v-flex xs4 class="pt-4 subheading">
... ... @@ -399,6 +369,22 @@
399 369 </v-flex>
400 370 </v-layout>
401 371 </v-flex>
  372 + <v-flex xs12>
  373 + <v-layout>
  374 + <v-flex xs4 class="pt-4 subheading">
  375 + <label class="right">Uplaod Image:</label>
  376 + </v-flex>
  377 + <v-flex xs4 class="ml-3">
  378 + <v-text-field
  379 + label="Select Image"
  380 + @click="pickFile"
  381 + v-model="imageName"
  382 + append-icon="attach_file"
  383 + multiple
  384 + ></v-text-field>
  385 + </v-flex>
  386 + </v-layout>
  387 + </v-flex>
402 388 <v-layout>
403 389 <v-flex xs12 sm6 offset-sm3>
404 390 <v-card-actions>
... ... @@ -448,10 +434,12 @@ export default {
448 434 pagination: {
449 435 rowsPerPage: 15
450 436 },
451   - imageData: {},
452 437 imageName: "",
453 438 imageUrl: "",
454 439 imageFile: "",
  440 + image: [],
  441 + upload:"",
  442 + files:[],
455 443 titleRules: [v => !!v || " Tilte is required"],
456 444 descriptionRules: [v => !!v || " Description is required"],
457 445 headers: [
... ... @@ -469,7 +457,7 @@ export default {
469 457 editedIndex: -1,
470 458 addNews: {
471 459 title: "",
472   - description: ""
  460 + description: "",
473 461 },
474 462 editedItem: {
475 463 title: "",
... ... @@ -499,6 +487,7 @@ export default {
499 487 }),
500 488 methods: {
501 489 getSections(_id) {
  490 + console.log("_id",_id)
502 491 var token = this.$store.state.token;
503 492 http()
504 493 .get(
... ... @@ -524,21 +513,36 @@ export default {
524 513 onFilePicked(e) {
525 514 // console.log(e)
526 515 const files = e.target.files;
527   - this.imageData.upload = e.target.files[0];
  516 + /** fetch Image Name **/
528 517 if (files[0] !== undefined) {
529 518 this.imageName = files[0].name;
530 519 if (this.imageName.lastIndexOf(".") <= 0) {
531 520 return;
532   - }
  521 + }
  522 + this.files = [];
  523 + console.log("files", this.files);
  524 + /** Select many image and showing many image add to news card **/
  525 + const test = Array.from(files).forEach((file, idx) => {
533 526 const fr = new FileReader();
534   - fr.readAsDataURL(files[0]);
535   - fr.addEventListener("load", () => {
536   - this.imageUrl = fr.result;
537   - this.imageFile = files[0]; // this is an image file that can be sent to server...
538   - this.imageData.imageUrl = URL.createObjectURL(this.imageFile);
539   - console.log("upload=======>", this.imageData.imageUrl);
540   - console.log("imageFile", this.imageFile);
  527 + const getResult = new Promise(resolve => {
  528 + fr.onload = e => {
  529 + this.files.push({
  530 + id: idx,
  531 + url: e.target.result
  532 + });
  533 + };
541 534 });
  535 + fr.readAsDataURL(file);
  536 + return getResult.then(file => {
  537 + return file;
  538 + });
  539 + });
  540 + const fr = new FileReader();
  541 + fr.readAsDataURL(files[0]);
  542 + fr.addEventListener("load", () => {
  543 + this.imageFile = files; // this is an image file that can be sent to server...
  544 + console.log("uploadImage=======>", this.imageFile );
  545 + });
542 546 } else {
543 547 this.imageName = "";
544 548 this.imageFile = "";
... ... @@ -619,19 +623,21 @@ export default {
619 623 this.dialog1 = false;
620 624 },
621 625 submit() {
  626 + console.log("===========>",this.image)
622 627 if (this.$refs.form.validate()) {
623   - let imageData = new FormData();
624   - imageData.append("upload", this.imageFile);
625   - console.log(imageData);
626   - let addNewses = {
627   - title: this.addNews.title,
628   - description: this.addNews.description,
629   - // imageData
630   - };
  628 + let newsData = new FormData();
  629 + for( var i = 0; i < this.imageFile.length; i++ ){
  630 + let file = this.imageFile[i];
  631 + newsData.append("upload", file );
  632 + }
  633 + newsData.append("title",this.addNews.title);
  634 + newsData.append("description",this.addNews.description);
  635 + console.log("newsDataData",newsData);
  636 +
631 637 http()
632   - .post("/createNews", addNewses)
  638 + .post("/createNews", newsData)
633 639 .then(response => {
634   - // console.log(addNewses)
  640 + console.log(newsData)
635 641 if ((this.snackbar = true)) {
636 642 this.text = "New user added successfully";
637 643 }
... ... @@ -639,7 +645,6 @@ export default {
639 645 this.clear();
640 646 })
641 647 .catch(error => {
642   - // console.log(error);
643 648 if ((this.snackbar = true)) {
644 649 this.text = error.response.data.message;
645 650 }
... ...
src/pages/Section/section.vue
... ... @@ -244,7 +244,7 @@
244 244 </v-flex>
245 245 <v-flex xs6 class="ml-3">
246 246 <v-text-field
247   - v-model="editedItem.name"
  247 + v-model="add.name"
248 248 placeholder="fill your Section Name"
249 249 name="name"
250 250 type="text"
... ... @@ -276,7 +276,7 @@
276 276 </v-flex>
277 277 <v-flex xs6 class="ml-3">
278 278 <v-text-field
279   - v-model="editedItem.session"
  279 + v-model="add.session"
280 280 placeholder="fill your Session"
281 281 name="name"
282 282 type="text"
... ... @@ -363,6 +363,14 @@ export default {
363 363 session:new Date().getFullYear()
364 364  
365 365 },
  366 + add: {
  367 + classData:{
  368 + classNum:"",
  369 + },
  370 + name:'',
  371 + session:new Date().getFullYear()
  372 +
  373 + },
366 374 items: [
367 375 {
368 376 href: "/changepassword",
... ... @@ -397,7 +405,7 @@ export default {
397 405 .catch(err => {
398 406 // console.log("err====>", err);
399 407 this.showLoader = false;
400   - this.$router.replace({ path: '/' });
  408 + // this.$router.replace({ path: '/' });
401 409 });
402 410 },
403 411 editItem(item) {
... ... @@ -457,16 +465,16 @@ export default {
457 465 submit() {
458 466 if (this.$refs.forms.validate()) {
459 467 let addSection = {
460   - name: this.editedItem.name,
  468 + name: this.add.name,
461 469 classId: this.select,
462   - session:this.editedItem.session
  470 + session:this.add.session
463 471 };
464 472 console.log(addSection)
465 473 http()
466 474 .post("/createSection", addSection)
467 475 .then(response => {
468 476 console.log(addSection)
469   - // this.getStudentList();
  477 + this.getSectionList();
470 478 if (this.snackbar = true) {
471 479 this.text = "New user added successfully";
472 480 }
... ...
src/pages/Teachers/teachers.vue
... ... @@ -90,15 +90,15 @@
90 90 </v-avatar>
91 91 <input
92 92 type="file"
93   - style="display: none"
  93 + style="display:none"
94 94 ref="image"
95 95 accept="image/*"
96 96 @change="onFilePicked"
97 97 >
98 98 <img
99   - :src="imageData.imageUrl"
100   - height="150"
101 99 v-if="imageUrl"
  100 + :src="imageUrl"
  101 + height="150"
102 102 style="border-radius:50%; width:200px"
103 103 >
104 104 </v-flex>
... ... @@ -299,7 +299,7 @@
299 299 label="Select Image"
300 300 @click="pickFile"
301 301 v-model="imageName"
302   - prepend-icon="attach_file"
  302 + append-icon="attach_file"
303 303 ></v-text-field>
304 304 </v-flex>
305 305 </v-layout>
... ... @@ -553,7 +553,7 @@
553 553 @change="onFilePicked"
554 554 > -->
555 555 <img
556   - :src="imageData.imageUrl"
  556 + :src="imageUrl"
557 557 height="150"
558 558 v-if="imageUrl"
559 559 style="border-radius:50%; width:200px"
... ... @@ -769,7 +769,7 @@
769 769 ></v-text-field>
770 770 <input
771 771 type="file"
772   - style="display: none"
  772 + style="display:none"
773 773 ref="image"
774 774 accept="image/*"
775 775 @change="onFilePicked"
... ... @@ -1180,9 +1180,8 @@ export default {
1180 1180 this.$refs.menu1.save(date)
1181 1181 },
1182 1182 pickFile() {
1183   - this.$refs.image.click();
  1183 + this.$refs.image.click ();
1184 1184 },
1185   -
1186 1185 onFilePicked(e) {
1187 1186 // console.log(e)
1188 1187 const files = e.target.files;
... ... @@ -1211,6 +1210,7 @@ export default {
1211 1210 getTeacherList() {
1212 1211 this.showLoader = true;
1213 1212 var token = this.$store.state.token;
  1213 + console.log("token",token)
1214 1214 http()
1215 1215 .get("/getTeachersList", {
1216 1216 headers: { Authorization: "Bearer " + token }
... ...
src/router/paths.js
... ... @@ -34,6 +34,16 @@ export default [
34 34 )
35 35 },
36 36 {
  37 + path: '/dashboard',
  38 + meta: {},
  39 + name: 'dashboard',
  40 + component: () => import(
  41 + /* webpackChunkName: "routes" */
  42 + /* webpackMode: "lazy-once" */
  43 + `@/pages/Dasboard/dashbord`
  44 + )
  45 + },
  46 + {
37 47 path: '/changepassword',
38 48 meta: { },
39 49 name: 'changepassword',
... ...