管理端全部功能跑通
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package clusters
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/httpdns/httpdnsutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type CreateNodeAction struct {
|
||||
@@ -13,13 +16,18 @@ func (this *CreateNodeAction) Init() {
|
||||
this.Nav("httpdns", "cluster", "createNode")
|
||||
}
|
||||
|
||||
func (this *CreateNodeAction) RunGet(params struct{ ClusterId int64 }) {
|
||||
func (this *CreateNodeAction) RunGet(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
httpdnsutils.AddLeftMenu(this.Parent())
|
||||
cluster := pickCluster(params.ClusterId)
|
||||
|
||||
// 构建顶部 tabbar
|
||||
cluster, err := findClusterMap(this.Parent(), params.ClusterId)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
httpdnsutils.AddClusterTabbar(this.Parent(), cluster.GetString("name"), params.ClusterId, "node")
|
||||
|
||||
this.Data["clusterId"] = params.ClusterId
|
||||
this.Data["cluster"] = cluster
|
||||
this.Show()
|
||||
@@ -28,6 +36,28 @@ func (this *CreateNodeAction) RunGet(params struct{ ClusterId int64 }) {
|
||||
func (this *CreateNodeAction) RunPost(params struct {
|
||||
ClusterId int64
|
||||
Name string
|
||||
InstallDir string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
params.Name = strings.TrimSpace(params.Name)
|
||||
params.InstallDir = strings.TrimSpace(params.InstallDir)
|
||||
params.Must.Field("clusterId", params.ClusterId).Gt(0, "请选择集群")
|
||||
params.Must.Field("name", params.Name).Require("请输入节点名称")
|
||||
|
||||
if len(params.InstallDir) == 0 {
|
||||
cluster, err := findClusterMap(this.Parent(), params.ClusterId)
|
||||
if err == nil {
|
||||
params.InstallDir = strings.TrimSpace(cluster.GetString("installDir"))
|
||||
}
|
||||
if len(params.InstallDir) == 0 {
|
||||
params.InstallDir = "/opt/edge-httpdns"
|
||||
}
|
||||
}
|
||||
|
||||
if err := createNode(this.Parent(), params.ClusterId, params.Name, params.InstallDir); err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user