diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 7a4adc403..97a65fa98 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -34,6 +34,7 @@ import ( "code.google.com/p/go.crypto/bcrypt" "github.com/syncthing/syncthing/internal/auto" "github.com/syncthing/syncthing/internal/config" + "github.com/syncthing/syncthing/internal/discover" "github.com/syncthing/syncthing/internal/events" "github.com/syncthing/syncthing/internal/logger" "github.com/syncthing/syncthing/internal/model" @@ -451,7 +452,17 @@ func restPostDiscoveryHint(w http.ResponseWriter, r *http.Request) { } func restGetDiscovery(w http.ResponseWriter, r *http.Request) { - json.NewEncoder(w).Encode(discoverer.All()) + w.Header().Set("Content-Type", "application/json; charset=utf-8") + registry := discoverer.All() + + // Device ids can't be marshalled as keys so we need to manually + // rebuild this map using strings. + devices := make(map[string][]discover.CacheEntry, len(registry)) + for device, _ := range registry { + devices[device.String()] = registry[device] + } + + json.NewEncoder(w).Encode(devices) } func restGetReport(m *model.Model, w http.ResponseWriter, r *http.Request) { diff --git a/gui/app.js b/gui/app.js index 333a5342c..6932edc7d 100644 --- a/gui/app.js +++ b/gui/app.js @@ -666,15 +666,21 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http, $translate, $loca }; $scope.addDevice = function () { - $scope.currentDevice = { - AddressesStr: 'dynamic', - Compression: true, - Introducer: false - }; - $scope.editingExisting = false; - $scope.editingSelf = false; - $scope.deviceEditor.$setPristine(); - $('#editDevice').modal(); + $http.get(urlbase + '/discovery') + .success(function (registry) { + $scope.discovery = registry; + }) + .then(function () { + $scope.currentDevice = { + AddressesStr: 'dynamic', + Compression: true, + Introducer: false + }; + $scope.editingExisting = false; + $scope.editingSelf = false; + $scope.deviceEditor.$setPristine(); + $('#editDevice').modal(); + }); }; $scope.deleteDevice = function () { diff --git a/gui/index.html b/gui/index.html index cb24de487..30b57b3e2 100644 --- a/gui/index.html +++ b/gui/index.html @@ -383,7 +383,10 @@