From 2b0e316eeb2a5332682d83dc8dc209c9e34b20a8 Mon Sep 17 00:00:00 2001 From: Neeraj Sharma Date: Tue, 9 Apr 2019 13:18:38 +0530 Subject: [PATCH] upload mytiple images and others changes --- README.md | 2 +- src/Services/http.js | 4 +- src/api/menu.js | 28 +++--- src/components/pageHeader/AppDrawer.vue | 2 +- src/pages/Authentication/Login.vue | 3 +- src/pages/Authentication/changepassword.vue | 2 +- src/pages/Authentication/forgetpassword.vue | 2 +- src/pages/Class/addclass.vue | 11 ++- src/pages/Event/event.vue | 63 +++++++++---- src/pages/News/news.vue | 131 +++++++++++++++------------- src/pages/Section/section.vue | 20 +++-- src/pages/Teachers/teachers.vue | 16 ++-- src/router/paths.js | 10 +++ 13 files changed, 177 insertions(+), 117 deletions(-) diff --git a/README.md b/README.md index 7fa2505..cb595c4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Vue Material Admin +# SchoolManagement diff --git a/src/Services/http.js b/src/Services/http.js index 12a3bdf..b01ed34 100644 --- a/src/Services/http.js +++ b/src/Services/http.js @@ -3,10 +3,12 @@ import store from '@/store/store' export default () => { return axios.create({ - baseURL:'http://192.168.4.220:3002/v1', + // baseURL:'http://d246be2d.ngrok.io/v1', + baseURL:'http://192.168.4.220:3002/v1', // baseURL:'http://139.59.58.160:8001/v1', headers: { Authorization: `Bearer ${store.state.token}` + // Authorization:"Basic YWRtaW46b2ZiaXo=" } }) } diff --git a/src/api/menu.js b/src/api/menu.js index fb359a6..a79cf9a 100644 --- a/src/api/menu.js +++ b/src/api/menu.js @@ -1,6 +1,12 @@ const Menu = [ // { header: 'Apps' }, - { + // { + // title: 'Dashboard', + // // group: 'apps', + // name: 'dashboard', + // icon: 'view_module', + // }, + { title: 'Class', // group: 'apps', name: 'addclass', @@ -24,21 +30,21 @@ const Menu = [ name: 'Students', icon: 'school', }, - { - title: 'Event', - name: 'event', - icon: 'event_available', - }, + // { + // title: 'Event', + // name: 'event', + // icon: 'event_available', + // }, { title: 'News', name: 'news', icon: 'notification_important', }, - { - title: 'Reminder', - name: 'reminder', - icon: 'alarm_add', - }, + // { + // title: 'Reminder', + // name: 'reminder', + // icon: 'alarm_add', + // }, { title: 'Time Table', name: 'timeTable', diff --git a/src/components/pageHeader/AppDrawer.vue b/src/components/pageHeader/AppDrawer.vue index a498bcd..1c9b2c4 100644 --- a/src/components/pageHeader/AppDrawer.vue +++ b/src/components/pageHeader/AppDrawer.vue @@ -10,7 +10,7 @@ > -
School-Managament
+
Technology Succes
diff --git a/src/pages/Authentication/Login.vue b/src/pages/Authentication/Login.vue index e16d8ac..f0d10ce 100644 --- a/src/pages/Authentication/Login.vue +++ b/src/pages/Authentication/Login.vue @@ -3,7 +3,7 @@ logo -

School-Management

+

School-Maagement

