🐛 修复无法编辑已创建服务监控

This commit is contained in:
naiba 2021-04-22 22:18:55 +08:00
parent 585cf538d0
commit b69b069f27
6 changed files with 15 additions and 15 deletions

View File

@ -1,7 +1,7 @@
<div align="center" style="background-color: white"> <div align="center" style="background-color: white">
<img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控"> <img width="500" style="max-width:100%" src="https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.png" title="哪吒监控">
<br><br> <br><br>
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.6.3&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.4.10-brightgreen?style=for-the-badge&logo=linux"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.6.4&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.4.10-brightgreen?style=for-the-badge&logo=linux">
<br> <br>
<p>:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p> <p>:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。</p>
</div> </div>

View File

@ -201,8 +201,8 @@ function addOrEditMonitor(monitor) {
} }
var servers; var servers;
if (monitor) { if (monitor) {
servers = monitor.SkipServersRaw || "[]"; servers = monitor.SkipServersRaw;
const serverList = JSON.parse(servers); const serverList = JSON.parse(servers || "[]");
const node = modal.find("i.dropdown.icon"); const node = modal.find("i.dropdown.icon");
for (let i = 0; i < serverList.length; i++) { for (let i = 0; i < serverList.length; i++) {
node.after( node.after(
@ -237,7 +237,7 @@ function addOrEditCron(cron) {
var servers; var servers;
if (cron) { if (cron) {
servers = cron.ServersRaw; servers = cron.ServersRaw;
const serverList = JSON.parse(servers); const serverList = JSON.parse(servers || "[]");
const node = modal.find("i.dropdown.icon"); const node = modal.find("i.dropdown.icon");
for (let i = 0; i < serverList.length; i++) { for (let i = 0; i < serverList.length; i++) {
node.after( node.after(

View File

@ -9,7 +9,7 @@
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script> <script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js"></script>
<script src="/static/main.js?v202104222126"></script> <script src="/static/main.js?v202104222216"></script>
</body> </body>
</html> </html>

View File

@ -1,6 +1,5 @@
{{define "dashboard/monitor"}} {{define "dashboard/monitor"}} {{template "common/header" .}} {{template
{{template "common/header" .}} "common/menu" .}}
{{template "common/menu" .}}
<div class="nb-container"> <div class="nb-container">
<div class="ui container"> <div class="ui container">
<div class="ui grid"> <div class="ui grid">
@ -18,10 +17,10 @@
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>名称</th> <th>名称</th>
<th>通知</th>
<th>目标</th> <th>目标</th>
<th>类型</th>
<th>跳过的服务器</th> <th>跳过的服务器</th>
<th>类型</th>
<th>通知</th>
<th>管理</th> <th>管理</th>
</tr> </tr>
</thead> </thead>
@ -30,13 +29,13 @@
<tr> <tr>
<td>{{$monitor.ID}}</td> <td>{{$monitor.ID}}</td>
<td>{{$monitor.Name}}</td> <td>{{$monitor.Name}}</td>
<td>{{$monitor.Notify}}</td>
<td>{{$monitor.Target}}</td> <td>{{$monitor.Target}}</td>
<td>{{$monitor.SkipServersRaw}}</td>
<td> <td>
{{if eq $monitor.Type 1}}HTTP(S)/SSL证书 {{else if eq $monitor.Type {{if eq $monitor.Type 1}}HTTP(S)/SSL证书 {{else if eq $monitor.Type
2}} ICMP Ping {{else}} TCP 端口 {{end}} 2}} ICMP Ping {{else}} TCP 端口 {{end}}
</td> </td>
<td>{{$monitor.SkipServersRaw}}</td> <td>{{$monitor.Notify}}</td>
<td> <td>
<div class="ui mini icon buttons"> <div class="ui mini icon buttons">
<button <button
@ -59,8 +58,7 @@
</table> </table>
</div> </div>
</div> </div>
{{template "component/monitor"}} {{template "component/monitor"}} {{template "common/footer" .}}
{{template "common/footer" .}}
<script> <script>
$(".checkbox").checkbox(); $(".checkbox").checkbox();
</script> </script>

View File

@ -13,7 +13,7 @@ import (
pb "github.com/naiba/nezha/proto" pb "github.com/naiba/nezha/proto"
) )
var Version = "v0.6.3" // !!记得修改 README 中的 badge 版本!! var Version = "v0.6.4" // !!记得修改 README 中的 badge 版本!!
const ( const (
SnapshotDelay = 3 SnapshotDelay = 3

View File

@ -180,8 +180,10 @@ func (ss *ServiceSentinel) LoadStats() map[uint64]*model.ServiceItemResponse {
for i := 0; i < len(v); i++ { for i := 0; i < len(v); i++ {
if v[i].Successful { if v[i].Successful {
msm[k].Up[29]++ msm[k].Up[29]++
msm[k].TotalUp++
} else { } else {
msm[k].Down[29]++ msm[k].Down[29]++
msm[k].TotalDown++
} }
msm[k].Delay[29] = (msm[k].Delay[29]*float32(msm[k].Up[29]) + v[i].Delay) / float32(msm[k].Up[29]+1) msm[k].Delay[29] = (msm[k].Delay[29]*float32(msm[k].Up[29]) + v[i].Delay) / float32(msm[k].Up[29]+1)
} }