Aias00 commented on code in PR #2736:
URL: https://github.com/apache/hertzbeat/pull/2736#discussion_r1770721548


##########
alerter/src/main/java/org/apache/hertzbeat/alert/service/impl/AlertDefineServiceImpl.java:
##########
@@ -158,6 +164,18 @@ public AlertDefine getMonitorBindAlertAvaDefine(long 
monitorId, String app, Stri
 
     @Override
     public Page<AlertDefine> getAlertDefines(List<Long> defineIds, String 
search, Byte priority, String sort, String order, int pageIndex, int pageSize) {
+        // parse translation content list
+        ObjectMapper objectMapper = new ObjectMapper();
+        List<String> searchList = Collections.emptyList();
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(search)) {

Review Comment:
   change all "org.springframework.util.StringUtils" to  
"org.apache.commons.lang3.StringUtils", and import 
org.apache.commons.lang3.StringUtils



##########
alerter/src/main/java/org/apache/hertzbeat/alert/service/impl/AlertDefineServiceImpl.java:
##########
@@ -167,30 +185,20 @@ public Page<AlertDefine> getAlertDefines(List<Long> 
defineIds, String search, By
                 }
                 andList.add(inPredicate);
             }
-            if (StringUtils.hasText(search)) {
-                Predicate predicate = criteriaBuilder.or(
-                        criteriaBuilder.like(
-                                criteriaBuilder.lower(root.get("app")),
-                                "%" + search.toLowerCase() + "%"
-                        ),
-                        criteriaBuilder.like(
-                                criteriaBuilder.lower(root.get("metric")),
-                                "%" + search.toLowerCase() + "%"
-                        ),
-                        criteriaBuilder.like(
-                                criteriaBuilder.lower(root.get("field")),
-                                "%" + search.toLowerCase() + "%"
-                        ),
-                        criteriaBuilder.like(
-                                criteriaBuilder.lower(root.get("expr")),
-                                "%" + search.toLowerCase() + "%"
-                        ),
-                        criteriaBuilder.like(
-                                criteriaBuilder.lower(root.get("template")),
-                                "%" + search.toLowerCase() + "%"
-                        )
-                );
-                andList.add(predicate);
+            if (null != finalSearchList && !finalSearchList.isEmpty()) {
+                List<Predicate> searchPredicates = new ArrayList<>();
+                for (String searchContent : finalSearchList) {
+                    Predicate predicate = criteriaBuilder.or(
+                            
criteriaBuilder.like(criteriaBuilder.lower(root.get("app")), "%" + 
searchContent.toLowerCase() + "%"),

Review Comment:
   set all  finalSearchList content toLowerCase(), to  reduce 
searchContent.toLowerCase() 



##########
web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts:
##########
@@ -138,27 +140,61 @@ export class AlertSettingComponent implements OnInit {
   }
 
   loadAlertDefineTable() {
+    const translationSearchList: string[] = [];
     this.tableLoading = true;
-    let alertDefineInit$ = this.alertDefineSvc.getAlertDefines(this.search, 
this.pageIndex - 1, this.pageSize).subscribe(
-      message => {
-        this.tableLoading = false;
-        this.checkedAll = false;
-        this.checkedDefineIds.clear();
-        if (message.code === 0) {
-          let page = message.data;
-          this.defines = page.content;
-          this.pageIndex = page.number + 1;
-          this.total = page.totalElements;
-        } else {
-          console.warn(message.msg);
+
+    this.appDefineSvc
+      .getAppDefines(this.i18nSvc.defaultLang)

Review Comment:
   call this method just when page`s construction



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to