v0.15.1 批量删除服务器 bulk delete the servers
This commit is contained in:
		
							parent
							
								
									42c038c829
								
							
						
					
					
						commit
						45e26f4082
					
				@ -4,7 +4,7 @@
 | 
				
			|||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
 | 
					  <small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
 | 
				
			||||||
  <br><br>
 | 
					  <br><br>
 | 
				
			||||||
<img src="https://img.shields.io/github/actions/workflow/status/naiba/nezha/dashboard.yml?branch=master&label=Dash%20v0.15.0&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?branch=v0.15.0&label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.15.0-brightgreen?style=for-the-badge&logo=linux">
 | 
					<img src="https://img.shields.io/github/actions/workflow/status/naiba/nezha/dashboard.yml?branch=master&label=Dash%20v0.15.1&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?branch=v0.15.1&label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.15.0-brightgreen?style=for-the-badge&logo=linux">
 | 
				
			||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
 | 
					  <p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
 | 
				
			||||||
 | 
				
			|||||||
@ -41,6 +41,7 @@ func (ma *memberAPI) serve() {
 | 
				
			|||||||
	mr.GET("/cron/:id/manual", ma.manualTrigger)
 | 
						mr.GET("/cron/:id/manual", ma.manualTrigger)
 | 
				
			||||||
	mr.POST("/force-update", ma.forceUpdate)
 | 
						mr.POST("/force-update", ma.forceUpdate)
 | 
				
			||||||
	mr.POST("/batch-update-server-group", ma.batchUpdateServerGroup)
 | 
						mr.POST("/batch-update-server-group", ma.batchUpdateServerGroup)
 | 
				
			||||||
 | 
						mr.POST("/batch-delete-server", ma.batchDeleteServer)
 | 
				
			||||||
	mr.POST("/notification", ma.addOrEditNotification)
 | 
						mr.POST("/notification", ma.addOrEditNotification)
 | 
				
			||||||
	mr.POST("/alert-rule", ma.addOrEditAlertRule)
 | 
						mr.POST("/alert-rule", ma.addOrEditAlertRule)
 | 
				
			||||||
	mr.POST("/setting", ma.updateSetting)
 | 
						mr.POST("/setting", ma.updateSetting)
 | 
				
			||||||
@ -187,37 +188,9 @@ func (ma *memberAPI) delete(c *gin.Context) {
 | 
				
			|||||||
		if err == nil {
 | 
							if err == nil {
 | 
				
			||||||
			// 删除服务器
 | 
								// 删除服务器
 | 
				
			||||||
			singleton.ServerLock.Lock()
 | 
								singleton.ServerLock.Lock()
 | 
				
			||||||
			tag := singleton.ServerList[id].Tag
 | 
								onServerDelete(id)
 | 
				
			||||||
			delete(singleton.SecretToID, singleton.ServerList[id].Secret)
 | 
					 | 
				
			||||||
			delete(singleton.ServerList, id)
 | 
					 | 
				
			||||||
			index := -1
 | 
					 | 
				
			||||||
			for i := 0; i < len(singleton.ServerTagToIDList[tag]); i++ {
 | 
					 | 
				
			||||||
				if singleton.ServerTagToIDList[tag][i] == id {
 | 
					 | 
				
			||||||
					index = i
 | 
					 | 
				
			||||||
					break
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if index > -1 {
 | 
					 | 
				
			||||||
				// 删除旧 Tag-ID 绑定关系
 | 
					 | 
				
			||||||
				singleton.ServerTagToIDList[tag] = append(singleton.ServerTagToIDList[tag][:index], singleton.ServerTagToIDList[tag][index+1:]...)
 | 
					 | 
				
			||||||
				if len(singleton.ServerTagToIDList[tag]) == 0 {
 | 
					 | 
				
			||||||
					delete(singleton.ServerTagToIDList, tag)
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			singleton.ServerLock.Unlock()
 | 
								singleton.ServerLock.Unlock()
 | 
				
			||||||
			singleton.ReSortServer()
 | 
								singleton.ReSortServer()
 | 
				
			||||||
			// 删除循环流量状态中的此服务器相关的记录
 | 
					 | 
				
			||||||
			singleton.AlertsLock.Lock()
 | 
					 | 
				
			||||||
			for i := 0; i < len(singleton.Alerts); i++ {
 | 
					 | 
				
			||||||
				if singleton.AlertsCycleTransferStatsStore[singleton.Alerts[i].ID] != nil {
 | 
					 | 
				
			||||||
					delete(singleton.AlertsCycleTransferStatsStore[singleton.Alerts[i].ID].ServerName, id)
 | 
					 | 
				
			||||||
					delete(singleton.AlertsCycleTransferStatsStore[singleton.Alerts[i].ID].Transfer, id)
 | 
					 | 
				
			||||||
					delete(singleton.AlertsCycleTransferStatsStore[singleton.Alerts[i].ID].NextUpdate, id)
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			singleton.AlertsLock.Unlock()
 | 
					 | 
				
			||||||
			// 删除服务器相关循环流量记录
 | 
					 | 
				
			||||||
			singleton.DB.Unscoped().Delete(&model.Transfer{}, "server_id = ?", id)
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	case "notification":
 | 
						case "notification":
 | 
				
			||||||
		err = singleton.DB.Unscoped().Delete(&model.Notification{}, "id = ?", id).Error
 | 
							err = singleton.DB.Unscoped().Delete(&model.Notification{}, "id = ?", id).Error
 | 
				
			||||||
@ -446,10 +419,12 @@ func (ma *memberAPI) addOrEditMonitor(c *gin.Context) {
 | 
				
			|||||||
		if err == nil {
 | 
							if err == nil {
 | 
				
			||||||
			err = utils.Json.Unmarshal([]byte(mf.RecoverTriggerTasksRaw), &m.RecoverTriggerTasks)
 | 
								err = utils.Json.Unmarshal([]byte(mf.RecoverTriggerTasksRaw), &m.RecoverTriggerTasks)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if m.ID == 0 {
 | 
							if err == nil {
 | 
				
			||||||
			err = singleton.DB.Create(&m).Error
 | 
								if m.ID == 0 {
 | 
				
			||||||
		} else {
 | 
									err = singleton.DB.Create(&m).Error
 | 
				
			||||||
			err = singleton.DB.Save(&m).Error
 | 
								} else {
 | 
				
			||||||
 | 
									err = singleton.DB.Save(&m).Error
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if err == nil {
 | 
						if err == nil {
 | 
				
			||||||
@ -933,3 +908,63 @@ func (ma *memberAPI) updateSetting(c *gin.Context) {
 | 
				
			|||||||
		Code: http.StatusOK,
 | 
							Code: http.StatusOK,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (ma *memberAPI) batchDeleteServer(c *gin.Context) {
 | 
				
			||||||
 | 
						var servers []uint64
 | 
				
			||||||
 | 
						if err := c.ShouldBindJSON(&servers); err != nil {
 | 
				
			||||||
 | 
							c.JSON(http.StatusOK, model.Response{
 | 
				
			||||||
 | 
								Code:    http.StatusBadRequest,
 | 
				
			||||||
 | 
								Message: err.Error(),
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if err := singleton.DB.Unscoped().Delete(&model.Server{}, "id in (?)", servers).Error; err != nil {
 | 
				
			||||||
 | 
							c.JSON(http.StatusOK, model.Response{
 | 
				
			||||||
 | 
								Code:    http.StatusBadRequest,
 | 
				
			||||||
 | 
								Message: err.Error(),
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						singleton.ServerLock.Lock()
 | 
				
			||||||
 | 
						for i := 0; i < len(servers); i++ {
 | 
				
			||||||
 | 
							id := servers[i]
 | 
				
			||||||
 | 
							onServerDelete(id)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						singleton.ServerLock.Unlock()
 | 
				
			||||||
 | 
						singleton.ReSortServer()
 | 
				
			||||||
 | 
						c.JSON(http.StatusOK, model.Response{
 | 
				
			||||||
 | 
							Code: http.StatusOK,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func onServerDelete(id uint64) {
 | 
				
			||||||
 | 
						tag := singleton.ServerList[id].Tag
 | 
				
			||||||
 | 
						delete(singleton.SecretToID, singleton.ServerList[id].Secret)
 | 
				
			||||||
 | 
						delete(singleton.ServerList, id)
 | 
				
			||||||
 | 
						index := -1
 | 
				
			||||||
 | 
						for i := 0; i < len(singleton.ServerTagToIDList[tag]); i++ {
 | 
				
			||||||
 | 
							if singleton.ServerTagToIDList[tag][i] == id {
 | 
				
			||||||
 | 
								index = i
 | 
				
			||||||
 | 
								break
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if index > -1 {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							singleton.ServerTagToIDList[tag] = append(singleton.ServerTagToIDList[tag][:index], singleton.ServerTagToIDList[tag][index+1:]...)
 | 
				
			||||||
 | 
							if len(singleton.ServerTagToIDList[tag]) == 0 {
 | 
				
			||||||
 | 
								delete(singleton.ServerTagToIDList, tag)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						singleton.AlertsLock.Lock()
 | 
				
			||||||
 | 
						for i := 0; i < len(singleton.Alerts); i++ {
 | 
				
			||||||
 | 
							if singleton.AlertsCycleTransferStatsStore[singleton.Alerts[i].ID] != nil {
 | 
				
			||||||
 | 
								delete(singleton.AlertsCycleTransferStatsStore[singleton.Alerts[i].ID].ServerName, id)
 | 
				
			||||||
 | 
								delete(singleton.AlertsCycleTransferStatsStore[singleton.Alerts[i].ID].Transfer, id)
 | 
				
			||||||
 | 
								delete(singleton.AlertsCycleTransferStatsStore[singleton.Alerts[i].ID].NextUpdate, id)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						singleton.AlertsLock.Unlock()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						singleton.DB.Unscoped().Delete(&model.Transfer{}, "server_id = ?", id)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										5
									
								
								resource/l10n/en-US.toml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								resource/l10n/en-US.toml
									
									
									
									
										vendored
									
									
								
							@ -202,6 +202,9 @@ other = "Add Server"
 | 
				
			|||||||
[BatchEditServerGroup]
 | 
					[BatchEditServerGroup]
 | 
				
			||||||
other = "Batch Modify Groups"
 | 
					other = "Batch Modify Groups"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[BatchDeleteServer]
 | 
				
			||||||
 | 
					other = "Batch Delete Server"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[InputServerGroupName]
 | 
					[InputServerGroupName]
 | 
				
			||||||
other = "Enter the name of the group"
 | 
					other = "Enter the name of the group"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -307,7 +310,7 @@ other = "Click To Copy"
 | 
				
			|||||||
[DeleteServer]
 | 
					[DeleteServer]
 | 
				
			||||||
other = "Delete Server"
 | 
					other = "Delete Server"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ConfirmToDeleteThisServer]
 | 
					[ConfirmToDeleteServer]
 | 
				
			||||||
other = "Confirm Delete?"
 | 
					other = "Confirm Delete?"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[NoServerSelected]
 | 
					[NoServerSelected]
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								resource/l10n/es-ES.toml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								resource/l10n/es-ES.toml
									
									
									
									
										vendored
									
									
								
							@ -202,6 +202,9 @@ other = "Añadir un servidor"
 | 
				
			|||||||
[BatchEditServerGroup]
 | 
					[BatchEditServerGroup]
 | 
				
			||||||
other = "Modificación de grupos por lotes"
 | 
					other = "Modificación de grupos por lotes"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[BatchDeleteServer]
 | 
				
			||||||
 | 
					other = "Batch Delete Server"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[InputServerGroupName]
 | 
					[InputServerGroupName]
 | 
				
			||||||
other = "Introduzca un nombre de grupo"
 | 
					other = "Introduzca un nombre de grupo"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -307,8 +310,8 @@ other = "Haga clic para copiar"
 | 
				
			|||||||
[DeleteServer]
 | 
					[DeleteServer]
 | 
				
			||||||
other = "Eliminar el servidor"
 | 
					other = "Eliminar el servidor"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ConfirmToDeleteThisServer]
 | 
					[ConfirmToDeleteServer]
 | 
				
			||||||
other = "¿Confirma que quiere eliminar este servidor?"
 | 
					other = "¿Confirma que quiere eliminar servidor?"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[NoServerSelected]
 | 
					[NoServerSelected]
 | 
				
			||||||
other = "No hay servidores seleccionados actualmente"
 | 
					other = "No hay servidores seleccionados actualmente"
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								resource/l10n/zh-CN.toml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								resource/l10n/zh-CN.toml
									
									
									
									
										vendored
									
									
								
							@ -202,6 +202,9 @@ other = "添加服务器"
 | 
				
			|||||||
[BatchEditServerGroup]
 | 
					[BatchEditServerGroup]
 | 
				
			||||||
other = "批量修改分组"
 | 
					other = "批量修改分组"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[BatchDeleteServer]
 | 
				
			||||||
 | 
					other = "批量删除服务器"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[InputServerGroupName]
 | 
					[InputServerGroupName]
 | 
				
			||||||
other = "输入分组名称"
 | 
					other = "输入分组名称"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -307,8 +310,8 @@ other = "点击复制"
 | 
				
			|||||||
[DeleteServer]
 | 
					[DeleteServer]
 | 
				
			||||||
other = "删除主机"
 | 
					other = "删除主机"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ConfirmToDeleteThisServer]
 | 
					[ConfirmToDeleteServer]
 | 
				
			||||||
other = "确认删除此主机?"
 | 
					other = "确认删除主机?"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[NoServerSelected]
 | 
					[NoServerSelected]
 | 
				
			||||||
other = "当前没有选中的服务器"
 | 
					other = "当前没有选中的服务器"
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								resource/l10n/zh-TW.toml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								resource/l10n/zh-TW.toml
									
									
									
									
										vendored
									
									
								
							@ -202,6 +202,9 @@ other = "添加服務器"
 | 
				
			|||||||
[BatchEditServerGroup]
 | 
					[BatchEditServerGroup]
 | 
				
			||||||
other = "批量修改分組"
 | 
					other = "批量修改分組"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[BatchDeleteServer]
 | 
				
			||||||
 | 
					other = "批量删除服务器"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[InputServerGroupName]
 | 
					[InputServerGroupName]
 | 
				
			||||||
other = "輸入分組名稱"
 | 
					other = "輸入分組名稱"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -307,8 +310,8 @@ other = "點擊複製"
 | 
				
			|||||||
[DeleteServer]
 | 
					[DeleteServer]
 | 
				
			||||||
other = "刪除主機"
 | 
					other = "刪除主機"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ConfirmToDeleteThisServer]
 | 
					[ConfirmToDeleteServer]
 | 
				
			||||||
other = "確認刪除此主機?"
 | 
					other = "確認刪除主機?"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[NoServerSelected]
 | 
					[NoServerSelected]
 | 
				
			||||||
other = "當前沒有選中的服務器"
 | 
					other = "當前沒有選中的服務器"
 | 
				
			||||||
 | 
				
			|||||||
@ -44,6 +44,30 @@ function showConfirm(title, content, callFn, extData) {
 | 
				
			|||||||
    .modal("show");
 | 
					    .modal("show");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function postJson(url, data) {
 | 
				
			||||||
 | 
					  return $.ajax({
 | 
				
			||||||
 | 
					    url: url,
 | 
				
			||||||
 | 
					    type: "POST",
 | 
				
			||||||
 | 
					    contentType: "application/json",
 | 
				
			||||||
 | 
					    data: JSON.stringify(data),
 | 
				
			||||||
 | 
					  }).done((resp) => {
 | 
				
			||||||
 | 
					    if (resp.code == 200) {
 | 
				
			||||||
 | 
					      if (resp.message) {
 | 
				
			||||||
 | 
					        alert(resp.message);
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        alert("删除成功");
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      window.location.reload();
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      alert("删除失败 " + resp.code + ":" + resp.message);
 | 
				
			||||||
 | 
					      confirmBtn.toggleClass("loading");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					    .fail((err) => {
 | 
				
			||||||
 | 
					      alert("网络错误:" + err.responseText);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function showFormModal(modelSelector, formID, URL, getData) {
 | 
					function showFormModal(modelSelector, formID, URL, getData) {
 | 
				
			||||||
  $(modelSelector)
 | 
					  $(modelSelector)
 | 
				
			||||||
    .modal({
 | 
					    .modal({
 | 
				
			||||||
@ -344,11 +368,11 @@ function addOrEditMonitor(monitor) {
 | 
				
			|||||||
    const node = modal.find("i.dropdown.icon.specificServer");
 | 
					    const node = modal.find("i.dropdown.icon.specificServer");
 | 
				
			||||||
    for (let i = 0; i < serverList.length; i++) {
 | 
					    for (let i = 0; i < serverList.length; i++) {
 | 
				
			||||||
      node.after(
 | 
					      node.after(
 | 
				
			||||||
          '<a class="ui label transition visible" data-value="' +
 | 
					        '<a class="ui label transition visible" data-value="' +
 | 
				
			||||||
          serverList[i] +
 | 
					        serverList[i] +
 | 
				
			||||||
          '" style="display: inline-block !important;">ID:' +
 | 
					        '" style="display: inline-block !important;">ID:' +
 | 
				
			||||||
          serverList[i] +
 | 
					        serverList[i] +
 | 
				
			||||||
          '<i class="delete icon"></i></a>'
 | 
					        '<i class="delete icon"></i></a>'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -360,31 +384,31 @@ function addOrEditMonitor(monitor) {
 | 
				
			|||||||
    const node2 = modal.find("i.dropdown.icon.recoverTask");
 | 
					    const node2 = modal.find("i.dropdown.icon.recoverTask");
 | 
				
			||||||
    for (let i = 0; i < failTriggerTasksList.length; i++) {
 | 
					    for (let i = 0; i < failTriggerTasksList.length; i++) {
 | 
				
			||||||
      node1.after(
 | 
					      node1.after(
 | 
				
			||||||
          '<a class="ui label transition visible" data-value="' +
 | 
					        '<a class="ui label transition visible" data-value="' +
 | 
				
			||||||
          failTriggerTasksList[i] +
 | 
					        failTriggerTasksList[i] +
 | 
				
			||||||
          '" style="display: inline-block !important;">ID:' +
 | 
					        '" style="display: inline-block !important;">ID:' +
 | 
				
			||||||
          failTriggerTasksList[i] +
 | 
					        failTriggerTasksList[i] +
 | 
				
			||||||
          '<i class="delete icon"></i></a>'
 | 
					        '<i class="delete icon"></i></a>'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (let i = 0; i < recoverTriggerTasksList.length; i++) {
 | 
					    for (let i = 0; i < recoverTriggerTasksList.length; i++) {
 | 
				
			||||||
      node2.after(
 | 
					      node2.after(
 | 
				
			||||||
          '<a class="ui label transition visible" data-value="' +
 | 
					        '<a class="ui label transition visible" data-value="' +
 | 
				
			||||||
          recoverTriggerTasksList[i] +
 | 
					        recoverTriggerTasksList[i] +
 | 
				
			||||||
          '" style="display: inline-block !important;">ID:' +
 | 
					        '" style="display: inline-block !important;">ID:' +
 | 
				
			||||||
          recoverTriggerTasksList[i] +
 | 
					        recoverTriggerTasksList[i] +
 | 
				
			||||||
          '<i class="delete icon"></i></a>'
 | 
					        '<i class="delete icon"></i></a>'
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
modal
 | 
					  modal
 | 
				
			||||||
    .find("input[name=FailTriggerTasksRaw]")
 | 
					    .find("input[name=FailTriggerTasksRaw]")
 | 
				
			||||||
    .val(monitor ? "[]," + failTriggerTasks.substr(1, failTriggerTasks.length - 2) : "[]");
 | 
					    .val(monitor ? "[]," + failTriggerTasks.substr(1, failTriggerTasks.length - 2) : "[]");
 | 
				
			||||||
modal
 | 
					  modal
 | 
				
			||||||
    .find("input[name=RecoverTriggerTasksRaw]")
 | 
					    .find("input[name=RecoverTriggerTasksRaw]")
 | 
				
			||||||
    .val(monitor ? "[]," + recoverTriggerTasks.substr(1, recoverTriggerTasks.length - 2) : "[]");
 | 
					    .val(monitor ? "[]," + recoverTriggerTasks.substr(1, recoverTriggerTasks.length - 2) : "[]");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
modal
 | 
					  modal
 | 
				
			||||||
    .find("input[name=SkipServersRaw]")
 | 
					    .find("input[name=SkipServersRaw]")
 | 
				
			||||||
    .val(monitor ? "[]," + servers.substr(1, servers.length - 2) : "[]");
 | 
					    .val(monitor ? "[]," + servers.substr(1, servers.length - 2) : "[]");
 | 
				
			||||||
  showFormModal(".monitor.modal", "#monitorForm", "/api/monitor");
 | 
					  showFormModal(".monitor.modal", "#monitorForm", "/api/monitor");
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								resource/template/common/footer.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								resource/template/common/footer.html
									
									
									
									
										vendored
									
									
								
							@ -10,7 +10,7 @@
 | 
				
			|||||||
<script src="https://cdn.staticfile.org/semantic-ui/2.4.1/semantic.min.js"></script>
 | 
					<script src="https://cdn.staticfile.org/semantic-ui/2.4.1/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.staticfile.org/vue/2.6.14/vue.min.js"></script>
 | 
					<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
 | 
				
			||||||
<script src="/static/main.js?v20230417"></script>
 | 
					<script src="/static/main.js?v20230614"></script>
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
    (function () {
 | 
					    (function () {
 | 
				
			||||||
        updateLang({{.LANG }});
 | 
					        updateLang({{.LANG }});
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										24
									
								
								resource/template/dashboard-default/server.html
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										24
									
								
								resource/template/dashboard-default/server.html
									
									
									
									
										vendored
									
									
								
							@ -8,6 +8,9 @@
 | 
				
			|||||||
                <button class="ui right labeled nezha-primary-btn icon button" onclick="batchEditServerGroup()"><i
 | 
					                <button class="ui right labeled nezha-primary-btn icon button" onclick="batchEditServerGroup()"><i
 | 
				
			||||||
                        class="edit icon"></i> {{tr "BatchEditServerGroup"}}
 | 
					                        class="edit icon"></i> {{tr "BatchEditServerGroup"}}
 | 
				
			||||||
                </button>
 | 
					                </button>
 | 
				
			||||||
 | 
					                <button class="ui right labeled nezha-primary-btn icon button" onclick="batchDeleteServer()"><i
 | 
				
			||||||
 | 
					                        class="trash icon"></i> {{tr "BatchDeleteServer"}}
 | 
				
			||||||
 | 
					                </button>
 | 
				
			||||||
                <button class="ui right labeled nezha-primary-btn icon button" onclick="addOrEditServer()"><i
 | 
					                <button class="ui right labeled nezha-primary-btn icon button" onclick="addOrEditServer()"><i
 | 
				
			||||||
                        class="add icon"></i> {{tr "AddServer"}}
 | 
					                        class="add icon"></i> {{tr "AddServer"}}
 | 
				
			||||||
                </button>
 | 
					                </button>
 | 
				
			||||||
@ -69,7 +72,7 @@
 | 
				
			|||||||
                                <i class="edit icon"></i>
 | 
					                                <i class="edit icon"></i>
 | 
				
			||||||
                            </button>
 | 
					                            </button>
 | 
				
			||||||
                            <button class="ui button"
 | 
					                            <button class="ui button"
 | 
				
			||||||
                                onclick="showConfirm('{{tr "DeleteServer"}}','{{tr "ConfirmToDeleteThisServer"}}',deleteRequest,'/api/server/'+{{$server.ID}})">
 | 
					                                onclick="showConfirm('{{tr "DeleteServer"}}','{{tr "ConfirmToDeleteServer"}}',deleteRequest,'/api/server/'+{{$server.ID}})">
 | 
				
			||||||
                                <i class="trash alternate outline icon"></i>
 | 
					                                <i class="trash alternate outline icon"></i>
 | 
				
			||||||
                            </button>
 | 
					                            </button>
 | 
				
			||||||
                        </div>
 | 
					                        </div>
 | 
				
			||||||
@ -188,5 +191,24 @@
 | 
				
			|||||||
                });
 | 
					                });
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    function batchDeleteServer() {
 | 
				
			||||||
 | 
					        const servers = []
 | 
				
			||||||
 | 
					        checkBoxList.forEach(cb => {
 | 
				
			||||||
 | 
					            if (cb.checked) {
 | 
				
			||||||
 | 
					                servers.push(parseInt(cb.value))
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					        if (servers.length == 0) {
 | 
				
			||||||
 | 
					            $.suiAlert({
 | 
				
			||||||
 | 
					                title: '{{tr "NoServerSelected"}}',
 | 
				
			||||||
 | 
					                description: '',
 | 
				
			||||||
 | 
					                type: 'warning',
 | 
				
			||||||
 | 
					                time: '2',
 | 
				
			||||||
 | 
					                position: 'top-center',
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        showConfirm('{{tr "DeleteServer"}}', '{{tr "ConfirmToDeleteServer"}}', () => postJson('/api/batch-delete-server', servers), '')
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@
 | 
				
			|||||||
<script src="https://cdn.staticfile.org/semantic-ui/2.4.1/semantic.min.js"></script>
 | 
					<script src="https://cdn.staticfile.org/semantic-ui/2.4.1/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.staticfile.org/vue/2.6.14/vue.min.js"></script>
 | 
					<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
 | 
				
			||||||
<script src="/static/main.js?v20230417"></script>
 | 
					<script src="/static/main.js?v20230614"></script>
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
    (function () {
 | 
					    (function () {
 | 
				
			||||||
        updateLang({{.LANG }});
 | 
					        updateLang({{.LANG }});
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ import (
 | 
				
			|||||||
	"github.com/naiba/nezha/pkg/utils"
 | 
						"github.com/naiba/nezha/pkg/utils"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Version = "v0.15.0" // !!记得修改 README 中的 badge 版本!!
 | 
					var Version = "v0.15.1" // !!记得修改 README 中的 badge 版本!!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	Conf  *model.Config
 | 
						Conf  *model.Config
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user