修正Id为ID

修正in18错误
修正RunScript宿主机未使用错误
This commit is contained in:
曾广宇 2023-05-08 10:05:34 +08:00
parent fe4915bbb0
commit c389990706
8 changed files with 26 additions and 22 deletions

View File

@ -136,8 +136,8 @@ func (Monitor) Add(gp *server.Goploy) server.Response {
Description: reqData.Description,
FailScript: reqData.FailScript,
SuccessScript: reqData.SuccessScript,
SuccessServerId: reqData.SuccessServerId,
FailServerId: reqData.FailServerId,
SuccessServerID: reqData.SuccessServerId,
FailServerID: reqData.FailServerId,
}.AddRow()
if err != nil {
@ -184,8 +184,8 @@ func (Monitor) Edit(gp *server.Goploy) server.Response {
Description: reqData.Description,
FailScript: reqData.FailScript,
SuccessScript: reqData.SuccessScript,
SuccessServerId: reqData.SuccessServerId,
FailServerId: reqData.FailServerId,
SuccessServerID: reqData.SuccessServerId,
FailServerID: reqData.FailServerId,
}.EditRow()
if err != nil {

View File

@ -81,8 +81,8 @@ func monitorTask() {
if int(now-monitorCache.time) >= m.Second {
monitorCache.time = now
ms, err := monitor.NewMonitorFromTarget(m.Type, m.Target,
monitor.NewScript(m.SuccessServerId, m.SuccessScript),
monitor.NewScript(m.FailServerId, m.FailScript),
monitor.NewScript(m.SuccessServerID, m.SuccessScript),
monitor.NewScript(m.FailServerID, m.FailScript),
)
if err != nil {
_ = m.TurnOff(err.Error())

View File

@ -163,6 +163,8 @@ func (m Monitor) RunFailScript(serverId int64) error {
if sId == -1 {
if serverId == 0 {
return errors.New("the executor is not clear")
} else {
sId = serverId
}
}
session, err := NewSession(sId, m.Timeout*time.Second)
@ -179,6 +181,8 @@ func (m Monitor) RunSuccessScript(serverId int64) error {
if sId == -1 {
if serverId == 0 {
return errors.New("the executor is not clear")
} else {
sId = serverId
}
}
session, err := NewSession(sId, m.Timeout*time.Second)

View File

@ -26,9 +26,9 @@ type Monitor struct {
SilentCycle int `json:"silentCycle"`
NotifyType uint8 `json:"notifyType"`
NotifyTarget string `json:"notifyTarget"`
SuccessServerId int64 `json:"successServerId"`
SuccessServerID int64 `json:"successServerId"`
SuccessScript string `json:"successScript"`
FailServerId int64 `json:"failServerId"`
FailServerID int64 `json:"failServerId"`
FailScript string `json:"failScript"`
Description string `json:"description"`
ErrorContent string `json:"errorContent"`
@ -71,8 +71,8 @@ func (m Monitor) GetList() (Monitors, error) {
&monitor.State,
&monitor.SuccessScript,
&monitor.FailScript,
&monitor.SuccessServerId,
&monitor.FailServerId,
&monitor.SuccessServerID,
&monitor.FailServerID,
&monitor.InsertTime,
&monitor.UpdateTime); err != nil {
return nil, err
@ -92,7 +92,7 @@ func (m Monitor) GetData() (Monitor, error) {
OrderBy("id DESC").
RunWith(DB).
QueryRow().
Scan(&monitor.ID, &monitor.Name, &monitor.Type, &monitor.Target, &monitor.Second, &monitor.Times, &monitor.SilentCycle, &monitor.NotifyType, &monitor.NotifyTarget, &monitor.State, &monitor.SuccessScript, &monitor.FailScript, &monitor.SuccessServerId, &monitor.FailServerId)
Scan(&monitor.ID, &monitor.Name, &monitor.Type, &monitor.Target, &monitor.Second, &monitor.Times, &monitor.SilentCycle, &monitor.NotifyType, &monitor.NotifyTarget, &monitor.State, &monitor.SuccessScript, &monitor.FailScript, &monitor.SuccessServerID, &monitor.FailServerID)
if err != nil {
return monitor, err
}
@ -127,8 +127,8 @@ func (m Monitor) GetAllByState() (Monitors, error) {
&monitor.NotifyTarget,
&monitor.SuccessScript,
&monitor.FailScript,
&monitor.SuccessServerId,
&monitor.FailServerId,
&monitor.SuccessServerID,
&monitor.FailServerID,
&monitor.Description,
&monitor.UpdateTime,
); err != nil {
@ -144,7 +144,7 @@ func (m Monitor) AddRow() (int64, error) {
result, err := sq.
Insert(monitorTable).
Columns("namespace_id", "name", "type", "target", "second", "times", "silent_cycle", "notify_type", "notify_target", "description", "error_content", "success_script", "fail_script", "success_server_id", "fail_server_id").
Values(m.NamespaceID, m.Name, m.Type, m.Target, m.Second, m.Times, m.SilentCycle, m.NotifyType, m.NotifyTarget, m.Description, "", m.SuccessScript, m.FailScript, m.SuccessServerId, m.FailServerId).
Values(m.NamespaceID, m.Name, m.Type, m.Target, m.Second, m.Times, m.SilentCycle, m.NotifyType, m.NotifyTarget, m.Description, "", m.SuccessScript, m.FailScript, m.SuccessServerID, m.FailServerID).
RunWith(DB).
Exec()
if err != nil {
@ -169,8 +169,8 @@ func (m Monitor) EditRow() error {
"description": m.Description,
"success_script": m.SuccessScript,
"fail_script": m.FailScript,
"success_server_id": m.SuccessServerId,
"fail_server_id": m.FailServerId,
"success_server_id": m.SuccessServerID,
"fail_server_id": m.FailServerID,
}).
Where(sq.Eq{"id": m.ID}).
RunWith(DB).

2
web/components.d.ts vendored
View File

@ -25,7 +25,6 @@ declare module '@vue/runtime-core' {
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
ElEmpty: typeof import('element-plus/es')['ElEmpty']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElIcon: typeof import('element-plus/es')['ElIcon']
@ -50,7 +49,6 @@ declare module '@vue/runtime-core' {
ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag']
ElTimeSelect: typeof import('element-plus/es')['ElTimeSelect']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElUpload: typeof import('element-plus/es')['ElUpload']
Hamburger: typeof import('./src/components/Hamburger/index.vue')['default']

View File

@ -307,6 +307,7 @@
"saveTemplate": "Save template"
},
"monitorPage": {
"defaultServer": "Follow Host",
"scriptMode": "Script mode",
"typeOption": [
"Unknown",

View File

@ -291,6 +291,7 @@
},
"monitorPage": {
"scriptMode": "脚本类型",
"defaultServer": "跟随宿主机",
"typeOption": ["未知", "站点检测", "端口检测", "Ping检测", "进程检测", "自定义脚本检测"],
"testState": "测试状态",
"failTimes": "连续失败次数",

View File

@ -233,7 +233,7 @@
<el-form-item prop="successServerId" :label="$t('target')">
<el-select v-model="formData.successServerId" style="width: 100%">
<el-option v-for="item in [
{ id: -1, label: '跟随宿主机' },
{ id: -1, label: $t('monitorPage.defaultServer') },
...serverOption,
]" :key="item.label" :label="item.label" :value="item.id" />
</el-select>
@ -263,7 +263,7 @@
<el-form-item prop="failServerId" :label="$t('target')">
<el-select v-model="formData.failServerId" style="width: 100%">
<el-option v-for="item in [
{ id: -1, label: '跟随宿主机' },
{ id: -1, label: $t('monitorPage.defaultServer') },
...serverOption,
]" :key="item.label" :label="item.label" :value="item.id" />
</el-select>