diff 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
line wrap: on
line diff
--- a/Resources/OrthancExplorer.js	Mon Sep 17 12:14:20 2018 +0200
+++ b/Resources/OrthancExplorer.js	Mon Sep 17 14:42:57 2018 +0200
@@ -4,8 +4,6 @@
     .attr('data-divider-theme', 'd')
     .attr('data-role', 'listview');
 
-  items.append('<li data-role="list-divider">Orthanc peers</li>');
-
   $.ajax({
     url: '../transfers/peers',
     type: 'GET',
@@ -13,22 +11,32 @@
     async: false,
     cache: false,
     success: function(peers) {
-      for (var i = 0; i < peers.length; i++) {
-        var name = peers[i];
-        var item = $('<li>')
-          .html('<a href="#" rel="close">' + name + '</a>')
-          .attr('name', name)
-          .click(function() { 
-            clickedPeer = $(this).attr('name');
-          });
-        items.append(item);
+      console.log(peers);
+      var clickedPeer = null;
+      
+      for (var name in peers) {
+        if (peers.hasOwnProperty(name)) {
+          var item = $('<li>')
+              .html('<a href="#" rel="close">' + name + '</a>')
+              .attr('name', name)
+              .click(function() { 
+                clickedPeer = $(this).attr('name');
+              });
+
+          if (peers[name] != 'installed' &&
+              peers[name] != 'bidirectional') {
+            item.addClass('ui-disabled');
+          }
+
+          items.append(item);          
+        }
       }
 
       // Launch the dialog
       $('#dialog').simpledialog2({
         mode: 'blank',
         animate: false,
-        headerText: 'Choose target',
+        headerText: 'Choose Orthanc peer',
         headerClose: true,
         forceInput: false,
         width: '100%',
@@ -38,7 +46,9 @@
           function WaitForDialogToClose() {
             if (!$('#dialog').is(':visible')) {
               clearInterval(timer);
-              callback(clickedPeer);
+              if (clickedPeer !== null) {
+                callback(clickedPeer);
+              }
             }
           }
           timer = setInterval(WaitForDialogToClose, 100);