You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by rm...@apache.org on 2017/10/13 18:04:21 UTC
metron git commit: METRON-1232 Alert status changes are not reflected
in list view (iraghumitra via merrimanr) closes apache/metron#787
Repository: metron
Updated Branches:
refs/heads/master 7f3eb2a4c -> d5afb7284
METRON-1232 Alert status changes are not reflected in list view (iraghumitra via merrimanr) closes apache/metron#787
Project: http://git-wip-us.apache.org/repos/asf/metron/repo
Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/d5afb728
Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/d5afb728
Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/d5afb728
Branch: refs/heads/master
Commit: d5afb7284d65a8583fbc5f3f627a6460f4ac8284
Parents: 7f3eb2a
Author: iraghumitra <ra...@gmail.com>
Authored: Fri Oct 13 13:04:08 2017 -0500
Committer: merrimanr <me...@apache.org>
Committed: Fri Oct 13 13:04:08 2017 -0500
----------------------------------------------------------------------
.../e2e/alert-details/alert-details.po.ts | 4 ++--
.../alert-details-status.e2e-spec.ts | 10 +++++++++-
.../e2e/alerts-list/alerts-list.po.ts | 19 ++++++++++++++-----
.../alerts/alerts-list/alerts-list.component.ts | 15 +++++++++++++++
.../app/alerts/alerts-list/alerts-list.module.ts | 3 +--
.../metron-alerts/src/app/app.module.ts | 4 +++-
.../src/app/service/update.service.ts | 9 ++++++++-
.../shared/directives/alert-search.directive.ts | 2 +-
8 files changed, 53 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/metron/blob/d5afb728/metron-interface/metron-alerts/e2e/alert-details/alert-details.po.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-alerts/e2e/alert-details/alert-details.po.ts b/metron-interface/metron-alerts/e2e/alert-details/alert-details.po.ts
index de0650f..79a0e1d 100644
--- a/metron-interface/metron-alerts/e2e/alert-details/alert-details.po.ts
+++ b/metron-interface/metron-alerts/e2e/alert-details/alert-details.po.ts
@@ -20,9 +20,9 @@ import {browser, element, by, protractor} from 'protractor';
export class MetronAlertDetailsPage {
- navigateTo() {
+ navigateTo(alertId: string) {
browser.waitForAngularEnabled(false);
- return browser.get('/alerts-list(dialog:details/alerts_ui_e2e/c4c5e418-3938-099e-bb0d-37028a98dca8)');
+ return browser.get('/alerts-list(dialog:details/alerts_ui_e2e/'+ alertId +')');
}
clickNew() {
http://git-wip-us.apache.org/repos/asf/metron/blob/d5afb728/metron-interface/metron-alerts/e2e/alert-details/alert-status/alert-details-status.e2e-spec.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-alerts/e2e/alert-details/alert-status/alert-details-status.e2e-spec.ts b/metron-interface/metron-alerts/e2e/alert-details/alert-status/alert-details-status.e2e-spec.ts
index f464e62..4e7331c 100644
--- a/metron-interface/metron-alerts/e2e/alert-details/alert-status/alert-details-status.e2e-spec.ts
+++ b/metron-interface/metron-alerts/e2e/alert-details/alert-status/alert-details-status.e2e-spec.ts
@@ -24,11 +24,13 @@ import { MetronAlertsPage } from '../../alerts-list/alerts-list.po';
describe('metron-alerts alert status', function() {
let page: MetronAlertDetailsPage;
+ let listPage: MetronAlertsPage;
let loginPage: LoginPage;
beforeAll(() => {
loadTestData();
loginPage = new LoginPage();
+ listPage = new MetronAlertsPage();
loginPage.login();
});
@@ -44,16 +46,22 @@ describe('metron-alerts alert status', function() {
});
it('should change alert statuses', () => {
- page.navigateTo();
+ let alertId = 'c4c5e418-3938-099e-bb0d-37028a98dca8';
+
+ page.navigateTo(alertId);
page.clickNew();
page.clickOpen();
expect(page.getAlertStatus('NEW')).toEqual('OPEN');
+ expect(listPage.getAlertStatusById(alertId)).toEqual('OPEN');
page.clickDismiss();
expect(page.getAlertStatus('OPEN')).toEqual('DISMISS');
+ expect(listPage.getAlertStatusById(alertId)).toEqual('DISMISS');
page.clickEscalate();
expect(page.getAlertStatus('DISMISS')).toEqual('ESCALATE');
+ expect(listPage.getAlertStatusById(alertId)).toEqual('ESCALATE');
page.clickResolve();
expect(page.getAlertStatus('ESCALATE')).toEqual('RESOLVE');
+ expect(listPage.getAlertStatusById(alertId)).toEqual('RESOLVE');
page.clickNew();
});
http://git-wip-us.apache.org/repos/asf/metron/blob/d5afb728/metron-interface/metron-alerts/e2e/alerts-list/alerts-list.po.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-alerts/e2e/alerts-list/alerts-list.po.ts b/metron-interface/metron-alerts/e2e/alerts-list/alerts-list.po.ts
index ec44120..982a79b 100644
--- a/metron-interface/metron-alerts/e2e/alerts-list/alerts-list.po.ts
+++ b/metron-interface/metron-alerts/e2e/alerts-list/alerts-list.po.ts
@@ -232,11 +232,15 @@ export class MetronAlertsPage {
clickRemoveSearchChip() {
let aceLine = element.all(by.css('.ace_keyword')).get(0);
- browser.actions().mouseMove(aceLine).perform().then(() => {
- this.waitForElementPresence(element(by.css('.ace_value i'))).then(() => {
- element.all(by.css('.ace_value i')).get(0).click();
- });
- });
+ /* - Focus on the search text box by sending a empty string
+ - move the mouse to the text in search bos so that delete buttons become visible
+ - wait for delete buttons become visible
+ - click on delete button
+ */
+ element(by.css('app-alerts-list .ace_text-input')).sendKeys('')
+ .then(() => browser.actions().mouseMove(aceLine).perform())
+ .then(() => this.waitForElementPresence(element(by.css('.ace_value i'))))
+ .then(() => element.all(by.css('.ace_value i')).get(0).click());
}
setSearchText(search: string) {
@@ -274,4 +278,9 @@ export class MetronAlertsPage {
return column.getText();
});
}
+
+ getAlertStatusById(id: string) {
+ return element(by.css('a[title="' + id +'"]'))
+ .element(by.xpath('../..')).all(by.css('td a')).get(8).getText();
+ }
}
http://git-wip-us.apache.org/repos/asf/metron/blob/d5afb728/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.ts
----------------------------------------------------------------------
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 039ed48..a3ba5ef 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
@@ -39,6 +39,7 @@ import {TableViewComponent} from './table-view/table-view.component';
import {Filter} from '../../model/filter';
import {Pagination} from '../../model/pagination';
import {environment} from '../../../environments/environment';
+import {PatchRequest} from '../../model/patch-request';
@Component({
selector: 'app-alerts-list',
@@ -89,6 +90,12 @@ export class AlertsListComponent implements OnInit, OnDestroy {
}
}
+ addAlertChangedListner() {
+ this.updateService.alertChanged$.subscribe(patchRequest => {
+ this.updateAlert(patchRequest);
+ });
+ }
+
addAlertColChangedListner() {
this.configureTableService.tableChanged$.subscribe(colChanged => {
if (colChanged) {
@@ -150,6 +157,7 @@ export class AlertsListComponent implements OnInit, OnDestroy {
this.getAlertColumnNames(true);
this.addAlertColChangedListner();
this.addLoadSavedSearchListner();
+ this.addAlertChangedListner();
}
onClear() {
@@ -353,6 +361,13 @@ export class AlertsListComponent implements OnInit, OnDestroy {
this.searchService.interval = this.refreshInterval;
}
+ updateAlert(patchRequest: PatchRequest) {
+ this.searchService.getAlert(patchRequest.sensorType, patchRequest.guid).subscribe(alertSource => {
+ this.alerts.filter(alert => alert.source.guid == patchRequest.guid)
+ .map(alert => alert.source = alertSource);
+ });
+ }
+
updateSelectedAlertStatus(status: string) {
for (let selectedAlert of this.selectedAlerts) {
selectedAlert.status = status;
http://git-wip-us.apache.org/repos/asf/metron/blob/d5afb728/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.module.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.module.ts b/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.module.ts
index 805265c..c1025f0 100644
--- a/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.module.ts
+++ b/metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.module.ts
@@ -21,7 +21,6 @@ import {AlertsListComponent} from './alerts-list.component';
import {routing} from './alerts-list.routing';
import {SharedModule} from '../../shared/shared.module';
import {SearchService} from '../../service/search.service';
-import {UpdateService} from '../../service/update.service';
import {MetronSorterModule} from '../../shared/metron-table/metron-sorter/metron-sorter.module';
import {ListGroupModule} from '../../shared/list-group/list-grup.module';
import {CollapseModule} from '../../shared/collapse/collapse.module';
@@ -34,7 +33,7 @@ import {TableViewComponent} from './table-view/table-view.component';
ListGroupModule, CollapseModule],
exports: [AlertsListComponent],
declarations: [AlertsListComponent, TableViewComponent],
- providers: [SearchService, UpdateService]
+ providers: [SearchService]
})
export class AlertsListModule {
}
http://git-wip-us.apache.org/repos/asf/metron/blob/d5afb728/metron-interface/metron-alerts/src/app/app.module.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-alerts/src/app/app.module.ts b/metron-interface/metron-alerts/src/app/app.module.ts
index f16b2d1..c817831 100644
--- a/metron-interface/metron-alerts/src/app/app.module.ts
+++ b/metron-interface/metron-alerts/src/app/app.module.ts
@@ -41,6 +41,7 @@ import {LoginModule} from './login/login.module';
import {AuthGuard} from './shared/auth-guard';
import {AuthenticationService} from './service/authentication.service';
import {LoginGuard} from './shared/login-guard';
+import {UpdateService} from './service/update.service';
@@ -74,7 +75,8 @@ export function initConfig(config: ColumnNamesService) {
ConfigureTableService,
SaveSearchService,
MetronDialogBox,
- ColumnNamesService],
+ ColumnNamesService,
+ UpdateService],
bootstrap: [AppComponent]
})
http://git-wip-us.apache.org/repos/asf/metron/blob/d5afb728/metron-interface/metron-alerts/src/app/service/update.service.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-alerts/src/app/service/update.service.ts b/metron-interface/metron-alerts/src/app/service/update.service.ts
index c4bc7d6..a1bf4a1 100644
--- a/metron-interface/metron-alerts/src/app/service/update.service.ts
+++ b/metron-interface/metron-alerts/src/app/service/update.service.ts
@@ -17,6 +17,7 @@
*/
import {Injectable} from '@angular/core';
import {Headers, RequestOptions} from '@angular/http';
+import {Subject} from 'rxjs/Subject';
import {Observable} from 'rxjs/Rx';
import 'rxjs/add/observable/interval';
import 'rxjs/add/operator/switchMap';
@@ -32,13 +33,19 @@ export class UpdateService {
defaultHeaders = {'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest'};
+ alertChangedSource = new Subject<PatchRequest>();
+ alertChanged$ = this.alertChangedSource.asObservable();
constructor(private http: Http) { }
public patch(patchRequest: PatchRequest): Observable<{}> {
let url = '/api/v1/update/patch';
return this.http.patch(url, patchRequest, new RequestOptions({headers: new Headers(this.defaultHeaders)}))
- .catch(HttpUtil.handleError);
+ .catch(HttpUtil.handleError)
+ .map(result => {
+ this.alertChangedSource.next(patchRequest);
+ return result;
+ });
}
public updateAlertState(alerts: Alert[], state: string): Observable<{}> {
http://git-wip-us.apache.org/repos/asf/metron/blob/d5afb728/metron-interface/metron-alerts/src/app/shared/directives/alert-search.directive.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-alerts/src/app/shared/directives/alert-search.directive.ts b/metron-interface/metron-alerts/src/app/shared/directives/alert-search.directive.ts
index fc3d113..c512233 100644
--- a/metron-interface/metron-alerts/src/app/shared/directives/alert-search.directive.ts
+++ b/metron-interface/metron-alerts/src/app/shared/directives/alert-search.directive.ts
@@ -130,7 +130,7 @@ export class AlertSearchDirective implements AfterViewInit, OnChanges {
private handleMouseEvent (callback: Function) {
clearTimeout(this.mouseEventTimer);
- this.mouseEventTimer = setTimeout(() => { callback(); }, 500);
+ this.mouseEventTimer = setTimeout(() => { callback(); }, 100);
}
private mouseover($event) {