Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:stochss/stochss into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
seanebum committed Jun 21, 2021
2 parents af1e390 + e105813 commit 31241fe
Show file tree
Hide file tree
Showing 322 changed files with 33,910 additions and 108,249 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/pylint_on_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
BASE_REF: ${{ github.event.pull_request.base.ref }}
- name: Get Base Lint Score
run: |
echo ::set-env name=BASE_LINT::$(git diff --name-only --diff-filter=M $HEAD_REF | grep -E "\.py" | xargs pylint | grep -E -o "at [0-9.-]+" | grep -E -o [0-9.-]+)
echo BASE_LINT=$(git diff --name-only --diff-filter=M $HEAD_REF | grep -E "\.py" | xargs pylint | grep -E -o "at [0-9.-]+" | grep -E -o [0-9.-]+) >> $GITHUB_ENV
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
if: always()
Expand All @@ -31,17 +31,20 @@ jobs:
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
- name: Get Lint Delta Sign (+/-)
run: echo ::set-env name=PASSING_SCORE::$(git diff --name-only --diff-filter=M $BASE_REF | grep -E "\.py" | xargs pylint | grep -Eo "10, [+-]" | grep -Eo [+-] )
run: |
echo PASSING_SCORE=$(git diff --name-only --diff-filter=M $BASE_REF | grep -E "\.py" | xargs pylint | grep -Eo "10, [+-]" | grep -Eo [+-] ) >> $GITHUB_ENV
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
if: always()
- name: Get Head Lint Score
run: echo ::set-env name=HEAD_LINT::$(git diff --name-only --diff-filter=M $BASE_REF | grep -E "\.py" | xargs pylint | grep -E -o "at [0-9.-]+" | grep -E -o [0-9.-]+)
run: |
echo HEAD_LINT=$(git diff --name-only --diff-filter=M $BASE_REF | grep -E "\.py" | xargs pylint | grep -E -o "at [0-9.-]+" | grep -E -o [0-9.-]+) >> $GITHUB_ENV
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
if: always()
- name: Get Added Files Lint Score
run: echo ::set-env name=ADDED_LINT::$(git diff --name-only --diff-filter=A $BASE_REF | grep -E "\.py" | xargs pylint | grep -E -o "at [0-9.-]+" | grep -E -o [0-9.-]+)
run: |
echo ADDED_LINT=$(git diff --name-only --diff-filter=A $BASE_REF | grep -E "\.py" | xargs pylint | grep -E -o "at [0-9.-]+" | grep -E -o [0-9.-]+) >> $GITHUB_ENV
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
if: always()
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ stochss-model-editor.html
stochss-workflow-manager.html
stochss-workflow-selection.html
stochss-project-manager.html
multiple-plots-page.html
stochss-domain-editor.html
stochss-loading-page.html
stochss-project-browser.html
stochss-quick-start.html
stochss-user-home.html
*.swp
*.swo
package-lock.json
Expand Down
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.1.6'
__version__ = '2.3.2'
__title__ = 'StochSS'
__description__ = 'StochSS is an integrated development environment (IDE) \
for simulation of biochemical networks.'
Expand Down
120 changes: 119 additions & 1 deletion client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

//var config = require('./config.js')(process.env.NODE_ENV);
let xhr = require('xhr');
let $ = require('jquery');
let path = require('path');
//support files
let modals = require('./modals');

let routePrefix = 'stochss';
let apiPrefix = path.join(routePrefix, 'api');
Expand Down Expand Up @@ -77,14 +81,128 @@ var BrowserDetect = {
]
};

let changeCollapseButtonText = (view, e) => {
let source = e.target.dataset.hook;
let isBtn = $(view.queryByHook(source)).attr("class").includes("btn");
let collapseContainer = $(view.queryByHook(source).dataset.target);
if(isBtn && !collapseContainer.attr("class").includes("collapsing")) {
let collapseBtn = $(view.queryByHook(source));
let text = collapseBtn.text();
text === '+' ? collapseBtn.text('-') : collapseBtn.text('+');
}
};

let registerRenderSubview = (parent, view, hook) => {
parent.registerSubview(view);
parent.renderSubview(view, parent.queryByHook(hook));
};

