annotate Resources/OrthancExplorer.js @ 54:5915547fa6f2

upgraded SDK and framework to 1.11.3
author Alain Mazy <am@osimis.io>
date Fri, 03 Feb 2023 18:44:53 +0100
parents 6f504d862494
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
6f504d862494 documentation is in the Orthanc Book
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4
diff changeset
1 function TransfersAcceleratorSelectPeer(callback)
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 var items = $('<ul>')
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 .attr('data-divider-theme', 'd')
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 .attr('data-role', 'listview');
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 $.ajax({
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 url: '../transfers/peers',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 type: 'GET',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 dataType: 'json',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 async: false,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 cache: false,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 success: function(peers) {
4
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
14 console.log(peers);
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
15 var clickedPeer = null;
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
16
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
17 for (var name in peers) {
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
18 if (peers.hasOwnProperty(name)) {
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
19 var item = $('<li>')
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
20 .html('<a href="#" rel="close">' + name + '</a>')
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
21 .attr('name', name)
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
22 .click(function() {
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
23 clickedPeer = $(this).attr('name');
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
24 });
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
25
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
26 if (peers[name] != 'installed' &&
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
27 peers[name] != 'bidirectional') {
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
28 item.addClass('ui-disabled');
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
29 }
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
30
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
31 items.append(item);
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
32 }
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 // Launch the dialog
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 $('#dialog').simpledialog2({
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 mode: 'blank',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 animate: false,
4
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
39 headerText: 'Choose Orthanc peer',
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 headerClose: true,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 forceInput: false,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 width: '100%',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 blankContent: items,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 callbackClose: function() {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 var timer;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 function WaitForDialogToClose() {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 if (!$('#dialog').is(':visible')) {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 clearInterval(timer);
4
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
49 if (clickedPeer !== null) {
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
50 callback(clickedPeer);
1ed03945c057 showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 0
diff changeset
51 }
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 timer = setInterval(WaitForDialogToClose, 100);
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 });
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 });
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
6
6f504d862494 documentation is in the Orthanc Book
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4
diff changeset
62 function TransfersAcceleratorAddSendButton(level, siblingButton)
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 var b = $('<a>')
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 .attr('data-role', 'button')
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 .attr('href', '#')
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 .attr('data-icon', 'search')
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 .attr('data-theme', 'e')
6
6f504d862494 documentation is in the Orthanc Book
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4
diff changeset
69 .text('Transfers accelerator');
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 b.insertBefore($(siblingButton).parent().parent());
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 b.click(function() {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 if ($.mobile.pageData) {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 var uuid = $.mobile.pageData.uuid;
6
6f504d862494 documentation is in the Orthanc Book
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4
diff changeset
76 TransfersAcceleratorSelectPeer(function(peer) {
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 console.log('Sending ' + level + ' ' + uuid + ' to peer ' + peer);
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 var query = {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 'Resources' : [
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 'Level' : level,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 'ID' : uuid
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 ],
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 'Compression' : 'gzip',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 'Peer' : peer
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 };
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 $.ajax({
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 url: '../transfers/send',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 type: 'POST',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 dataType: 'json',
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 data: JSON.stringify(query),
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 success: function(job) {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 if (!(typeof job.ID === 'undefined')) {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 $.mobile.changePage('#job?uuid=' + job.ID);
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 },
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 error: function() {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 alert('Error while creating the transfer job');
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 });
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 });
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 });
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 $('#patient').live('pagebeforecreate', function() {
6
6f504d862494 documentation is in the Orthanc Book
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4
diff changeset
112 TransfersAcceleratorAddSendButton('Patient', '#patient-delete');
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 });
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 $('#study').live('pagebeforecreate', function() {
6
6f504d862494 documentation is in the Orthanc Book
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4
diff changeset
116 TransfersAcceleratorAddSendButton('Study', '#study-delete');
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 });
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 $('#series').live('pagebeforecreate', function() {
6
6f504d862494 documentation is in the Orthanc Book
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4
diff changeset
120 TransfersAcceleratorAddSendButton('Series', '#series-delete');
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 });