Skip to content

Commit 8085ca3

Browse files
committed
Adding required config + green color back in
1 parent 70b9ad0 commit 8085ca3

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

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

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http
6767

6868
flatValuesArray = $scope.formValuesPerSection.split('\n');
6969
config = NewConnectorFactory.getJSONConfigFlat(flatValuesArray);
70-
//console.log(flatValuesArray);
71-
// var classname = $scope.connector.class;
70+
71+
// Make sure the 'classname' is a valid one - as it can crash the connect services
7272
var classname = flatValuesArray.find(function (p) {
73-
//console.log(p.indexOf("connector.class"));
7473
return (p.indexOf("connector.class=") == 0)
7574
}).split('connector.class=').join('');
76-
//console.log("classname is -> " + classname);
7775
if (classname != $scope.connector.class) {
7876
console.log("error in classname -> " + classname);
7977
var errors = { errors : [ 'Classname "' + $scope.connector.class + '" is not defined' ] };
@@ -97,13 +95,22 @@ angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http
9795
//STEP 2: Get errors if any
9896
$scope.validConfig = '';
9997
var validConnectorConfigKeys = [];
98+
var requiredConfigKeys = [];
10099
angular.forEach(data.configs, function (config) {
100+
//console.log("c-> " + config.value.name);
101+
//console.log(config);
101102
if (config.value.errors.length > 0) {
102103
errorConfigs.push(config.value);
103104
$log.info(config.value.name + ' : ' + config.value.errors[0]);
104105
}
106+
//console.log("config.value -> ");
107+
if (config.definition.required == true) {
108+
requiredConfigKeys.push(config.value.name);
109+
}
110+
//console.log("Required/compulsory config keys: " + requiredConfigKeys);
105111
validConnectorConfigKeys.push(config.value.name);
106112
});
113+
//console.log("validConnectorConfigKeys -> " + validConnectorConfigKeys);
107114
angular.forEach(flatValuesArray, function (propertyLine) {
108115
if (propertyLine.length > 0) {
109116
if ( (propertyLine.indexOf("=") == -1) | (propertyLine.length < 3) ) {
@@ -125,6 +132,20 @@ angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http
125132
}
126133
}
127134
});
135+
// Now check the other way around. Whether a required property is not set
136+
angular.forEach(requiredConfigKeys, function (requiredKey) {
137+
var x = flatValuesArray.find(function(p) {
138+
var result = (p.indexOf(requiredKey) == 0);
139+
console.log(result + " " + p);
140+
return result
141+
});
142+
//console.log("x " + requiredKey + " " + x)
143+
if (x == undefined) {
144+
var errors = { errors : [ 'Required config "' + requiredKey + '" is not there' ] };
145+
errorConfigs.push(errors);
146+
};
147+
});
148+
128149
if(errorConfigs == 0) {
129150
$scope.validConfig = constants.VIEW_MESSAGE_CONNECTOR_VALID;
130151
$scope.curlCommand = NewConnectorFactory.getCurlCommand(flatValuesArray);
@@ -143,13 +164,12 @@ angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http
143164
console.log(flatKeysUsed);
144165
console.log(errorConfigs);
145166
*/
146-
}, function (data, reason) {
167+
},
168+
function error(data, reason) {
147169
$log.error('Failure : ' + data);
148170
deferred.reject(data);
149-
150171
});
151172
return deferred.promise;
152-
153173
}
154174

155175
$scope.validateConnector = function () {

src/kafka-connect/create-connector/create-connector.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ <h3 style="font-size:12px;padding:0px; margin:0px">{{connector.name}}</h3>
4747
<!--Show Property file-->
4848
<div id="propertyFile" ng-hide="showCurl"
4949
ng-model="formValuesPerSection" ng-readonly="false"
50+
style="background-color:rgba(0, 128, 0, 0.0392157);"
5051
ui-ace="{
5152
useWrapMode: true,
5253
mode: 'properties',

0 commit comments

Comments
 (0)