Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/src/Database/Type/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class MySQL extends DatabaseParent {
'DewarReport',
'CourierTermsAccepted',

'BLSamplePosition',
'BLSubSample',
'PDB',
'Protein_has_PDB',
Expand Down
40 changes: 36 additions & 4 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ class Sample extends Page
'scid' => '\d+-\d+',

'BLSAMPLEID' => '\d+',
'X' => '\d+(.\d+)?',
'Y' => '\d+(.\d+)?',
'X' => '\d*(.\d+)?',
'Y' => '\d*(.\d+)?',
'Z' => '\d+(.\d+)?',
'X2' => '\d+(.\d+)?',
'Y2' => '\d+(.\d+)?',
Expand Down Expand Up @@ -799,6 +799,9 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
po2.posx as x2,
po2.posy as y2,
po2.posz as z2,
bsp.posx as dispensex,
bsp.posy as dispensey,
bsp.posz as dispensez,
IF(cqs.containerqueuesampleid IS NOT NULL AND cqs.containerqueueid IS NULL, 1, 0) as readyforqueue,
cq.containerqueueid,
count(distinct IF(dc.overlap != 0,
Expand All @@ -824,7 +827,7 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
INNER JOIN shipping sh ON sh.shippingid = d.shippingid
INNER JOIN proposal p ON p.proposalid = sh.proposalid


LEFT OUTER JOIN blsampleposition bsp ON bsp.blsampleid = s.blsampleid
LEFT OUTER JOIN containerqueuesample cqs ON cqs.blsubsampleid = ss.blsubsampleid
LEFT OUTER JOIN containerqueue cq ON cqs.containerqueueid = cq.containerqueueid AND cq.completedtimestamp IS NULL

Expand Down Expand Up @@ -1903,11 +1906,12 @@ function _update_sample()
if (!$this->has_arg('sid'))
$this->_error('No sampleid specified');

$samp = $this->db->pq("SELECT b.blsampleid, pr.proteinid,cr.crystalid,dp.diffractionplanid
$samp = $this->db->pq("SELECT b.blsampleid, pr.proteinid,cr.crystalid,dp.diffractionplanid,bsp.blsamplepositionid
FROM blsample b
INNER JOIN crystal cr ON cr.crystalid = b.crystalid
INNER JOIN protein pr ON pr.proteinid = cr.proteinid
LEFT OUTER JOIN diffractionplan dp on dp.diffractionplanid = b.diffractionplanid
LEFT OUTER JOIN blsampleposition bsp ON bsp.blsampleid = b.blsampleid AND bsp.positiontype='dispensing'
WHERE pr.proposalid = :1 AND b.blsampleid = :2", array($this->proposalid, $this->arg('sid')));

if (!sizeof($samp))
Expand Down Expand Up @@ -1980,6 +1984,34 @@ function _update_sample()
}
}
}

if ($this->has_arg('X') && $this->has_arg('Y')) {
$z = $this->has_arg('Z') ? $this->arg('Z') : null;
$pid = $samp['BLSAMPLEPOSITIONID'];
if ($this->arg('X') == '' && $this->arg('Y') == '') {
if (!empty($pid)) {
$this->db->pq(
"UPDATE blsampleposition SET posx=null, posy=null, posz=null, recordtimestamp=CURRENT_TIMESTAMP WHERE blsamplepositionid=:1",
array($pid)
);
}
} else {
if (empty($pid)) {
$this->db->pq(
"INSERT INTO blsampleposition (blsampleid, posx, posy, posz, positiontype, recordtimestamp)
VALUES (:1, :2, :3, :4, 'dispensing', CURRENT_TIMESTAMP) RETURNING blsamplepositionid INTO :id",
array($this->arg('sid'), $this->arg('X'), $this->arg('Y'), $z)
);
$pid = $this->db->id();
} else {
$this->db->pq(
"UPDATE blsampleposition SET posx=:1, posy=:2, posz=:3, recordtimestamp=CURRENT_TIMESTAMP WHERE blsamplepositionid=:4",
array($this->arg('X'), $this->arg('Y'), $z, $pid)
);
}
}
$this->_output(array('BLSAMPLEPOSITIONID' => $pid));
}
}


Expand Down
20 changes: 19 additions & 1 deletion client/src/js/models/sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ define(['backbone', 'collections/components',
this.listenTo(this, 'change:RADIATIONSENSITIVITY', this.updateRadSen)
this.updateRadSen()

this.listenTo(this, 'change:X', this.updatePosition)

this.listenTo(this, 'change', this.updateHasData)
this.updateHasData()

},

updatePosition: function() {
this.save(this.changedAttributes(), { patch: true })
},

updateHasData: function() {
var hasData = this.get('DC') > 0 || this.get('GR') > 0 || this.get('SC') > 0
if (hasData !== this.get('HASDATA')) this.set('HASDATA', hasData)
Expand Down Expand Up @@ -98,7 +104,10 @@ define(['backbone', 'collections/components',
VOLUME: '',
INITIALSAMPLEGROUP: '',
COMPONENTIDS: [],
COMPONENTAMOUNTS: []
COMPONENTAMOUNTS: [],
X: null,
Y: null,
Z: null,
},

validation: {
Expand Down Expand Up @@ -225,6 +234,15 @@ define(['backbone', 'collections/components',
required: false,
pattern: 'word'
},
X: {
required: false
},
Y: {
required: false
},
Z: {
required: false
},

COMPONENTAMOUNTS: function(from_ui, attr, all_values) {
var values = all_values.components.pluck('ABUNDANCE')
Expand Down
36 changes: 34 additions & 2 deletions client/src/js/modules/imaging/views/imageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define(['marionette',
'backbone',
'modules/imaging/collections/inspectionimagescores',

'models/sample',
'models/subsample',
'collections/subsamples',

Expand All @@ -18,7 +19,7 @@ define(['marionette',
'backbone-validation',
], function(Marionette,
Backbone,
ImageScores, Subsample, Subsamples, ImageHistory, InspectionImage, Attachments,
ImageScores, Sample, Subsample, Subsamples, ImageHistory, InspectionImage, Attachments,
Editable, utils, XHRImage, HeatMap,
template) {

Expand Down Expand Up @@ -175,6 +176,10 @@ define(['marionette',
},
})
}

if (this.add_dispensing) {
this.editDispensing(x, y)
}
},

setAddSubsample: function(state) {
Expand All @@ -184,7 +189,21 @@ define(['marionette',
setAddSubsampleRegion: function(state) {
this.add_region = state
},


setAddDispensing: function(state) {
this.add_dispensing = state
},

deleteDispensing: function() {
this.editDispensing('', '')
},

editDispensing: function(x, y) {
var s = new Sample({ BLSAMPLEID: this.model.get('BLSAMPLEID') })
s.set({ X: x, Y: y })
this.trigger('finishdispensing')
this.subsamples.fetch()
},

remSubsample: function() {
this.draw()
Expand All @@ -204,6 +223,7 @@ define(['marionette',
initialize: function(options) {
this.add_object = false
this.add_region = false
this.add_dispensing = false

this.plotObjects = _.debounce(this.plotObjects, 200)
this.drawDebounce = _.debounce(this.draw, 10)
Expand Down Expand Up @@ -1004,6 +1024,18 @@ define(['marionette',
this.ctx.fillStyle = options.o.get('isSelected') ? 'turquoise' : options.o.get('SOURCE') === 'auto' ? 'darkblue' : 'red'
this.ctx.font = parseInt(14*m)+'px Arial'
this.ctx.fillText(parseInt(options.o.get('RID'))+1,x-(m*15), y-(m*6))

if (options.o.get('DISPENSEX') && options.o.get('DISPENSEY')) {
var disx = parseInt(options.o.get('DISPENSEX'))
var disy = parseInt(options.o.get('DISPENSEY'))
this.ctx.strokeStyle = 'white'
this.ctx.beginPath()
this.ctx.arc(disx, disy, 50, 0, 2*Math.PI)
this.ctx.stroke()
this.ctx.fillStyle = 'white'
this.ctx.fillText('D',disx-5*m, disy+5*m)
this.ctx.closePath()
}
},

drawBeam: function(o) {
Expand Down
57 changes: 57 additions & 0 deletions client/src/js/modules/shipment/views/containerplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ define(['marionette',
add: '.add_image',
ads: 'a.add_point',
adr: 'a.add_region',
addis: 'a.add_dispensing',
deldis: 'a.del_dispensing',

drop: '.dropimage',
prog: '.progress',
Expand Down Expand Up @@ -275,6 +277,8 @@ define(['marionette',
'change @ui.ins': 'selectInspection',
'click @ui.ads': 'setAddSubsamplePoint',
'click @ui.adr': 'setAddSubsampleRegion',
'click @ui.addis': 'setAddDispensing',
'click @ui.deldis': 'deleteDispensing',
'click a.add_inspection': 'showAddInspection',
'click a.view_sched': 'showViewSchedule',
'click @ui.play': 'playInspection',
Expand Down Expand Up @@ -483,16 +487,24 @@ define(['marionette',
this.ui.ads.removeClass('button-highlight')
this.image.setAddSubsample(false)
this.ui.ads.find('span').text('Mark Point')
this.ui.ads.find('i').removeClass('fa-times').addClass('fa-plus')

} else {
this.ui.ads.addClass('button-highlight')
this.image.setAddSubsample(true)
this.ui.ads.find('span').text('Finish')
this.ui.ads.find('i').removeClass('fa-plus').addClass('fa-times')
}

this.ui.adr.removeClass('button-highlight')
this.ui.addis.removeClass('button-highlight')
this.image.setAddSubsampleRegion(false)
this.image.setAddDispensing(false)
this.ui.adr.find('span').text('Mark Region')
this.ui.adr.find('i').removeClass('fa-times').addClass('fa-plus')
this.ui.addis.find('span').text('Mark Dispensing')
this.ui.addis.find('i').removeClass('fa-times').addClass('fa-plus')
this.ui.deldis.hide()
},


Expand All @@ -503,16 +515,59 @@ define(['marionette',
this.ui.adr.removeClass('button-highlight')
this.image.setAddSubsampleRegion(false)
this.ui.adr.find('span').text('Mark Region')
this.ui.adr.find('i').removeClass('fa-times').addClass('fa-plus')

} else {
this.ui.adr.addClass('button-highlight')
this.image.setAddSubsampleRegion(true)
this.ui.adr.find('span').text('Finish')
this.ui.adr.find('i').removeClass('fa-plus').addClass('fa-times')
}

this.ui.ads.removeClass('button-highlight')
this.ui.addis.removeClass('button-highlight')
this.image.setAddSubsample(false)
this.image.setAddDispensing(false)
this.ui.ads.find('span').text('Mark Point')
this.ui.ads.find('i').removeClass('fa-times').addClass('fa-plus')
this.ui.addis.find('span').text('Mark Dispensing')
this.ui.addis.find('i').removeClass('fa-times').addClass('fa-plus')
this.ui.deldis.hide()
},

setAddDispensing: function(e) {
if (e) e.preventDefault()

if (this.ui.addis.hasClass('button-highlight')) {
this.ui.addis.removeClass('button-highlight')
this.image.setAddDispensing(false)
this.ui.addis.find('span').text('Mark Dispensing')
this.ui.addis.find('i').removeClass('fa-times').addClass('fa-plus')
this.ui.deldis.hide()

} else {
this.ui.addis.addClass('button-highlight')
this.image.setAddDispensing(true)
this.ui.addis.find('span').text('Cancel')
this.ui.addis.find('i').removeClass('fa-plus').addClass('fa-times')
if (this.subsamples.length && this.subsamples.findWhere({ BLSAMPLEID: this.getSample() }).get('DISPENSEX')) {
this.ui.deldis.show()
}
}

this.ui.ads.removeClass('button-highlight')
this.ui.adr.removeClass('button-highlight')
this.image.setAddSubsample(false)
this.image.setAddSubsampleRegion(false)
this.ui.ads.find('span').text('Mark Point')
this.ui.ads.find('i').removeClass('fa-times').addClass('fa-plus')
this.ui.adr.find('span').text('Mark Region')
this.ui.adr.find('i').removeClass('fa-times').addClass('fa-plus')
},

deleteDispensing: function(e) {
e.preventDefault()
this.image.deleteDispensing()
},


Expand Down Expand Up @@ -905,12 +960,14 @@ define(['marionette',
this.listenTo(this.image, 'image:prev', this.prevImage, this)
this.listenTo(this.image, 'image:first', this.firstImage, this)
this.listenTo(this.image, 'image:last', this.lastImage, this)
this.listenTo(this.image, 'finishdispensing', this.setAddDispensing, this)

if (this.getOption('params').iid) this.ui.ins.val(this.getOption('params').iid)
this.selectInspection()

this.ui.prog.hide()
this.ui.prog.progressbar({ value: 0 })
this.ui.deldis.hide()

this.img.show(this.image)
this.sten.show(new ImageHistoryView({ historyimages: this.startendimages, embed: true }))
Expand Down
2 changes: 2 additions & 0 deletions client/src/js/templates/shipment/containerplateimage.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ <h2>Marked Sub Samples</h2>
<div class="ra">
<a href="#" class="button add_point"><i class="fa fa-plus"></i> <span>Mark Point</span></a>
<a href="#" class="button add_region"><i class="fa fa-plus"></i> <span>Mark Region</span></a>
<a href="#" class="button add_dispensing"><i class="fa fa-plus"></i> <span>Mark Dispensing</span></a>
<a href="#" class="button del_dispensing"><i class="fa fa-trash"></i> <span>Delete</span></a>
</div>
<div class="subs"></div>
</div>
Expand Down
Loading