Skip to content

Commit abcbc27

Browse files
committed
refactor: Tab and dashboard update
1 parent a758c15 commit abcbc27

File tree

13 files changed

+150
-43
lines changed

13 files changed

+150
-43
lines changed

frontend/src/i18n/en.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"AI Model Configuration": "AI Model Configuration"
77
},
88
"common": {
9+
"input_content": "Please Input Content",
910
"back": "Back",
1011
"confirm": "Confirm",
1112
"cancel": "Cancel",
@@ -18,6 +19,17 @@
1819
"logout": "Logout"
1920
},
2021
"dashboard": {
22+
"select_dashboard": "Please Select Dashboard",
23+
"view": "View",
24+
"text": "Text",
25+
"preview": "Preview",
26+
"creator": "Creator",
27+
"dashboard_id": "Dashboard ID",
28+
"create_time": "Create Time",
29+
"updator": "Updater",
30+
"update_time": "Update Time",
31+
"edit": "Edit",
32+
"edit_title": "Edit Title",
2133
"length_1_64_characters": "Name field length must be 1-64 characters",
2234
"rename": "Rename",
2335
"delete": "Delete",

frontend/src/i18n/zh-CN.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,31 @@
66
"AI Model Configuration": "模型配置"
77
},
88
"common": {
9+
"input_content": "请输入内容",
910
"back": "返回",
1011
"confirm": "确认",
1112
"cancel": "取消",
1213
"search": "查询",
1314
"system_manage": "系统管理",
14-
"update_success": "更新",
15+
"update_success": "更新成功",
1516
"save_success": "保存成功",
1617
"next": "下一步",
1718
"save": "保存",
1819
"logout": "退出登录"
1920
},
2021
"dashboard": {
22+
"select_dashboard": "请选择仪表板",
23+
"name": "名称",
24+
"view": "图表",
25+
"text": "文本",
26+
"preview": "预览",
27+
"creator": "创建人",
28+
"dashboard_id": "仪表板ID",
29+
"create_time": "创建时间",
30+
"updator": "更新人",
31+
"update_time": "更新时间",
32+
"edit": "编辑",
33+
"edit_title": "编辑标题",
2134
"length_1_64_characters": "名称字段长度1-64个字符",
2235
"rename": "重命名",
2336
"delete": "删除",

frontend/src/views/dashboard/canvas/CanvasCore.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,7 @@ defineExpose({
11961196
:config-item="item"
11971197
:view-info="canvasViewInfo[item.id]"
11981198
:canvas-view-info="canvasViewInfo"
1199+
:show-position="'canvas'"
11991200
@parent-add-item-box="(subItem: any) => addItemBox(subItem)"
12001201
>
12011202
</component>

frontend/src/views/dashboard/canvas/DragHandle.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ const shadowStyle = (size: number, index: number) => {
6161
background: #c1e2e8;
6262
position: absolute;
6363
cursor: move !important;
64-
z-index: 1;
64+
z-index: 3;
6565
}
6666
</style>

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<template>
22
<div class="info-card">
3-
<div class="info-title">Dashboard ID</div>
3+
<div class="info-title">{{ t('dashboard.dashboard_id') }}</div>
44
<div class="info-content">{{ dashboardInfo.id }}</div>
5-
<div v-if="dashboardInfo.createName" class="info-title">Creator</div>
5+
<div v-if="dashboardInfo.createName" class="info-title">{{ t('dashboard.creator') }}</div>
66
<div v-if="dashboardInfo.createName" class="info-content">{{ dashboardInfo.createName }}</div>
7-
<div class="info-title">Create Time</div>
7+
<div class="info-title">{{ t('dashboard.create_time') }}</div>
88
<div class="info-content">{{ timestampFormatDate(dashboardInfo.createTime) }}</div>
9-
<div v-if="dashboardInfo.updateName" class="info-title">Updator</div>
9+
<div v-if="dashboardInfo.updateName" class="info-title">{{ t('dashboard.updator') }}</div>
1010
<div v-if="dashboardInfo.updateName" class="info-content">{{ dashboardInfo.updateName }}</div>
11-
<div class="info-title">Update Time</div>
11+
<div class="info-title">{{ t('dashboard.update_time') }}</div>
1212
<div v-if="dashboardInfo.updateTime" class="info-content">
1313
{{ timestampFormatDate(dashboardInfo.updateTime) }}
1414
</div>
@@ -17,6 +17,9 @@
1717
</template>
1818

1919
<script lang="ts" setup>
20+
import { useI18n } from 'vue-i18n'
21+
const { t } = useI18n()
22+
2023
defineProps({
2124
dashboardInfo: {
2225
type: Object,

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ import { type SQTreeNode } from '@/views/dashboard/utils/treeNode'
44
import { computed, reactive, ref } from 'vue'
55
import { saveDashboardResource } from '@/views/dashboard/utils/canvasUtils.ts'
66
import { dashboardApi } from '@/api/dashboard.ts'
7+
import { useI18n } from 'vue-i18n'
78
9+
const { t } = useI18n()
810
const emits = defineEmits(['finish'])
911
const state = reactive({
1012
id: null,
1113
opt: null,
1214
placeholder: '',
1315
nodeType: 'folder',
1416
parentSelect: false,
15-
resourceFormNameLabel: 'Name',
17+
resourceFormNameLabel: t('dashboard.name'),
1618
dialogTitle: '',
1719
tData: [],
1820
tDataSource: [],
@@ -24,11 +26,11 @@ const state = reactive({
2426
const getTitle = (opt: string) => {
2527
switch (opt) {
2628
case 'newLeaf':
27-
return 'New Dashboard'
29+
return t('dashboard.new_dashboard')
2830
case 'newFolder':
29-
return 'New Folder'
31+
return t('dashboard.new_folder')
3032
case 'rename':
31-
return 'Rename'
33+
return t('dashboard.rename')
3234
default:
3335
return
3436
}
@@ -137,7 +139,8 @@ const saveResource = () => {
137139
level: state.nodeType === 'folder' ? 0 : 1,
138140
}
139141
saveDashboardResource(params, function (rsp: any) {
140-
const messageTips = state.opt === 'rename' ? 'Update Success' : 'Save Success'
142+
const messageTips =
143+
state.opt === 'rename' ? t('common.update_success') : t('common.save_success')
141144
ElMessage({
142145
type: 'success',
143146
message: messageTips,
@@ -169,6 +172,7 @@ defineExpose({
169172
:title="state.dialogTitle"
170173
width="420px"
171174
:before-close="resetForm"
175+
append-to-body
172176
@submit.prevent
173177
>
174178
<el-form
@@ -212,8 +216,8 @@ defineExpose({
212216
</el-form-item>
213217
</el-form>
214218
<template #footer>
215-
<el-button secondary @click="resetForm()">Cancel</el-button>
216-
<el-button type="primary" @click="saveResource()">Confirm</el-button>
219+
<el-button secondary @click="resetForm()">{{ t('common.cancel') }}</el-button>
220+
<el-button type="primary" @click="saveResource()">{{ t('common.confirm') }}</el-button>
217221
</template>
218222
</el-dialog>
219223
</template>

frontend/src/views/dashboard/components/sq-tab/index.vue

Lines changed: 80 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const showTabTitleFlag = ref(true)
2020
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
2121
let currentInstance
2222
import _ from 'lodash'
23+
import SQPreview from '@/views/dashboard/preview/SQPreview.vue'
24+
import { useI18n } from 'vue-i18n'
25+
const { t } = useI18n()
2326
2427
const emits = defineEmits(['parentAddItemBox'])
2528
@@ -117,16 +120,7 @@ const beforeHandleCommand = (item: any, param: any) => {
117120
param: param,
118121
}
119122
}
120-
121-
const titleStyle = (itemName: string) => {
122-
if (editableTabsValue.value === itemName) {
123-
return {}
124-
} else {
125-
return {}
126-
}
127-
}
128-
129-
const isEditMode = computed(() => true)
123+
const isEditMode = computed(() => props.showPosition === 'canvas')
130124
131125
const addTabItem = (item: CanvasItem) => {
132126
// do addTabItem
@@ -144,8 +138,34 @@ const addTabItem = (item: CanvasItem) => {
144138
refInstance.addItemToBox(newTabItem)
145139
}
146140
141+
function sureCurTitle() {
142+
state.curItem.title = state.textarea
143+
state.dialogVisible = false
144+
}
145+
146+
const titleValid = computed(() => {
147+
return !!state.textarea && !!state.textarea.trim()
148+
})
149+
150+
const titleStyle = (itemName: string) => {
151+
let style = {}
152+
if (editableTabsValue.value === itemName) {
153+
style = {
154+
fontSize: '16px',
155+
}
156+
} else {
157+
style = {
158+
fontSize: '14px',
159+
}
160+
}
161+
return style
162+
}
163+
147164
onMounted(() => {
148165
currentInstance = getCurrentInstance()
166+
if (configItem.value.propValue.length > 0) {
167+
editableTabsValue.value = configItem.value.propValue[0].name
168+
}
149169
})
150170
151171
defineExpose({
@@ -166,7 +186,6 @@ defineExpose({
166186
:hide-title="!showTabTitleFlag"
167187
@tab-add="addTab"
168188
>
169-
<!-- {{ configItem.collisionActive }} & {{ configItem.moveInActive }}${{ configItem.moveOutActive }}-->
170189
<template v-for="tabItem in configItem.propValue" :key="tabItem.name">
171190
<el-tab-pane
172191
class="el-tab-pane-custom"
@@ -185,21 +204,18 @@ defineExpose({
185204
@command="handleCommand"
186205
>
187206
<span class="el-dropdown-link">
188-
<el-icon v-if="isEditMode"><ArrowDown /></el-icon>
207+
<el-icon v-if="isEditMode" style="margin-top: 5px"><ArrowDown /></el-icon>
189208
</span>
190209
<template #dropdown>
191210
<el-dropdown-menu>
192211
<el-dropdown-item :command="beforeHandleCommand('editTitle', tabItem)">
193-
edit
194-
</el-dropdown-item>
195-
<el-dropdown-item :command="beforeHandleCommand('copyCur', tabItem)">
196-
copy
212+
{{ t('dashboard.edit') }}
197213
</el-dropdown-item>
198214
<el-dropdown-item
199215
v-if="configItem.propValue.length > 1"
200216
:command="beforeHandleCommand('deleteCur', tabItem)"
201217
>
202-
delete
218+
{{ t('dashboard.delete') }}
203219
</el-dropdown-item>
204220
</el-dropdown-menu>
205221
</template>
@@ -216,7 +232,16 @@ defineExpose({
216232
class="tab-content-custom"
217233
:class="{ 'switch-hidden': editableTabsValue !== tabItem.name }"
218234
>
235+
<SQPreview
236+
v-if="showPosition === 'preview'"
237+
:ref="'tabPreviewRef_' + index"
238+
class="tab-dashboard-preview"
239+
:component-data="tabItem.componentData"
240+
:canvas-view-info="canvasViewInfo"
241+
:base-matrix-count="tabBaseMatrixCount"
242+
></SQPreview>
219243
<DashboardEditor
244+
v-else
220245
:ref="'tabEditorRef_' + index"
221246
class="tab-dashboard-editor-main"
222247
:canvas-component-data="tabItem.componentData"
@@ -230,10 +255,35 @@ defineExpose({
230255
</DashboardEditor>
231256
</div>
232257
</custom-tab>
258+
<el-dialog
259+
v-model="state.dialogVisible"
260+
:title="t('dashboard.edit_title')"
261+
:append-to-body="true"
262+
width="30%"
263+
:show-close="false"
264+
:close-on-click-modal="false"
265+
center
266+
>
267+
<el-input v-model="state.textarea" maxlength="50" :placeholder="t('common.input_content')" />
268+
<template #footer>
269+
<span class="dialog-footer">
270+
<el-button @click="state.dialogVisible = false">{{ t('common.cancel') }}</el-button>
271+
<el-button :disabled="!titleValid" type="primary" @click="sureCurTitle">{{
272+
t('common.confirm')
273+
}}</el-button>
274+
</span>
275+
</template>
276+
</el-dialog>
233277
</div>
234278
</template>
235279

236280
<style scoped lang="less">
281+
::v-deep(.ed-tabs__header) {
282+
margin: 0 24px 0 12px !important;
283+
}
284+
::v-deep(.ed-tabs__nav-scroll) {
285+
margin: 0 12px !important;
286+
}
237287
.ed-dropdown-link {
238288
margin-top: 3px !important;
239289
}
@@ -245,6 +295,10 @@ defineExpose({
245295
margin: 2px !important; // border size
246296
}
247297
298+
.tab-dashboard-preview {
299+
background: #ffffff !important;
300+
}
301+
248302
.tab-dashboard-editor-main {
249303
height: 100% !important;
250304
}
@@ -258,4 +312,13 @@ defineExpose({
258312
overflow: visible !important;
259313
}
260314
}
315+
316+
.custom-tab-title {
317+
padding: 0 8px 0 4px !important;
318+
}
319+
320+
.switch-hidden {
321+
opacity: 0;
322+
z-index: -1;
323+
}
261324
</style>

frontend/src/views/dashboard/editor/Toolbar.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,21 +181,21 @@ const addChatChart = (views: any) => {
181181
<div class="core-toolbar">
182182
<component-button-label
183183
:icon-name="dvView"
184-
title="Add View"
184+
:title="t('dashboard.view')"
185185
themes="light"
186186
is-label
187187
@custom-click="openViewDialog"
188188
></component-button-label>
189189
<component-button-label
190190
:icon-name="dvText"
191-
title="Text"
191+
:title="t('dashboard.text')"
192192
themes="light"
193193
is-label
194194
@custom-click="() => emits('addComponent', 'SQText')"
195195
></component-button-label>
196196
<component-button-label
197197
:icon-name="dvTab"
198-
title="Tab Item"
198+
title="Tab"
199199
themes="light"
200200
is-label
201201
@custom-click="() => emits('addComponent', 'SQTab')"
@@ -208,7 +208,7 @@ const addChatChart = (views: any) => {
208208
type="primary"
209209
@click="saveCanvasWithCheck()"
210210
>
211-
Save
211+
{{ t('common.save') }}
212212
</el-button>
213213
</div>
214214
<Teleport v-if="nameEdit" :to="'#canvas-name'">

frontend/src/views/dashboard/editor/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { storeToRefs } from 'pinia'
99
import { dashboardStoreWithOut } from '@/stores/dashboard/dashboard.ts'
1010
import router from '@/router'
1111
import { initCanvasData } from '@/views/dashboard/utils/canvasUtils.ts'
12+
import { useI18n } from 'vue-i18n'
1213
14+
const { t } = useI18n()
1315
const dashboardStore = dashboardStoreWithOut()
1416
const { componentData, canvasViewInfo } = storeToRefs(dashboardStore)
1517
@@ -52,7 +54,7 @@ onMounted(() => {
5254
if (state.opt === 'create') {
5355
dashboardStore.updateDashboardInfo({
5456
dataState: 'prepare',
55-
name: 'New Dashboard',
57+
name: t('dashboard.new_dashboard'),
5658
pid: state.routerPid,
5759
})
5860
} else if (state.resourceId) {

0 commit comments

Comments
 (0)