diff --git a/internal/web/actions/default/clusters/cluster/index.go b/internal/web/actions/default/clusters/cluster/index.go index 055bc670..30e61992 100644 --- a/internal/web/actions/default/clusters/cluster/index.go +++ b/internal/web/actions/default/clusters/cluster/index.go @@ -73,9 +73,10 @@ func (this *IndexAction) RunGet(params struct { ipAddresses := []maps.Map{} for _, addr := range ipAddressesResp.Addresses { ipAddresses = append(ipAddresses, maps.Map{ - "id": addr.Id, - "name": addr.Name, - "ip": addr.Ip, + "id": addr.Id, + "name": addr.Name, + "ip": addr.Ip, + "canAccess": addr.CanAccess, }) } diff --git a/internal/web/actions/default/clusters/cluster/node/node.go b/internal/web/actions/default/clusters/cluster/node/node.go index 3bfdc882..d4abc49e 100644 --- a/internal/web/actions/default/clusters/cluster/node/node.go +++ b/internal/web/actions/default/clusters/cluster/node/node.go @@ -60,9 +60,10 @@ func (this *NodeAction) RunGet(params struct { ipAddressMaps := []maps.Map{} for _, addr := range ipAddressesResp.Addresses { ipAddressMaps = append(ipAddressMaps, maps.Map{ - "id": addr.Id, - "name": addr.Name, - "ip": addr.Ip, + "id": addr.Id, + "name": addr.Name, + "ip": addr.Ip, + "canAccess": addr.CanAccess, }) } diff --git a/internal/web/actions/default/clusters/cluster/node/update.go b/internal/web/actions/default/clusters/cluster/node/update.go index 979a0800..6f2fa3d1 100644 --- a/internal/web/actions/default/clusters/cluster/node/update.go +++ b/internal/web/actions/default/clusters/cluster/node/update.go @@ -4,6 +4,7 @@ import ( "encoding/json" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/grants/grantutils" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/nodes/ipAddresses/ipaddressutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" @@ -51,9 +52,10 @@ func (this *UpdateAction) RunGet(params struct { ipAddressMaps := []maps.Map{} for _, addr := range ipAddressesResp.Addresses { ipAddressMaps = append(ipAddressMaps, maps.Map{ - "id": addr.Id, - "name": addr.Name, - "ip": addr.Ip, + "id": addr.Id, + "name": addr.Name, + "ip": addr.Ip, + "canAccess": addr.CanAccess, }) } @@ -128,16 +130,16 @@ func (this *UpdateAction) RunGet(params struct { } func (this *UpdateAction) RunPost(params struct { - LoginId int64 - NodeId int64 - Name string - IPAddresses string `alias:"ipAddresses"` - ClusterId int64 - GrantId int64 - SshHost string - SshPort int - MaxCPU int32 - IsOn bool + LoginId int64 + NodeId int64 + Name string + IPAddressesJSON []byte `alias:"ipAddressesJSON"` + ClusterId int64 + GrantId int64 + SshHost string + SshPort int + MaxCPU int32 + IsOn bool Must *actions.Must }) { @@ -188,23 +190,11 @@ func (this *UpdateAction) RunPost(params struct { } // 添加新的IP地址 - ipAddresses := []maps.Map{} - err = json.Unmarshal([]byte(params.IPAddresses), &ipAddresses) + err = ipaddressutils.UpdateNodeIPAddresses(this.Parent(), params.NodeId, params.IPAddressesJSON) if err != nil { this.ErrorPage(err) return } - for _, address := range ipAddresses { - addressId := address.GetInt64("id") - _, err = this.RPC().NodeIPAddressRPC().UpdateNodeIPAddressNodeId(this.AdminContext(), &pb.UpdateNodeIPAddressNodeIdRequest{ - AddressId: addressId, - NodeId: params.NodeId, - }) - if err != nil { - this.ErrorPage(err) - return - } - } this.Success() } diff --git a/internal/web/actions/default/clusters/cluster/settings/health.go b/internal/web/actions/default/clusters/cluster/settings/health.go new file mode 100644 index 00000000..e7ceaf1a --- /dev/null +++ b/internal/web/actions/default/clusters/cluster/settings/health.go @@ -0,0 +1,63 @@ +package settings + +import ( + "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/iwind/TeaGo/actions" +) + +type HealthAction struct { + actionutils.ParentAction +} + +func (this *HealthAction) Init() { + this.Nav("", "setting", "") + this.SecondMenu("health") +} + +func (this *HealthAction) RunGet(params struct { + ClusterId int64 +}) { + configResp, err := this.RPC().NodeClusterRPC().FindNodeClusterHealthCheckConfig(this.AdminContext(), &pb.FindNodeClusterHealthCheckConfigRequest{ClusterId: params.ClusterId}) + if err != nil { + this.ErrorPage(err) + return + } + var config *serverconfigs.HealthCheckConfig = nil + if len(configResp.HealthCheckConfig) > 0 { + config = &serverconfigs.HealthCheckConfig{} + err = json.Unmarshal(configResp.HealthCheckConfig, config) + if err != nil { + this.ErrorPage(err) + return + } + } + + this.Data["healthCheckConfig"] = config + this.Show() +} + +func (this *HealthAction) RunPost(params struct { + ClusterId int64 + HealthCheckJSON []byte + Must *actions.Must +}) { + config := &serverconfigs.HealthCheckConfig{} + err := json.Unmarshal(params.HealthCheckJSON, config) + if err != nil { + this.ErrorPage(err) + return + } + + _, err = this.RPC().NodeClusterRPC().UpdateNodeClusterHealthCheck(this.AdminContext(), &pb.UpdateNodeClusterHealthCheckRequest{ + ClusterId: params.ClusterId, + HealthCheckJSON: params.HealthCheckJSON, + }) + if err != nil { + this.ErrorPage(err) + return + } + this.Success() +} diff --git a/internal/web/actions/default/clusters/cluster/settings/healthRun.go b/internal/web/actions/default/clusters/cluster/settings/healthRun.go new file mode 100644 index 00000000..3c78eedf --- /dev/null +++ b/internal/web/actions/default/clusters/cluster/settings/healthRun.go @@ -0,0 +1,34 @@ +package settings + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/iwind/TeaGo/actions" +) + +type HealthRunAction struct { + actionutils.ParentAction +} + +func (this *HealthRunAction) Init() { + this.Nav("", "", "") +} + +func (this *HealthRunAction) RunGet(params struct{}) { + + this.Show() +} + +func (this *HealthRunAction) RunPost(params struct { + ClusterId int64 + + Must *actions.Must +}) { + resp, err := this.RPC().NodeClusterRPC().ExecuteNodeClusterHealthCheck(this.AdminContext(), &pb.ExecuteNodeClusterHealthCheckRequest{ClusterId: params.ClusterId}) + if err != nil { + this.Fail(err.Error()) + } + + this.Data["results"] = resp.Results + this.Success() +} diff --git a/internal/web/actions/default/clusters/cluster/settings/init.go b/internal/web/actions/default/clusters/cluster/settings/init.go index 6a0d2a34..2e160433 100644 --- a/internal/web/actions/default/clusters/cluster/settings/init.go +++ b/internal/web/actions/default/clusters/cluster/settings/init.go @@ -13,6 +13,8 @@ func init() { Helper(clusters.NewClusterHelper()). Prefix("/clusters/cluster/settings"). GetPost("", new(IndexAction)). + GetPost("/health", new(HealthAction)). + GetPost("/healthRun", new(HealthRunAction)). EndAll() }) } diff --git a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go index a73fb104..214a979a 100644 --- a/internal/web/actions/default/clusters/clusterutils/cluster_helper.go +++ b/internal/web/actions/default/clusters/clusterutils/cluster_helper.go @@ -84,5 +84,10 @@ func (this *ClusterHelper) createSettingMenu(clusterId string, selectedItem stri "url": "/clusters/cluster/settings?clusterId=" + clusterId, "isActive": selectedItem == "basic", }) + items = append(items, maps.Map{ + "name": "健康检查", + "url": "/clusters/cluster/settings/health?clusterId=" + clusterId, + "isActive": selectedItem == "health", + }) return } diff --git a/internal/web/actions/default/nodes/ipAddresses/createPopup.go b/internal/web/actions/default/nodes/ipAddresses/createPopup.go index b71a4c5d..323c1c44 100644 --- a/internal/web/actions/default/nodes/ipAddresses/createPopup.go +++ b/internal/web/actions/default/nodes/ipAddresses/createPopup.go @@ -1,10 +1,10 @@ package ipAddresses import ( - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" + "net" ) type CreatePopupAction struct { @@ -20,31 +20,28 @@ func (this *CreatePopupAction) RunGet(params struct{}) { } func (this *CreatePopupAction) RunPost(params struct { - IP string `alias:"ip"` - Name string + IP string `alias:"ip"` + CanAccess bool + Name string Must *actions.Must }) { // TODO 严格校验IP地址 + ip := net.ParseIP(params.IP) + if len(ip) == 0 { + this.Fail("请输入正确的IP") + } + params.Must. Field("ip", params.IP). Require("请输入IP地址") - resp, err := this.RPC().NodeIPAddressRPC().CreateNodeIPAddress(this.AdminContext(), &pb.CreateNodeIPAddressRequest{ - NodeId: 0, - Name: params.Name, - Ip: params.IP, - }) - if err != nil { - this.ErrorPage(err) - return - } - this.Data["ipAddress"] = maps.Map{ - "name": params.Name, - "ip": params.IP, - "id": resp.AddressId, + "name": params.Name, + "canAccess": params.CanAccess, + "ip": params.IP, + "id": 0, } this.Success() } diff --git a/internal/web/actions/default/nodes/ipAddresses/ipaddressutils/utils.go b/internal/web/actions/default/nodes/ipAddresses/ipaddressutils/utils.go new file mode 100644 index 00000000..e963fd40 --- /dev/null +++ b/internal/web/actions/default/nodes/ipAddresses/ipaddressutils/utils.go @@ -0,0 +1,42 @@ +package ipaddressutils + +import ( + "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" + "github.com/iwind/TeaGo/maps" +) + +// 保存一组IP地址 +func UpdateNodeIPAddresses(parentAction *actionutils.ParentAction, nodeId int64, ipAddressesJSON []byte) error { + addresses := []maps.Map{} + err := json.Unmarshal(ipAddressesJSON, &addresses) + if err != nil { + return err + } + for _, addr := range addresses { + addrId := addr.GetInt64("id") + if addrId > 0 { + _, err = parentAction.RPC().NodeIPAddressRPC().UpdateNodeIPAddress(parentAction.AdminContext(), &pb.UpdateNodeIPAddressRequest{ + AddressId: addrId, + Ip: addr.GetString("ip"), + Name: addr.GetString("name"), + CanAccess: addr.GetBool("canAccess"), + }) + if err != nil { + return err + } + } else { + _, err = parentAction.RPC().NodeIPAddressRPC().CreateNodeIPAddress(parentAction.AdminContext(), &pb.CreateNodeIPAddressRequest{ + NodeId: nodeId, + Name: addr.GetString("name"), + Ip: addr.GetString("ip"), + CanAccess: addr.GetBool("canAccess"), + }) + if err != nil { + return err + } + } + } + return nil +} diff --git a/internal/web/actions/default/nodes/ipAddresses/updatePopup.go b/internal/web/actions/default/nodes/ipAddresses/updatePopup.go index 3f79f99f..ba218975 100644 --- a/internal/web/actions/default/nodes/ipAddresses/updatePopup.go +++ b/internal/web/actions/default/nodes/ipAddresses/updatePopup.go @@ -1,10 +1,10 @@ package ipAddresses import ( - "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" + "net" ) type UpdatePopupAction struct { @@ -18,23 +18,6 @@ func (this *UpdatePopupAction) Init() { func (this *UpdatePopupAction) RunGet(params struct { AddressId int64 }) { - addressResp, err := this.RPC().NodeIPAddressRPC().FindEnabledNodeIPAddress(this.AdminContext(), &pb.FindEnabledNodeIPAddressRequest{AddressId: params.AddressId}) - if err != nil { - this.ErrorPage(err) - return - } - address := addressResp.IpAddress - if address == nil { - this.WriteString("找不到要修改的IP地址") - return - } - - this.Data["address"] = maps.Map{ - "id": address.Id, - "name": address.Name, - "ip": address.Ip, - } - this.Show() } @@ -42,6 +25,7 @@ func (this *UpdatePopupAction) RunPost(params struct { AddressId int64 IP string `alias:"ip"` Name string + CanAccess bool Must *actions.Must }) { @@ -51,20 +35,16 @@ func (this *UpdatePopupAction) RunPost(params struct { Field("ip", params.IP). Require("请输入IP地址") - _, err := this.RPC().NodeIPAddressRPC().UpdateNodeIPAddress(this.AdminContext(), &pb.UpdateNodeIPAddressRequest{ - AddressId: params.AddressId, - Name: params.Name, - Ip: params.IP, - }) - if err != nil { - this.ErrorPage(err) - return + ip := net.ParseIP(params.IP) + if len(ip) == 0 { + this.Fail("请输入正确的IP") } this.Data["ipAddress"] = maps.Map{ - "name": params.Name, - "ip": params.IP, - "id": params.AddressId, + "name": params.Name, + "ip": params.IP, + "id": params.AddressId, + "canAccess": params.CanAccess, } this.Success() diff --git a/web/public/js/components/common/health-check-config-box.js b/web/public/js/components/common/health-check-config-box.js new file mode 100644 index 00000000..775b2d95 --- /dev/null +++ b/web/public/js/components/common/health-check-config-box.js @@ -0,0 +1,168 @@ +Vue.component("health-check-config-box", { + props: ["v-health-check-config"], + data: function () { + let healthCheckConfig = this.vHealthCheckConfig + let urlProtocol = "http" + let urlPort = "" + let urlRequestURI = "/" + + if (healthCheckConfig == null) { + healthCheckConfig = { + isOn: false, + url: "", + interval: {count: 60, unit: "second"}, + statusCodes: [200], + timeout: {count: 10, unit: "second"}, + countTries: 3, + tryDelay: {count: 100, unit: "ms"} + } + let that = this + setTimeout(function () { + that.changeURL() + }, 500) + } else { + let url = new URL(healthCheckConfig.url) + urlProtocol = url.protocol.substring(0, url.protocol.length - 1) + urlPort = url.port + urlRequestURI = url.pathname + if (url.search.length > 0) { + urlRequestURI += url.search + } + } + return { + healthCheck: healthCheckConfig, + advancedVisible: false, + urlProtocol: urlProtocol, + urlPort: urlPort, + urlRequestURI: urlRequestURI + } + }, + watch: { + urlRequestURI: function () { + if (this.urlRequestURI.length > 0 && this.urlRequestURI[0] != "/") { + this.urlRequestURI = "/" + this.urlRequestURI + } + this.changeURL() + }, + urlPort: function (v) { + let port = parseInt(v) + if (!isNaN(port)) { + this.urlPort = port.toString() + } else { + this.urlPort = "" + } + this.changeURL() + }, + urlProtocol: function () { + this.changeURL() + }, + "healthCheck.countTries": function (v) { + let count = parseInt(v) + if (!isNaN(count)) { + this.healthCheck.countTries = count + } else { + this.healthCheck.countTries = 0 + } + } + }, + methods: { + showAdvanced: function () { + this.advancedVisible = !this.advancedVisible + }, + changeURL: function () { + this.healthCheck.url = this.urlProtocol + "://${host}" + ((this.urlPort.length > 0) ? ":" + this.urlPort : "") + this.urlRequestURI + }, + changeStatus: function (values) { + this.healthCheck.statusCodes = values.$map(function (k, v) { + let status = parseInt(v) + if (isNaN(status)) { + return 0 + } else { + return status + } + }) + console.log(this.healthCheck.statusCodes) + } + }, + template: `
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
是否启用 +
+ + +
+
URL * +
+
+ +
+
+ \${host} +
+
:
+
+ +
+
+ +
+
+
+

拼接后的URL:{{healthCheck.url}},其中\${host}指的是节点地址。

+
检测时间间隔 + +
允许的状态码 + +
超时时间 + +
连续尝试次数 + +
每次尝试间隔 + +
+
+
` +}) \ No newline at end of file diff --git a/web/public/js/components/common/values-box.js b/web/public/js/components/common/values-box.js index baeb6442..0262305d 100644 --- a/web/public/js/components/common/values-box.js +++ b/web/public/js/components/common/values-box.js @@ -37,10 +37,12 @@ Vue.component("values-box", { } else { this.vValues.push(this.value); } - this.cancel(); + this.cancel() + this.$emit("change", this.vValues) }, remove: function (index) { - this.vValues.$remove(index); + this.vValues.$remove(index) + this.$emit("change", this.vValues) }, cancel: function () { this.isUpdating = false; diff --git a/web/public/js/components/node/node-ip-addresses-box.js b/web/public/js/components/node/node-ip-addresses-box.js index a1111176..c2003ec4 100644 --- a/web/public/js/components/node/node-ip-addresses-box.js +++ b/web/public/js/components/node/node-ip-addresses-box.js @@ -8,6 +8,8 @@ Vue.component("node-ip-addresses-box", { methods: { // 添加IP地址 addIPAddress: function () { + window.UPDATING_NODE_IP_ADDRESS = null + let that = this; teaweb.popup("/nodes/ipAddresses/createPopup", { callback: function (resp) { @@ -18,8 +20,10 @@ Vue.component("node-ip-addresses-box", { // 修改地址 updateIPAddress: function (index, address) { + window.UPDATING_NODE_IP_ADDRESS = address + let that = this; - teaweb.popup("/nodes/ipAddresses/updatePopup?addressId=" + address.id, { + teaweb.popup("/nodes/ipAddresses/updatePopup", { callback: function (resp) { Vue.set(that.ipAddresses, index, resp.data.ipAddress); } @@ -32,11 +36,13 @@ Vue.component("node-ip-addresses-box", { } }, template: `
- +
- {{address.ip}}({{address.name}}) + {{address.ip}} + ({{address.name}},不可访问 + (不可访问)
@@ -46,6 +52,5 @@ Vue.component("node-ip-addresses-box", {
-

添加已经绑定的IP地址,仅做记录用。

` }) \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/index.html b/web/views/@default/clusters/cluster/index.html index 73eda244..6c218d0b 100644 --- a/web/views/@default/clusters/cluster/index.html +++ b/web/views/@default/clusters/cluster/index.html @@ -1,7 +1,5 @@ {$layout} -{$template "/left_menu"} -
{$template "menu"}
@@ -61,7 +59,10 @@ -
-
{{addr.ip}} ({{addr.name}})
+
{{addr.ip}} + ({{addr.name}},不可访问 + (不可访问) +
@@ -98,5 +99,4 @@ -
-
\ No newline at end of file +
\ No newline at end of file diff --git a/web/views/@default/clusters/cluster/installNodes.html b/web/views/@default/clusters/cluster/installNodes.html index ba06d008..858f4cbf 100644 --- a/web/views/@default/clusters/cluster/installNodes.html +++ b/web/views/@default/clusters/cluster/installNodes.html @@ -1,7 +1,5 @@ {$layout} -{$template "/left_menu"} -
{$template "menu"}

可以通过节点安装包中的configs/cluster.yaml直接自动注册节点。

@@ -16,5 +14,4 @@ clusterId: "{{cluster.uniqueId}}" secret: "{{cluster.secret}}" -
-
\ No newline at end of file + \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/node/@node_menu.html b/web/views/@default/clusters/cluster/node/@node_menu.html index 42b1f6ed..ec4f1176 100644 --- a/web/views/@default/clusters/cluster/node/@node_menu.html +++ b/web/views/@default/clusters/cluster/node/@node_menu.html @@ -1,4 +1,6 @@ + 节点列表 + | 节点详情 运行日志 修改设置 diff --git a/web/views/@default/clusters/cluster/node/create.html b/web/views/@default/clusters/cluster/node/create.html index c0184e89..08ace998 100644 --- a/web/views/@default/clusters/cluster/node/create.html +++ b/web/views/@default/clusters/cluster/node/create.html @@ -1,7 +1,5 @@ {$layout} -{$template "/left_menu"} -
{$template "/clusters/cluster/menu"} @@ -41,5 +39,4 @@ - -
\ No newline at end of file + \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/node/install.html b/web/views/@default/clusters/cluster/node/install.html index fe1e4658..d132693f 100644 --- a/web/views/@default/clusters/cluster/node/install.html +++ b/web/views/@default/clusters/cluster/node/install.html @@ -1,7 +1,5 @@ {$layout} -{$template "/left_menu"} -
{$template "node_menu"} @@ -53,5 +51,4 @@ secret: "{{node.secret}}" [修改为已安装状态] -
-
\ No newline at end of file +
\ No newline at end of file diff --git a/web/views/@default/clusters/cluster/node/logs.html b/web/views/@default/clusters/cluster/node/logs.html index 05f40852..c938db9a 100644 --- a/web/views/@default/clusters/cluster/node/logs.html +++ b/web/views/@default/clusters/cluster/node/logs.html @@ -1,7 +1,5 @@ {$layout} -{$template "/left_menu"} -
{$template "node_menu"}

暂时还没有日志。

@@ -19,5 +17,4 @@ -
-
\ No newline at end of file +
\ No newline at end of file diff --git a/web/views/@default/clusters/cluster/node/node.html b/web/views/@default/clusters/cluster/node/node.html index 6ac337c4..3283b96f 100644 --- a/web/views/@default/clusters/cluster/node/node.html +++ b/web/views/@default/clusters/cluster/node/node.html @@ -1,7 +1,5 @@ {$layout} -{$template "/left_menu"} -
{$template "node_menu"}

节点详情

@@ -19,8 +17,10 @@
-
- {{address.ip}}({{address.name}}) +
+ {{address.ip}} + ({{address.name}},不可访问 + (不可访问)
@@ -97,5 +97,4 @@ 未安装 - -
\ No newline at end of file + \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/node/update.html b/web/views/@default/clusters/cluster/node/update.html index f48e7b62..b78ca6e8 100644 --- a/web/views/@default/clusters/cluster/node/update.html +++ b/web/views/@default/clusters/cluster/node/update.html @@ -1,7 +1,5 @@ {$layout} -{$template "/left_menu"} -
{$template "node_menu"}

修改节点

@@ -76,5 +74,4 @@ - -
\ No newline at end of file + \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/settings/health.html b/web/views/@default/clusters/cluster/settings/health.html new file mode 100644 index 00000000..358251db --- /dev/null +++ b/web/views/@default/clusters/cluster/settings/health.html @@ -0,0 +1,10 @@ +{$layout} +{$template "/left_menu"} + +
+
+ + +   立即检查 +
+
\ No newline at end of file diff --git a/web/views/@default/clusters/cluster/settings/health.js b/web/views/@default/clusters/cluster/settings/health.js new file mode 100644 index 00000000..e0535afb --- /dev/null +++ b/web/views/@default/clusters/cluster/settings/health.js @@ -0,0 +1,11 @@ +Tea.context(function () { + this.success = NotifyReloadSuccess("保存成功") + + this.run = function () { + teaweb.confirm("确定要对当前集群下的所有节点进行健康检查吗?", function () { + teaweb.popup("/clusters/cluster/settings/healthRun?clusterId=" + this.clusterId, { + + }) + }) + } +}) \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/settings/healthRun.html b/web/views/@default/clusters/cluster/settings/healthRun.html new file mode 100644 index 00000000..2e0b8430 --- /dev/null +++ b/web/views/@default/clusters/cluster/settings/healthRun.html @@ -0,0 +1,27 @@ +{$layout "layout_popup"} + +

健康检查

+ +正在执行中,请等待执行完毕... + +
+

成功节点:{{countSuccess}}   失败节点:{{countFail}}

+ + + + + + + + + + + + + +
节点结果耗时
{{result.node.name}}({{result.nodeAddr}}) + 失败:{{result.error}} + 成功 + {{result.costMs}}ms
+ +
\ No newline at end of file diff --git a/web/views/@default/clusters/cluster/settings/healthRun.js b/web/views/@default/clusters/cluster/settings/healthRun.js new file mode 100644 index 00000000..ea25e1e8 --- /dev/null +++ b/web/views/@default/clusters/cluster/settings/healthRun.js @@ -0,0 +1,39 @@ +Tea.context(function () { + this.success = NotifyPopup + + this.isRequesting = false + this.results = [] + this.countSuccess = 0 + this.countFail = 0 + + this.$delay(function () { + this.run() + }) + + this.run = function () { + this.isRequesting = true + + this.$post("$") + .params({ + clusterId: this.clusterId + }) + .success(function (resp) { + this.results = resp.data.results + let that = this + this.results.forEach(function (v) { + v.costMs = Math.ceil(v.costMs) + if (isNaN(v.costMs)) { + v.costMs = 0 + } + if (v.isOk) { + that.countSuccess++ + } else { + that.countFail++ + } + }) + }) + .done(function () { + this.isRequesting = false + }) + } +}) \ No newline at end of file diff --git a/web/views/@default/nodes/ipAddresses/createPopup.html b/web/views/@default/nodes/ipAddresses/createPopup.html index 010bbc0e..70e344f6 100644 --- a/web/views/@default/nodes/ipAddresses/createPopup.html +++ b/web/views/@default/nodes/ipAddresses/createPopup.html @@ -10,6 +10,16 @@ + + 是否可以访问 + +
+ + +
+

是否为可以公开访问的IP。

+ + 备注 diff --git a/web/views/@default/nodes/ipAddresses/updatePopup.html b/web/views/@default/nodes/ipAddresses/updatePopup.html index 7457487a..3babc00a 100644 --- a/web/views/@default/nodes/ipAddresses/updatePopup.html +++ b/web/views/@default/nodes/ipAddresses/updatePopup.html @@ -11,6 +11,16 @@ + + 是否可以访问 + +
+ + +
+

是否为可以公开访问的IP。

+ + 备注 diff --git a/web/views/@default/nodes/ipAddresses/updatePopup.js b/web/views/@default/nodes/ipAddresses/updatePopup.js index 277e82e3..cd35c2f6 100644 --- a/web/views/@default/nodes/ipAddresses/updatePopup.js +++ b/web/views/@default/nodes/ipAddresses/updatePopup.js @@ -1,3 +1,5 @@ -Tea.context(function (){ +Tea.context(function () { this.success = NotifyPopup; + + this.address = window.parent.UPDATING_NODE_IP_ADDRESS }); \ No newline at end of file