fix(monitor): shield list support alert_name and res_name like query

This commit is contained in:
zhaoxiangchun
2021-09-28 20:38:48 +08:00
parent 8a597e1bf4
commit bf4b98ca36
5 changed files with 11 additions and 1 deletions
+1
View File
@@ -103,6 +103,7 @@ type CommonAlertListInput struct {
Level string `json:"level"`
ResType []string `json:"res_type"`
UsedBy string `json:"used_by"`
Name string `json:"name"`
}
type CommonAlertUpdateInput struct {
@@ -31,6 +31,7 @@ type MonitorResourceJointListInput struct {
SendState string `json:"send_state"`
ResType string `json:"res_type"`
ResName string `json:"res_name"`
AlertName string `json:"alert_name"`
}
type MonitorResourceJointCreateInput struct {
+3
View File
@@ -426,6 +426,9 @@ func (man *SCommonAlertManager) FieldListFilter(q *sqlchemy.SQuery, input monito
if len(input.Level) > 0 {
q.Equals("level", input.Level)
}
if len(input.Name) != 0 {
q.Contains("name", input.Name)
}
}
func (manager *SCommonAlertManager) GetExportExtraKeys(ctx context.Context, keys stringutils2.SSortedStrings, rowMap map[string]string) *jsonutils.JSONDict {
+1 -1
View File
@@ -193,7 +193,7 @@ func (manager *SMonitorResourceManager) FieldListFilter(q *sqlchemy.SQuery, quer
q.In("res_id", query.ResId)
}
if len(query.ResName) != 0 {
q.Equals("name", query.ResName)
q.Contains("name", query.ResName)
}
return q
}
@@ -180,6 +180,11 @@ func (m *SMonitorResourceAlertManager) ListItemFilter(ctx context.Context, q *sq
}
q.Filter(sqlchemy.In(q.Field("monitor_resource_id"), resQ.SubQuery()))
}
if len(input.AlertName) != 0 {
alertQuery := CommonAlertManager.Query("id")
CommonAlertManager.FieldListFilter(alertQuery, monitor.CommonAlertListInput{Name: input.AlertName})
q.Filter(sqlchemy.In(q.Field(m.GetSlaveFieldName()), alertQuery.SubQuery()))
}
return q, nil
}