Disallow adding duplicate device ID in GUI
Adds check in valid device id to check for uniqueness
This commit is contained in:
parent
7b3fa8da60
commit
4a6f1718b8
|
@ -15,6 +15,15 @@ angular.module('syncthing.core')
|
||||||
ctrl.$setValidity('validDeviceid', true);
|
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;
|
return viewValue;
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
<span translate ng-show="!editingExisting && (deviceEditor.deviceID.$valid || deviceEditor.deviceID.$pristine)">When adding a new device, keep in mind that this device must be added on the other side too.</span>
|
<span translate ng-show="!editingExisting && (deviceEditor.deviceID.$valid || deviceEditor.deviceID.$pristine)">When adding a new device, keep in mind that this device must be added on the other side too.</span>
|
||||||
<span translate ng-if="deviceEditor.deviceID.$error.required && deviceEditor.deviceID.$dirty">The device ID cannot be blank.</span>
|
<span translate ng-if="deviceEditor.deviceID.$error.required && deviceEditor.deviceID.$dirty">The device ID cannot be blank.</span>
|
||||||
<span translate ng-if="deviceEditor.deviceID.$error.validDeviceid && deviceEditor.deviceID.$dirty">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.</span>
|
<span translate ng-if="deviceEditor.deviceID.$error.validDeviceid && deviceEditor.deviceID.$dirty">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.</span>
|
||||||
|
<span translate ng-if="deviceEditor.deviceID.$error.unique && deviceEditor.deviceID.$dirty">A device with that ID is already added.</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
Loading…
Reference in New Issue