From 98cfc204ca366e455b0996096b9f440b5257c089 Mon Sep 17 00:00:00 2001
From: Simon Frei
Date: Fri, 16 Jun 2017 15:27:09 +0000
Subject: [PATCH] gui: Add dropdown menu to choose discovered devices to device
modal (fixes #4157)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4186
LGTM: AudriusButkevicius, calmh
---
gui/default/assets/lang/lang-en.json | 1 +
gui/default/syncthing/core/syncthingController.js | 10 +++++++++-
gui/default/syncthing/device/editDeviceModalView.html | 8 +++++++-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/gui/default/assets/lang/lang-en.json b/gui/default/assets/lang/lang-en.json
index c4bae57c..e38a6272 100644
--- a/gui/default/assets/lang/lang-en.json
+++ b/gui/default/assets/lang/lang-en.json
@@ -273,6 +273,7 @@
"When adding a new device, keep in mind that this device must be added on the other side too.": "When adding a new device, keep in mind that this device must be added on the other side too.",
"When adding a new folder, keep in mind that the Folder ID is used to tie folders together between devices. They are case sensitive and must match exactly between all devices.": "When adding a new folder, keep in mind that the Folder ID is used to tie folders together between devices. They are case sensitive and must match exactly between all devices.",
"Yes": "Yes",
+ "You can also select one of these nearby devices:": "You can also select one of these nearby devices:",
"You can change your choice at any time in the Settings dialog.": "You can change your choice at any time in the Settings dialog.",
"You can read more about the two release channels at the link below.": "You can read more about the two release channels at the link below.",
"You must keep at least one version.": "You must keep at least one version.",
diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js
index 57acb8c3..d57989c5 100755
--- a/gui/default/syncthing/core/syncthingController.js
+++ b/gui/default/syncthing/core/syncthingController.js
@@ -1185,7 +1185,15 @@ angular.module('syncthing.core')
$scope.addDevice = function (deviceID, name) {
return $http.get(urlbase + '/system/discovery')
.success(function (registry) {
- $scope.discovery = registry;
+ $scope.discovery = [];
+ for (var id in registry) {
+ if ($scope.discovery.length === 5) {
+ break;
+ }
+ if (!(id in $scope.devices)) {
+ $scope.discovery.push(id);
+ }
+ }
})
.then(function () {
$scope.currentDevice = {
diff --git a/gui/default/syncthing/device/editDeviceModalView.html b/gui/default/syncthing/device/editDeviceModalView.html
index b2c9f006..1f4c068c 100644
--- a/gui/default/syncthing/device/editDeviceModalView.html
+++ b/gui/default/syncthing/device/editDeviceModalView.html
@@ -5,9 +5,15 @@
{{currentDevice.deviceID}}
+
+ You can also select one of these nearby devices:
+
The device ID to enter here can be found in the "Actions > Show ID" dialog on the other device. Spaces and dashes are optional (ignored).When adding a new device, keep in mind that this device must be added on the other side too.