Skip to content

Commit

Permalink
It fixes issue ispyb#499
Browse files Browse the repository at this point in the history
  • Loading branch information
antolinos committed Jul 23, 2019
1 parent 955d712 commit a4ed614
Show file tree
Hide file tree
Showing 17 changed files with 355 additions and 20 deletions.
1 change: 1 addition & 0 deletions js/core/app/exi.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function Exi(args) {

this.credentialManager.onActiveProposalChanged.attach(function(sender){
_this.mainMenu.populateCredentialsMenu();

});


Expand Down
7 changes: 7 additions & 0 deletions js/core/app/proposalmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ ProposalManager.prototype.getCrystals = function() {
return this.get()[0].crystals;
};

/**
* @method getLigands
*/
ProposalManager.prototype.getLigands = function() {
return this.get()[0].ligands;
};

/**
* @method getProteinByAcronym
*/
Expand Down
19 changes: 19 additions & 0 deletions js/core/controller/proposalexicontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,24 @@ ProposalExiController.prototype.init = function() {
EXI.addMainPanel(mainView);
mainView.load(this.params['containerId']);
}).enter(this.setPageBackground);


Path.map("#/ligands/list").to(function() {

EXI.clearNavigationPanel();
EXI.hideNavigationPanel();

EXI.setLoadingMainPanel("Searching for ligands");
var main = new LigandsMainView();
EXI.addMainPanel(main);
var onSuccessProtein = function(sender, ligands) {
main.load(ligands);
EXI.setLoadingMainPanel(false);
};
EXI.getDataAdapter({onSuccess : onSuccessProtein}).proposal.proposal.getLigandsByProposalId();
}).enter(this.setPageBackground);




};
19 changes: 17 additions & 2 deletions js/core/view/shipping/containerspreadsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ ContainerSpreadSheet.prototype.getSamplesData = function(puck) {
diffraction.axisRange,
diffraction.minOscWidth,
getValue(diffraction["observedResolution"]),
sample.comments
sample.comments,
sample.structureStage
]
);
}
Expand Down Expand Up @@ -340,7 +341,14 @@ ContainerSpreadSheet.prototype.getHeader = function() {
{ text :'Tot Rot. <br />Angle', id :'axisRange',column : {width : 60}},
{ text :'Min Osc.<br />Angle', id :'minOscWidth',column : {width : 60}},
{ text :'Observed <br />resolution', id : 'Pre-observed resolution', column : {width : 80}},
{ text :'Comments', id :'Comments', column : {width : 200}}
{ text :'Comments', id :'Comments', column : {width : 200}},
{ text :'Ligands', id : 'Ligands', column : {
width : 100,
type: 'autocomplete',
filter: 'true',
source: this.getLigandsGroupName()
}
}
];


