Skip to content

Commit 66cbfd2

Browse files
committed
refactor: support sq add view to dashboard
1 parent 17fcfd4 commit 66cbfd2

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ function showSql() {
189189
}
190190
191191
function addToDashboard() {
192+
const viewInfo = chartRef.value?.getViewInfo()
192193
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
193-
addViewRef.value?.optInit()
194+
addViewRef.value?.optInit(viewInfo)
194195
}
195196
196197
function copy() {

frontend/src/views/chat/component/DisplayChartBlock.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,22 @@ function onTypeChange() {
5454
chartRef.value?.renderChart()
5555
})
5656
}
57-
57+
function getViewInfo() {
58+
return {
59+
chart: {
60+
columns: chartObject.value?.columns,
61+
type: props.chartType,
62+
xAxis: xAxis.value,
63+
yAxis: yAxis.value,
64+
series: series.value,
65+
title: chartObject.value.title,
66+
},
67+
data: { data: props.data },
68+
}
69+
}
5870
defineExpose({
5971
onTypeChange,
72+
getViewInfo,
6073
})
6174
</script>
6275

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ const saveResourcePrepare = () => {
8686
component['id'] = newComponentId
8787
component['y'] = bottomPosition + 1
8888
canvasDataResult.push(component)
89+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
90+
state.viewInfo.chart['id'] = newComponentId
8991
canvasViewInfoPreview[newComponentId] = state.viewInfo
9092
const commonParams = {
9193
componentData: canvasDataResult,

0 commit comments

Comments
 (0)