Browse Source

fix: 修复 Redis 数据库快速命令部分问题 (#5206)

pull/5215/head
ssongliu 6 months ago committed by GitHub
parent
commit
c62232e648
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      backend/app/api/v1/command.go
  2. 6
      backend/app/repo/command.go
  3. 12
      backend/app/service/command.go
  4. 8
      backend/app/service/database.go
  5. 2
      backend/router/ro_host.go
  6. 8
      cmd/server/docs/docs.go
  7. 8
      cmd/server/docs/swagger.json
  8. 8
      cmd/server/docs/swagger.yaml
  9. 2
      frontend/src/api/modules/host.ts
  10. 2
      frontend/src/global/form-rules.ts
  11. 2
      frontend/src/lang/modules/en.ts
  12. 4
      frontend/src/lang/modules/tw.ts
  13. 4
      frontend/src/lang/modules/zh.ts
  14. 7
      frontend/src/views/container/image/pull/index.vue
  15. 45
      frontend/src/views/database/redis/command/index.vue
  16. 41
      frontend/src/views/database/redis/index.vue
  17. 2
      frontend/src/views/database/redis/remote/operate/index.vue
  18. 11
      frontend/src/views/toolbox/ftp/index.vue
  19. 2
      frontend/src/views/toolbox/ftp/log/index.vue
  20. 2
      frontend/src/views/toolbox/ftp/operate/index.vue

10
backend/app/api/v1/command.go

@ -30,21 +30,21 @@ func (b *BaseApi) CreateCommand(c *gin.Context) {
} }
// @Tags Redis Command // @Tags Redis Command
// @Summary Create redis command // @Summary Save redis command
// @Description 创建 Redis 快速命令 // @Description 保存 Redis 快速命令
// @Accept json // @Accept json
// @Param request body dto.RedisCommand true "request" // @Param request body dto.RedisCommand true "request"
// @Success 200 // @Success 200
// @Security ApiKeyAuth // @Security ApiKeyAuth
// @Router /hosts/command/redis [post] // @Router /hosts/command/redis [post]
// @x-panel-log {"bodyKeys":["name","command"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"创建 redis 快捷命令 [name][command]","formatEN":"create quick command for redis [name][command]"} // @x-panel-log {"bodyKeys":["name","command"],"paramKeys":[],"BeforeFunctions":[],"formatZH":"保存 redis 快捷命令 [name][command]","formatEN":"save quick command for redis [name][command]"}
func (b *BaseApi) CreateRedisCommand(c *gin.Context) { func (b *BaseApi) SaveRedisCommand(c *gin.Context) {
var req dto.RedisCommand var req dto.RedisCommand
if err := helper.CheckBindAndValidate(&req, c); err != nil { if err := helper.CheckBindAndValidate(&req, c); err != nil {
return return
} }
if err := commandService.CreateRedisCommand(req); err != nil { if err := commandService.SaveRedisCommand(req); err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return return
} }

6
backend/app/repo/command.go

@ -21,7 +21,7 @@ type ICommandRepo interface {
PageRedis(limit, offset int, opts ...DBOption) (int64, []model.RedisCommand, error) PageRedis(limit, offset int, opts ...DBOption) (int64, []model.RedisCommand, error)
GetRedis(opts ...DBOption) (model.RedisCommand, error) GetRedis(opts ...DBOption) (model.RedisCommand, error)
GetRedisList(opts ...DBOption) ([]model.RedisCommand, error) GetRedisList(opts ...DBOption) ([]model.RedisCommand, error)
CreateRedis(command *model.RedisCommand) error SaveRedis(command *model.RedisCommand) error
DeleteRedis(opts ...DBOption) error DeleteRedis(opts ...DBOption) error
} }
@ -107,8 +107,8 @@ func (u *CommandRepo) Create(command *model.Command) error {
return global.DB.Create(command).Error return global.DB.Create(command).Error
} }
func (u *CommandRepo) CreateRedis(command *model.RedisCommand) error { func (u *CommandRepo) SaveRedis(command *model.RedisCommand) error {
return global.DB.Create(command).Error return global.DB.Save(command).Error
} }
func (u *CommandRepo) Update(id uint, vars map[string]interface{}) error { func (u *CommandRepo) Update(id uint, vars map[string]interface{}) error {

12
backend/app/service/command.go

@ -2,6 +2,7 @@ package service
import ( import (
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/app/model"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/jinzhu/copier" "github.com/jinzhu/copier"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -19,7 +20,7 @@ type ICommandService interface {
SearchRedisCommandWithPage(search dto.SearchWithPage) (int64, interface{}, error) SearchRedisCommandWithPage(search dto.SearchWithPage) (int64, interface{}, error)
ListRedisCommand() ([]dto.RedisCommand, error) ListRedisCommand() ([]dto.RedisCommand, error)
CreateRedisCommand(commandDto dto.RedisCommand) error SaveRedisCommand(commandDto dto.RedisCommand) error
DeleteRedisCommand(ids []uint) error DeleteRedisCommand(ids []uint) error
} }
@ -153,15 +154,12 @@ func (u *CommandService) ListRedisCommand() ([]dto.RedisCommand, error) {
return dtoCommands, err return dtoCommands, err
} }
func (u *CommandService) CreateRedisCommand(commandDto dto.RedisCommand) error { func (u *CommandService) SaveRedisCommand(commandDto dto.RedisCommand) error {
command, _ := commandRepo.GetRedis(commonRepo.WithByName(commandDto.Name)) var command model.RedisCommand
if command.ID != 0 {
return constant.ErrRecordExist
}
if err := copier.Copy(&command, &commandDto); err != nil { if err := copier.Copy(&command, &commandDto); err != nil {
return errors.WithMessage(constant.ErrStructTransform, err.Error()) return errors.WithMessage(constant.ErrStructTransform, err.Error())
} }
if err := commandRepo.CreateRedis(&command); err != nil { if err := commandRepo.SaveRedis(&command); err != nil {
return err return err
} }
return nil return nil

8
backend/app/service/database.go

@ -275,6 +275,14 @@ func (u *DatabaseService) Update(req dto.DatabaseUpdate) error {
}); err != nil { }); err != nil {
return err return err
} }
case constant.AppRedis:
if _, err := redis_client.NewRedisClient(redis_client.DBInfo{
Address: req.Address,
Port: req.Port,
Password: req.Password,
}); err != nil {
return err
}
case "mysql", "mariadb": case "mysql", "mariadb":
if _, err := mysql.NewMysqlClient(client.DBInfo{ if _, err := mysql.NewMysqlClient(client.DBInfo{
From: "remote", From: "remote",

2
backend/router/ro_host.go

@ -57,7 +57,7 @@ func (s *HostRouter) InitRouter(Router *gin.RouterGroup) {
hostRouter.POST("/command/update", baseApi.UpdateCommand) hostRouter.POST("/command/update", baseApi.UpdateCommand)
hostRouter.GET("/command/redis", baseApi.ListRedisCommand) hostRouter.GET("/command/redis", baseApi.ListRedisCommand)
hostRouter.POST("/command/redis", baseApi.CreateRedisCommand) hostRouter.POST("/command/redis", baseApi.SaveRedisCommand)
hostRouter.POST("/command/redis/search", baseApi.SearchRedisCommand) hostRouter.POST("/command/redis/search", baseApi.SearchRedisCommand)
hostRouter.POST("/command/redis/del", baseApi.DeleteRedisCommand) hostRouter.POST("/command/redis/del", baseApi.DeleteRedisCommand)

8
cmd/server/docs/docs.go

@ -7674,14 +7674,14 @@ const docTemplate = `{
"ApiKeyAuth": [] "ApiKeyAuth": []
} }
], ],
"description": "创建 Redis 快速命令", "description": "保存 Redis 快速命令",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
"tags": [ "tags": [
"Redis Command" "Redis Command"
], ],
"summary": "Create redis command", "summary": "Save redis command",
"parameters": [ "parameters": [
{ {
"description": "request", "description": "request",
@ -7704,8 +7704,8 @@ const docTemplate = `{
"name", "name",
"command" "command"
], ],
"formatEN": "create quick command for redis [name][command]", "formatEN": "save quick command for redis [name][command]",
"formatZH": "创建 redis 快捷命令 [name][command]", "formatZH": "保存 redis 快捷命令 [name][command]",
"paramKeys": [] "paramKeys": []
} }
} }

8
cmd/server/docs/swagger.json

@ -7667,14 +7667,14 @@
"ApiKeyAuth": [] "ApiKeyAuth": []
} }
], ],
"description": "创建 Redis 快速命令", "description": "保存 Redis 快速命令",
"consumes": [ "consumes": [
"application/json" "application/json"
], ],
"tags": [ "tags": [
"Redis Command" "Redis Command"
], ],
"summary": "Create redis command", "summary": "Save redis command",
"parameters": [ "parameters": [
{ {
"description": "request", "description": "request",
@ -7697,8 +7697,8 @@
"name", "name",
"command" "command"
], ],
"formatEN": "create quick command for redis [name][command]", "formatEN": "save quick command for redis [name][command]",
"formatZH": "创建 redis 快捷命令 [name][command]", "formatZH": "保存 redis 快捷命令 [name][command]",
"paramKeys": [] "paramKeys": []
} }
} }

