Skip to content

Commit 970f69f

Browse files
authored
Merge pre-release/2025-R2.1 into master (#920)
* LIMS-1646: Show 'Use Facility Account' button for EU dewar dispatch (#910) * LIMS-1622: Add units and decimal places to visit summary page (#911) * LIMS-1605: Remove jquery-touchswipe library (#895) * LIMS-1496: Fix offset grid scan heatmaps in Safari (#896) * LIMS-1389 - Add upload to ccp4 cloud button (#901) * LIMS-538: Remove the 'Centring Method' column from creating an MX container (#908) * LIMS-128: Add plate view to queue container page (#900)
1 parent 92984cb commit 970f69f

27 files changed

+401
-131
lines changed

api/config_sample.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,7 @@
379379
$dials_rest_url = "";
380380
$dials_rest_jwt = "";
381381
$dials_rest_url_rings = false;
382+
383+
# Add a button to upload file to CCP4 cloud
384+
#$ccp4_cloud_upload_url = 'https://data.cloud.ccp4.ac.uk/api/data/<%=USERNAME%>/<%=FACILITYNAME%>/<%=IMAGEPREFIX%>_<%=DATACOLLECTIONNUMBER%>/upload';
382385
?>

api/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function setupApplication($mode): Slim
7272
$dhl_enable, $scale_grid, $scale_grid_end_date, $preset_proposal, $timezone,
7373
$valid_components, $enabled_container_types, $synchweb_version, $redirects,
7474
$shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments,
75-
$dials_rest_url_rings, $closed_proposal_link;
75+
$dials_rest_url_rings, $closed_proposal_link, $ccp4_cloud_upload_url;
7676
$app->contentType('application/json');
7777
$options = $app->container['options'];
7878
$app->response()->body(json_encode(array(
@@ -97,6 +97,7 @@ function setupApplication($mode): Slim
9797
'shipping_service_app_url_incoming' => $use_shipping_service_redirect_incoming_shipments ? $shipping_service_app_url : null,
9898
'closed_proposal_link' => $closed_proposal_link,
9999
'dials_rest_url_rings' => $dials_rest_url_rings,
100+
'ccp4_cloud_upload_url' => $ccp4_cloud_upload_url,
100101
'redirects' => $redirects
101102
)));
102103
});

api/src/Page/Processing.php

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,10 @@ class Processing extends Page {
1616

1717
array('/downstream/:id', 'get', '_downstream'),
1818
array('/downstream/images/:aid(/n/:n)', 'get', '_downstream_images'),
19-
array(
20-
'/downstream/mapmodel/:aid(/n/:n)',
21-
'get',
22-
'_downstream_mapmodel',
23-
),
24-
array(
25-
'/multiplex_jobs/groups/:blSampleGroupId',
26-
'get',
27-
'_get_latest_multiplex_job_result'
28-
),
19+
array('/downstream/mapmodel/:aid(/n/:n)', 'get', '_downstream_mapmodel'),
20+
array('/multiplex_jobs/groups/:blSampleGroupId', 'get', '_get_latest_multiplex_job_result'),
21+
22+
array('/upload', 'post', '_upload_to_cloud'),
2923
);
3024

