You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by mm...@apache.org on 2019/03/08 20:19:37 UTC

[metron] branch master updated: METRON-2031 [UI] Turning off initial search request and polling by default on Alerts UI (tiborm via mmiklavc) closes apache/metron#1353

This is an automated email from the ASF dual-hosted git repository.

mmiklavcic 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 143901b  METRON-2031 [UI] Turning off initial search request and polling by default on Alerts UI (tiborm via mmiklavc) closes apache/metron#1353
143901b is described below

commit 143901b018fff7008415e08351f32a63095b357e
Author: tiborm <ti...@gmail.com>
AuthorDate: Fri Mar 8 13:14:16 2019 -0700

    METRON-2031 [UI] Turning off initial search request and polling by default on Alerts UI (tiborm via mmiklavc) closes apache/metron#1353
---
 .../alerts/alerts-list/alerts-list.component.html  |  4 +--
 .../alerts/alerts-list/alerts-list.component.ts    | 33 +++++++++++++---------
 .../metron-alerts/src/app/model/table-metadata.ts  |  2 +-
 .../metron-alerts/src/app/utils/constants.ts       |  2 +-
 4 files changed, 23 insertions(+), 18 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 0b6f36d..a02147f 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
@@ -51,8 +51,8 @@
                 </div>
                 <app-configure-rows [srcElement]="settingsIcon" [tableMetaData]="tableMetaData" [(interval)]="refreshInterval" [(size)]="tableMetaData.size" (configRowsChange)="onConfigRowsChange()" > </app-configure-rows>
                 <div class="btn  pause-play" (click)="onPausePlay()">
-                    <i *ngIf="!pauseRefresh" class="fa fa-pause" aria-hidden="true"></i>
-                    <i *ngIf="pauseRefresh" class="fa fa-play" aria-hidden="true"></i>
+                    <i *ngIf="!isRefreshPaused" class="fa fa-pause" aria-hidden="true"></i>
+                    <i *ngIf="isRefreshPaused" class="fa fa-play" aria-hidden="true"></i>
                 </div>
                 <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>
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 20c3a19..342f44e 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
@@ -61,10 +61,10 @@ export class AlertsListComponent implements OnInit, OnDestroy {
   alerts: Alert[] = [];
   searchResponse: SearchResponse = new SearchResponse();
   colNumberTimerId: number;
-  refreshInterval = RefreshInterval.ONE_MIN;
+  refreshInterval = RefreshInterval.TEN_MIN;
   refreshTimer: Subscription;
-  pauseRefresh = POLLING_DEFAULT_STATE;
-  lastPauseRefreshValue = false;
+  isRefreshPaused = POLLING_DEFAULT_STATE;
+  lastIsRefreshPausedValue = false;
   isMetaAlertPresentInSelectedAlerts = false;
   timeStampfilterPresent = false;
   selectedTimeRange = new Filter(TIMESTAMP_FIELD_NAME, ALL_TIME, false);
@@ -164,10 +164,17 @@ export class AlertsListComponent implements OnInit, OnDestroy {
         this.configureTableService.getTableMetadata(),
         this.clusterMetaDataService.getDefaultColumns()
     ).subscribe((response: any) => {
-      this.prepareData(response[0], response[1], resetPaginationForSearch);
+      this.prepareData(response[0], response[1]);
+      this.refreshAlertData(resetPaginationForSearch);
     });
   }
 
