The very deep tree structure didn't really aggree with me, sorry. This makes the core module rather large, but on the other hand that just highlights that it is rather large.
24 lines
944 B
JavaScript
24 lines
944 B
JavaScript
angular.module('syncthing.core')
|
|
.directive('validDeviceid', function ($http) {
|
|
return {
|
|
require: 'ngModel',
|
|
link: function (scope, elm, attrs, ctrl) {
|
|
ctrl.$parsers.unshift(function (viewValue) {
|
|
if (scope.editingExisting) {
|
|
// we shouldn't validate
|
|
ctrl.$setValidity('validDeviceid', true);
|
|
} else {
|
|
$http.get(urlbase + '/svc/deviceid?id=' + viewValue).success(function (resp) {
|
|
if (resp.error) {
|
|
ctrl.$setValidity('validDeviceid', false);
|
|
} else {
|
|
ctrl.$setValidity('validDeviceid', true);
|
|
}
|
|
});
|
|
}
|
|
return viewValue;
|
|
});
|
|
}
|
|
};
|
|
});
|