Skip to content

Commit

Permalink
🐛 [Frontend] Fix: Download logs with newlines (Firefox) (#6583)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Oct 23, 2024
1 parent b857ace commit 5db5ac5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -804,11 +804,10 @@ qx.Class.define("osparc.utils.Utils", {
loadedCb();
}
const blob = new Blob([xhr.response]);
const urlBlob = window.URL.createObjectURL(blob);
if (!fileName) {
fileName = this.self().filenameFromContentDisposition(xhr);
}
this.self().downloadContent(urlBlob, fileName);
this.self().downloadBlobContent(blob, fileName);
resolve();
} else {
reject(xhr);
Expand All @@ -820,9 +819,9 @@ qx.Class.define("osparc.utils.Utils", {
});
},

downloadContent: function(content, filename = "file") {
downloadBlobContent: function(blob, filename = "file") {
let downloadAnchorNode = document.createElement("a");
downloadAnchorNode.setAttribute("href", content);
downloadAnchorNode.setAttribute("href", window.URL.createObjectURL(blob));
downloadAnchorNode.setAttribute("download", filename);
downloadAnchorNode.click();
downloadAnchorNode.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,10 @@ qx.Class.define("osparc.widget.logger.LoggerView", {
},

__getLogsString: function() {
const newLine = "\n";
let logs = "";
this.__loggerModel.getFilteredRows().forEach(rowData => {
logs += this.self().printRow(rowData) + "\n";
logs += this.self().printRow(rowData) + newLine;
});
return logs;
},
Expand All @@ -338,7 +339,8 @@ qx.Class.define("osparc.widget.logger.LoggerView", {

downloadLogs: function() {
const logs = this.__getLogsString();
osparc.utils.Utils.downloadContent("data:text/plain;charset=utf-8," + logs, "logs.log");
const blob = new Blob([logs], {type: "text/plain"});
osparc.utils.Utils.downloadBlobContent(blob, "logs.log");
},

debug: function(nodeId, msg = "") {
Expand Down

0 comments on commit 5db5ac5

Please sign in to comment.