Skip to content
Open
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
77 changes: 61 additions & 16 deletions api/src/Page/Processing.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Processing extends Page {
public static $dispatch = array(
array('/:id(/dcg/:dcg)', 'get', '_results'),
array('/visit/:visit(/csv/:csv)', 'get', '_results_for_visit'),
array('/summary(/group/:sgid)(/protein/:pid)(/visit/:visit)(/csv/:csv)', 'get', '_summary'),
array('/status', 'post', '_statuses'),

array('/messages/status', 'post', '_ap_message_status'),
Expand All @@ -27,6 +27,8 @@ class Processing extends Page {
'id' => '\d+',
'ids' => '\d+',
'dcg' => '\d+',
'pid' => '\d+',
'sgid' => '\d+',
'visit' => '\w+\d+-\d+',
'map' => '\d+',
'n' => '\d+',
Expand Down Expand Up @@ -382,24 +384,56 @@ function _statuses() {
$this->_output($out);
}

function _results_for_visit() {
if (!($this->has_arg('visit'))) {
$this->_error('No visit specified');
}
$pattern = '/([A-z]+)(\d+)-(\d+)/';
preg_match($pattern, $this->arg('visit'), $matches);
if (!sizeof($matches))
$this->_error('No such visit');
function _summary() {
$where = 'dc.overlap = 0 AND dc.axisrange > 0 AND app.processingstatus = 1';
$join = '';
if ($this->has_arg('visit')) {
$pattern = '/([A-z]+)(\d+)-(\d+)/';
preg_match($pattern, $this->arg('visit'), $matches);
if (!sizeof($matches))
$this->_error('No such visit');

$info = $this->db->pq("SELECT s.sessionid FROM blsession s
INNER JOIN proposal p ON (p.proposalid = s.proposalid)
WHERE p.proposalid=:1 AND p.proposalcode=:2 AND p.proposalnumber=:3 AND s.visit_number=:4",
array($this->proposalid, $matches[1], $matches[2], $matches[3])
);

$info = $this->db->pq("SELECT s.sessionid FROM blsession s INNER JOIN proposal p ON (p.proposalid = s.proposalid) WHERE p.proposalcode=:1 AND p.proposalnumber=:2 AND s.visit_number=:3", array($matches[1], $matches[2], $matches[3]));
if (!sizeof($info)) {
$this->_error('No such visit');
}

if (!sizeof($info)) {
$this->_error('No such visit');
}
$args = array($info[0]['SESSIONID']);
$where .= ' AND dc.sessionid=:1';
} else if ($this->has_arg('pid')) {
$info = $this->db->pq("SELECT pr.proteinid FROM protein pr
WHERE pr.proposalid=:1 AND pr.proteinid=:2",
array($this->proposalid, $this->arg('pid'))
);

if (!sizeof($info)) {
$this->_error('No such protein');
}

$args = array($info[0]['PROTEINID']);
$where .= ' AND c.proteinid=:1';
$join = 'INNER JOIN crystal c on smp.crystalid=c.crystalid';
} else if ($this->has_arg('sgid')) {
$info = $this->db->pq("SELECT blsg.blsamplegroupid FROM blsamplegroup blsg
WHERE blsg.proposalid=:1 AND blsg.blsamplegroupid=:2",
array($this->proposalid, $this->arg('sgid'))
);

$args = array($info[0]['SESSIONID']);
if (!sizeof($info)) {
$this->_error('No such sample group');
}

$where = 'dc.sessionid=:1 AND dc.overlap = 0 AND dc.axisrange > 0 AND app.processingstatus = 1';
$args = array($info[0]['BLSAMPLEGROUPID']);
$where .= ' AND bhb.blsamplegroupid=:1';
$join = 'INNER JOIN BLSampleGroup_has_BLSample bhb on smp.blsampleid=bhb.blsampleid';
} else {
$this->_error('No visit, protein or group specified');
}

if ($this->has_arg('pipeline')) {
$st = sizeof($args);
Expand Down Expand Up @@ -489,6 +523,7 @@ function _results_for_visit() {
$jobs = $this->db->pq(
"SELECT dc.datacollectionid as id,
CONCAT(dc.imageprefix, '_', dc.datacollectionnumber) as prefix,
CONCAT(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit,
smp.name as sample,
smp.blsampleid,
".self::EVTOA."/dc.wavelength as energy,
Expand Down Expand Up @@ -518,7 +553,10 @@ function _results_for_visit() {
apssinner.ccanomalous as innerccanom,
app.autoprocprogramid as aid
FROM datacollection dc
INNER JOIN blsession s ON dc.sessionid = s.sessionid
INNER JOIN proposal p ON s.proposalid = p.proposalid
LEFT OUTER JOIN blsample smp ON dc.blsampleid = smp.blsampleid
$join
INNER JOIN processingjob pj ON dc.datacollectionid = pj.datacollectionid
INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid
INNER JOIN autoproc ap ON app.autoprocprogramid=ap.autoprocprogramid
Expand Down Expand Up @@ -583,7 +621,14 @@ function _results_for_visit() {

if ($this->has_arg('csv')) {
$this->app->response->headers->set("Content-type", "text/csv");
Utils::setDispositionAttachment($this->app->response, $this->arg('visit') . "_summary.csv");
if ($this->has_arg('visit')) {
$filename = 'visit_' . $this->arg('visit') . "_summary.csv";
} else if ($this->has_arg('pid')) {
$filename = 'protein_' . $this->arg('pid') . "_summary.csv";
} else {
$filename = 'group_' . $this->arg('sgid') . "_summary.csv";
}
Utils::setDispositionAttachment($this->app->response, $filename);
if (!empty($data)) {
print implode(',', array_keys($data[0])) . "\n";
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ function _distinct_proteins()
LEFT OUTER JOIN concentrationtype ct ON ct.concentrationtypeid = pr.concentrationtypeid
WHERE pr.acronym is not null AND $where
GROUP BY ct.symbol, pr.acronym, pr.name, pr.global
ORDER BY lower(pr.acronym)", $args);
ORDER BY lower(pr.acronym), pr.proteinid", $args);

$this->_output($rows);
}
Expand Down
1 change: 1 addition & 0 deletions client/src/css/partials/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

&.nou {
border-bottom: 0;
margin-bottom: 0;
}

&.center {
Expand Down
10 changes: 9 additions & 1 deletion client/src/css/partials/_utility.scss
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,19 @@ ul.ui-autocomplete {
@apply tw-flex;
@apply tw-flex-row;
@apply tw-gap-2;
@apply tw-items-center;
@apply tw-items-baseline;
border-bottom: 1px solid grey;

h1 {
padding: 0 !important;
@apply tw-flex-grow;

&.no-grow {
@apply tw-flex-grow-0;
}
}

.xl {
@apply tw-text-xl;
}
}
4 changes: 3 additions & 1 deletion client/src/js/app/views/marionette/marionette-wrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export default {
// If this component is used directly from another vue component this will not be called
// Instead the parent vue component will need to load the model/collection data as required
beforeRouteEnter: function(to, from, next) {
next(vm => vm.prefetchData())
next(vm => {
if (!vm.fetchOnLoad) vm.prefetchData()
})
},
props: {
'mview': [Function, Promise], // The marionette view could be lazy loaded or static import
Expand Down
26 changes: 21 additions & 5 deletions client/src/js/collections/datacollectionsforvisit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,41 @@ define(['backbone.paginator', 'models/datacollectionsforvisit', 'utils/kvcollect
model: DCs,
mode: 'server',
visit: null,
url: function() { return '/processing/visit/'+this.visit },
pid: null,
sgid: null,
url: function() {
if (this.pid) {
return '/processing/summary/protein/'+this.pid
} else if (this.visit) {
return '/processing/summary/visit/'+this.visit
} else {
return '/processing/summary/group/'+this.sgid
}
},

initialize(collection, options) {
if (options && options.queryParams && options.queryParams.visit) {
this.visit = options.queryParams.visit
}
if (options && options.queryParams && options.queryParams.pid) {
this.pid = options.queryParams.pid
}
if (options && options.queryParams && options.queryParams.sgid) {
this.sgid = options.queryParams.sgid
}
},

state: {
pageSize: 15,
},

parseState: function(r, q, state, options) {
return { totalRecords: r.total }
},

parseRecords: function(r, options) {
return r.data
},

}))
})
10 changes: 7 additions & 3 deletions client/src/js/collections/samplegroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
define(['backbone',
'backbone.paginator',
'models/samplegroup',
], function(Backbone, PageableCollection, SampleGroup) {
return PageableCollection.extend({
'utils/kvcollection',
], function(Backbone, PageableCollection, SampleGroup, KVCollection) {
return PageableCollection.extend(_.extend({}, KVCollection, {
model: SampleGroup,
url: '/sample/groups',

Expand All @@ -23,5 +24,8 @@ define(['backbone',
parseState: function(r) {
return { totalRecords: r.total }
},
})

keyAttribute: 'NAME', // What the user sees in the dropdown list
valueAttribute: 'BLSAMPLEGROUPID', // The hidden ID submitted when selected
}))
})
45 changes: 45 additions & 0 deletions client/src/js/modules/dc/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ application.addInitializer(function() {
application.navigate('/dc/'+(visit ? ('visit/'+visit) : '') + '/ty/'+type+'/id/'+id)
// controller.dc_list(visit, null, null, null, type, id)
})

application.on('visitsummary:show', function(visit) {
application.navigate('/dc/summary/visit/'+visit)
})

application.on('proteinsummary:show', function(pid) {
application.navigate('/dc/summary/protein/'+pid)
})

application.on('groupsummary:show', function(pid) {
application.navigate('/dc/summary/group/'+pid)
})
})

// appRoutes: {
Expand Down Expand Up @@ -110,12 +122,45 @@ let routes = [
id: +route.params.id || null,
}),
},
{
path: '/dc/summary/protein/:pid([0-9]+)',
name: 'dc-summary-protein',
component: MarionetteView,
props: route => ({
mview: Summary,
fetchOnLoad: true,
pid: route.params.pid || '',
options: {
model: new Visit(),
collection: new DCVisit(null, {
queryParams: { pid: route.params.pid }
})
}
}),
},
{
path: '/dc/summary/group/:sgid([0-9]+)',
name: 'dc-summary-group',
component: MarionetteView,
props: route => ({
mview: Summary,
fetchOnLoad: true,
sgid: route.params.sgid || '',
options: {
model: new Visit(),
collection: new DCVisit(null, {
queryParams: { sgid: route.params.sgid }
})
}
}),
},
{
path: '/dc/summary/visit/:visit([a-zA-Z]{2}[0-9]+-[0-9]+)',
name: 'dc-summary',
component: MarionetteView,
props: route => ({
mview: Summary,
fetchOnLoad: true,
visit: route.params.visit || '',
options: {
model: visitModel,
Expand Down
Loading
Loading