0
|
1 function TransferAcceleratorSelectPeer(callback)
|
|
2 {
|
|
3 var items = $('<ul>')
|
|
4 .attr('data-divider-theme', 'd')
|
|
5 .attr('data-role', 'listview');
|
|
6
|
|
7 items.append('<li data-role="list-divider">Orthanc peers</li>');
|
|
8
|
|
9 $.ajax({
|
|
10 url: '../transfers/peers',
|
|
11 type: 'GET',
|
|
12 dataType: 'json',
|
|
13 async: false,
|
|
14 cache: false,
|
|
15 success: function(peers) {
|
|
16 for (var i = 0; i < peers.length; i++) {
|
|
17 var name = peers[i];
|
|
18 var item = $('<li>')
|
|
19 .html('<a href="#" rel="close">' + name + '</a>')
|
|
20 .attr('name', name)
|
|
21 .click(function() {
|
|
22 clickedPeer = $(this).attr('name');
|
|
23 });
|
|
24 items.append(item);
|
|
25 }
|
|
26
|
|
27 // Launch the dialog
|
|
28 $('#dialog').simpledialog2({
|
|
29 mode: 'blank',
|
|
30 animate: false,
|
|
31 headerText: 'Choose target',
|
|
32 headerClose: true,
|
|
33 forceInput: false,
|
|
34 width: '100%',
|
|
35 blankContent: items,
|
|
36 callbackClose: function() {
|
|
37 var timer;
|
|
38 function WaitForDialogToClose() {
|
|
39 if (!$('#dialog').is(':visible')) {
|
|
40 clearInterval(timer);
|
|
41 callback(clickedPeer);
|
|
42 }
|
|
43 }
|
|
44 timer = setInterval(WaitForDialogToClose, 100);
|
|
45 }
|
|
46 });
|
|
47 }
|
|
48 });
|
|
49 }
|
|
50
|
|
51
|
|
52 function TransferAcceleratorAddSendButton(level, siblingButton)
|
|
53 {
|
|
54 var b = $('<a>')
|
|
55 .attr('data-role', 'button')
|
|
56 .attr('href', '#')
|
|
57 .attr('data-icon', 'search')
|
|
58 .attr('data-theme', 'e')
|
|
59 .text('Transfer accelerator');
|
|
60
|
|
61 b.insertBefore($(siblingButton).parent().parent());
|
|
62
|
|
63 b.click(function() {
|
|
64 if ($.mobile.pageData) {
|
|
65 var uuid = $.mobile.pageData.uuid;
|
|
66 TransferAcceleratorSelectPeer(function(peer) {
|
|
67 console.log('Sending ' + level + ' ' + uuid + ' to peer ' + peer);
|
|
68
|
|
69 var query = {
|
|
70 'Resources' : [
|
|
71 {
|
|
72 'Level' : level,
|
|
73 'ID' : uuid
|
|
74 }
|
|
75 ],
|
|
76 'Compression' : 'gzip',
|
|
77 'Peer' : peer
|
|
78 };
|
|
79
|
|
80 $.ajax({
|
|
81 url: '../transfers/send',
|
|
82 type: 'POST',
|
|
83 dataType: 'json',
|
|
84 data: JSON.stringify(query),
|
|
85 success: function(job) {
|
|
86 if (!(typeof job.ID === 'undefined')) {
|
|
87 $.mobile.changePage('#job?uuid=' + job.ID);
|
|
88 }
|
|
89 },
|
|
90 error: function() {
|
|
91 alert('Error while creating the transfer job');
|
|
92 }
|
|
93 });
|
|
94 });
|
|
95 }
|
|
96 });
|
|
97 }
|
|
98
|
|
99
|
|
100
|
|
101 $('#patient').live('pagebeforecreate', function() {
|
|
102 TransferAcceleratorAddSendButton('Patient', '#patient-delete');
|
|
103 });
|
|
104
|
|
105 $('#study').live('pagebeforecreate', function() {
|
|
106 TransferAcceleratorAddSendButton('Study', '#study-delete');
|
|
107 });
|
|
108
|
|
109 $('#series').live('pagebeforecreate', function() {
|
|
110 TransferAcceleratorAddSendButton('Series', '#series-delete');
|
|
111 });
|