From bea9321fc8f705536b5274d9f8b865390c890b7b Mon Sep 17 00:00:00 2001 From: ssongliu Date: Thu, 1 Sep 2022 16:52:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BF=AB=E9=80=9F=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E4=B8=8E=E6=89=B9=E9=87=8F=E8=BE=93=E5=85=A5=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/host.go | 2 +- backend/app/dto/host.go | 9 + backend/router/ro_command.go | 9 +- backend/router/ro_group.go | 8 +- frontend/src/api/interface/host.ts | 8 + frontend/src/api/modules/host.ts | 7 +- frontend/src/lang/modules/en.ts | 3 + frontend/src/lang/modules/zh.ts | 3 + frontend/src/views/terminal/host/index.vue | 6 +- frontend/src/views/terminal/index.vue | 550 +++++++++--------- .../src/views/terminal/terminal/index.vue | 11 +- 11 files changed, 311 insertions(+), 305 deletions(-) diff --git a/backend/app/api/v1/host.go b/backend/app/api/v1/host.go index f5fbf5e9f..90c65aa50 100644 --- a/backend/app/api/v1/host.go +++ b/backend/app/api/v1/host.go @@ -29,7 +29,7 @@ func (b *BaseApi) CreateHost(c *gin.Context) { } func (b *BaseApi) TestConn(c *gin.Context) { - var req dto.HostOperate + var req dto.HostConnTest if err := c.ShouldBindJSON(&req); err != nil { helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) return diff --git a/backend/app/dto/host.go b/backend/app/dto/host.go index 43c97c0b8..4f76f9020 100644 --- a/backend/app/dto/host.go +++ b/backend/app/dto/host.go @@ -17,6 +17,15 @@ type HostOperate struct { Description string `json:"description"` } +type HostConnTest struct { + Addr string `json:"addr" validate:"required,ip"` + Port uint `json:"port" validate:"required,number,max=65535,min=1"` + User string `json:"user" validate:"required"` + AuthMode string `json:"authMode" validate:"oneof=password key"` + PrivateKey string `json:"privateKey"` + Password string `json:"password"` +} + type SearchForTree struct { Info string `json:"info"` } diff --git a/backend/router/ro_command.go b/backend/router/ro_command.go index ec4b5559a..94af78685 100644 --- a/backend/router/ro_command.go +++ b/backend/router/ro_command.go @@ -10,15 +10,14 @@ import ( type CommandRouter struct{} func (s *CommandRouter) InitCommandRouter(Router *gin.RouterGroup) { - userRouter := Router.Group("commands") - userRouter.Use(middleware.JwtAuth()).Use(middleware.SessionAuth()) - withRecordRouter := userRouter.Use(middleware.OperationRecord()) + cmdRouter := Router.Group("commands").Use(middleware.JwtAuth()).Use(middleware.SessionAuth()) + withRecordRouter := Router.Group("commands").Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.OperationRecord()) baseApi := v1.ApiGroupApp.BaseApi { withRecordRouter.POST("", baseApi.CreateCommand) withRecordRouter.POST("/del", baseApi.DeleteCommand) withRecordRouter.PUT(":id", baseApi.UpdateCommand) - userRouter.POST("/search", baseApi.SearchCommand) - userRouter.GET("", baseApi.ListCommand) + cmdRouter.POST("/search", baseApi.SearchCommand) + cmdRouter.GET("", baseApi.ListCommand) } } diff --git a/backend/router/ro_group.go b/backend/router/ro_group.go index e815b75a2..a80bb2ee5 100644 --- a/backend/router/ro_group.go +++ b/backend/router/ro_group.go @@ -10,14 +10,14 @@ import ( type GroupRouter struct{} func (s *GroupRouter) InitGroupRouter(Router *gin.RouterGroup) { - userRouter := Router.Group("groups").Use(middleware.JwtAuth()).Use(middleware.SessionAuth()) + groupRouter := Router.Group("groups").Use(middleware.JwtAuth()).Use(middleware.SessionAuth()) withRecordRouter := Router.Group("groups").Use(middleware.JwtAuth()).Use(middleware.SessionAuth()).Use(middleware.OperationRecord()) baseApi := v1.ApiGroupApp.BaseApi { withRecordRouter.POST("", baseApi.CreateGroup) withRecordRouter.DELETE(":id", baseApi.DeleteGroup) - userRouter.POST("/search", baseApi.ListGroup) - userRouter.GET(":id", baseApi.GetGroupInfo) - userRouter.PUT(":id", baseApi.UpdateGroup) + withRecordRouter.PUT(":id", baseApi.UpdateGroup) + groupRouter.POST("/search", baseApi.ListGroup) + groupRouter.GET(":id", baseApi.GetGroupInfo) } } diff --git a/frontend/src/api/interface/host.ts b/frontend/src/api/interface/host.ts index 68641d7c3..2f0e256a4 100644 --- a/frontend/src/api/interface/host.ts +++ b/frontend/src/api/interface/host.ts @@ -32,6 +32,14 @@ export namespace Host { description: string; } + export interface HostConnTest { + addr: string; + port: number; + user: string; + authMode: string; + privateKey: string; + password: string; + } export interface ReqSearch { info?: string; } diff --git a/frontend/src/api/modules/host.ts b/frontend/src/api/modules/host.ts index 073e38952..8986144f9 100644 --- a/frontend/src/api/modules/host.ts +++ b/frontend/src/api/modules/host.ts @@ -1,7 +1,7 @@ import http from '@/api'; import { Host } from '../interface/host'; -export const getHostList = (params: Host.ReqSearch) => { +export const getHostTree = (params: Host.ReqSearch) => { return http.post>(`/hosts/search`, params); }; @@ -13,12 +13,11 @@ export const addHost = (params: Host.HostOperate) => { return http.post(`/hosts`, params); }; -export const testConn = (params: Host.HostOperate) => { - return http.post(`/hosts/testconn`, params); +export const testConn = (params: Host.HostConnTest) => { + return http.post(`/hosts/testconn`, params); }; export const editHost = (params: Host.HostOperate) => { - console.log(params.id); return http.put(`/hosts/` + params.id, params); }; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 1b341ac20..c3e64debc 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -92,12 +92,15 @@ export default { terminal: { conn: 'connection', testConn: 'Test connection', + saveAndConn: 'Save and Connect', connTestOk: 'Connection information available', hostList: 'Host information', createConn: 'Create a connection', createGroup: 'Create a group', expand: 'Expand all', fold: 'All contract', + batchInput: 'Batch input', + quickCommand: 'quick command', groupDeleteHelper: 'After the group is removed, all connections in the group will be migrated to the default group. Confirm the information', addHost: 'Add Host', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 06767eb7c..1cb875d2d 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -95,12 +95,15 @@ export default { terminal: { conn: '连接', testConn: '连接测试', + saveAndConn: '保存并连接', connTestOk: '连接信息可用', hostList: '主机信息', createConn: '创建连接', createGroup: '创建分组', expand: '全部展开', fold: '全部收缩', + batchInput: '批量输入', + quickCommand: '快速命令', groupDeleteHelper: '移除组后,组内所有连接将迁移到 default 组内,是否确认', quickCmd: '快捷命令', command: '命令', diff --git a/frontend/src/views/terminal/host/index.vue b/frontend/src/views/terminal/host/index.vue index 5c8535800..f7cf52320 100644 --- a/frontend/src/views/terminal/host/index.vue +++ b/frontend/src/views/terminal/host/index.vue @@ -44,7 +44,6 @@ :default-expand-all="true" :data="hostTree" :props="defaultProps" - draggable >