Skip to content

Commit

Permalink
Merge pull request #1074 from StochSS/develop
Browse files Browse the repository at this point in the history
Release v2.2.1
  • Loading branch information
makdl authored Mar 11, 2021
2 parents 7db230a + 9fb9f54 commit 25c210e
Show file tree
Hide file tree
Showing 46 changed files with 765 additions and 297 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ 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 \
&& tar -xvzf julia-1.4.2-linux-x86_64.tar.gz \
&& mv julia-1.4.2 /usr/local/ \
&& 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

Expand Down
12 changes: 12 additions & 0 deletions client/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,18 @@ module.exports = {

return templates.select(modalID, selectID, title, label, options)
},
selectSpeciesHTML : (species) => {
let modalID = "speciesSelectModal";
let selectID = "speciesSelectList";
let title = "Preview Variable Selection";
let label = "Select a variable to preview: ";
var options = species.map(function (name) {
return `<option value="${name}">${name}</option>`
});
options = options.join(" ");

return templates.select(modalID, selectID, title, label, options)
},
projectExportSuccessHtml : (fileType, message) => {
let modalID = "projectExportSuccessModal"
let title = `Successfully Exported the ${fileType}`
Expand Down
6 changes: 4 additions & 2 deletions client/models/domain-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ var Collection = require('ampersand-collection');
module.exports = Collection.extend({
model: Type,
indexes: ['typeID'],
addType: function (vol, mass, nu, fixed) {
let id = this.parent.getDefaultTypeID();
addType: function (vol, mass, nu, fixed, id=null) {
if(!id) {
id = this.parent.getDefaultTypeID();
}
let name = String(id);
var type = new Type({
fixed: fixed,
Expand Down
8 changes: 6 additions & 2 deletions client/models/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,18 @@ module.exports = Model.extend({
//TODO: implement auto save
},
//called when save button is clicked
saveModel: function () {
saveModel: function (cb=null) {
var self = this;
this.species.map(function (specie) {
self.species.trigger('update-species', specie.compID, specie, false, false);
});
this.parameters.map(function (parameter) {
self.parameters.trigger('update-parameters', parameter.compID, parameter);
});
this.save();
if(cb) {
this.save({success: cb});
}else{
this.save()
}
},
});
113 changes: 91 additions & 22 deletions client/pages/domain-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ let DomainEditor = PageView.extend({
this.renderEditTypeDefaults();
},
handleImportMesh: function (e) {
this.startAction("Importing mesh ...", "im")
let data = {"type":null, "transformation":null}
let id = Number($(this.queryByHook("mesh-type-select")).find('select')[0].value)
if(id > 0) {
Expand Down Expand Up @@ -116,6 +117,12 @@ let DomainEditor = PageView.extend({
self.domain.z_lim[1] = resp.limits.z_lim[1]
}
self.renderDomainLimitations();
self.completeAction("Mesh successfully imported", "im")
$('html, body').animate({
scrollTop: $("#domain-plot").offset().top
}, 20);
}else{
self.errorAction(resp.Message, "im")
}
}
req.send(formData)
Expand All @@ -140,11 +147,16 @@ let DomainEditor = PageView.extend({
},
handleSaveToModel: function () {
if(this.model) {
this.startAction("Saving domain to model ...", "sd");
this.model.domain = this.domain;
this.model.saveModel();
this.model.saveModel(_.bind(function () {
this.completeAction("Domain saved to model", "sd");
}, this));
window.history.back();
}
},
handleSaveToFile: function () {
this.startAction("Saving the domain to file (.domn) ...", "sd")
if(this.domain.directory && !this.domain.dirname) {
this.saveDomain()
}else{
Expand Down Expand Up @@ -182,6 +194,8 @@ let DomainEditor = PageView.extend({
let value = e.srcElement.value;
if(value) {
if(this.typeDescriptions[value].length <= 1) {
$(this.queryByHook("type-location-message")).css('display', "none");
$(this.queryByHook("type-location-container")).css("display", "none");
this.typeDescriptionsFile = this.typeDescriptions[value][0];
var disabled = false;
}else{
Expand Down Expand Up @@ -238,7 +252,7 @@ let DomainEditor = PageView.extend({
$('[autofocus]', e.target).focus();
});
},
addParticle: function (newPart, fromImport=false) {
addParticle: function (newPart, {fromImport=false, cb=null}={}) {
this.domain.particles.addParticle(newPart.point, newPart.volume,
newPart.mass, newPart.type,
newPart.nu, newPart.fixed);
Expand All @@ -249,15 +263,19 @@ let DomainEditor = PageView.extend({
this.plot.data[particle.type].y.push(particle.point[1]);
this.plot.data[particle.type].z.push(particle.point[2]);
if(!fromImport) {
this.renderNewParticle();
this.renderDomainTypes();
this.updatePlot();
}else{
console.log("From Imports")
}
if(cb) {
cb();
}
},
addParticles: function (particles) {
let self = this;
particles.forEach(function (particle) {
self.addParticle(particle, true);
self.addParticle(particle, {fromImport: true});
});
this.renderDomainTypes();
this.updatePlot();
Expand All @@ -269,7 +287,7 @@ let DomainEditor = PageView.extend({
let domainType = self.domain.types.get(type, "typeID");
if(!domainType) {
self.domain.types.addType(defaultType.volume, defaultType.mass,
defaultType.nu, defaultType.fixed);
defaultType.nu, defaultType.fixed, type);
self.addType(String(type));
}
});
Expand Down Expand Up @@ -340,6 +358,16 @@ let DomainEditor = PageView.extend({
this.plot.data[type].z.push(z);
this.actPart.part.typeChanged = false;
},
completeAction: function (action, src) {
$(this.queryByHook(src + "-in-progress")).css("display", "none");
$(this.queryByHook(src + "-action-complete")).text(action);
$(this.queryByHook(src + "-complete")).css("display", "inline-block");
console.log(action)
let self = this
setTimeout(function () {
$(self.queryByHook(src + "-complete")).css("display", "none");
}, 5000);
},
deleteParticle: function () {
this.domain.particles.removeParticle(this.actPart.part);
this.plot.data[this.actPart.tn].ids.splice(this.actPart.pn, 1);
Expand All @@ -350,6 +378,9 @@ let DomainEditor = PageView.extend({
this.updatePlot();
this.renderEditParticle();
this.renderDomainTypes();
$('html, body').animate({
scrollTop: $("#domain-plot").offset().top
}, 20);
},
deleteType: function (typeID) {
if(this.actPart.part && this.actPart.part.type >= typeID) {
Expand Down Expand Up @@ -385,6 +416,12 @@ let DomainEditor = PageView.extend({
Plotly.newPlot(el, this.plot);
el.on('plotly_click', _.bind(this.selectParticle, this));
},
errorAction: function (action, src) {
$(this.queryByHook(src + "-in-progress")).css("display", "none");
$(this.queryByHook(src + "-action-error")).text(action);
$(this.queryByHook(src + "-error")).css("display", "block");
console.log(action)
},
getBreadcrumbData: function () {
var data = {"project":null, "model":null};
var projEP = "stochss/project/manager?path="
Expand Down Expand Up @@ -423,14 +460,17 @@ let DomainEditor = PageView.extend({
return particle;
},
getTypesFromFile: function (typePath) {
this.startAction("Setting types ...", "st")
let self = this;
let queryStr = "?path=" + this.typeDescriptionsFile;
let endpoint = path.join(app.getApiPath(), "spatial-model/particle-types") + queryStr;
xhr({uri: endpoint, json: true}, function (err, resp, body) {
if(resp.statusCode < 400) {
self.addMissingTypes(body.names)
self.changeParticleTypes(body.types)
self.completeAction("Types set", "st")
}else{
self.errorAction(body.Message, "st")
console.log(err)
}
});
Expand All @@ -439,41 +479,54 @@ let DomainEditor = PageView.extend({
this.domain.types.get(index, "typeID").name = newName;
this.renderEditParticle();
this.renderNewParticle();
this.renderTypeSelectView();
this.renderCreate3DDomain();
this.plot.data[index].name = newName;
this.updatePlot();
},
renderCreate3DDomain: function () {
let create3DDomainView = new Create3DDomainView({
if(this.create3DDomainView) {
this.create3DDomainView.remove()
}
this.create3DDomainView = new Create3DDomainView({
parent: this,
model: this.domain
});
this.registerRenderSubview(create3DDomainView, "add-3d-domain");
this.registerRenderSubview(this.create3DDomainView, "add-3d-domain");
},
renderDomainLimitations: function () {
let xLimMinView = new InputView({parent: this, required: true,
if(this.xLimMinView) {
this.xLimMinView.remove();
this.yLimMinView.remove();
this.zLimMinView.remove();
this.xLimMaxView.remove();
this.yLimMaxView.remove();
this.zLimMaxView.remove();
}
this.xLimMinView = new InputView({parent: this, required: true,
name: 'x-lim-min', valueType: 'number',
value: this.domain.x_lim[0] || 0});
this.registerRenderSubview(xLimMinView, "x_lim-min");
let yLimMinView = new InputView({parent: this, required: true,
this.registerRenderSubview(this.xLimMinView, "x_lim-min");
this.yLimMinView = new InputView({parent: this, required: true,
name: 'y-lim-min', valueType: 'number',
value: this.domain.y_lim[0] || 0});
this.registerRenderSubview(yLimMinView, "y_lim-min");
let zLimMinView = new InputView({parent: this, required: true,
this.registerRenderSubview(this.yLimMinView, "y_lim-min");
this.zLimMinView = new InputView({parent: this, required: true,
name: 'z-lim-min', valueType: 'number',
value: this.domain.z_lim[0] || 0});
this.registerRenderSubview(zLimMinView, "z_lim-min");
let xLimMaxView = new InputView({parent: this, required: true,
this.registerRenderSubview(this.zLimMinView, "z_lim-min");
this.xLimMaxView = new InputView({parent: this, required: true,
name: 'x-lim-max', valueType: 'number',
value: this.domain.x_lim[1] || 0});
this.registerRenderSubview(xLimMaxView, "x_lim-max");
let yLimMaxView = new InputView({parent: this, required: true,
this.registerRenderSubview(this.xLimMaxView, "x_lim-max");
this.yLimMaxView = new InputView({parent: this, required: true,
name: 'y-lim-max', valueType: 'number',
value: this.domain.y_lim[1] || 0});
this.registerRenderSubview(yLimMaxView, "y_lim-max");
let zLimMaxView = new InputView({parent: this, required: true,
this.registerRenderSubview(this.yLimMaxView, "y_lim-max");
this.zLimMaxView = new InputView({parent: this, required: true,
name: 'z-lim-max', valueType: 'number',
value: this.domain.z_lim[1] || 0});
this.registerRenderSubview(zLimMaxView, "z_lim-max");
this.registerRenderSubview(this.zLimMaxView, "z_lim-max");
},
renderDomainProperties: function () {
let densityView = new InputView({parent: this, required: true,
Expand Down Expand Up @@ -692,7 +745,10 @@ let DomainEditor = PageView.extend({
this.registerRenderSubview(this.typesLocationSelectView, "types-file-location-select")
},
renderTypeSelectView: function () {
var typeView = new SelectView({
if(this.typeView) {
this.typeView.remove()
}
this.typeView = new SelectView({
label: 'Type: ',
name: 'type',
required: true,
Expand All @@ -702,7 +758,7 @@ let DomainEditor = PageView.extend({
options: this.domain.types,
value: this.domain.types.get(0, "typeID")
});
this.registerRenderSubview(typeView, "mesh-type-select")
this.registerRenderSubview(this.typeView, "mesh-type-select")
},
saveDomain: function (name=null) {
let domain = this.domain.toJSON();
Expand All @@ -713,10 +769,14 @@ let DomainEditor = PageView.extend({
}else{
var domainPath = this.domain.directory;
}
let self = this;
let endpoint = path.join(app.getApiPath(), "file/json-data") + "?path=" + domainPath;
xhr({uri: endpoint, method: "post", json: true, body: domain}, function (err, response, body) {
if(response.statusCode >= 400) {
self.errorAction(body.Message, "sd");
console.log(body.message)
}else{
self.completeAction("Domain save to file (.domn)", "sd");
}
});
},
Expand Down Expand Up @@ -761,6 +821,12 @@ let DomainEditor = PageView.extend({
let value = Number(e.target.value)
this.domain.c_0 = value;
},
startAction: function (action, src) {
$(this.queryByHook(src + "-complete")).css("display", "none");
$(this.queryByHook(src + "-action-in-progress")).text(action);
$(this.queryByHook(src + "-in-progress")).css("display", "inline-block");
console.log(action)
},
unassignAllParticles: function (type, update=true) {
let self = this;
this.domain.particles.forEach(function (particle) {
Expand Down Expand Up @@ -790,7 +856,7 @@ let DomainEditor = PageView.extend({
let id = Number(e.target.selectedOptions.item(0).value);
this.renderMeshTypeDefaults(id);
},
updateParticle: function () {
updateParticle: function ({cb=null}={}) {
if(this.actPart.part.pointChanged) {
let x = this.actPart.part.point[0];
let y = this.actPart.part.point[1];
Expand All @@ -803,6 +869,9 @@ let DomainEditor = PageView.extend({
this.renderDomainTypes();
}
this.updatePlot();
if(cb) {
cb()
}
},
updateValid: function () {},
validateName(input, rename = false) {
Expand Down
9 changes: 6 additions & 3 deletions client/pages/file-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ let FileBrowser = PageView.extend({
}
var notebookPath = path.join(app.getBasePath(), "notebooks", body.FilePath)
self.selectNode(node, body.File)
window.open(notebookPath, '_blank')
console.log(notebookPath)
window.open(notebookPath)
console.log("Opened new window")
}
});
},
Expand Down Expand Up @@ -1007,7 +1009,7 @@ let FileBrowser = PageView.extend({
},
"New Workflow" : {
"label" : "New Workflow",
"_disabled" : (nodeType === "spatial") ? true : false,
"_disabled" : false,
"separator_before" : false,
"separator_after" : false,
"action" : function (data) {
Expand All @@ -1034,10 +1036,11 @@ let FileBrowser = PageView.extend({
},
"Convert to Notebook" : {
"label" : "Convert to Notebook",
"_disabled" : true,
"_disabled" : false,
"separator_before" : false,
"separator_after" : false,
"action" : function (data) {
self.toNotebook(o, "model")
}
}
}
Expand Down
Loading

0 comments on commit 25c210e

Please sign in to comment.