You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ak...@apache.org on 2019/06/13 23:02:56 UTC
[incubator-pinot] branch master updated: [TE] frontend -
harleyjj/alerts - refactor alerts controller to maintain consistent state
(#4299)
This is an automated email from the ASF dual-hosted git repository.
akshayrai09 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 891b31c [TE] frontend - harleyjj/alerts - refactor alerts controller to maintain consistent state (#4299)
891b31c is described below
commit 891b31cf8a29edd7f36278928f607b7ac6d58d37
Author: Harley Jackson <hj...@linkedin.com>
AuthorDate: Thu Jun 13 16:02:51 2019 -0700
[TE] frontend - harleyjj/alerts - refactor alerts controller to maintain consistent state (#4299)
---
.../app/pods/manage/alerts/index/controller.js | 49 ++++++++++++++--------
.../app/pods/manage/alerts/index/route.js | 1 -
.../app/pods/manage/alerts/index/template.hbs | 4 +-
3 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js
index c658533..0e2ae98 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/controller.js
@@ -63,7 +63,7 @@ export default Controller.extend({
/**
* Filter settings
*/
- alertFilters: [],
+ alertFilters: {},
resetFiltersGlobal: null,
resetFiltersLocal: null,
alertFoundByName: null,
@@ -73,9 +73,6 @@ export default Controller.extend({
*/
topSearchKeyName: 'application',
- // Total displayed alerts
- totalFilteredAlerts: 0,
-
// default current Page
currentPage: 1,
@@ -186,14 +183,21 @@ export default Controller.extend({
setProperties(this, {
filtersTriggered: false, // reset filter trigger
- alertFoundByName: false, // reset single found alert var
- totalFilteredAlerts: filteredAlerts.length
+ alertFoundByName: false // reset single found alert var
});
return filteredAlerts;
}
),
+ // Total displayed alerts
+ totalFilteredAlerts: computed(
+ 'selectedAlerts.@each',
+ function() {
+ return this.get('selectedAlerts').length;
+ }
+ ),
+
// alerts with pagination
paginatedSelectedAlerts: computed(
'selectedAlerts.@each',
@@ -235,6 +239,14 @@ export default Controller.extend({
}
),
+ // Total displayed alerts
+ currentPageAlerts: computed(
+ 'paginatedSelectedAlerts.@each',
+ function() {
+ return this.get('paginatedSelectedAlerts').length;
+ }
+ ),
+
// String containing all selected filters for display
activeFiltersString: computed(
'alertFilters',
@@ -247,12 +259,11 @@ export default Controller.extend({
};
let filterStr = 'All Alerts';
if (isPresent(alertFilters)) {
- if (alertFilters.primary) {
- filterStr = alertFilters.primary;
- set(this, 'primaryFilterVal', filterStr);
- } else {
- let filterArr = [get(this, 'primaryFilterVal')];
- Object.keys(alertFilters).forEach((filterKey) => {
+ filterStr = alertFilters.primary;
+ set(this, 'primaryFilterVal', filterStr);
+ let filterArr = [get(this, 'primaryFilterVal')];
+ Object.keys(alertFilters).forEach((filterKey) => {
+ if (filterKey !== 'primary') {
const value = alertFilters[filterKey];
const isStatusAll = filterKey === 'status' && Array.isArray(value) && value.length > 1;
// Only display valid search filters
@@ -261,9 +272,9 @@ export default Controller.extend({
let abbrevKey = filterAbbrevMap[filterKey] || filterKey;
filterArr.push(`${abbrevKey}: ${concatVal}`);
}
- });
- filterStr = filterArr.join(' | ');
- }
+ }
+ });
+ filterStr = filterArr.join(' | ');
}
return filterStr;
}
@@ -439,14 +450,16 @@ export default Controller.extend({
},
// Handles filter selections (receives array of filter options)
- userDidSelectFilter(filterArr) {
+ userDidSelectFilter(filterObj) {
+ let alertFilters = get(this, 'alertFilters');
+ const updatedAlertFilters = filterObj.primary ? {primary: filterObj.primary} : {primary: alertFilters.primary, ...filterObj};
setProperties(this, {
filtersTriggered: true,
allowFilterSummary: true,
- alertFilters: filterArr
+ alertFilters: updatedAlertFilters
});
// Reset secondary filters component instance if a primary filter was selected
- if (Object.keys(filterArr).includes('primary')) {
+ if (Object.keys(filterObj).includes('primary')) {
setProperties(this, {
filterBlocksLocal: _.cloneDeep(get(this, 'initialFiltersLocal')),
resetFiltersLocal: moment().valueOf()
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
index 3426388..06760be 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/route.js
@@ -171,7 +171,6 @@ export default Route.extend(AuthenticatedRouteMixin, {
filterBlocksGlobal,
filterBlocksLocal,
filteredAlerts: model.alerts,
- totalFilteredAlerts: model.alerts.length,
sortModes: ['Edited:first', 'Edited:last', 'A to Z', 'Z to A'] // Alerts Search Mode options
});
},
diff --git a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/template.hbs b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/template.hbs
index 6ec41bb..dc5c5d8 100644
--- a/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/template.hbs
+++ b/thirdeye/thirdeye-frontend/app/pods/manage/alerts/index/template.hbs
@@ -37,7 +37,7 @@
{{/power-select}}
</div>
- {{#if (gt paginatedSelectedAlerts.length 1)}}
+ {{#if (gt currentPageAlerts 1)}}
<div class="manage-alert-search__sort">
<div class="manage-alert-search__label">Sort By:</div>
{{#power-select
@@ -67,7 +67,7 @@
{{/if}}
{{#if paginatedSelectedAlerts}}
<span class="te-search-header__displaynum pull-right">
- Showing {{paginatedSelectedAlerts.length}} of
+ Showing {{currentPageAlerts}} of
{{totalFilteredAlerts}} {{if (gt totalFilteredAlerts 1) 'alerts' 'alert'}}
</span>
{{/if}}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org