Browse Source

Merge pull request #4705 from nocodb/fix/3927-at-error

fix: proper error if provided url is not shared base
pull/4741/head
Raju Udava 2 years ago committed by GitHub
parent
commit
c853372d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      packages/nc-gui/components/dlg/AirtableImport.vue
  2. 2
      packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue
  3. 39
      packages/nocodb/src/lib/meta/api/sync/helpers/fetchAT.ts
  4. 7
      packages/nocodb/src/lib/meta/api/sync/helpers/job.ts
  5. 19
      packages/nocodb/src/lib/meta/api/sync/importApis.ts

6
packages/nc-gui/components/dlg/AirtableImport.vue

@ -45,8 +45,6 @@ const enableAbort = ref(false)
let socket: Socket | null
let socketInterval: NodeJS.Timer
const syncSource = ref({
id: '',
type: 'Airtable',
@ -275,10 +273,10 @@ onMounted(async () => {
onBeforeUnmount(() => {
if (socket) {
socket.removeAllListeners()
socket.off('disconnect')
socket.disconnect()
socket.removeAllListeners()
}
clearInterval(socketInterval)
})
</script>

2
packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue

@ -75,7 +75,7 @@ function onEdit(targetKey: number, action: 'add' | 'remove' | string) {
<span class="flex-1" />
<div class="flex justify-center self-center mr-2 min-w-[115px]">
<div v-show="isLoading" class="flex items-center gap-2 ml-3 text-gray-200" data-testid="nc-loading">
<div v-if="isLoading" class="flex items-center gap-2 ml-3 text-gray-200" data-testid="nc-loading">
{{ $t('general.loading') }}
<MdiLoading class="animate-infinite animate-spin" />

39
packages/nocodb/src/lib/meta/api/sync/helpers/fetchAT.ts

@ -36,6 +36,12 @@ async function initialize(shareId) {
info.cookie += ck.split(';')[0] + '; ';
}
return response.data;
})
.catch(() => {
throw {
message:
'Invalid Shared Base ID :: Ensure www.airtable.com/<SharedBaseID> is accessible. Refer https://bit.ly/3x0OdXI for details',
};
});
info.headers = JSON.parse(
@ -64,6 +70,14 @@ async function initialize(shareId) {
} catch (e) {
console.log(e);
info.initialized = false;
if (e.message) {
throw e;
} else {
throw {
message:
'Error processing Shared Base :: Ensure www.airtable.com/<SharedBaseID> is accessible. Refer https://bit.ly/3x0OdXI for details',
};
}
}
}
@ -94,7 +108,10 @@ async function read() {
return response.data;
})
.catch(() => {
throw 'Error while fetching';
throw {
message:
'Error Reading :: Ensure www.airtable.com/<SharedBaseID> is accessible. Refer https://bit.ly/3x0OdXI for details',
};
});
return {
@ -103,7 +120,10 @@ async function read() {
baseInfo: info.baseInfo,
};
} else {
throw 'Please initialize first!';
throw {
message:
'Error Initializing :: please try again !!',
};
}
}
@ -149,11 +169,17 @@ async function readView(viewId) {
return response.data;
})
.catch(() => {
throw 'Error while fetching';
throw {
message:
'Error Reading View :: Ensure www.airtable.com/<SharedBaseID> is accessible. Refer https://bit.ly/3x0OdXI for details',
};
});
return { view: resreq.data };
} else {
throw 'Please initialize first!';
throw {
message:
'Error Initializing :: please try again !!',
};
}
}
@ -192,7 +218,10 @@ async function readTemplate(templateId) {
return response.data;
})
.catch(() => {
throw 'Error while fetching';
throw {
message:
'Error Fetching :: Ensure www.airtable.com/templates/featured/<TemplateID> is accessible.',
};
});
return { template: resreq };
}

7
packages/nocodb/src/lib/meta/api/sync/helpers/job.ts

@ -190,6 +190,13 @@ export default async (
const duration = Date.now() - start;
rtc.fetchAt.count++;
rtc.fetchAt.time += duration;
if (!ft.baseId) {
throw {
message:
'Invalid Shared Base ID :: Ensure www.airtable.com/<SharedBaseID> is accessible. Refer https://bit.ly/3x0OdXI for details',
};
}
const file = ft.schema;
baseId = ft.baseId;

19
packages/nocodb/src/lib/meta/api/sync/importApis.ts

@ -107,14 +107,17 @@ export default (
baseURL = `http://localhost:${process.env.PORT || 8080}`;
}
NocoJobs.jobsMgr.add<AirtableSyncConfig>(AIRTABLE_IMPORT_JOB, {
id: req.params.syncId,
...(syncSource?.details || {}),
projectId: syncSource.project_id,
baseId: syncSource.base_id,
authToken: token,
baseURL,
});
setTimeout(() => {
NocoJobs.jobsMgr.add<AirtableSyncConfig>(AIRTABLE_IMPORT_JOB, {
id: req.params.syncId,
...(syncSource?.details || {}),
projectId: syncSource.project_id,
baseId: syncSource.base_id,
authToken: token,
baseURL,
});
}, 1000);
jobs[req.params.syncId] = {
last_message: {
msg: 'Sync started',

Loading…
Cancel
Save