3125
public static $arg_list = array(
@@ -44,6 +38,10 @@ class Processing extends Page {
4438
'rmeas' => '[\d\.]+',
4539
'cchalf' => '[\d\.]+',
4640
'ccanom' => '[\d\.]+',
41+
'username' => '(\w|\s|\-|\.)+',
42+
'cloudrunid' => '(\w|\-)+',
43+
'AUTOPROCPROGRAMATTACHMENTID' => '\d+',
44+
'DATACOLLECTIONFILEATTACHMENTID' => '\d+',
4745
);
4846

4947
/**
@@ -66,6 +64,80 @@ function _map_status($status) {
6664
}
6765
}
6866

67+
function _make_curl_file($file){
68+
$mime = mime_content_type($file);
69+
$info = pathinfo($file);
70+
$name = $info['basename'];
71+
$output = new \CURLFile($file, $mime, $name);
72+
return $output;
73+
}
74+
75+
function _upload_to_cloud() {
76+
global $facility_name, $facility_short, $ccp4_cloud_upload_url;
77+
if (!$this->has_arg('AUTOPROCPROGRAMATTACHMENTID') && !$this->has_arg('DATACOLLECTIONFILEATTACHMENTID')) {
78+
$this->_error('No file specified');
79+
}
80+
if (!$this->has_arg('username')) {
81+
$this->_error('No username specified');
82+
}
83+
if (!$this->has_arg('cloudrunid')) {
84+
$this->_error('No cloudrun id specified');
85+
}
86+
if ($this->has_arg('AUTOPROCPROGRAMATTACHMENTID')) {
87+
$select = ", concat(appa.filepath, '/', appa.filename) as filefullpath";
88+
$join = "INNER JOIN processingjob pj ON dc.datacollectionid = pj.datacollectionid
89+
INNER JOIN autoprocprogram app ON pj.processingjobid = app.processingjobid
90+
INNER JOIN autoprocprogramattachment appa ON app.autoprocprogramid = appa.autoprocprogramid";
91+
$where = "WHERE appa.autoprocprogramattachmentid=:1";
92+
$args = array($this->arg('AUTOPROCPROGRAMATTACHMENTID'));
93+
} else if ($this->has_arg('DATACOLLECTIONFILEATTACHMENTID')) {
94+
$select = ", dcfa.filefullpath";
95+
$join = "INNER JOIN datacollectionfileattachment dcfa ON dc.datacollectionid = dcfa.datacollectionid";
96+
$where = "WHERE dcfa.datacollectionfileattachmentid=:1";
97+
$args = array($this->arg('DATACOLLECTIONFILEATTACHMENTID'));
98+
}
99+
$dc = $this->db->pq(
100+
"SELECT dc.imageprefix, dc.datacollectionnumber, concat(p.proposalcode, p.proposalnumber, '-', s.visit_number) as visit
101+
$select
102+
FROM datacollection dc
103+
INNER JOIN blsession s ON dc.sessionid = s.sessionid
104+
INNER JOIN proposal p ON s.proposalid = p.proposalid
105+
$join
106+
$where",
107+
$args);
108+
$dc = $dc[0];
109+
$dc['USERNAME'] = $this->arg('username');
110+
$dc['FACILITYNAME'] = strtolower(preg_replace( '/[\W]/', '', $facility_name));
111+
$dc['FACILITYSHORT'] = strtolower(preg_replace( '/[\W]/', '', $facility_short));
112+
$url = preg_replace_callback('/<%=(\w+)%>/',
113+
function($mat) use ($dc) {
114+
if (array_key_exists($mat[1], $dc)) {
115+
return $dc[$mat[1]];
116+
}
117+
},
118+
$ccp4_cloud_upload_url);
119+
$ch = curl_init($url);
120+
$headers = array('cloudrun_id: '.$this->arg('cloudrunid'));
121+
$data = array('file' => $this->_make_curl_file($dc['FILEFULLPATH']));
122+
curl_setopt_array(
123+
$ch,
124+
array(
125+
CURLOPT_RETURNTRANSFER => TRUE,
126+
CURLOPT_HTTPHEADER => $headers,
127+
CURLOPT_TIMEOUT => 10,
128+
CURLOPT_POST => TRUE,
129+
CURLOPT_POSTFIELDS => $data,
130+
)
131+
);
132+
$result = json_decode(curl_exec($ch));
133+
curl_close($ch);
134+
if (isset($result->error)) {
135+
$this->_error($result);
136+
} else {
137+
$this->_output($result);
138+
}
139+
}
140+
69141
function _screening_status($where, $ids) {
70142
$screenings = $this->db->pq(
71143
"SELECT dc.datacollectionid, sc.programversion, so.indexingsuccess, so.strategysuccess, so.alignmentsuccess
@@ -420,13 +492,16 @@ function _results_for_visit() {
420492
// Set number of decimal places
421493
$nf = array(
422494
0 => array('ENERGY'),
495+
1 => array(
496+
'OVERALLCOMPLETENESS', 'INNERCOMPLETENESS', 'OUTERCOMPLETENESS',
497+
'ANOMOVERALLCOMPLETENESS', 'ANOMINNERCOMPLETENESS', 'ANOMOUTERCOMPLETENESS',
498+
),
423499
2 => array(
424-
'RESOLUTION', 'INNERRMEAS', 'OUTERCCHALF', 'INNERCCANOM',
500+
'RESOLUTION', 'OUTERCCHALF', 'INNERCCANOM',
425501
'CELL_A', 'CELL_B', 'CELL_C', 'CELL_AL', 'CELL_BE', 'CELL_GA',
426502
'OVERALLRHIGH', 'OVERALLRLOW', 'INNERRHIGH', 'INNERRLOW', 'OUTERRHIGH', 'OUTERRLOW',
427-
'OVERALLCOMPLETENESS', 'INNERCOMPLETENESS', 'OUTERCOMPLETENESS',
428-
'ANOMOVERALLCOMPLETENESS', 'ANOMINNERCOMPLETENESS', 'ANOMOUTERCOMPLETENESS'
429-
)
503+
),
504+
3 => array('INNERRMEAS'),
430505
);
431506

432507
foreach ($nf as $nff => $cols) {

api/src/Page/Sample.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ function _queue_all_sub_samples()
596596
$this->_error('No containerid specified');
597597
}
598598

599-
$args = array($this->proposalid, $this->arg('cid'), $this->arg('cid'), $this->arg('cid'));
599+
$args = array($this->proposalid, $this->arg('cid'));
600600
$where = ' AND c.containerid=:2 AND cq2.completedtimestamp IS NULL';
601601

602602
if ($this->has_arg('filter')) {
@@ -609,8 +609,14 @@ function _queue_all_sub_samples()
609609
$where .= $filters[$this->arg('filter')];
610610
}
611611

612-
$first_inner_select_where = ' AND s.containerid=:3';
613-
$second_inner_select_where = ' AND s.containerid=:4';
612+
if ($this->has_arg('LOCATION')) {
613+
$where .= ' AND s.location=:' . (sizeof($args) + 1);
614+
array_push($args, $this->arg('LOCATION'));
615+
}
616+
617+
$first_inner_select_where = ' AND s.containerid=:' . (sizeof($args) + 1);
618+
$second_inner_select_where = ' AND s.containerid=:' . (sizeof($args) + 2);
619+
array_push($args, $this->arg('cid'), $this->arg('cid'));
614620

615621
$this->db->wait_rep_sync(true);
616622
$ss_query_string = $this->get_sub_samples_query($where, $first_inner_select_where, $second_inner_select_where);
@@ -1311,8 +1317,8 @@ function _handle_update_sample_full($a, $sid)
13111317
$blSampleId = $samp['BLSAMPLEID'];
13121318

13131319
$this->db->pq(
1314-
"UPDATE blsample set name=:1,comments=:2,code=:3,volume=:4,packingfraction=:5,dimension1=:6,dimension2=:7,dimension3=:8,shape=:9,looptype=:10 WHERE blsampleid=:11",
1315-
array($a['NAME'], $a['COMMENTS'], $a['CODE'], $a['VOLUME'], $a['PACKINGFRACTION'], $a['DIMENSION1'], $a['DIMENSION2'], $a['DIMENSION3'], $a['SHAPE'], $a['LOOPTYPE'], $blSampleId)
1320+
"UPDATE blsample set name=:1,comments=:2,code=:3,volume=:4,packingfraction=:5,dimension1=:6,dimension2=:7,dimension3=:8,shape=:9,looptype=:10,smiles=:11 WHERE blsampleid=:12",
1321+
array($a['NAME'], $a['COMMENTS'], $a['CODE'], $a['VOLUME'], $a['PACKINGFRACTION'], $a['DIMENSION1'], $a['DIMENSION2'], $a['DIMENSION3'], $a['SHAPE'], $a['LOOPTYPE'], $a['SMILES'], $blSampleId)
13161322
);
13171323

13181324
if (array_key_exists('PROTEINID', $a)) {
@@ -1480,6 +1486,7 @@ function _prepare_sample_args($s = null)
14801486
'LOOPTYPE',
14811487
'ENERGY',
14821488
'USERPATH',
1489+
'SMILES',
14831490
'SCREENINGMETHOD',
14841491
'SCREENINGCOLLECTVALUE',
14851492
'SAMPLEGROUP',
@@ -1537,8 +1544,8 @@ function _do_add_sample($s)
15371544
}
15381545

15391546
$this->db->pq(
1540-
"INSERT INTO blsample (blsampleid,crystalid,diffractionplanid,containerid,location,comments,name,code,blsubsampleid,screencomponentgroupid,volume,packingfraction,dimension1,dimension2,dimension3,shape,looptype,source) VALUES (s_blsample.nextval,:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,IFNULL(:17,CURRENT_USER)) RETURNING blsampleid INTO :id",
1541-
array($crysid, $did, $a['CONTAINERID'], $a['LOCATION'], $a['COMMENTS'], $a['NAME'], $a['CODE'], $a['BLSUBSAMPLEID'], $a['SCREENCOMPONENTGROUPID'], $a['VOLUME'], $a['PACKINGFRACTION'], $a['DIMENSION1'], $a['DIMENSION2'], $a['DIMENSION3'], $a['SHAPE'], $a['LOOPTYPE'], $a['SOURCE'])
1547+
"INSERT INTO blsample (blsampleid,crystalid,diffractionplanid,containerid,location,comments,name,code,blsubsampleid,screencomponentgroupid,volume,packingfraction,dimension1,dimension2,dimension3,shape,looptype,smiles,source) VALUES (s_blsample.nextval,:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,IFNULL(:18,CURRENT_USER)) RETURNING blsampleid INTO :id",
1548+
array($crysid, $did, $a['CONTAINERID'], $a['LOCATION'], $a['COMMENTS'], $a['NAME'], $a['CODE'], $a['BLSUBSAMPLEID'], $a['SCREENCOMPONENTGROUPID'], $a['VOLUME'], $a['PACKINGFRACTION'], $a['DIMENSION1'], $a['DIMENSION2'], $a['DIMENSION3'], $a['SHAPE'], $a['LOOPTYPE'], $a['SMILES'], $a['SOURCE'])
15421549
);
15431550
$sid = $this->db->id();
15441551

client/package-lock.json

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
"jquery": "^1.12.4",
8282
"jquery-color": "^3.0.0-alpha.1",
8383
"jquery-flot-resize": "^1.0.0",
84-
"jquery-touchswipe": "^1.6.19",
8584
"jquery-ui": "^1.12.1",
8685
"jquery-ui-timepicker-addon": "^1.6.3",
8786
"jquery.flot": "^0.8.3",

client/src/css/partials/_imaging.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,7 @@ input[name=gap] {
226226
text-align: center;
227227
box-sizing: content-box;
228228
}
229+
230+
.plate-max-width {
231+
max-width: 700px;
232+
}

client/src/css/partials/_utility.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@
9797
font-weight: bold;
9898
}
9999

100+
.u {
101+
text-decoration: underline;
102+
}
103+
100104
.nowrap {
101105
white-space: nowrap;
102106
}

client/src/js/app/store/modules/store.samples.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const INITIAL_SAMPLE_STATE = {
3939
SCREENINGCOLLECTVALUE: '',
4040
THEORETICALDENSITY: '',
4141
SHAPE: '',
42+
SMILES: '',
4243
SPACEGROUP: '',
4344
SYMBOL: '',
4445
USERPATH: '',

client/src/js/modules/dc/views/attachments.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ define(['marionette',
33
'views/table',
44
'collections/attachments',
55
'views/log',
6+
'views/cloudupload',
67
'utils'],
7-
function(Marionette, Backgrid, TableView, attachments, LogView, utils) {
8+
function(Marionette, Backgrid, TableView, attachments, LogView, CloudUploadView, utils) {
89

910

1011
var OptionsCell = Backgrid.Cell.extend({
1112
events: {
1213
'click a.dl': utils.signHandler,
1314
'click a.rsv': 'closeDialog',
1415
'click a.vatlog': 'showLog',
16+
'click a.vatupload': 'showCloudUpload',
1517
},
1618

1719
closeDialog: function() {
@@ -30,6 +32,11 @@ define(['marionette',
3032
})
3133
},
3234

35+
showCloudUpload: function(e) {
36+
e.preventDefault()
37+
app.dialog.show(new CloudUploadView({ model: this.model, collection: this.model.collection }))
38+
},
39+
3340
render: function() {
3441
// This was using an 'id' passed into the column as the dcid (getOption('id')).
3542
// However, this is not present when loading attachments from a data collection group
@@ -46,6 +53,10 @@ define(['marionette',
4653
this.$el.append('<a href="/dc/rsv/id/'+dcid+'" class="button rsv"><i class="fa fa-search"></i> Reciprocal Space Viewer</a>')
4754
}
4855

56+
if (app.options.get('ccp4_cloud_upload_url') && this.model.get('FILETYPE') == 'params') {
57+
this.$el.append('<a class="vatupload button" href="#"><i class="fa fa-cloud-upload"></i> CCP4 Cloud</a>')
58+
}
59+
4960
return this
5061
}
5162
})

0 commit comments

Comments
 (0)