Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit e1d3bb2

Browse files
committed
Bring duplicate stream async validation back
1 parent 49aa5e9 commit e1d3bb2

File tree

1 file changed

+14
-21
lines changed

1 file changed

+14
-21
lines changed

ui/app/scripts/stream/directives.js

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ define(function(require) {
2525
var angular = require('angular');
2626

2727
return angular.module('dataflowStreams.directives', ['dataflowShared.services', 'dataflowStreams.services'])
28-
//.directive('uniqueStreamName', ['DataflowUtils', 'StreamService', function (utils, streamService) {
29-
.directive('uniqueStreamName', ['DataflowUtils', function (utils) {
28+
.directive('uniqueStreamName', ['DataflowUtils', 'StreamService', function (utils, streamService) {
3029
return {
3130
require: 'ngModel',
3231
link: function(scope, elm, attrs, ctrl) {
@@ -37,26 +36,20 @@ define(function(require) {
3736
return utils.$q.when();
3837
}
3938

40-
// For now consider everything valid (it will fail when the create operation
41-
// is actually driven if there is a real problem). Once there is a quiet
42-
// backend operation to check for stream existence, reactivate the code
43-
// below.
44-
return utils.$q.when();
45-
4639
// This variant calls the API that currently logs an exception on the server.
47-
// var def = utils.$q.defer();
48-
// streamService.getSingleStreamDefinition(modelValue).then(function() {
49-
// // Success! Found stream with such name
50-
// def.reject('Stream with such name exists');
51-
// }, function(error) {
52-
// if (error.status === 404) {
53-
// def.resolve();
54-
// } else {
55-
// def.reject(error.statusText);
56-
// }
57-
// });
58-
//
59-
// return def.promise;
40+
var def = utils.$q.defer();
41+
streamService.getSingleStreamDefinition(modelValue).then(function() {
42+
// Success! Found stream with such name
43+
def.reject('Stream with such name exists');
44+
}, function(error) {
45+
if (error.status === 404) {
46+
def.resolve();
47+
} else {
48+
def.reject(error.statusText);
49+
}
50+
});
51+
52+
return def.promise;
6053
};
6154
}
6255
};

0 commit comments

Comments
 (0)