Mercurial > hg > orthanc
comparison OrthancServer/OrthancExplorer/explorer.js @ 5241:efaeec259623 db-protobuf
added labels at the study level in orthanc explorer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Apr 2023 20:14:59 +0200 |
parents | 0ea402b4d901 |
children | c60a7fc95f04 |
comparison
equal
deleted
inserted
replaced
5239:178b0434256a | 5241:efaeec259623 |
---|---|
63 | 63 |
64 var ANONYMIZED_FROM = 'AnonymizedFrom'; | 64 var ANONYMIZED_FROM = 'AnonymizedFrom'; |
65 var MODIFIED_FROM = 'ModifiedFrom'; | 65 var MODIFIED_FROM = 'ModifiedFrom'; |
66 | 66 |
67 | 67 |
68 function IsAlphanumeric(s) | |
69 { | |
70 return s.match(/^[0-9a-zA-Z]+$/); | |
71 } | |
72 | |
73 | |
68 function DeepCopy(obj) | 74 function DeepCopy(obj) |
69 { | 75 { |
70 return jQuery.extend(true, {}, obj); | 76 return jQuery.extend(true, {}, obj); |
71 } | 77 } |
72 | 78 |
699 target.append('<li data-icon="gear" class="' + liClass + '"><a href="#" id="' + attachments[key] + '">Download ' + key + '</a></li>') | 705 target.append('<li data-icon="gear" class="' + liClass + '"><a href="#" id="' + attachments[key] + '">Download ' + key + '</a></li>') |
700 } | 706 } |
701 } | 707 } |
702 target.listview('refresh'); | 708 target.listview('refresh'); |
703 }); | 709 }); |
704 | 710 } |
705 } | 711 |
712 | |
713 | |
714 function RefreshLabels(nodeLabels, resourceLevel, resourceId) | |
715 { | |
716 GetResource('/' + resourceLevel + '/' + resourceId + '/labels', function(labels) { | |
717 nodeLabels.empty(); | |
718 | |
719 if (labels.length > 0) { | |
720 for (var i = 0; i < labels.length; i++) { | |
721 var removeButton = $('<button>').text('X').attr('title', 'Remove label "' + labels[i] + '"'); | |
722 | |
723 removeButton.click({ | |
724 label : labels[i], | |
725 nodeLabels : nodeLabels | |
726 }, function(s) { | |
727 $.ajax({ | |
728 url: '../' + resourceLevel + '/' + resourceId + '/labels/' + s.data.label, | |
729 dataType: 'json', | |
730 type: 'DELETE', | |
731 success: function(ss) { | |
732 RefreshLabels(nodeLabels, resourceLevel, resourceId); | |
733 } | |
734 }); | |
735 }); | |
736 | |
737 nodeLabels.append($('<span>').text(labels[i] + ' ').addClass('label').append(removeButton)); | |
738 } | |
739 } else { | |
740 nodeLabels.css('display', 'none'); | |
741 } | |
742 }); | |
743 } | |
744 | |
745 | |
746 function ConfigureLabels(nodeLabels, addLabelButton, resourceLevel, resourceId) | |
747 { | |
748 RefreshLabels(nodeLabels, resourceLevel, resourceId); | |
749 | |
750 addLabelButton.click(function(s) { | |
751 $('#dialog').simpledialog2({ | |
752 mode: 'button', | |
753 animate: false, | |
754 headerText: 'Add label', | |
755 headerClose: true, | |
756 buttonPrommpt: 'Enter the new label', | |
757 buttonInput: true, | |
758 width: '100%', | |
759 buttons : { | |
760 'OK': { | |
761 click: function () { | |
762 var label = $.mobile.sdLastInput; | |
763 if (label.length > 0) { | |
764 if (IsAlphanumeric(label)) { | |
765 $.ajax({ | |
766 url: '../' + resourceLevel + '/' + resourceId + '/labels/' + label, | |
767 dataType: 'json', | |
768 type: 'PUT', | |
769 data: '', | |
770 success: function(ss) { | |
771 RefreshLabels(nodeLabels, resourceLevel, resourceId); | |
772 } | |
773 }); | |
774 } else { | |
775 alert('Error: Labels can only contain alphanumeric characters'); | |
776 } | |
777 } | |
778 } | |
779 }, | |
780 } | |
781 }); | |
782 }); | |
783 } | |
784 | |
706 | 785 |
707 function RefreshPatient() | 786 function RefreshPatient() |
708 { | 787 { |
709 var pageData, target, v; | 788 var pageData, target, v; |
710 | 789 |
769 var pageData, target; | 848 var pageData, target; |
770 | 849 |
771 if ($.mobile.pageData) { | 850 if ($.mobile.pageData) { |
772 pageData = DeepCopy($.mobile.pageData); | 851 pageData = DeepCopy($.mobile.pageData); |
773 | 852 |
774 GetResource('/studies/' + pageData.uuid + '?full', function(study) { | 853 GetResource('/system', function(system) { |
775 GetResource('/patients/' + study.ParentPatient + '?full', function(patient) { | 854 GetResource('/studies/' + pageData.uuid + '?full', function(study) { |
776 GetResource('/studies/' + pageData.uuid + '/series?full', function(series) { | 855 GetResource('/patients/' + study.ParentPatient + '?full', function(patient) { |
777 SortOnDicomTag(series, SERIES_DATE, false, true); | 856 GetResource('/studies/' + pageData.uuid + '/series?full', function(series) { |
778 | 857 SortOnDicomTag(series, SERIES_DATE, false, true); |
779 $('#study .patient-link').attr('href', '#patient?uuid=' + patient.ID); | 858 |
780 $('#study-info li').remove(); | 859 $('#study .patient-link').attr('href', '#patient?uuid=' + patient.ID); |
781 $('#study-info') | 860 $('#study-info li').remove(); |
782 .append('<li data-role="list-divider">Patient</li>') | 861 |
783 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) | 862 var info = $('#study-info') |
784 .append('<li data-role="list-divider">Study</li>') | 863 .append('<li data-role="list-divider">Patient</li>') |
785 .append(FormatStudy(study)) | 864 .append(FormatPatient(patient, '#patient?uuid=' + patient.ID, true)) |
786 .listview('refresh'); | 865 .append('<li data-role="list-divider">Study</li>') |
787 | 866 .append(FormatStudy(study)); |
788 SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', ANONYMIZED_FROM); | 867 |
789 SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', MODIFIED_FROM); | 868 if (system.HasLabels === true) { |
790 SetupAttachments('#study-access', 'study-attachment', pageData.uuid, 'studies'); | 869 var nodeLabels = $('<li>').append($('<div>')); |
791 | 870 var addLabelButton = $('<a>').text('Add label'); |
792 target = $('#list-series'); | 871 ConfigureLabels(nodeLabels, addLabelButton, 'studies', study.ID) |
793 $('li', target).remove(); | 872 |
794 for (var i = 0; i < series.length; i++) { | 873 info |
795 if (i == 0 || | 874 .append('<li data-role="list-divider">Labels</li>') |
796 GetMainDicomTag(series[i].MainDicomTags, SERIES_DATE) != | 875 .append(nodeLabels) |
797 GetMainDicomTag(series[i - 1].MainDicomTags, SERIES_DATE)) | 876 .append($('<li>').attr('data-icon', 'plus').append(addLabelButton)); |
798 { | |
799 target.append($('<li>') | |
800 .attr('data-role', 'list-divider') | |
801 .text(FormatDicomDate(GetMainDicomTag(series[i].MainDicomTags, SERIES_DATE)))); | |
802 } | 877 } |
803 | 878 |
804 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); | 879 info.listview('refresh'); |
805 } | 880 |
806 target.listview('refresh'); | 881 SetupAnonymizedOrModifiedFrom('#study-anonymized-from', study, 'study', ANONYMIZED_FROM); |
807 | 882 SetupAnonymizedOrModifiedFrom('#study-modified-from', study, 'study', MODIFIED_FROM); |
808 | 883 SetupAttachments('#study-access', 'study-attachment', pageData.uuid, 'studies'); |
809 currentPage = 'study'; | 884 |
810 currentUuid = pageData.uuid; | 885 target = $('#list-series'); |
886 $('li', target).remove(); | |
887 for (var i = 0; i < series.length; i++) { | |
888 if (i == 0 || | |
889 GetMainDicomTag(series[i].MainDicomTags, SERIES_DATE) != | |
890 GetMainDicomTag(series[i - 1].MainDicomTags, SERIES_DATE)) | |
891 { | |
892 target.append($('<li>') | |
893 .attr('data-role', 'list-divider') | |
894 .text(FormatDicomDate(GetMainDicomTag(series[i].MainDicomTags, SERIES_DATE)))); | |
895 } | |
896 | |
897 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); | |
898 } | |
899 target.listview('refresh'); | |
900 | |
901 | |
902 currentPage = 'study'; | |
903 currentUuid = pageData.uuid; | |
904 }); | |
811 }); | 905 }); |
812 }); | 906 }); |
813 }); | 907 }); |
814 } | 908 } |
815 } | 909 } |