Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix validation to parse partitions as ints first #2512

Merged
merged 4 commits into from
Jun 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions core/src/main/resources/static/js/envs.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,11 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) {

$scope.addNewEnv = function() {

var defRepFactor = parseInt($scope.addNewEnv.defrepfctr,10)
var maxRepFactor = parseInt($scope.addNewEnv.maxrepfctr,10)
var defPartitionFactor = parseInt($scope.addNewEnv.defparts,10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var defPartitionFactor = parseInt($scope.addNewEnv.defparts,10)
var defPartitions = parseInt($scope.addNewEnv.defparts,10)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well that was a silly mistake to make gimme two minutes and I'll fix it

var maxPartitionFactor = parseInt($scope.addNewEnv.defmaxparts,10)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var maxPartitionFactor = parseInt($scope.addNewEnv.defmaxparts,10)
var maxPartitions = parseInt($scope.addNewEnv.defmaxparts,10)


// Validation partitions
if($scope.addNewEnv.defparts.length<=0 || $scope.addNewEnv.defparts<=0)
{
Expand All @@ -713,7 +718,7 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) {
return;
}

if(isNaN($scope.addNewEnv.defparts)){
if(isNaN(defPartitionFactor)){
$scope.alertnote = "Default partitions should be a valid number";
$scope.showAlertToast();
return;
Expand All @@ -726,13 +731,13 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) {
return;
}

if(isNaN($scope.addNewEnv.defmaxparts)){
if(isNaN(maxPartitionFactor)){
$scope.alertnote = "Maximum partitions should be a valid number";
$scope.showAlertToast();
return;
}

if($scope.addNewEnv.defparts > $scope.addNewEnv.defmaxparts){
if(defPartitionFactor > maxPartitionFactor){
$scope.alertnote = "Default partitions should be less than Maximum partitions";
$scope.showAlertToast();
return;
Expand All @@ -747,26 +752,26 @@ app.controller("envsCtrl", function($scope, $http, $location, $window) {
return;
}

if(isNaN($scope.addNewEnv.defrepfctr)){
if(isNaN(defRepFactor)){
$scope.alertnote = "Default replication factor should be a valid number";
$scope.showAlertToast();
return;
}

if($scope.addNewEnv.maxrepfctr.length<=0 || $scope.addNewEnv.maxrepfctr<=0)
if(defRepFactor<=0 || maxRepFactor<=0)
{
$scope.alertnote = "Maximum Replication factor should not be empty and should be greater than 0";
$scope.showAlertToast();
return;
}

if(isNaN($scope.addNewEnv.maxrepfctr)){
if(isNaN(maxRepFactor)){
$scope.alertnote = "Maximum Replication factor should be a valid number";
$scope.showAlertToast();
return;
}

if($scope.addNewEnv.defrepfctr > $scope.addNewEnv.maxrepfctr){
if(defRepFactor > maxRepFactor){
$scope.alertnote = "Default Replication factor should be less than Maximum Replication factor";
$scope.showAlertToast();
return;
Expand Down