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

Loading…
Cancel
Save