Skip to content

Commit 507c4de

Browse files
committed
refactor: add view to dashboard
1 parent 693ac3f commit 507c4de

File tree

6 files changed

+111
-9
lines changed

6 files changed

+111
-9
lines changed

frontend/auto-imports.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// biome-ignore lint: disable
77
export {}
88
declare global {
9+
const ElButton: typeof import('element-plus-secondary/es')['ElButton']
910
const ElMessage: typeof import('element-plus-secondary/es')['ElMessage']
1011
const ElMessageBox: typeof import('element-plus-secondary/es')['ElMessageBox']
1112
const LicenseGenerator: any

frontend/src/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"or": "Or"
4545
},
4646
"dashboard": {
47+
"open_dashboard": "Open Dashboard",
4748
"add_dashboard_name_tips": "Please Input Dashboard Name",
4849
"existing_dashboard": "Existing Dashboard",
4950
"add_success": "Add Success",

frontend/src/i18n/zh-CN.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"or": "或者"
4545
},
4646
"dashboard": {
47+
"open_dashboard": "打开仪表板",
4748
"add_dashboard_name_tips": "请输入仪表板名称",
4849
"existing_dashboard": "存量仪表板",
4950
"add_success": "添加成功",

frontend/src/style.less

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,62 @@ strong {
230230
height: 1px !important;
231231
}
232232
}
233+
234+
.sq-message-success {
235+
border: 1px solid #34c724 !important;
236+
background: #f0fbef !important;
237+
238+
.ed-message__icon {
239+
color: #34c724
240+
}
241+
}
242+
243+
244+
.sq-message-export {
245+
min-width: 20px !important;
246+
padding: 16px 20px !important;
247+
display: flex;
248+
align-items: center;
249+
box-shadow: 0px 4px 8px 0px #1f23291a;
250+
251+
& > p {
252+
font-family: var(--de-custom_font, 'PingFang');
253+
font-size: 14px;
254+
font-weight: 500;
255+
line-height: 22px;
256+
letter-spacing: 0px;
257+
text-align: left;
258+
color: #1f2329;
259+
display: flex;
260+
align-items: center;
261+
padding-right: 24px;
262+
}
263+
264+
.m50-export {
265+
max-width: 200px;
266+
}
267+
268+
.btn-text {
269+
padding: 2px 4px;
270+
271+
&:hover {
272+
background: var(--primary10, #3370ff1a);
273+
}
274+
}
275+
276+
.ed-message__closeBtn {
277+
margin-left: 28px;
278+
position: relative;
279+
margin-right: 0;
280+
top: 0;
281+
right: 0;
282+
transform: translateY(0);
283+
color: #646a73;
284+
}
285+
286+
.ed-message__icon {
287+
height: 16px;
288+
width: 16px;
289+
margin-right: 8px;
290+
}
291+
}

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

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts" setup>
2-
import { onMounted, reactive, ref } from 'vue'
2+
import { onMounted, reactive, ref, h } from 'vue'
3+
import { ElButton, ElMessage } from 'element-plus-secondary'
34
import {
45
findNextComponentIndex,
56
saveDashboardResourceTarget,
@@ -18,7 +19,7 @@ const optInit = (viewInfo: any) => {
1819
resourceDialogShow.value = true
1920
state.viewInfo = viewInfo
2021
}
21-
22+
const curOptDashboardId = ref(null)
2223
const state = reactive({
2324
dashboardList: [] as SQTreeNode[],
2425
viewInfo: null,
@@ -123,16 +124,55 @@ const saveResourcePrepare = () => {
123124
}
124125
125126
const saveResource = (params: any, commonParams: any) => {
126-
saveDashboardResourceTarget(params, commonParams, function () {
127+
saveDashboardResourceTarget(params, commonParams, (res: any) => {
127128
const messageTips = t('dashboard.add_success')
128-
ElMessage({
129-
type: 'success',
130-
message: messageTips,
131-
})
129+
curOptDashboardId.value = res?.id
130+
openMessageLoading(messageTips, 'success', callbackExportSuc)
132131
resetForm()
133132
})
134133
}
135134
135+
const callbackExportSuc = () => {
136+
// do open dashboard
137+
const url = `#/canvas?resourceId=${curOptDashboardId.value}`
138+
window.open(url, '_self')
139+
}
140+
141+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
142+
const openMessageLoading = (text: string, type = 'success', cb: Function) => {
143+
// success error loading
144+
const customClass = `sq-message-${type || 'success'} sq-message-export`
145+
ElMessage({
146+
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
147+
message: h('p', null, [
148+
h(
149+
'span',
150+
{
151+
title: t(text),
152+
class: 'ellipsis m50-export',
153+
},
154+
t(text)
155+
),
156+
h(
157+
ElButton,
158+
{
159+
text: true,
160+
size: 'small',
161+
class: 'btn-text',
162+
onClick: () => {
163+
cb()
164+
},
165+
},
166+
t('dashboard.open_dashboard')
167+
),
168+
]),
169+
type,
170+
showClose: true,
171+
duration: 0,
172+
customClass,
173+
})
174+
}
175+
136176
const initDashboardList = () => {
137177
state.dashboardList = []
138178
const params = {}

frontend/src/views/dashboard/utils/canvasUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ export const saveDashboardResourceTarget = (params: any, commonParams: any, call
116116
canvas_style_data: JSON.stringify(commonParams.canvasStyleData),
117117
canvas_view_info: JSON.stringify(commonParams.canvasViewInfo),
118118
}
119-
dashboardApi.update_canvas(requestParams).then(() => {
120-
callBack()
119+
dashboardApi.update_canvas(requestParams).then((res: any) => {
120+
callBack(res)
121121
})
122122
}
123123
} else {

0 commit comments

Comments
 (0)