comparison Resources/OrthancExplorer.js @ 4:1ed03945c057

showing unavailable peers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 17 Sep 2018 14:42:57 +0200
parents 95226b754d9e
children 6f504d862494
comparison
equal deleted inserted replaced
3:9bcd6eadcff5 4:1ed03945c057
1 function TransferAcceleratorSelectPeer(callback) 1 function TransferAcceleratorSelectPeer(callback)
2 { 2 {
3 var items = $('<ul>') 3 var items = $('<ul>')
4 .attr('data-divider-theme', 'd') 4 .attr('data-divider-theme', 'd')
5 .attr('data-role', 'listview'); 5 .attr('data-role', 'listview');
6
7 items.append('<li data-role="list-divider">Orthanc peers</li>');
8 6
9 $.ajax({ 7 $.ajax({
10 url: '../transfers/peers', 8 url: '../transfers/peers',
11 type: 'GET', 9 type: 'GET',
12 dataType: 'json', 10 dataType: 'json',
13 async: false, 11 async: false,
14 cache: false, 12 cache: false,
15 success: function(peers) { 13 success: function(peers) {
16 for (var i = 0; i < peers.length; i++) { 14 console.log(peers);
17 var name = peers[i]; 15 var clickedPeer = null;
18 var item = $('<li>') 16
19 .html('<a href="#" rel="close">' + name + '</a>') 17 for (var name in peers) {
20 .attr('name', name) 18 if (peers.hasOwnProperty(name)) {
21 .click(function() { 19 var item = $('<li>')
22 clickedPeer = $(this).attr('name'); 20 .html('<a href="#" rel="close">' + name + '</a>')
23 }); 21 .attr('name', name)
24 items.append(item); 22 .click(function() {
23 clickedPeer = $(this).attr('name');
24 });
25
26 if (peers[name] != 'installed' &&
27 peers[name] != 'bidirectional') {
28 item.addClass('ui-disabled');
29 }
30
31 items.append(item);
32 }
25 } 33 }
26 34
27 // Launch the dialog 35 // Launch the dialog
28 $('#dialog').simpledialog2({ 36 $('#dialog').simpledialog2({
29 mode: 'blank', 37 mode: 'blank',
30 animate: false, 38 animate: false,
31 headerText: 'Choose target', 39 headerText: 'Choose Orthanc peer',
32 headerClose: true, 40 headerClose: true,
33 forceInput: false, 41 forceInput: false,
34 width: '100%', 42 width: '100%',
35 blankContent: items, 43 blankContent: items,
36 callbackClose: function() { 44 callbackClose: function() {
37 var timer; 45 var timer;
38 function WaitForDialogToClose() { 46 function WaitForDialogToClose() {
39 if (!$('#dialog').is(':visible')) { 47 if (!$('#dialog').is(':visible')) {
40 clearInterval(timer); 48 clearInterval(timer);
41 callback(clickedPeer); 49 if (clickedPeer !== null) {
50 callback(clickedPeer);
51 }
42 } 52 }
43 } 53 }
44 timer = setInterval(WaitForDialogToClose, 100); 54 timer = setInterval(WaitForDialogToClose, 100);
45 } 55 }
46 }); 56 });