Skip to content
Snippets Groups Projects
Verified Commit 4a250557 authored by Kirill Stytsenko's avatar Kirill Stytsenko
Browse files

Upload CSV data

parent 2aae0e5a
No related branches found
No related tags found
4 merge requests!23Sprint results,!18Merge Conflicts,!15Sprint ended, merge into master,!14CSV import
......@@ -88,7 +88,7 @@ export default {
const tableId = this.tables[this.panelIndex].id
try {
const res = await this.$axios.get(`/api/tables/api/database/${this.$route.params.db_id}/table/${tableId}`)
this.tableDetails = res.data[0] // It's a list with one element
this.tableDetails = res.data
} catch (err) {
this.$toast.error('Could not get table details.')
}
......
......@@ -6,6 +6,7 @@
<v-row dense>
<v-col cols="10">
<v-file-input
v-model="file"
accept="text/csv"
show-size
label="CSV File" />
......@@ -23,19 +24,32 @@ export default {
},
data () {
return {
loading: false
loading: false,
file: null
}
},
mounted () {
},
methods: {
upload () {
async upload () {
this.loading = true
setTimeout(() => {
const url = `/api/tables/api/database/${this.$route.params.db_id}/table/${this.$route.params.table_id}`
const data = new FormData()
data.append('file', this.file)
try {
const res = await this.$axios.post(url, data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
if (res.data.Result) {
this.$toast.success('Uploaded successfully!')
this.loading = false
this.$router.push({ path: '.' })
}, 1000)
} else {
this.$toast.error('Could not upload CSV data')
}
} catch (err) {
this.$toast.error('Could not upload data.')
}
this.loading = false
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment