mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-24 02:10:28 +08:00
增加API节点安装配置界面
This commit is contained in:
58
internal/web/actions/default/api/node/install.go
Normal file
58
internal/web/actions/default/api/node/install.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
type InstallAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *InstallAction) Init() {
|
||||
this.Nav("", "", "install")
|
||||
}
|
||||
|
||||
func (this *InstallAction) RunGet(params struct {
|
||||
NodeId int64
|
||||
}) {
|
||||
// API节点信息
|
||||
nodeResp, err := this.RPC().APINodeRPC().FindEnabledAPINode(this.AdminContext(), &pb.FindEnabledAPINodeRequest{NodeId: params.NodeId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
node := nodeResp.Node
|
||||
if node == nil {
|
||||
this.NotFound("apiNode", params.NodeId)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["node"] = maps.Map{
|
||||
"id": node.Id,
|
||||
"name": node.Name,
|
||||
"uniqueId": node.UniqueId,
|
||||
"secret": node.Secret,
|
||||
}
|
||||
|
||||
// 数据库配置
|
||||
dbConfigMap := maps.Map{
|
||||
"config": "",
|
||||
"error": "",
|
||||
"isNotFound": false,
|
||||
}
|
||||
dbConfigFile := Tea.ConfigFile("api_db.yaml")
|
||||
data, err := ioutil.ReadFile(dbConfigFile)
|
||||
dbConfigMap["config"] = string(data)
|
||||
if err != nil {
|
||||
dbConfigMap["error"] = err.Error()
|
||||
dbConfigMap["isNotFound"] = os.IsNotExist(err)
|
||||
}
|
||||
this.Data["dbConfig"] = dbConfigMap
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user