mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 00:20:26 +08:00
集群列表页也增加“创建节点”链接
This commit is contained in:
@@ -30,6 +30,11 @@ func (this *CreateNodeAction) Init() {
|
|||||||
func (this *CreateNodeAction) RunGet(params struct {
|
func (this *CreateNodeAction) RunGet(params struct {
|
||||||
ClusterId int64
|
ClusterId int64
|
||||||
}) {
|
}) {
|
||||||
|
if params.ClusterId <= 0 {
|
||||||
|
this.RedirectURL("/clusters")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var leftMenuItems = []maps.Map{
|
var leftMenuItems = []maps.Map{
|
||||||
{
|
{
|
||||||
"name": "单个创建",
|
"name": "单个创建",
|
||||||
|
|||||||
52
internal/web/actions/default/clusters/createNode.go
Normal file
52
internal/web/actions/default/clusters/createNode.go
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||||
|
|
||||||
|
package clusters
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/iwind/TeaGo/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateNodeAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CreateNodeAction) Init() {
|
||||||
|
this.Nav("", "cluster", "createNode")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CreateNodeAction) RunGet(params struct{}) {
|
||||||
|
// 集群总数
|
||||||
|
totalClustersResp, err := this.RPC().NodeClusterRPC().CountAllEnabledNodeClusters(this.AdminContext(), &pb.CountAllEnabledNodeClustersRequest{})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.Data["totalNodeClusters"] = totalClustersResp.Count
|
||||||
|
|
||||||
|
// 节点总数
|
||||||
|
totalNodesResp, err := this.RPC().NodeRPC().CountAllEnabledNodes(this.AdminContext(), &pb.CountAllEnabledNodesRequest{})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.Data["totalNodes"] = totalNodesResp.Count
|
||||||
|
|
||||||
|
// 如果只有一个默认集群,那么直接跳转到集群
|
||||||
|
clustersResp, err := this.RPC().NodeClusterRPC().ListEnabledNodeClusters(this.AdminContext(), &pb.ListEnabledNodeClustersRequest{
|
||||||
|
Offset: 0,
|
||||||
|
Size: 2,
|
||||||
|
Keyword: "",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(clustersResp.NodeClusters) == 1 {
|
||||||
|
this.RedirectURL("/clusters/cluster/createNode?clusterId=" + types.String(clustersResp.NodeClusters[0].Id))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Show()
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ func init() {
|
|||||||
Prefix("/clusters").
|
Prefix("/clusters").
|
||||||
Get("", new(IndexAction)).
|
Get("", new(IndexAction)).
|
||||||
GetPost("/create", new(CreateAction)).
|
GetPost("/create", new(CreateAction)).
|
||||||
|
GetPost("/createNode", new(CreateNodeAction)).
|
||||||
Post("/pin", new(PinAction)).
|
Post("/pin", new(PinAction)).
|
||||||
Get("/nodes", new(NodesAction)).
|
Get("/nodes", new(NodesAction)).
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,5 @@
|
|||||||
<menu-item href="/clusters/nodes" code="node">节点 <span class="small">({{totalNodes}})</span></menu-item>
|
<menu-item href="/clusters/nodes" code="node">节点 <span class="small">({{totalNodes}})</span></menu-item>
|
||||||
<span class="disabled item">|</span>
|
<span class="disabled item">|</span>
|
||||||
<menu-item href="/clusters/create" code="create">[创建集群]</menu-item>
|
<menu-item href="/clusters/create" code="create">[创建集群]</menu-item>
|
||||||
|
<menu-item href="/clusters/createNode" code="createNode">[创建节点]</menu-item>
|
||||||
</first-menu>
|
</first-menu>
|
||||||
|
|||||||
14
web/views/@default/clusters/createNode.html
Normal file
14
web/views/@default/clusters/createNode.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{$layout}
|
||||||
|
{$template "menu"}
|
||||||
|
|
||||||
|
<div class="margin"></div>
|
||||||
|
<form class="ui form">
|
||||||
|
<table class="ui table definition selectable">
|
||||||
|
<tr>
|
||||||
|
<td class="title">选择所属集群 *</td>
|
||||||
|
<td><node-cluster-combo-box @change="changeCluster"></node-cluster-combo-box></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<button type="button" class="ui button primary" :class="{disabled: clusterId <= 0}" @click.prevent="goNext">下一步 <i class="icon right arrow"></i></button>
|
||||||
|
</form>
|
||||||
13
web/views/@default/clusters/createNode.js
Normal file
13
web/views/@default/clusters/createNode.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Tea.context(function () {
|
||||||
|
this.clusterId = 0
|
||||||
|
|
||||||
|
this.changeCluster = function(clusterId) {
|
||||||
|
this.clusterId = clusterId
|
||||||
|
}
|
||||||
|
|
||||||
|
this.goNext = function () {
|
||||||
|
if (this.clusterId > 0) {
|
||||||
|
window.location = "/clusters/cluster/createNode?clusterId=" + this.clusterId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user