Mercurial > hg > orthanc-transfers
annotate Resources/OrthancExplorer.js @ 73:0a18367a3358 OrthancTransfers-1.5
1.5
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 26 Mar 2024 11:06:52 +0100 |
parents | 6f504d862494 |
children |
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 | 2 { |
3 var items = $('<ul>') | |
4 .attr('data-divider-theme', 'd') | |
5 .attr('data-role', 'listview'); | |
6 | |
7 $.ajax({ | |
8 url: '../transfers/peers', | |
9 type: 'GET', | |
10 dataType: 'json', | |
11 async: false, | |
12 cache: false, | |
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 | 33 } |
34 | |
35 // Launch the dialog | |
36 $('#dialog').simpledialog2({ | |
37 mode: 'blank', | |
38 animate: false, | |
4
1ed03945c057
showing unavailable peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
39 headerText: 'Choose Orthanc peer', |
0 | 40 headerClose: true, |
41 forceInput: false, | |
42 width: '100%', | |
43 blankContent: items, | |
44 callbackClose: function() { | |
45 var timer; | |
46 function WaitForDialogToClose() { | |
47 if (!$('#dialog').is(':visible')) { | |
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 | 52 } |
53 } | |
54 timer = setInterval(WaitForDialogToClose, 100); | |
55 } | |
56 }); | |
57 } | |
58 }); | |
59 } | |
60 | |
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 | 63 { |
64 var b = $('<a>') | |
65 .attr('data-role', 'button') | |
66 .attr('href', '#') | |
67 .attr('data-icon', 'search') | |
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 | 70 |
71 b.insertBefore($(siblingButton).parent().parent()); | |
72 | |
73 b.click(function() { | |
74 if ($.mobile.pageData) { | |
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 | 77 console.log('Sending ' + level + ' ' + uuid + ' to peer ' + peer); |
78 | |
79 var query = { | |
80 'Resources' : [ | |
81 { | |
82 'Level' : level, | |
83 'ID' : uuid | |
84 } | |
85 ], | |
86 'Compression' : 'gzip', | |
87 'Peer' : peer | |
88 }; | |
89 | |
90 $.ajax({ | |
91 url: '../transfers/send', | |
92 type: 'POST', | |
93 dataType: 'json', | |
94 data: JSON.stringify(query), | |
95 success: function(job) { | |
96 if (!(typeof job.ID === 'undefined')) { | |
97 $.mobile.changePage('#job?uuid=' + job.ID); | |
98 } | |
99 }, | |
100 error: function() { | |
101 alert('Error while creating the transfer job'); | |
102 } | |
103 }); | |
104 }); | |
105 } | |
106 }); | |
107 } | |
108 | |
109 | |
110 | |
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 | 113 }); |
114 | |
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 | 117 }); |
118 | |
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 | 121 }); |