diff --git a/backend/app/api/v1/app_install.go b/backend/app/api/v1/app_install.go index 3ea662736..334d378e0 100644 --- a/backend/app/api/v1/app_install.go +++ b/backend/app/api/v1/app_install.go @@ -53,6 +53,20 @@ func (b *BaseApi) CheckAppInstalled(c *gin.Context) { helper.SuccessWithData(c, checkData) } +func (b *BaseApi) LoadPort(c *gin.Context) { + key, ok := c.Params.Get("key") + if !ok { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, errors.New("error key in path")) + return + } + port, err := appInstallService.LoadPort(key) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, port) +} + func (b *BaseApi) DeleteCheck(c *gin.Context) { appInstallId, err := helper.GetIntParamByKey(c, "appInstallId") diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index 5088e5ab8..23e58c2da 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -79,6 +79,14 @@ func (a AppInstallService) CheckExist(key string) (*dto.CheckInstalled, error) { return res, nil } +func (a AppInstallService) LoadPort(key string) (int64, error) { + app, err := appInstallRepo.LoadBaseInfoByKey(key) + if err != nil { + return int64(0), nil + } + return app.Port, nil +} + func (a AppInstallService) Search(req dto.AppInstalledRequest) ([]dto.AppInstalled, error) { var installs []model.AppInstall var err error diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index cb5bc4134..e7dac3885 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -240,7 +240,7 @@ func (u *MysqlService) DeleteCheck(id uint) ([]string, error) { apps, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithResourceId(app.ID), appInstallResourceRepo.WithLinkId(db.ID)) for _, app := range apps { - appInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(app.ID)) + appInstall, _ := appInstallRepo.GetFirst(commonRepo.WithByID(app.AppInstallId)) if appInstall.ID != 0 { appInUsed = append(appInUsed, appInstall.Name) } diff --git a/backend/router/ro_app.go b/backend/router/ro_app.go index d45b27c2c..fce5320db 100644 --- a/backend/router/ro_app.go +++ b/backend/router/ro_app.go @@ -22,6 +22,7 @@ func (a *AppRouter) InitAppRouter(Router *gin.RouterGroup) { appRouter.POST("/install", baseApi.InstallApp) appRouter.GET("/installed/:appInstallId/versions", baseApi.GetUpdateVersions) appRouter.GET("/installed/check/:key", baseApi.CheckAppInstalled) + appRouter.GET("/installed/loadport/:key", baseApi.LoadPort) appRouter.GET("/installed/delete/check/:appInstallId", baseApi.DeleteCheck) appRouter.POST("/installed", baseApi.SearchAppInstalled) appRouter.POST("/installed/op", baseApi.OperateInstalled) diff --git a/frontend/src/api/modules/app.ts b/frontend/src/api/modules/app.ts index d4c44ec68..3ee69ae07 100644 --- a/frontend/src/api/modules/app.ts +++ b/frontend/src/api/modules/app.ts @@ -30,6 +30,10 @@ export const SearchAppInstalled = (search: App.AppInstallSearch) => { return http.post>('apps/installed', search); }; +export const GetAppPort = (key: string) => { + return http.get(`apps/installed/loadport/${key}`); +}; + export const CheckAppInstalled = (key: string) => { return http.get(`apps/installed/check/${key}`); }; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 89d075f54..9d52e1a7b 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -184,7 +184,7 @@ export default { jsInfo: 'The popular Open source fortress machine', msInfo: 'One-stop open source continuous testing platform', koInfo: 'Open source lightweight Kubernetes distribution', - kubepiInfo: 'Modern open source K8s panel', + kubepiInfo: 'Modern open source Kubernetes panel', goInstall: 'Go install', }, tabs: { @@ -276,6 +276,9 @@ export default { maxConnectionsHelper: 'Max connections', restart: 'Restart', + log: 'Logs', + slowLog: 'Slowlogs', + isOn: 'Is on', longQueryTime: 'Slow query threshold', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index b4ea2367d..7cbe0a55b 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -190,7 +190,7 @@ export default { jsInfo: '广受欢迎的开源堡垒机', msInfo: '一站式开源持续测试平台', koInfo: '开源的轻量级 Kubernetes 发行版', - kubepiInfo: '现代化的开源 K8s 面板', + kubepiInfo: '现代化的开源 Kubernetes 面板', goInstall: '去安装', }, tabs: { @@ -279,6 +279,9 @@ export default { maxConnectionsHelper: '最大连接数', restart: '重启数据库', + log: '日志', + slowLog: '慢日志', + isOn: '是否开启', longQueryTime: '慢查询阈值', @@ -751,7 +754,7 @@ export default { gotoInstalled: '去安装', search: '搜索', limitHelper: '该应用已安装,不支持重复安装', - deleteHelper: '应用已经关联以下资源,无法删除', + deleteHelper: '{0}已经关联以下资源,无法删除', checkTitle: '提示', website: '网站', database: '数据库', diff --git a/frontend/src/views/app-store/installed/check/index.vue b/frontend/src/views/app-store/installed/check/index.vue index 4dcc172c7..5467bdb86 100644 --- a/frontend/src/views/app-store/installed/check/index.vue +++ b/frontend/src/views/app-store/installed/check/index.vue @@ -7,7 +7,13 @@ :destroy-on-close="true" > - +
diff --git a/frontend/src/views/database/mysql/check/index.vue b/frontend/src/views/database/mysql/check/index.vue index 1036add89..0e5232144 100644 --- a/frontend/src/views/database/mysql/check/index.vue +++ b/frontend/src/views/database/mysql/check/index.vue @@ -7,7 +7,13 @@ :destroy-on-close="true" > - +
diff --git a/frontend/src/views/database/mysql/index.vue b/frontend/src/views/database/mysql/index.vue index b400878c7..a99521f47 100644 --- a/frontend/src/views/database/mysql/index.vue +++ b/frontend/src/views/database/mysql/index.vue @@ -16,7 +16,7 @@ {{ $t('commons.button.create') }} - phpMyAdmin + phpMyAdmin @@ -132,12 +132,14 @@ import { ElForm, ElMessage } from 'element-plus'; import { Database } from '@/api/interface/database'; import { Rules } from '@/global/form-rules'; import { App } from '@/api/interface/app'; +import { GetAppPort } from '@/api/modules/app'; const selects = ref([]); const mysqlName = ref(); const isOnSetting = ref(); const checkRef = ref(); +const phpadminPort = ref(); const data = ref(); const paginationConfig = reactive({ @@ -212,11 +214,21 @@ const search = async () => { paginationConfig.total = res.data.total; }; +const goDashboard = async () => { + window.open('http://localhost:' + phpadminPort.value, '_blank'); +}; + +const loadDashboardPort = async () => { + const res = await GetAppPort('phpmyadmin'); + phpadminPort.value = res.data; +}; + const checkExist = (data: App.CheckInstalled) => { mysqlIsExist.value = data.isExist; mysqlName.value = data.name; if (mysqlIsExist.value) { search(); + loadDashboardPort(); } }; diff --git a/frontend/src/views/database/mysql/setting/index.vue b/frontend/src/views/database/mysql/setting/index.vue index 6c62d0248..fd858d736 100644 --- a/frontend/src/views/database/mysql/setting/index.vue +++ b/frontend/src/views/database/mysql/setting/index.vue @@ -66,7 +66,7 @@ v-model="mysqlConf" :readOnly="true" /> - + {{ $t('commons.button.save') }} @@ -76,11 +76,11 @@ - + - + diff --git a/frontend/src/views/database/mysql/setting/variables/index.vue b/frontend/src/views/database/mysql/setting/variables/index.vue index 61f3602fd..06232a76b 100644 --- a/frontend/src/views/database/mysql/setting/variables/index.vue +++ b/frontend/src/views/database/mysql/setting/variables/index.vue @@ -64,17 +64,9 @@ - + {{ $t('commons.button.save') }} - - {{ $t('database.restart') }} -

@@ -285,7 +277,7 @@ const onSaveVariables = async () => { if (oldVariables.value?.max_connections !== mysqlVariables.max_connections) { param.push({ param: 'max_connections', value: mysqlVariables.max_connections }); } - await updateMysqlVariables(mysqlName.value, param); + await updateMysqlVariables(param); ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); }; diff --git a/frontend/src/views/database/redis/index.vue b/frontend/src/views/database/redis/index.vue index fe10a6c10..a3ff96a9c 100644 --- a/frontend/src/views/database/redis/index.vue +++ b/frontend/src/views/database/redis/index.vue @@ -6,7 +6,8 @@
- + Redis-Command +
@@ -18,21 +19,34 @@ import Terminal from '@/views/database/redis/terminal/index.vue'; import AppStatus from '@/components/app-status/index.vue'; import { ref } from 'vue'; import { App } from '@/api/interface/app'; +import { GetAppPort } from '@/api/modules/app'; const terminalRef = ref(); const settingRef = ref(); const isOnSetting = ref(false); const redisIsExist = ref(false); +const redisCommandPort = ref(); + const onSetting = async () => { isOnSetting.value = true; terminalRef.value.onClose(); settingRef.value!.acceptParams(); }; +const goDashboard = async () => { + window.open('http://localhost:' + redisCommandPort.value, '_blank'); +}; + +const loadDashboardPort = async () => { + const res = await GetAppPort('phpmyadmin'); + redisCommandPort.value = res.data; +}; + const checkExist = (data: App.CheckInstalled) => { redisIsExist.value = data.isExist; if (redisIsExist.value) { + loadDashboardPort(); terminalRef.value.acceptParams(); } }; diff --git a/frontend/src/views/database/redis/setting/index.vue b/frontend/src/views/database/redis/setting/index.vue index cc1a31d90..9c22e13b0 100644 --- a/frontend/src/views/database/redis/setting/index.vue +++ b/frontend/src/views/database/redis/setting/index.vue @@ -1,7 +1,7 @@ @@ -114,6 +110,8 @@ import { ChangePort } from '@/api/modules/app'; const extensions = [javascript(), oneDark]; const confShowType = ref('base'); +const loading = ref(false); + const form = reactive({ name: '', port: 6379, @@ -136,6 +134,7 @@ const persistenceRef = ref(); const formRef = ref(); const mysqlConf = ref(); const confirmDialogRef = ref(); +const confirmDialogRef2 = ref(); const settingShow = ref(false); @@ -149,6 +148,15 @@ const onClose = (): void => { settingShow.value = false; }; +const onSavePort = async () => { + let params = { + header: i18n.global.t('database.confChange'), + operationInfo: i18n.global.t('database.restartNowHelper1'), + submitInputInfo: i18n.global.t('database.restartNow'), + }; + confirmDialogRef2.value!.acceptParams(params); +}; + const onChangePort = async (formEl: FormInstance | undefined) => { if (!formEl) return; const result = await formEl.validateField('port', callback); @@ -160,9 +168,15 @@ const onChangePort = async (formEl: FormInstance | undefined) => { name: form.name, port: form.port, }; - await ChangePort(params); - ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); - return; + loading.value = true; + await ChangePort(params) + .then(() => { + loading.value = false; + ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); + }) + .finally(() => { + loading.value = false; + }); }; function callback(error: any) { if (error) { @@ -193,9 +207,16 @@ const onSave = async (formEl: FormInstance | undefined) => { requirepass: form.requirepass, maxmemory: form.maxmemory + '', }; - await updateRedisConf(param); - loadform(); - ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); + loading.value = true; + await updateRedisConf(param) + .then(() => { + loadform(); + loading.value = false; + ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); + }) + .finally(() => { + loading.value = false; + }); }); }; diff --git a/frontend/src/views/database/redis/terminal/index.vue b/frontend/src/views/database/redis/terminal/index.vue index d82ba50db..d6da4cdea 100644 --- a/frontend/src/views/database/redis/terminal/index.vue +++ b/frontend/src/views/database/redis/terminal/index.vue @@ -1,7 +1,7 @@