@@ -126,6 +126,7 @@ export default { this.snackbar = true; this.loading = false; }); + this.$router.push("/teachers"); } }, computed: { diff --git a/src/pages/Authentication/changepassword.vue b/src/pages/Authentication/changepassword.vue index a5a5fc5..e830e1b 100644 --- a/src/pages/Authentication/changepassword.vue +++ b/src/pages/Authentication/changepassword.vue @@ -6,7 +6,7 @@ - Change Password + Technology Succes diff --git a/src/pages/Authentication/forgetpassword.vue b/src/pages/Authentication/forgetpassword.vue index 51fe7e5..3ec04ec 100644 --- a/src/pages/Authentication/forgetpassword.vue +++ b/src/pages/Authentication/forgetpassword.vue @@ -3,7 +3,7 @@ logo -

School-Management

+

Technology Succes

diff --git a/src/pages/Class/addclass.vue b/src/pages/Class/addclass.vue index 0cd43ee..63097f0 100644 --- a/src/pages/Class/addclass.vue +++ b/src/pages/Class/addclass.vue @@ -291,7 +291,8 @@ export default { sortable: false, value: "No" }, - { text: "Class Name", value: "classNum", sortable: false, align: "center" }, + { text: "Class No", value: "classNum", sortable: false, align: "center" }, + { text: "Action", value: "", sortable: false, align: "center" } ], desserts: [], @@ -327,16 +328,14 @@ export default { this.showLoader = true; var token = this.$store.state.token; http() - .get("/getClassesList", { - headers: { Authorization: "Bearer " + token } - }) + .get("/getClassesList") .then(response => { this.desserts = response.data.data; this.showLoader = false; - // console.log("getClassList=====>", this.desserts); + // console.log("getClassList=====>", response); }) .catch(err => { - // console.log("err====>", err); + console.log("err====>", err); this.showLoader = false; this.$router.replace({ path: "/" }); }); diff --git a/src/pages/Event/event.vue b/src/pages/Event/event.vue index 5f61b82..ba09a78 100644 --- a/src/pages/Event/event.vue +++ b/src/pages/Event/event.vue @@ -4,7 +4,9 @@ + + - + @@ -205,6 +207,7 @@ >{{ text }} +
- + @@ -320,6 +323,19 @@ + + + + + + + + clear @@ -369,12 +385,12 @@ export default { gender: ["Male", "Female"], AddUsercredentials: {}, pagination: { - rowsPerPage: 15 + rowsPerPage: 19 }, - imageData: {}, imageName: "", imageUrl: "", imageFile: "", + upload: '', titleRules: [v => !!v || " Title is required"], descriptionRules: [v => !!v || " Description is required"], headers: [ @@ -433,7 +449,8 @@ export default { onFilePicked(e) { // console.log(e) const files = e.target.files; - this.imageData.upload = e.target.files[0]; + 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) { @@ -444,8 +461,8 @@ export default { fr.addEventListener("load", () => { this.imageUrl = fr.result; this.imageFile = files[0]; // this is an image file that can be sent to server... - this.imageData.imageUrl = URL.createObjectURL(this.imageFile); - console.log("upload=======>", this.imageData.imageUrl); + // this.imageData.imageUrl = URL.createObjectURL(this.imageFile); + console.log("upload=======>", this.imageUrl); console.log("imageFile", this.imageFile); }); } else { @@ -531,15 +548,18 @@ export default { if (this.$refs.form.validate()) { let imageData = new FormData(); imageData.append("upload", this.imageFile); + imageData.append("title", this.addEvents.title); + imageData.append("description", this.addEvents.description); console.log(imageData); - let addEvent = { - title: this.addEvents.title, - description: this.addEvents.description - }; + // let addEvent = { + // title: this.addEvents.title, + // description: this.addEvents.description, + // imageData + // }; http() - .post("/createEvent", addEvent) + .post("/createEvent", imageData) .then(response => { - // console.log("addEvent=====>",addEvent) + console.log("addEvent=====>",imageData) if ((this.snackbar = true)) { this.text = "New user added successfully"; } @@ -552,6 +572,15 @@ export default { this.text = error.response.data.message; } }); + var form_data = new FormData(); + for (var key in addEvent) { + if (key === 'upload') { + form_data.append(key, this.imageFile); + } + else { + form_data.append(key, addEvent[key]) + } + } } }, mail() {}, @@ -562,7 +591,7 @@ export default { save() { let imageData = new FormData(); imageData.append("upload", this.imageFile); - console.log(imageData); + console.log("imageData",imageData); let editEvent = { eventId: this.editedItem._id, title: this.editedItem.title, diff --git a/src/pages/News/news.vue b/src/pages/News/news.vue index 756ce12..6cbdfeb 100644 --- a/src/pages/News/news.vue +++ b/src/pages/News/news.vue @@ -5,7 +5,7 @@ - + - - - + > - - - - - - - - - - - - - - - - - + + + + + @@ -399,6 +369,22 @@ + + + + + + + + + + @@ -448,10 +434,12 @@ export default { pagination: { rowsPerPage: 15 }, - imageData: {}, imageName: "", imageUrl: "", imageFile: "", + image: [], + upload:"", + files:[], titleRules: [v => !!v || " Tilte is required"], descriptionRules: [v => !!v || " Description is required"], headers: [ @@ -469,7 +457,7 @@ export default { editedIndex: -1, addNews: { title: "", - description: "" + description: "", }, editedItem: { title: "", @@ -499,6 +487,7 @@ export default { }), methods: { getSections(_id) { + console.log("_id",_id) var token = this.$store.state.token; http() .get( @@ -524,21 +513,36 @@ export default { onFilePicked(e) { // console.log(e) const files = e.target.files; - this.imageData.upload = e.target.files[0]; + /** 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 news card **/ + const test = Array.from(files).forEach((file, idx) => { 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... - this.imageData.imageUrl = URL.createObjectURL(this.imageFile); - console.log("upload=======>", this.imageData.imageUrl); - console.log("imageFile", this.imageFile); + const getResult = new Promise(resolve => { + fr.onload = e => { + this.files.push({ + id: idx, + url: e.target.result + }); + }; }); + 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... + console.log("uploadImage=======>", this.imageFile ); + }); } else { this.imageName = ""; this.imageFile = ""; @@ -619,19 +623,21 @@ export default { this.dialog1 = false; }, submit() { + console.log("===========>",this.image) if (this.$refs.form.validate()) { - let imageData = new FormData(); - imageData.append("upload", this.imageFile); - console.log(imageData); - let addNewses = { - title: this.addNews.title, - description: this.addNews.description, - // imageData - }; + let newsData = new FormData(); + for( var i = 0; i < this.imageFile.length; i++ ){ + let file = this.imageFile[i]; + newsData.append("upload", file ); + } + newsData.append("title",this.addNews.title); + newsData.append("description",this.addNews.description); + console.log("newsDataData",newsData); + http() - .post("/createNews", addNewses) + .post("/createNews", newsData) .then(response => { - // console.log(addNewses) + console.log(newsData) if ((this.snackbar = true)) { this.text = "New user added successfully"; } @@ -639,7 +645,6 @@ export default { this.clear(); }) .catch(error => { - // console.log(error); if ((this.snackbar = true)) { this.text = error.response.data.message; } diff --git a/src/pages/Section/section.vue b/src/pages/Section/section.vue index 94a6a90..3c531ab 100644 --- a/src/pages/Section/section.vue +++ b/src/pages/Section/section.vue @@ -244,7 +244,7 @@ { // console.log("err====>", err); this.showLoader = false; - this.$router.replace({ path: '/' }); + // this.$router.replace({ path: '/' }); }); }, editItem(item) { @@ -457,16 +465,16 @@ export default { submit() { if (this.$refs.forms.validate()) { let addSection = { - name: this.editedItem.name, + name: this.add.name, classId: this.select, - session:this.editedItem.session + session:this.add.session }; console.log(addSection) http() .post("/createSection", addSection) .then(response => { console.log(addSection) - // this.getStudentList(); + this.getSectionList(); if (this.snackbar = true) { this.text = "New user added successfully"; } diff --git a/src/pages/Teachers/teachers.vue b/src/pages/Teachers/teachers.vue index 37f66e5..bc9f9e3 100644 --- a/src/pages/Teachers/teachers.vue +++ b/src/pages/Teachers/teachers.vue @@ -90,15 +90,15 @@ @@ -299,7 +299,7 @@ label="Select Image" @click="pickFile" v-model="imageName" - prepend-icon="attach_file" + append-icon="attach_file" > @@ -553,7 +553,7 @@ @change="onFilePicked" > --> import( + /* webpackChunkName: "routes" */ + /* webpackMode: "lazy-once" */ + `@/pages/Dasboard/dashbord` + ) + }, + { path: '/changepassword', meta: { }, name: 'changepassword', -- 2.0.0