Skip to content

Commit

Permalink
Merge pull request #5066 from himdel/monitoring-sparkle
Browse files Browse the repository at this point in the history
Monitoring > Alerts - sparkle when loading
  • Loading branch information
mzazrivec authored Dec 10, 2018
2 parents 91bacce + 322ab20 commit 61bfd22
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* global miqHttpInject */
/* global miqHttpInject, miqSparkleOn, miqSparkleOff */

angular.module('alertsCenter').controller('alertsListController',
['$window', 'alertsCenterService', '$interval', '$timeout',
function($window, alertsCenterService, $interval, $timeout) {
['$window', 'alertsCenterService', '$interval',
function($window, alertsCenterService, $interval) {
var vm = this;

vm.alerts = [];
vm.alertsList = [];
vm.loadingDone = false;
miqSparkleOn();

function processData(response) {
var updatedAlerts = alertsCenterService.convertToAlertsList(response);
Expand All @@ -16,16 +18,15 @@ angular.module('alertsCenter').controller('alertsListController',
return nextUpdate.id === existingAlert.id;
});

if (matchingAlert !== undefined) {
if (matchingAlert) {
nextUpdate.isExpanded = matchingAlert.isExpanded;
}
});

vm.alerts = updatedAlerts;
vm.loadingDone = true;
vm.filterChange();

$timeout();
miqSparkleOff();
}

function setupConfig() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
/* global miqHttpInject */
/* global miqHttpInject, miqSparkleOn, miqSparkleOff */

angular.module('alertsCenter').controller('alertsMostRecentController',
['$window', 'alertsCenterService', '$interval', '$timeout',
function($window, alertsCenterService, $interval, $timeout) {
['$window', 'alertsCenterService', '$interval',
function($window, alertsCenterService, $interval) {
var vm = this;

vm.alertsList = [];
vm.loadingDone = false;
miqSparkleOn();

function processData(response) {
var updatedAlerts = alertsCenterService.convertToAlertsList(response);

// update display data for the alerts from the current alert settings
angular.forEach(updatedAlerts, function(nextUpdate) {
matchingAlert = _.find(vm.alerts, function(existingAlert) {
var matchingAlert = _.find(vm.alerts, function(existingAlert) {
return nextUpdate.id === existingAlert.id;
});

if (matchingAlert !== undefined) {
if (matchingAlert) {
nextUpdate.isExpanded = matchingAlert.isExpanded;
}
});

vm.alerts = updatedAlerts;
vm.loadingDone = true;
vm.filterChange();

$timeout();
miqSparkleOff();
}

function setupConfig() {
Expand Down Expand Up @@ -104,12 +105,12 @@ angular.module('alertsCenter').controller('alertsMostRecentController',
}

function getAlerts() {
alertsCenterService.updateAlertsData(vm.showCount, 0, undefined, 'evaluated_on', false).then(processData);
alertsCenterService.updateAlertsData(vm.showCount, 0, 'evaluated_on', false).then(processData);

if (alertsCenterService.refreshInterval > 0) {
$interval(
function() {
alertsCenterService.updateAlertsData(vm.showCount, 0, undefined, 'evaluated_on', false).then(processData);
alertsCenterService.updateAlertsData(vm.showCount, 0, 'evaluated_on', false).then(processData);
},
alertsCenterService.refreshInterval
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* global miqHttpInject */
/* global miqHttpInject, miqSparkleOn, miqSparkleOff */

angular.module('alertsCenter').controller('alertsOverviewController',
['$window', 'alertsCenterService', '$interval', '$timeout',
function($window, alertsCenterService, $interval, $timeout) {
['$window', 'alertsCenterService', '$interval',
function($window, alertsCenterService, $interval) {
var vm = this;

vm.alertData = [];
vm.loadingDone = false;
miqSparkleOn();

function setupInitialValues() {
document.getElementById('center_div').className += ' miq-body';
Expand Down Expand Up @@ -113,9 +115,7 @@ angular.module('alertsCenter').controller('alertsOverviewController',
var filtered = true;
if (item.info.length + item.warning.length + item.error.length > 0) {
var filter = _.find(vm.filterConfig.appliedFilters, function(filter) {
if (!alertsCenterService.matchesFilter(item, filter)) {
return true;
}
return !alertsCenterService.matchesFilter(item, filter);
});
filtered = filter != undefined;
}
Expand Down Expand Up @@ -240,10 +240,9 @@ angular.module('alertsCenter').controller('alertsOverviewController',
vm.displayFilters = alertsCenterService.displayFilters;
vm.categories = alertsCenterService.categories;

vm.filterChange();
vm.loadingDone = true;

$timeout();
vm.filterChange();
miqSparkleOff();
}

vm.onHoverAlerts = function(alerts) {
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/services/alerts_center_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,15 @@ angular.module('alertsCenter').service('alertsCenterService', ['API', '$q', '$ti
return deferred.promise;
};

_this.updateAlertsData = function(limit, offset, filters, sortField, sortAscending) {
_this.updateAlertsData = function(limit, offset, sortField, sortAscending) {
// Update data then get the alerts data
return _this.getCurrentUser()
.then(_this.updateExistingUsers)
.then(_this.updateProviders)
.then(_this.updateTags)
.then(_this.updateIcons)
.then(function() {
return _this.getAlertsData(limit, offset, filters, sortField, sortAscending);
return _this.getAlertsData(limit, offset, sortField, sortAscending);
});
};

Expand All @@ -403,7 +403,7 @@ angular.module('alertsCenter').service('alertsCenterService', ['API', '$q', '$ti
});
};

_this.getAlertsData = function(limit, offset, filters, sortField, sortAscending) {
_this.getAlertsData = function(limit, offset, sortField, sortAscending) {
var deferred = $q.defer();
var resourceOptions = '?expand=resources,alert_actions&attributes=assignee,resource&filter[]=resolved=false&filter[]=or+resolved=nil';
var limitOptions = '';
Expand Down

0 comments on commit 61bfd22

Please sign in to comment.