Skip to content

Commit e7c26d8

Browse files
authored
feat(query): data view fullscreen mode (#548)
1 parent f4cba30 commit e7c26d8

File tree

5 files changed

+139
-50
lines changed

5 files changed

+139
-50
lines changed

src/assets/style/new.less

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -53,60 +53,60 @@
5353
}
5454
}
5555

56-
.arco-tabs.arco-tabs-type-line.panel-tabs {
57-
display: flex;
58-
flex-direction: column;
59-
height: 100%;
56+
.has-panel {
57+
.layout-space {
58+
height: 100%;
59+
}
60+
}
61+
}
6062

61-
> .arco-tabs-nav {
62-
height: 28px;
63+
.arco-tabs.panel-tabs {
64+
display: flex;
65+
flex-direction: column;
66+
height: 100%;
6367

64-
&:before {
65-
background-color: var(--border-color);
66-
}
68+
> .arco-tabs-nav {
69+
height: 28px;
6770

68-
.arco-tabs-nav-tab {
71+
&:before {
72+
background-color: var(--border-color);
73+
}
74+
75+
.arco-tabs-nav-tab {
76+
height: 100%;
77+
78+
.arco-tabs-tab {
79+
border-radius: 0;
80+
font-size: 13px;
6981
height: 100%;
82+
margin: 0;
83+
padding: 0 12px;
7084

71-
.arco-tabs-tab {
72-
border-radius: 0;
73-
font-size: 13px;
74-
height: 100%;
75-
margin: 0;
76-
padding: 0 12px;
77-
78-
&.arco-tabs-tab-active {
79-
color: var(--main-font-color);
80-
font-weight: 600;
81-
}
85+
&.arco-tabs-tab-active {
86+
color: var(--main-font-color);
87+
font-weight: 600;
8288
}
8389
}
84-
.arco-tabs-nav-ink {
85-
background: var(--brand-color);
86-
}
8790
}
91+
.arco-tabs-nav-ink {
92+
background: var(--brand-color);
93+
}
94+
}
8895

89-
.arco-tabs-content {
90-
height: calc(100% - 28px);
96+
.arco-tabs-content {
97+
height: calc(100% - 28px);
9198

92-
padding: 0;
99+
padding: 0;
93100

94-
> .arco-tabs-content-list {
101+
> .arco-tabs-content-list {
102+
height: 100%;
103+
> .arco-tabs-content-item {
95104
height: 100%;
96-
> .arco-tabs-content-item {
97-
height: 100%;
98-
overflow: auto;
99-
> .arco-tabs-pane {
100-
height: 100%;
101-
}
105+
overflow: auto;
106+
> .arco-tabs-pane {
107+
height: 99%;
102108
}
103109
}
104110
}
105111
}
106-
107-
.has-panel {
108-
.layout-space {
109-
height: 100%;
110-
}
111-
}
112112
}

src/locale/en-US/dashboard.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export default {
6363
'dashboard.details': 'Information',
6464
'dashboard.quickSelect': 'Quick Query',
6565
'dashboard.clearCode': 'Clear Code',
66+
'dashboard.fullSizeMode': 'View fullscreen',
67+
'dashboard.exitFullSize': 'Exit fullscreen',
6668
'dashboard.refresh': 'Refresh',
6769
'dashboard.hints.columns': 'View column name and type, create quick query from any column.',
6870
'dashboard.hints.details': 'Metadata of the table',

src/locale/zh-CN/dashboard.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ export default {
6363
'dashboard.details': 'Information',
6464
'dashboard.quickSelect': 'Quick Query',
6565
'dashboard.clearCode': 'Clear Code',
66+
'dashboard.fullSizeMode': '全屏模式',
67+
'dashboard.exitFullSize': '退出全屏',
6668
'dashboard.refresh': 'Refresh',
6769
'dashboard.hints.columns': 'View column name and type, create quick query from any column.',
6870
'dashboard.hints.details': 'View metadata of the table.',

src/views/dashboard/modules/data-view/index.vue

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ a-tabs.panel-tabs(
99
@delete="deleteTab"
1010
)
1111
template(#extra)
12-
a-popconfirm(
13-
content="Clear results?"
14-
type="warning"
15-
ok-text="Clear"
16-
cancel-text=""
17-
@ok="clearResults"
18-
)
19-
a-button(status="danger" size="small") {{ $t('dashboard.clear') }}
12+
a-space(:size="8")
13+
a-tooltip(mini :content="props.isInFullSizeMode ? $t('dashboard.exitFullSize') : $t('dashboard.fullSizeMode')")
14+
a-button(size="small" @click="toggleFullSize")
15+
template(#icon)
16+
svg.icon-16
17+
use(href="#zoom")
18+
a-popconfirm(
19+
content="Clear results?"
20+
type="warning"
21+
ok-text="Clear"
22+
cancel-text=""
23+
@ok="clearResults"
24+
)
25+
a-button(status="danger" size="small") {{ $t('dashboard.clear') }}
2026
a-tab-pane(
2127
v-if="explainResult"
2228
key="explain"
@@ -96,9 +102,10 @@ a-tabs.panel-tabs(
96102
results: ResultType[]
97103
types: string[]
98104
explainResult?: ResultType
105+
isInFullSizeMode?: boolean
99106
}>()
100107
101-
const emit = defineEmits(['update:explainResult'])
108+
const emit = defineEmits(['update:explainResult', 'toggleFullSize'])
102109
103110
const { removeResult, clear } = useCodeRunStore()
104111
const activeTabKey = ref<string | number>()
@@ -143,6 +150,10 @@ a-tabs.panel-tabs(
143150
clear(props.types)
144151
}
145152
153+
const toggleFullSize = () => {
154+
emit('toggleFullSize', !props.isInFullSizeMode)
155+
}
156+
146157
watch(
147158
() => ({ ...props }),
148159
(value, old) => {
@@ -341,6 +352,15 @@ a-tabs.panel-tabs(
341352
}
342353
}
343354
355+
&.full-size {
356+
:deep(> .arco-tabs-nav) {
357+
height: 40px;
358+
}
359+
:deep(> .arco-tabs-content) {
360+
height: calc(100% - 40px);
361+
}
362+
}
363+
344364
.raw-json-card {
345365
padding: 8px 12px;
346366

src/views/dashboard/query/index.vue

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ a-layout.new-layout
2323
:results="results"
2424
:types="types"
2525
:explainResult="explainResult"
26+
:is-in-full-size-mode="false"
2627
@update:explainResult="(val) => (explainResult = val)"
28+
@toggle-full-size="handleToggleFullSize"
2729
)
2830
a-resize-box.panel-resize(
2931
v-model:height="logsHeight"
@@ -33,6 +35,27 @@ a-layout.new-layout
3335
a-tabs.panel-tabs
3436
a-tab-pane(title="Log" key="log")
3537
LogsNew(:logs="queryLogs")
38+
39+
a-modal.full-size-modal(
40+
v-model:visible="isFullSizeMode"
41+
:class="{ 'full-screen': isFullSizeMode }"
42+
:align-center="false"
43+
:footer="false"
44+
:closable="false"
45+
:header="false"
46+
:esc-to-close="true"
47+
:mask-style="{ backgroundColor: 'transparent', 'pointer-events': 'auto' }"
48+
)
49+
DataView.full-size(
50+
v-if="!!results?.length || !!explainResult"
51+
:results="results"
52+
:types="types"
53+
:explainResult="explainResult"
54+
:show-full-size-button="false"
55+
:is-in-full-size-mode="true"
56+
@update:explainResult="(val) => (explainResult = val)"
57+
@toggle-full-size="isFullSizeMode = false"
58+
)
3659
</template>
3760

3861
<script lang="ts" setup name="QueryNew">
@@ -41,7 +64,7 @@ a-layout.new-layout
4164
import 'driver.js/dist/driver.css'
4265
import { navbarSteps, tableSteps } from '../config'
4366
44-
const { s, q } = useMagicKeys()
67+
const { s, q, escape } = useMagicKeys()
4568
const activeElement = useActiveElement()
4669
const { hideSidebar, databaseList } = storeToRefs(useAppStore())
4770
const { logs } = storeToRefs(useLogStore())
@@ -52,6 +75,7 @@ a-layout.new-layout
5275
const { explainResult } = storeToRefs(useCodeRunStore())
5376
const types = ['sql', 'promql']
5477
const logsHeight = ref(66)
78+
const isFullSizeMode = ref(false)
5579
5680
const sidebarWidth = useStorage('sidebarWidth', 320)
5781
@@ -88,12 +112,26 @@ a-layout.new-layout
88112
queryType.value = 'promql'
89113
})
90114
115+
watch(escape, (v) => {
116+
if (v && isFullSizeMode.value) {
117+
isFullSizeMode.value = false
118+
}
119+
})
120+
91121
const selectExplainTab = () => {
92122
if (dataViewRef.value) {
93123
dataViewRef.value.selectTab('explain')
94124
}
95125
}
96126
127+
const handleToggleFullSize = (fullSize: boolean) => {
128+
isFullSizeMode.value = fullSize
129+
}
130+
131+
const toggleFullSize = () => {
132+
isFullSizeMode.value = !isFullSizeMode.value
133+
}
134+
97135
const globalTour = driver({
98136
showProgress: false,
99137
allowClose: false,
@@ -168,3 +206,30 @@ a-layout.new-layout
168206
}
169207
}
170208
</style>
209+
210+
<style lang="less">
211+
.full-size-modal {
212+
.arco-modal-wrapper {
213+
overflow: hidden;
214+
.arco-modal {
215+
pointer-events: auto;
216+
box-shadow: 0 2px 10px 0 var(--box-shadow-color);
217+
width: calc(100vw - var(--navbar-width-collapsed) - 16px);
218+
border: 1px solid var(--border-color);
219+
.arco-modal-body {
220+
padding: 8px 16px;
221+
height: calc(100vh - var(--footer-height) - 20px);
222+
}
223+
}
224+
}
225+
226+
&.full-screen {
227+
.arco-modal {
228+
transform: none !important;
229+
position: fixed !important;
230+
right: 6px !important;
231+
top: 10px !important;
232+
}
233+
}
234+
}
235+
</style>

0 commit comments

Comments
 (0)