let getXHR = (endpoint, {
always = function (err, response, body) {}, success = function (err, response, body) {},
error = function (err, response, body) {}}={}) => {
xhr({uri: endpoint, json: true}, function (err, response, body) {
if(response.statusCode < 400) {
success(err, response, body);
}else if(response.statusCode < 500) {
error(err, response, body);
}else{
console.log("Critical Error Detected");
}
always(err, response, body);
});
};

let postXHR = (endpoint, data, {
always = function (err, response, body) {}, success = function (err, response, body) {},
error = function (err, response, body) {}}={}, isJSON) => {
xhr({uri: endpoint, json: isJSON !== undefined ? isJSON : true, method: "post", body: data}, function (err, response, body) {
if(response.statusCode < 400) {
success(err, response, body);
}else if(response.statusCode < 500) {
error(err, response, body);
}else{
console.log("Critical Error Detected");
}
always(err, response, body);
});
};

let getBrowser = () => {
BrowserDetect.init();
return {"name":BrowserDetect.browser,"version":BrowserDetect.version};
}

let validateName = (input, rename = false) => {
var error = ""
if(input.endsWith('/')) {
error = 'forward'
}
var invalidChars = "`~!@#$%^&*=+[{]}\"|:;'<,>?\\"
if(rename) {
invalidChars += "/"
}
for(var i = 0; i < input.length; i++) {
if(invalidChars.includes(input.charAt(i))) {
error = error === "" || error === "special" ? "special" : "both"
}
}
return error
}

let newWorkflow = (parent, mdlPath, isSpatial, type) => {
if(document.querySelector('#newWorkflowModal')) {
document.querySelector('#newWorkflowModal').remove()
}
let self = parent;
let ext = isSpatial ? /.smdl/g : /.mdl/g
let name = mdlPath.split('/').pop().replace(ext, "")
let modal = $(modals.newWorkflowHtml(name, type)).modal();
let okBtn = document.querySelector('#newWorkflowModal .ok-model-btn');
let input = document.querySelector('#newWorkflowModal #workflowNameInput');
okBtn.disabled = false;
input.addEventListener("keyup", function (event) {
if(event.keyCode === 13){
event.preventDefault();
okBtn.click();
}
});
input.addEventListener("input", function (e) {
let endErrMsg = document.querySelector('#newWorkflowModal #workflowNameInputEndCharError')
let charErrMsg = document.querySelector('#newWorkflowModal #workflowNameInputSpecCharError')
let error = validateName(input.value)
okBtn.disabled = error !== "" || input.value.trim() === ""
charErrMsg.style.display = error === "both" || error === "special" ? "block" : "none"
endErrMsg.style.display = error === "both" || error === "forward" ? "block" : "none"
});
okBtn.addEventListener('click', function (e) {
modal.modal("hide");
let typeCode = type === "Ensemble Simulation" ? "_ES" : "_PS";
let wkflFile = input.value.trim() + typeCode + ".wkfl";
if(mdlPath.includes(".proj") && !mdlPath.includes(".wkgp")){
var wkflPath = path.join(path.dirname(mdlPath), "WorkflowGroup1.wkgp", wkflFile);
}else{
var wkflPath = path.join(path.dirname(mdlPath), wkflFile);
}
let queryString = "?path=" + wkflPath + "&model=" + mdlPath + "&type=" + type;
let endpoint = path.join(getApiPath(), "workflow/new") + queryString;
getXHR(endpoint, {
success: function (err, response, body) {
window.location.href = path.join(getBasePath(), "stochss/workflow/edit") + "?path=" + body.path;
}
});
});
}

module.exports = {
routePrefix: routePrefix,
getApiPath: getApiPath,
getBasePath: getBasePath,
getBrowser: getBrowser
getBrowser: getBrowser,
registerRenderSubview: registerRenderSubview,
changeCollapseButtonText: changeCollapseButtonText,
newWorkflow: newWorkflow,
getXHR: getXHR,
postXHR: postXHR
};


