Skip to content

Commit

Permalink
Merge pull request #1221 from StochSS/develop
Browse files Browse the repository at this point in the history
Release 2.3.11
  • Loading branch information
briandrawert authored Aug 6, 2021
2 parents bbbaf58 + 2bfc9f8 commit f263281
Show file tree
Hide file tree
Showing 69 changed files with 2,914 additions and 2,799 deletions.
5 changes: 5 additions & 0 deletions .win32.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DOCKER_STOCHSS_IMAGE=stochss-lab

DOCKER_BASE_IMAGE=jupyter/minimal-notebook:latest

JUPYTER_CONFIG_DIR=/opt/stochss-config/.jupyter
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ COPY --chown=jovyan:users jupyter_notebook_config.py $JUPYTER_CONFIG_DIR/jupyter

USER root

RUN wget -q https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.2-linux-x86_64.tar.gz
RUN tar -xvzf julia-1.4.2-linux-x86_64.tar.gz
RUN mv julia-1.4.2 /usr/local/
RUN chown -R jovyan:users /usr/local/julia-1.4.2/
#RUN wget -q https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.2-linux-x86_64.tar.gz
#RUN tar -xvzf julia-1.4.2-linux-x86_64.tar.gz
#RUN mv julia-1.4.2 /usr/local/
#RUN chown -R jovyan:users /usr/local/julia-1.4.2/

USER jovyan

ENV PATH="/usr/local/julia-1.4.2/bin:${PATH}"
#ENV PATH="/usr/local/julia-1.4.2/bin:${PATH}"

RUN julia -e 'using Pkg; Pkg.add("IJulia")'
RUN julia -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/stochss/gillespy2lia", rev="main"))'
#RUN julia -e 'using Pkg; Pkg.add("IJulia")'
#RUN julia -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/stochss/gillespy2lia", rev="main"))'

RUN pip install --no-cache-dir -e .

RUN rm -r /home/jovyan/work

WORKDIR /home/jovyan
WORKDIR /home/jovyan
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ update:
docker exec -it $(DOCKER_STOCHSS_IMAGE) python -m pip install -e /stochss


.PHONY: network volumes check-files pull notebook_image build
.PHONY: network volumes check-files pull notebook_image build
2 changes: 1 addition & 1 deletion __version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# @website https://github.com/stochss/stochss
# =============================================================================

__version__ = '2.3.9'
__version__ = '2.3.11'
__title__ = 'StochSS'
__description__ = 'StochSS is an integrated development environment (IDE) \
for simulation of biochemical networks.'
Expand Down
31 changes: 8 additions & 23 deletions client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,29 +212,14 @@ 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);
}
}
copyToClipboard = (text, success, error) => {
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 {
navigator.clipboard.writeText(text).then(success, error)
}
}

