Explorar o código

Provide a data-list of locally discovered nodes when adding a new node.

Phill Luby %!s(int64=11) %!d(string=hai) anos
pai
achega
36431b3dcd
Modificáronse 2 ficheiros con 19 adicións e 10 borrados
  1. 15 9
      gui/app.js
  2. 4 1
      gui/index.html

+ 15 - 9
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 () {

+ 4 - 1
gui/index.html

@@ -383,7 +383,10 @@
           <form role="form" name="deviceEditor">
             <div class="form-group" ng-class="{'has-error': deviceEditor.deviceID.$invalid && deviceEditor.deviceID.$dirty}">
               <label translate for="deviceID">Device ID</label>
-              <input ng-if="!editingExisting" name="deviceID" id="deviceID" class="form-control text-monospace" type="text" ng-model="currentDevice.DeviceID" required valid-deviceid></input>
+              <input ng-if="!editingExisting" name="deviceID" id="deviceID" class="form-control text-monospace" type="text" ng-model="currentDevice.DeviceID" required valid-deviceid list="discovery-list" />
+              <datalist id="discovery-list" ng-if="!editingExisting">
+                <option ng-repeat="(id,address) in discovery" value="{{ id }}" />
+              </datalist>
               <div ng-if="editingExisting" class="well well-sm text-monospace">{{currentDevice.DeviceID}}</div>
               <p class="help-block">
                 <span translate ng-if="deviceEditor.deviceID.$valid || deviceEditor.deviceID.$pristine">The device ID to enter here can be found in the "Edit > Show ID" dialog on the other device. Spaces and dashes are optional (ignored).</span>