Skip to content

Commit 4d7eef4

Browse files
authored
Merge pull request #26 from namoscato/master
Fix inconsistent connector creation behavior
2 parents 2f341ac + 98e51ac commit 4d7eef4

File tree

6 files changed

+45
-36
lines changed

6 files changed

+45
-36
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
},
1919
"scripts": {
2020
"test": "echo \"Error: no test specified\" && exit 1",
21-
"postinstall": "bower install"
21+
"postinstall": "bower install",
22+
"build": "grunt && cd dist && tar cvzf kafka-connect-ui.tar.gz ."
2223
},
2324
"repository": {
2425
"type": "git",

src/app.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,7 @@ angularAPP.config(function ($routeProvider) {
5252
templateUrl: 'src/kafka-connect/select-type/sink-or-source.html',
5353
controller: 'SelectNewConnectorCtrl'
5454
})
55-
.when('/cluster/:cluster/create-connector/:type/:name', {
56-
templateUrl: 'src/kafka-connect/create-connector/create-connector.html',
57-
controller: 'CreateConnectorCtrl'
58-
})
59-
.when('/cluster/:cluster/create-connector/:name', {
60-
templateUrl: 'src/kafka-connect/create-connector/create-connector.html',
61-
controller: 'CreateConnectorCtrl'
62-
})
63-
.when('/cluster/:cluster/create-connector/:type/:name/:tab', {
55+
.when('/cluster/:cluster/create-connector/:className', {
6456
templateUrl: 'src/kafka-connect/create-connector/create-connector.html',
6557
controller: 'CreateConnectorCtrl'
6658
})

src/factories/kafka-connect-api.factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ angularAPP.service('KafkaConnectFactory', function ($rootScope, $http, $location
101101
.error(function (responseError) {
102102
var msg = "Failed at method [" + method + "] with error: \n" + JSON.stringify(responseError);
103103
$log.error(msg);
104-
if (responseError.error_code == 404) {
104+
if (angular.isObject(responseError) && responseError.error_code == 404) {
105105
$rootScope.notExists = true;
106106
}
107107
deferred.reject(msg);

src/kafka-connect/create-connector/create-connector.controller.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@
33
Config is created on the fly using the `template` models.
44
*/
55
angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http, $log, $routeParams, $location, $filter, KafkaConnectFactory, supportedConnectorsFactory, NewConnectorFactory, env, constants) {
6-
$http.get(env.KAFKA_CONNECT() + '/connector-plugins').then(function(allPlugins){
7-
angular.forEach(allPlugins.data, function (plugin) {
8-
if (plugin.class.indexOf($routeParams.name) > 0) {
9-
getClassConfig(plugin.class)
10-
}
11-
});
12-
},
13-
function (reason) {
14-
$log.error('Failed: ' + reason);
15-
}, function (update) {
16-
$log.info('Got notification: ' + update);
17-
});
6+
KafkaConnectFactory.getConnectorPlugins().then(function(allPlugins) {
7+
var className;
8+
9+
for (var i in allPlugins) {
10+
className = allPlugins[i].class;
11+
12+
if (className === $routeParams.className) {
13+
getClassConfig(className)
14+
break;
15+
}
16+
}
17+
}, function (reason) {
18+
$log.error('Failed: ' + reason);
19+
}, function (update) {
20+
$log.info('Got notification: ' + update);
21+
});
1822

1923
$scope.prefillValues = true;
2024
$scope.showCurl = false;

src/kafka-connect/select-type/sink-or-source.controller.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
angularAPP.controller('SelectNewConnectorCtrl', function ($scope, $http, $log, $rootScope, KafkaConnectFactory, supportedConnectorsFactory, env ) {
1+
angularAPP.controller('SelectNewConnectorCtrl', function ($scope, $http, $log, $rootScope, KafkaConnectFactory, supportedConnectorsFactory, env) {
22
$log.info("SelectNewConnector controller");
33

4+
var classpathMap = {};
5+
46
$scope.cluster = env.getSelectedCluster().NAME;
57

68
var supportedConnectors = supportedConnectorsFactory.getSupportedConnectors();
@@ -9,14 +11,15 @@ angularAPP.controller('SelectNewConnectorCtrl', function ($scope, $http, $log, $
911
$scope.sinks = supportedConnectors.filter(supportedConnectorsFactory.matchesType('Sink'));
1012
}
1113

12-
$scope.classesInClasspath = [];
1314
$scope.unsupportedConnectors = [];
1415
$scope.hasUnsupportedConnectors = false;
1516

17+
$scope.isClassInClasspath = isClassInClasspath;
1618

17-
KafkaConnectFactory.getConnectorPlugins(true).then(function (allPlugins) {
19+
KafkaConnectFactory.getConnectorPlugins().then(function (allPlugins) {
1820
angular.forEach(allPlugins, function (plugin) {
19-
$scope.classesInClasspath.push(plugin.class);
21+
classpathMap[plugin.class] = true;
22+
2023
if (supportedConnectorsFactory.getAllClassFromTemplate().indexOf(plugin.class) == -1) {
2124
$scope.hasUnsupportedConnectors = true;
2225
var type="Unknown";
@@ -44,4 +47,13 @@ angularAPP.controller('SelectNewConnectorCtrl', function ($scope, $http, $log, $
4447
}, function (update) {
4548
$log.info('Got notification: ' + update);
4649
});
47-
});
50+
51+
/**
52+
* @description Determines if the specified class name is in the classpath
53+
* @param {String} className
54+
* @returns {Boolean}
55+
*/
56+
function isClassInClasspath(className) {
57+
return angular.isDefined(classpathMap[className]);
58+
}
59+
});

src/kafka-connect/select-type/sink-or-source.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ <h4>
2424

2525
<md-list class="dense" flex ng-if="sources.length > 0">
2626
<md-subheader class="md-no-sticky">Sources</md-subheader>
27-
<md-list-item ng-repeat='source in sources | filter : search2' class="md-2-line"
28-
ng-if="classesInClasspath.indexOf(source.class) !=-1"
29-
ng-href="{{ classesInClasspath.indexOf(source.class) !==-1 && '#/cluster/'+cluster+'/create-connector/source/' + source.name || '' }}"
30-
ng-class="classesInClasspath.indexOf(source.class) ==-1 && 'notavailable' || '' ">
27+
<md-list-item ng-repeat="source in sources | filter : search2"
28+
class="md-2-line"
29+
ng-if="isClassInClasspath(source.class)"
30+
ng-href="#/cluster/{{ cluster }}/create-connector/{{ source.class }}">
3131
<img ng-src="src/assets/icons/{{source.icon}}" class="md-avatar" style="width:40px;height:40px;" />
3232
<div class="md-list-item-text" >
3333
<h3><b>{{source.name}}</b></h3>
@@ -38,10 +38,10 @@ <h3><b>{{source.name}}</b></h3>
3838

3939
<md-list class="dense" flex ng-if="sinks.length > 0" >
4040
<md-subheader class="md-no-sticky">Sinks</md-subheader>
41-
<md-list-item ng-repeat='sink in sinks | filter : search2' class="md-2-line"
42-
ng-if="classesInClasspath.indexOf(sink.class) !=-1"
43-
ng-href="{{ classesInClasspath.indexOf(sink.class) !==-1 && '#/cluster/'+cluster+'/create-connector/sink/' + sink.name || '' }}"
44-
ng-class="classesInClasspath.indexOf(sink.class) ==-1 && 'notavailable' || '' ">
41+
<md-list-item ng-repeat="sink in sinks | filter : search2"
42+
class="md-2-line"
43+
ng-if="isClassInClasspath(sink.class)"
44+
ng-href="#/cluster/{{ cluster }}/create-connector/{{ sink.class }}">
4545
<img ng-src="src/assets/icons/{{sink.icon}}" class="md-avatar" style="width:40px;height:40px;" />
4646
<div class="md-list-item-text">
4747
<h3><b>{{sink.name}}</b></h3>

0 commit comments

Comments
 (0)