Mercurial > hg > orthanc
comparison OrthancExplorer/explorer.js @ 2119:e0517f25919e
Improved robustness of Orthanc Explorer wrt. query/retrieve (maybe fix issue #24)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 06 Nov 2016 11:39:04 +0100 |
parents | 5cdea1cd2071 |
children | ccd44d546b47 |
comparison
equal
deleted
inserted
replaced
2118:9cf176bc21ad | 2119:e0517f25919e |
---|---|
26 : match;*/ | 26 : match;*/ |
27 | 27 |
28 return args[number]; | 28 return args[number]; |
29 }); | 29 }); |
30 }; | 30 }; |
31 | |
32 | |
33 function DeepCopy(obj) | |
34 { | |
35 return jQuery.extend(true, {}, obj); | |
36 } | |
37 | |
38 | |
39 function ChangePage(page, options) | |
40 { | |
41 var first = true; | |
42 if (options) { | |
43 for (var key in options) { | |
44 var value = options[key]; | |
45 if (first) { | |
46 page += '?'; | |
47 first = false; | |
48 } else { | |
49 page += '&'; | |
50 } | |
51 | |
52 page += key + '=' + value; | |
53 } | |
54 } | |
55 | |
56 window.location.replace('explorer.html#' + page); | |
57 /*$.mobile.changePage('#' + page, { | |
58 changeHash: true | |
59 });*/ | |
60 } | |
31 | 61 |
32 | 62 |
33 function Refresh() | 63 function Refresh() |
34 { | 64 { |
35 if (currentPage == 'patient') | 65 if (currentPage == 'patient') |
367 | 397 |
368 | 398 |
369 function RefreshPatient() | 399 function RefreshPatient() |
370 { | 400 { |
371 if ($.mobile.pageData) { | 401 if ($.mobile.pageData) { |
372 GetResource('/patients/' + $.mobile.pageData.uuid, function(patient) { | 402 var pageData = DeepCopy($.mobile.pageData); |
373 GetResource('/patients/' + $.mobile.pageData.uuid + '/studies', function(studies) { | 403 |
404 GetResource('/patients/' + pageData.uuid, function(patient) { | |
405 GetResource('/patients/' + pageData.uuid + '/studies', function(studies) { | |
374 SortOnDicomTag(studies, 'StudyDate', false, true); | 406 SortOnDicomTag(studies, 'StudyDate', false, true); |
375 | 407 |
376 $('#patient-info li').remove(); | 408 $('#patient-info li').remove(); |
377 $('#patient-info') | 409 $('#patient-info') |
378 .append('<li data-role="list-divider">Patient</li>') | 410 .append('<li data-role="list-divider">Patient</li>') |
397 | 429 |
398 target.listview('refresh'); | 430 target.listview('refresh'); |
399 | 431 |
400 // Check whether this patient is protected | 432 // Check whether this patient is protected |
401 $.ajax({ | 433 $.ajax({ |
402 url: '../patients/' + $.mobile.pageData.uuid + '/protected', | 434 url: '../patients/' + pageData.uuid + '/protected', |
403 type: 'GET', | 435 type: 'GET', |
404 dataType: 'text', | 436 dataType: 'text', |
405 async: false, | 437 async: false, |
406 cache: false, | 438 cache: false, |
407 success: function (s) { | 439 success: function (s) { |
409 $('#protection').val(v).slider('refresh'); | 441 $('#protection').val(v).slider('refresh'); |
410 } | 442 } |
411 }); | 443 }); |
412 | 444 |
413 currentPage = 'patient'; | 445 currentPage = 'patient'; |
414 currentUuid = $.mobile.pageData.uuid; | 446 currentUuid = pageData.uuid; |
415 }); | 447 }); |
416 }); | 448 }); |
417 } | 449 } |
418 } | 450 } |
419 | 451 |
420 | 452 |
421 function RefreshStudy() | 453 function RefreshStudy() |
422 { | 454 { |
423 if ($.mobile.pageData) { | 455 if ($.mobile.pageData) { |
424 GetResource('/studies/' + $.mobile.pageData.uuid, function(study) { | 456 var pageData = DeepCopy($.mobile.pageData); |
457 | |
458 GetResource('/studies/' + pageData.uuid, function(study) { | |
425 GetResource('/patients/' + study.ParentPatient, function(patient) { | 459 GetResource('/patients/' + study.ParentPatient, function(patient) { |
426 GetResource('/studies/' + $.mobile.pageData.uuid + '/series', function(series) { | 460 GetResource('/studies/' + pageData.uuid + '/series', function(series) { |
427 SortOnDicomTag(series, 'SeriesDate', false, true); | 461 SortOnDicomTag(series, 'SeriesDate', false, true); |
428 | 462 |
429 $('#study .patient-link').attr('href', '#patient?uuid=' + patient.ID); | 463 $('#study .patient-link').attr('href', '#patient?uuid=' + patient.ID); |
430 $('#study-info li').remove(); | 464 $('#study-info li').remove(); |
431 $('#study-info') | 465 $('#study-info') |
449 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); | 483 target.append(FormatSeries(series[i], '#series?uuid=' + series[i].ID)); |
450 } | 484 } |
451 target.listview('refresh'); | 485 target.listview('refresh'); |
452 | 486 |
453 currentPage = 'study'; | 487 currentPage = 'study'; |
454 currentUuid = $.mobile.pageData.uuid; | 488 currentUuid = pageData.uuid; |
455 }); | 489 }); |
456 }); | 490 }); |
457 }); | 491 }); |
458 } | 492 } |
459 } | 493 } |
460 | 494 |
461 | 495 |
462 function RefreshSeries() | 496 function RefreshSeries() |
463 { | 497 { |
464 if ($.mobile.pageData) { | 498 if ($.mobile.pageData) { |
465 GetResource('/series/' + $.mobile.pageData.uuid, function(series) { | 499 var pageData = DeepCopy($.mobile.pageData); |
500 | |
501 GetResource('/series/' + pageData.uuid, function(series) { | |
466 GetResource('/studies/' + series.ParentStudy, function(study) { | 502 GetResource('/studies/' + series.ParentStudy, function(study) { |
467 GetResource('/patients/' + study.ParentPatient, function(patient) { | 503 GetResource('/patients/' + study.ParentPatient, function(patient) { |
468 GetResource('/series/' + $.mobile.pageData.uuid + '/instances', function(instances) { | 504 GetResource('/series/' + pageData.uuid + '/instances', function(instances) { |
469 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); | 505 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); |
470 | 506 |
471 $('#series .patient-link').attr('href', '#patient?uuid=' + patient.ID); | 507 $('#series .patient-link').attr('href', '#patient?uuid=' + patient.ID); |
472 $('#series .study-link').attr('href', '#study?uuid=' + study.ID); | 508 $('#series .study-link').attr('href', '#study?uuid=' + study.ID); |
473 | 509 |
490 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); | 526 target.append(FormatInstance(instances[i], '#instance?uuid=' + instances[i].ID)); |
491 } | 527 } |
492 target.listview('refresh'); | 528 target.listview('refresh'); |
493 | 529 |
494 currentPage = 'series'; | 530 currentPage = 'series'; |
495 currentUuid = $.mobile.pageData.uuid; | 531 currentUuid = pageData.uuid; |
496 }); | 532 }); |
497 }); | 533 }); |
498 }); | 534 }); |
499 }); | 535 }); |
500 } | 536 } |
554 | 590 |
555 | 591 |
556 function RefreshInstance() | 592 function RefreshInstance() |
557 { | 593 { |
558 if ($.mobile.pageData) { | 594 if ($.mobile.pageData) { |
559 GetResource('/instances/' + $.mobile.pageData.uuid, function(instance) { | 595 var pageData = DeepCopy($.mobile.pageData); |
596 | |
597 GetResource('/instances/' + pageData.uuid, function(instance) { | |
560 GetResource('/series/' + instance.ParentSeries, function(series) { | 598 GetResource('/series/' + instance.ParentSeries, function(series) { |
561 GetResource('/studies/' + series.ParentStudy, function(study) { | 599 GetResource('/studies/' + series.ParentStudy, function(study) { |
562 GetResource('/patients/' + study.ParentPatient, function(patient) { | 600 GetResource('/patients/' + study.ParentPatient, function(patient) { |
563 | 601 |
564 $('#instance .patient-link').attr('href', '#patient?uuid=' + patient.ID); | 602 $('#instance .patient-link').attr('href', '#patient?uuid=' + patient.ID); |
583 | 621 |
584 SetupAnonymizedOrModifiedFrom('#instance-anonymized-from', instance, 'instance', 'AnonymizedFrom'); | 622 SetupAnonymizedOrModifiedFrom('#instance-anonymized-from', instance, 'instance', 'AnonymizedFrom'); |
585 SetupAnonymizedOrModifiedFrom('#instance-modified-from', instance, 'instance', 'ModifiedFrom'); | 623 SetupAnonymizedOrModifiedFrom('#instance-modified-from', instance, 'instance', 'ModifiedFrom'); |
586 | 624 |
587 currentPage = 'instance'; | 625 currentPage = 'instance'; |
588 currentUuid = $.mobile.pageData.uuid; | 626 currentUuid = pageData.uuid; |
589 }); | 627 }); |
590 }); | 628 }); |
591 }); | 629 }); |
592 }); | 630 }); |
593 } | 631 } |
702 | 740 |
703 | 741 |
704 | 742 |
705 $('#instance-preview').live('click', function(e) { | 743 $('#instance-preview').live('click', function(e) { |
706 if ($.mobile.pageData) { | 744 if ($.mobile.pageData) { |
707 var pdf = '../instances/' + $.mobile.pageData.uuid + '/pdf'; | 745 var pageData = DeepCopy($.mobile.pageData); |
746 | |
747 var pdf = '../instances/' + pageData.uuid + '/pdf'; | |
708 $.ajax({ | 748 $.ajax({ |
709 url: pdf, | 749 url: pdf, |
710 cache: false, | 750 cache: false, |
711 success: function(s) { | 751 success: function(s) { |
712 window.location.assign(pdf); | 752 window.location.assign(pdf); |
713 }, | 753 }, |
714 error: function() { | 754 error: function() { |
715 GetResource('/instances/' + $.mobile.pageData.uuid + '/frames', function(frames) { | 755 GetResource('/instances/' + pageData.uuid + '/frames', function(frames) { |
716 if (frames.length == 1) | 756 if (frames.length == 1) |
717 { | 757 { |
718 // Viewing a single-frame image | 758 // Viewing a single-frame image |
719 jQuery.slimbox('../instances/' + $.mobile.pageData.uuid + '/preview', '', { | 759 jQuery.slimbox('../instances/' + pageData.uuid + '/preview', '', { |
720 overlayFadeDuration : 1, | 760 overlayFadeDuration : 1, |
721 resizeDuration : 1, | 761 resizeDuration : 1, |
722 imageFadeDuration : 1 | 762 imageFadeDuration : 1 |
723 }); | 763 }); |
724 } | 764 } |
726 { | 766 { |
727 // Viewing a multi-frame image | 767 // Viewing a multi-frame image |
728 | 768 |
729 var images = []; | 769 var images = []; |
730 for (var i = 0; i < frames.length; i++) { | 770 for (var i = 0; i < frames.length; i++) { |
731 images.push([ '../instances/' + $.mobile.pageData.uuid + '/frames/' + i + '/preview' ]); | 771 images.push([ '../instances/' + pageData.uuid + '/frames/' + i + '/preview' ]); |
732 } | 772 } |
733 | 773 |
734 jQuery.slimbox(images, 0, { | 774 jQuery.slimbox(images, 0, { |
735 overlayFadeDuration : 1, | 775 overlayFadeDuration : 1, |
736 resizeDuration : 1, | 776 resizeDuration : 1, |
746 | 786 |
747 | 787 |
748 | 788 |
749 $('#series-preview').live('click', function(e) { | 789 $('#series-preview').live('click', function(e) { |
750 if ($.mobile.pageData) { | 790 if ($.mobile.pageData) { |
751 GetResource('/series/' + $.mobile.pageData.uuid, function(series) { | 791 var pageData = DeepCopy($.mobile.pageData); |
752 GetResource('/series/' + $.mobile.pageData.uuid + '/instances', function(instances) { | 792 |
793 GetResource('/series/' + pageData.uuid, function(series) { | |
794 GetResource('/series/' + pageData.uuid + '/instances', function(instances) { | |
753 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); | 795 Sort(instances, function(x) { return x.IndexInSeries; }, true, false); |
754 | 796 |
755 var images = []; | 797 var images = []; |
756 for (var i = 0; i < instances.length; i++) { | 798 for (var i = 0; i < instances.length; i++) { |
757 images.push([ '../instances/' + instances[i].ID + '/preview', | 799 images.push([ '../instances/' + instances[i].ID + '/preview', |
856 } | 898 } |
857 | 899 |
858 | 900 |
859 $('#instance-store,#series-store,#study-store,#patient-store').live('click', function(e) { | 901 $('#instance-store,#series-store,#study-store,#patient-store').live('click', function(e) { |
860 ChooseDicomModality(function(modality, peer) { | 902 ChooseDicomModality(function(modality, peer) { |
903 var pageData = DeepCopy($.mobile.pageData); | |
904 | |
861 var url; | 905 var url; |
862 var loading; | 906 var loading; |
863 | 907 |
864 if (modality != '') | 908 if (modality != '') |
865 { | 909 { |
876 if (url != '') { | 920 if (url != '') { |
877 $.ajax({ | 921 $.ajax({ |
878 url: url, | 922 url: url, |
879 type: 'POST', | 923 type: 'POST', |
880 dataType: 'text', | 924 dataType: 'text', |
881 data: $.mobile.pageData.uuid, | 925 data: pageData.uuid, |
882 async: true, // Necessary to block UI | 926 async: true, // Necessary to block UI |
883 beforeSend: function() { | 927 beforeSend: function() { |
884 $.blockUI({ message: $(loading) }); | 928 $.blockUI({ message: $(loading) }); |
885 }, | 929 }, |
886 complete: function(s) { | 930 complete: function(s) { |