summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2018-04-02 16:53:53 -0500
committerGunnar Mills <gmills@us.ibm.com>2018-04-09 14:55:49 +0000
commit36379b993791d743d39b3aee659c3d8d0fa51620 (patch)
tree2b333ef2464763977917e989363c55a88eb4df67
parent6d7b4a8d9da5f27acce5a96ea5b512674c24ecf8 (diff)
downloadphosphor-webui-36379b993791d743d39b3aee659c3d8d0fa51620.tar.gz
phosphor-webui-36379b993791d743d39b3aee659c3d8d0fa51620.zip
Display error if TFTP post fails
Display an error if the DownloadViaTFTP returns an error code. This code replaces some unused code. Resolves openbmc/openbmc#3029 Tested: Verified I see this error if the DownloadViaTFTP call returns an error code. Change-Id: I1547689059f45953b29aedda75c0599aec30079d Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rw-r--r--app/common/services/api-utils.js20
-rw-r--r--app/configuration/controllers/firmware-controller.js44
2 files changed, 18 insertions, 46 deletions
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index c20b2ca..f73a584 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -841,29 +841,19 @@ window.angular && (function (angular) {
return deferred.promise;
},
downloadImage: function(host, filename){
- var deferred = $q.defer();
- $http({
+ return $http({
method: 'POST',
url: DataService.getHost() + "/xyz/openbmc_project/software/action/DownloadViaTFTP",
headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
},
withCredentials: true,
data: JSON.stringify({"data": [filename, host]}),
responseType: 'arraybuffer'
- }).then(function(response, status, headers){
- deferred.resolve({
- data: response,
- status: status,
- headers: headers
- });
- }, function(error){
- console.log(error);
- deferred.reject(error);
+ }).then(function(response){
+ return response.data;
});
-
- return deferred.promise;
},
getBMCEthernetInfo: function(){
var deferred = $q.defer();
diff --git a/app/configuration/controllers/firmware-controller.js b/app/configuration/controllers/firmware-controller.js
index 29d0412..618cad8 100644
--- a/app/configuration/controllers/firmware-controller.js
+++ b/app/configuration/controllers/firmware-controller.js
@@ -159,40 +159,22 @@ window.angular && (function (angular) {
$scope.download = function(){
$scope.download_error_msg = "";
if(!$scope.download_host || !$scope.download_filename){
- $scope.download_error_msg = "Field is required!";
- return false;
+ $scope.download_error_msg = "Field is required!";
+ return false;
}
$scope.downloading = true;
APIUtils.downloadImage($scope.download_host, $scope.download_filename).then(function(response){
- var data = response.data;
- $scope.downloading = false;
- var headers = response.headers();
-
- var filename = headers['x-filename'];
- var contentType = headers['content-type'];
-
- if(!headers['x-filename']){
- filename = $scope.download_filename;
- }
-
- var linkElement = document.createElement('a');
- try {
- var blob = new Blob([data], { type: contentType });
- var url = window.URL.createObjectURL(blob);
-
- linkElement.setAttribute('href', url);
- linkElement.setAttribute("download", filename);
-
- var clickEvent = new MouseEvent("click", {
- "view": window,
- "bubbles": true,
- "cancelable": false
- });
- linkElement.dispatchEvent(clickEvent);
- } catch (ex) {
- console.log(ex);
- }
- });
+ $scope.downloading = false;
+ // TODO: refresh firmware page to display new image
+ }, function(error){
+ $scope.downloading = false;
+ $scope.displayError({
+ modal_title: 'Error during downloading Image',
+ title: 'Error during downloading Image',
+ desc: JSON.stringify(error),
+ type: 'Error'
+ });
+ });
}
$scope.changePriority = function(imageId, imageVersion, from, to){
OpenPOWER on IntegriCloud