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
24 changes: 19 additions & 5 deletions api/src/Page/Exp.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Exp extends Page
array('/plans/detectors/:DATACOLLECTIONPLANHASDETECTORID', 'patch', '_dp_update_detector'),
array('/plans/detectors/:DATACOLLECTIONPLANHASDETECTORID', 'delete', '_dp_remove_detector'),

array('/setup', 'get', '_get_beamline_setups'),
array('/setup(/:BEAMLINESETUPID)', 'get', '_get_beamline_setups'),
array('/setup', 'post', '_add_beamline_setup'),
array('/setup/:BEAMLINESETUPID', 'patch', '_update_beamline_setup'),

Expand All @@ -164,7 +164,7 @@ function _detectors()
array_push($args, $this->arg('BEAMLINENAME'));
}

$tot = $this->db->pq("SELECT count(d.detectorid) as tot
$tot = $this->db->pq("SELECT count(distinct d.detectorid) as tot
FROM detector d
LEFT OUTER JOIN beamlinesetup bls ON bls.detectorid = d.detectorid
WHERE $where", $args);
Expand All @@ -177,10 +177,24 @@ function _detectors()
'd.detectorid ASC'
);

$rows = $this->db->paginate("SELECT d.detectorid, d.detectortype, d.detectormanufacturer, d.detectorserialnumber, d.sensorthickness, d.detectormodel, d.detectorpixelsizehorizontal, d.detectorpixelsizevertical, d.detectordistancemin, d.detectordistancemax, d.density, d.composition, concat(d.detectormanufacturer,' ',d.detectormodel, ' (',d.detectortype,')') as description, d.detectormaxresolution, d.detectorminresolution, count(distinct dc.datacollectionid) as dcs, count(distinct bls.beamlinesetupid) as blsetups, (SELECT count(distinct dphd.detectorid) FROM DataCollectionPlan_has_Detector dphd WHERE dphd.detectorid = d.detectorid) as dps, GROUP_CONCAT(distinct bls.beamlinename) as beamlines, d.numberofpixelsx, d.numberofpixelsy, d.detectorrollmin, d.detectorrollmax
$rows = $this->db->paginate("SELECT d.detectorid, d.detectortype, d.detectormanufacturer, d.detectorserialnumber, d.sensorthickness, d.detectormodel, d.detectorpixelsizehorizontal, d.detectorpixelsizevertical, d.detectordistancemin, d.detectordistancemax, d.density, d.composition, d.detectormaxresolution, d.detectorminresolution, d.numberofpixelsx, d.numberofpixelsy, d.detectorrollmin, d.detectorrollmax,
concat(d.detectormanufacturer,' ',d.detectormodel, ' (', ifnull(d.detectortype, ''), ')') as description,
count(distinct bls.beamlinesetupid) as blsetups,
GROUP_CONCAT(distinct bls.beamlinename) as beamlines,
COALESCE(datacollections.dcs, 0) as dcs,
COALESCE(datacollectionplans.dps, 0) as dps
FROM detector d
LEFT OUTER JOIN datacollection dc ON dc.detectorid = d.detectorid
LEFT OUTER JOIN beamlinesetup bls ON bls.detectorid = d.detectorid
LEFT JOIN (
SELECT detectorid, COUNT(datacollectionid) as dcs
FROM datacollection
GROUP BY detectorid
) datacollections ON datacollections.detectorid = d.detectorid
LEFT JOIN (
SELECT detectorid, COUNT(DISTINCT detectorid) as dps
FROM DataCollectionPlan_has_Detector
GROUP BY detectorid
) datacollectionplans ON datacollectionplans.detectorid = d.detectorid
WHERE $where
GROUP BY d.detectorid
ORDER BY $order", $args);
Expand Down Expand Up @@ -925,4 +939,4 @@ function _get_experiment_types()

$this->_output(array('total' => count($rows), 'data' => $rows));
}
}
}
2 changes: 1 addition & 1 deletion client/src/js/collections/detectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define(['backbone.paginator', 'models/detector', 'utils/kvcollection'], function
valueAttribute: 'DETECTORID',

state: {
pageSize: 5,
pageSize: 9999,
},

parseState: function(r, q, state, options) {
Expand Down
19 changes: 16 additions & 3 deletions client/src/js/modules/imaging/views/admin/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ define(['marionette',


var DetectorsLimitsCellStatic = Backgrid.Cell.extend({
initialize: function(options) {
Backgrid.Cell.prototype.initialize.apply(this, arguments)
this.listenTo(this.model, 'sync change', this.render)
},

render: function() {
this.$el.empty()
if (!this.model.isNew()) {
Expand Down Expand Up @@ -238,9 +243,17 @@ define(['marionette',
console.log('model changed', arguments)
// Changed Attributes are not being detected correctly.
// Therefore we can crudely set all parameters to enforce a PATCH request
if (!m.isNew()) m.save(_.clone(m.attributes), { patch: true })
},

if (!m.isNew()) {
m.save(_.clone(m.attributes), {
patch: true,
wait: true,
success: function() {
m.fetch()
}
});
}
},


onRender: function() {
Expand Down Expand Up @@ -297,4 +310,4 @@ define(['marionette',
})


})
})
Loading