Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/app/api/v2/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ func checkSettingValueRange(key, value string) bool {
// @Tags System Setting
// @Summary Update system terminal setting
// @Accept json
// @Param request body dto.TerminalInfo true "request"
// @Param request body dto.TerminalUpdate true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /core/settings/terminal/update [post]
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"修改系统终端配置","formatEN":"update system terminal setting"}
func (b *BaseApi) UpdateTerminalSetting(c *gin.Context) {
var req dto.TerminalInfo
var req dto.TerminalUpdate
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
Expand Down
35 changes: 25 additions & 10 deletions core/app/dto/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,31 @@ type MenuLabelSort struct {
}

type TerminalInfo struct {
LineHeight string `json:"lineHeight"`
LetterSpacing string `json:"letterSpacing"`
FontSize string `json:"fontSize"`
FontFamily string `json:"fontFamily"`
BackgroundColor string `json:"backgroundColor"`
ForegroundColor string `json:"foregroundColor"`
CursorBlink string `json:"cursorBlink"`
CursorStyle string `json:"cursorStyle"`
Scrollback string `json:"scrollback"`
ScrollSensitivity string `json:"scrollSensitivity"`
ShowTerminalButton string `json:"showTerminalButton"`
LineHeight string `json:"lineHeight"`
LetterSpacing string `json:"letterSpacing"`
FontSize string `json:"fontSize"`
FontFamily string `json:"fontFamily"`
BackgroundColor string `json:"backgroundColor"`
ForegroundColor string `json:"foregroundColor"`
CursorBlink string `json:"cursorBlink"`
CursorStyle string `json:"cursorStyle"`
Scrollback string `json:"scrollback"`
ScrollSensitivity string `json:"scrollSensitivity"`
}

type TerminalUpdate struct {
ShowTerminalButton *string `json:"showTerminalButton,omitempty" validate:"omitempty,oneof=Enable Disable"`
LineHeight *string `json:"lineHeight,omitempty"`
LetterSpacing *string `json:"letterSpacing,omitempty"`
FontSize *string `json:"fontSize,omitempty"`
FontFamily *string `json:"fontFamily,omitempty"`
BackgroundColor *string `json:"backgroundColor,omitempty"`
ForegroundColor *string `json:"foregroundColor,omitempty"`
CursorBlink *string `json:"cursorBlink,omitempty"`
CursorStyle *string `json:"cursorStyle,omitempty"`
Scrollback *string `json:"scrollback,omitempty"`
ScrollSensitivity *string `json:"scrollSensitivity,omitempty"`
}

type AppstoreUpdate struct {
Expand Down
61 changes: 26 additions & 35 deletions core/app/service/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type ISettingService interface {
UpdateProxy(req dto.ProxyUpdate) error

GetTerminalInfo() (*dto.TerminalInfo, error)
UpdateTerminal(req dto.TerminalInfo) error
UpdateTerminal(req dto.TerminalUpdate) error

UpdateSystemSSL() error
GenerateRSAKey() error
Expand Down Expand Up @@ -559,7 +559,7 @@ func (u *SettingService) GetTerminalInfo() (*dto.TerminalInfo, error) {
for _, set := range setting {
settingMap[set.Key] = set.Value
}
var info dto.TerminalInfo
info := dto.TerminalInfo{ShowTerminalButton: "Enable"}
arr, err := json.Marshal(settingMap)
if err != nil {
return nil, err
Expand All @@ -569,39 +569,30 @@ func (u *SettingService) GetTerminalInfo() (*dto.TerminalInfo, error) {
}
return &info, err
}
func (u *SettingService) UpdateTerminal(req dto.TerminalInfo) error {
if err := settingRepo.UpdateOrCreate("LineHeight", req.LineHeight); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("LetterSpacing", req.LetterSpacing); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("FontSize", req.FontSize); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("FontFamily", req.FontFamily); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("CursorBlink", req.CursorBlink); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("BackgroundColor", req.BackgroundColor); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("ForegroundColor", req.ForegroundColor); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("CursorBlink", req.CursorBlink); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("CursorStyle", req.CursorStyle); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("Scrollback", req.Scrollback); err != nil {
return err
}
if err := settingRepo.UpdateOrCreate("ScrollSensitivity", req.ScrollSensitivity); err != nil {
return err
func (u *SettingService) UpdateTerminal(req dto.TerminalUpdate) error {
settings := []struct {
key string
value *string
}{
{"ShowTerminalButton", req.ShowTerminalButton},
{"LineHeight", req.LineHeight},
{"LetterSpacing", req.LetterSpacing},
{"FontSize", req.FontSize},
{"FontFamily", req.FontFamily},
{"CursorBlink", req.CursorBlink},
{"BackgroundColor", req.BackgroundColor},
{"ForegroundColor", req.ForegroundColor},
{"CursorStyle", req.CursorStyle},
{"Scrollback", req.Scrollback},
{"ScrollSensitivity", req.ScrollSensitivity},
}
for _, setting := range settings {
if setting.value == nil {
continue
}
if err := settingRepo.UpdateOrCreate(setting.key, *setting.value); err != nil {
return err
}
}
return nil
}
Expand Down
43 changes: 42 additions & 1 deletion core/cmd/server/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11683,7 +11683,7 @@ const docTemplate = `{
"name": "request",
"required": true,
"schema": {
"$ref": "#/definitions/dto.TerminalInfo"
"$ref": "#/definitions/dto.TerminalUpdate"
}
}
],
Expand Down Expand Up @@ -40869,6 +40869,47 @@ const docTemplate = `{
},
"scrollback": {
"type": "string"
},
"showTerminalButton": {
"type": "string"
}
},
"type": "object"
},
"dto.TerminalUpdate": {
"properties": {
"backgroundColor": {
"type": "string"
},
"cursorBlink": {
"type": "string"
},
"cursorStyle": {
"type": "string"
},
"fontFamily": {
"type": "string"
},
"fontSize": {
"type": "string"
},
"foregroundColor": {
"type": "string"
},
"letterSpacing": {
"type": "string"
},
"lineHeight": {
"type": "string"
},
"scrollSensitivity": {
"type": "string"
},
"scrollback": {
"type": "string"
},
"showTerminalButton": {
"type": "string"
}
},
"type": "object"
Expand Down
43 changes: 42 additions & 1 deletion core/cmd/server/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11679,7 +11679,7 @@
"name": "request",
"required": true,
"schema": {
"$ref": "#/definitions/dto.TerminalInfo"
"$ref": "#/definitions/dto.TerminalUpdate"
}
}
],
Expand Down Expand Up @@ -40865,6 +40865,47 @@
},
"scrollback": {
"type": "string"
},
"showTerminalButton": {
"type": "string"
}
},
"type": "object"
},
"dto.TerminalUpdate": {
"properties": {
"backgroundColor": {
"type": "string"
},
"cursorBlink": {
"type": "string"
},
"cursorStyle": {
"type": "string"
},
"fontFamily": {
"type": "string"
},
"fontSize": {
"type": "string"
},
"foregroundColor": {
"type": "string"
},
"letterSpacing": {
"type": "string"
},
"lineHeight": {
"type": "string"
},
"scrollSensitivity": {
"type": "string"
},
"scrollback": {
"type": "string"
},
"showTerminalButton": {
"type": "string"
}
},
"type": "object"
Expand Down
1 change: 1 addition & 0 deletions frontend/src/api/interface/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export namespace Setting {
dashboardSimpleNodeVisible: string;
}
export interface TerminalInfo {
showTerminalButton?: string;
lineHeight: string;
letterSpacing: string;
fontSize: string;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/modules/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const getSettingBaseInfo = () => {
export const getTerminalInfo = () => {
return http.post<Setting.TerminalInfo>(`/core/settings/terminal/search`);
};
export const UpdateTerminalInfo = (param: Setting.TerminalInfo) => {
export const UpdateTerminalInfo = (param: Partial<Setting.TerminalInfo>) => {
return http.post(`/core/settings/terminal/update`, param);
};
export const getSystemAvailable = () => {
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/components/terminal/dock/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<!-- Right edge handle: open a terminal from any page without leaving it. Hidden on the terminal page itself. -->
<div v-if="!onTerminalPage" class="terminal-dock-handle" @click="show">
<div v-if="terminalStore.showTerminalButton && !onTerminalPage" class="terminal-dock-handle" @click="show">
<el-badge
:value="store.entries.length"
:hidden="store.entries.length === 0"
Expand Down Expand Up @@ -143,22 +143,29 @@
</template>

<script setup lang="ts">
import { computed, nextTick, ref, watch } from 'vue';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import i18n from '@/lang';
import { ElTree } from 'element-plus';
import { TerminalSessionStore } from '@/store';
import { TerminalSessionStore, TerminalStore } from '@/store';
import { getTerminalInfo } from '@/api/modules/setting';
import { useGlobalStore } from '@/composables/useGlobalStore';
import { getHostTree, testByID, testLocalConn } from '@/api/modules/terminal';
import { MsgError } from '@/utils/message';
import { ElMessageBox } from 'element-plus';
import { Host } from '@/api/interface/host';

const store = TerminalSessionStore();
const terminalStore = TerminalStore();
const { isNodeAdmin } = useGlobalStore();
const route = useRoute();
const onTerminalPage = computed(() => route.path.startsWith('/terminal'));

onMounted(async () => {
const res = await getTerminalInfo();
terminalStore.showTerminalButton = res.data.showTerminalButton !== 'Disable';
});

const open = ref(false);
const active = ref('');
const showConnections = ref(false);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,8 @@ const message = {
profileBlockDesc: 'Measures blocking on channels, select statements, and synchronization primitives.',
},
terminal: {
showTerminalButton: 'Show Terminal Button',
showTerminalButtonHelper: 'Show the terminal shortcut button in the bottom-right corner of the page.',
local: 'Local',
defaultConn: 'Default Connection',
defaultConnHelper:
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/es-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,8 @@ const message = {
profileBlockDesc: 'Mide los bloqueos en canales, select y primitivas de sincronización.',
},
terminal: {
showTerminalButton: 'Mostrar botón de terminal',
showTerminalButtonHelper: 'Mostrar el botón de acceso al terminal en la esquina inferior derecha de la página.',
local: 'Local',
defaultConn: 'Conexión predeterminada',
defaultConnHelper:
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2049,6 +2049,8 @@ const message = {
profileBlockDesc: 'زمان انسداد روی Channel، Select و ابزارهای همگام‌سازی را اندازه‌گیری می‌کند.',
},
terminal: {
showTerminalButton: 'نمایش دکمه ترمینال',
showTerminalButtonHelper: 'نمایش دکمه میانبر ترمینال در گوشه پایین سمت راست صفحه.',
local: 'محلی',
defaultConn: 'اتصال پیش‌فرض',
defaultConnHelper:
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,8 @@ const message = {
profileBlockDesc: 'Channel、Select、同期プリミティブでのブロック待機時間を測定します。',
},
terminal: {
showTerminalButton: 'ターミナルボタンを表示',
showTerminalButtonHelper: 'ページの右下にターミナルのショートカットボタンを表示します。',
local: 'ローカル',
defaultConn: 'デフォルト接続',
defaultConnHelper:
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,8 @@ const message = {
profileBlockDesc: 'Channel, Select 및 동기화 프리미티브의 차단 대기 시간을 측정합니다.',
},
terminal: {
showTerminalButton: '터미널 버튼 표시',
showTerminalButtonHelper: '페이지 오른쪽 아래에 터미널 바로가기 버튼을 표시합니다.',
local: '로컬',
defaultConn: '기본 연결',
defaultConnHelper: '이 작업은 【{0}】의 터미널을 연 후 자동으로 노드 터미널에 연결됩니다. 계속하시겠습니까?',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/lo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,8 @@ const message = {
profileBlockDesc: 'ວັດແທກການບລັອກໃນ Channel, Select Statement ແລະ ກົນໄກ Synchronization.',
},
terminal: {
showTerminalButton: 'ສະແດງປຸ່ມ Terminal',
showTerminalButtonHelper: 'ສະແດງປຸ່ມທາງລັດ Terminal ຢູ່ມຸມຂວາລຸ່ມຂອງໜ້າ.',
local: 'ພາຍໃນເຄື່ອງ (Local)',
defaultConn: 'ການເຊື່ອມຕໍ່ເລີ່ມຕົ້ນ',
defaultConnHelper:
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,8 @@ const message = {
profileBlockDesc: 'Mengukur sekatan pada Channel, Select dan primitif penyegerakan.',
},
terminal: {
showTerminalButton: 'Papar Butang Terminal',
showTerminalButtonHelper: 'Paparkan butang pintasan terminal di sudut kanan bawah halaman.',
local: 'Tempatan',
defaultConn: 'Sambungan Lalai',
defaultConnHelper:
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/pt-br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,8 @@ const message = {
profileBlockDesc: 'Mede bloqueios em canais, select e primitivas de sincronização.',
},
terminal: {
showTerminalButton: 'Mostrar botão do terminal',
showTerminalButtonHelper: 'Mostrar o botão de acesso ao terminal no canto inferior direito da página.',
local: 'Local',
defaultConn: 'Conexão Padrão',
defaultConnHelper:
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/lang/modules/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2081,6 +2081,8 @@ const message = {
profileBlockDesc: 'Измеряет блокировки на каналах, select и примитивах синхронизации.',
},
terminal: {
showTerminalButton: 'Показывать кнопку терминала',
showTerminalButtonHelper: 'Показывать кнопку быстрого доступа к терминалу в правом нижнем углу страницы.',
local: 'Локальный',
defaultConn: 'Соединение по умолчанию',
defaultConnHelper:
Expand Down
Loading
Loading