diff --git a/api/src/Page/DC.php b/api/src/Page/DC.php index 4ab4da7d2..a0bd154fb 100644 --- a/api/src/Page/DC.php +++ b/api/src/Page/DC.php @@ -458,8 +458,7 @@ function _data_collections($single = null) dc.c2lens, dc.objaperture, dc.magnification, - dose.total as totaldose, - CAST(dc.totalabsorbeddose AS DECIMAL(5, 2)) as totalabsdose, + dc.totalabsorbeddose as totaldose, d.detectorpixelsizehorizontal, d.detectorpixelsizevertical, d.detectormanufacturer, @@ -539,6 +538,12 @@ function _data_collections($single = null) array_push($args, $this->arg('dcg')); } } else { + $groupby = 'GROUP BY dc.datacollectiongroupid'; + $numimgs = 'totals.numimg'; + if ($this->has_arg('expandgroups')) { + $groupby = 'GROUP BY dc.datacollectionid'; + $numimgs = 'dc.numberofimages as numimg'; + } $fields = "count(distinct dca.datacollectionfileattachmentid) as dcac, if(dca.fileType='recip',1,0) as recip, count(distinct dcc.datacollectioncommentid) as dccc, @@ -569,7 +574,7 @@ function _data_collections($single = null) min(dc.resolution) as resolution, min(dc.exposuretime) as exposuretime, min(dc.axisstart) as axisstart, - min(dc.numberofimages) as numimg, + $numimgs, TO_CHAR(min(dc.starttime), 'DD-MM-YYYY HH24:MI:SS') as st, min(dc.transmission) as transmission, min(dc.axisrange) as axisrange, @@ -596,12 +601,11 @@ function _data_collections($single = null) max(dc.c2lens) as c2lens, max(dc.objaperture) as objaperture, max(dc.magnification) as magnification, - dose.total as totaldose, - CAST(dc.totalabsorbeddose AS DECIMAL(5, 2)) as totalabsdose, - max(d.detectormanufacturer) as detectormanufacturer, - max(d.detectormodel) as detectormodel, + totals.totaldose as totaldose, max(d.detectorpixelsizehorizontal) as detectorpixelsizehorizontal, max(d.detectorpixelsizevertical) as detectorpixelsizevertical, + max(d.detectormanufacturer) as detectormanufacturer, + max(d.detectormodel) as detectormodel, max(TIMESTAMPDIFF('MINUTE', dc.starttime, CURRENT_TIMESTAMP)) as age, max(dc.numberofpasses) as numberofpasses, max(dc.c1aperture) as c1aperture, @@ -626,11 +630,7 @@ function _data_collections($single = null) max(ses.archived) as archived, max(ses.purgedProcessedData) as purgedProcessedData, IFNULL(max(dc.rotationaxis), 'Omega') as rotationaxis, - dc.detector2theta"; - $groupby = "GROUP BY dc.datacollectiongroupid"; - if ($this->has_arg('expandgroups')) { - $groupby = "GROUP BY dc.datacollectionid"; - } + min(dc.detector2theta) as detector2theta"; } // We don't want to remove duplicates, since if two counts are equal, one might go uncounted @@ -687,8 +687,8 @@ function _data_collections($single = null) FROM datacollection dc INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid INNER JOIN ( - select datacollectiongroupid, sum(totalabsorbeddose) as total from datacollection group by datacollectiongroupid) dose - ON dc.datacollectiongroupid = dose.datacollectiongroupid + select datacollectiongroupid, sum(totalabsorbeddose) as totaldose, sum(numberofimages) as numimg from datacollection group by datacollectiongroupid) totals + ON dc.datacollectiongroupid = totals.datacollectiongroupid INNER JOIN blsession ses ON ses.sessionid = dcg.sessionid LEFT OUTER JOIN experimenttype et on dcg.experimenttypeid = et.experimenttypeid $sample_joins[0] @@ -782,7 +782,6 @@ function _data_collections($single = null) 0, 0, 0, - 0, ses.beamlinename as bl, es.blsubsampleid, '', @@ -879,7 +878,6 @@ function _data_collections($single = null) 0, 0, 0, - 0, ses.beamlinename as bl, xrf.blsubsampleid, '', @@ -976,7 +974,6 @@ function _data_collections($single = null) 0, 0, 0, - 0, ses.beamlinename as bl, 1 as blsubsampleid, '', @@ -1441,45 +1438,40 @@ function _get_ap($com) function _image_qi($id) { session_write_close(); - $iqs = array(array(), array(), array(), array(), array()); + $iqs = array(array(), array(), array(), array()); + $args = array($id); + $offset = 0; + $offsets = array($id => 0); + if ($this->has_arg('dcg') && $this->arg('dcg') == 1) { + $dcs = $this->db->pq("SELECT datacollectionid, numberofimages + FROM datacollection dc + WHERE datacollectiongroupid = ( + SELECT dataCollectionGroupId + FROM DataCollection + WHERE dataCollectionId = :1 + ) + ORDER BY datacollectionid ASC", $args); + $args = array(); + foreach ($dcs as $i => $id) { + array_push($args, $id['DATACOLLECTIONID']); + $offsets[$id['DATACOLLECTIONID']] = $offset; + $offset += $id['NUMBEROFIMAGES']; + } + } - #$this->db->set_debug(True); + $dcids = implode(', ', $args); - $where = $id; - $args = array(); - /* - $dcg = $this->db->pq("SELECT datacollectiongroupid as dcg FROM datacollection WHERE datacollectionid=:1", array($id)); - if (!sizeof($dcg)) $this->error('No such data collection'); - $dcids = $this->db->pq("SELECT datacollectionid as id FROM datacollection WHERE datacollectiongroupid=:1", array($dcg[0]['DCG'])); - $where = array(); - $args = array(); - foreach ($dcids as $i => $id) { - //array_push($where, ':'.($i+1)); - array_push($where, $id['ID']); - //array_push($args, $id['ID']); - } - $where = implode($where, ', '); - */ - - /*$tot = $this->db->pq("SELECT count(im.imagenumber) as tot - FROM image im - INNER JOIN imagequalityindicators imq ON imq.imageid = im.imageid AND (im.datacollectionid IN ($where)) - ORDER BY imagenumber", $args); - $int = intval($tot[0]['TOT'] / 250); - array_push($args, $int);*/ - - #im.datacollectionid=:1 - $imqs = $this->db->pq("SELECT imq.imagenumber as nim, imq.method2res as res, imq.spottotal as s, imq.totalintegratedsignal, imq.goodbraggcandidates as b, imq.dozor_score as d + $imqs = $this->db->pq("SELECT imq.datacollectionid, imq.imagenumber, imq.method2res, imq.spottotal, imq.totalintegratedsignal, imq.goodbraggcandidates FROM imagequalityindicators imq - WHERE imq.datacollectionid IN ($where) - ORDER BY imq.imagenumber", $args); + WHERE imq.datacollectionid IN ($dcids) + ORDER BY imq.datacollectionid asc, imq.imagenumber asc", array()); foreach ($imqs as $imq) { - array_push($iqs[0], array(intval($imq['NIM']), $this->_null_or($imq['S'], 'int'))); - array_push($iqs[1], array(intval($imq['NIM']), $this->_null_or($imq['B'], 'int'))); - array_push($iqs[2], array(intval($imq['NIM']), $this->_null_or($imq['RES'], 'float'))); - array_push($iqs[3], array(intval($imq['NIM']), $this->_null_or($imq['TOTALINTEGRATEDSIGNAL'], 'float'))); - array_push($iqs[4], array(intval($imq['NIM']), $this->_null_or($imq['D'], 'float'))); + $globalImageNumber = $imq['IMAGENUMBER'] + $offsets[$imq['DATACOLLECTIONID']]; + array_push($iqs[0], array($globalImageNumber, $this->_null_or($imq['SPOTTOTAL'], 'int'))); + array_push($iqs[1], array($globalImageNumber, $this->_null_or($imq['GOODBRAGGCANDIDATES'], 'int'))); + array_push($iqs[2], array($globalImageNumber, $this->_null_or($imq['METHOD2RES'], 'float'))); + array_push($iqs[3], array($globalImageNumber, $this->_null_or($imq['TOTALINTEGRATEDSIGNAL'], 'float'))); } $this->_output($iqs); diff --git a/api/src/Page/Processing.php b/api/src/Page/Processing.php index 67e0ec777..fc22b1651 100644 --- a/api/src/Page/Processing.php +++ b/api/src/Page/Processing.php @@ -8,14 +8,14 @@ class Processing extends Page { public static $dispatch = array( - array('/:id', 'get', '_results'), + array('/:id(/dcg/:dcg)', 'get', '_results'), array('/visit/:visit(/csv/:csv)', 'get', '_results_for_visit'), array('/status', 'post', '_statuses'), array('/messages/status', 'post', '_ap_message_status'), array('/messages', 'get', '_ap_message'), - array('/downstream/:id', 'get', '_downstream'), + array('/downstream/:id(/dcg/:dcg)', 'get', '_downstream'), array('/downstream/images/:aid(/n/:n)', 'get', '_downstream_images'), array('/downstream/mapmodel/:aid(/n/:n)', 'get', '_downstream_mapmodel'), array('/multiplex_jobs/groups/:blSampleGroupId', 'get', '_get_latest_multiplex_job_result'), @@ -26,6 +26,7 @@ class Processing extends Page { public static $arg_list = array( 'id' => '\d+', 'ids' => '\d+', + 'dcg' => '\d+', 'visit' => '\w+\d+-\d+', 'map' => '\d+', 'n' => '\d+', @@ -217,7 +218,7 @@ function _autoproc_status($where, $ids) { $processings = $this->db->union( array( - "SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'autoproc' as type + "SELECT app.autoprocprogramid, dc.datacollectionid, dc.datacollectiongroupid, app.processingprograms, app.processingstatus as status, 'autoproc' as type FROM datacollection dc INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid INNER JOIN blsession s ON s.sessionid = dcg.sessionid @@ -227,7 +228,7 @@ function _autoproc_status($where, $ids) { WHERE $where AND app.processingprograms NOT IN ('$filter') AND app.processingprograms NOT IN ('$screening_filter')", - "SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'downstream' as type + "SELECT app.autoprocprogramid, dc.datacollectionid, dc.datacollectiongroupid, app.processingprograms, app.processingstatus as status, 'downstream' as type FROM datacollection dc INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid INNER JOIN blsession s ON s.sessionid = dcg.sessionid @@ -239,7 +240,7 @@ function _autoproc_status($where, $ids) { AND api.autoprocintegrationid IS NULL AND app.processingprograms NOT IN ('$filter') AND app.processingprograms NOT IN ('$screening_filter')", - "SELECT app.autoprocprogramid, dc.datacollectionid, app.processingprograms, app.processingstatus as status, 'screening' as type + "SELECT app.autoprocprogramid, dc.datacollectionid, dc.datacollectiongroupid, app.processingprograms, app.processingstatus as status, 'screening' as type FROM datacollection dc INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid INNER JOIN blsession s ON s.sessionid = dcg.sessionid @@ -256,33 +257,35 @@ function _autoproc_status($where, $ids) { ); $statuses = array(); - foreach ($processings as $p) { - if (!array_key_exists($p['DATACOLLECTIONID'], $statuses)) { - $statuses[$p['DATACOLLECTIONID']] = array(); - } - if ( - !array_key_exists($p['TYPE'], $statuses[$p['DATACOLLECTIONID']]) - ) { - $statuses[$p['DATACOLLECTIONID']][$p["TYPE"]] = array(); - } + foreach ($ids as $id) { + $statuses[$id] = array(); + foreach ($processings as $p) { + if ($p['DATACOLLECTIONID'] === $id || $p['DATACOLLECTIONGROUPID'] === $id) { + if ( + !array_key_exists($p['TYPE'], $statuses[$id]) + ) { + $statuses[$id][$p["TYPE"]] = array(); + } - if ( - !array_key_exists( - $p['PROCESSINGPROGRAMS'], - $statuses[$p['DATACOLLECTIONID']][$p['TYPE']] - ) - ) { - $statuses[$p['DATACOLLECTIONID']][$p["TYPE"]][ - $p['PROCESSINGPROGRAMS'] - ] = array(); - } + if ( + !array_key_exists( + $p['PROCESSINGPROGRAMS'], + $statuses[$id][$p['TYPE']] + ) + ) { + $statuses[$id][$p["TYPE"]][ + $p['PROCESSINGPROGRAMS'] + ] = array(); + } - array_push( - $statuses[$p['DATACOLLECTIONID']][$p['TYPE']][ - $p['PROCESSINGPROGRAMS'] - ], - $this->_map_status($p['STATUS']) - ); + array_push( + $statuses[$id][$p['TYPE']][ + $p['PROCESSINGPROGRAMS'] + ], + $this->_map_status($p['STATUS']) + ); + } + } } return $statuses; @@ -299,6 +302,14 @@ function _get_ids() { } } } + if ($this->has_arg('dcg')) { + if (is_array($this->arg('dcg'))) { + foreach ($this->arg('dcg') as $i) { + array_push($ids, $i); + array_push($where, 'dc.datacollectiongroupid=:' . sizeof($ids)); + } + } + } $where = '(' . implode(' OR ', $where) . ')'; return array($where, $ids); @@ -590,14 +601,33 @@ function _results_for_visit() { * @param integer $id DataCollectionId */ function _results($id) { + + if ($this->has_arg('dcg') && $this->arg('dcg') == 1) { + $where = array(); + $dcs = $this->db->pq("SELECT datacollectionid FROM datacollection dc + WHERE datacollectiongroupid = ( + SELECT datacollectiongroupId + FROM datacollection + WHERE datacollectionid = :1 + )", array($id)); + $args = array(); + foreach ($dcs as $i) { + array_push($args, $i['DATACOLLECTIONID']); + array_push($where, 'api.datacollectionid=:' . sizeof($args)); + } + $whereClause = '(' . implode(' OR ', $where) . ')'; + } else { + $whereClause = "api.datacollectionid=:1"; + $args = array($id); + } + $processing_job_query = $this->_autoprocessing_query_builder( - "api.datacollectionid = :1 AND app.processingstatus IS NOT NULL", + $whereClause . " AND app.processingstatus IS NOT NULL", "GROUP BY app.autoprocprogramid, apss.autoprocscalingstatisticsid", "ORDER BY apss.scalingstatisticstype DESC"); - $rows = $this->db->pq($processing_job_query, array($id)); + $rows = $this->db->pq($processing_job_query, $args); - $whereClause = "api.datacollectionid=:1"; - $messages = $this->_generate_auto_program_messages($whereClause, "", array($id)); + $messages = $this->_generate_auto_program_messages($whereClause, "", $args); $output = $this->_format_auto_processing_result($rows, $messages); @@ -611,28 +641,10 @@ function _ap_message_status() { if (!($this->has_arg('visit') || $this->has_arg('prop'))) { $this->_error('No visit or proposal specified'); } - $where = 'WHERE s.proposalid=:1'; - $args = array($this->proposalid); - - $wids = array(); - if ($this->has_arg('ids')) { - if (is_array($this->arg('ids'))) { - foreach ($this->arg('ids') as $i) { - array_push( - $wids, - 'dc.datacollectionid=:' . (sizeof($args) + 1) - ); - array_push($args, $i); - } - } - } - - if (!sizeof($wids)) { - $this->_output(array()); - return; - } - $where .= ' AND (' . implode(' OR ', $wids) . ')'; + list($where, $args) = $this->_get_ids(); + array_push($args, $this->proposalid); + $where .= ' AND s.proposalid=:' . sizeof($args); $rows = $this->db->union( array( @@ -643,7 +655,7 @@ function _ap_message_status() { INNER JOIN datacollection dc ON dc.datacollectionid = api.datacollectionid INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid INNER JOIN blsession s ON s.sessionid = dcg.sessionid - $where + WHERE $where GROUP BY dc.datacollectionid", "SELECT app.autoprocprogramid, dc.datacollectionid as id, SUM(IF(appm.severity = 'ERROR', 1, 0)) as errors, SUM(IF(appm.severity = 'WARNING', 1, 0)) as warnings, SUM(IF(appm.severity = 'INFO', 1, 0)) as infos FROM autoprocprogrammessage appm @@ -652,7 +664,7 @@ function _ap_message_status() { INNER JOIN datacollection dc ON dc.datacollectionid = pj.datacollectionid INNER JOIN datacollectiongroup dcg ON dcg.datacollectiongroupid = dc.datacollectiongroupid INNER JOIN blsession s ON s.sessionid = dcg.sessionid - $where + WHERE $where GROUP BY dc.datacollectionid ", ), @@ -673,6 +685,7 @@ function _ap_message() { } if ( !$this->has_arg('id') && + !$this->has_arg('dcg') && !$this->has_arg('AUTOPROCPROGRAMMESSAGEID') ) { $this->_error('No datacollection or message specified'); @@ -682,14 +695,18 @@ function _ap_message() { $args = array($this->proposalid); if ($this->has_arg('AUTOPROCPROGRAMMESSAGEID')) { - $where .= - ' AND appm.autoprocprogrammessageid=:' . (sizeof($args) + 1); array_push($args, $this->arg('AUTOPROCPROGRAMMESSAGEID')); + $where .= ' AND appm.autoprocprogrammessageid=:' . sizeof($args); } if ($this->has_arg('id')) { - $where .= ' AND dc.datacollectionid=:2'; array_push($args, $this->arg('id')); + $where .= ' AND dc.datacollectionid=:' . sizeof($args); + } + + if ($this->has_arg('dcg')) { + array_push($args, $this->arg('dcg')); + $where .= ' AND dc.datacollectiongroupid=:' . sizeof($args); } $rows = $this->db->union( @@ -736,8 +753,23 @@ function _get_downstreams($dcid = null, $aid = null) { $args = array($this->proposalid); if ($dcid) { - $where .= ' AND dc.datacollectionid=:' . (sizeof($args) + 1); - array_push($args, $dcid); + if ($this->has_arg('dcg') && $this->arg('dcg') == 1) { + $whereClause = array(); + $dcs = $this->db->pq('SELECT datacollectionid FROM datacollection dc + WHERE datacollectiongroupid = ( + SELECT datacollectiongroupId + FROM datacollection + WHERE datacollectionid = :1 + )', array($dcid)); + foreach ($dcs as $i) { + array_push($args, $i['DATACOLLECTIONID']); + array_push($whereClause, 'dc.datacollectionid=:' . sizeof($args)); + } + $where .= ' AND (' . implode(' OR ', $whereClause) . ')'; + } else { + array_push($args, $dcid); + $where .= ' AND dc.datacollectionid=:' . sizeof($args); + } } if ($aid) { @@ -798,14 +830,33 @@ function _get_downstreams($dcid = null, $aid = null) { function _downstream($id) { $downstreams = $this->_get_downstreams($id); + if ($this->has_arg('dcg') && $this->arg('dcg') == 1) { + $where = array(); + $dcs = $this->db->pq("SELECT datacollectionid FROM datacollection dc + WHERE datacollectiongroupid = ( + SELECT datacollectiongroupId + FROM datacollection + WHERE datacollectionid = :1 + )", array($id)); + $args = array(); + foreach ($dcs as $i) { + array_push($args, $i['DATACOLLECTIONID']); + array_push($where, 'pj.datacollectionid=:' . sizeof($args)); + } + $whereClause = '(' . implode(' OR ', $where) . ')'; + } else { + $whereClause = "pj.datacollectionid=:1"; + $args = array($id); + } + $msg_tmp = $this->db->pq( "SELECT app.autoprocprogramid, appm.recordtimestamp, appm.severity, appm.message, appm.description FROM autoprocprogrammessage appm INNER JOIN autoprocprogram app ON app.autoprocprogramid = appm.autoprocprogramid INNER JOIN processingjob pj ON app.processingjobid = pj.processingjobid LEFT OUTER JOIN autoprocintegration api ON api.autoprocprogramid = app.autoprocprogramid - WHERE pj.datacollectionid =:1 AND api.autoprocintegrationid IS NULL", - array($id) + WHERE $whereClause AND api.autoprocintegrationid IS NULL", + $args ); $messages = array(); diff --git a/client/src/css/modules/_colors.scss b/client/src/css/modules/_colors.scss index 29edacd74..f4bb8e6e7 100644 --- a/client/src/css/modules/_colors.scss +++ b/client/src/css/modules/_colors.scss @@ -72,6 +72,14 @@ $content-page-color-tint: color(#666666 tint(5%)); $content-main-background: #efefef; +$content-group-background: #e6eef8; +$content-group-border: #c9c9c9; +$content-group-background-shade: #dbe5f1; +$content-group-background-dark: #cad4e0; +$content-group-button-light: #eef1f5; +$content-group-button-dark: #d8dee6; +$content-group-button-border: #c9d3df; + $content-sub-header-background: #afafaf; $content-sub-header-hover-background: #cdcdcd; $content-sub-background: #ffffff; diff --git a/client/src/css/partials/_content.scss b/client/src/css/partials/_content.scss index 8eef90377..d1309b8ed 100644 --- a/client/src/css/partials/_content.scss +++ b/client/src/css/partials/_content.scss @@ -1277,6 +1277,37 @@ li:last-child .visit_users { background-color: #a087eb; } } + + &.data_collection_group { + background: $content-group-background; + border: 1px solid $content-group-border; + + /* The "Stack" Effect */ + box-shadow: + 4px 4px 0 0 $content-group-background, /* Layer 1 Spacer */ + 4px 4px 0 1px $content-group-border, /* Layer 1 Border */ + 8px 8px 0 0 $content-group-background, /* Layer 2 Spacer */ + 8px 8px 0 1px $content-group-border; /* Layer 2 Border */ + + > ul > li { + background: $content-group-background-shade; + + &:before { + background: $content-group-background-dark; + } + } + + > h1 .button { + border-color: $content-group-button-border; + background: linear-gradient($content-group-button-light, $content-group-button-dark); + + &:hover { + background: linear-gradient($content-group-button-dark, $content-group-button-light); + } + } + } + + /* Postcss - not working here - move to separate declaration below */ // > ul { // @extend .ul; diff --git a/client/src/css/partials/_utility.scss b/client/src/css/partials/_utility.scss index eb7e802a0..752b9ad99 100644 --- a/client/src/css/partials/_utility.scss +++ b/client/src/css/partials/_utility.scss @@ -144,6 +144,11 @@ } +body.cursor-loading, +body.cursor-loading * { + cursor: wait !important; +} + .loading-container { min-height: 450px; position: relative; diff --git a/client/src/js/modules/dc/collections/autointegrations.js b/client/src/js/modules/dc/collections/autointegrations.js index 11e81f39f..6242d9a16 100644 --- a/client/src/js/modules/dc/collections/autointegrations.js +++ b/client/src/js/modules/dc/collections/autointegrations.js @@ -3,10 +3,15 @@ define(['underscore', 'backbone', 'modules/dc/models/autointegration'], function return Backbone.Collection.extend({ model: AutoIntegration, - url: function() { return '/processing/' + this.id }, + url: function() { + var url = '/processing/' + this.id + if (this.dcc > 1) url += '/dcg/1' + return url + }, initialize: function(models, options) { this.id = options.id + this.dcc = options.dcc }, parse: function(r, options) { @@ -22,4 +27,4 @@ define(['underscore', 'backbone', 'modules/dc/models/autointegration'], function }, }) -}) \ No newline at end of file +}) diff --git a/client/src/js/modules/dc/collections/downstreams.js b/client/src/js/modules/dc/collections/downstreams.js index 3b74b546d..316a210bc 100644 --- a/client/src/js/modules/dc/collections/downstreams.js +++ b/client/src/js/modules/dc/collections/downstreams.js @@ -3,10 +3,15 @@ define(['backbone', 'modules/dc/models/downstream'], function(Backbone, DownStre return Backbone.Collection.extend({ model: DownStream, - url: function() { return '/processing/downstream/' + this.id }, + url: function() { + var url = '/processing/downstream/' + this.id + if (this.dcc > 1) url += '/dcg/1' + return url + }, initialize: function(models, options) { this.id = options.id + this.dcc = options.dcc }, }) diff --git a/client/src/js/modules/dc/dclist.js b/client/src/js/modules/dc/dclist.js index 19ca15a94..85d01fead 100644 --- a/client/src/js/modules/dc/dclist.js +++ b/client/src/js/modules/dc/dclist.js @@ -64,7 +64,7 @@ function(Marionette, this.listenTo(this.collection, 'sync', this._onSync, this) this._onSync() }, - + _onSync: function() { var ids = this.collection .filter(m => m.get('TYPE') === 'data' || m.get('TYPE') === 'grid') @@ -76,8 +76,15 @@ function(Marionette, } if (!ids.length) return this.imagestatuses.fetch({ data: data, type: 'POST' }) - if (this.getOption('apStatus')) this.apstatuses.fetch({ data: { ids: ids }, type: 'POST' }) - if (this.getOption('apMessageStatus')) this.apmessagestatuses.fetch({ data: { ids: ids }, type: 'POST' }) + var dcids = this.collection + .filter(m => (m.get('DCC') == 1 && m.get('TYPE') === 'data') || m.get('TYPE') === 'grid') + .map(m => m.get('ID')); + var dcg = this.collection + .filter(m => m.get('DCC') > 1 && m.get('TYPE') === 'data') + .map(m => m.get('DCG')); + var dcgdata = { ids: dcids, dcg: dcg } + if (this.getOption('apStatus')) this.apstatuses.fetch({ data: dcgdata, type: 'POST' }) + if (this.getOption('apMessageStatus')) this.apmessagestatuses.fetch({ data: dcgdata, type: 'POST' }) }, getChildView: function(item) { diff --git a/client/src/js/modules/dc/models/distl.js b/client/src/js/modules/dc/models/distl.js index f1eb3a3be..710bf9930 100644 --- a/client/src/js/modules/dc/models/distl.js +++ b/client/src/js/modules/dc/models/distl.js @@ -16,6 +16,7 @@ define(['backbone'], function(Backbone){ initialize: function(options) { this.nimg = options.nimg this.pm = options.pm + this.dcg = options.dcg this.bind('sync', this.poll, this) this.refresh_thread = null this.running = true @@ -39,9 +40,13 @@ define(['backbone'], function(Backbone){ if (this.nimg == _.last(d[0])[0]) refresh = false } if (this.pm.get('AGE') > 15) refresh = false - if (refresh) this.refresh_thread = setTimeout(this.fetch.bind(this), 10000) + if (refresh) { + this.refresh_thread = setTimeout(() => { + this.fetch({ data: { dcg: this.dcg } }); + }, 10000); + } } }, }) -}) \ No newline at end of file +}) diff --git a/client/src/js/modules/dc/views/apstatusitem.js b/client/src/js/modules/dc/views/apstatusitem.js index e65ce5358..9a29580db 100644 --- a/client/src/js/modules/dc/views/apstatusitem.js +++ b/client/src/js/modules/dc/views/apstatusitem.js @@ -17,7 +17,10 @@ define(['marionette', 'jquery'], function(Marionette, $) { }, getModel: function() { - var m = this.getOption('statuses').findWhere({ ID: this.getOption('ID') }) + var m = this.getOption('statuses').find(m => + m.get('ID') === this.getOption('ID') || + m.get('ID') === this.getOption('DCG') + ) if (m != this.model) { //console.log('old', this.model, 'new', m) this.undelegateEvents() diff --git a/client/src/js/modules/dc/views/autointegration.js b/client/src/js/modules/dc/views/autointegration.js index 3288e26ae..36e63df8f 100644 --- a/client/src/js/modules/dc/views/autointegration.js +++ b/client/src/js/modules/dc/views/autointegration.js @@ -135,7 +135,7 @@ define(['marionette', initialize: function(options) { dcPurgedProcessedData = options.dcPurgedProcessedData; - this.collection = new AutoIntegrations(null, { id: options.id }) + this.collection = new AutoIntegrations(null, { id: options.id, dcc: options.dcc }) this.collection.fetch().done(this.render.bind(this)) }, diff --git a/client/src/js/modules/dc/views/dc.js b/client/src/js/modules/dc/views/dc.js index 175de6e90..df54443df 100644 --- a/client/src/js/modules/dc/views/dc.js +++ b/client/src/js/modules/dc/views/dc.js @@ -45,6 +45,7 @@ define(['marionette', this.showStrategies = true this.showProcessing = true this.setProcessingVars() + this.numimg = this.model.get('DCC') == 1 }, setProcessingVars: function() { @@ -65,7 +66,7 @@ define(['marionette', //var h = $(window).width() > 800 ? w : (w*1.65) //this.$el.find('.distl,.diffraction,.snapshots').height(h) - if (this.getOption('plotView')) this.plotview = new (this.getOption('plotView'))({ parent: this.model, el: this.$el.find('.distl') }) + if (this.getOption('plotView')) this.plotview = new (this.getOption('plotView'))({ parent: this.model, el: this.$el.find('.distl'), numimg: this.numimg }) Backbone.Validation.unbind(this) Backbone.Validation.bind(this) @@ -79,7 +80,7 @@ define(['marionette', this.ui.dp.hide(); } - this.apstatus = new (this.getOption('apStatusItem'))({ ID: this.model.get('ID'), showStrategies: this.showStrategies, showProcessing: this.showProcessing, statuses: this.getOption('apstatuses'), el: this.$el }) + this.apstatus = new (this.getOption('apStatusItem'))({ ID: this.model.get('ID'), DCG: this.model.get('DCG'), showStrategies: this.showStrategies, showProcessing: this.showProcessing, statuses: this.getOption('apstatuses'), el: this.$el }) this.listenTo(this.apstatus, 'status', this.updateAP, this) this.apmessagestatus = new (this.getOption('apMessageStatusItem'))({ ID: this.model.get('ID'), statuses: this.getOption('apmessagestatuses'), el: this.$el }) @@ -157,25 +158,34 @@ define(['marionette', showDistl: function(e) { e.preventDefault() - app.dialog.show(new DialogView({ title: 'Per-image Analysis Plot', view: new DCDISTLView({ parent: this.model }), autoSize: true })) + app.dialog.show(new DialogView({ title: 'Per-image Analysis Plot', view: new DCDISTLView({ parent: this.model, numimg: this.numimg }), autoSize: true })) }, loadStrategies: function(e) { if (!this.strat) { + $('body').addClass('cursor-loading') this.strat = new DCAutoIndexingView({ id: this.model.get('ID') , el: this.$el.find('div.strategies', this.$el) }) this.strat.render() + this.listenToOnce(this.strat.collection, 'sync', () => { + $('body').removeClass('cursor-loading') + }) } else this.strat.$el.slideToggle() }, loadAP: function(e, callback) { if (!this.ap) { + $('body').addClass('cursor-loading') this.ap = new DCAutoIntegrationView({ id: this.model.get('ID'), + dcc: this.model.get('DCC'), dcPurgedProcessedData: this.model.get('PURGEDPROCESSEDDATA'), el: this.$el.find('div.autoproc'), parent: this.model, onReady: callback }) + this.listenToOnce(this.ap.collection, 'sync', () => { + $('body').removeClass('cursor-loading') + }) } else { this.ap.$el.slideToggle(() => { if (callback) callback(this.ap); @@ -186,13 +196,18 @@ define(['marionette', loadDP: function(e) { if (!this.dp) { + $('body').addClass('cursor-loading') this.dp = new DCDownstreamView({ id: this.model.get('ID'), + dcc: this.model.get('DCC'), dcPurgedProcessedData: this.model.get('PURGEDPROCESSEDDATA'), el: this.$el.find('div.downstream'), holderWidth: this.$el.find('.holder').width(), upstreamLink: true, }) + this.listenToOnce(this.dp.collection, 'sync', () => { + $('body').removeClass('cursor-loading') + }) } else this.dp.$el.slideToggle() }, diff --git a/client/src/js/modules/dc/views/dcbase.js b/client/src/js/modules/dc/views/dcbase.js index aa095c923..72c58aba2 100644 --- a/client/src/js/modules/dc/views/dcbase.js +++ b/client/src/js/modules/dc/views/dcbase.js @@ -46,6 +46,13 @@ define(['marionette', var DCBaseView = Marionette.LayoutView.extend({ titleView: DCTitleBase, fullPath: false, + serializeData: function () { + var data = this.model.toJSON(); + data.min = data.DCC > 1 ? 'Min ' : ''; + data.max = data.DCC > 1 ? 'Max ' : ''; + data.tot = data.DCC > 1 ? 'Total ' : ''; + return data; + }, modelEvents: { 'change': 'updateInPlace', @@ -82,10 +89,15 @@ define(['marionette', this.$el.find('li.group').show() this.$el.find('.dcglink').show() this.$el.find('.dclink').hide() + this.$el.find('.reprocess').hide() + if (this.model.get('TYPE') == 'data') { + this.$el.children('.data_collection').addClass('data_collection_group') + } } else { this.$el.find('li.group').hide() this.$el.find('.dcglink').hide() this.$el.find('.dclink').show() + this.$el.find('.reprocess').show() } return value @@ -171,7 +183,7 @@ define(['marionette', this.titleView.render() var vis_link =this.getOption('templateHelpers')()['VIS_LINK'] - this.ui.ul.prepend('
  • Group: '+this.model.escape('DCC')+' Data Collections
  • ') + this.ui.ul.prepend('
  • Group: '+this.model.escape('DCC')+' Data Collections
  • ') this.ui.ul.prepend('
  • Sample: '+this.model.escape('SAMPLE')+'
  • ') this.updateBLSAMPLEID() diff --git a/client/src/js/modules/dc/views/distl.js b/client/src/js/modules/dc/views/distl.js index 120caca7c..0e694286e 100644 --- a/client/src/js/modules/dc/views/distl.js +++ b/client/src/js/modules/dc/views/distl.js @@ -42,8 +42,9 @@ define(['marionette', 'modules/dc/models/distl', 'utils', initialize: function(options) { var pm = options.parent - this.model = new DCDISTLModel({ id: pm.get('ID'), nimg: pm.get('NUMIMG'), pm: pm }) - this.model.fetch() + const dcg = pm.get('DCC') > 1 ? 1 : 0 + this.model = new DCDISTLModel({ id: pm.get('ID'), nimg: pm.get('NUMIMG'), pm: pm, dcg: dcg }) + this.model.fetch({ data: { dcg: dcg }}) this.$el.css('opacity', 0) //this.listenTo(app, 'window:scroll', this.lazyLoad, this) }, diff --git a/client/src/js/modules/dc/views/downstream.js b/client/src/js/modules/dc/views/downstream.js index 0be64f4ea..5e72f1477 100644 --- a/client/src/js/modules/dc/views/downstream.js +++ b/client/src/js/modules/dc/views/downstream.js @@ -163,7 +163,7 @@ define(['backbone', 'marionette', initialize: function(options) { dcPurgedProcessedData = options.dcPurgedProcessedData; - this.collection = new DownStreams(null, { id: options.id }) + this.collection = new DownStreams(null, { id: options.id, dcc: options.dcc }) this.collection.fetch().done(this.render.bind(this)) }, diff --git a/client/src/js/templates/dc/dc.html b/client/src/js/templates/dc/dc.html index 632fcb803..d203764ed 100644 --- a/client/src/js/templates/dc/dc.html +++ b/client/src/js/templates/dc/dc.html @@ -16,23 +16,27 @@