comparison OrthancExplorer/explorer.js @ 485:bdbde1fbfab3

send resources through HTTP
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 16 Jul 2013 13:48:33 +0200
parents b8ace6fc1d1f
children a8be42bcf2bb
comparison
equal deleted inserted replaced
484:b8ace6fc1d1f 485:bdbde1fbfab3
781 781
782 782
783 783
784 function ChooseDicomModality(callback) 784 function ChooseDicomModality(callback)
785 { 785 {
786 var clickedModality = '';
787 var clickedPeer = '';
788 var items = $('<ul>')
789 .attr('data-divider-theme', 'd')
790 .attr('data-role', 'listview');
791
792 // Retrieve the list of the known DICOM modalities
786 $.ajax({ 793 $.ajax({
787 url: '../modalities', 794 url: '../modalities',
788 type: 'GET', 795 type: 'GET',
789 dataType: 'json', 796 dataType: 'json',
790 async: false, 797 async: false,
791 cache: false, 798 cache: false,
792 success: function(modalities) { 799 success: function(modalities) {
793 var clickedModality = ''; 800 if (modalities.length > 0)
794 var items = $('<ul>') 801 {
795 .attr('data-divider-theme', 'd') 802 items.append('<li data-role="list-divider">DICOM modalities</li>');
796 .attr('data-role', 'listview'); 803
797 804 for (var i = 0; i < modalities.length; i++) {
798 items.append('<li data-role="list-divider">DICOM modalities</li>'); 805 var name = modalities[i];
799 806 var item = $('<li>')
800 for (var i = 0; i < modalities.length; i++) { 807 .html('<a href="#" rel="close">' + name + '</a>')
801 var modality = modalities[i]; 808 .attr('name', name)
802 var item = $('<li>') 809 .click(function() {
803 .html('<a href="#" rel="close">' + modality + '</a>') 810 clickedModality = $(this).attr('name');
804 .attr('modality', modality) 811 });
805 .click(function() { 812 items.append(item);
806 clickedModality = $(this).attr('modality'); 813 }
807 }); 814 }
808 items.append(item); 815
809 } 816 // Retrieve the list of the known Orthanc peers
810 817 $.ajax({
811 items.append('<li data-role="list-divider">Orthanc peers</li>'); 818 url: '../peers',
812 819 type: 'GET',
813 820 dataType: 'json',
814 $('#dialog').simpledialog2({ 821 async: false,
815 mode: 'blank', 822 cache: false,
816 animate: false, 823 success: function(peers) {
817 headerText: 'Choose target', 824 if (peers.length > 0)
818 headerClose: true, 825 {
819 width: '100%', 826 items.append('<li data-role="list-divider">Orthanc peers</li>');
820 blankContent: items, 827
821 callbackClose: function() { 828 for (var i = 0; i < peers.length; i++) {
822 var timer; 829 var name = peers[i];
823 function WaitForDialogToClose() { 830 var item = $('<li>')
824 if (!$('#dialog').is(':visible')) { 831 .html('<a href="#" rel="close">' + name + '</a>')
825 clearInterval(timer); 832 .attr('name', name)
826 callback(clickedModality); 833 .click(function() {
834 clickedPeer = $(this).attr('name');
835 });
836 items.append(item);
827 } 837 }
828 } 838 }
829 timer = setInterval(WaitForDialogToClose, 100); 839
840 // Launch the dialog
841 $('#dialog').simpledialog2({
842 mode: 'blank',
843 animate: false,
844 headerText: 'Choose target',
845 headerClose: true,
846 forceInput: false,
847 width: '100%',
848 blankContent: items,
849 callbackClose: function() {
850 var timer;
851 function WaitForDialogToClose() {
852 if (!$('#dialog').is(':visible')) {
853 clearInterval(timer);
854 callback(clickedModality, clickedPeer);
855 }
856 }
857 timer = setInterval(WaitForDialogToClose, 100);
858 }
859 });
830 } 860 }
831 }); 861 });
832 } 862 }
833 }); 863 });
834 } 864 }
835 865
836 866
837 $('#instance-store,#series-store,#study-store,#patient-store').live('click', function(e) { 867 $('#instance-store,#series-store,#study-store,#patient-store').live('click', function(e) {
838 ChooseDicomModality(function(modality) { 868 ChooseDicomModality(function(modality, peer) {
839 if (modality != '') { 869 var url;
870 var loading;
871
872 if (modality != '')
873 {
874 url = '../modalities/' + modality + '/store';
875 loading = '#dicom-store';
876 }
877
878 if (peer != '')
879 {
880 url = '../peers/' + peer + '/store';
881 loading = '#peer-store';
882 }
883
884 if (url != '') {
840 $.ajax({ 885 $.ajax({
841 url: '../modalities/' + modality + '/store', 886 url: url,
842 type: 'POST', 887 type: 'POST',
843 dataType: 'text', 888 dataType: 'text',
844 data: $.mobile.pageData.uuid, 889 data: $.mobile.pageData.uuid,
845 async: true, // Necessary to block UI 890 async: true, // Necessary to block UI
846 beforeSend: function() { 891 beforeSend: function() {
847 $.blockUI({ message: $('#loading') }); 892 $.blockUI({ message: $(loading) });
848 }, 893 },
849 complete: function(s) { 894 complete: function(s) {
850 $.unblockUI(); 895 $.unblockUI();
851 }, 896 },
852 success: function(s) { 897 success: function(s) {
853 }, 898 },
854 error: function() { 899 error: function() {
855 alert('Error during C-Store'); 900 alert('Error during store');
856 } 901 }
857 }); 902 });
858
859 } 903 }
860 }); 904 });
861 }); 905 });
862 906
863 907