Skip to content

Commit f46b721

Browse files
committed
refactor: preview head
1 parent 67c0d8a commit f46b721

File tree

13 files changed

+325
-72
lines changed

13 files changed

+325
-72
lines changed

backend/apps/dashboard/api/dashboard_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from apps.dashboard.crud.dashboard_service import list_resource, load_resource, \
44
create_resource, create_canvas, validate_name, delete_resource, update_resource, update_canvas
5-
from apps.dashboard.models.dashboard_model import CreateDashboard, BaseDashboard, QueryDashboard
5+
from apps.dashboard.models.dashboard_model import CreateDashboard, BaseDashboard, QueryDashboard,DashboardResponse
66
from common.core.deps import SessionDep, CurrentUser
77

88
router = APIRouter(tags=["dashboard"], prefix="/dashboard")

backend/apps/dashboard/crud/dashboard_service.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ def list_resource(session: SessionDep, dashboard: QueryDashboard):
2424
return tree
2525

2626

27-
def load_resource(session: SessionDep,dashboard: QueryDashboard):
28-
return session.query(CoreDashboard).filter(CoreDashboard.id == dashboard.id).first()
27+
def load_resource(session: SessionDep, dashboard: QueryDashboard):
28+
sql = text("""
29+
SELECT cd.*,
30+
creator.name AS create_name,
31+
updator.name AS update_name
32+
FROM core_dashboard cd
33+
LEFT JOIN sys_user creator ON cd.create_by = creator.id::varchar
34+
LEFT JOIN sys_user updator
35+
ON cd.update_by = updator.id:: varchar
36+
WHERE cd.id = :dashboard_id
37+
""")
38+
result = session.execute(sql, {"dashboard_id": dashboard.id}).mappings().first()
39+
return result
2940

3041

3142
def get_create_base_info(user: CurrentUser, dashboard: CreateDashboard):

backend/apps/dashboard/models/dashboard_model.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ class DashboardBaseResponse(BaseModel):
133133
update_time: Optional[int] = None
134134
children: List['DashboardBaseResponse'] = []
135135

136+
class DashboardResponse(CoreDashboard):
137+
update_name: Optional[str] = None
138+
create_name: Optional[str] = None
139+
136140
class BaseDashboard(BaseModel):
137141
id: str = ''
138142
name: str = ''

frontend/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"dayjs": "^1.11.13",
1717
"element-plus": "^2.10.1",
1818
"element-plus-secondary": "^1.0.0",
19+
"element-resize-detector": "^1.2.4",
1920
"lodash": "^4.17.21",
2021
"lodash-es": "^4.17.21",
2122
"snowflake-id": "^1.1.0",
@@ -28,6 +29,7 @@
2829
"devDependencies": {
2930
"@element-plus/icons-vue": "^2.3.1",
3031
"@types/crypto-js": "^4.2.2",
32+
"@types/element-resize-detector": "^1.1.6",
3133
"@types/node": "^22.14.1",
3234
"@vitejs/plugin-vue": "^5.2.2",
3335
"@vue/tsconfig": "^0.7.0",

frontend/src/stores/dashboard/dashboard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export const dashboardStore = defineStore('dashboard', {
2020
workspaceId: null,
2121
status: null,
2222
dataState: null,
23-
type: null,
24-
creatorName: null,
23+
createName: null,
2524
updateName: null,
2625
createTime: null,
2726
updateTime: null,
28-
contentId: null
27+
contentId: null,
28+
type: null
2929
}
3030
}
3131
},

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
Dashboard ID
55
</div>
66
<div class="info-content">{{ dashboardInfo.id }}</div>
7-
<div v-if="dashboardInfo.creatorName" class="info-title">Creator</div>
8-
<div v-if="dashboardInfo.creatorName" class="info-content">Creator Name</div>
7+
<div v-if="dashboardInfo.createName" class="info-title">Creator</div>
8+
<div v-if="dashboardInfo.createName" class="info-content">{{ dashboardInfo.createName }}</div>
99
<div class="info-title">Create Time</div>
1010
<div class="info-content">{{ timestampFormatDate(dashboardInfo.createTime) }}</div>
1111
<div v-if="dashboardInfo.updateName" class="info-title">Updator</div>
12-
<div v-if="dashboardInfo.updateName" class="info-content">Updator Name</div>
12+
<div v-if="dashboardInfo.updateName" class="info-content">{{ dashboardInfo.updateName }}</div>
1313
<div class="info-title">Update Time</div>
1414
<div v-if="dashboardInfo.updateTime" class="info-content">
1515
{{ timestampFormatDate(dashboardInfo.updateTime) }}
@@ -19,17 +19,19 @@
1919
</template>
2020

