Skip to content

Commit e9d3f20

Browse files
committed
refactor: Optimize the logic for adding charts to the dashboard
1 parent aaaa0c6 commit e9d3f20

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ watch(
395395
</div>
396396
</el-popover>
397397
</div>
398-
<div v-if="message?.record?.chart && !isAssistant">
398+
<div v-if="message?.record?.chart && isCompletePage">
399399
<el-tooltip effect="dark" :content="t('chat.add_to_dashboard')" placement="top">
400400
<el-button class="tool-btn" text @click="addToDashboard">
401401
<el-icon size="16">

frontend/src/views/dashboard/common/AddViewDashboard.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const optInit = (viewInfo: any) => {
2020
resourceDialogShow.value = true
2121
state.viewInfo = viewInfo
2222
}
23-
const curOptDashboardId = ref(null)
2423
const state = reactive({
2524
dashboardList: [] as SQTreeNode[],
2625
viewInfo: null,
@@ -127,20 +126,19 @@ const saveResourcePrepare = () => {
127126
const saveResource = (params: any, commonParams: any) => {
128127
saveDashboardResourceTarget(params, commonParams, (res: any) => {
129128
const messageTips = t('dashboard.add_success')
130-
curOptDashboardId.value = res?.id
131-
openMessageLoading(messageTips, 'success', callbackExportSuc)
129+
openMessageLoading(messageTips, 'success', res?.id, callbackExportSuc)
132130
resetForm()
133131
})
134132
}
135133
136-
const callbackExportSuc = () => {
134+
const callbackExportSuc = (curOptDashboardIdValue: any) => {
137135
// do open dashboard
138-
const url = `#/canvas?resourceId=${curOptDashboardId.value}`
136+
const url = `#/canvas?resourceId=${curOptDashboardIdValue}`
139137
window.open(url, '_self')
140138
}
141139
142140
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
143-
const openMessageLoading = (text: string, type = 'success', cb: Function) => {
141+
const openMessageLoading = (text: string, type = 'success', dvId: any, cb: Function) => {
144142
// success error loading
145143
const customClass = `sq-message-${type || 'success'} sq-message-export`
146144
ElMessage({
@@ -161,15 +159,15 @@ const openMessageLoading = (text: string, type = 'success', cb: Function) => {
161159
size: 'small',
162160
class: 'btn-text',
163161
onClick: () => {
164-
cb()
162+
cb(dvId)
165163
},
166164
},
167165
t('dashboard.open_dashboard')
168166
),
169167
]),
170168
type,
171169
showClose: true,
172-
duration: 0,
170+
duration: 2000,
173171
customClass,
174172
})
175173
}

0 commit comments

Comments
 (0)