diff --git a/backend/apps/datasource/crud/datasource.py b/backend/apps/datasource/crud/datasource.py index 0168c420..84e5b9a6 100644 --- a/backend/apps/datasource/crud/datasource.py +++ b/backend/apps/datasource/crud/datasource.py @@ -183,6 +183,10 @@ def sync_table(session: SessionDep, ds: CoreDatasource, tables: List[CoreTable]) session.query(CoreField).filter(and_(CoreField.ds_id == ds.id, CoreField.table_id.not_in(id_list))).delete( synchronize_session=False) session.commit() + else: # delete all tables and fields in this ds + session.query(CoreTable).filter(CoreTable.ds_id == ds.id).delete(synchronize_session=False) + session.query(CoreField).filter(CoreField.ds_id == ds.id).delete(synchronize_session=False) + session.commit() def sync_fields(session: SessionDep, ds: CoreDatasource, table: CoreTable, fields: List[ColumnSchema]): diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 197e303e..2f2fe1c8 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -227,7 +227,9 @@ "cannot_be_deleted": "The chart of the dashboard uses this data source and cannot be deleted.", "got_it": "Got it", "field_original_notes": "Field original notes", - "field_notes_1": "Field notes" + "field_notes_1": "Field notes", + "no_table":"No Table", + "go_add":"Add" }, "model": { "default_model": "Default model", diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index a97339a7..45eaac16 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -230,7 +230,9 @@ "cannot_be_deleted": "仪表板的图表使用了该数据源,不可删除。", "got_it": "知道了", "field_original_notes": "字段原始备注", - "field_notes_1": "字段备注" + "field_notes_1": "字段备注", + "no_table":"暂无数据表", + "go_add":"去添加" }, "model": { "default_model": "默认模型", diff --git a/frontend/src/views/ds/DataTable.vue b/frontend/src/views/ds/DataTable.vue index 7a804af5..2e675c80 100644 --- a/frontend/src/views/ds/DataTable.vue +++ b/frontend/src/views/ds/DataTable.vue @@ -8,6 +8,7 @@ import EmptyBackground from '@/views/dashboard/common/EmptyBackground.vue' import edit from '@/assets/svg/icon_edit_outlined.svg' import { useI18n } from 'vue-i18n' import ParamsForm from './ParamsForm.vue' +import icon_add_outlined from '@/assets/svg/icon_add_outlined.svg' interface Table { name: string @@ -53,6 +54,7 @@ const { t } = useI18n() const paramsFormRef = ref() const tableList = ref([] as any[]) const loading = ref(false) +const initLoading = ref(false) const keywords = ref('') const tableListWithSearch = computed(() => { if (!keywords.value) return tableList.value @@ -67,11 +69,13 @@ const ds = ref({}) const btnSelect = ref('d') const init = () => { + initLoading.value = true datasourceApi.getDs(props.info.id).then((res) => { ds.value = res fieldList.value = [] datasourceApi.tableList(props.info.id).then((res) => { tableList.value = res + initLoading.value = false }) }) } @@ -213,7 +217,7 @@ const back = () => { -
+
{ img-type="tree" style="width: 100%; margin-top: 100px" /> +
+
+
+ {{ $t('datasource.no_table') }} +
+ + {{ $t('datasource.go_add') }} + +
+
@@ -447,6 +461,20 @@ const back = () => { } } } + + .no-data { + height: 100%; + text-align: center; + display: flex; + align-items: center; + width: 100%; + .no-data-msg { + display: inline; + width: 100%; + color: var(--ed-text-color-secondary); + font-size: var(--ed-font-size-base); + } + } } .info-table { position: absolute;