Browse Source

feat(gui-v2): replace $axios implementation

pull/2795/head
Wing-Kam Wong 2 years ago
parent
commit
32c11ff7c4
  1. 100
      packages/nc-gui-v2/components/dlg/AirtableImport.vue

100
packages/nc-gui-v2/components/dlg/AirtableImport.vue

@ -24,6 +24,7 @@ const progress = ref([])
const socket = ref() const socket = ref()
const syncSourceUrlOrId = ref('') const syncSourceUrlOrId = ref('')
const syncSource = ref({ const syncSource = ref({
id: '',
type: 'Airtable', type: 'Airtable',
details: { details: {
syncInterval: '15mins', syncInterval: '15mins',
@ -67,57 +68,66 @@ async function saveAndSync() {
} }
async function createOrUpdate() { async function createOrUpdate() {
// TODO: check $axios implementation try {
// try { const { id, ...payload } = syncSource.value
// const { id, ...payload } = syncSource.value; if (id !== '') {
// if (id) { await $fetch(`/api/v1/db/meta/syncs/${id}`, {
// await $axios.patch(`/api/v1/db/meta/syncs/${id}`, payload); method: 'PATCH',
// } else { body: payload,
// syncSource.value = (await $axios.post(`/api/v1/db/meta/projects/${project.value.id}/syncs`, payload)).data; })
// } } else {
// } catch (e: any) { const { data }: any = await $fetch(`/api/v1/db/meta/projects/${project.value.id}/syncs`, {
// toast.error(await extractSdkResponseErrorMsg(e)) method: 'POST',
// } body: payload,
})
syncSource.value = data
}
} catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e))
}
} }
async function loadSyncSrc() { async function loadSyncSrc() {
// const { const {
// data: { list: srcs }, data: { list: srcs },
// } = await $axios.get(`/api/v1/db/meta/projects/${project.id}/syncs`) }: any = await $fetch(`/api/v1/db/meta/projects/${project.value.id}/syncs`, {
// if (srcs && srcs[0]) { method: 'GET',
// srcs[0].details = srcs[0].details || {} })
// syncSource.value = this.migrateSync(srcs[0]) if (srcs && srcs[0]) {
// syncSourceUrlOrId.value = srcs[0].details.shareId srcs[0].details = srcs[0].details || {}
// } else { syncSource.value = migrateSync(srcs[0])
// syncSource.value = { syncSourceUrlOrId.value = srcs[0].details.shareId
// type: 'Airtable', } else {
// details: { syncSource.value = {
// syncInterval: '15mins', id: '',
// syncDirection: 'Airtable to NocoDB', type: 'Airtable',
// syncRetryCount: 1, details: {
// apiKey: '', syncInterval: '15mins',
// shareId: '', syncDirection: 'Airtable to NocoDB',
// options: { syncRetryCount: 1,
// syncViews: true, apiKey: '',
// syncData: true, shareId: '',
// syncRollup: false, options: {
// syncLookup: true, syncViews: true,
// syncFormula: false, syncData: true,
// syncAttachment: true, syncRollup: false,
// }, syncLookup: true,
// }, syncFormula: false,
// } syncAttachment: true,
// } },
},
}
}
} }
function sync() { async function sync() {
step.value = 2 step.value = 2
// TODO: check $axios implementation const { data }: any = await $fetch(`/api/v1/db/meta/syncs/${syncSource.value.id}/trigger`, {
// $axios.post(`/api/v1/db/meta/syncs/${syncSource.value.id}/trigger`, payload, { method: 'POST',
// params: { body: {
// id: this.socket.id, id: socket.value.id,
// }, },
// }); })
} }
function migrateSync(src: any) { function migrateSync(src: any) {

Loading…
Cancel
Save