Skip to content

Commit

Permalink
feat alert converge, define, silence support search query (#1300)
Browse files Browse the repository at this point in the history
Signed-off-by: tomsun28 <tomsun28@outlook.com>
Co-authored-by: ruanliang <ruanliang_hualun@163.com>
Co-authored-by: ruanliang01 <ruanliang01@corp.netease.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Ceilzcx <48920254+Ceilzcx@users.noreply.github.com>
Co-authored-by: Eden4701 <Eden4701@163.com>
  • Loading branch information
6 people authored Oct 26, 2023
1 parent 21e16f2 commit 3c64699
Show file tree
Hide file tree
Showing 31 changed files with 222 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.persistence.criteria.CriteriaBuilder;
Expand Down Expand Up @@ -58,6 +59,7 @@ public class AlertConvergesController {
description = "You can obtain the list of alarm converge by querying filter items | 根据查询过滤项获取告警收敛信息列表")
public ResponseEntity<Message<Page<AlertConverge>>> getAlertConverges(
@Parameter(description = "Alarm Converge ID | 告警收敛ID", example = "6565463543") @RequestParam(required = false) List<Long> ids,
@Parameter(description = "Search Name | 模糊查询-名称", example = "x") @RequestParam(required = false) String search,
@Parameter(description = "Sort field, default id | 排序字段,默认id", example = "id") @RequestParam(defaultValue = "id") String sort,
@Parameter(description = "Sort mode: asc: ascending, desc: descending | 排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") String order,
@Parameter(description = "List current page | 列表当前分页", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
Expand All @@ -72,6 +74,15 @@ public ResponseEntity<Message<Page<AlertConverge>>> getAlertConverges(
}
andList.add(inPredicate);
}
if (StringUtils.hasText(search)) {
Predicate predicate = criteriaBuilder.or(
criteriaBuilder.like(
criteriaBuilder.lower(root.get("name")),
"%" + search.toLowerCase() + "%"
)
);
andList.add(predicate);
}
Predicate[] predicates = new Predicate[andList.size()];
return criteriaBuilder.and(andList.toArray(predicates));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class AlertDefinesController {
description = "You can obtain the list of alarm definitions by querying filter items | 根据查询过滤项获取告警定义信息列表")
public ResponseEntity<Message<Page<AlertDefine>>> getAlertDefines(
@Parameter(description = "Alarm Definition ID | 告警定义ID", example = "6565463543") @RequestParam(required = false) List<Long> ids,
@Parameter(description = "Alarm Definition app告警定义名称", example = "6565463543") @RequestParam(required = false) String search,
@Parameter(description = "Search-Target Expr Template模糊查询-指标对象 表达式 通知模版", example = "x") @RequestParam(required = false) String search,
@Parameter(description = "Alarm Definition Severity | 告警定义级别", example = "6565463543") @RequestParam(required = false) Byte priority,
@Parameter(description = "Sort field, default id | 排序字段,默认id", example = "id") @RequestParam(defaultValue = "id") String sort,
@Parameter(description = "Sort mode: asc: ascending, desc: descending | 排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") String order,
Expand All @@ -87,11 +87,19 @@ public ResponseEntity<Message<Page<AlertDefine>>> getAlertDefines(
),
criteriaBuilder.like(
criteriaBuilder.lower(root.get("metric")),
"%" + search.toUpperCase() + "%"
"%" + search.toLowerCase() + "%"
),
criteriaBuilder.like(
criteriaBuilder.lower(root.get("field")),
"%" + search.toUpperCase() + "%"
"%" + search.toLowerCase() + "%"
),
criteriaBuilder.like(
criteriaBuilder.lower(root.get("expr")),
"%" + search.toLowerCase() + "%"
),
criteriaBuilder.like(
criteriaBuilder.lower(root.get("template")),
"%" + search.toLowerCase() + "%"
)
);
andList.add(predicate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.persistence.criteria.CriteriaBuilder;
Expand Down Expand Up @@ -58,6 +59,7 @@ public class AlertSilencesController {
description = "You can obtain the list of alarm silence by querying filter items | 根据查询过滤项获取告警静默信息列表")
public ResponseEntity<Message<Page<AlertSilence>>> getAlertSilences(
@Parameter(description = "Alarm Silence ID | 告警静默ID", example = "6565463543") @RequestParam(required = false) List<Long> ids,
@Parameter(description = "Search Name | 模糊查询-名称", example = "x") @RequestParam(required = false) String search,
@Parameter(description = "Sort field, default id | 排序字段,默认id", example = "id") @RequestParam(defaultValue = "id") String sort,
@Parameter(description = "Sort mode: asc: ascending, desc: descending | 排序方式,asc:升序,desc:降序", example = "desc") @RequestParam(defaultValue = "desc") String order,
@Parameter(description = "List current page | 列表当前分页", example = "0") @RequestParam(defaultValue = "0") int pageIndex,
Expand All @@ -72,6 +74,15 @@ public ResponseEntity<Message<Page<AlertSilence>>> getAlertSilences(
}
andList.add(inPredicate);
}
if (StringUtils.hasText(search)) {
Predicate predicate = criteriaBuilder.or(
criteriaBuilder.like(
criteriaBuilder.lower(root.get("name")),
"%" + search.toLowerCase() + "%"
)
);
andList.add(predicate);
}
Predicate[] predicates = new Predicate[andList.size()];
return criteriaBuilder.and(andList.toArray(predicates));
};
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/app/core/startup/startup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class StartupService {
// Application information: including site name, description, year
this.settingService.setApp(appData.app);
// https://ng-alain.com/theme/settings/zh
this.settingService.setLayout('collapsed', true);
// this.settingService.setLayout('collapsed', true);
// ACL: Set the permissions to full, https://ng-alain.com/acl/getting-started
this.aclService.setFull(true);
// Menu data, https://ng-alain.com/theme/menu
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/app/layout/basic/widgets/user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { CONSTANTS } from '../../../shared/constants';
[nzFooter]="null"
(nzOnCancel)="disAboutModal()"
nzClosable="false"
nzWidth="44%"
nzWidth="48%"
>
<div *nzModalContent class="-inner-content">
<div style="text-align: center">
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/app/pojo/NoticeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export class NoticeRule {
name!: string;
receiverId!: number;
receiverName!: string;
templateId!: number;
templateName!: string;
templateId!: number | null;
templateName!: string | null;
enable: boolean = true;
// 是否转发所有
filterAll: boolean = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
<i nz-icon nzType="delete" nzTheme="outline"></i>
{{ 'alert.converge.delete' | i18n }}
</button>
<button style="margin-right: 25px; float: right" nz-button nzType="primary" (click)="loadAlertConvergeTable()">
{{ 'common.search' | i18n }}
</button>
<input
style="margin-right: 5px; float: right; width: 200px; border-radius: 9px; text-align: center; margin-right: 0"
nz-input
type="text"
[placeholder]="'alert.converge.name' | i18n"
nzSize="default"
(keyup.enter)="loadAlertConvergeTable()"
[(ngModel)]="search"
/>
</div>

<nz-table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class AlertConvergeComponent implements OnInit {
pageIndex: number = 1;
pageSize: number = 8;
total: number = 0;
search!: string;
converges!: AlertConverge[];
tableLoading: boolean = true;
checkedConvergeIds = new Set<number>();
Expand All @@ -43,7 +44,7 @@ export class AlertConvergeComponent implements OnInit {

loadAlertConvergeTable() {
this.tableLoading = true;
let alertDefineInit$ = this.alertConvergeService.getAlertConverges(this.pageIndex - 1, this.pageSize).subscribe(
let alertDefineInit$ = this.alertConvergeService.getAlertConverges(this.search, this.pageIndex - 1, this.pageSize).subscribe(
message => {
this.tableLoading = false;
this.checkedAll = false;
Expand Down
Loading

0 comments on commit 3c64699

Please sign in to comment.