Skip to content

Commit

Permalink
Add waiting indication, make end point post only queue if no data
Browse files Browse the repository at this point in the history
  • Loading branch information
John Holt authored and John Holt committed Aug 25, 2023
1 parent 7efc63f commit 1ee0b4f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 7 additions & 3 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +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/cid/:cid', 'get', '_queue_all_sub_samples'),
array('/sub/queue/cid/:cid', 'post', '_queue_all_sub_samples'),
array('/sub/queue(/:BLSUBSAMPLEID)', 'get', '_pre_q_sub_sample'),

array('/plan', 'get', '_get_diffraction_plans'),
Expand Down Expand Up @@ -592,19 +592,23 @@ function _queue_all_sub_samples()
}

$args = array($this->proposalid, $this->arg('cid'), $this->arg('cid'), $this->arg('cid'));
$where = ' AND c.containerid=:2';
$where = ' AND c.containerid=:2 AND cq2.completedtimestamp IS NULL';
$first_inner_select_where = ' AND s.containerid=:3';
$second_inner_select_where = ' AND s.containerid=:4';

$this->db->wait_rep_sync(true);
$ss_query_string = $this->get_sub_samples_query($where, $first_inner_select_where, $second_inner_select_where);
$this->db->set_debug(True);
$subs = $this->db->pq($ss_query_string, $args);
$this->db->set_debug(False);

$this->db->wait_rep_sync(false);

$ret = array();
foreach ($subs as $sub) {
array_push($ret, array('BLSUBSAMPLEID' => $sub['BLSUBSAMPLEID'], 'CONTAINERQUEUESAMPLEID' => $this->_do_pre_q_sample(array('BLSUBSAMPLEID' => $sub['BLSUBSAMPLEID']))));
array_push($ret, array(
'BLSUBSAMPLEID' => $sub['BLSUBSAMPLEID'],
'CONTAINERQUEUESAMPLEID' => $this->_do_pre_q_sample(array('BLSUBSAMPLEID' => $sub['BLSUBSAMPLEID']))));
}
$this->_output($ret);
}
Expand Down
14 changes: 8 additions & 6 deletions client/src/js/modules/imaging/views/queuecontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,20 +567,22 @@ define(['marionette',
e.preventDefault()

var self = this

this.$el.addClass('loading');
Backbone.ajax({
url: app.apiurl+'/sample/sub/queue/cid/'+this.model.get('CONTAINERID'),
method: "post",
data: {},
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)
complete: function(resp, status) {
self.$el.removeClass('loading')
self.refreshQSubSamples(self)
}
})
},


Expand Down

0 comments on commit 1ee0b4f

Please sign in to comment.