mirror of
https://gitee.com/fit2cloud-feizhiyun/1Panel.git
synced 2024-12-04 21:09:31 +08:00
fix: 增加数据库密码回显
This commit is contained in:
parent
8bbc286f43
commit
0e6846a266
@ -2,9 +2,10 @@ package v1
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"reflect"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/backend/constant"
|
||||
@ -68,6 +69,20 @@ func (b *BaseApi) LoadPort(c *gin.Context) {
|
||||
helper.SuccessWithData(c, port)
|
||||
}
|
||||
|
||||
func (b *BaseApi) LoadPassword(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
|
||||
}
|
||||
password, err := appInstallService.LoadPassword(key)
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
helper.SuccessWithData(c, password)
|
||||
}
|
||||
|
||||
func (b *BaseApi) DeleteCheck(c *gin.Context) {
|
||||
appInstallId, err := helper.GetIntParamByKey(c, "appInstallId")
|
||||
if err != nil {
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
@ -13,6 +11,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/request"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto/response"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/app/dto"
|
||||
@ -88,6 +89,14 @@ func (a AppInstallService) LoadPort(key string) (int64, error) {
|
||||
return app.Port, nil
|
||||
}
|
||||
|
||||
func (a AppInstallService) LoadPassword(key string) (string, error) {
|
||||
app, err := appInstallRepo.LoadBaseInfoByKey(key)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
return app.Password, nil
|
||||
}
|
||||
|
||||
func (a AppInstallService) Search(req request.AppInstalledSearch) ([]response.AppInstalledDTO, error) {
|
||||
var installs []model.AppInstall
|
||||
var err error
|
||||
|
@ -23,6 +23,7 @@ func (a *AppRouter) InitAppRouter(Router *gin.RouterGroup) {
|
||||
appRouter.GET("/installed/:appInstallId/versions", baseApi.GetUpdateVersions)
|
||||
appRouter.GET("/installed/check/:key", baseApi.CheckAppInstalled)
|
||||
appRouter.GET("/installed/loadport/:key", baseApi.LoadPort)
|
||||
appRouter.GET("/installed/loadpassword/:key", baseApi.LoadPassword)
|
||||
appRouter.GET("/installed/delete/check/:appInstallId", baseApi.DeleteCheck)
|
||||
appRouter.POST("/installed", baseApi.SearchAppInstalled)
|
||||
appRouter.POST("/installed/op", baseApi.OperateInstalled)
|
||||
|
@ -34,6 +34,10 @@ export const GetAppPort = (key: string) => {
|
||||
return http.get<number>(`apps/installed/loadport/${key}`);
|
||||
};
|
||||
|
||||
export const GetAppPassword = (key: string) => {
|
||||
return http.get<string>(`apps/installed/loadpassword/${key}`);
|
||||
};
|
||||
|
||||
export const CheckAppInstalled = (key: string) => {
|
||||
return http.get<App.CheckInstalled>(`apps/installed/check/${key}`);
|
||||
};
|
||||
|
@ -15,8 +15,10 @@
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisiable = false">{{ $t('commons.button.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="onSave(formRef)">
|
||||
<el-button :disabled="loading" @click="dialogVisiable = false">
|
||||
{{ $t('commons.button.cancel') }}
|
||||
</el-button>
|
||||
<el-button :disabled="loading" type="primary" @click="onSave(formRef)">
|
||||
{{ $t('commons.button.confirm') }}
|
||||
</el-button>
|
||||
</span>
|
||||
@ -31,6 +33,7 @@ import i18n from '@/lang';
|
||||
import { ElForm, ElMessage } from 'element-plus';
|
||||
import { updateMysqlPassword } from '@/api/modules/database';
|
||||
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
|
||||
import { GetAppPassword } from '@/api/modules/app';
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
@ -46,9 +49,15 @@ const formRef = ref<FormInstance>();
|
||||
|
||||
const acceptParams = (): void => {
|
||||
form.password = '';
|
||||
loadPassword();
|
||||
dialogVisiable.value = true;
|
||||
};
|
||||
|
||||
const loadPassword = async () => {
|
||||
const res = await GetAppPassword('mysql');
|
||||
form.password = res.data;
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
let param = {
|
||||
id: 0,
|
||||
|
@ -15,8 +15,10 @@
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisiable = false">{{ $t('commons.button.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="onSave(formRef)">
|
||||
<el-button :disabled="loading" @click="dialogVisiable = false">
|
||||
{{ $t('commons.button.cancel') }}
|
||||
</el-button>
|
||||
<el-button :disabled="loading" type="primary" @click="onSave(formRef)">
|
||||
{{ $t('commons.button.confirm') }}
|
||||
</el-button>
|
||||
</span>
|
||||
@ -31,6 +33,7 @@ import i18n from '@/lang';
|
||||
import { ElForm, ElMessage } from 'element-plus';
|
||||
import { changeRedisPassword } from '@/api/modules/database';
|
||||
import ConfirmDialog from '@/components/confirm-dialog/index.vue';
|
||||
import { GetAppPassword } from '@/api/modules/app';
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
@ -48,9 +51,15 @@ const formRef = ref<FormInstance>();
|
||||
|
||||
const acceptParams = (): void => {
|
||||
form.password = '';
|
||||
loadPassword();
|
||||
dialogVisiable.value = true;
|
||||
};
|
||||
|
||||
const loadPassword = async () => {
|
||||
const res = await GetAppPassword('redis');
|
||||
form.password = res.data;
|
||||
};
|
||||
|
||||
const onSubmit = async () => {
|
||||
let param = {
|
||||
id: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user