mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:50:28 +08:00 
			
		
		
		
	增加独立的IP地址管理功能
This commit is contained in:
		@@ -99,6 +99,10 @@ func (this *RPCClient) NodeIPAddressRPC() pb.NodeIPAddressServiceClient {
 | 
				
			|||||||
	return pb.NewNodeIPAddressServiceClient(this.pickConn())
 | 
						return pb.NewNodeIPAddressServiceClient(this.pickConn())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *RPCClient) NodeIPAddressLogRPC() pb.NodeIPAddressLogServiceClient {
 | 
				
			||||||
 | 
						return pb.NewNodeIPAddressLogServiceClient(this.pickConn())
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *RPCClient) NodeValueRPC() pb.NodeValueServiceClient {
 | 
					func (this *RPCClient) NodeValueRPC() pb.NodeValueServiceClient {
 | 
				
			||||||
	return pb.NewNodeValueServiceClient(this.pickConn())
 | 
						return pb.NewNodeValueServiceClient(this.pickConn())
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -171,7 +171,7 @@ func (this *CreateNodeAction) RunPost(params struct {
 | 
				
			|||||||
		addressId := address.GetInt64("id")
 | 
							addressId := address.GetInt64("id")
 | 
				
			||||||
		if addressId > 0 {
 | 
							if addressId > 0 {
 | 
				
			||||||
			_, err = this.RPC().NodeIPAddressRPC().UpdateNodeIPAddressNodeId(this.AdminContext(), &pb.UpdateNodeIPAddressNodeIdRequest{
 | 
								_, err = this.RPC().NodeIPAddressRPC().UpdateNodeIPAddressNodeId(this.AdminContext(), &pb.UpdateNodeIPAddressNodeIdRequest{
 | 
				
			||||||
				AddressId: addressId,
 | 
									NodeIPAddressId: addressId,
 | 
				
			||||||
				NodeId:          nodeId,
 | 
									NodeId:          nodeId,
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,26 @@
 | 
				
			|||||||
 | 
					// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package addr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type DeleteAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *DeleteAction) RunPost(params struct {
 | 
				
			||||||
 | 
						AddrId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						defer this.CreateLogInfo("删除IP地址 %d", params.AddrId)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().NodeIPAddressRPC().DisableNodeIPAddress(this.AdminContext(), &pb.DisableNodeIPAddressRequest{NodeIPAddressId: params.AddrId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										66
									
								
								internal/web/actions/default/clusters/ip-addrs/addr/index.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								internal/web/actions/default/clusters/ip-addrs/addr/index.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,66 @@
 | 
				
			|||||||
 | 
					// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package addr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/ip-addrs/ipaddrutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "", "addr")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						AddrId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						addr, err := ipaddrutils.InitIPAddr(this.Parent(), params.AddrId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var thresholds = []*nodeconfigs.NodeValueThresholdConfig{}
 | 
				
			||||||
 | 
						if len(addr.ThresholdsJSON) > 0 {
 | 
				
			||||||
 | 
							err = json.Unmarshal(addr.ThresholdsJSON, &thresholds)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						nodeResp, err := this.RPC().NodeRPC().FindEnabledBasicNode(this.AdminContext(), &pb.FindEnabledBasicNodeRequest{NodeId: addr.NodeId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var node = nodeResp.Node
 | 
				
			||||||
 | 
						if node == nil || node.NodeCluster == nil {
 | 
				
			||||||
 | 
							this.ErrorPage(errors.New("node or cluster is not available"))
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["addr"] = maps.Map{
 | 
				
			||||||
 | 
							"id":          addr.Id,
 | 
				
			||||||
 | 
							"name":        addr.Name,
 | 
				
			||||||
 | 
							"description": addr.Description,
 | 
				
			||||||
 | 
							"ip":          addr.Ip,
 | 
				
			||||||
 | 
							"canAccess":   addr.CanAccess,
 | 
				
			||||||
 | 
							"isOn":        addr.IsOn,
 | 
				
			||||||
 | 
							"isUp":        addr.IsUp,
 | 
				
			||||||
 | 
							"thresholds":  thresholds,
 | 
				
			||||||
 | 
							"node":        maps.Map{"id": node.Id, "name": node.Name},
 | 
				
			||||||
 | 
							"cluster":     maps.Map{"id": node.NodeCluster.Id, "name": node.NodeCluster.Name},
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										75
									
								
								internal/web/actions/default/clusters/ip-addrs/addr/logs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								internal/web/actions/default/clusters/ip-addrs/addr/logs.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
				
			|||||||
 | 
					// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package addr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/ip-addrs/ipaddrutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
						timeutil "github.com/iwind/TeaGo/utils/time"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type LogsAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *LogsAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "", "log")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *LogsAction) RunGet(params struct {
 | 
				
			||||||
 | 
						AddrId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						_, err := ipaddrutils.InitIPAddr(this.Parent(), params.AddrId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						countResp, err := this.RPC().NodeIPAddressLogRPC().CountAllNodeIPAddressLogs(this.AdminContext(), &pb.CountAllNodeIPAddressLogsRequest{NodeIPAddressId: params.AddrId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var page = this.NewPage(countResp.Count)
 | 
				
			||||||
 | 
						this.Data["page"] = page.AsHTML()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						logsResp, err := this.RPC().NodeIPAddressLogRPC().ListNodeIPAddressLogs(this.AdminContext(), &pb.ListNodeIPAddressLogsRequest{
 | 
				
			||||||
 | 
							NodeIPAddressId: params.AddrId,
 | 
				
			||||||
 | 
							Offset:          page.Offset,
 | 
				
			||||||
 | 
							Size:            page.Size,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var logMaps = []maps.Map{}
 | 
				
			||||||
 | 
						for _, log := range logsResp.NodeIPAddressLogs {
 | 
				
			||||||
 | 
							var adminMap maps.Map
 | 
				
			||||||
 | 
							if log.Admin != nil {
 | 
				
			||||||
 | 
								adminMap = maps.Map{
 | 
				
			||||||
 | 
									"id":   log.Admin.Id,
 | 
				
			||||||
 | 
									"name": log.Admin.Fullname,
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								adminMap = maps.Map{
 | 
				
			||||||
 | 
									"id":   0,
 | 
				
			||||||
 | 
									"name": "[系统]",
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							logMaps = append(logMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":          log.Id,
 | 
				
			||||||
 | 
								"description": log.Description,
 | 
				
			||||||
 | 
								"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
 | 
				
			||||||
 | 
								"isUp":        log.IsUp,
 | 
				
			||||||
 | 
								"isOn":        log.IsOn,
 | 
				
			||||||
 | 
								"canAccess":   log.CanAccess,
 | 
				
			||||||
 | 
								"admin":       adminMap,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["logs"] = logMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,92 @@
 | 
				
			|||||||
 | 
					// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package addr
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/ip-addrs/ipaddrutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/actions"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
						"net"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type UpdateAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *UpdateAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "", "update")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *UpdateAction) RunGet(params struct {
 | 
				
			||||||
 | 
						AddrId int64
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						addr, err := ipaddrutils.InitIPAddr(this.Parent(), params.AddrId)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var thresholds = []*nodeconfigs.NodeValueThresholdConfig{}
 | 
				
			||||||
 | 
						if len(addr.ThresholdsJSON) > 0 {
 | 
				
			||||||
 | 
							err = json.Unmarshal(addr.ThresholdsJSON, &thresholds)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["supportThresholds"] = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Data["addr"] = maps.Map{
 | 
				
			||||||
 | 
							"id":          addr.Id,
 | 
				
			||||||
 | 
							"name":        addr.Name,
 | 
				
			||||||
 | 
							"description": addr.Description,
 | 
				
			||||||
 | 
							"ip":          addr.Ip,
 | 
				
			||||||
 | 
							"canAccess":   addr.CanAccess,
 | 
				
			||||||
 | 
							"isOn":        addr.IsOn,
 | 
				
			||||||
 | 
							"isUp":        addr.IsUp,
 | 
				
			||||||
 | 
							"thresholds":  thresholds,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *UpdateAction) RunPost(params struct {
 | 
				
			||||||
 | 
						AddrId         int64
 | 
				
			||||||
 | 
						IP             string `alias:"ip"`
 | 
				
			||||||
 | 
						Name           string
 | 
				
			||||||
 | 
						CanAccess      bool
 | 
				
			||||||
 | 
						IsOn           bool
 | 
				
			||||||
 | 
						ThresholdsJSON []byte
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Must *actions.Must
 | 
				
			||||||
 | 
						CSRF *actionutils.CSRF
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						params.Must.
 | 
				
			||||||
 | 
							Field("ip", params.IP).
 | 
				
			||||||
 | 
							Require("请输入IP地址")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ip := net.ParseIP(params.IP)
 | 
				
			||||||
 | 
						if len(ip) == 0 {
 | 
				
			||||||
 | 
							this.Fail("请输入正确的IP")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						_, err := this.RPC().NodeIPAddressRPC().UpdateNodeIPAddress(this.AdminContext(), &pb.UpdateNodeIPAddressRequest{
 | 
				
			||||||
 | 
							NodeIPAddressId: params.AddrId,
 | 
				
			||||||
 | 
							Name:            params.Name,
 | 
				
			||||||
 | 
							Ip:              params.IP,
 | 
				
			||||||
 | 
							CanAccess:       params.CanAccess,
 | 
				
			||||||
 | 
							IsOn:            params.IsOn,
 | 
				
			||||||
 | 
							ThresholdsJSON:  params.ThresholdsJSON,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Success()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										94
									
								
								internal/web/actions/default/clusters/ip-addrs/index.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								internal/web/actions/default/clusters/ip-addrs/index.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
				
			|||||||
 | 
					// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package ipaddrs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"encoding/json"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type IndexAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "", "index")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *IndexAction) RunGet(params struct {
 | 
				
			||||||
 | 
						ClusterId int64
 | 
				
			||||||
 | 
						UpState   int8
 | 
				
			||||||
 | 
						Keyword   string
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						this.Data["clusterId"] = params.ClusterId
 | 
				
			||||||
 | 
						this.Data["upState"] = params.UpState
 | 
				
			||||||
 | 
						this.Data["keyword"] = params.Keyword
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						countResp, err := this.RPC().NodeIPAddressRPC().CountAllEnabledIPAddresses(this.AdminContext(), &pb.CountAllEnabledIPAddressesRequest{
 | 
				
			||||||
 | 
							NodeClusterId: params.ClusterId,
 | 
				
			||||||
 | 
							Role:          nodeconfigs.NodeRoleNode,
 | 
				
			||||||
 | 
							UpState:       int32(params.UpState),
 | 
				
			||||||
 | 
							Keyword:       params.Keyword,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var count = countResp.Count
 | 
				
			||||||
 | 
						var page = this.NewPage(count)
 | 
				
			||||||
 | 
						this.Data["page"] = page.AsHTML()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						addrsResp, err := this.RPC().NodeIPAddressRPC().ListEnabledIPAddresses(this.AdminContext(), &pb.ListEnabledIPAddressesRequest{
 | 
				
			||||||
 | 
							NodeClusterId: params.ClusterId,
 | 
				
			||||||
 | 
							Role:          nodeconfigs.NodeRoleNode,
 | 
				
			||||||
 | 
							UpState:       int32(params.UpState),
 | 
				
			||||||
 | 
							Keyword:       params.Keyword,
 | 
				
			||||||
 | 
							Offset:        page.Offset,
 | 
				
			||||||
 | 
							Size:          page.Size,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var addrMaps = []maps.Map{}
 | 
				
			||||||
 | 
						for _, addr := range addrsResp.NodeIPAddresses {
 | 
				
			||||||
 | 
							var thresholds = []*nodeconfigs.NodeValueThresholdConfig{}
 | 
				
			||||||
 | 
							if len(addr.ThresholdsJSON) > 0 {
 | 
				
			||||||
 | 
								err = json.Unmarshal(addr.ThresholdsJSON, &thresholds)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									this.ErrorPage(err)
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							nodeResp, err := this.RPC().NodeRPC().FindEnabledBasicNode(this.AdminContext(), &pb.FindEnabledBasicNodeRequest{NodeId: addr.NodeId})
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								this.ErrorPage(err)
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							var node = nodeResp.Node
 | 
				
			||||||
 | 
							if node == nil || node.NodeCluster == nil {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							addrMaps = append(addrMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":            addr.Id,
 | 
				
			||||||
 | 
								"name":          addr.Name,
 | 
				
			||||||
 | 
								"description":   addr.Description,
 | 
				
			||||||
 | 
								"ip":            addr.Ip,
 | 
				
			||||||
 | 
								"canAccess":     addr.CanAccess,
 | 
				
			||||||
 | 
								"isOn":          addr.IsOn,
 | 
				
			||||||
 | 
								"isUp":          addr.IsUp,
 | 
				
			||||||
 | 
								"hasThresholds": len(thresholds) > 0,
 | 
				
			||||||
 | 
								"node":          maps.Map{"id": node.Id, "name": node.Name},
 | 
				
			||||||
 | 
								"cluster":       maps.Map{"id": node.NodeCluster.Id, "name": node.NodeCluster.Name},
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["addrs"] = addrMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										28
									
								
								internal/web/actions/default/clusters/ip-addrs/init.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								internal/web/actions/default/clusters/ip-addrs/init.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					package ipaddrs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/clusterutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/ip-addrs/addr"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func init() {
 | 
				
			||||||
 | 
						TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
				
			||||||
 | 
							server.
 | 
				
			||||||
 | 
								Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeNode)).
 | 
				
			||||||
 | 
								Helper(clusterutils.NewClustersHelper()).
 | 
				
			||||||
 | 
								Data("teaSubMenu", "ipAddr").
 | 
				
			||||||
 | 
								Prefix("/clusters/ip-addrs").
 | 
				
			||||||
 | 
								Get("", new(IndexAction)).
 | 
				
			||||||
 | 
								Get("/logs", new(LogsAction)).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// 单个地址操作
 | 
				
			||||||
 | 
								Post("/addr/delete", new(addr.DeleteAction)).
 | 
				
			||||||
 | 
								Get("/addr", new(addr.IndexAction)).
 | 
				
			||||||
 | 
								GetPost("/addr/update", new(addr.UpdateAction)).
 | 
				
			||||||
 | 
								Get("/addr/logs", new(addr.LogsAction)).
 | 
				
			||||||
 | 
								EndAll()
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package ipaddrutils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"errors"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/types"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func InitIPAddr(parent *actionutils.ParentAction, addrId int64) (*pb.NodeIPAddress, error) {
 | 
				
			||||||
 | 
						addrResp, err := parent.RPC().NodeIPAddressRPC().FindEnabledNodeIPAddress(parent.AdminContext(), &pb.FindEnabledNodeIPAddressRequest{NodeIPAddressId: addrId})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							return nil, err
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var addr = addrResp.NodeIPAddress
 | 
				
			||||||
 | 
						if addr == nil {
 | 
				
			||||||
 | 
							return nil, errors.New("nodeIPAddress with id '" + types.String(addrId) + "' not found")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						parent.Data["addr"] = maps.Map{
 | 
				
			||||||
 | 
							"id":   addr.Id,
 | 
				
			||||||
 | 
							"name": addr.Name,
 | 
				
			||||||
 | 
							"ip":   addr.Ip,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return addr, nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										78
									
								
								internal/web/actions/default/clusters/ip-addrs/logs.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								internal/web/actions/default/clusters/ip-addrs/logs.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
				
			|||||||
 | 
					// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package ipaddrs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import (
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
 | 
				
			||||||
 | 
						"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
 | 
				
			||||||
 | 
						"github.com/iwind/TeaGo/maps"
 | 
				
			||||||
 | 
						timeutil "github.com/iwind/TeaGo/utils/time"
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type LogsAction struct {
 | 
				
			||||||
 | 
						actionutils.ParentAction
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *LogsAction) Init() {
 | 
				
			||||||
 | 
						this.Nav("", "", "log")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (this *LogsAction) RunGet(params struct {
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						countResp, err := this.RPC().NodeIPAddressLogRPC().CountAllNodeIPAddressLogs(this.AdminContext(), &pb.CountAllNodeIPAddressLogsRequest{})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var page = this.NewPage(countResp.Count)
 | 
				
			||||||
 | 
						this.Data["page"] = page.AsHTML()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						logsResp, err := this.RPC().NodeIPAddressLogRPC().ListNodeIPAddressLogs(this.AdminContext(), &pb.ListNodeIPAddressLogsRequest{
 | 
				
			||||||
 | 
							Offset: page.Offset,
 | 
				
			||||||
 | 
							Size:   page.Size,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							this.ErrorPage(err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						var logMaps = []maps.Map{}
 | 
				
			||||||
 | 
						for _, log := range logsResp.NodeIPAddressLogs {
 | 
				
			||||||
 | 
							var adminMap maps.Map
 | 
				
			||||||
 | 
							if log.Admin != nil {
 | 
				
			||||||
 | 
								adminMap = maps.Map{
 | 
				
			||||||
 | 
									"id":   log.Admin.Id,
 | 
				
			||||||
 | 
									"name": log.Admin.Fullname,
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								adminMap = maps.Map{
 | 
				
			||||||
 | 
									"id":   0,
 | 
				
			||||||
 | 
									"name": "[系统]",
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							var addrMap maps.Map
 | 
				
			||||||
 | 
							if log.NodeIPAddress != nil {
 | 
				
			||||||
 | 
								var addr = log.NodeIPAddress
 | 
				
			||||||
 | 
								if addr != nil {
 | 
				
			||||||
 | 
									addrMap = maps.Map{
 | 
				
			||||||
 | 
										"id": addr.Id,
 | 
				
			||||||
 | 
										"ip": addr.Ip,
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							logMaps = append(logMaps, maps.Map{
 | 
				
			||||||
 | 
								"id":          log.Id,
 | 
				
			||||||
 | 
								"description": log.Description,
 | 
				
			||||||
 | 
								"createdTime": timeutil.FormatTime("Y-m-d H:i:s", log.CreatedAt),
 | 
				
			||||||
 | 
								"isUp":        log.IsUp,
 | 
				
			||||||
 | 
								"isOn":        log.IsOn,
 | 
				
			||||||
 | 
								"canAccess":   log.CanAccess,
 | 
				
			||||||
 | 
								"admin":       adminMap,
 | 
				
			||||||
 | 
								"addr":        addrMap,
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						this.Data["logs"] = logMaps
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						this.Show()
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -18,7 +18,10 @@ func (this *CreatePopupAction) Init() {
 | 
				
			|||||||
	this.Nav("", "", "")
 | 
						this.Nav("", "", "")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *CreatePopupAction) RunGet(params struct{}) {
 | 
					func (this *CreatePopupAction) RunGet(params struct {
 | 
				
			||||||
 | 
						SupportThresholds bool
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
						this.Data["supportThresholds"] = params.SupportThresholds
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Show()
 | 
						this.Show()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,7 @@ func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64,
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			_, err = parentAction.RPC().NodeIPAddressRPC().UpdateNodeIPAddress(parentAction.AdminContext(), &pb.UpdateNodeIPAddressRequest{
 | 
								_, err = parentAction.RPC().NodeIPAddressRPC().UpdateNodeIPAddress(parentAction.AdminContext(), &pb.UpdateNodeIPAddressRequest{
 | 
				
			||||||
				AddressId:      addrId,
 | 
									NodeIPAddressId: addrId,
 | 
				
			||||||
				Ip:              addr.GetString("ip"),
 | 
									Ip:              addr.GetString("ip"),
 | 
				
			||||||
				Name:            addr.GetString("name"),
 | 
									Name:            addr.GetString("name"),
 | 
				
			||||||
				CanAccess:       addr.GetBool("canAccess"),
 | 
									CanAccess:       addr.GetBool("canAccess"),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,10 @@ func (this *UpdatePopupAction) Init() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func (this *UpdatePopupAction) RunGet(params struct {
 | 
					func (this *UpdatePopupAction) RunGet(params struct {
 | 
				
			||||||
	AddressId         int64
 | 
						AddressId         int64
 | 
				
			||||||
 | 
						SupportThresholds bool
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
 | 
						this.Data["supportThresholds"] = params.SupportThresholds
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Show()
 | 
						this.Show()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -42,12 +45,12 @@ func (this *UpdatePopupAction) RunPost(params struct {
 | 
				
			|||||||
	// 获取IP地址信息
 | 
						// 获取IP地址信息
 | 
				
			||||||
	var isUp = true
 | 
						var isUp = true
 | 
				
			||||||
	if params.AddressId > 0 {
 | 
						if params.AddressId > 0 {
 | 
				
			||||||
		addressResp, err := this.RPC().NodeIPAddressRPC().FindEnabledNodeIPAddress(this.AdminContext(), &pb.FindEnabledNodeIPAddressRequest{AddressId: params.AddressId})
 | 
							addressResp, err := this.RPC().NodeIPAddressRPC().FindEnabledNodeIPAddress(this.AdminContext(), &pb.FindEnabledNodeIPAddressRequest{NodeIPAddressId: params.AddressId})
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			this.ErrorPage(err)
 | 
								this.ErrorPage(err)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		var address = addressResp.IpAddress
 | 
							var address = addressResp.NodeIPAddress
 | 
				
			||||||
		if address == nil {
 | 
							if address == nil {
 | 
				
			||||||
			this.Fail("找不到要修改的地址")
 | 
								this.Fail("找不到要修改的地址")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -83,7 +83,7 @@ func (this *CreateNodeAction) RunPost(params struct {
 | 
				
			|||||||
		addressId := address.GetInt64("id")
 | 
							addressId := address.GetInt64("id")
 | 
				
			||||||
		if addressId > 0 {
 | 
							if addressId > 0 {
 | 
				
			||||||
			_, err = this.RPC().NodeIPAddressRPC().UpdateNodeIPAddressNodeId(this.AdminContext(), &pb.UpdateNodeIPAddressNodeIdRequest{
 | 
								_, err = this.RPC().NodeIPAddressRPC().UpdateNodeIPAddressNodeId(this.AdminContext(), &pb.UpdateNodeIPAddressNodeIdRequest{
 | 
				
			||||||
				AddressId: addressId,
 | 
									NodeIPAddressId: addressId,
 | 
				
			||||||
				NodeId:          nodeId,
 | 
									NodeId:          nodeId,
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -240,13 +240,13 @@ func (this *userMustAuth) modules(adminId int64) []maps.Map {
 | 
				
			|||||||
					"url":  "/clusters/logs",
 | 
										"url":  "/clusters/logs",
 | 
				
			||||||
					"code": "log",
 | 
										"code": "log",
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				/**{
 | 
									{
 | 
				
			||||||
					"name": "IP资源",
 | 
										"name": "IP地址",
 | 
				
			||||||
					"url":  "/clusters/ip-addrs",
 | 
										"url":  "/clusters/ip-addrs",
 | 
				
			||||||
					"code": "ipAddr",
 | 
										"code": "ipAddr",
 | 
				
			||||||
					"isOn": teaconst.IsPlus,
 | 
										"isOn": teaconst.IsPlus,
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									/**{
 | 
				
			||||||
					"name": "监控",
 | 
										"name": "监控",
 | 
				
			||||||
					"url":  "/clusters/monitors",
 | 
										"url":  "/clusters/monitors",
 | 
				
			||||||
					"code": "monitor",
 | 
										"code": "monitor",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,11 +6,6 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// 系统用户
 | 
						// 系统用户
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/groups"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/instances"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/logs"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/admins/recipients/tasks"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// API节点
 | 
						// API节点
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/api"
 | 
				
			||||||
@@ -41,23 +36,8 @@ import (
 | 
				
			|||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ui"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ui"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// 域名服务
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/accessLogs"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings/accessLog"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/cluster/settings/recursion"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/clusters/logs"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/routes"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/settings/accesslogs"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/test"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/ns/users"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// 服务相关
 | 
						// 服务相关
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/accesslogs"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/certs"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/certs"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/cache"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/cache"
 | 
				
			||||||
@@ -68,7 +48,6 @@ import (
 | 
				
			|||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/metrics"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/metrics"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/metrics/charts"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/metrics/charts"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/boards"
 | 
					 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/delete"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/delete"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/log"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/log"
 | 
				
			||||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings"
 | 
						_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/server/settings"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,6 @@
 | 
				
			|||||||
// 单个集群选择
 | 
					// 单个集群选择
 | 
				
			||||||
Vue.component("cluster-selector", {
 | 
					Vue.component("cluster-selector", {
 | 
				
			||||||
 | 
						props: ["v-cluster-id"],
 | 
				
			||||||
	mounted: function () {
 | 
						mounted: function () {
 | 
				
			||||||
		let that = this
 | 
							let that = this
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -9,7 +10,6 @@ Vue.component("cluster-selector", {
 | 
				
			|||||||
				that.clusters = resp.data.clusters
 | 
									that.clusters = resp.data.clusters
 | 
				
			||||||
			})
 | 
								})
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	props: ["v-cluster-id"],
 | 
					 | 
				
			||||||
	data: function () {
 | 
						data: function () {
 | 
				
			||||||
		let clusterId = this.vClusterId
 | 
							let clusterId = this.vClusterId
 | 
				
			||||||
		if (clusterId == null) {
 | 
							if (clusterId == null) {
 | 
				
			||||||
@@ -21,7 +21,7 @@ Vue.component("cluster-selector", {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	template: `<div>
 | 
						template: `<div>
 | 
				
			||||||
	<select class="ui dropdown auto-width" name="clusterId" v-model="clusterId">
 | 
						<select class="ui dropdown" style="max-width: 10em" name="clusterId" v-model="clusterId">
 | 
				
			||||||
		<option value="0">[选择集群]</option>
 | 
							<option value="0">[选择集群]</option>
 | 
				
			||||||
		<option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
 | 
							<option v-for="cluster in clusters" :value="cluster.id">{{cluster.name}}</option>
 | 
				
			||||||
	</select>
 | 
						</select>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,10 @@
 | 
				
			|||||||
// 节点IP地址管理(标签形式)
 | 
					// 节点IP地址管理(标签形式)
 | 
				
			||||||
Vue.component("node-ip-addresses-box", {
 | 
					Vue.component("node-ip-addresses-box", {
 | 
				
			||||||
	props: ["vIpAddresses"],
 | 
						props: ["v-ip-addresses", "role"],
 | 
				
			||||||
	data: function () {
 | 
						data: function () {
 | 
				
			||||||
		return {
 | 
							return {
 | 
				
			||||||
			ipAddresses: (this.vIpAddresses == null) ? [] : this.vIpAddresses
 | 
								ipAddresses: (this.vIpAddresses == null) ? [] : this.vIpAddresses,
 | 
				
			||||||
 | 
								supportThresholds: this.role != "ns"
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	methods: {
 | 
						methods: {
 | 
				
			||||||
@@ -12,7 +13,7 @@ Vue.component("node-ip-addresses-box", {
 | 
				
			|||||||
			window.UPDATING_NODE_IP_ADDRESS = null
 | 
								window.UPDATING_NODE_IP_ADDRESS = null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			let that = this;
 | 
								let that = this;
 | 
				
			||||||
			teaweb.popup("/nodes/ipAddresses/createPopup", {
 | 
								teaweb.popup("/nodes/ipAddresses/createPopup?supportThresholds=" + (this.supportThresholds ? 1 : 0), {
 | 
				
			||||||
				callback: function (resp) {
 | 
									callback: function (resp) {
 | 
				
			||||||
					that.ipAddresses.push(resp.data.ipAddress);
 | 
										that.ipAddresses.push(resp.data.ipAddress);
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -26,7 +27,7 @@ Vue.component("node-ip-addresses-box", {
 | 
				
			|||||||
			window.UPDATING_NODE_IP_ADDRESS = address
 | 
								window.UPDATING_NODE_IP_ADDRESS = address
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			let that = this;
 | 
								let that = this;
 | 
				
			||||||
			teaweb.popup("/nodes/ipAddresses/updatePopup", {
 | 
								teaweb.popup("/nodes/ipAddresses/updatePopup?supportThresholds=" + (this.supportThresholds ? 1 : 0), {
 | 
				
			||||||
				callback: function (resp) {
 | 
									callback: function (resp) {
 | 
				
			||||||
					Vue.set(that.ipAddresses, index, resp.data.ipAddress);
 | 
										Vue.set(that.ipAddresses, index, resp.data.ipAddress);
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								web/views/@default/clusters/ip-addrs/@menu.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								web/views/@default/clusters/ip-addrs/@menu.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					<first-menu>
 | 
				
			||||||
 | 
					    <menu-item href="." code="index">IP地址</menu-item>
 | 
				
			||||||
 | 
					    <menu-item href=".logs" code="log">变更日志</menu-item>
 | 
				
			||||||
 | 
					</first-menu>
 | 
				
			||||||
							
								
								
									
										7
									
								
								web/views/@default/clusters/ip-addrs/addr/@menu.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								web/views/@default/clusters/ip-addrs/addr/@menu.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					<first-menu>
 | 
				
			||||||
 | 
					    <menu-item href="/clusters/ip-addrs">全部地址</menu-item>
 | 
				
			||||||
 | 
					    <span class="item disabled">|</span>
 | 
				
			||||||
 | 
					    <menu-item :href="'.?addrId=' + addr.id" code="addr">"{{addr.ip}}"详情</menu-item>
 | 
				
			||||||
 | 
					    <menu-item :href="'.logs?addrId=' + addr.id" code="log">日志</menu-item>
 | 
				
			||||||
 | 
					    <menu-item :href="'.update?addrId=' + addr.id" code="update">修改</menu-item>
 | 
				
			||||||
 | 
					</first-menu>
 | 
				
			||||||
							
								
								
									
										54
									
								
								web/views/@default/clusters/ip-addrs/addr/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								web/views/@default/clusters/ip-addrs/addr/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					{$template "menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<table class="ui table definition selectable">
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td class="title">IP地址</td>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					            {{addr.ip}}
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td>状态</td>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					            <label-on :v-is-on="addr.isOn" v-if="!addr.isOn"></label-on>
 | 
				
			||||||
 | 
					            <span v-else-if="addr.isUp" class="green">在线</span>
 | 
				
			||||||
 | 
					            <span v-else class="red">离线</span>
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td>所属集群</td>
 | 
				
			||||||
 | 
					        <td><link-icon :href="'/clusters/cluster?clusterId=' + addr.cluster.id">{{addr.cluster.name}}</link-icon></td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td>所属节点</td>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					            <link-icon :href="'/clusters/cluster/node?clusterId=' + addr.cluster.id + '&nodeId=' + addr.node.id">{{addr.node.name}}</link-icon>
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td>名称</td>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					            <span v-if="addr.name.length > 0">{{addr.name}}</span>
 | 
				
			||||||
 | 
					            <span v-else class="disabled">-</span>
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td>是否可以访问</td>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					            <span v-if="addr.canAccess" class="green">Y</span>
 | 
				
			||||||
 | 
					            <span v-else class="disabled">N</span>
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					    <tr>
 | 
				
			||||||
 | 
					        <td>阈值</td>
 | 
				
			||||||
 | 
					        <td>
 | 
				
			||||||
 | 
					            <div v-if="addr.thresholds.length > 0">
 | 
				
			||||||
 | 
					                <span v-for="threshold in addr.thresholds" class="ui basic tiny label">
 | 
				
			||||||
 | 
					                    {{threshold.item}} {{threshold.operator}} {{threshold.value}}
 | 
				
			||||||
 | 
					                </span>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					            <span v-else class="disabled">没有设置阈值。</span>
 | 
				
			||||||
 | 
					        </td>
 | 
				
			||||||
 | 
					    </tr>
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
							
								
								
									
										34
									
								
								web/views/@default/clusters/ip-addrs/addr/logs.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								web/views/@default/clusters/ip-addrs/addr/logs.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					{$template "menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<p class="comment" v-if="logs.length == 0">暂时还没有日志。</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div v-if="logs.length > 0">
 | 
				
			||||||
 | 
					   <div class="margin"></div>
 | 
				
			||||||
 | 
					   <table class="ui table selectable celled">
 | 
				
			||||||
 | 
					       <thead>
 | 
				
			||||||
 | 
					            <tr>
 | 
				
			||||||
 | 
					                <th class="two wide">操作人</th>
 | 
				
			||||||
 | 
					                <th class="two wide">状态</th>
 | 
				
			||||||
 | 
					                <th>描述</th>
 | 
				
			||||||
 | 
					                <th style="width: 12em">时间</th>
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
 | 
					       </thead>
 | 
				
			||||||
 | 
					        <tr v-for="log in logs">
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span v-if="log.admin.id > 0">{{log.admin.name}}</span>
 | 
				
			||||||
 | 
					                <span v-else class="grey">{{log.admin.name}}</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span v-if="!log.isOn" class="red">停用</span>
 | 
				
			||||||
 | 
					                <span v-else-if="!log.canAccess" class="red">不可访问</span>
 | 
				
			||||||
 | 
					                <span v-else-if="log.isUp" class="green">上线</span>
 | 
				
			||||||
 | 
					                <span v-else class="red">离线</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>{{log.description}}</td>
 | 
				
			||||||
 | 
					            <td>{{log.createdTime}}</td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
 | 
					   </table>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="page" v-html="page"></div>
 | 
				
			||||||
							
								
								
									
										53
									
								
								web/views/@default/clusters/ip-addrs/addr/update.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								web/views/@default/clusters/ip-addrs/addr/update.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					{$template "menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
 | 
				
			||||||
 | 
					    <csrf-token></csrf-token>
 | 
				
			||||||
 | 
						<input type="hidden" name="addrId" :value="addr.id"/>
 | 
				
			||||||
 | 
						<table class="ui table definition selectable">
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td class="title">IP地址 *</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<input type="text" name="ip" maxlength="128" ref="focus" v-model="addr.ip"/>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
							<tr>
 | 
				
			||||||
 | 
								<td>是否可以访问</td>
 | 
				
			||||||
 | 
								<td>
 | 
				
			||||||
 | 
									<div class="ui checkbox">
 | 
				
			||||||
 | 
										<input type="checkbox" name="canAccess" value="1" v-model="addr.canAccess"/>
 | 
				
			||||||
 | 
										<label></label>
 | 
				
			||||||
 | 
									</div>
 | 
				
			||||||
 | 
									<p class="comment">是否为可以公开访问的IP,如果选中,也会作为DNS解析记录的值使用。</p>
 | 
				
			||||||
 | 
								</td>
 | 
				
			||||||
 | 
							</tr>
 | 
				
			||||||
 | 
					        <tr>
 | 
				
			||||||
 | 
					            <td colspan="2"><more-options-indicator></more-options-indicator></td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
 | 
					        <tbody v-show="moreOptionsVisible">
 | 
				
			||||||
 | 
					            <tr>
 | 
				
			||||||
 | 
					                <td>是否启用</td>
 | 
				
			||||||
 | 
					                <td>
 | 
				
			||||||
 | 
					                    <div class="ui checkbox">
 | 
				
			||||||
 | 
					                        <input type="checkbox" name="isOn" value="1" v-model="addr.isOn"/>
 | 
				
			||||||
 | 
					                        <label></label>
 | 
				
			||||||
 | 
					                    </div>
 | 
				
			||||||
 | 
					                    <p class="comment">选中表示当前IP有效。</p>
 | 
				
			||||||
 | 
					                </td>
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
 | 
					            <tr>
 | 
				
			||||||
 | 
					                <td class="title">名称</td>
 | 
				
			||||||
 | 
					                <td>
 | 
				
			||||||
 | 
					                    <input type="text" name="name" maxlength="50" v-model="addr.name"/>
 | 
				
			||||||
 | 
					                </td>
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
 | 
					            <tr v-if="teaIsPlus && supportThresholds">
 | 
				
			||||||
 | 
					                <td>上线阈值</td>
 | 
				
			||||||
 | 
					                <td>
 | 
				
			||||||
 | 
					                    <node-ip-address-thresholds-box :v-thresholds="addr.thresholds"></node-ip-address-thresholds-box>
 | 
				
			||||||
 | 
					                </td>
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
 | 
					        </tbody>
 | 
				
			||||||
 | 
						</table>
 | 
				
			||||||
 | 
						<submit-btn></submit-btn>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
							
								
								
									
										3
									
								
								web/views/@default/clusters/ip-addrs/addr/update.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								web/views/@default/clusters/ip-addrs/addr/update.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.success = NotifySuccess("保存成功", Tea.url(".addr", { addrId: this.addr.id }))
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										86
									
								
								web/views/@default/clusters/ip-addrs/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										86
									
								
								web/views/@default/clusters/ip-addrs/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,86 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					{$template "menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="margin"></div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<form class="ui form" method="get" action="/clusters/ip-addrs">
 | 
				
			||||||
 | 
					    <div class="ui fields inline">
 | 
				
			||||||
 | 
					        <div class="ui field">
 | 
				
			||||||
 | 
					            集群:
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="ui field">
 | 
				
			||||||
 | 
					            <cluster-selector :v-cluster-id="clusterId"></cluster-selector>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="ui field">
 | 
				
			||||||
 | 
					            状态:
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="ui field">
 | 
				
			||||||
 | 
					            <select class="ui dropdown" name="upState" v-model="upState">
 | 
				
			||||||
 | 
					                <option value="0">[全部]</option>
 | 
				
			||||||
 | 
					                <option value="1">在线</option>
 | 
				
			||||||
 | 
					                <option value="2">离线</option>
 | 
				
			||||||
 | 
					            </select>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="ui field">
 | 
				
			||||||
 | 
					            <input type="text" placeholder="IP、名称..." name="keyword" v-model="keyword"/>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					        <div class="ui field">
 | 
				
			||||||
 | 
					            <button class="ui button" type="submit">搜索</button>
 | 
				
			||||||
 | 
					             
 | 
				
			||||||
 | 
					            <a href="/clusters/ip-addrs" v-if="clusterId > 0 || upState > 0 || keyword.length > 0">[清除条件]</a>
 | 
				
			||||||
 | 
					        </div>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					</form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<p class="comment" v-if="addrs.length == 0">暂时还没有IP地址。</p>
 | 
				
			||||||
 | 
					<div v-if="addrs.length > 0">
 | 
				
			||||||
 | 
					    <div class="margin"></div>
 | 
				
			||||||
 | 
					    <table class="ui table selectable celled">
 | 
				
			||||||
 | 
					        <thead>
 | 
				
			||||||
 | 
					            <tr>
 | 
				
			||||||
 | 
					                <th>IP</th>
 | 
				
			||||||
 | 
					                <th>所属集群</th>
 | 
				
			||||||
 | 
					                <th>所属节点</th>
 | 
				
			||||||
 | 
					                <th>名称</th>
 | 
				
			||||||
 | 
					                <th>可访问</th>
 | 
				
			||||||
 | 
					                <th>阈值</th>
 | 
				
			||||||
 | 
					                <th>状态</th>
 | 
				
			||||||
 | 
					                <th class="two op">操作</th>
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
 | 
					        </thead>
 | 
				
			||||||
 | 
					        <tr v-for="addr in addrs">
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <a :href="'/clusters/ip-addrs/addr?addrId=' + addr.id"><keyword :v-word="keyword">{{addr.ip}}</keyword></a>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <link-icon :href="'/clusters/cluster?clusterId=' + addr.cluster.id">{{addr.cluster.name}}</link-icon>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <link-icon :href="'/clusters/cluster/node?clusterId=' + addr.cluster.id + '&nodeId=' + addr.node.id"><keyword :v-word="keyword">{{addr.node.name}}</keyword></link-icon>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span v-if="addr.name.length > 0"><keyword :v-word="keyword">{{addr.name}}</keyword></span>
 | 
				
			||||||
 | 
					                <span v-else class="disabled">-</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span v-if="addr.canAccess" class="green">Y</span>
 | 
				
			||||||
 | 
					                <span v-else class="disabled">N</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span v-if="addr.hasThresholds" class="green">Y</span>
 | 
				
			||||||
 | 
					                <span v-else class="disabled">N</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <label-on :v-is-on="addr.isOn" v-if="!addr.isOn"></label-on>
 | 
				
			||||||
 | 
					                <span v-else-if="addr.isUp" class="green">在线</span>
 | 
				
			||||||
 | 
					                <span v-else class="red">离线</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <a :href="'/clusters/ip-addrs/addr?addrId=' + addr.id">详情</a>  
 | 
				
			||||||
 | 
					                <a href="" @click.prevent="deleteAddr(addr.id)">删除</a>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
 | 
					    </table>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="page" v-html="page"></div>
 | 
				
			||||||
							
								
								
									
										13
									
								
								web/views/@default/clusters/ip-addrs/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								web/views/@default/clusters/ip-addrs/index.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					Tea.context(function () {
 | 
				
			||||||
 | 
						this.deleteAddr = function (addrId) {
 | 
				
			||||||
 | 
							teaweb.confirm("确定要删除这个IP地址吗?", function () {
 | 
				
			||||||
 | 
								this.$post(".addr.delete")
 | 
				
			||||||
 | 
									.params({
 | 
				
			||||||
 | 
										addrId: addrId
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
									.success(function () {
 | 
				
			||||||
 | 
										teaweb.reload()
 | 
				
			||||||
 | 
									})
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
							
								
								
									
										39
									
								
								web/views/@default/clusters/ip-addrs/logs.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								web/views/@default/clusters/ip-addrs/logs.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					{$layout}
 | 
				
			||||||
 | 
					{$template "menu"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<p class="comment" v-if="logs.length == 0">暂时还没有日志。</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div v-if="logs.length > 0">
 | 
				
			||||||
 | 
					   <div class="margin"></div>
 | 
				
			||||||
 | 
					   <table class="ui table selectable celled">
 | 
				
			||||||
 | 
					       <thead>
 | 
				
			||||||
 | 
					            <tr>
 | 
				
			||||||
 | 
					                <th class="two wide">操作人</th>
 | 
				
			||||||
 | 
					                <th>IP</th>
 | 
				
			||||||
 | 
					                <th class="two wide">状态</th>
 | 
				
			||||||
 | 
					                <th>描述</th>
 | 
				
			||||||
 | 
					                <th style="width: 12em">时间</th>
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
 | 
					       </thead>
 | 
				
			||||||
 | 
					        <tr v-for="log in logs">
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span v-if="log.admin.id > 0">{{log.admin.name}}</span>
 | 
				
			||||||
 | 
					                <span v-else class="grey">{{log.admin.name}}</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span v-if="log.addr != null"><a :href="'/clusters/ip-addrs/addr?addrId=' + log.addr.id">{{log.addr.ip}}</a></span>
 | 
				
			||||||
 | 
					                <span v-else class="disabled">已删除</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>
 | 
				
			||||||
 | 
					                <span v-if="!log.isOn" class="red">停用</span>
 | 
				
			||||||
 | 
					                <span v-else-if="!log.canAccess" class="red">不可访问</span>
 | 
				
			||||||
 | 
					                <span v-else-if="log.isUp" class="green">上线</span>
 | 
				
			||||||
 | 
					                <span v-else class="red">离线</span>
 | 
				
			||||||
 | 
					            </td>
 | 
				
			||||||
 | 
					            <td>{{log.description}}</td>
 | 
				
			||||||
 | 
					            <td>{{log.createdTime}}</td>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
 | 
					   </table>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<div class="page" v-html="page"></div>
 | 
				
			||||||
@@ -25,12 +25,12 @@
 | 
				
			|||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
        <tbody v-show="moreOptionsVisible">
 | 
					        <tbody v-show="moreOptionsVisible">
 | 
				
			||||||
            <tr>
 | 
					            <tr>
 | 
				
			||||||
                <td class="title">备注</td>
 | 
					                <td class="title">名称</td>
 | 
				
			||||||
                <td>
 | 
					                <td>
 | 
				
			||||||
                    <input type="text" name="name" maxlength="50"/>
 | 
					                    <input type="text" name="name" maxlength="50"/>
 | 
				
			||||||
                </td>
 | 
					                </td>
 | 
				
			||||||
            </tr>
 | 
					            </tr>
 | 
				
			||||||
            <tr v-if="teaIsPlus">
 | 
					            <tr v-if="teaIsPlus && supportThresholds">
 | 
				
			||||||
                <td>上线阈值</td>
 | 
					                <td>上线阈值</td>
 | 
				
			||||||
                <td>
 | 
					                <td>
 | 
				
			||||||
                    <node-ip-address-thresholds-box></node-ip-address-thresholds-box>
 | 
					                    <node-ip-address-thresholds-box></node-ip-address-thresholds-box>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,12 +36,12 @@
 | 
				
			|||||||
                </td>
 | 
					                </td>
 | 
				
			||||||
            </tr>
 | 
					            </tr>
 | 
				
			||||||
            <tr>
 | 
					            <tr>
 | 
				
			||||||
                <td class="title">备注</td>
 | 
					                <td class="title">名称</td>
 | 
				
			||||||
                <td>
 | 
					                <td>
 | 
				
			||||||
                    <input type="text" name="name" maxlength="50" v-model="address.name"/>
 | 
					                    <input type="text" name="name" maxlength="50" v-model="address.name"/>
 | 
				
			||||||
                </td>
 | 
					                </td>
 | 
				
			||||||
            </tr>
 | 
					            </tr>
 | 
				
			||||||
            <tr v-if="teaIsPlus">
 | 
					            <tr v-if="teaIsPlus && supportThresholds">
 | 
				
			||||||
                <td>上线阈值</td>
 | 
					                <td>上线阈值</td>
 | 
				
			||||||
                <td>
 | 
					                <td>
 | 
				
			||||||
                    <node-ip-address-thresholds-box :v-thresholds="address.thresholds"></node-ip-address-thresholds-box>
 | 
					                    <node-ip-address-thresholds-box :v-thresholds="address.thresholds"></node-ip-address-thresholds-box>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,7 +13,7 @@
 | 
				
			|||||||
        <tr>
 | 
					        <tr>
 | 
				
			||||||
            <td>IP地址 *</td>
 | 
					            <td>IP地址 *</td>
 | 
				
			||||||
            <td>
 | 
					            <td>
 | 
				
			||||||
                <node-ip-addresses-box role="dns"></node-ip-addresses-box>
 | 
					                <node-ip-addresses-box role="ns"></node-ip-addresses-box>
 | 
				
			||||||
                <p class="comment">用于访问节点和域名解析等。</p>
 | 
					                <p class="comment">用于访问节点和域名解析等。</p>
 | 
				
			||||||
            </td>
 | 
					            </td>
 | 
				
			||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@
 | 
				
			|||||||
        <tr>
 | 
					        <tr>
 | 
				
			||||||
            <td>IP地址 *</td>
 | 
					            <td>IP地址 *</td>
 | 
				
			||||||
            <td>
 | 
					            <td>
 | 
				
			||||||
                <node-ip-addresses-box :v-ip-addresses="node.ipAddresses"></node-ip-addresses-box>
 | 
					                <node-ip-addresses-box role="ns" :v-ip-addresses="node.ipAddresses"></node-ip-addresses-box>
 | 
				
			||||||
                <p class="comment">用于访问节点和域名解析等。</p>
 | 
					                <p class="comment">用于访问节点和域名解析等。</p>
 | 
				
			||||||
            </td>
 | 
					            </td>
 | 
				
			||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user