Skip to content

Commit 0fe2afb

Browse files
authored
feat: support to show the key binding on each page (#721)
* chore: move styles into css files * support to show the key binding on each page * move the magic key dialog into a component * add shortcuts on the data manager page --------- Co-authored-by: rick <[email protected]>
1 parent ec10a65 commit 0fe2afb

File tree

14 files changed

+214
-47
lines changed

14 files changed

+214
-47
lines changed

console/atest-ui/src/App.vue

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import StoreManager from './views/StoreManager.vue'
1919
import SecretManager from './views/SecretManager.vue'
2020
import WelcomePage from './views/WelcomePage.vue'
2121
import DataManager from './views/DataManager.vue'
22+
import MagicKey from './components/MagicKey.vue'
2223
import { useI18n } from 'vue-i18n'
2324
2425
const { t, locale: i18nLocale } = useI18n()
@@ -101,15 +102,14 @@ watch(theme, (e) => {
101102
</script>
102103

103104
<template>
104-
<el-container style="height: 100%;">
105+
<el-container class="full-height">
105106
<el-aside width="auto" style="display: flex; flex-direction: column;">
106-
<el-radio-group v-model="isCollapse">
107+
<el-radio-group v-model="isCollapse" class="el-menu">
107108
<el-radio-button :value="false">+</el-radio-button>
108109
<el-radio-button :value="true">-</el-radio-button>
109110
</el-radio-group>
110111
<el-menu
111-
class="el-menu-vertical"
112-
style="height: 100%;"
112+
class="el-menu-vertical full-height"
113113
:default-active="activeMenu"
114114
:collapse="isCollapse"
115115
@select="handleSelect"
@@ -145,7 +145,7 @@ watch(theme, (e) => {
145145
</el-menu>
146146
</el-aside>
147147

148-
<el-main style="padding-top: 0px;">
148+
<el-main class="center-zone">
149149
<div class="top-menu">
150150
<el-col style="display: flex; align-items: center;">
151151
<el-icon @click="settingDialogVisible=true" size="20"><Setting /></el-icon>
@@ -213,10 +213,15 @@ watch(theme, (e) => {
213213
</el-col>
214214
</el-row>
215215
</el-dialog>
216+
217+
<MagicKey />
216218
</template>
217219

218220
<style>
219221
.el-menu-vertical:not(.el-menu--collapse) {
220222
width: 200px;
221223
}
224+
.el-menu-vertical:is(.el-menu--collapse) {
225+
width: 80px;
226+
}
222227
</style>

console/atest-ui/src/assets/base.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
2020
--vt-c-text-dark-1: var(--vt-c-white);
2121
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
22+
23+
--center-zone-side-padding: 5px;
2224
}
2325

2426
/* semantic color variables for this project */
@@ -34,6 +36,12 @@
3436
--color-text: var(--vt-c-text-light-1);
3537

3638
--section-gap: 160px;
39+
40+
--tool-box-bottom: 5px;
41+
--tool-box-position: absolute;
42+
43+
--page-title-right-padding: 10px;
44+
--page-title-bottom-padding: 5px;
3745
}
3846

3947
*,
@@ -67,3 +75,27 @@ html.dark .el-main {
6775
color: #fff;
6876
}
6977

78+
.center-zone {
79+
padding-left: var(--center-zone-side-padding) !important;
80+
padding-right: var(--center-zone-side-padding) !important;
81+
padding-top: 0px !important;
82+
}
83+
84+
.tool-box {
85+
position: var(--tool-box-position);
86+
bottom: var(--tool-box-bottom);
87+
}
88+
89+
.edit-button {
90+
height: 32px !important;
91+
margin-left: 10px;
92+
}
93+
94+
.page-title {
95+
padding-right: var(--page-title-right-padding);
96+
}
97+
98+
.page-header {
99+
height: 32px;
100+
padding-bottom: var(--page-title-bottom-padding, 0px);
101+
}

console/atest-ui/src/assets/main.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
#app {
44
margin: 0 auto;
5-
padding: 1rem;
6-
padding-top: 40px;
5+
{{/* padding-top: 40px; */}}
76
height: 100vh;
87
font-weight: normal;
98
}
@@ -14,6 +13,14 @@
1413
right: 20px;
1514
}
1615

16+
.full-height {
17+
height: 100%;
18+
}
19+
20+
.full-width {
21+
width: 100%;
22+
}
23+
1724
a,
1825
.green {
1926
text-decoration: none;

console/atest-ui/src/components/EditButton.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const handleInputConfirm = () => {
4040
@keyup.enter="handleInputConfirm"
4141
@blur="handleInputConfirm"
4242
/>
43-
<el-button v-else class="button-new-tag" size="small" @click="showInput">
43+
<el-button v-else class="button-new-tag" size="small edit-button" @click="showInput">
4444
{{ value }}
4545
</el-button>
4646
</span>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<script setup lang="ts">
2+
import { ref, onMounted, onBeforeUnmount } from 'vue'
3+
import { useI18n } from 'vue-i18n'
4+
import { Magic } from '@/views/magicKeys'
5+
6+
const { t } = useI18n()
7+
const keyBindingsDialogVisible = ref(false)
8+
const keyBindings = ref([])
9+
const showKeyBindingsDialog = (keys: any) => {
10+
keyBindingsDialogVisible.value = true
11+
keyBindings.value = keys.detail || []
12+
}
13+
14+
onMounted(() => {
15+
window.addEventListener(Magic.MagicKeyEventName, showKeyBindingsDialog)
16+
})
17+
18+
onBeforeUnmount(() => {
19+
window.removeEventListener(Magic.MagicKeyEventName, showKeyBindingsDialog)
20+
})
21+
</script>
22+
23+
<template>
24+
<el-drawer v-model="keyBindingsDialogVisible" size="50%">
25+
<template #header>
26+
<h4>{{ t('title.keyBindings') }}</h4>
27+
</template>
28+
<template #default>
29+
<el-table :data="keyBindings">
30+
<el-table-column prop="keys" :label="t('field.shortcut')" />
31+
<el-table-column prop="description" :label="t('field.description')" />
32+
</el-table>
33+
</template>
34+
</el-drawer>
35+
</template>

console/atest-ui/src/locales/en.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"updateStore": "Update Store",
3636
"createSecret": "Create Secret",
3737
"secretManager": "Secret Manager",
38+
"storeManager": "Store Manager",
39+
"dataManager": "Data Manager",
3840
"protoContent": "Proto Content",
3941
"protoFile": "Proto File",
4042
"protoImport": "Proto Import",
@@ -53,7 +55,8 @@
5355
"proxy": "Proxy",
5456
"secure": "Secure",
5557
"data": "Data",
56-
"setting": "Setting"
58+
"setting": "Setting",
59+
"keyBindings": "Key Bindings"
5760
},
5861
"tip": {
5962
"filter": "Filter Keyword",
@@ -78,6 +81,8 @@
7881
"key": "Key",
7982
"value": "Value",
8083
"proxy": "Proxy",
84+
"shortcut": "Shortcut",
85+
"description": "Description",
8186
"insecure": "Insecure"
8287
},
8388
"proxy": {

console/atest-ui/src/locales/zh.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"updateStore": "更新存储",
3636
"createSecret": "创建凭据",
3737
"secretManager": "凭据管理",
38+
"storeManager": "存储管理",
39+
"dataManager": "数据管理",
3840
"apiRequestParameter": "API 请求参数",
3941
"codeGenerator": "代码生成",
4042
"testing": "测试",
@@ -48,7 +50,8 @@
4850
"proxy": "代理",
4951
"secure": "安全",
5052
"data": "数据",
51-
"setting": "设置"
53+
"setting": "设置",
54+
"keyBindings": "按键绑定"
5255
},
5356
"tip": {
5457
"filter": "过滤",
@@ -73,6 +76,8 @@
7376
"key": "",
7477
"value": "",
7578
"proxy": "代理",
79+
"shortcut": "快捷键",
80+
"description": "描述",
7681
"insecure": "忽略证书验证"
7782
},
7883
"proxy": {

console/atest-ui/src/views/DataManager.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import { Codemirror } from 'vue-codemirror'
1010
import HistoryInput from '../components/HistoryInput.vue'
1111
import type { Ref } from 'vue'
1212
import { Refresh, Document } from '@element-plus/icons-vue'
13+
import { Magic } from './magicKeys'
14+
import { useI18n } from 'vue-i18n'
1315
16+
const { t } = useI18n()
1417
const stores: Ref<Store[]> = ref([])
1518
const kind = ref('')
1619
const store = ref('')
@@ -259,10 +262,19 @@ const tryShowPrettyJSON = (row: any, column: any, cell: HTMLTableCellElement, ev
259262
watch(largeContent, (e) => {
260263
largeContentDialogVisible.value = e !== ''
261264
})
265+
266+
Magic.AdvancedKeys([{
267+
Keys: ['Ctrl+E'],
268+
Func: executeQuery,
269+
Description: 'Execute query'
270+
}])
262271
</script>
263272

264273
<template>
265274
<div>
275+
<div class="page-header">
276+
<span class="page-title">{{t('title.dataManager')}}</span>
277+
</div>
266278
<el-container style="height: calc(100vh - 80px);">
267279
<el-aside v-if="kind === 'atest-store-orm' || kind === 'atest-store-iotdb' || kind === 'atest-store-cassandra' || kind === 'atest-store-elasticsearch' || kind === 'atest-store-opengemini'">
268280
<el-scrollbar>

console/atest-ui/src/views/SecretManager.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ const submitForm = async (formEl: FormInstance | undefined) => {
6666
</script>
6767

6868
<template>
69-
<div>{{t('title.secretManager')}}</div>
70-
<div>
69+
<div class="page-header">
70+
<span class="page-title">{{t('title.secretManager')}}</span>
7171
<el-button type="primary" @click="addSecret" :icon="Edit">{{t('button.new')}}</el-button>
7272
</div>
7373
<el-table :data="secrets" style="width: 100%">

console/atest-ui/src/views/StoreManager.vue

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function loadStores() {
6767
})
6868
}
6969
loadStores()
70-
Magic.Keys(loadStores, ['Alt+KeyR'])
7170
7271
function deleteStore(name: string) {
7372
API.DeleteStore(name, () => {
@@ -108,7 +107,16 @@ function addStore() {
108107
dialogVisible.value = true
109108
createAction.value = true
110109
}
111-
Magic.Keys(addStore, ['Alt+KeyN'])
110+
111+
Magic.AdvancedKeys([{
112+
Keys: ['Alt+KeyE', 'ctrl+n'],
113+
Func: addStore,
114+
Description: 'Add a new store'
115+
}, {
116+
Keys: ['Alt+KeyR'],
117+
Func: loadStores,
118+
Description: 'Refresh the store list'
119+
}])
112120
113121
const rules = reactive<FormRules<Store>>({
114122
name: [{ required: true, message: 'Name is required', trigger: 'blur' }],
@@ -211,10 +219,10 @@ const storeExtLink = ref('')
211219
</script>
212220

213221
<template>
214-
<div>Store Manager</div>
215-
<div>
216-
<Button type="primary" @click="addStore" :icon="Edit">{{t('button.new')}}</Button>
217-
<Button type="primary" @click="loadStores" :icon="Refresh">{{t('button.refresh')}}</Button>
222+
<div class="page-header">
223+
<span class="page-title">{{t('title.storeManager')}}</span>
224+
<Button type="primary" @click="addStore" :icon="Edit">{{t('button.new')}}</Button>
225+
<Button type="primary" @click="loadStores" :icon="Refresh">{{t('button.refresh')}}</Button>
218226
</div>
219227
<el-table :data="stores" style="width: 100%" v-loading=storesLoading>
220228
<el-table-column :label="t('field.name')" width="180">

0 commit comments

Comments
 (0)