Mercurial > hg > orthanc-stl
comparison Sources/OrthancExplorer.js @ 2:2bdb9acb7dcf
added STL viewer button at instance level too
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 18 Jul 2023 09:41:31 +0200 |
parents | 0f03a8a0bd6f |
children | 1cc024bb662a |
comparison
equal
deleted
inserted
replaced
1:0f03a8a0bd6f | 2:2bdb9acb7dcf |
---|---|
20 * You should have received a copy of the GNU General Public License | 20 * You should have received a copy of the GNU General Public License |
21 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 21 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 **/ | 22 **/ |
23 | 23 |
24 | 24 |
25 const SOP_CLASS_UID_STL = '1.2.840.10008.5.1.4.1.1.104.3'; | |
26 | |
27 function AddOpenStlViewerButton(instanceId, id, parent) { | |
28 var b = $('<a>') | |
29 .attr('id', id) | |
30 .attr('data-role', 'button') | |
31 .attr('href', '#') | |
32 .attr('data-icon', 'search') | |
33 .attr('data-theme', 'e') | |
34 .text('STL viewer') | |
35 .button(); | |
36 | |
37 b.insertAfter($('#' + parent)); | |
38 b.click(function() { | |
39 if ($.mobile.pageData) { | |
40 window.open('../stl/app/viewer.html?instance=' + instanceId); | |
41 } | |
42 }); | |
43 } | |
44 | |
45 | |
25 $('#series').live('pagebeforeshow', function() { | 46 $('#series').live('pagebeforeshow', function() { |
26 var seriesId = $.mobile.pageData.uuid; | 47 var seriesId = $.mobile.pageData.uuid; |
27 | 48 |
28 $('#stl-button').remove(); | 49 $('#stl-button-series').remove(); |
29 | 50 |
30 // Test whether this is a whole-slide image by check the SOP Class | 51 // Test whether this is a whole-slide image by check the SOP Class |
31 // UID of one instance of the series | 52 // UID of one instance of the series |
32 GetResource('/series/' + seriesId, function(series) { | 53 GetResource('/series/' + seriesId, function(series) { |
33 var instanceId = series['Instances'][0]; | 54 if (series['Instances'].length == 1) { |
34 | 55 var instanceId = series['Instances'][0]; |
35 $.ajax({ | |
36 url: '/instances/' + instanceId + '/metadata/SopClassUid', | |
37 success: function(sopClassUid) { | |
38 if (sopClassUid == '1.2.840.10008.5.1.4.1.1.104.3') { | |
39 | 56 |
40 // This is an "Encapsulated STL Storage" IOD, register the button | 57 $.ajax({ |
41 var b = $('<a>') | 58 url: '/instances/' + instanceId + '/metadata/SopClassUid', |
42 .attr('id', 'stl-button') | 59 success: function(sopClassUid) { |
43 .attr('data-role', 'button') | 60 if (sopClassUid == SOP_CLASS_UID_STL) { |
44 .attr('href', '#') | 61 // This is an "Encapsulated STL Storage" IOD, register the button |
45 .attr('data-icon', 'search') | 62 AddOpenStlViewerButton(instanceId, 'stl-button-series', 'series-info'); |
46 .attr('data-theme', 'e') | 63 } |
47 .text('STL viewer') | |
48 .button(); | |
49 | |
50 b.insertAfter($('#series-info')); | |
51 b.click(function() { | |
52 if ($.mobile.pageData) { | |
53 window.open('../stl/app/viewer.html?instance=' + instanceId); | |
54 } | |
55 }); | |
56 } | 64 } |
57 } | 65 }); |
58 }); | 66 } |
59 }); | 67 }); |
60 }); | 68 }); |
69 | |
70 | |
71 $('#instance').live('pagebeforeshow', function() { | |
72 var instanceId = $.mobile.pageData.uuid; | |
73 | |
74 $('#stl-button-instance').remove(); | |
75 | |
76 // Test whether this is a whole-slide image by check the SOP Class | |
77 // UID of one instance of the series | |
78 $.ajax({ | |
79 url: '/instances/' + instanceId + '/metadata/SopClassUid', | |
80 success: function(sopClassUid) { | |
81 if (sopClassUid == SOP_CLASS_UID_STL) { | |
82 // This is an "Encapsulated STL Storage" IOD, register the button | |
83 AddOpenStlViewerButton(instanceId, 'stl-button-instance', 'instance-info'); | |
84 } | |
85 } | |
86 }); | |
87 }); |