77 changes: 69 additions & 8 deletions client/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,39 @@ let templates = {
</div>
</div>
</div>`
},
fileSelect : (modalID, fileID, locationID, title, label, files) => {
return `
<div id=${modalID} class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">${title}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div>
<label for=${fileID}>${label}</label>
<select id=${fileID} name=${fileID} autofocus>
${files}
</select>
</div>
<div id="location-container" style="display: none;">
<div class="text-info">This model was found in multiple locations</div>
<label for=${locationID}>Location: </label>
<select id=${locationID} name=${locationID} autofocus>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary ok-model-btn box-shadow" disabled>OK</button>
<button type="button" class="btn btn-secondary box-shadow" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>`
}
}

Expand All @@ -200,10 +233,14 @@ module.exports = {

return templates.confirmation(modalID, title)
},
moveToTrashConfirmHtml : (fileType) => {
moveToTrashConfirmHtml : (fileType, newProjectFormat=false) => {
let modalID = "moveToTrashConfirmModal"
let title = `Move this ${fileType} to trash?`

if(newProjectFormat) {
let message = "The workflows for this model will be archived"
return templates.confirmation_with_message(modalID, title, message);
}
return templates.confirmation(modalID, title)
},
emptyTrashConfirmHtml : () => {
Expand Down Expand Up @@ -237,17 +274,19 @@ module.exports = {

return templates.input(modalID, inputID, title, label, value)
},
newProjectModelHtml : (options) => {
newProjectModelHtml : (files) => {
let modalID = "newProjectModelModal"
let selectID = "modelPathInput"
let fileID = "modelFileInput"
let locationID = "modelPathInput"
let title = "Add Existing Model to Project"
let label = "Path to the Model"
options = options.map(function (name) {
return `<option value="${name}">${name}</option>`
let label = "Models: "
files = files.map(function (file) {
return `<option value="${file[0]}">${file[1]}</option>`
})
options = options.join(" ")
files.unshift(`<option value="">-- Select a model --</option>`)
files = files.join(" ")

return templates.select(modalID, selectID, title, label, options)
return templates.fileSelect(modalID, fileID, locationID, title, label, files)
},
newProjectModelSuccessHtml : (message) => {
let modalID = "newProjectModelSuccessModal"
Expand Down Expand Up @@ -428,6 +467,28 @@ module.exports = {

return templates.message(modalID, title, message)
},
newWorkflowHtml: (name, type) => {
let modalID = "newWorkflowModal"
let inputID = "workflowNameInput"
let title = `New ${type} Workflow`
let label = "Name:"
let value = name

return templates.input(modalID, inputID, title, label, value);
},
updateFormatHtml: (fileType) => {
let modalID = `update${fileType}FormatModal`
let title = `Update ${fileType} Format`
if(fileType === "Project") {
fileType += "s and Workflow";
var target = "project and its workflows";
}else{
var target = "workflow";
}
let message = `StochSS ${fileType}s have a new format. Would you like to update this ${target} to the new format?`

return templates.confirmation_with_message(modalID, title, message);
},
renderDefaultModeModalHtml : () => {
let concentrationDesciption = `Variables will only be represented using continuous (floating point) values.`;
let populationDescription = `Population - Variables will only be represented using discrete (integer count) values.`;
Expand Down
3 changes: 2 additions & 1 deletion client/models/creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module.exports = State.extend({
fname: 'string',
lname: 'string',
email: 'string',
organization: 'string'
organization: 'string',
elementID: 'string'
},
initialize: function(attrs, options) {
State.prototype.initialize.apply(this, arguments)
Expand Down
25 changes: 19 additions & 6 deletions client/models/models.js → client/models/creators.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

var app = require('ampersand-app');
var RestCollection = require('ampersand-rest-collection');
var Model = require('./model');
var path = require('path');
//collections
let Collection = require('ampersand-collection');
//models
let Creator = require('./creator');

module.exports = RestCollection.extend({
model: Model
module.exports = Collection.extend({
model: Creator,
indexes: ["elementID"],
addCreator: function (creatorInfo) {
let elementID = "C" + (this.length + 1);
let creator = new Creator({
fname: creatorInfo.fname,
lname: creatorInfo.lname,
email: creatorInfo.email,
organization: creatorInfo.organization,
elementID: elementID
});
this.add(creator);
return creator;
}
});
3 changes: 2 additions & 1 deletion client/models/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ module.exports = State.extend({
size: 'number',
x_lim: 'object',
y_lim: 'object',
z_lim: 'object'
z_lim: 'object',
static: 'boolean'
},
collections: {
types: Types,
Expand Down
Loading

0 comments on commit 31241fe

Please sign in to comment.