diff --git a/internal/web/actions/default/clusters/cluster/createBatch.go b/internal/web/actions/default/clusters/cluster/createBatch.go
index aca4a1da..28b69b8b 100644
--- a/internal/web/actions/default/clusters/cluster/createBatch.go
+++ b/internal/web/actions/default/clusters/cluster/createBatch.go
@@ -45,6 +45,7 @@ func (this *CreateBatchAction) RunPost(params struct {
IpList string
Must *actions.Must
+ CSRF *actionutils.CSRF
}) {
if params.ClusterId <= 0 {
this.Fail("请选择正确的集群")
diff --git a/internal/web/actions/default/clusters/cluster/init.go b/internal/web/actions/default/clusters/cluster/init.go
index 6fa7fdf2..ca35f7ae 100644
--- a/internal/web/actions/default/clusters/cluster/init.go
+++ b/internal/web/actions/default/clusters/cluster/init.go
@@ -17,6 +17,8 @@ func init() {
GetPost("/installNodes", new(InstallNodesAction)).
GetPost("/installRemote", new(InstallRemoteAction)).
Post("/installStatus", new(InstallStatusAction)).
+ GetPost("/upgradeRemote", new(UpgradeRemoteAction)).
+ Post("/upgradeStatus", new(UpgradeStatusAction)).
GetPost("/delete", new(DeleteAction)).
GetPost("/createNode", new(CreateNodeAction)).
GetPost("/createBatch", new(CreateBatchAction)).
diff --git a/internal/web/actions/default/clusters/cluster/installNodes.go b/internal/web/actions/default/clusters/cluster/installNodes.go
index c27d45a5..71c60af8 100644
--- a/internal/web/actions/default/clusters/cluster/installNodes.go
+++ b/internal/web/actions/default/clusters/cluster/installNodes.go
@@ -1,7 +1,6 @@
package cluster
import (
- "github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/maps"
@@ -20,18 +19,7 @@ func (this *InstallNodesAction) Init() {
func (this *InstallNodesAction) RunGet(params struct {
ClusterId int64
}) {
- this.Data["leftMenuItems"] = []maps.Map{
- {
- "name": "自动注册",
- "url": "/clusters/cluster/installNodes?clusterId=" + numberutils.FormatInt64(params.ClusterId),
- "isActive": true,
- },
- {
- "name": "远程安装",
- "url": "/clusters/cluster/installRemote?clusterId=" + numberutils.FormatInt64(params.ClusterId),
- "isActive": false,
- },
- }
+ this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "register")
clusterResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeCluster(this.AdminContext(), &pb.FindEnabledNodeClusterRequest{ClusterId: params.ClusterId})
if err != nil {
diff --git a/internal/web/actions/default/clusters/cluster/installRemote.go b/internal/web/actions/default/clusters/cluster/installRemote.go
index 4d22c2c2..bf659ef8 100644
--- a/internal/web/actions/default/clusters/cluster/installRemote.go
+++ b/internal/web/actions/default/clusters/cluster/installRemote.go
@@ -2,7 +2,6 @@ package cluster
import (
"encoding/json"
- "github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
@@ -21,18 +20,7 @@ func (this *InstallRemoteAction) Init() {
func (this *InstallRemoteAction) RunGet(params struct {
ClusterId int64
}) {
- this.Data["leftMenuItems"] = []maps.Map{
- {
- "name": "自动注册",
- "url": "/clusters/cluster/installNodes?clusterId=" + numberutils.FormatInt64(params.ClusterId),
- "isActive": false,
- },
- {
- "name": "远程安装",
- "url": "/clusters/cluster/installRemote?clusterId=" + numberutils.FormatInt64(params.ClusterId),
- "isActive": true,
- },
- }
+ this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "install")
nodesResp, err := this.RPC().NodeRPC().FindAllNotInstalledNodesWithClusterId(this.AdminContext(), &pb.FindAllNotInstalledNodesWithClusterIdRequest{ClusterId: params.ClusterId})
if err != nil {
diff --git a/internal/web/actions/default/clusters/cluster/upgradeRemote.go b/internal/web/actions/default/clusters/cluster/upgradeRemote.go
new file mode 100644
index 00000000..6a0574b3
--- /dev/null
+++ b/internal/web/actions/default/clusters/cluster/upgradeRemote.go
@@ -0,0 +1,70 @@
+package cluster
+
+import (
+ "encoding/json"
+ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
+ "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
+ "github.com/iwind/TeaGo/actions"
+ "github.com/iwind/TeaGo/maps"
+)
+
+type UpgradeRemoteAction struct {
+ actionutils.ParentAction
+}
+
+func (this *UpgradeRemoteAction) Init() {
+ this.Nav("", "", "")
+}
+
+func (this *UpgradeRemoteAction) RunGet(params struct {
+ ClusterId int64
+}) {
+ this.Data["leftMenuItems"] = LeftMenuItemsForInstall(params.ClusterId, "upgrade")
+
+ nodes := []maps.Map{}
+ resp, err := this.RPC().NodeRPC().FindAllUpgradeNodesWithClusterId(this.AdminContext(), &pb.FindAllUpgradeNodesWithClusterIdRequest{ClusterId: params.ClusterId})
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ for _, node := range resp.Nodes {
+ loginParams := maps.Map{}
+ if node.Node.Login != nil && len(node.Node.Login.Params) > 0 {
+ err := json.Unmarshal(node.Node.Login.Params, &loginParams)
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ }
+
+ nodes = append(nodes, maps.Map{
+ "id": node.Node.Id,
+ "name": node.Node.Name,
+ "os": node.Os,
+ "arch": node.Arch,
+ "oldVersion": node.OldVersion,
+ "newVersion": node.NewVersion,
+ "login": node.Node.Login,
+ "loginParams": loginParams,
+ "addresses": node.Node.IpAddresses,
+ "installStatus": node.Node.InstallStatus,
+ })
+ }
+ this.Data["nodes"] = nodes
+
+ this.Show()
+}
+
+func (this *UpgradeRemoteAction) RunPost(params struct {
+ NodeId int64
+
+ Must *actions.Must
+}) {
+ _, err := this.RPC().NodeRPC().UpgradeNode(this.AdminContext(), &pb.UpgradeNodeRequest{NodeId: params.NodeId})
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+
+ this.Success()
+}
diff --git a/internal/web/actions/default/clusters/cluster/upgradeStatus.go b/internal/web/actions/default/clusters/cluster/upgradeStatus.go
new file mode 100644
index 00000000..dc498787
--- /dev/null
+++ b/internal/web/actions/default/clusters/cluster/upgradeStatus.go
@@ -0,0 +1,35 @@
+package cluster
+
+import (
+ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
+ "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
+ "github.com/iwind/TeaGo/maps"
+)
+
+type UpgradeStatusAction struct {
+ actionutils.ParentAction
+}
+
+func (this *UpgradeStatusAction) RunPost(params struct {
+ NodeId int64
+}) {
+ resp, err := this.RPC().NodeRPC().FindNodeInstallStatus(this.AdminContext(), &pb.FindNodeInstallStatusRequest{NodeId: params.NodeId})
+ if err != nil {
+ this.ErrorPage(err)
+ return
+ }
+ if resp.InstallStatus == nil {
+ this.Data["status"] = nil
+ this.Success()
+ }
+
+ this.Data["status"] = maps.Map{
+ "isRunning": resp.InstallStatus.IsRunning,
+ "isFinished": resp.InstallStatus.IsFinished,
+ "isOk": resp.InstallStatus.IsOk,
+ "error": resp.InstallStatus.Error,
+ "errorCode": resp.InstallStatus.ErrorCode,
+ }
+
+ this.Success()
+}
diff --git a/internal/web/actions/default/clusters/cluster/utils.go b/internal/web/actions/default/clusters/cluster/utils.go
new file mode 100644
index 00000000..52647a9e
--- /dev/null
+++ b/internal/web/actions/default/clusters/cluster/utils.go
@@ -0,0 +1,27 @@
+package cluster
+
+import (
+ "github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
+ "github.com/iwind/TeaGo/maps"
+)
+
+// 安装升级相关的左侧菜单
+func LeftMenuItemsForInstall(clusterId int64, selectedItem string) []maps.Map {
+ return []maps.Map{
+ {
+ "name": "自动注册",
+ "url": "/clusters/cluster/installNodes?clusterId=" + numberutils.FormatInt64(clusterId),
+ "isActive": selectedItem == "register",
+ },
+ {
+ "name": "远程安装",
+ "url": "/clusters/cluster/installRemote?clusterId=" + numberutils.FormatInt64(clusterId),
+ "isActive": selectedItem == "install",
+ },
+ {
+ "name": "远程升级",
+ "url": "/clusters/cluster/upgradeRemote?clusterId=" + numberutils.FormatInt64(clusterId),
+ "isActive": selectedItem == "upgrade",
+ },
+ }
+}
diff --git a/web/views/@default/clusters/cluster/@menu.html b/web/views/@default/clusters/cluster/@menu.html
index f5e7b19d..0dbf2132 100644
--- a/web/views/@default/clusters/cluster/@menu.html
+++ b/web/views/@default/clusters/cluster/@menu.html
@@ -1,5 +1,5 @@