-
-
-
-
-
-
-
- mdi-file-excel-outline
+
+
+
+
+
+
+
+
+ mdi-file-excel-outline
+
+ Import
+
+
+ Create template from Excel
+
+
+
+
+
+ mdi-information-outline
+
+
+
+
-
+
+
+
+ mdi-close
-
- Reset template
- -->
+ Reset
+
+
+
+
+ mdi-plus
+
+ New table
+
-
-
- mdi-close
-
- Reset
-
-
-
-
- mdi-plus
-
- New table
-
-
-
-
- {{ id || localId ? 'Update in' : 'Submit to' }} NocoDB
-
+
+
+ {{ id || localId ? 'Update in' : 'Submit to' }} NocoDB
+
+
@@ -620,7 +622,7 @@ export default {
return this.url && this.url.split('/').pop()
},
projectTemplate() {
- return {
+ const template = {
...this.project,
tables: (this.project.tables || []).map((t) => {
const table = { tn: t.tn, columns: [], hasMany: [], manyToMany: [], belongsTo: [], v: [] }
@@ -673,6 +675,10 @@ export default {
return table
})
}
+
+ this.$emit('update:templateData', template)
+
+ return template
}
},
@@ -851,7 +857,7 @@ export default {
isRelation(col) {
return col.uidt === 'LinkToAnotherRecord' ||
- col.uidt === 'ForeignKey'
+ col.uidt === 'ForeignKey'
},
isLookup(col) {
return col.uidt === 'Lookup'
@@ -864,11 +870,11 @@ export default {
},
isLookupOrRollup(col) {
return this.isLookup(col) ||
- this.isRollup(col)
+ this.isRollup(col)
},
isSelect(col) {
return col.uidt === 'MultiSelect' ||
- col.uidt === 'SingleSelect'
+ col.uidt === 'SingleSelect'
},
addNewColumnRow(table, uidt) {
table.columns.push({
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json
index d65bda3cdf..56bb0dd642 100644
--- a/packages/nc-gui/lang/en.json
+++ b/packages/nc-gui/lang/en.json
@@ -8,7 +8,8 @@
"subtext_1_tooltip": "Create a new project",
"subtext_2": "Create By Connecting
To An External Database",
"subtext_2_tooltip": "Supports MySQL, PostgreSQL, SQL Server & SQLite",
- "from_template": "Create Project from template"
+ "from_template": "Create Project from template",
+ "from_excel": "Create Project from excel"
},
"search_project": "Search Project",
"import_metadata": "Import Metadata",
diff --git a/packages/nc-gui/pages/projects/index.vue b/packages/nc-gui/pages/projects/index.vue
index 3fb0066fe6..4daf47f7d5 100644
--- a/packages/nc-gui/pages/projects/index.vue
+++ b/packages/nc-gui/pages/projects/index.vue
@@ -211,6 +211,27 @@
/>
+
+
+
+
+ mdi-file-excel-outline
+
+
+
+
+
+
+
@@ -686,6 +707,7 @@
:dialog-show="dialogShow"
:heading="confirmMessage"
/>
+
@@ -696,9 +718,11 @@ import ShareIcons from '../../components/share-icons'
import SponsorMini from '@/components/sponsorMini'
import colors from '~/mixins/colors'
import TemplatesModal from '~/components/templates/templatesModal'
+import ExcelImport from '~/components/import/excelImport'
export default {
components: {
+ ExcelImport,
TemplatesModal,
ShareIcons,
SponsorMini,
@@ -711,6 +735,7 @@ export default {
},
data() {
return {
+ excelImportModal: false,
templatesModal: false,
overlayVisible: true,
showCommunity: false,
@@ -979,6 +1004,10 @@ export default {
onCreateProjectFromTemplate() {
this.templatesModal = true
},
+ onCreateProjectFromExcel() {
+ // this.$refs.excelImport.selectFile()
+ this.excelImportModal = true
+ },
async importProjectFromJSON() {
},
onTourCompletion() {
diff --git a/packages/nc-gui/plugins/ncApis/index.js b/packages/nc-gui/plugins/ncApis/index.js
index fcdacfa2a8..4ced54aa1e 100644
--- a/packages/nc-gui/plugins/ncApis/index.js
+++ b/packages/nc-gui/plugins/ncApis/index.js
@@ -5,7 +5,7 @@ export default function({ store: $store, $axios, ...rest }, inject) {
let projectId = null
inject('ncApis', {
- get: ({ table, dbAlias = 'db', env = '_noco' }) => {
+ get: ({ table, dbAlias = 'db', env = '_noco', type }) => {
if (!$store.state.meta.metas[table]) {
return
}
@@ -19,7 +19,7 @@ export default function({ store: $store, $axios, ...rest }, inject) {
instanceRefs[env][dbAlias][table] = ApiFactory.create(
table,
- $store.getters['project/GtrProjectType'],
+ type || $store.getters['project/GtrProjectType'],
{ $store, $axios, projectId, dbAlias, env, table }
)
diff --git a/packages/nc-gui/plugins/ncApis/restApi.js b/packages/nc-gui/plugins/ncApis/restApi.js
index 722a3e0749..b26c9bf13b 100644
--- a/packages/nc-gui/plugins/ncApis/restApi.js
+++ b/packages/nc-gui/plugins/ncApis/restApi.js
@@ -93,6 +93,17 @@ export default class RestApi {
})).data
}
+ async insertBulk(data, {
+ params = {}
+ } = {}) {
+ return (await this.$axios({
+ method: 'post',
+ url: `/nc/${this.$ctx.projectId}/api/v1/${this.table}/bulk`,
+ data,
+ params
+ })).data
+ }
+
async delete(id) {
return this.$axios({
method: 'delete',
diff --git a/packages/nc-gui/store/meta.js b/packages/nc-gui/store/meta.js
index 8bc833cdd2..8869501f31 100644
--- a/packages/nc-gui/store/meta.js
+++ b/packages/nc-gui/store/meta.js
@@ -16,7 +16,7 @@ export const mutations = {
}
export const actions = {
- async ActLoadMeta({ state, commit, dispatch }, { tn, env, dbAlias, force }) {
+ async ActLoadMeta({ state, commit, dispatch }, { tn, env = '_noco', dbAlias = 'db', force }) {
if (!force && state.loading[tn]) {
return await new Promise((resolve) => {
const unsubscribe = this.app.store.subscribe((s) => {
diff --git a/packages/nc-gui/store/sqlMgr.js b/packages/nc-gui/store/sqlMgr.js
index 66b7a7fba4..adccc9a68f 100644
--- a/packages/nc-gui/store/sqlMgr.js
+++ b/packages/nc-gui/store/sqlMgr.js
@@ -361,6 +361,8 @@ export const actions = {
dispatch
}, [args, op, opArgs, cusHeaders, cusAxiosOptions, queryParams, returnResponse]) {
const params = {}
+ params.project_id = rootState.project.projectId
+
if (this.$router.currentRoute && this.$router.currentRoute.params) {
if (this.$router.currentRoute.params.project_id) {
params.project_id = this.$router.currentRoute.params.project_id
@@ -419,6 +421,7 @@ export const actions = {
return data
} catch (e) {
+ console.log(e)
const err = new Error(e.response.data.msg)
err.response = e.response
throw err
diff --git a/packages/nocodb/src/lib/noco/meta/NcMetaIOImpl.ts b/packages/nocodb/src/lib/noco/meta/NcMetaIOImpl.ts
index 69d2b2a0df..057c590bff 100644
--- a/packages/nocodb/src/lib/noco/meta/NcMetaIOImpl.ts
+++ b/packages/nocodb/src/lib/noco/meta/NcMetaIOImpl.ts
@@ -353,7 +353,7 @@ export default class NcMetaIOImpl extends NcMetaIO {
// }
}
config.id = id;
- const project = {
+ const project: any = {
id,
title: projectName,
description,
@@ -368,6 +368,8 @@ export default class NcMetaIOImpl extends NcMetaIO {
created_at: this.knexConnection?.fn?.now(),
updated_at: this.knexConnection?.fn?.now()
});
+
+ project.prefix = config.prefix;
return project;
} catch (e) {
console.log(e);