2121
<script lang="ts" setup>
22-
import {dashboardStoreWithOut} from "@/stores/dashboard/dashboard.ts";
23-
import {storeToRefs} from "pinia";
2422
25-
const dashboardStore = dashboardStoreWithOut()
26-
const {dashboardInfo} = storeToRefs(dashboardStore)
23+
defineProps({
24+
dashboardInfo: {
25+
type: Object,
26+
required: true
27+
}
28+
})
2729
28-
const timestampFormatDate = (value:any) => {
30+
const timestampFormatDate = (value: any) => {
2931
if (!value) {
3032
return '-'
3133
}
32-
return new Date(value).toLocaleString()
34+
return new Date(value * 1000).toLocaleString()
3335
}
3436
</script>
3537

@@ -45,6 +47,7 @@ const timestampFormatDate = (value:any) => {
4547
font-size: 14px;
4648
margin-bottom: 4px;
4749
}
50+
4851
.info-content {
4952
color: #1f2329;
5053
font-size: 14px;

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ const props = defineProps({
2323
configItem: {
2424
type: Object as PropType<CanvasItem>,
2525
required: true
26+
},
27+
canvasViewInfo: {
28+
type: Object,
29+
required: true
30+
},
31+
showPosition: {
32+
required: false,
33+
type: String,
34+
default: 'preview'
35+
},
36+
canvasId: {
37+
type: String,
38+
default: 'canvas-main'
2639
}
2740
})
2841
@@ -220,11 +233,11 @@ defineExpose({
220233
position: absolute;
221234
width: 100%;
222235
height: 100%;
223-
margin: 2px!important;// border size
236+
margin: 2px !important; // border size
224237
}
225238
226-
.tab-dashboard-editor-main{
227-
height: 100%!important;
239+
.tab-dashboard-editor-main {
240+
height: 100% !important;
228241
}
229242
230243
.tab-moveout {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import cloneDeep from 'lodash/cloneDeep';
88
import {storeToRefs} from "pinia";
99
import {dashboardStoreWithOut} from "@/stores/dashboard/dashboard.ts";
1010
import router from '@/router'
11-
import {dashboardApi} from "@/api/dashboard.ts";
1211
import {initCanvasData} from "@/views/dashboard/utils/canvasUtils.ts";
1312
1413
const dashboardStore = dashboardStoreWithOut()
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<script setup lang="ts">
2+
import {ref, toRefs, computed} from 'vue'
3+
import {findComponent} from "@/views/dashboard/components/component-list.ts";
4+
5+
const componentWrapperInnerRef = ref(null)
6+
7+
const props = defineProps({
8+
active: {
9+
type: Boolean,
10+
default: false
11+
},
12+
configItem: {
13+
type: Object,
14+
required: true
15+
},
16+
canvasViewInfo: {
17+
type: Object,
18+
required: true
19+
},
20+
showPosition: {
21+
required: false,
22+
type: String,
23+
default: 'preview'
24+
},
25+
canvasId: {
26+
type: String,
27+
default: 'canvas-main'
28+
}
29+
})
30+
const {configItem, showPosition} = toRefs(props)
31+
const component = ref(null)
32+
const wrapperId = 'wrapper-outer-id-' + configItem.value.id
33+
const viewDemoInnerId = computed(() => 'enlarge-inner-content-' + configItem.value.id)
34+
35+
</script>
36+
37+
<template>
38+
<div class="wrapper-outer" :id="wrapperId">
39+
<div class="wrapper-inner" ref="componentWrapperInnerRef" :id="viewDemoInnerId">
40+
<div class="wrapper-inner-adaptor">
41+
<component
42+
ref="component"
43+
class="component"
44+
:is="findComponent(configItem['component'])"
45+
:canvas-view-info="canvasViewInfo"
46+
:view="canvasViewInfo[configItem.id]"
47+
:config-item="configItem"
48+
:show-position="showPosition"
49+
:active="active"
50+
/>
51+
</div>
52+
</div>
53+
</div>
54+
</template>
55+
56+
<style lang="less" scoped>
57+
.wrapper-outer {
58+
position: absolute;
59+
.wrapper-inner {
60+
width: 100%;
61+
height: 100%;
62+
position: relative;
63+
background-size: 100% 100% !important;
64+
65+
.wrapper-inner-adaptor {
66+
position: relative;
67+
transform-style: preserve-3d;
68+
width: 100%;
69+
height: 100%;
70+
}
71+
}
72+
}
73+
</style>

0 commit comments

Comments
 (0)