Skip to content

Commit 2511e07

Browse files
committed
refactor: dashboard preview
1 parent 20ec595 commit 2511e07

File tree

12 files changed

+77
-74
lines changed

12 files changed

+77
-74
lines changed

backend/apps/dashboard/api/dashboard_api.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
from fastapi import APIRouter, File, UploadFile, HTTPException
33

44
from apps.dashboard.crud.dashboard_service import get_dashboard_list, preview_with_id,create_dashboard
5-
from apps.dashboard.models.dashboard_model import CreateDashboard, DashboardResponse
5+
from apps.dashboard.models.dashboard_model import CreateDashboard
66
from common.core.deps import SessionDep, CurrentUser
7-
from typing import List
8-
from fastapi.encoders import jsonable_encoder
97

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

backend/apps/dashboard/crud/dashboard_service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from sqlalchemy import select
22
from apps.dashboard.models.dashboard_model import CoreDashboard, CreateDashboard
33
from common.core.deps import SessionDep, CurrentUser
4+
from sqlmodel import text
45
import uuid
56
def get_dashboard_list(session: SessionDep):
6-
statement = select(CoreDashboard)
7-
dashboard_list = session.exec(statement).scalars().all()
8-
return dashboard_list
7+
sql = text("SELECT id, name, type,node_type, pid, create_time FROM core_dashboard")
8+
for row in session.exec(sql).mappings():
9+
yield CoreDashboard(**row)
910

1011
def preview_with_id(session: SessionDep, dashboard_id: str):
1112
return session.query(CoreDashboard).filter(CoreDashboard.id == id).first()

backend/apps/dashboard/models/dashboard_model.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -122,36 +122,14 @@ class CoreDashboard(SQLModel, table=True):
122122
sa_column=Column(String(50), nullable=True)
123123
)
124124

125-
class DashboardResponse(BaseModel):
125+
class DashboardBaseResponse(BaseModel):
126126
id: Optional[str] = None
127127
name: Optional[str] = None
128128
pid: Optional[str] = None
129-
workspace_id: Optional[str] = None
130-
org_id: Optional[str] = None
131-
level: Optional[int] = None
132129
node_type: Optional[str] = None
133130
type: Optional[str] = None
134-
canvas_style_data: Optional[str] = None
135-
component_data: Optional[str] = None
136-
mobile_layout: Optional[int] = None
137-
status: Optional[int] = None
138-
self_watermark_status: Optional[int] = None
139-
sort: Optional[int] = None
140131
create_time: Optional[int] = None
141-
create_by: Optional[str] = None
142132
update_time: Optional[int] = None
143-
update_by: Optional[str] = None
144-
remark: Optional[str] = None
145-
source: Optional[str] = None
146-
delete_flag: Optional[int] = None
147-
delete_time: Optional[int] = None
148-
delete_by: Optional[str] = None
149-
version: Optional[int] = None
150-
content_id: Optional[str] = None
151-
check_version: Optional[str] = None
152-
153-
class Config:
154-
orm_mode = True
155133

156134
# dashboard create obj
157135
class CreateDashboard(BaseModel):
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading

frontend/src/components/layout/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const name = ref('admin')
163163
const activeMenu = computed(() => route.path)
164164
const routerList = computed(() => {
165165
return router.getRoutes().filter(route => {
166-
return route.path !== '/login' && !route.path.includes('/system') && !route.redirect && route.path !== '/:pathMatch(.*)*' && !route.path.includes('dsTable')
166+
return !route.path.includes('canvas') && route.path !== '/login' && !route.path.includes('/system') && !route.redirect && route.path !== '/:pathMatch(.*)*' && !route.path.includes('dsTable')
167167
})
168168
})
169169

