Browse Source
Merge pull request #14339 from mtsymbarov-del/feat/propagated-option-alarm-count-widget
Added "Search propagated alarms" option for alarm count widget
pull/14387/head
Viacheslav Klimov
9 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
8 additions and
3 deletions
-
dao/src/main/java/org/thingsboard/server/dao/sql/query/DefaultAlarmQueryRepository.java
-
dao/src/test/java/org/thingsboard/server/dao/service/AlarmServiceTest.java
-
ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarm-count-basic-config.component.html
-
ui-ngx/src/app/modules/home/components/widget/config/datasource.component.html
|
|
|
@ -319,7 +319,11 @@ public class DefaultAlarmQueryRepository implements AlarmQueryRepository { |
|
|
|
SqlQueryContext ctx = new SqlQueryContext(new QueryContext(tenantId, null, EntityType.ALARM)); |
|
|
|
|
|
|
|
if (query.isSearchPropagatedAlarms()) { |
|
|
|
ctx.append("select count(distinct(a.id)) from alarm_info a "); |
|
|
|
if (query.getEntityFilter() == null) { |
|
|
|
ctx.append("select count(distinct(a.id)) from alarm_info a "); |
|
|
|
} else { |
|
|
|
ctx.append("select count(a.id) from alarm_info a "); |
|
|
|
} |
|
|
|
ctx.append(JOIN_ENTITY_ALARMS); |
|
|
|
if (orderedEntityIds != null) { |
|
|
|
if (orderedEntityIds.isEmpty()) { |
|
|
|
|
|
|
|
@ -974,6 +974,9 @@ public class AlarmServiceTest extends AbstractServiceTest { |
|
|
|
alarmsCount = alarmService.countAlarmsByQuery(tenantId, null, countQuery, List.of(parentId)); |
|
|
|
Assert.assertEquals(1, alarmsCount); |
|
|
|
|
|
|
|
alarmsCount = alarmService.countAlarmsByQuery(tenantId, null, countQuery, List.of(childId, parentId)); |
|
|
|
Assert.assertEquals(2, alarmsCount); |
|
|
|
|
|
|
|
created = alarmService.acknowledgeAlarm(tenantId, created.getId(), System.currentTimeMillis()).getAlarm(); |
|
|
|
|
|
|
|
countQuery.setStatusList(List.of(AlarmSearchStatus.UNACK)); |
|
|
|
|
|
|
|
@ -34,7 +34,6 @@ |
|
|
|
</button> |
|
|
|
</div> |
|
|
|
<tb-alarm-filter-config #alarmFilterConfig buttonMode="false" |
|
|
|
propagatedFilter="false" |
|
|
|
formControlName="alarmFilterConfig" |
|
|
|
[initialAlarmFilterConfig]="{ statusList: [alarmSearchStatus.ACTIVE] }"></tb-alarm-filter-config> |
|
|
|
</div> |
|
|
|
|
|
|
|
@ -37,7 +37,6 @@ |
|
|
|
datasourceFormGroup.get('type').value === datasourceType.entityCount || |
|
|
|
datasourceFormGroup.get('type').value === datasourceType.alarmCount ? datasourceFormGroup.get('type').value : ''"> |
|
|
|
<tb-alarm-filter-config *ngIf="datasourceFormGroup.get('type').value === datasourceType.alarmCount && !hideAlarmFilter" |
|
|
|
propagatedFilter="false" |
|
|
|
[initialAlarmFilterConfig]="{ statusList: [alarmSearchStatus.ACTIVE] }" |
|
|
|
style="height: 56px; margin-bottom: 22px;" |
|
|
|
formControlName="alarmFilterConfig"></tb-alarm-filter-config> |
|
|
|
|