Mercurial > hg > orthanc
diff OrthancServer/OrthancExplorer/explorer.js @ 4853:b3d0a3a4d890
Added links to download attachments from the Orthanc Explorer
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 16 Dec 2021 14:48:46 +0100 |
parents | 7053502fbf97 |
children | 3e9a76464e8a 43e613a7756b |
line wrap: on
line diff
--- a/OrthancServer/OrthancExplorer/explorer.js Tue Dec 14 22:52:59 2021 +0100 +++ b/OrthancServer/OrthancExplorer/explorer.js Thu Dec 16 14:48:46 2021 +0100 @@ -701,7 +701,19 @@ } } +function SetupAttachments(accessSelector, liClass, resourceId, resourceType) { + GetResource('/' + resourceType + '/' + resourceId + '/attachments?full', function(attachments) { + target = $(accessSelector); + $('.' + liClass).remove(); + for (var key in attachments) { + if (attachments[key] >= 1024) { + target.append('<li data-icon="gear" class="' + liClass + '"><a href="#" id="' + attachments[key] + '">Download ' + key + '</a></li>') + } + } + target.listview('refresh'); + }); +} function RefreshPatient() { @@ -738,6 +750,7 @@ SetupAnonymizedOrModifiedFrom('#patient-anonymized-from', patient, 'patient', ANONYMIZED_FROM); SetupAnonymizedOrModifiedFrom('#patient-modified-from', patient, 'patient', MODIFIED_FROM); + SetupAttachments('#patient-access', 'patient-attachment', pageData.uuid, 'patients'); target.listview('refresh'); @@ -785,6 +798,7 @@ SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', ANONYMIZED_FROM); SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', MODIFIED_FROM); + SetupAttachments('#study-access', 'study-attachment', pageData.uuid, 'studies'); target = $('#list-series'); $('li', target).remove(); @@ -802,6 +816,7 @@ } target.listview('refresh'); + currentPage = 'study'; currentUuid = pageData.uuid; }); @@ -839,6 +854,7 @@ SetupAnonymizedOrModifiedFrom('#series-anonymized-from', series, 'series', ANONYMIZED_FROM); SetupAnonymizedOrModifiedFrom('#series-modified-from', series, 'series', MODIFIED_FROM); + SetupAttachments('#series-access', 'series-attachment', pageData.uuid, 'series'); target = $('#list-instances'); $('li', target).remove(); @@ -978,6 +994,8 @@ SetupAnonymizedOrModifiedFrom('#instance-anonymized-from', instance, 'instance', ANONYMIZED_FROM); SetupAnonymizedOrModifiedFrom('#instance-modified-from', instance, 'instance', MODIFIED_FROM); + SetupAttachments('#instance-access', 'instance-attachment', pageData.uuid, 'instances'); + currentPage = 'instance'; currentUuid = pageData.uuid; }); @@ -1347,7 +1365,25 @@ window.location.href = '../series/' + $.mobile.pageData.uuid + '/media'; }); +$('.patient-attachment').live('click', function(e) { + e.preventDefault(); //stop the browser from following + window.location.href = '../patients/' + $.mobile.pageData.uuid + '/attachments/' + e.target.id + '/data'; +}); +$('.study-attachment').live('click', function(e) { + e.preventDefault(); //stop the browser from following + window.location.href = '../studies/' + $.mobile.pageData.uuid + '/attachments/' + e.target.id + '/data'; +}); + +$('.series-attachment').live('click', function(e) { + e.preventDefault(); //stop the browser from following + window.location.href = '../series/' + $.mobile.pageData.uuid + '/attachments/' + e.target.id + '/data'; +}); + +$('.instance-attachment').live('click', function(e) { + e.preventDefault(); //stop the browser from following + window.location.href = '../instances/' + $.mobile.pageData.uuid + '/attachments/' + e.target.id + '/data'; +}); $('#protection').live('change', function(e) { var isProtected = e.target.value == "on";