frontend/src/router/index.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,10 @@ const router = createRouter({
6969
],
7070
},
7171
{
72-
path: "/dashboard-edit",
73-
redirect: "/dashboard-edit/index",
74-
component: Layout,
75-
children: [
76-
{
77-
path: "index",
78-
name: "dashboard-edit",
79-
component: DashboardEditor,
80-
meta: { title: "dashboard-edit", icon: "dashboard" },
81-
},
82-
],
72+
path: "/canvas",
73+
name: "canvas",
74+
component: DashboardEditor,
75+
meta: { title: "canvas", icon: "dashboard" },
8376
},
8477
/* {
8578
path: "/setting",

frontend/src/style.less

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,25 @@ body {
110110

111111

112112

113+
.hover-icon {
114+
cursor: pointer;
115+
height: 24px !important;
116+
width: 24px !important;
117+
font-size: 16px !important;
118+
border-radius: 4px;
119+
color: #646a73 !important;
120+
121+
&[aria-expanded='true'] {
122+
background: rgba(31, 35, 41, 0.1);
123+
}
124+
125+
&:hover {
126+
background: rgba(31, 35, 41, 0.1);
127+
}
128+
129+
&:active {
130+
background: rgba(31, 35, 41, 0.2);
131+
}
132+
}
133+
134+

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

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import icon_add_outlined from '@/assets/svg/icon_add_outlined.svg'
33
import {treeDraggableChart} from '@/views/dashboard/utils/treeDraggableChart'
44
import newFolder from '@/assets/svg/new-folder.svg'
55
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
6-
import Folder from '@/assets/svg/folder.svg'
6+
import icon_folder from '@/assets/svg/icon_folder.svg'
77
import icon_fileAdd_outlined from '@/assets/svg/icon_file-add_outlined.svg'
8-
import icon_operationAnalysis_outlined from '@/assets/svg/icon_operation-analysis_outlined.svg'
8+
import icon_dashboard from '@/assets/svg/icon_dashboard.svg'
99
import icon_edit_outlined from '@/assets/svg/icon_edit_outlined.svg'
1010
import {onMounted, reactive, ref, watch, nextTick, computed} from 'vue'
1111
import {ElIcon, ElScrollbar} from 'element-plus-secondary'
@@ -14,7 +14,6 @@ import {type SQTreeNode} from '@/views/dashboard/utils/treeNode'
1414
import _ from 'lodash'
1515
import router from '@/router'
1616
import {dashboardStoreWithOut} from "@/stores/dashboard/dashboard.ts";
17-
import HandleMore from "@/views/dashboard/common/HandleMore.vue";
1817
import ResourceGroupOpt from "@/views/dashboard/common/ResourceGroupOpt.vue";
1918
import {dashboardApi} from "@/api/dashboard.ts";
2019
@@ -58,10 +57,6 @@ const state = reactive({
5857
})
5958
6059
61-
const resourceTypeList = computed(() => {
62-
return []
63-
})
64-
6560
// @ts-ignore
6661
const {handleDrop, allowDrop, handleDragStart} = treeDraggableChart(
6762
state,
@@ -118,7 +113,8 @@ const getTree = async () => {
118113
state.originResourceTree = []
119114
const params = {}
120115
dashboardApi.list(params).then((res: SQTreeNode[]) => {
121-
state.originResourceTree = res?.data || []
116+
state.originResourceTree = res || []
117+
state.resourceTree = _.cloneDeep(state.originResourceTree)
122118
afterTreeInit()
123119
})
124120
}
@@ -210,7 +206,7 @@ onMounted(() => {
210206
// @ts-ignore
211207
const addOperation = (params: any) => {
212208
if (params.cmd === 'newLeaf') {
213-
const newCanvasUrl = '#/canvas?opt=create' + params.data?.id ? `&pid=${params.data?.id}` : ''
209+
const newCanvasUrl = '#/canvas?opt=create' + (params?.id ? `&pid=${params?.id}` : '')
214210
window.open(newCanvasUrl, '_blank')
215211
} else {
216212
// @ts-ignore
@@ -247,6 +243,7 @@ defineExpose({
247243
<el-icon
248244
class="custom-icon btn"
249245
style="margin-right: 10px"
246+
@click="addOperation({cmd:'newLeaf',type:'dashboard'} )"
250247
>
251248
<Icon name="dv-new-folder">
252249
<icon_fileAdd_outlined class="svg-icon"/>
@@ -290,22 +287,26 @@ defineExpose({
290287
@node-drop="handleDrop"
291288
draggable
292289
>
293-
<template #default="{ data }">
294-
<span class="custom-tree-node" :class="{ 'node-disabled-custom': data.extraFlag1 === 0 }">
290+
<template #default="{ node, data }">
291+
<span class="custom-tree-node">
295292
<el-icon style="font-size: 18px" v-if="!data.leaf">
296-
<Icon name="dv-folder"><Folder class="svg-icon"/></Icon>
293+
<Icon name="icon_folder"><icon_folder class="svg-icon"/></Icon>
297294
</el-icon>
298-
<el-icon
299-
class="icon-screen-new color-dataV"
300-
:class="{ 'color-dataV': data.extraFlag1, 'color-dataV-disabled': !data.extraFlag1 }"
301-
style="font-size: 18px"
302-
v-else
303-
>
304-
<Icon name="icon_operation-analysis_outlined"
305-
><icon_operationAnalysis_outlined class="svg-icon"
306-
/></Icon>
295+
<el-icon style="font-size: 18px" v-else>
296+
<Icon name="icon_dashboard"><icon_dashboard class="svg-icon"/></Icon>
307297
</el-icon>
298+
<span :title="node.label" class="label-tooltip">
299+
{{ node.label }}
300+
</span>
308301
<div class="icon-more">
302+
<el-icon
303+
v-on:click.stop
304+
v-if="!data.leaf"
305+
class="hover-icon"
306+
@click="addOperation({cmd:'newLeaf',type:'dashboard',id:data.id} )"
307+
>
308+
<Icon><icon_add_outlined class="svg-icon"/></Icon>
309+
</el-icon>
309310
<el-icon
310311
v-on:click.stop
311312
v-if="data.leaf"
@@ -314,14 +315,14 @@ defineExpose({
314315
>
315316
<Icon><icon_edit_outlined class="svg-icon"/></Icon>
316317
</el-icon>
317-
<HandleMore
318-
@handle-command=" (cmd:string) => addOperation({cmd})
319-
"
320-
:menu-list="resourceTypeList"
321-
:icon-name="icon_add_outlined"
322-
placement="bottom-start"
323-
v-if="!data.leaf"
324-
></HandleMore>
318+
<!-- <HandleMore-->
319+
<!-- @handle-command=" (cmd:string) => addOperation({cmd})-->
320+
<!-- "-->
321+
<!-- :menu-list="resourceTypeList"-->
322+
<!-- :icon-name="icon_add_outlined"-->
323+
<!-- placement="bottom-start"-->
324+
<!-- v-if="!data.leaf"-->
325+
<!-- ></HandleMore>-->
325326
</div>
326327
</span>
327328
</template>
@@ -446,7 +447,7 @@ defineExpose({
446447
display: flex;
447448
align-items: center;
448449
box-sizing: content-box;
449-
padding-right: 4px;
450+
padding-right: 12px;
450451
451452
.label-tooltip {
452453
width: 100%;
@@ -459,6 +460,7 @@ defineExpose({
459460
.icon-more {
460461
margin-left: auto;
461462
display: none;
463+
color: #bbbfc4;
462464
}
463465
464466
&:hover {

0 commit comments

Comments
 (0)