Add role alert to toasts
For accessibility reasons, 'role="alert" is required for toast
messages. This notifies screen readers that an error or success
message has appeared. Adds a service layer for toast messages
that adds the role attribute to the message.
Change-Id: Ic4dbf5556337eea589de5692c1b4c3323e771813
Signed-off-by: beccabroek <beccabroek@gmail.com>
diff --git a/app/configuration/controllers/firmware-controller.js b/app/configuration/controllers/firmware-controller.js
index 8d4926d..9a811c3 100644
--- a/app/configuration/controllers/firmware-controller.js
+++ b/app/configuration/controllers/firmware-controller.js
@@ -12,10 +12,10 @@
angular.module('app.configuration').controller('firmwareController', [
'$scope', '$window', 'APIUtils', 'dataService', '$location',
'$anchorScroll', 'Constants', '$interval', '$q', '$timeout', '$interpolate',
- 'ngToast',
+ 'toastService',
function(
$scope, $window, APIUtils, dataService, $location, $anchorScroll,
- Constants, $interval, $q, $timeout, $interpolate, ngToast) {
+ Constants, $interval, $q, $timeout, $interpolate, toastService) {
$scope.dataService = dataService;
// Scroll to target anchor
@@ -96,7 +96,7 @@
},
function(error) {
console.log(JSON.stringify(error));
- ngToast.danger('Unable to activate image');
+ toastService.error('Unable to activate image');
})
.then(function(activationState) {
waitForActive($scope.activate_image_id)
@@ -106,7 +106,7 @@
},
function(error) {
console.log(JSON.stringify(error));
- ngToast.danger('Unable to activate image');
+ toastService.error('Unable to activate image');
})
.then(function(state) {
if ($scope.activate.reboot &&
@@ -126,7 +126,7 @@
function(response) {},
function(error) {
console.log(JSON.stringify(error));
- ngToast.danger('Unable to reboot BMC');
+ toastService.error('Unable to reboot BMC');
});
}, 10000);
}
@@ -156,7 +156,7 @@
})
.catch(function(error) {
console.log(JSON.stringify(error));
- ngToast.danger(Constants.MESSAGES.POWER_OP.POWER_ON_FAILED);
+ toastService.error(Constants.MESSAGES.POWER_OP.POWER_ON_FAILED);
});
};
function warmReboot() {
@@ -171,7 +171,8 @@
})
.catch(function(error) {
console.log(JSON.stringify(error));
- ngToast.danger(Constants.MESSAGES.POWER_OP.WARM_REBOOT_FAILED);
+ toastService.error(
+ Constants.MESSAGES.POWER_OP.WARM_REBOOT_FAILED);
});
};
$scope.isServerOff = function() {
@@ -185,7 +186,7 @@
.then(
function(response) {
$scope.uploading = false;
- ngToast.success(
+ toastService.success(
'Image file "' + $scope.file.name +
'" has been uploaded');
$scope.file = '';
@@ -194,7 +195,7 @@
function(error) {
$scope.uploading = false;
console.log(error);
- ngToast.danger('Unable to upload image file');
+ toastService.error('Unable to upload image file');
});
}
};
@@ -236,7 +237,8 @@
$scope.download = function() {
if (!$scope.download_host || !$scope.download_filename) {
- ngToast.danger('TFTP server IP address and file name are required!');
+ toastService.error(
+ 'TFTP server IP address and file name are required!');
return false;
}
@@ -260,12 +262,12 @@
$scope.download_host = '';
$scope.download_filename = '';
$scope.downloading = false;
- ngToast.success('Download complete');
+ toastService.success('Download complete');
$scope.loadFirmwares();
},
function(error) {
console.log(error);
- ngToast.danger(
+ toastService.error(
'Image file from TFTP server "' + $scope.download_host +
'" could not be downloaded');
$scope.downloading = false;
@@ -286,7 +288,7 @@
.then(function(response) {
$scope.loading = false;
if (response.status == 'error') {
- ngToast.danger('Unable to update boot priority');
+ toastService.error('Unable to update boot priority');
} else {
$scope.loadFirmwares();
}
@@ -303,7 +305,7 @@
APIUtils.deleteImage($scope.delete_image_id).then(function(response) {
$scope.loading = false;
if (response.status == 'error') {
- ngToast.danger('Unable to delete image');
+ toastService.error('Unable to delete image');
} else {
$scope.loadFirmwares();
}