module.exports = {
Expand Down
15 changes: 11 additions & 4 deletions client/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ let templates = {
</div>
</div>`
},
presentationLinks : (modalID, title, name, headers, links) => {
presentationLinks : (modalID, title, headers, links) => {
return `
<div id=${modalID} class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
Expand All @@ -238,8 +238,10 @@ let templates = {
<div class="modal-body">
<h4><u>${headers}</u></h4>
<div>
<a class="inline" data-hook="view-present-link" href="${links.presentation}" target="_blank"> View ${name} Presentation</a>
<a class="btn btn-primary box-shadow inline" role="button" data-hook="view-present-link" href="${links.presentation}" target="_blank">View</a>
<button type="button" class="btn btn-primary box-shadow inline" id="copy-to-clipboard">Copy Link</button>
<div class="text-success" id="copy-link-success" style="display: none;"> Link copied to clipboard</div>
<div class="text-danger" id="copy-link-failed" style="display: none;"></div>
</div>
</div>
<div class="modal-footer">
Expand Down Expand Up @@ -567,9 +569,14 @@ module.exports = {
</div>
</div>`
},
presentationLinks : (title, name, headers, links) => {
presentationLinks : (title, headers, links) => {
let modalID = "presentationLinksModal"

return templates.presentationLinks(modalID, title, name, headers, links);
return templates.presentationLinks(modalID, title, headers, links);
},
modelErrorHtml: (title, message) => {
let modalID = "modelErrorModal";

return templates.message(modalID, title, message);
}
}
1 change: 1 addition & 0 deletions client/models/domain-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = State.extend({
this.numParticles = 0;
},
validate: function () {
if((!/^[a-zA-Z0-9_]+$/.test(this.name))) return false;
return true;
}
});
1 change: 1 addition & 0 deletions client/models/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = State.extend({
validateComponent: function () {
advanced_error = false;
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if((!/^[a-zA-Z0-9_]+$/.test(this.name))) return false;
if(!this.triggerExpression.trim()) return false;
if(!this.priority.trim()) {
this.advanced_error = true;
Expand Down
1 change: 1 addition & 0 deletions client/models/parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module.exports = State.extend({
},
validateComponent: function () {
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if((!/^[a-zA-Z0-9_]+$/.test(this.name))) return false;
if(this.expression === "" || isNaN(this.expression)) return false
return true;
}
Expand Down
1 change: 1 addition & 0 deletions client/models/reaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ module.exports = State.extend({
},
validateComponent: function () {
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if((!/^[a-zA-Z0-9_]+$/.test(this.name))) return false;
if(!this.propensity.trim() && this.reactionType === "custom-propensity") return false;
if(this.reactionType.startsWith('custom')) {
if(this.reactants.length <= 0 && this.products.length <= 0) return false;
Expand Down
1 change: 1 addition & 0 deletions client/models/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = State.extend({
},
validateComponent: function () {
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if((!/^[a-zA-Z0-9_]+$/.test(this.name))) return false;
if(!this.expression.trim()) return false;
return true;
}
Expand Down
1 change: 1 addition & 0 deletions client/models/specie.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = State.extend({
},
validateComponent: function () {
if(!this.name.trim() || this.name.match(/^\d/)) return false;
if((!/^[a-zA-Z0-9_]+$/.test(this.name))) return false;
if(this.value === "" || isNaN(this.value)) return false;
if(this.mode === "dynamic") {
if(this.isSwitchTol && (this.switchTol === "" || isNaN(this.switchTol))) return false;
Expand Down
3 changes: 3 additions & 0 deletions client/models/sweep-parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module.exports = State.extend({
steps: 'any',
hasChangedRange: 'boolean'
},
session: {
fixed: 'boolean'
},
derived: {
elementID: {
deps: ["collection"],
Expand Down
35 changes: 30 additions & 5 deletions client/pages/file-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ let _ = require('underscore');
//support files
let app = require('../app');
let modals = require('../modals');
//models
let Model = require('../models/model');
//views
let PageView = require('./base');
//templates
Expand Down Expand Up @@ -660,7 +662,23 @@ let FileBrowser = PageView.extend({
});
},
newWorkflow: function (o, type) {
app.newWorkflow(this, o.original._path, o.type === "spatial", type);
let model = new Model({
directory: o.original._path
});
app.getXHR(model.url(), {
success: function (err, response, body) {
model.set(body);
model.updateValid();
if(model.valid){
app.newWorkflow(this, o.original._path, o.type === "spatial", type);
}else{
let title = "Model Errors Detected";
let endpoint = path.join(app.getBasePath(), "stochss/models/edit") + '?path=' + model.directory;
let message = 'Errors were detected in you model <a href="' + endpoint + '">click here to fix your model<a/>';
$(modals.modelErrorHtml(title, message)).modal();
}
}
});
},
addExistingModel: function (o) {
var self = this
Expand Down Expand Up @@ -904,13 +922,20 @@ let FileBrowser = PageView.extend({
app.getXHR(endpoint, {
success: function (err, response, body) {
let title = body.message;
let linkHeaders = "Shareable Presentation Link";
let linkHeaders = "Shareable Presentation";
let links = body.links;
let name = o.original._path.split('/').pop().split('.ipynb')[0];
$(modals.presentationLinks(title, name, linkHeaders, links)).modal();
$(modals.presentationLinks(title, linkHeaders, links)).modal();
let copyBtn = document.querySelector('#presentationLinksModal #copy-to-clipboard');
copyBtn.addEventListener('click', function (e) {
app.copyToClipboard(links.presentation)
let onFulfilled = (value) => {
$("#copy-link-success").css("display", "inline-block");
}
let onReject = (reason) => {
let msg = $("#copy-link-failed");
msg.html(reason);
msg.css("display", "inline-block");
}
app.copyToClipboard(links.presentation, onFulfilled, onReject);
});
},
error: function (err, response, body) {
Expand Down
2 changes: 1 addition & 1 deletion client/pages/job-presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let Job = require("../models/job");
//views
let PageView = require('./base');
let ModelView = require('../model-view/model-view');
let ResultsView = require('../views/workflow-results');
let ResultsView = require('../views/job-results-view');
let SettingsView = require('../views/settings-viewer');
//templates
let template = require('../templates/pages/jobPresentation.pug');
Expand Down
2 changes: 1 addition & 1 deletion client/pages/loading-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ 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');
this.homeLink = path.join(app.getBasePath(), 'stochss/home');
},
render: function (attrs, options) {
PageView.prototype.render.apply(this, arguments);
Expand Down
26 changes: 22 additions & 4 deletions client/pages/model-presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ let PageView = require('./base');
let ModelView = require('../model-view/model-view');
//templates
let template = require('../templates/pages/modelPresentation.pug');
let loadingTemplate = require('../templates/pages/loadingPage.pug');
let errorTemplate = require('../templates/pages/errorTemplate.pug');

import bootstrapStyles from '../styles/bootstrap.css';
import styles from '../styles/styles.css';
import fontawesomeStyles from '@fortawesome/fontawesome-free/css/svg-with-js.min.css'

let ModelPresentationPage = PageView.extend({
template: template,
template: loadingTemplate,
initialize: function (attrs, options) {
PageView.prototype.initialize.apply(this, arguments);
let urlParams = new URLSearchParams(window.location.search);
let owner = urlParams.get("owner");
let file = urlParams.get("file");
this.fileType = file.endsWith(".mdl") ? "Model" : "Spatial Model";
this.model = new Model({
directory: file,
for: "presentation"
Expand All @@ -51,16 +54,31 @@ let ModelPresentationPage = PageView.extend({
app.getXHR(endpoint, {
success: function (err, response, body) {
self.model.set(body);
self.renderSubviews();
self.renderSubviews(false);
},
error: function (err, response, body) {
self.notFound = true;
self.renderSubviews(true);
}
});
let downloadStart = "https://live.stochss.org/stochss/download_presentation";
this.downloadLink = downloadStart + "/" + owner + "/" + file;
this.openLink = "https://open.stochss.org?open=" + this.downloadLink;
},
renderSubviews: function () {
render: function (attrs, options) {
PageView.prototype.render.apply(this, arguments);
this.renderModelView();
$(this.queryByHook("loading-header")).html(`Loading ${this.fileType}`);
$(this.queryByHook("loading-target")).css("display", "none");
$(this.queryByHook("loading-spinner")).css("display", "block");
let message = `This ${this.fileType} can be downloaded or opened in your own StochSS Live! account using the buttons at the bottom of the page.`;
$(this.queryByHook("loading-message")).html(message);
},
renderSubviews: function (notFound) {
this.template = notFound ? errorTemplate : template
PageView.prototype.render.apply(this, arguments);
if(!notFound) {
this.renderModelView();
}
},
renderModelView: function () {
let modelView = new ModelView({
Expand Down
43 changes: 30 additions & 13 deletions client/pages/notebook-presentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,61 @@ let app = require('../app');
//views
let PageView = require('./base');
//templates
let loadingTemplate = require('../templates/pages/loadingPage.pug');
let errorTemplate = require('../templates/pages/errorTemplate.pug');
let template = require('../templates/pages/notebookPresentation.pug');

import bootstrapStyles from '../styles/bootstrap.css';
import styles from '../styles/styles.css';
import fontawesomeStyles from '@fortawesome/fontawesome-free/css/svg-with-js.min.css'

let NotebookPresentationPage = PageView.extend({
template: template,
template: loadingTemplate,
initialize: function (attrs, options) {
PageView.prototype.initialize.apply(this, arguments);
let urlParams = new URLSearchParams(window.location.search);
let owner = urlParams.get("owner");
let file = urlParams.get("file");
this.fileType = "Notebook";
let self = this;
let queryStr = "?owner=" + owner + "&file=" + file;
let endpoint = "api/notebook/load" + queryStr;
app.getXHR(endpoint, {
success: function (err, response, body) {
self.name = body.file.split('/').pop().split('.ipynb')[0];
self.renderSubviews(body.html);
self.renderSubviews(false, body.html);
},
error: function (err, response, body) {
self.renderSubviews(true, null);
}
});
let downloadStart = "https://live.stochss.org/stochss/notebook/download_presentation";
this.downloadLink = downloadStart + "/" + owner + "/" + file;
this.openLink = "https://open.stochss.org?open=" + this.downloadLink;
},
renderSubviews: function (html) {
render: function (attrs, options) {
PageView.prototype.render.apply(this, arguments);
$(this.queryByHook("loading-header")).html(`Loading ${this.fileType}`);
$(this.queryByHook("loading-spinner")).css("display", "block");
$(this.queryByHook("loading-target")).css("display", "none");
let message = `This ${this.fileType} can be downloaded or opened in your own StochSS Live! account using the buttons at the bottom of the page.`;
$(this.queryByHook("loading-message")).html(message);
},
renderSubviews: function (notFound, html) {
this.template = notFound ? errorTemplate : template;
PageView.prototype.render.apply(this, arguments);
let iframe = document.getElementById('notebook');
let iframedoc = iframe.document;
if (iframe.contentDocument) {
iframedoc = iframe.contentDocument;
}else if (iframe.contentWindow) {
iframedoc = iframe.contentWindow.document;
}
if (iframedoc) {
iframedoc.write(html);
iframedoc.close();
if(!notFound){
let iframe = document.getElementById('notebook');
let iframedoc = iframe.document;
if (iframe.contentDocument) {
iframedoc = iframe.contentDocument;
}else if (iframe.contentWindow) {
iframedoc = iframe.contentWindow.document;
}
if (iframedoc) {
iframedoc.write(html);
iframedoc.close();
}
}
}
});
Expand Down
Loading

0 comments on commit f263281

Please sign in to comment.