From 456af8f373d9fbbda4c0b5e5b43c12900873dd42 Mon Sep 17 00:00:00 2001 From: "peng.jianhua" Date: Tue, 12 Dec 2017 10:09:44 +0800 Subject: [PATCH 1/1] KYLIN-3061 When we cancel the Topic modification for 'Kafka Setting' of streaming table, the 'Cancel' operation will make a mistake. --- webapp/app/js/controllers/streamingConfig.js | 35 +++++++++++++++++++--- .../app/partials/cubeDesigner/streamingConfig.html | 20 +++++++++---- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/webapp/app/js/controllers/streamingConfig.js b/webapp/app/js/controllers/streamingConfig.js index 32b09c6..3e0ed66 100644 --- a/webapp/app/js/controllers/streamingConfig.js +++ b/webapp/app/js/controllers/streamingConfig.js @@ -68,11 +68,17 @@ KylinApp.controller('streamingConfigCtrl', function ($scope,StreamingService, $q $scope.addBroker = function (cluster,broker) { //$scope.modelsManager.selectedModel = model; - cluster.newBroker=(!!broker)?broker:StreamingModel.createBrokerConfig(); + if(!!broker){ + cluster.newBroker = {}; + angular.copy(broker, cluster.newBroker); + cluster.edit_index = cluster.brokers.indexOf(broker); + }else{ + cluster.newBroker = StreamingModel.createBrokerConfig(); + } }; $scope.removeNewBroker = function (cluster){ - delete cluster.newBroker; + $scope.clearNewBroker(cluster); } $scope.removeElement = function (cluster, element) { @@ -80,16 +86,37 @@ KylinApp.controller('streamingConfigCtrl', function ($scope,StreamingService, $q if (index > -1) { cluster.brokers.splice(index, 1); } + $scope.clearNewBroker(cluster); }; $scope.saveNewBroker = function(cluster){ - if (cluster.brokers.indexOf(cluster.newBroker) === -1) { + if ($scope.isIDExistentInArray(cluster.brokers,cluster.newBroker)) { + if (cluster.edit_index > -1) { + cluster.brokers.splice(cluster.edit_index, 1, cluster.newBroker); + }else{ + SweetAlert.swal('', 'The new record ID already exists.', 'warning'); + return; + } + }else{ cluster.brokers.push(cluster.newBroker); } - delete cluster.newBroker; + $scope.clearNewBroker(cluster); } + $scope.isIDExistentInArray = function(arr,obj){ + if(!arr || arr.length === 0){ + return false; + } + for(var i=0; i - {{broker.id}} - {{broker.host}} - {{broker.port}} + {{broker.id}} + {{broker.host}} + +
+ +
+ + {{broker.port}} + +
+ +
+ - @@ -79,7 +89,7 @@ - +
-- 2.7.2.windows.1