diff --git a/api/src/Page/Exp.php b/api/src/Page/Exp.php index 88cc5f9bb..7e8887e12 100644 --- a/api/src/Page/Exp.php +++ b/api/src/Page/Exp.php @@ -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'), @@ -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); @@ -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); @@ -925,4 +939,4 @@ function _get_experiment_types() $this->_output(array('total' => count($rows), 'data' => $rows)); } -} \ No newline at end of file +} diff --git a/client/src/js/collections/detectors.js b/client/src/js/collections/detectors.js index fb4df7862..ad6442032 100644 --- a/client/src/js/collections/detectors.js +++ b/client/src/js/collections/detectors.js @@ -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) { diff --git a/client/src/js/modules/imaging/views/admin/params.js b/client/src/js/modules/imaging/views/admin/params.js index d0518ec6c..c7f35df02 100644 --- a/client/src/js/modules/imaging/views/admin/params.js +++ b/client/src/js/modules/imaging/views/admin/params.js @@ -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()) { @@ -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() { @@ -297,4 +310,4 @@ define(['marionette', }) -}) \ No newline at end of file +})