Mercurial > hg > orthanc-stone
changeset 1842:9568082ee013
If available, use ZIP streaming from Orthanc >= 1.9.4 to create archives
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 Jun 2021 14:19:36 +0200 |
parents | 6f82cd776cf6 |
children | 251d7f7a6c4e |
files | Applications/StoneWebViewer/NEWS Applications/StoneWebViewer/WebApplication/app.js Applications/StoneWebViewer/WebApplication/index.html |
diffstat | 3 files changed, 32 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/Applications/StoneWebViewer/NEWS Thu Jun 24 13:53:33 2021 +0200 +++ b/Applications/StoneWebViewer/NEWS Thu Jun 24 14:19:36 2021 +0200 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* If available, use ZIP streaming from Orthanc >= 1.9.4 to create archives + Version 2.0 (2021-05-27) ========================
--- a/Applications/StoneWebViewer/WebApplication/app.js Thu Jun 24 13:53:33 2021 +0200 +++ b/Applications/StoneWebViewer/WebApplication/app.js Thu Jun 24 14:19:36 2021 +0200 @@ -401,6 +401,7 @@ creatingArchive: false, archiveJob: '', mouseTool: 0, + orthancSystem: {}, // Only available if "DicomWebRoot" configuration option is set stoneWebViewerVersion: '...', emscriptenVersion: '...', @@ -998,7 +999,7 @@ } }, - DownloadStudy: function(studyInstanceUid) + DownloadStudy: function(studyInstanceUid, event) { console.log('Creating archive for study: ' + studyInstanceUid); @@ -1010,20 +1011,31 @@ } else { var orthancId = response.data[0]['ID']; - axios.post(that.globalConfiguration.OrthancApiRoot + '/studies/' + orthancId + '/archive', - { - 'Asynchronous' : true - }) - .then(function(response) { - that.creatingArchive = true; - that.archiveJob = response.data.ID; - setTimeout(that.CheckIsDownloadComplete, 1000); - }); + var uri = that.globalConfiguration.OrthancApiRoot + '/studies/' + orthancId + '/archive'; + + if (that.orthancSystem.ApiVersion >= 13) { + // ZIP streaming is available (this is Orthanc >= + // 1.9.4): Simply give the hand to Orthanc + event.preventDefault(); + window.location.href = uri; + + } else { + // ZIP streaming is not available: Create a job to create the archive + axios.post(uri, { + 'Asynchronous' : true + }) + .then(function(response) { + that.creatingArchive = true; + that.archiveJob = response.data.ID; + setTimeout(that.CheckIsDownloadComplete, 1000); + }); + } } }) .catch(function (error) { alert('Cannot find the study in Orthanc'); }); + } }, @@ -1223,6 +1235,13 @@ .catch(function (error) { alert('Cannot load the WebAssembly framework'); }); + + if (app.globalConfiguration.OrthancApiRoot) { + axios.get(app.globalConfiguration.OrthancApiRoot + '/system') + .then(function (response) { + app.orthancSystem = response.data; + }); + } }) .catch(function (error) { alert('Cannot load the configuration file');
--- a/Applications/StoneWebViewer/WebApplication/index.html Thu Jun 24 13:53:33 2021 +0200 +++ b/Applications/StoneWebViewer/WebApplication/index.html Thu Jun 24 14:19:36 2021 +0200 @@ -188,7 +188,7 @@ <!-- download --> <i class="fa fa-download" v-show="!creatingArchive" data-toggle="tooltip" data-title="Download the study" - @click="DownloadStudy(study.tags[STUDY_INSTANCE_UID])"></i> + @click="DownloadStudy(study.tags[STUDY_INSTANCE_UID], $event)"></i> <i class="fas fa-sync fa-spin" v-show="creatingArchive" data-toggle="tooltip" data-title="A ZIP archive is being created by Orthanc..."></i> </a>