Browse Source

chore(gui-v2): bypass bulk import if data is not found & reset loading

pull/2828/head
Wing-Kam Wong 2 years ago
parent
commit
b9737dca9d
  1. 15
      packages/nc-gui-v2/components/template/Editor.vue

15
packages/nc-gui-v2/components/template/Editor.vue

@ -214,6 +214,7 @@ const importTemplate = async () => {
} catch (errorInfo) {
// TODO: handle error message
console.log('Failed:', errorInfo)
loading.value = false
return
}
@ -267,6 +268,7 @@ const importTemplate = async () => {
// TODO: retrieve error msg from sdk
console.log(e)
toast.error(e.message)
loading.value = false
return
}
@ -280,11 +282,13 @@ const importTemplate = async () => {
(async (tableMeta) => {
const tableName = tableMeta.table_title
const data = importData[tableMeta.ref_table_name]
total += data.length
for (let i = 0; i < data.length; i += 500) {
const batchData = remapColNames(data.slice(i, i + 500), tableMeta.columns)
await $api.dbTableRow.bulkCreate('noco', projectName, tableName, batchData)
progress += batchData.length
if (data) {
total += data.length
for (let i = 0; i < data.length; i += 500) {
const batchData = remapColNames(data.slice(i, i + 500), tableMeta.columns)
await $api.dbTableRow.bulkCreate('noco', projectName, tableName, batchData)
progress += batchData.length
}
}
})(v),
),
@ -292,6 +296,7 @@ const importTemplate = async () => {
} catch (e: any) {
// TODO: retrieve error msg from sdk
toast.error(e.message)
loading.value = false
return
}
}

Loading…
Cancel
Save