Skip to content

Commit 4a8c8fb

Browse files
xingzhang-suseBinX-Suse
authored andcommitted
NVSHAS-9869: UI: Move DDoS Controls to Group Pane
1 parent a1cdb9b commit 4a8c8fb

14 files changed

+224
-10
lines changed

admin/webapp/websrc/app/common/services/groups.service.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import { GlobalConstant } from '@common/constants/global.constant';
77
import { MapConstant } from '@common/constants/map.constant';
88
import { UtilsService } from '@common/utils/app.utils';
99
import { parseCamelStyle } from '@common/utils/common.utils';
10-
import { ActionButtonsComponent } from '@routes/components/groups/partial/action-buttons/action-buttons.component';
11-
import { ScorableHeaderComponent } from '@routes/components/groups/partial/scorable-header/scorable-header.component';
10+
import { ActionButtonsComponent } from '@components/groups/partial/action-buttons/action-buttons.component';
11+
import { ScorableHeaderComponent } from '@components/groups/partial/scorable-header/scorable-header.component';
12+
import { MonitorMetricHeaderComponent } from '@components/groups/partial/monitor-metric-header/monitor-metric-header.component';
13+
import { MonitorMetricSwitchComponent } from '@components/groups/partial/monitor-metric-switch/monitor-metric-switch.component';
1214
import { CustomCheckActionButtonComponent } from '@routes/components/group-details/partial/custom-check-action-button/custom-check-action-button.component';
1315
import { GroupDlpConfigActionButtonComponent } from '@routes/components/group-details/partial/group-dlp-config-action-button/group-dlp-config-action-button.component';
1416
import { GroupWafConfigActionButtonComponent } from '@routes/components/group-details/partial/group-waf-config-action-button/group-waf-config-action-button.component';
@@ -234,6 +236,15 @@ export class GroupsService {
234236
minWidth: 50,
235237
maxWidth: 50,
236238
},
239+
{
240+
headerComponent: MonitorMetricHeaderComponent,
241+
field: 'monitor_metric',
242+
cellRenderer: MonitorMetricSwitchComponent,
243+
width: 50,
244+
sortable: false,
245+
minWidth: 50,
246+
maxWidth: 50,
247+
},
237248
{
238249
headerName: '',
239250
cellRenderer: ActionButtonsComponent,

admin/webapp/websrc/app/routes/components/groups/groups.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
308308
this.groups = [];
309309
this.groupsService.getFedGroupsData().subscribe({
310310
next: groups => {
311-
this.renderGroups(groups, true);
311+
this.renderGroups(groups, { isHardReloaded: true });
312312
},
313313
error: ({ error }: { error: ErrorResponse }) => {},
314314
complete: () => {
@@ -509,17 +509,19 @@ export class GroupsComponent implements OnInit, OnDestroy {
509509
this.filtered = this.filteredCount !== this.groupsCount;
510510
}
511511

512-
private renderGroups = (data, options) => {
512+
renderGroups = (data, options) => {
513513
this.eof = data.length < MapConstant.PAGE.GROUPS;
514-
this.groups = this.groups.concat(data);
514+
this.groups = options.isHardReloaded ? this.groups.concat(data) : data;
515515
if (!this.isShowingSystemGroups) {
516516
this.groups = this.groups.filter(function (item) {
517517
return !item.platform_role;
518518
});
519519
}
520520
console.log('this.groups', this.groups);
521521
this.gridApi!.setRowData(this.groups);
522-
this.filteredCount = this.groups.length;
522+
this.filteredCount = options.isHardReloaded
523+
? this.groups.length
524+
: this.filteredCount;
523525
if (this.eof) this.refreshing.emit(false);
524526
console.log('this.linkedGroup:', this.linkedGroup);
525527
setTimeout(() => {
@@ -564,7 +566,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
564566

565567
private handleError = () => {
566568
this.groupsErr = true;
567-
this.renderGroups([], true);
569+
this.renderGroups([], { isHardReloaded: true });
568570
};
569571

570572
private getModeCounts = () => {

admin/webapp/websrc/app/routes/components/groups/groups.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { RuleDetailModalService } from '@components/groups/partial/rule-detail-m
1919
import { DragDropModule } from '@angular/cdk/drag-drop';
2020
import { ExportOptionsModalModule } from '@components/export-options-modal/export-options-modal.module';
2121
import { FederatedConfigurationService } from '@services/federated-configuration.service';
22+
import { MonitorMetricHeaderComponent } from './partial/monitor-metric-header/monitor-metric-header.component';
23+
import { MonitorMetricSwitchComponent } from './partial/monitor-metric-switch/monitor-metric-switch.component';
2224

2325
@NgModule({
2426
declarations: [
@@ -30,6 +32,8 @@ import { FederatedConfigurationService } from '@services/federated-configuration
3032
GroupResponseRulesComponent,
3133
GroupNetworkRulesComponent,
3234
RuleDetailModalComponent,
35+
MonitorMetricHeaderComponent,
36+
MonitorMetricSwitchComponent,
3337
],
3438
imports: [
3539
CommonModule,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<em
2+
class="eos-icons icon-18"
3+
matTooltip="{{ 'group.editGroup.MONITOR_METRIC' | translate }}"
4+
matTooltipPosition="above"
5+
>security</em
6+
>

admin/webapp/websrc/app/routes/components/groups/partial/monitor-metric-header/monitor-metric-header.component.scss

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { MonitorMetricHeaderComponent } from './monitor-metric-header.component';
4+
5+
describe('MonitorMetricHeaderComponent', () => {
6+
let component: MonitorMetricHeaderComponent;
7+
let fixture: ComponentFixture<MonitorMetricHeaderComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [MonitorMetricHeaderComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(MonitorMetricHeaderComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { IHeaderAngularComp } from 'ag-grid-angular';
3+
import { IHeaderParams } from 'ag-grid-community';
4+
5+
@Component({
6+
selector: 'app-monitor-metric-header',
7+
templateUrl: './monitor-metric-header.component.html',
8+
styleUrls: ['./monitor-metric-header.component.scss'],
9+
})
10+
export class MonitorMetricHeaderComponent implements IHeaderAngularComp {
11+
constructor() {}
12+
13+
agInit(headerParams: IHeaderParams): void {}
14+
15+
refresh(params: IHeaderParams): boolean {
16+
return false;
17+
}
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<span *ngIf="showMonitorMetric">
2+
<span
3+
*ngIf="
4+
!isReadonlyGroup &&
5+
!isAddressGroupAndNamespaceUser &&
6+
params.context.componentParent.isWriteGroupAuthorized
7+
">
8+
<em
9+
class="eos-icons hand text-action text-muted"
10+
*ngIf="!params.value"
11+
(click)="toggleMonitoMetric(true)">
12+
toggle_off
13+
</em>
14+
<em
15+
class="eos-icons hand text-action text-success"
16+
*ngIf="params.value"
17+
(click)="toggleMonitoMetric(false)">
18+
toggle_on
19+
</em>
20+
</span>
21+
<span
22+
*ngIf="
23+
isReadonlyGroup ||
24+
isAddressGroupAndNamespaceUser ||
25+
!params.context.componentParent.isWriteGroupAuthorized
26+
">
27+
<em class="eos-icons text-action text-muted" *ngIf="!params.value">
28+
toggle_off
29+
</em>
30+
<em class="eos-icons text-action text-success" *ngIf="params.value">
31+
toggle_on
32+
</em>
33+
</span>
34+
</span>

admin/webapp/websrc/app/routes/components/groups/partial/monitor-metric-switch/monitor-metric-switch.component.scss

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { MonitorMetricSwitchComponent } from './monitor-metric-switch.component';
4+
5+
describe('MonitorMetricSwitchComponent', () => {
6+
let component: MonitorMetricSwitchComponent;
7+
let fixture: ComponentFixture<MonitorMetricSwitchComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [MonitorMetricSwitchComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(MonitorMetricSwitchComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});

0 commit comments

Comments
 (0)