Skip to content

Commit

Permalink
Merge pull request #3393 from nimrodshn/better_handling_of_responses
Browse files Browse the repository at this point in the history
Better handling of responses from validation
  • Loading branch information
himdel authored Feb 19, 2018
2 parents bed7f58 + aed0ceb commit 6c8e07a
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -610,17 +610,23 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.authType = authType;
miqService.validateWithREST($event, authType, $scope.actionUrl, formSubmit)
.then(function success(data) {
$timeout(function() {
$scope.$apply(function() {
if(data.level == "error") {
$scope.updateAuthStatus(false);
} else {
$scope.updateAuthStatus(true);
}
miqService.miqFlash(data.level, data.message, data.options);
miqSparkleOff();
// check if data object is a JSON, otherwise (recieved JS or HTML) output a warning to the user.
if (data === Object(data)) {
$timeout(function() {
$scope.$apply(function() {
if(data.level == "error") {
$scope.updateAuthStatus(false);
} else {
$scope.updateAuthStatus(true);
}
miqService.miqFlash(data.level, data.message, data.options);
miqSparkleOff();
});
});
});
} else {
miqService.miqFlash("error", __('Something went wrong, please check the logs for more information.'));
miqSparkleOff();
}
});
};

Expand Down

0 comments on commit 6c8e07a

Please sign in to comment.