Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIMS-219: Add All Samples To Queue #591

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class Sample extends Page
array('/sub/:ssid', 'put', '_update_sub_sample_full'),
array('/sub', 'post', '_add_sub_sample'),
array('/sub/:ssid', 'delete', '_delete_sub_sample'),
array('/sub/queue', 'post', '_pre_q_sub_sample'),
array('/sub/queue(/:BLSUBSAMPLEID)', 'get', '_pre_q_sub_sample'),

array('/plan', 'get', '_get_diffraction_plans'),
Expand Down
34 changes: 33 additions & 1 deletion client/src/js/modules/imaging/views/queuecontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ define(['marionette',
'click button.submit': 'queueContainer',
'click a.apply': 'applyPreset',
'click a.unqueue': 'unqueueContainer',
'click a.addpage': 'queuePageSamples',
'click a.addall': 'queueAllSamples',
'change @ui.nodata': 'refreshSubSamples',
'change @ui.notcompleted': 'refreshSubSamples',
Expand All @@ -538,7 +539,7 @@ define(['marionette',
},


queueAllSamples: function(e) {
queuePageSamples: function(e) {
e.preventDefault()

var self = this
Expand All @@ -562,6 +563,37 @@ define(['marionette',
}, 200)
},

queueAllSamples: function(e) {
e.preventDefault()

var self = this
var sids = _.map(this.subsamples.fullCollection.filter(function(ss) { return (!ss.get('QUEUECOMPLETED')) }), function(ss) {return ss.get('BLSUBSAMPLEID')})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I think this will work I think we should do this in the back end in one go. This avoids all sorts of problems. Let's create an end point which can either take a page or all and queue's everything and returns done. The backend should do a single update to the database


// cannot send >1000 at once
const chunkSize = 500;
for (let i = 0; i < Math.ceil(sids.length / chunkSize); i++) {
var chunk = sids.slice(i*chunkSize, (i+1)*chunkSize);

Backbone.ajax({
type: 'post',
url: app.apiurl+'/sample/sub/queue',
data: {
BLSUBSAMPLEID: chunk,
},
success: function(resp) {
_.each(resp, function (r) {
var ss = self.subsamples.fullCollection.findWhere({ BLSUBSAMPLEID: r.BLSUBSAMPLEID })
ss.set({ READYFORQUEUE: '1' })
})
},
})
}

setTimeout(function() {
self.refreshQSubSamples.bind(self)
}, 1000)
},


unqueueContainer: function(e) {
e.preventDefault()
Expand Down
3 changes: 2 additions & 1 deletion client/src/js/templates/imaging/queuecontainer.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ <h1>Prepare Container for Data Collection</h1>
<h2>Available Samples</h2>
<div class="filter">
<span class="r">
<a href="#" class="button addall"><i class="fa fa-plus"></i> <span>Add Current Page to Queue</span></a>
<a href="#" class="button addpage"><i class="fa fa-plus"></i> <span>Add Current Page to Queue</span></a>
<a href="#" class="button addall"><i class="fa fa-plus"></i> <span>Add All to Queue</span></a>
</span>
<ul>
<li><label><input type="checkbox" name="nodata" /> Without Data</label></li>
Expand Down