8
cmd/server/docs/swagger.yaml

@ -10069,7 +10069,7 @@ paths:
post: post:
consumes: consumes:
- application/json - application/json
description: 创建 Redis 快速命令 description: 保存 Redis 快速命令
parameters: parameters:
- description: request - description: request
in: body in: body
@ -10082,7 +10082,7 @@ paths:
description: OK description: OK
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
summary: Create redis command summary: Save redis command
tags: tags:
- Redis Command - Redis Command
x-panel-log: x-panel-log:
@ -10090,8 +10090,8 @@ paths:
bodyKeys: bodyKeys:
- name - name
- command - command
formatEN: create quick command for redis [name][command] formatEN: save quick command for redis [name][command]
formatZH: 创建 redis 快捷命令 [name][command] formatZH: 保存 redis 快捷命令 [name][command]
paramKeys: [] paramKeys: []
/hosts/command/redis/del: /hosts/command/redis/del:
post: post:

2
frontend/src/api/modules/host.ts

@ -78,7 +78,7 @@ export const getRedisCommandList = () => {
export const getRedisCommandPage = (params: SearchWithPage) => { export const getRedisCommandPage = (params: SearchWithPage) => {
return http.post<ResPage<Command.RedisCommand>>(`/hosts/command/redis/search`, params); return http.post<ResPage<Command.RedisCommand>>(`/hosts/command/redis/search`, params);
}; };
export const addRedisCommand = (params: Command.RedisCommand) => { export const saveRedisCommand = (params: Command.RedisCommand) => {
return http.post(`/hosts/command/redis`, params); return http.post(`/hosts/command/redis`, params);
}; };
export const deleteRedisCommand = (params: { ids: number[] }) => { export const deleteRedisCommand = (params: { ids: number[] }) => {

2
frontend/src/global/form-rules.ts

@ -185,7 +185,7 @@ const checkSimplePassword = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) { if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.simplePassword'))); callback(new Error(i18n.global.t('commons.rule.simplePassword')));
} else { } else {
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{5,29}$/; const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{0,29}$/;
if (!reg.test(value) && value !== '') { if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.simplePassword'))); callback(new Error(i18n.global.t('commons.rule.simplePassword')));
} else { } else {

2
frontend/src/lang/modules/en.ts

@ -171,7 +171,7 @@ const message = {
'Supports non-special characters starting with English, Chinese, numbers, .- and _, length 1-128', 'Supports non-special characters starting with English, Chinese, numbers, .- and _, length 1-128',
userName: 'Support English, Chinese, numbers and _ length 3-30', userName: 'Support English, Chinese, numbers and _ length 3-30',
simpleName: 'Supports non-underscore starting, English, numbers, _, length 3-30', simpleName: 'Supports non-underscore starting, English, numbers, _, length 3-30',
simplePassword: 'Supports non-underscore starting, English, numbers, _, length 6-30', simplePassword: 'Supports non-underscore starting, English, numbers, _, length 1-30',
dbName: 'Supports non-special character starting, including English, Chinese, numbers, .-_, with a length of 1-64', dbName: 'Supports non-special character starting, including English, Chinese, numbers, .-_, with a length of 1-64',
imageName: 'Support English, numbers, :/.-_, length 1-150', imageName: 'Support English, numbers, :/.-_, length 1-150',
volumeName: 'Support English, numbers, .-_, length 2-30', volumeName: 'Support English, numbers, .-_, length 2-30',

4
frontend/src/lang/modules/tw.ts

@ -171,7 +171,7 @@ const message = {
commonName: '支持非特殊字元開頭,英文中文數字.-和_,長度1-128', commonName: '支持非特殊字元開頭,英文中文數字.-和_,長度1-128',
userName: '支持英文中文數字和_,長度3-30', userName: '支持英文中文數字和_,長度3-30',
simpleName: '支持非底線開頭英文數字_,長度3-30', simpleName: '支持非底線開頭英文數字_,長度3-30',
simplePassword: '支持非底線開頭英文數字_,長度6-30', simplePassword: '支持非底線開頭英文數字_,長度1-30',
dbName: '支持非特殊字符開頭英文中文數字.-_長度1-64', dbName: '支持非特殊字符開頭英文中文數字.-_長度1-64',
imageName: '支持英文數字:/.-_,長度1-150', imageName: '支持英文數字:/.-_,長度1-150',
volumeName: '支持英文數字.-和_,長度2-30', volumeName: '支持英文數字.-和_,長度2-30',
@ -1205,7 +1205,7 @@ const message = {
sessionTimeoutError: '最小超時時間為 300 ', sessionTimeoutError: '最小超時時間為 300 ',
sessionTimeoutHelper: '如果用戶超過 {0} 秒未操作面板面板將自動退出登錄', sessionTimeoutHelper: '如果用戶超過 {0} 秒未操作面板面板將自動退出登錄',
systemIP: '伺服器地址', systemIP: '伺服器地址',
proxy: '伺服器代理', proxy: '代理伺服器',
proxyHelper: '設置代理伺服器後將在以下場景中生效', proxyHelper: '設置代理伺服器後將在以下場景中生效',
proxyHelper1: '應用商店的安裝包下載和同步', proxyHelper1: '應用商店的安裝包下載和同步',
proxyHelper2: '系統版本升級及獲取更新說明', proxyHelper2: '系統版本升級及獲取更新說明',

4
frontend/src/lang/modules/zh.ts

@ -171,7 +171,7 @@ const message = {
commonName: '支持非特殊字符开头,英文中文数字.-和_,长度1-128', commonName: '支持非特殊字符开头,英文中文数字.-和_,长度1-128',
userName: '支持英文中文数字和_,长度3-30', userName: '支持英文中文数字和_,长度3-30',
simpleName: '支持非下划线开头英文数字_,长度3-30', simpleName: '支持非下划线开头英文数字_,长度3-30',
simplePassword: '支持非下划线开头英文数字_,长度6-30', simplePassword: '支持非下划线开头英文数字_,长度1-30',
dbName: '支持非特殊字符开头英文中文数字.-_,长度1-64', dbName: '支持非特殊字符开头英文中文数字.-_,长度1-64',
imageName: '支持英文数字:/.-_,长度1-150', imageName: '支持英文数字:/.-_,长度1-150',
volumeName: '支持英文数字.-和_,长度2-30', volumeName: '支持英文数字.-和_,长度2-30',
@ -1206,7 +1206,7 @@ const message = {
sessionTimeoutError: '最小超时时间为 300 ', sessionTimeoutError: '最小超时时间为 300 ',
sessionTimeoutHelper: '如果用户超过 {0} 秒未操作面板面板将自动退出登录', sessionTimeoutHelper: '如果用户超过 {0} 秒未操作面板面板将自动退出登录',
systemIP: '服务器地址', systemIP: '服务器地址',
proxy: '服务器代理', proxy: '代理服务器',
proxyHelper: '设置代理服务器后将在以下场景中生效', proxyHelper: '设置代理服务器后将在以下场景中生效',
proxyHelper1: '应用商店的安装包下载和同步', proxyHelper1: '应用商店的安装包下载和同步',
proxyHelper2: '系统版本升级及获取更新说明', proxyHelper2: '系统版本升级及获取更新说明',

7
frontend/src/views/container/image/pull/index.vue

@ -92,6 +92,13 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
form.fromRepo = true; form.fromRepo = true;
form.imageName = ''; form.imageName = '';
repos.value = params.repos; repos.value = params.repos;
form.repoID = 1;
for (const item of repos.value) {
if (item.name === 'Docker Hub' && item.downloadUrl === 'docker.io') {
form.repoID = item.id;
break;
}
}
buttonDisabled.value = false; buttonDisabled.value = false;
logInfo.value = ''; logInfo.value = '';
showLog.value = false; showLog.value = false;

45
frontend/src/views/database/redis/command/index.vue

@ -21,22 +21,46 @@
<el-table-column type="selection" fix /> <el-table-column type="selection" fix />
<el-table-column :label="$t('commons.table.name')" min-width="50"> <el-table-column :label="$t('commons.table.name')" min-width="50">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-if="row.isOn" v-model="row.name" /> <el-input v-if="row.lineStatus === 'create' || row.lineStatus === 'edit'" v-model="row.name" />
<span v-else>{{ row.name }}</span> <span v-else>{{ row.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('terminal.quickCommand')" min-width="120"> <el-table-column :label="$t('terminal.quickCommand')" min-width="120">
<template #default="{ row }"> <template #default="{ row }">
<el-input v-if="row.isOn" v-model="row.command" /> <el-input
<span v-else>{{ row.name }}</span> v-if="row.lineStatus === 'create' || row.lineStatus === 'edit'"
v-model="row.command"
/>
<span v-else>{{ row.command }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column min-width="40"> <el-table-column min-width="40">
<template #default="scope"> <template #default="scope">
<el-button link type="primary" @click="handleCmdCreate(scope.row)"> <el-button
v-if="scope.row.lineStatus === 'create'"
link
type="primary"
@click="handleCmdSave(scope.row)"
>
{{ $t('commons.button.save') }} {{ $t('commons.button.save') }}
</el-button> </el-button>
<el-button link type="primary" @click="handleCmdDelete(scope.$index)"> <el-button
v-if="!scope.row.lineStatus || scope.row.lineStatus === 'saved'"
link
type="primary"
@click="scope.row.lineStatus = 'create'"
>
{{ $t('commons.button.edit') }}
</el-button>
<el-button v-if="scope.row.lineStatus === 'create'" link type="primary" @click="search()">
{{ $t('commons.button.cancel') }}
</el-button>
<el-button
v-if="scope.row.lineStatus !== 'create'"
link
type="primary"
@click="handleCmdDelete(scope.$index)"
>
{{ $t('commons.button.delete') }} {{ $t('commons.button.delete') }}
</el-button> </el-button>
</template> </template>
@ -55,7 +79,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Command } from '@/api/interface/command'; import { Command } from '@/api/interface/command';
import { addRedisCommand, deleteRedisCommand, getRedisCommandPage } from '@/api/modules/host'; import { saveRedisCommand, deleteRedisCommand, getRedisCommandPage } from '@/api/modules/host';
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
import i18n from '@/lang'; import i18n from '@/lang';
import DrawerHeader from '@/components/drawer-header/index.vue'; import DrawerHeader from '@/components/drawer-header/index.vue';
@ -87,21 +111,20 @@ const handleCmdAdd = () => {
let item = { let item = {
name: '', name: '',
command: '', command: '',
isOn: true, lineStatus: 'create',
}; };
data.value.push(item); data.value.push(item);
}; };
const handleCmdDelete = (index: number) => { const handleCmdDelete = (index: number) => {
batchDelete(data.value[index]); batchDelete(data.value[index]);
data.value.splice(index, 1);
}; };
const handleCmdCreate = async (row: any) => { const handleCmdSave = async (row: any) => {
loading.value = true; loading.value = true;
await addRedisCommand(row) await saveRedisCommand(row)
.then(() => { .then(() => {
loading.value = false; loading.value = false;
row.isOn = false; row.lineStatus = 'saved';
MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
search(); search();
}) })

41
frontend/src/views/database/redis/index.vue

@ -51,20 +51,19 @@
</el-option-group> </el-option-group>
</el-select> </el-select>
</template> </template>
<template #toolbar v-if="!isOnSetting && redisIsExist"> <template #toolbar v-if="!isOnSetting && currentDB">
<div :class="{ mask: redisStatus != 'Running' }"> <div :class="{ mask: redisStatus != 'Running' && currentDB.from === 'local' }">
<el-button type="primary" plain @click="onChangePassword"> <el-button type="primary" plain @click="onChangePassword">
{{ $t('database.databaseConnInfo') }} {{ $t('database.databaseConnInfo') }}
</el-button> </el-button>
<el-button @click="goRemoteDB" type="primary" plain> <el-button @click="goRemoteDB" type="primary" plain>
{{ $t('database.remoteDB') }} {{ $t('database.remoteDB') }}
</el-button> </el-button>
<el-button type="primary" plain @click="goDashboard" icon="Position">Redis-Commander</el-button>
</div> </div>
</template> </template>
</LayoutContent> </LayoutContent>
<div v-if="redisIsExist && !isOnSetting" class="mt-5"> <div v-if="currentDB && !isOnSetting" class="mt-5">
<Terminal <Terminal
:style="{ height: `calc(100vh - ${loadHeight()})` }" :style="{ height: `calc(100vh - ${loadHeight()})` }"
:key="isRefresh" :key="isRefresh"
@ -75,7 +74,7 @@
v-if="redisStatus !== 'Running' || (currentDB.from === 'remote' && !redisCliExist)" v-if="redisStatus !== 'Running' || (currentDB.from === 'remote' && !redisCliExist)"
:style="{ height: `calc(100vh - ${loadHeight()})`, 'background-color': '#000' }" :style="{ height: `calc(100vh - ${loadHeight()})`, 'background-color': '#000' }"
:description=" :description="
currentDB.from !== 'remote' currentDB.from === 'remote'
? $t('commons.service.serviceNotStarted', ['Redis']) ? $t('commons.service.serviceNotStarted', ['Redis'])
: $t('database.redisCliHelper') : $t('database.redisCliHelper')
" "
@ -116,7 +115,6 @@
</template> </template>
</el-dialog> </el-dialog>
<PortJumpDialog ref="dialogPortJumpRef" />
<QuickCmd ref="dialogQuickCmdRef" @reload="loadQuickCmd" /> <QuickCmd ref="dialogQuickCmdRef" @reload="loadQuickCmd" />
</div> </div>
</template> </template>
@ -126,10 +124,9 @@ import Setting from '@/views/database/redis/setting/index.vue';
import Password from '@/views/database/redis/password/index.vue'; import Password from '@/views/database/redis/password/index.vue';
import Terminal from '@/components/terminal/index.vue'; import Terminal from '@/components/terminal/index.vue';
import AppStatus from '@/components/app-status/index.vue'; import AppStatus from '@/components/app-status/index.vue';
import PortJumpDialog from '@/components/port-jump/index.vue';
import QuickCmd from '@/views/database/redis/command/index.vue'; import QuickCmd from '@/views/database/redis/command/index.vue';
import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue'; import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
import { CheckAppInstalled, GetAppPort } from '@/api/modules/app'; import { CheckAppInstalled } from '@/api/modules/app';
import router from '@/routers'; import router from '@/routers';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import { listDatabases, checkRedisCli, installRedisCli } from '@/api/modules/database'; import { listDatabases, checkRedisCli, installRedisCli } from '@/api/modules/database';
@ -149,7 +146,6 @@ const redisIsExist = ref(false);
const redisStatus = ref(); const redisStatus = ref();
const terminalShow = ref(false); const terminalShow = ref(false);
const redisCommandPort = ref();
const commandVisible = ref(false); const commandVisible = ref(false);
const redisCliExist = ref(); const redisCliExist = ref();
@ -165,8 +161,6 @@ const quickCmd = ref();
const quickCmdList = ref([]); const quickCmdList = ref([]);
const dialogQuickCmdRef = ref(); const dialogQuickCmdRef = ref();
const dialogPortJumpRef = ref();
const isRefresh = ref(); const isRefresh = ref();
const onSetting = async () => { const onSetting = async () => {
@ -180,13 +174,6 @@ const loadHeight = () => {
return globalStore.openMenuTabs ? '470px' : '380px'; return globalStore.openMenuTabs ? '470px' : '380px';
}; };
const goDashboard = async () => {
if (redisCommandPort.value === 0) {
commandVisible.value = true;
return;
}
dialogPortJumpRef.value.acceptParams({ port: redisCommandPort.value });
};
const getAppDetail = (key: string) => { const getAppDetail = (key: string) => {
router.push({ name: 'AppAll', query: { install: key } }); router.push({ name: 'AppAll', query: { install: key } });
}; };
@ -197,11 +184,6 @@ const goRemoteDB = async () => {
router.push({ name: 'Redis-Remote' }); router.push({ name: 'Redis-Remote' });
}; };
const loadDashboardPort = async () => {
const res = await GetAppPort('redis-commander', '');
redisCommandPort.value = res.data;
};
const passwordRef = ref(); const passwordRef = ref();
const onChangePassword = async () => { const onChangePassword = async () => {
passwordRef.value!.acceptParams({ database: currentDBName.value }); passwordRef.value!.acceptParams({ database: currentDBName.value });
@ -331,8 +313,14 @@ const closeTerminal = async (isKeepShow: boolean) => {
}; };
const checkCliValid = async () => { const checkCliValid = async () => {
const res = await checkRedisCli(); await checkRedisCli()
redisCliExist.value = res.data; .then((res) => {
redisCliExist.value = res.data;
loadDBOptions();
})
.catch(() => {
loadDBOptions();
});
}; };
const installCli = async () => { const installCli = async () => {
loading.value = true; loading.value = true;
@ -341,6 +329,7 @@ const installCli = async () => {
loading.value = false; loading.value = false;
redisCliExist.value = true; redisCliExist.value = true;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
reOpenTerminal();
}) })
.catch(() => { .catch(() => {
loading.value = false; loading.value = false;
@ -363,9 +352,7 @@ const onSetQuickCmd = () => {
}; };
onMounted(() => { onMounted(() => {
loadDBOptions();
loadQuickCmd(); loadQuickCmd();
loadDashboardPort();
checkCliValid(); checkCliValid();
}); });
const onBefore = () => { const onBefore = () => {

2
frontend/src/views/database/redis/remote/operate/index.vue

@ -95,7 +95,7 @@ const acceptParams = (params: DialogProps): void => {
dialogData.value.rowData.version = '6.x'; dialogData.value.rowData.version = '6.x';
} }
if (dialogData.value.rowData.version.startsWith('7.')) { if (dialogData.value.rowData.version.startsWith('7.')) {
dialogData.value.rowData.version = '7,x'; dialogData.value.rowData.version = '7.x';
} }
title.value = i18n.global.t('database.' + dialogData.value.title + 'RemoteDB'); title.value = i18n.global.t('database.' + dialogData.value.title + 'RemoteDB');
drawerVisible.value = true; drawerVisible.value = true;

11
frontend/src/views/toolbox/ftp/index.vue

@ -128,13 +128,6 @@
prop="description" prop="description"
show-overflow-tooltip show-overflow-tooltip
/> />
<el-table-column
:label="$t('commons.table.createdAt')"
show-overflow-tooltip
:formatter="dateFormat"
:min-width="80"
prop="createdAt"
/>
<fu-table-operations <fu-table-operations
width="200px" width="200px"
:buttons="buttons" :buttons="buttons"
@ -174,7 +167,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import i18n from '@/lang'; import i18n from '@/lang';
import { dateFormat } from '@/utils/util';
import { MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
import { deleteFtp, searchFtp, updateFtp, syncFtp, operateFtp, getFtpBase } from '@/api/modules/toolbox'; import { deleteFtp, searchFtp, updateFtp, syncFtp, operateFtp, getFtpBase } from '@/api/modules/toolbox';
import OperateDialog from '@/views/toolbox/ftp/operate/index.vue'; import OperateDialog from '@/views/toolbox/ftp/operate/index.vue';
@ -363,9 +355,6 @@ const buttons = [
}, },
{ {
label: i18n.global.t('commons.button.delete'), label: i18n.global.t('commons.button.delete'),
disabled: (row: Toolbox.FtpInfo) => {
return row.status === 'deleted';
},
click: (row: Toolbox.FtpInfo) => { click: (row: Toolbox.FtpInfo) => {
onDelete(row); onDelete(row);
}, },

2
frontend/src/views/toolbox/ftp/log/index.vue

@ -10,7 +10,7 @@
<DrawerHeader header="FTP" :resource="paginationConfig.user" :back="handleClose" /> <DrawerHeader header="FTP" :resource="paginationConfig.user" :back="handleClose" />
</template> </template>
<el-select @change="search" class="p-w-200" clearable v-model="paginationConfig.operation"> <el-select @change="search" class="p-w-200" clearable v-model="paginationConfig.operation">
<template #prefix>{{ $t('container.lines') }}</template> <template #prefix>{{ $t('commons.table.operate') }}</template>
<el-option value="PUT" :label="$t('file.upload')" /> <el-option value="PUT" :label="$t('file.upload')" />
<el-option value="GET" :label="$t('file.download')" /> <el-option value="GET" :label="$t('file.download')" />
</el-select> </el-select>

2
frontend/src/views/toolbox/ftp/operate/index.vue

@ -111,8 +111,8 @@ const onSubmit = async (formEl: FormInstance | undefined) => {
if (!formEl) return; if (!formEl) return;
formEl.validate(async (valid) => { formEl.validate(async (valid) => {
if (!valid) return; if (!valid) return;
loading.value = true;
if (dialogData.value.title === 'edit') { if (dialogData.value.title === 'edit') {
loading.value = true;
await updateFtp(dialogData.value.rowData) await updateFtp(dialogData.value.rowData)
.then(() => { .then(() => {
loading.value = false; loading.value = false;

Loading…
Cancel
Save