Skip to content

Commit 8e4567c

Browse files
committed
feat: datasource UI
1 parent 4fe3a75 commit 8e4567c

File tree

5 files changed

+142
-18
lines changed

5 files changed

+142
-18
lines changed

frontend/src/style.less

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,6 @@ h1 {
5555
line-height: 1.1;
5656
}
5757

58-
button {
59-
border-radius: 8px;
60-
border: 1px solid transparent;
61-
padding: 0.6em 1.2em;
62-
font-size: 1em;
63-
font-weight: 500;
64-
font-family: inherit;
65-
background-color: #1a1a1a;
66-
cursor: pointer;
67-
transition: border-color 0.25s;
68-
}
69-
7058
.card {
7159
padding: 2em;
7260
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<template>
2+
<el-drawer
3+
v-model="drawer"
4+
direction="btt"
5+
:destroy-on-close="true"
6+
:close-on-click-modal="false"
7+
size="80%"
8+
>
9+
<template #header>
10+
<div>Detail</div>
11+
</template>
12+
<template #default>
13+
<el-row :gutter="20">
14+
<el-col :span="12">
15+
<el-table-v2
16+
:columns="tableColumns"
17+
:data="tableData"
18+
:width="700"
19+
:height="400"
20+
fixed
21+
/>
22+
</el-col>
23+
<el-col :span="12">
24+
<el-table-v2
25+
:columns="fieldColumns"
26+
:data="fieldData"
27+
:width="700"
28+
:height="400"
29+
fixed
30+
/>
31+
</el-col>
32+
</el-row>
33+
</template>
34+
<template #footer>
35+
<div style="flex: auto">
36+
<el-button @click="cancelClick">cancel</el-button>
37+
<el-button type="primary" @click="confirmClick">confirm</el-button>
38+
</div>
39+
</template>
40+
</el-drawer>
41+
</template>
42+
43+
<script lang="tsx" setup>
44+
import { ref } from 'vue'
45+
import { datasourceApi } from '@/api/datasource'
46+
import { ElButton } from 'element-plus'
47+
import { h } from 'vue'
48+
49+
const drawer = ref<boolean>(false)
50+
const tableColumns = ref<any>([
51+
{
52+
key:"tableName",
53+
dataKey:"tableName",
54+
title: 'Table Name',
55+
width: 150,
56+
},
57+
{
58+
key:"tableRemark",
59+
dataKey:"tableRemark",
60+
title: 'Table Remark',
61+
width: 300,
62+
},
63+
{
64+
key: 'operations',
65+
title: 'Operations',
66+
cellRenderer: ({ rowData }) => {
67+
return h(ElButton,{
68+
onClick: () => showFields(rowData.tableName)
69+
},"Show Fields")
70+
},
71+
width: 150,
72+
align: 'center',
73+
}
74+
])
75+
const tableData = ref<any>([])
76+
const fieldColumns = ref<any>([
77+
{
78+
key:"fieldName",
79+
dataKey:"fieldName",
80+
title: 'Field Name',
81+
width: 150,
82+
},
83+
{
84+
key:"fieldType",
85+
dataKey:"fieldType",
86+
title: 'Field Type',
87+
width: 150,
88+
},
89+
{
90+
key:"fieldRemark",
91+
dataKey:"fieldRemark",
92+
title: 'Field Remark',
93+
width: 300,
94+
}
95+
])
96+
const fieldData = ref<any>([])
97+
const dsId = ref<Number>(0)
98+
99+
const open = (id: Number) => {
100+
drawer.value = true
101+
dsId.value = id
102+
datasourceApi.getTables(id).then((res) => {
103+
tableData.value = res
104+
})
105+
}
106+
107+
const showFields = (tableName: string) =>{
108+
datasourceApi.getFields(dsId.value, tableName).then((res) => {
109+
fieldData.value = res
110+
})
111+
}
112+
113+
const cancelClick = () => {
114+
drawer.value = false
115+
}
116+
117+
const confirmClick = () => {
118+
// save something
119+
cancelClick()
120+
}
121+
122+
defineExpose({ open })
123+
</script>
124+
125+
<style lang="less" scoped>
126+
127+
</style>

frontend/src/views/ds/form.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
v-model="dialogVisible"
44
title="Add Datasource"
55
width="500"
6+
:destroy-on-close="true"
67
>
78
<el-form :model="form" label-width="auto" ref="dsFormRef" :rules="rules">
89
<el-form-item label="Name" prop="name">
@@ -169,4 +170,4 @@ const check = () => {
169170
defineExpose({ open })
170171
</script>
171172
<style lang="less" scoped>
172-
</style>./js/aes
173+
</style>

frontend/src/views/ds/index.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,31 @@
3535
</div>
3636
<div class="connection-status" :class="`${getStatus(ds.status)}`">{{ ds.status }}</div>
3737
<div class="connection-actions">
38-
<el-button class="action-btn" @click="getTables(ds.id)">Info</el-button>
38+
<el-button class="action-btn" circle @click="getTables(ds.id)" :icon="List" />
3939
<el-button type="primary" class="action-btn" circle @click="editDs(ds)" :icon="IconOpeEdit"/>
4040
<el-button type="danger" class="action-btn" circle @click="deleteDs(ds)" :icon="IconOpeDelete"/>
4141
</div>
4242
</div>
4343
</div>
4444
</div>
4545
<DsForm ref="dsForm" @refresh="refresh"/>
46+
<TableList ref="tableList" />
4647
</template>
4748
<script lang="ts" setup>
4849
import IconOpeAdd from '@/assets/svg/operate/ope-add.svg'
4950
import IconOpeEdit from '@/assets/svg/operate/ope-edit.svg'
5051
import IconOpeDelete from '@/assets/svg/operate/ope-delete.svg'
51-
import { Search } from '@element-plus/icons-vue'
52+
import { Search, List } from '@element-plus/icons-vue'
5253
import { ref, onMounted } from 'vue'
5354
import DsForm from './form.vue'
5455
import { datasourceApi } from '@/api/datasource'
5556
import { datetimeFormat } from '@/utils/utils'
5657
import { ElMessageBox } from 'element-plus'
58+
import TableList from './TableList.vue'
5759
5860
const searchValue = ref<string>('')
5961
const dsForm = ref()
62+
const tableList = ref()
6063
const dsList = ref<any>([])// show ds list
6164
const allDsList = ref<any>([])// all ds list
6265
@@ -124,9 +127,10 @@ const getTables = (id: Number) => {
124127
// console.log(res)
125128
// })
126129
127-
datasourceApi.execSql(id,'select id,name,table_name from core_dataset_table limit 10').then((res) => {
128-
console.log(res)
129-
})
130+
// datasourceApi.execSql(id,'select id,name,table_name from core_dataset_table limit 10').then((res) => {
131+
// console.log(res)
132+
// })
133+
tableList.value.open(id)
130134
}
131135
132136
onMounted(() => {

frontend/vite.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@ export default defineConfig(({ mode }) => {
4343
},
4444
},
4545
},
46+
esbuild: {
47+
jsxFactory: 'h',
48+
jsxFragment: 'Fragment',
49+
},
4650
}
4751
})

0 commit comments

Comments
 (0)