+  private refreshAlertData(resetPaginationForSearch: boolean) {
+    if (this.alerts.length) {
+      this.search(resetPaginationForSearch);
+    }
+  }
+
   getColumnNamesForQuery() {
     let fieldNames = this.alertsColumns.map(columnMetadata => columnMetadata.name);
     fieldNames = fieldNames.filter(name => !(name === 'id' || name === 'alert_status'));
@@ -249,8 +256,8 @@ export class AlertsListComponent implements OnInit, OnDestroy {
   }
 
   onPausePlay() {
-    this.pauseRefresh = !this.pauseRefresh;
-    if (this.pauseRefresh) {
+    this.isRefreshPaused = !this.isRefreshPaused;
+    if (this.isRefreshPaused) {
       this.tryStopPolling();
     } else {
       this.search(false);
@@ -278,14 +285,12 @@ export class AlertsListComponent implements OnInit, OnDestroy {
     this.calcColumnsToDisplay();
   }
 
-  prepareData(tableMetaData: TableMetadata, defaultColumns: ColumnMetadata[], resetPagination: boolean) {
+  prepareData(tableMetaData: TableMetadata, defaultColumns: ColumnMetadata[]) {
     this.tableMetaData = tableMetaData;
     this.refreshInterval = this.tableMetaData.refreshInterval;
 
     this.updateConfigRowsSettings();
     this.prepareColumnData(tableMetaData.tableColumns, defaultColumns);
-
-    this.search(resetPagination);
   }
 
   processEscalate() {
@@ -326,7 +331,7 @@ export class AlertsListComponent implements OnInit, OnDestroy {
   }
 
   restoreRefreshState() {
-    this.pauseRefresh = this.lastPauseRefreshValue;
+    this.isRefreshPaused = this.lastIsRefreshPausedValue;
     this.tryStartPolling();
   }
 
@@ -412,17 +417,17 @@ export class AlertsListComponent implements OnInit, OnDestroy {
   }
 
   saveRefreshState() {
-    this.lastPauseRefreshValue = this.pauseRefresh;
+    this.lastIsRefreshPausedValue = this.isRefreshPaused;
     this.tryStopPolling();
   }
 
   pause() {
-    this.pauseRefresh = true;
+    this.isRefreshPaused = true;
     this.tryStopPolling();
   }
 
   resume() {
-    this.pauseRefresh = false;
+    this.isRefreshPaused = false;
     this.tryStartPolling();
   }
 
@@ -438,7 +443,7 @@ export class AlertsListComponent implements OnInit, OnDestroy {
   }
 
   tryStartPolling() {
-    if (!this.pauseRefresh) {
+    if (!this.isRefreshPaused) {
       this.tryStopPolling();
       this.refreshTimer = this.searchService.pollSearch(this.queryBuilder).subscribe(results => {
         this.setData(results);
diff --git a/metron-interface/metron-alerts/src/app/model/table-metadata.ts b/metron-interface/metron-alerts/src/app/model/table-metadata.ts
index e624b6e..0417041 100644
--- a/metron-interface/metron-alerts/src/app/model/table-metadata.ts
+++ b/metron-interface/metron-alerts/src/app/model/table-metadata.ts
@@ -20,7 +20,7 @@ import {ColumnMetadata} from './column-metadata';
 
 export class TableMetadata {
   size = PageSize.TWENTY_FIVE;
-  refreshInterval = RefreshInterval.ONE_MIN;
+  refreshInterval = RefreshInterval.TEN_MIN;
   hideResolvedAlerts = true;
   hideDismissedAlerts = true;
   tableColumns: ColumnMetadata[];
diff --git a/metron-interface/metron-alerts/src/app/utils/constants.ts b/metron-interface/metron-alerts/src/app/utils/constants.ts
index 703e0f7..7edddc1 100644
--- a/metron-interface/metron-alerts/src/app/utils/constants.ts
+++ b/metron-interface/metron-alerts/src/app/utils/constants.ts
@@ -34,7 +34,7 @@ export let CUSTOMM_DATE_RANGE_LABEL = 'Date Range';
 
 export let TREE_SUB_GROUP_SIZE = 5;
 export let INDEXES =  environment.indices ? environment.indices.split(',') : [];
-export let POLLING_DEFAULT_STATE = environment.defaultPollingState;
+export let POLLING_DEFAULT_STATE = !environment.defaultPollingState;
 
 export let MAX_ALERTS_IN_META_ALERTS = 350;