Skip to content

Commit 80cae12

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 2d62dcb + 3f448ac commit 80cae12

File tree

12 files changed

+255
-83
lines changed

12 files changed

+255
-83
lines changed

backend/apps/chat/curd/chat.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def get_chat_with_records(session: SessionDep, chart_id: int, current_user: Curr
8585
else:
8686
chat_info.datasource_exists = True
8787
chat_info.datasource_name = ds.name
88+
chat_info.ds_type = ds.type
8889

8990
record_list = session.query(ChatRecord).options(
9091
load_only(ChatRecord.id, ChatRecord.chat_id, ChatRecord.create_time, ChatRecord.finish_time,

backend/apps/chat/models/chat_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class ChatInfo(BaseModel):
8989
chat_type: str = "chat"
9090
datasource: Optional[int] = None
9191
engine_type: str = ''
92+
ds_type: str = ''
9293
datasource_name: str = ''
9394
datasource_exists: bool = True
9495
records: List[ChatRecord | dict] = []

backend/apps/datasource/crud/datasource.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,9 @@ def preview(session: SessionDep, current_user: CurrentUser, id: int, data: Table
292292
{where}
293293
LIMIT 100"""
294294
elif ds.type == "sqlServer":
295-
sql = f"""SELECT [{"], [".join(fields)}] FROM [{conf.dbSchema}].[{data.table.table_name}]
295+
sql = f"""SELECT TOP 100 [{"], [".join(fields)}] FROM [{conf.dbSchema}].[{data.table.table_name}]
296296
{where}
297-
ORDER BY [{fields[0]}]
298-
OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY"""
297+
"""
299298
elif ds.type == "pg" or ds.type == "excel":
300299
sql = f"""SELECT "{'", "'.join(fields)}" FROM "{conf.dbSchema}"."{data.table.table_name}"
301300
{where}
@@ -408,4 +407,4 @@ def filter_list(list_a, list_b):
408407

409408

410409
def is_normal_user(current_user: CurrentUser):
411-
return current_user.id != 1 and (current_user.weight is not None and current_user.weight != 1)
410+
return current_user.id != 1

frontend/src/api/chat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export class Chat {
134134
chat_type?: string
135135
datasource?: number
136136
engine_type?: string
137+
ds_type?: string
137138

138139
constructor()
139140
constructor(

frontend/src/style.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
--ed-color-primary-dark-2: #189e7a !important;
3232
--ed-color-primary-1a: #1cba901a;
3333
--ed-color-primary-light-5: #3ec4a1 !important;
34+
--ed-border-color: #d9dcdf !important;
3435
}
3536

3637
a {

frontend/src/views/chat/ChatListContainer.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ function onChatRenamed(chat: Chat) {
214214
/>
215215
</el-header>
216216
<el-main class="chat-list">
217+
<div v-if="!computedChatList.length" class="empty-search">
218+
{{ !!search ? $t('datasource.relevant_content_found') : $t('dashboard.no_chat') }}
219+
</div>
217220
<ChatList
221+
v-else
218222
v-model:loading="_loading"
219223
:current-chat-id="_currentChatId"
220224
:chat-list="computedChatList"
@@ -294,6 +298,16 @@ function onChatRenamed(chat: Chat) {
294298
295299
.chat-list {
296300
padding: 0 0 20px 0;
301+
302+
.empty-search {
303+
width: 100%;
304+
text-align: center;
305+
margin-top: 80px;
306+
color: #646a73;
307+
font-weight: 400;
308+
font-size: 14px;
309+
line-height: 22px;
310+
}
297311
}
298312
}
299313
</style>

frontend/src/views/chat/chat-block/ChartBlock.vue

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { ChatMessage } from '@/api/chat.ts'
33
import DisplayChartBlock from '@/views/chat/component/DisplayChartBlock.vue'
4+
import ChartPopover from '@/views/chat/chat-block/ChartPopover.vue'
45
import { computed, ref } from 'vue'
56
import { concat } from 'lodash-es'
67
import type { ChartTypes } from '@/views/chat/component/BaseChart.ts'
@@ -157,11 +158,11 @@ const chartTypeList = computed(() => {
157158
})
158159
159160
function changeTable() {
160-
chartType.value = 'table'
161-
onTypeChange()
161+
onTypeChange('table')
162162
}
163163
164-
function onTypeChange() {
164+
function onTypeChange(val: any) {
165+
chartType.value = val
165166
chartRef.value?.onTypeChange()
166167
}
167168
@@ -207,21 +208,13 @@ function addToDashboard() {
207208
<div class="buttons-bar">
208209
<div class="chart-select-container">
209210
<el-tooltip effect="dark" :content="t('chat.type')" placement="top">
210-
<el-select
211+
<ChartPopover
212+
:chartTypeList="chartTypeList"
213+
:chartType="chartType"
214+
:title="t('chat.type')"
215+
@typeChange="onTypeChange"
211216
v-if="chartTypeList.length > 0"
212-
v-model="chartType"
213-
class="chart-select"
214-
:class="{ 'chart-active': currentChartType !== 'table' }"
215-
@change="onTypeChange"
216-
>
217-
<el-option v-for="type in chartTypeList" :key="type.value" :value="type.value">
218-
<el-icon size="16">
219-
<component :is="type.icon" />
220-
</el-icon>
221-
{{ type.name }}
222-
&nbsp;
223-
</el-option>
224-
</el-select>
217+
></ChartPopover>
225218
</el-tooltip>
226219

227220
<el-tooltip effect="dark" :content="t('chat.chart_type.table')" placement="top">
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<script lang="ts" setup>
2+
import icon_done_outlined from '@/assets/svg/icon_done_outlined.svg'
3+
import { computed } from 'vue'
4+
import icon_expand_down_filled from '@/assets/svg/icon_down_outlined.svg'
5+
const props = defineProps({
6+
chartTypeList: {
7+
type: Array<any>,
8+
default: () => [],
9+
},
10+
chartType: {
11+
type: String,
12+
default: 'table',
13+
},
14+
title: {
15+
type: String,
16+
default: '',
17+
},
18+
})
19+
const currentIcon = computed(() => {
20+
return props.chartTypeList.find((ele) => ele.value === props.chartType || ele.value === 'table')
21+
.icon
22+
})
23+
const emits = defineEmits(['typeChange'])
24+
const handleDefaultChatChange = (val: any) => {
25+
emits('typeChange', val.value)
26+
}
27+
</script>
28+
29+
<template>
30+
<el-popover trigger="click" popper-class="chat-type_select" placement="bottom">
31+
<template #reference>
32+
<div class="chat-select_type" :class="chartType && chartType !== 'table' && 'active'">
33+
<component :is="currentIcon" />
34+
<el-icon style="transform: scale(0.75)" class="expand" size="16">
35+
<icon_expand_down_filled></icon_expand_down_filled>
36+
</el-icon>
37+
</div>
38+
</template>
39+
<div class="popover">
40+
<div class="popover-content">
41+
<div v-if="!!title" class="title">{{ title }}</div>
42+
<div
43+
v-for="ele in chartTypeList"
44+
:key="ele.name"
45+
class="popover-item"
46+
:class="chartType === ele.value && 'isActive'"
47+
@click="handleDefaultChatChange(ele)"
48+
>
49+
<el-icon size="16">
50+
<component :is="ele.icon" />
51+
</el-icon>
52+
<div class="model-name">{{ ele.name }}</div>
53+
<el-icon size="16" class="done">
54+
<icon_done_outlined></icon_done_outlined>
55+
</el-icon>
56+
</div>
57+
</div>
58+
</div>
59+
</el-popover>
60+
</template>
61+
62+
<style lang="less">
63+
.chat-type_select.chat-type_select {
64+
padding: 4px 0;
65+
width: 120px !important;
66+
min-width: 120px !important;
67+
box-shadow: 0px 4px 8px 0px #1f23291a;
68+
border: 1px solid #dee0e3;
69+
70+
.popover {
71+
.popover-content {
72+
padding: 0 4px;
73+
max-height: 300px;
74+
overflow-y: auto;
75+
76+
.title {
77+
width: 100%;
78+
height: 32px;
79+
margin-bottom: 2px;
80+
display: flex;
81+
align-items: center;
82+
padding-left: 8px;
83+
color: #8f959e;
84+
}
85+
}
86+
.popover-item {
87+
height: 32px;
88+
display: flex;
89+
align-items: center;
90+
padding-left: 12px;
91+
padding-right: 8px;
92+
margin-bottom: 2px;
93+
position: relative;
94+
border-radius: 4px;
95+
cursor: pointer;
96+
&:last-child {
97+
margin-bottom: 0;
98+
}
99+
&:hover {
100+
background: #1f23291a;
101+
}
102+
103+
.model-name {
104+
margin-left: 8px;
105+
font-weight: 400;
106+
font-size: 14px;
107+
line-height: 22px;
108+
max-width: 220px;
109+
}
110+
111+
.done {
112+
margin-left: auto;
113+
display: none;
114+
}
115+
116+
&.isActive {
117+
color: var(--ed-color-primary);
118+
119+
.done {
120+
display: block;
121+
}
122+
}
123+
}
124+
}
125+
}
126+
</style>
127+
128+
<style lang="less" scoped>
129+
.chat-select_type {
130+
width: 40px;
131+
height: 24px;
132+
border-radius: 4px;
133+
padding-left: 4px;
134+
display: flex;
135+
align-items: center;
136+
cursor: pointer;
137+
138+
.expand {
139+
margin-left: 4px;
140+
}
141+
142+
&:hover {
143+
background: #1f23291a;
144+
}
145+
146+
&.active {
147+
background: rgba(28, 186, 144, 0.1);
148+
color: rgba(28, 186, 144, 1);
149+
}
150+
}
151+
</style>

0 commit comments

Comments
 (0)