diff --git a/internal/web/actions/default/ui/components.go b/internal/web/actions/default/ui/components.go index 3efd92cf..947af66f 100644 --- a/internal/web/actions/default/ui/components.go +++ b/internal/web/actions/default/ui/components.go @@ -103,7 +103,7 @@ func (this *ComponentsAction) RunGet(params struct{}) { buffer.Write([]byte{'\n', '\n'}) } - // IP地址阈值 + // IP地址阈值项目 ipAddrThresholdItemsJSON, err := json.Marshal(nodeconfigs.FindAllIPAddressThresholdItems()) if err != nil { logs.Println("ComponentsAction marshal ip addr threshold items failed: " + err.Error()) @@ -113,6 +113,16 @@ func (this *ComponentsAction) RunGet(params struct{}) { buffer.Write([]byte{'\n', '\n'}) } + // IP地址阈值动作 + ipAddrThresholdActionsJSON, err := json.Marshal(nodeconfigs.FindAllIPAddressThresholdActions()) + if err != nil { + logs.Println("ComponentsAction marshal ip addr threshold actions failed: " + err.Error()) + } else { + buffer.WriteString("window.IP_ADDR_THRESHOLD_ACTIONS = ") + buffer.Write(ipAddrThresholdActionsJSON) + buffer.Write([]byte{'\n', '\n'}) + } + componentsData = buffer.Bytes() // ETag diff --git a/web/public/js/components/node/node-ip-address-thresholds-box.js b/web/public/js/components/node/node-ip-address-thresholds-box.js index 94f60f3f..d7cad0b2 100644 --- a/web/public/js/components/node/node-ip-address-thresholds-box.js +++ b/web/public/js/components/node/node-ip-address-thresholds-box.js @@ -55,31 +55,11 @@ Vue.component("node-ip-address-thresholds-box", { "code": "gte" } ], - allActions: [ - { - "name": "上线", - "code": "up", - "description": "上线当前IP。" - }, - { - "name": "下线", - "code": "down", - "description": "下线当前IP。" - }, - { - "name": "通知", - "code": "notify", - "description": "发送已达到阈值通知。" - }, - { - "name": "切换", - "code": "switch", - "description": "在DNS中记录中将IP切换到指定的备用IP。" - }, - ], + allActions: window.IP_ADDR_THRESHOLD_ACTIONS, actionCode: "up", - actionBackupIPs: "" + actionBackupIPs: "", + actionWebHookURL: "" } }, methods: { @@ -262,6 +242,7 @@ Vue.component("node-ip-address-thresholds-box", { this.isAddingAction = false this.actionCode = "up" this.actionBackupIPs = "" + this.actionWebHookURL = "" }, confirmAction: function () { this.doConfirmAction(false) @@ -310,6 +291,20 @@ Vue.component("node-ip-address-thresholds-box", { return } break + case "webHook": + if (this.actionWebHookURL.length ==0) { + teaweb.warn("请输入WebHook URL", function () { + that.$refs.webHookURL.focus() + }) + return + } + if (!this.actionWebHookURL.match(/^(http|https):\/\//i)) { + teaweb.warn("URL开头必须是http://或者https://", function () { + that.$refs.webHookURL.focus() + }) + return + } + options["url"] = this.actionWebHookURL } this.addingThreshold.actions.push({ @@ -348,6 +343,7 @@ Vue.component("node-ip-address-thresholds-box", { -> {{actionName(action.action)}} 到{{action.options.ips.join(", ")}} + ({{action.options.url}}) AND @@ -439,6 +435,7 @@ Vue.component("node-ip-address-thresholds-box", {
@@ -455,6 +452,8 @@ Vue.component("node-ip-address-thresholds-box", {{{action.description}}
+ +每行一个备用IP。
完整的URL,比如