Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Monitoring main navigation section, with Alert sections #254

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4a4099c
Add Monitoring main navigation section, with Alert sections
jeff-phillips-18 Nov 17, 2016
2346ef0
Fix rubocop errors
jeff-phillips-18 Jan 26, 2017
a7c5f80
Fix alerts page layout names to show when the section is active
jeff-phillips-18 Jan 26, 2017
19cb6ae
Small fixes and refactors to enable unit testing.
jeff-phillips-18 Jan 30, 2017
0deded4
Add unit tests for alerts service and controllers
jeff-phillips-18 Feb 1, 2017
7275ed7
Fix for tooltips in overview section, use correct field for provider id.
jeff-phillips-18 Feb 6, 2017
99dbc3c
Address review comments
jeff-phillips-18 Feb 6, 2017
36f657e
Fixes for unit test after changes.
jeff-phillips-18 Feb 6, 2017
7ef3706
Use original coding style and ignore rubocop issues on line lengths.
jeff-phillips-18 Feb 7, 2017
c955882
Add host name to alerts display info.
jeff-phillips-18 Feb 8, 2017
3e1e8e7
Add links to Hosts and Providers in list views
jeff-phillips-18 Feb 9, 2017
739d19f
Add link to alerts page from provider name in overview tiles
jeff-phillips-18 Feb 9, 2017
e515c56
Add link to SOP in alerts list expansion area
jeff-phillips-18 Feb 9, 2017
264f8e5
Add ability to filter by provider type in overview section
jeff-phillips-18 Feb 9, 2017
de1af48
Update to not show components until initialization complete
jeff-phillips-18 Feb 9, 2017
7fb2285
Keep display state for items after refresh
jeff-phillips-18 Feb 9, 2017
9d9c302
Change expected severity from danger to error
jeff-phillips-18 Feb 9, 2017
18bfecc
Update list styling to show row borders
jeff-phillips-18 Feb 9, 2017
76fb76e
Fix rubocop issues in html files.
jeff-phillips-18 Feb 9, 2017
347b071
Code simplification and minor width change for select components
jeff-phillips-18 Feb 14, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
miqHttpInject(angular.module('alertsCenter', [
'ui.bootstrap',
'patternfly',
'miq.util',
'miq.api'
]));
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//= require moment
//= require moment-strftime/lib/moment-strftime
//= require moment-timezone
//= require moment-duration-format
//= require sprintf
//= require numeral
//= require cable
Expand Down
131 changes: 131 additions & 0 deletions app/assets/javascripts/controllers/alerts/alerts_list_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/* global miqHttpInject */

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

vm.alerts = [];
vm.alertsList = [];

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) {
return nextUpdate.id === existingAlert.id;
});

if (angular.isDefined(matchingAlert)) {
nextUpdate.isExpanded = matchingAlert.isExpanded;
}
});

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

$timeout();
}

function setupConfig() {
vm.severities = alertsCenterService.severities;
vm.acknowledgedTooltip = __("Acknowledged");

vm.listConfig = {
showSelectBox: false,
selectItems: false,
useExpandingRows: true,
onClick: expandRow
};

vm.menuActions = alertsCenterService.menuActions;
vm.updateMenuActionForItemFn = alertsCenterService.updateMenuActionForItemFn;

vm.objectTypes = [];
vm.currentFilters = alertsCenterService.getFiltersFromLocation($window.location.search,
alertsCenterService.alertListSortFields);

vm.filterConfig = {
fields: alertsCenterService.alertListFilterFields,
resultsCount: vm.alertsList.length,
appliedFilters: vm.currentFilters,
onFilterChange: vm.filterChange
};


vm.sortConfig = {
fields: alertsCenterService.alertListSortFields,
onSortChange: sortChange,
isAscending: true
};

// Default sort descending by severity
vm.sortConfig.currentField = vm.sortConfig.fields[1];
vm.sortConfig.isAscending = false;

vm.toolbarConfig = {
filterConfig: vm.filterConfig,
sortConfig: vm.sortConfig,
actionsConfig: {
actionsInclude: true
}
};
}

