From 4a6f1718b859506511533e85044a99f87fc565ea Mon Sep 17 00:00:00 2001
From: Kevin Allen
Date: Tue, 29 Dec 2015 22:42:19 -0500
Subject: [PATCH] Disallow adding duplicate device ID in GUI
Adds check in valid device id to check for uniqueness
---
gui/syncthing/core/validDeviceidDirective.js | 9 +++++++++
gui/syncthing/device/editDeviceModalView.html | 1 +
2 files changed, 10 insertions(+)
diff --git a/gui/syncthing/core/validDeviceidDirective.js b/gui/syncthing/core/validDeviceidDirective.js
index d3e0d9868..4f600cadc 100644
--- a/gui/syncthing/core/validDeviceidDirective.js
+++ b/gui/syncthing/core/validDeviceidDirective.js
@@ -15,6 +15,15 @@ angular.module('syncthing.core')
ctrl.$setValidity('validDeviceid', true);
}
});
+ //Prevents user from adding a duplicate ID
+ var matches = scope.devices.filter(function (n) {
+ return n.deviceID == viewValue;
+ }).length;
+ if (matches > 0) {
+ ctrl.$setValidity('unique', false);
+ } else {
+ ctrl.$setValidity('unique', true);
+ }
}
return viewValue;
});
diff --git a/gui/syncthing/device/editDeviceModalView.html b/gui/syncthing/device/editDeviceModalView.html
index c368c36fa..36260ba23 100644
--- a/gui/syncthing/device/editDeviceModalView.html
+++ b/gui/syncthing/device/editDeviceModalView.html
@@ -21,6 +21,7 @@
When adding a new device, keep in mind that this device must be added on the other side too.
The device ID cannot be blank.
The entered device ID does not look valid. It should be a 52 or 56 character string consisting of letters and numbers, with spaces and dashes being optional.
+ A device with that ID is already added.