Skip to content

Commit

Permalink
Merge pull request #1201 from StochSS/develop
Browse files Browse the repository at this point in the history
Release 2.3.10
  • Loading branch information
briandrawert authored Jul 27, 2021
2 parents 5f81f1f + 49f0107 commit bbbaf58
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 19 deletions.
28 changes: 27 additions & 1 deletion client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,31 @@ documentSetup = () => {
});
}

copyToClipboard = (text) => {
if (window.clipboardData && window.clipboardData.setData) {
// Internet Explorer-specific code path to prevent textarea being shown while dialog is visible.
return window.clipboardData.setData("Text", text);

}
else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
textarea.style.display = 'none'; // Prevent scrolling to bottom of page in Microsoft Edge.
document.body.appendChild(textarea);
textarea.select();
try {
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
}
catch (ex) {
console.warn("Copy to clipboard failed.", ex);
return false;
}
finally {
document.body.removeChild(textarea);
}
}
}

module.exports = {
routePrefix: routePrefix,
getApiPath: getApiPath,
Expand All @@ -223,7 +248,8 @@ module.exports = {
getXHR: getXHR,
postXHR: postXHR,
tooltipSetup: tooltipSetup,
documentSetup: documentSetup
documentSetup: documentSetup,
copyToClipboard: copyToClipboard
};


15 changes: 3 additions & 12 deletions client/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,19 +236,10 @@ let templates = {
</button>
</div>
<div class="modal-body">
<h4><u>${headers[0]}</u></h4>
<h4><u>${headers}</u></h4>
<div>
<a href="${links.presentation}" target="_blank"> View ${name} Presentation</a>
</div>
<hr>
<h4><u>${headers[1]}</u></h4>
<div>
<a href="${links.download}"> Download ${name} Presentation</a>
</div>
<hr>
<h4><u>${headers[2]}</u></h4>
<div>
<a href="${links.open}" target="_blank"> Open ${name} Presentation</a>
<a class="inline" data-hook="view-present-link" href="${links.presentation}" target="_blank"> View ${name} Presentation</a>
<button type="button" class="btn btn-primary box-shadow inline" id="copy-to-clipboard">Copy Link</button>
</div>
</div>
<div class="modal-footer">
Expand Down
6 changes: 5 additions & 1 deletion client/pages/file-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,14 @@ let FileBrowser = PageView.extend({
app.getXHR(endpoint, {
success: function (err, response, body) {
let title = body.message;
let linkHeaders = ["Presentation Link", "Download Link", "Open Link"];
let linkHeaders = "Shareable Presentation Link";
let links = body.links;
let name = o.original._path.split('/').pop().split('.ipynb')[0];
$(modals.presentationLinks(title, name, linkHeaders, links)).modal();
let copyBtn = document.querySelector('#presentationLinksModal #copy-to-clipboard');
copyBtn.addEventListener('click', function (e) {
app.copyToClipboard(links.presentation)
});
},
error: function (err, response, body) {
$(modals.newProjectModelErrorHtml(body.Reason, body.Message)).modal();
Expand Down
9 changes: 7 additions & 2 deletions client/pages/loading-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ let LoadingPage = PageView.extend({
let urlParams = new URLSearchParams(window.location.search)
this.filePath = urlParams.get("path");
this.action = urlParams.get("action");
this.homeLink = path.append(app.getBasePath(), 'stochss/home');
},
render: function (attrs, options) {
PageView.prototype.render.apply(this, arguments);
let self = this;
$(document.querySelector("div[data-hook=side-navbar]")).css("display", "none");
$(document.querySelector("main[data-hook=page-main]")).removeClass().addClass("col-md-12 body");
$(this.queryByHook("loading-spinner")).css("display", "block");
if(this.action === "open") {
this.uploadFileFromLink(this.filePath);
setTimeout(function () {
$(self.queryByHook("loading-problem").css("display", "block"));
}, 30000);
}else if(this.action === "update-workflow") {
this.updateWorkflowFormat(this.filePath);
}else if(this.action === "update-project") {
Expand All @@ -58,7 +63,7 @@ let LoadingPage = PageView.extend({
$(self.queryByHook("loading-spinner")).css("display", "none");
let modal = $(modals.projectExportErrorHtml(body.reason, body.message)).modal();
modal.on('hidden.bs.modal', function (e) {
window.history.back();
window.location.href = this.homeLink;
});
}
app.getXHR(endpoint, {
Expand Down Expand Up @@ -125,7 +130,7 @@ let LoadingPage = PageView.extend({
},
uploadFileFromLink: function (filePath) {
$(this.queryByHook("loading-header")).html("Uploading file");
$(this.queryByHook("loading-target")).html(filePath.split('/').pop());
$(this.queryByHook("loading-target")).css("display", "none")
let message = `If the file is a Project, Workflow, Model, Domain, or Notebook it will be opened when the upload has completed.`;
$(this.queryByHook("loading-message")).html(message);
let self = this;
Expand Down
6 changes: 5 additions & 1 deletion client/templates/pages/loadingPage.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ section.page

div.centered.mt-5

p(data-hook="loading-message") Loading Page Message
p(data-hook="loading-message") Loading Page Message

div.centered.mt-3(data-hook="loading-problem" style="display: none;")

p Something may have gone wrong click <a href=this.homeLink>here</a> to go back
6 changes: 5 additions & 1 deletion client/views/file-browser-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,10 +948,14 @@ module.exports = View.extend({
app.getXHR(endpoint, {
success: function (err, response, body) {
let title = body.message;
let linkHeaders = ["Presentation Link", "Download Link", "Open Link"];
let linkHeaders = "Shareable Presentation Link";
let links = body.links;
let name = o.original._path.split('/').pop().split('.ipynb')[0];
$(modals.presentationLinks(title, name, linkHeaders, links)).modal();
let copyBtn = document.querySelector('#presentationLinksModal #copy-to-clipboard');
copyBtn.addEventListener('click', function (e) {
app.copyToClipboard(links.presentation)
});
},
error: function (err, response, body) {
$(modals.newProjectModelErrorHtml(body.Reason, body.Message)).modal();
Expand Down
6 changes: 5 additions & 1 deletion client/views/model-state-buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,14 @@ module.exports = View.extend({
success: function (err, response, body) {
self.endAction("publish");
let title = body.message;
let linkHeaders = ["Presentation Link", "Download Link", "Open Link"];
let linkHeaders = "Shareable Presentation Link";
let links = body.links;
let name = self.model.name
$(modals.presentationLinks(title, name, linkHeaders, links)).modal();
let copyBtn = document.querySelector('#presentationLinksModal #copy-to-clipboard');
copyBtn.addEventListener('click', function (e) {
app.copyToClipboard(links.presentation)
});
},
error: function (err, response, body) {
self.errorAction();
Expand Down
1 change: 1 addition & 0 deletions stochss/handlers/util/stochss_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ def upload_from_link(self, remote_path):
file = f"{json.loads(body)['name']}.{ext}"
elif ext == "ipynb":
file = json.loads(body)['file']
body = json.dumps(json.loads(body)['notebook'])
else:
file = self.get_file(path=remote_path)
path = self.get_new_path(dst_path=file)
Expand Down

0 comments on commit bbbaf58

Please sign in to comment.