From 61d1ce8e839f3956e364ebd9c66db17df96bc8ff Mon Sep 17 00:00:00 2001 From: marcoasjunior Date: Thu, 1 Oct 2020 20:59:55 -0300 Subject: [PATCH] beautifing --- src/components/cpmEventForm.vue | 499 ++++++++++++++------------------ src/views/private/Event.vue | 6 +- 2 files changed, 218 insertions(+), 287 deletions(-) diff --git a/src/components/cpmEventForm.vue b/src/components/cpmEventForm.vue index 05389b2..26061d7 100644 --- a/src/components/cpmEventForm.vue +++ b/src/components/cpmEventForm.vue @@ -1,158 +1,65 @@ @@ -161,48 +68,49 @@ import SetMap from './cpmSetMapPoints'; import axios from 'axios'; import { - mapActions, mapGetters + mapActions, + mapGetters } from 'vuex' export default { - components:{ + components: { SetMap }, - data:() => ({ + data: () => ({ userId: localStorage.getItem('id'), - fileInput:'', - currentFilePath:'', - value:'', + fileInput: '', + currentFilePath: '', + value: '', + + selectedFile: '', - selectedFile:'', - - url:process.env.VUE_APP_BASE_URL, - uploadUrl:process.env.VUE_APP_UPLOAD_URL, + url: process.env.VUE_APP_BASE_URL, + uploadUrl: process.env.VUE_APP_UPLOAD_URL, - active:0, + active: 0, srcInputFile: null, valid: null, date: null, menu: false, - eventForm:{ - name:'', - description:'', - private:'', - latitude:'', - longitude:'', - address:'', - eventDate:'', - img:'', + eventForm: { + name: '', + description: '', + private: '', + latitude: '', + longitude: '', + address: '', + eventDate: '', + img: '', }, - name:'', - inputFile:'', + name: '', + inputFile: '', - eventData:'', + eventData: '', // eventData:{ // nameEvent:'', @@ -221,28 +129,45 @@ export default { value => (value && value.length <= 10) || 'Necessário preencher com um valor válido.', ], - items:[ - {_id:'0', name:'Fluxo'}, - {_id:'1', name:'Rock'}, - {_id:'2', name:'Baile'}, - {_id:'3', name:'Luau'}, - {_id:'4', name:'Eletrônica'}, - {_id:'5', name:'Bar'}, + items: [{ + _id: '0', + name: 'Fluxo' + }, + { + _id: '1', + name: 'Rock' + }, + { + _id: '2', + name: 'Baile' + }, + { + _id: '3', + name: 'Luau' + }, + { + _id: '4', + name: 'Eletrônica' + }, + { + _id: '5', + name: 'Bar' + }, ], - imageData:'', - imageUrl:'', - image:'', - uploadedValue:'', - photo:'', + imageData: '', + imageUrl: '', + image: '', + uploadedValue: '', + photo: '', }), - created(){ - this.eventForm.private = false + created() { + this.eventForm.private = false }, - computed: { + computed: { ...mapGetters({ test: 'test', }) @@ -253,140 +178,148 @@ export default { createEvent: 'createEvent' }), - testVuex(){ - let obj = { - nome:'sei la', - record:'21321083218' - } + testVuex() { + let obj = { + nome: 'sei la', + record: '21321083218' + } - this.$store.commit('test', obj) + this.$store.commit('test', obj) }, - save (date) { + save(date) { this.$refs.menu.save(date) }, - typeEvent(param){ - if(param == 0){ - - this.active = 0 - this.eventForm.private = false + typeEvent(param) { + if (param == 0) { - }else{ + this.active = 0 + this.eventForm.private = false - this.active = 1 - this.eventForm.private = true - - } + } else { + + this.active = 1 + this.eventForm.private = true + + } }, - onFileSelected(){ - this.$refs.fileInput.click() - // console.log(e) - // console.log("AQUI AQUI") - // console.log(event.target.files[0]) - // console.log(event.files.target) - // console.log(this.selectedFile) + onFileSelected() { + this.$refs.fileInput.click() + // console.log(e) + // console.log("AQUI AQUI") + // console.log(event.target.files[0]) + // console.log(event.files.target) + // console.log(this.selectedFile) }, - onFilePicked(event){ - const files = event.target.files - let fileName = files[0].filename - this.imageData = event.target.files[0] - - const fileReader = new FileReader() - let uploadedFile = [] - fileReader.addEventListener('load', () => { - this.imageUrl = fileReader.result - }) - fileReader.readAsDataURL(files[0]) + onFilePicked(event) { + const files = event.target.files + let fileName = files[0].filename + this.imageData = event.target.files[0] + + const fileReader = new FileReader() + let uploadedFile = [] + fileReader.addEventListener('load', () => { + this.imageUrl = fileReader.result + }) + fileReader.readAsDataURL(files[0]) }, - uploadPhoto(){ - + uploadPhoto() { + const fd = new FormData(); console.log(this.imageData) fd.append('photo', this.imageData) this.$http.post(this.uploadUrl + '/upload/image', fd) - .then(resp => { - console.log(resp) - this.eventForm.img = resp.data - }) + .then(resp => { + console.log(resp) + this.eventForm.img = resp.data + }) }, onFileChange(event) { - console.log(event) - // let selectedFile = event.taget.files[0] + console.log(event) + // let selectedFile = event.taget.files[0] - // this.srcInputFile = URL.createObjectURL(this.inputFile); - // console.log(this.srcInputFile) + // this.srcInputFile = URL.createObjectURL(this.inputFile); + // console.log(this.srcInputFile) }, - mapsParams(param){ - console.log(param) + mapsParams(param) { + console.log(param) - this.eventForm.latitude = param.latitude - this.eventForm.longitude = param.longitude + this.eventForm.latitude = param.latitude + this.eventForm.longitude = param.longitude }, - async createEvent(){ + async createEvent() { - try{ - const fd = new FormData(); - console.log(this.imageData) - fd.append('photo', this.imageData); - await axios.post(this.uploadUrl + '/upload/image', fd).then(resp => { - this.eventForm.img = resp.data - }) + try { + const fd = new FormData(); + console.log(this.imageData) + fd.append('photo', this.imageData); + await axios.post(this.uploadUrl + '/upload/image', fd).then(resp => { + this.eventForm.img = resp.data + }) - let body = { - title:this.eventForm.name, - description:this.eventForm.description, - address:this.eventForm.address, - img:this.eventForm.img, - privated:this.eventForm.private, - eventDate:this.eventForm.eventDate, - latitude:this.eventForm.latitude, - longitude:this.eventForm.longitude, - user:{id: this.userId}, - } + let body = { + title: this.eventForm.name, + description: this.eventForm.description, + address: this.eventForm.address, + img: this.eventForm.img, + privated: this.eventForm.private, + eventDate: this.eventForm.eventDate, + latitude: this.eventForm.latitude, + longitude: this.eventForm.longitude, + user: { + id: this.userId + }, + } - console.log(body) + console.log(body) - axios.post(this.url + '/event/create', body) - .then(resp => { + axios.post(this.url + '/event/create', body) + .then(resp => { - if(resp.status == 200){ - this.$toast.success('Registro efetuado!', 'Hey', { - position: "topCenter" - }) - this.$router.push('/Feed') - this.eventForm = '' - - } - }) - .catch(err => { - - this.$toast.error('Erro no registro!', 'Putz', { - position: "topCenter" - }) - - }) + if (resp.status == 200) { + this.$toast.success('Registro efetuado!', 'Hey', { + position: "topCenter" + }) + this.$router.push('/Feed') + this.eventForm = '' - } + } + }) + .catch(err => { - catch(e){ - throw e - } - - } - + this.$toast.error('Erro no registro!', 'Putz', { + position: "topCenter" + }) + + }) + } catch (e) { + throw e + } + } }, } - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/views/private/Event.vue b/src/views/private/Event.vue index bdfd9fe..84895e5 100644 --- a/src/views/private/Event.vue +++ b/src/views/private/Event.vue @@ -1,11 +1,9 @@