Skip to content

Commit

Permalink
HAWKULAR-983 change generating of JDR. Now it is not automatically cl…
Browse files Browse the repository at this point in the history
…icked on, rather just generated URL and passed to console via message.
  • Loading branch information
karelhala committed Feb 2, 2016
1 parent a9f063a commit 225812a
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/rest/hawkRest-ops-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,31 +300,20 @@ module hawkularRest {
let message;

if (jdrResponse.status === "OK") {
message = 'JDR generated';
let reportFileName:string = jdrResponse.fileName;

// TODO: this could be extracted into a function, if other handlers also need to offer a download feature
var a = document.createElement("a");
document.body.appendChild(a);
a.style.display = "none";
var url = URL.createObjectURL(binaryData);
a.href = url;
a['download'] = reportFileName;
a.click();
setTimeout(function(){
document.body.removeChild(a);
URL.revokeObjectURL(url);
}, 100);

$rootScope.$broadcast('ExportJDRSuccess', message);
const urlWithFileName = {
url: URL.createObjectURL(binaryData),
fileName: jdrResponse.fileName,
jdrResponse: jdrResponse
};
$rootScope.$broadcast('ExportJDRSuccess', urlWithFileName);

} else if (jdrResponse.status === "ERROR") {
message = 'Export of JDR failed: ' + jdrResponse.message;
$rootScope.$broadcast('ExportJDRError', message);
$rootScope.$broadcast('ExportJDRError', {message, jdrResponse});
} else {
message = 'Export of JDR failed: ' + jdrResponse.message;
console.error('Unexpected ExportJdrResponse: ', jdrResponse);
$rootScope.$broadcast('ExportJDRError', message);
$rootScope.$broadcast('ExportJDRError', {message, jdrResponse});
}
}
},
Expand Down

0 comments on commit 225812a

Please sign in to comment.