diff --git a/dashboard-ui/thirdparty/apiclient/connectionmanager.js b/dashboard-ui/thirdparty/apiclient/connectionmanager.js index 42b7becc26..498dcf3c33 100644 --- a/dashboard-ui/thirdparty/apiclient/connectionmanager.js +++ b/dashboard-ui/thirdparty/apiclient/connectionmanager.js @@ -592,14 +592,15 @@ function findServers() { var deferred = DeferredBuilder.Deferred(); - ServerDiscovery.findServers().done(function (foundServers) { + ServerDiscovery.findServers(2000).done(function (foundServers) { var servers = foundServers.map(function (foundServer) { return { Id: foundServer.Id, LocalAddress: foundServer.Address, - Name: foundServer.Name + Name: foundServer.Name, + ManualAddress: convertEndpointAddressToManualAddress(foundServer) }; }); deferred.resolveWith(null, [servers]); @@ -607,6 +608,27 @@ return deferred.promise(); } + function convertEndpointAddressToManualAddress(info) { + + if (info.Address && info.EndpointAddress) { + var address = info.EndpointAddress.split(":")[0]; + + // Determine the port, if any + var parts = info.Address.split(":"); + if (parts.length > 1) { + var portString = parts[parts.length - 1]; + + if (!isNaN(parseInt(portString))) { + address += ":" + portString; + } + } + + return normalizeAddress(address); + } + + return null; + } + self.connect = function () { logger.log('Begin connect'); @@ -876,12 +898,19 @@ } }; - self.connectToAddress = function (address) { + function normalizeAddress(address) { if (address.toLowerCase().indexOf('http') != 0) { address = "http://" + address; } + return address; + } + + self.connectToAddress = function (address) { + + address = normalizeAddress(address); + var deferred = DeferredBuilder.Deferred(); tryConnect(address, 15000).done(function (publicInfo) { diff --git a/dashboard-ui/thirdparty/apiclient/serverdiscovery.js b/dashboard-ui/thirdparty/apiclient/serverdiscovery.js index a06ea77034..9fcd5d4ef3 100644 --- a/dashboard-ui/thirdparty/apiclient/serverdiscovery.js +++ b/dashboard-ui/thirdparty/apiclient/serverdiscovery.js @@ -2,9 +2,14 @@ globalScope.ServerDiscovery = { - findServers: function () { + findServers: function (timeoutMs) { + var deferred = DeferredBuilder.Deferred(); var servers = []; + + // Expected server properties + // Name, Id, Address, EndpointAddress (optional) + deferred.resolveWith(null, [servers]); return deferred.promise(); }