This commit is contained in:
Matej Glasnák committed 2023-02-01 14:58:17 +01:00
1 parent 0cf30d75e3
commit 3902cbd601
5 files changed
+97 -6

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
<template>
<input type="file" name="file" id="fileInput" class="hidden-input" accept="*"
@change="onChange" ref="fileUpload"
/>
<br>
<br>
<v-btn @click="createWithoutFile()">CREATE without file</v-btn>
<br>
<br>
<v-btn @click="createWithFile()">CREATE with file</v-btn>
</template>
<script>
import moment from 'moment'
import axios from 'axios'
export default {
data() {
return {
files: null
}
},
methods: {
async createWithoutFile() {
const masterTask = this._getMastertaskObject()
await axios.post('https://taskmanager.internal.studiotem.com/api/v1/mastertasks', this._objectToFormData(masterTask))
console.log(await this.$axios.get_data('v1/mastertasks'))
},
async createWithFile() {
if (!this.files) return alert('No files uploaded')
const masterTask = this._getMastertaskObject()
masterTask.data.files = this.files
await axios.post('https://taskmanager.internal.studiotem.com/api/v1/mastertasks', this._objectToFormData(masterTask))
console.log(await this.$axios.get_data('v1/mastertasks'))
},
_getMastertaskObject() {
const employees = [{
id: 1,
duration: 1000
}]
return {
data: {
name: `name-${3}`,
description: `description`,
duration: 1231,
deadline: moment().format('YYYY-MM-DD HH:MM:SS'),
project_id: 1,
team_id: 1,
employees: employees
}
}
},
onChange($event) {
this.files = $event.target.files
},
_buildFormData(formData, data, parentKey) {
if (data && typeof data === 'object' && !(data instanceof Date) && !(data instanceof File))
Object.keys(data).forEach(key => this._buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key));
else
formData.append(parentKey, data == null ? '' : data);
},
_objectToFormData(data) {
const formData = new FormData()
this._buildFormData(formData, data)
return formData
}
}
}
</script>
+6
View File
@@ -90,6 +90,12 @@ const routes: Array<RouteRecordRaw> = [
name: 'Search', name: 'Search',
meta: { title: 'Search Results' }, meta: { title: 'Search Results' },
component: () => import('@/plugins/lib@search/search/search.vue') component: () => import('@/plugins/lib@search/search/search.vue')
},
{
path: '/app/testing',
name: 'Testing',
meta: { title: 'Testing' },
component: () => import('@/plugins/_testing/testing.vue')
} }
] ]
} }
@@ -29,4 +29,7 @@
opacity: 2 opacity: 2
position: absolute position: absolute
left: 92% left: 92%
top: 25% top: 25%
.relative
position: relative !important
@@ -38,6 +38,7 @@
v-model="team.employees[index]._fullName" v-model="team.employees[index]._fullName"
> >
</v-text-field> </v-text-field>
<v-icon <v-icon
class="remove-input" class="remove-input"
@click.stop="team.employees.splice(index, 1)" @click.stop="team.employees.splice(index, 1)"
@@ -125,9 +126,9 @@ export default {
try { try {
if (this.team.id) if (this.team.id)
await this.$axios.patch_auth(`v1/teams/${this.team.id}`, this.team) await this.$axios.put_auth_data(`v1/teams/${this.team.id}`, this.team)
else else
await this.$axios.post_auth(`v1/teams`, this.team) await this.$axios.post_auth_data(`v1/teams`, this.team)
this.$emit('update', this.team) this.$emit('update', this.team)
this.closeModal() this.closeModal()
+3 -3
View File
@@ -119,7 +119,7 @@ export default {
}, },
async put(url: string, params = null, config?: any) { async put(url: string, params = null, config?: any) {
return axios.put(url, params, config) return axios.put(url, {data: params}, config)
.then(response => response.data) .then(response => response.data)
.catch(error => Promise.reject(error)) .catch(error => Promise.reject(error))
}, },
@@ -133,7 +133,7 @@ export default {
}, },
async put_data(url: string, params = null, config?: any) { async put_data(url: string, params = null, config?: any) {
return axios.put(url, params, config) return axios.put(url, {data: params}, config)
.then(response => response.data.data) .then(response => response.data.data)
.catch(error => Promise.reject(error.response || error)) .catch(error => Promise.reject(error.response || error))
}, },
@@ -141,7 +141,7 @@ export default {
async put_auth_data(url: string, params = null, config?: any) { async put_auth_data(url: string, params = null, config?: any) {
config = this._config(config) config = this._config(config)
return axios.put(url, params, config) return axios.put(url, {data: params}, config)
.then(response => response.data.data) .then(response => response.data.data)
.catch(error => Promise.reject(error.response || error)) .catch(error => Promise.reject(error.response || error))
}, },