vm.filterChange = function() {
vm.alertsList = alertsCenterService.filterAlerts(vm.alerts, vm.filterConfig.appliedFilters);

vm.toolbarConfig.filterConfig.resultsCount = vm.alertsList.length;

/* Make sure sorting is maintained */
sortChange();
};

function sortChange() {
if (vm.alertsList) {
vm.alertsList.sort(function(item1, item2) {
return alertsCenterService.compareAlerts(item1,
item2,
vm.toolbarConfig.sortConfig.currentField.id,
vm.toolbarConfig.sortConfig.isAscending);
});
}
}

function expandRow(item) {
if (!item.disableRowExpansion) {
item.isExpanded = !item.isExpanded;
}
}

function getAlerts() {
alertsCenterService.updateAlertsData().then(processData);

if (alertsCenterService.refreshInterval > 0) {
$interval(
function() {
alertsCenterService.updateAlertsData().then(processData);
},
alertsCenterService.refreshInterval
);
}
}

vm.showHostPage = function(item, event) {
event.stopImmediatePropagation();
$window.location.href = item.hostLink;
};

vm.showObjectPage = function(item, event) {
event.stopImmediatePropagation();
$window.location.href = item.objectLink;
};

alertsCenterService.registerObserverCallback(vm.filterChange);

setupConfig();
getAlerts();
}
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/* global miqHttpInject */

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

vm.alertsList = [];

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) {
return nextUpdate.id === existingAlert.id;
});

if (angular.isDefined(matchingAlert)) {
nextUpdate.isExpanded = matchingAlert.isExpanded;
}
});

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

$timeout();
}

function setupConfig() {
vm.acknowledgedTooltip = __("Acknowledged");

vm.showCount = 25;
vm.showCounts = [25, 50, 100];

vm.severities = alertsCenterService.severities;

vm.listConfig = {
showSelectBox: false,
selectItems: false,
useExpandingRows: true
};

vm.menuActions = alertsCenterService.menuActions;
vm.updateMenuActionForItemFn = alertsCenterService.updateMenuActionForItemFn;

vm.objectTypes = [];
vm.currentFilters = alertsCenterService.getFiltersFromLocation($window.location.search,
alertsCenterService.alertListSortFields);

vm.filterConfig = {
fields: alertsCenterService.alertListFilterFields,
resultsCount: vm.alertsList.length,
appliedFilters: vm.currentFilters,
onFilterChange: vm.filterChange
};


vm.sortConfig = {
fields: alertsCenterService.alertListSortFields,
onSortChange: sortChange,
isAscending: true
};

// Default sort descending by severity
vm.sortConfig.currentField = vm.sortConfig.fields[1];
vm.sortConfig.isAscending = false;

vm.toolbarConfig = {
filterConfig: vm.filterConfig,
sortConfig: vm.sortConfig,
actionsConfig: {
actionsInclude: true
}
};
}

vm.filterChange = function() {
vm.alertsList = [];

// Sort by update time descending
vm.alerts.sort(function(alert1, alert2) {
return (alert2.evaluated_on - alert1.evaluated_on);
});

vm.alertsList = alertsCenterService.filterAlerts(vm.alerts, vm.filterConfig.appliedFilters);

vm.toolbarConfig.filterConfig.resultsCount = vm.alertsList.length;

/* Make sure sorting is maintained */
sortChange();
};

function sortChange() {
if (vm.alertsList) {
vm.alertsList.sort(function(item1, item2) {
return alertsCenterService.compareAlerts(item1,
item2,
vm.toolbarConfig.sortConfig.currentField.id,
vm.toolbarConfig.sortConfig.isAscending);
});
}
}

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

if (alertsCenterService.refreshInterval > 0) {
$interval(
function() {
alertsCenterService.updateAlertsData(vm.showCount, 0, undefined, 'evaluated_on', false).then(processData);
},
alertsCenterService.refreshInterval
);
}
}

vm.showHostPage = function(item, event) {
event.stopImmediatePropagation();
$window.location.href = item.hostLink;
};

vm.showObjectPage = function(item, event) {
event.stopImmediatePropagation();
$window.location.href = item.objectLink;
};

alertsCenterService.registerObserverCallback(vm.filterChange);

setupConfig();
getAlerts();
}
]);
Loading