Display error if error on upload
We were missing the rejected promise when image upload returned
an error. Now with this change and
https://gerrit.openbmc-project.xyz/#/c/9594/ image upload
now uploads an image and refreshes the page to display the image
or displays an error if the upload failed.
Resolves openbmc/openbmc#2960
Tested: See an error if a bad image. GUI refreshes if the image
was uploaded successfully.
Change-Id: I5f4030fb29fc08aa65dd0d36e32368106c31a76b
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/configuration/controllers/firmware-controller.js b/app/configuration/controllers/firmware-controller.js
index 50cff28..d209a5a 100644
--- a/app/configuration/controllers/firmware-controller.js
+++ b/app/configuration/controllers/firmware-controller.js
@@ -148,22 +148,21 @@
}
$scope.upload = function(){
- if($scope.file) {
- $scope.uploading = true;
- APIUtils.uploadImage($scope.file).then(function(response){
- $scope.uploading = false;
- if(response.status == 'error'){
- $scope.displayError({
- modal_title: response.data.description,
- title: response.data.description,
- desc: response.data.exception,
- type: 'Error'
- });
- }else{
- $scope.loadFirmwares();
- }
- });
- }
+ if($scope.file) {
+ $scope.uploading = true;
+ APIUtils.uploadImage($scope.file).then(function(response){
+ $scope.uploading = false;
+ $scope.loadFirmwares();
+ }, function(error){
+ $scope.uploading = false;
+ $scope.displayError({
+ modal_title: 'Error during image upload',
+ title: 'Error during image upload',
+ desc: 'Error uploading image',
+ type: 'Error uploading image, please check the image'
+ });
+ });
+ }
}
$scope.download = function(){