Expand Down Expand Up @@ -390,6 +398,9 @@ ContainerSpreadSheet.prototype.getPuck = function() {
sample["smiles"] = rows[i]["Smiles"];
sample["location"]= rows[i]["location"];
sample["comments"] = rows[i]["Comments"];

sample["structureStage"] = rows[i]["Ligands"];

var proteins = [];
if (sample["crystalVO"] == null){
sample["crystalVO"] = {};
Expand Down Expand Up @@ -448,6 +459,10 @@ ContainerSpreadSheet.prototype.getProteinsByAcronym = function(acronym) {
return this.proteins[acronym];
};

ContainerSpreadSheet.prototype.getLigandsGroupName = function() {
return _.concat([""], _.uniq(_.map(EXI.proposalManager.getLigands(), function(o) {return o.groupName})));
};

/**
* Returns an object containing the crystal information given the value at the crystal form column
*
Expand Down
1 change: 1 addition & 0 deletions js/core/view/shipping/editcrystalformview.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ EditCrystalFormView.prototype.render = function () {
var html = "";
var crystalName = "";


dust.render("crystal.edit.form.template", this.crystal, function(err, out){
html = out;
});
Expand Down
37 changes: 31 additions & 6 deletions js/core/view/shipping/editcrystalstructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ function EditCrystalStructure(args) {
this.width = 600;
this.height = 500;
this.showTitle = true;

this.types = ["PDB", "FASTA"];
this.label = "Group Name";
if (args != null) {
if (args.showTitle != null) {
this.showTitle = args.showTitle;
Expand All @@ -14,6 +17,12 @@ function EditCrystalStructure(args) {
if (args.height != null) {
this.height = args.height;
}
if (args.types != null) {
this.types = args.types;
}
if (args.label != null) {
this.label = args.label;
}
}

this.onSaved = new Event(this);
Expand All @@ -33,12 +42,22 @@ EditCrystalStructure.prototype.getPanel = function () {
return this.panel;
};

/**
* Crystal might be null and then it is store as proposal
*/
EditCrystalStructure.prototype.load = function (crystal) {
var _this = this;

this.crystal = crystal;

this.crystal.url = EXI.getDataAdapter().mx.crystal.getSaveStructureURL(this.crystal.crystalId);
if (crystal){
this.crystal = crystal;

this.crystal.url = EXI.getDataAdapter().mx.crystal.getSaveStructureURL(this.crystal.crystalId);
}
else{
this.crystal = {};
this.crystal.url = EXI.getDataAdapter().proposal.proposal.saveStructure();
}
this.crystal.label = this.label;
this.crystal.types = this.types;
dust.render("structure.crystal.edit.form.template", this.crystal, function (err, out) {
html = out;
});
Expand All @@ -55,13 +74,19 @@ EditCrystalStructure.prototype.save = function () {
e.preventDefault();
/** Setting the filename */
$("#structure-fileName").val($("#structure-input-file").val().split('\\').pop());
var formData = new FormData(this);
var formData = new FormData(this);
_this.panel.setLoading();

$.ajax({
url: this.action,
type: 'POST',
data: formData,
success: function (data) {
_this.onSaved.notify();
_this.onSaved.notify(data);
_this.panel.setLoading(false);
},
error : function(error){
alert("There was an error in the server");
},
cache: false,
contentType: false,
Expand Down
76 changes: 76 additions & 0 deletions js/core/view/shipping/editligands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
function EditLigands(args) {
this.id = BUI.id();

this.width = 600;
this.height = 500;
this.showTitle = true;
if (args != null) {
if (args.showTitle != null) {
this.showTitle = args.showTitle;
}
if (args.width != null) {
this.width = args.width;
}
if (args.height != null) {
this.height = args.height;
}
}

this.onSaved = new Event(this);
};

EditLigands.prototype.getPanel = function () {

this.panel = Ext.create("Ext.panel.Panel", {
items: [{
html: '<div id="' + this.id + '"></div>',
autoScroll: false,
padding: this.padding,
width: this.width,
}]
});

return this.panel;
};

EditLigands.prototype.load = function (crystal) {
var _this = this;

this.crystal = crystal;

this.crystal.url = EXI.getDataAdapter().mx.crystal.getSaveStructureURL(this.crystal.crystalId);
dust.render("structure.crystal.edit.form.template", this.crystal, function (err, out) {
html = out;
});

$('#' + this.id).hide().html(html).fadeIn('fast');
this.panel.doLayout();
}



EditLigands.prototype.save = function () {
var _this = this;
$("#structure-form").submit(function (e) {
e.preventDefault();
/** Setting the filename */
$("#structure-fileName").val($("#structure-input-file").val().split('\\').pop());
var formData = new FormData(this);
$.ajax({
url: this.action,
type: 'POST',
data: formData,
success: function (data) {
_this.onSaved.notify();
},
cache: false,
contentType: false,
processData: false
});
});

$("#structure-form").submit();

};


8 changes: 8 additions & 0 deletions js/ispyb-client/proposal/proposaldataadapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ ProposalDataAdapter.prototype.synchSMIS= function(){
this.get('/{token}/proposal/{proposal}/update'.format([]));
};

ProposalDataAdapter.prototype.getLigandsByProposalId= function(){
this.get('/{token}/proposal/{proposal}/ligands/list');
};

ProposalDataAdapter.prototype.saveStructure= function(){
return this.getUrl('/{token}/proposal/{proposal}/structure/save');
};

ProposalDataAdapter.prototype.update= function(){
if (EXI != null){
if (EXI.proposalManager != null){
Expand Down
5 changes: 5 additions & 0 deletions js/mx/controller/proteincontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ ProteinController.prototype.init = function() {
};
EXI.getDataAdapter({onSuccess : onSuccessProtein}).mx.protein.getProteinStatsByProposalId();
}).enter(this.setPageBackground);





Path.rescue(this.notFound);

};
5 changes: 4 additions & 1 deletion js/mx/menu/mxmainmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ MXMainMenu.prototype.getHelpMenu = MainMenu.prototype.getHelpMenu;
MXMainMenu.prototype.getShipmentItem = MainMenu.prototype.getShipmentItem;
MXMainMenu.prototype.getDataExplorerMenu = MainMenu.prototype.getDataExplorerMenu;



MXMainMenu.prototype.getMenuItems = function() {

return [
this.getHomeItem(),
this.getShipmentItem(),
Expand All @@ -26,7 +29,7 @@ MXMainMenu.prototype.getMenuItems = function() {
disabled : false,
handler : function(){
location.hash = "#/protein/list";
}
}
},
{
text : this._convertToHTMLWhiteSpan("Prepare Experiment"),
Expand Down
54 changes: 46 additions & 8 deletions js/mx/menu/mxmanagermenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,19 @@ MXManagerMenu.prototype.getMenuItems = function() {
this.getShipmentItem(),
{
text : this._convertToHTMLWhiteSpan("Prepare Experiment"),
cls : 'ExiSAXSMenuToolBar',
disabled : false,
cls : 'ExiSAXSMenuToolBar',
handler : function(){
location.hash = "/mx/prepare/main";

}
}
},
{
text : this._convertToHTMLWhiteSpan("Proteins and Crystals <sub style='font-size:10px;color:orange'>NEW</sub>"),
text : this._convertToHTMLWhiteSpan("Samples <sub style='font-size:10px;color:orange'>NEW</sub>"),
cls : 'ExiSAXSMenuToolBar',
disabled : false,
handler : function(){
menu : this.getProteinCrystalsMenu()
/*handler : function(){
location.hash = "#/protein/list";
}
}*/
},
{
text : this._convertToHTMLWhiteSpan("Data Explorer"),
Expand Down Expand Up @@ -91,6 +90,45 @@ MXManagerMenu.prototype.getMenuItems = function() {
];
};



MXManagerMenu.prototype.getProteinCrystalsMenu = function() {
var _this = this;
function onItemCheck(item, checked) {
if (item.text == "Autoproc Scaling Statistics") {
var scatteringForm = new ScatteringForm();

var keys = ["ISA", "rPimWithinIPlusIMinus","anomalousMultiplicity","multiplicity","resolutionLimitLow","ccHalf",
"strategySubWedgeOrigId","completeness","rMerge","anomalous","meanIOverSigI","ccAno","autoProcScalingId",
"nTotalObservations","sigAno","rMeasWithinIPlusIMinus","anomalousCompleteness","resolutionLimitHigh",
"fractionalPartialBias","rMeasAllIPlusIMinus","nTotalUniqueObservations","rPimAllIPlusIMinus"];

var scatteringData = {title : "AutoprocIntegrator", keys : keys};

scatteringForm.load(scatteringData);
scatteringForm.show();
}
}

return Ext.create('Ext.menu.Menu', {
items : [
{
text : 'Proteins & Crystals',
handler : function(){
location.hash = "#/protein/list";
}
},
{
text : 'Ligands',
icon : '../images/icon/macromolecule.png',
handler : function(){
location.hash = "#/ligands/list";
}
}
]
});
};

MXManagerMenu.prototype.getManagerMenu = function() {
var _this = this;
function onItemCheck(item, checked) {
Expand Down Expand Up @@ -118,7 +156,7 @@ MXManagerMenu.prototype.getManagerMenu = function() {
items: [
{
text: 'Autoproc Scaling Statistics',
icon : '../images/icon/ic_insert_chart_black_36dp.png',
//icon : '../images/icon/ic_insert_chart_black_36dp.png',
handler: onItemCheck,
disabled : false
}
Expand Down
Loading

0 comments on commit a4ed614

Please sign in to comment.