This is an automated email from the ASF dual-hosted git repository. sardell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/metron.git
The following commit(s) were added to refs/heads/master by this push: new 2653157 METRON-2058 UI: Actions -> Add to Alert can still be selected from dropdown when no alerts are selected. (ruffle1986 via sardell) closes apache/metron#1373 2653157 is described below commit 2653157862740fc05ce8b3a8dcf4745a9f996c23 Author: ruffle1986 <ftamas.m...@gmail.com> AuthorDate: Thu May 16 18:02:30 2019 +0200 METRON-2058 UI: Actions -> Add to Alert can still be selected from dropdown when no alerts are selected. (ruffle1986 via sardell) closes apache/metron#1373 --- .../alerts/alerts-list/alerts-list.component.html | 10 ++-- .../alerts/alerts-list/alerts-list.component.ts | 61 ++++++++++++++-------- 2 files changed, 45 insertions(+), 26 deletions(-) diff --git a/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.html b/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.html index a02147f..9f12cbd 100644 --- a/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.html +++ b/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.html @@ -57,11 +57,11 @@ <div id="table-actions" class="dropdown d-inline-block"> <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">ACTIONS</button> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton"> - <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0" (click)="processOpen()">Open</span> - <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0" (click)="processDismiss()">Dismiss</span> - <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0" (click)="processEscalate()">Escalate</span> - <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0" (click)="processResolve()">Resolve</span> - <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0 || isMetaAlertPresentInSelectedAlerts" (click)="processAddToAlert()">Add to Alert</span> + <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0" (click)="processOpen($event)">Open</span> + <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0" (click)="processDismiss($event)">Dismiss</span> + <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0" (click)="processEscalate($event)">Escalate</span> + <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0" (click)="processResolve($event)">Resolve</span> + <span class="dropdown-item" [class.disabled]="selectedAlerts.length == 0 || isMetaAlertPresentInSelectedAlerts" (click)="processAddToAlert($event)">Add to Alert</span> </div> </div> </div> diff --git a/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.ts b/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.ts index 87c5aaa..26b472d 100644 --- a/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.ts +++ b/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.ts @@ -314,35 +314,54 @@ export class AlertsListComponent implements OnInit, OnDestroy { this.prepareColumnData(tableMetaData.tableColumns, defaultColumns); } - processEscalate() { - this.updateService.updateAlertState(this.selectedAlerts, 'ESCALATE', false).subscribe(() => { - const alerts = [...this.selectedAlerts]; - this.updateSelectedAlertStatus('ESCALATE'); - this.alertsService.escalate(alerts).subscribe(); - }); + preventDropdownOptionIfDisabled(event: Event): boolean { + if ((event.target as HTMLElement).classList.contains('disabled')) { + event.stopPropagation(); + event.preventDefault(); + return false; + } + return true } - processDismiss() { - this.updateService.updateAlertState(this.selectedAlerts, 'DISMISS', false).subscribe(results => { - this.updateSelectedAlertStatus('DISMISS'); - }); + processEscalate(event: Event) { + if (this.preventDropdownOptionIfDisabled(event) === true) { + this.updateService.updateAlertState(this.selectedAlerts, 'ESCALATE', false).subscribe(() => { + const alerts = [...this.selectedAlerts]; + this.updateSelectedAlertStatus('ESCALATE'); + this.alertsService.escalate(alerts).subscribe(); + }); + } } - processOpen() { - this.updateService.updateAlertState(this.selectedAlerts, 'OPEN', false).subscribe(results => { - this.updateSelectedAlertStatus('OPEN'); - }); + processDismiss(event: Event) { + if (this.preventDropdownOptionIfDisabled(event) === true) { + this.updateService.updateAlertState(this.selectedAlerts, 'DISMISS', false).subscribe(results => { + this.updateSelectedAlertStatus('DISMISS'); + }); + } } - processResolve() { - this.updateService.updateAlertState(this.selectedAlerts, 'RESOLVE', false).subscribe(results => { - this.updateSelectedAlertStatus('RESOLVE'); - }); + processOpen(event: Event) { + if (this.preventDropdownOptionIfDisabled(event) === true) { + this.updateService.updateAlertState(this.selectedAlerts, 'OPEN', false).subscribe(results => { + this.updateSelectedAlertStatus('OPEN'); + }); + } + } + + processResolve(event: Event) { + if (this.preventDropdownOptionIfDisabled(event) === true) { + this.updateService.updateAlertState(this.selectedAlerts, 'RESOLVE', false).subscribe(results => { + this.updateSelectedAlertStatus('RESOLVE'); + }); + } } - processAddToAlert() { - this.metaAlertsService.selectedAlerts = this.selectedAlerts; - this.router.navigateByUrl('/alerts-list(dialog:add-to-meta-alert)'); + processAddToAlert(event: Event) { + if (this.preventDropdownOptionIfDisabled(event) === true) { + this.metaAlertsService.selectedAlerts = this.selectedAlerts; + this.router.navigateByUrl('/alerts-list(dialog:add-to-meta-alert)'); + } } removeFilter(field: string) {