mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
up(notification): 添加修改删除通知、报警规则
This commit is contained in:
@@ -70,6 +70,21 @@ function showFormModal(modelSelector, formID, URL, getData) {
|
||||
}).modal('show')
|
||||
}
|
||||
|
||||
function addOrEditAlertRule(rule) {
|
||||
const modal = $('.rule.modal')
|
||||
modal.children('.header').text((rule ? '修改' : '添加') + '报警规则')
|
||||
modal.find('.positive.button').html(rule ? '修改<i class="edit icon"></i>' : '添加<i class="add icon"></i>')
|
||||
modal.find('input[name=ID]').val(rule ? rule.ID : null)
|
||||
modal.find('input[name=Name]').val(rule ? rule.Name : null)
|
||||
modal.find('textarea[name=RulesRaw]').val(rule ? rule.RulesRaw : null)
|
||||
if (rule && rule.Enable) {
|
||||
modal.find('.ui.rule-enable.checkbox').checkbox('set checked')
|
||||
} else {
|
||||
modal.find('.ui.rule-enable.checkbox').checkbox('set unchecked')
|
||||
}
|
||||
showFormModal('.rule.modal', '#ruleForm', '/api/alert-rule')
|
||||
}
|
||||
|
||||
function addOrEditNotification(notification) {
|
||||
const modal = $('.notification.modal')
|
||||
modal.children('.header').text((notification ? '修改' : '添加') + '通知方式')
|
||||
@@ -81,9 +96,9 @@ function addOrEditNotification(notification) {
|
||||
modal.find('select[name=RequestMethod]').val(notification ? notification.RequestMethod : 1)
|
||||
modal.find('select[name=RequestType]').val(notification ? notification.RequestType : 1)
|
||||
if (notification && notification.VerifySSL) {
|
||||
modal.find('.ui.checkbox').checkbox('set checked')
|
||||
modal.find('.ui.nf-ssl.checkbox').checkbox('set checked')
|
||||
} else {
|
||||
modal.find('.ui.checkbox').checkbox('set unchecked')
|
||||
modal.find('.ui.nf-ssl.checkbox').checkbox('set unchecked')
|
||||
}
|
||||
showFormModal('.notification.modal', '#notificationForm', '/api/notification')
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<textarea name="RequestBody"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<div class="ui nf-ssl checkbox">
|
||||
<input name="VerifySSL" type="checkbox" tabindex="0" class="hidden">
|
||||
<label>验证SSL</label>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{{define "component/rule"}}
|
||||
<div class="ui tiny notification modal transition hidden">
|
||||
<div class="ui tiny rule modal transition hidden">
|
||||
<div class="header">添加通知规则</div>
|
||||
<div class="content">
|
||||
<form id="notificationForm" class="ui form">
|
||||
<form id="ruleForm" class="ui form">
|
||||
<input type="hidden" name="ID">
|
||||
<div class="field">
|
||||
<label>备注</label>
|
||||
@@ -10,11 +10,11 @@
|
||||
</div>
|
||||
<div class="secret field">
|
||||
<label>规则</label>
|
||||
<textarea name="RequestBody"></textarea>
|
||||
<textarea name="RulesRaw"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox">
|
||||
<input name="VerifySSL" type="checkbox" tabindex="0" class="hidden">
|
||||
<div class="ui rule-enable checkbox">
|
||||
<input name="Enable" type="checkbox" tabindex="0" class="hidden">
|
||||
<label>启用</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<th>ID</th>
|
||||
<th>备注</th>
|
||||
<th>URL</th>
|
||||
<th>验证SSL</th>
|
||||
<th>管理</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -25,6 +26,7 @@
|
||||
<td>{{$notification.ID}}</td>
|
||||
<td>{{$notification.Name}}</td>
|
||||
<td>{{$notification.URL}}</td>
|
||||
<td>{{$notification.VerifySSL}}</td>
|
||||
<td>
|
||||
<div class="ui mini icon buttons">
|
||||
<button class="ui button" onclick="addOrEditNotification({{$notification}})">
|
||||
@@ -42,8 +44,9 @@
|
||||
</table>
|
||||
<div class="ui grid">
|
||||
<div class="right floated right aligned twelve wide column">
|
||||
<button class="ui right labeled positive icon button" onclick="addOrEditNotification()"><i
|
||||
class="add icon"></i> 添加报警规则
|
||||
<button class="ui right labeled positive icon button" onclick="addOrEditAlertRule()"><i
|
||||
class="add icon"></i>
|
||||
添加报警规则
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -52,23 +55,25 @@
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>备注</th>
|
||||
<th>URL</th>
|
||||
<th>规则</th>
|
||||
<th>启用</th>
|
||||
<th>管理</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range $notification := .Notifications}}
|
||||
{{range $rule := .AlertRules}}
|
||||
<tr>
|
||||
<td>{{$notification.ID}}</td>
|
||||
<td>{{$notification.Name}}</td>
|
||||
<td>{{$notification.URL}}</td>
|
||||
<td>{{$rule.ID}}</td>
|
||||
<td>{{$rule.Name}}</td>
|
||||
<td>{{$rule.RulesRaw}}</td>
|
||||
<td>{{$rule.Enable}}</td>
|
||||
<td>
|
||||
<div class="ui mini icon buttons">
|
||||
<button class="ui button" onclick="addOrEditNotification({{$notification}})">
|
||||
<button class="ui button" onclick="addOrEditAlertRule({{$rule}})">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui button"
|
||||
onclick="showConfirm('删除通知方式','确认删除此通知方式?',deleteRequest,'/api/notification/'+{{$notification.ID}})">
|
||||
onclick="showConfirm('删除通知方式','确认删除此通知方式?',deleteRequest,'/api/alert-rule/'+{{$rule.ID}})">
|
||||
<i class="delete icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -78,9 +83,9 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{template "component/notification"}}
|
||||
{{template "component/rule"}}
|
||||
{{template "common/footer" .}}
|
||||
<script>
|
||||
$('.checkbox').checkbox()
|
||||
|
||||
Reference in New Issue
Block a user