Skip to content

Commit 33a68a8

Browse files
ndg63276Mark Williams
andauthored
LIMS-1701: Make Xray Centring results an openable table (#935)
Co-authored-by: Mark Williams <mark.williams@diamond.ac.uk>
1 parent e5a10b6 commit 33a68a8

File tree

6 files changed

+84
-27
lines changed

6 files changed

+84
-27
lines changed

api/src/Page/DC.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,20 +1508,25 @@ function _grid_xrc()
15081508
$info = $this->db->pq("SELECT dc.datacollectiongroupid, dc.datacollectionid,
15091509
xrc.xraycentringtype as method, xrcr.xraycentringresultid,
15101510
xrcr.centreofmassx as x, xrcr.centreofmassy as y, xrcr.centreofmassz as z,
1511-
xrcr.totalcount
1511+
xrcr.totalcount,
1512+
xrcr.boundingboxmaxx-xrcr.boundingboxminx as sizex,
1513+
xrcr.boundingboxmaxy-xrcr.boundingboxminy as sizey,
1514+
xrcr.boundingboxmaxz-xrcr.boundingboxminz as sizez,
1515+
s.blsampleid, s.name
15121516
FROM datacollection dc
15131517
INNER JOIN xraycentring xrc ON xrc.datacollectiongroupid = dc.datacollectiongroupid
15141518
INNER JOIN xraycentringresult xrcr ON xrcr.xraycentringid = xrc.xraycentringid
1515-
WHERE dc.datacollectionid = :1 ", array($this->arg('id')));
1519+
LEFT JOIN blsample s ON xrcr.blsampleid = s.blsampleid
1520+
WHERE dc.datacollectionid = :1
1521+
ORDER BY xrcr.totalcount desc", array($this->arg('id')));
15161522

15171523
if (!sizeof($info))
15181524
$this->_output(array('total' => 0, 'data' => array()));
15191525
else {
15201526
foreach ($info as &$i) {
15211527
foreach ($i as $k => &$v) {
1522-
if ($k == 'METHOD')
1523-
continue;
1524-
$v = round(floatval($v), 2);
1528+
if ($k == 'X' || $k == 'Y' || $k == 'Z')
1529+
$v = number_format($v, 1);
15251530
}
15261531
}
15271532
$this->_output(array('total' => sizeof($info), 'data' => $info));
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
define(['backbone'], function(Backbone) {
2+
3+
return Backbone.Collection.extend({
4+
5+
url: function() { return '/dc/grid/xrc/' + this.id },
6+
7+
initialize: function(options) {
8+
this.id = options.id
9+
},
10+
11+
parse: function(r) {
12+
return r.data
13+
},
14+
})
15+
16+
})

client/src/js/modules/dc/models/gridxrc.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ define(['marionette',
1010
'modules/dc/views/dccomments',
1111
'modules/dc/views/attachments',
1212
'modules/dc/views/apstatusitem',
13-
'modules/dc/models/gridxrc',
13+
'modules/dc/views/gridxrc',
1414
'templates/dc/grid.html', 'backbone-validation'],
1515
function(Marionette, DCBase, TabView, AddToProjectView, Editable, Backbone, ImageViewer, GridPlot,
1616
DialogView, DCCommentsView, AttachmentsView, APStatusItem, GridXRC,
@@ -22,6 +22,7 @@ define(['marionette',
2222
apStatusItem: APStatusItem,
2323

2424
events: {
25+
'click .holder h1.xrc': 'loadXRC',
2526
'click @ui.zoom': 'toggleZoom'
2627
},
2728

@@ -136,24 +137,16 @@ define(['marionette',
136137
}
137138

138139
if (state >= 2) {
139-
this.xrc = new GridXRC({ id: this.model.get('ID') })
140-
this.xrc.fetch({
141-
success: this.showXRC.bind(this)
142-
})
140+
this.xrc = new GridXRC({ id: this.model.get('ID'), el: this.$el.find('div.xrc') })
143141
}
144142
}
145143
},
146144

147-
showXRC: function() {
148-
var xrcs = this.xrc.get('data')
149-
var t = ''
150-
for (var i = 0; i < xrcs.length; i++) {
151-
t += ' - Crystal '+(i+1)+': X Pos '+xrcs[i]['X']+' Y Pos '+xrcs[i]['Y']+' Z Pos '+xrcs[i]['Z']+' Strength '+xrcs[i]['TOTALCOUNT']
152-
}
153-
if (xrcs.length > 0) {
154-
this.ui.holder.prepend('Method: '+xrcs[0]['METHOD']+t)
145+
loadXRC: function(e) {
146+
if (!this.xrc) {
147+
this.xrc = new GridXRC({ id: this.model.get('ID'), el: this.$el.find('div.xrc') })
155148
} else {
156-
this.ui.holder.prepend('Found no diffraction')
149+
this.xrc.$el.slideToggle()
157150
}
158151
},
159152

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
define(['marionette',
2+
'modules/dc/collections/gridxrc',
3+
'views/table',
4+
'utils/table'], function(Marionette, GridXRC, TableView, table) {
5+
6+
var linkIfSample = function(data) {
7+
if (data.BLSAMPLEID) {
8+
return '<a href="/samples/sid/'+data.BLSAMPLEID+'"><i class="fa fa-search"></i> '+data.NAME+'</a>'
9+
} else {
10+
return ''
11+
}
12+
}
13+
14+
return Marionette.LayoutView.extend({
15+
template: _.template('<div class="summary"></div>'),
16+
regions: {
17+
summary: '.summary',
18+
},
19+
20+
initialize: function(options) {
21+
this.collection = new GridXRC({ id: options.id })
22+
this.collection.fetch().done(this.render.bind(this))
23+
},
24+
25+
onRender: function() {
26+
this.summary.show(new TableView({
27+
className: 'ui-tabs-panel',
28+
noTableHolder: true,
29+
collection: this.collection,
30+
columns: [
31+
{ label: 'Sample', cell: table.TemplateCell, template: d=>linkIfSample(d), editable: false },
32+
{ name: 'METHOD', label: 'Method', cell: 'string', editable: false },
33+
{ name: 'TOTALCOUNT', label: 'Strength', cell: 'string', editable: false },
34+
{ name: 'X', label: 'Pos X (Boxes)', cell: 'string', editable: false },
35+
{ name: 'Y', label: 'Pos Y (Boxes)', cell: 'string', editable: false },
36+
{ name: 'Z', label: 'Pos Z (Boxes)', cell: 'string', editable: false },
37+
{ name: 'SIZEX', label: 'Size X (Boxes)', cell: 'string', editable: false },
38+
{ name: 'SIZEY', label: 'Size Y (Boxes)', cell: 'string', editable: false },
39+
{ name: 'SIZEZ', label: 'Size Z (Boxes)', cell: 'string', editable: false },
40+
],
41+
pages: false,
42+
backgrid: {
43+
emptyText: 'No xray centring results available for this data collection',
44+
},
45+
}))
46+
},
47+
})
48+
49+
})

client/src/js/templates/dc/grid.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ <h1 class="title"></h1>
3232
<a href="#" class="button zoom"><i class="fa fa-search-plus"></i> <span>Enlarge</span></a>
3333

3434
<div class="holder">
35-
<h1 title="Xray Centring Status and Results" class="xrc"><span><i class="fa fa-spinner fa-spin"></i></span></h1>
35+
<h1 title="Xray Centring Status and Results" class="xrc">Grid Scan Processing<span><i class="fa fa-spinner fa-spin"></i></span></h1>
36+
<div class="xrc"></div>
3637
</div>
3738
</div>

0 commit comments

Comments
 (0)