Repository: kylin
Updated Branches:
  refs/heads/master 0af27cdf9 -> 39949c38d


KYLIN-3061 When we cancel the Topic modification for 'Kafka Setting' of 
streaming table, the 'Cancel' operation will make a mistake.


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/39949c38
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/39949c38
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/39949c38

Branch: refs/heads/master
Commit: 39949c38dc675fdad65b45c8a709ed879f29f949
Parents: 0af27cd
Author: peng.jianhua <peng.jian...@zte.com.cn>
Authored: Tue Dec 12 10:09:44 2017 +0800
Committer: chenzhx <c...@apache.org>
Committed: Sun Dec 17 19:39:50 2017 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/streamingConfig.js    | 35 +++++++++++++++++---
 .../partials/cubeDesigner/streamingConfig.html  | 20 ++++++++---
 2 files changed, 46 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/39949c38/webapp/app/js/controllers/streamingConfig.js
----------------------------------------------------------------------
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<arr.length; i++) {
+        if(arr[i].id == obj.id){
+            return true;
+        }
+      }
+      return false;
+    }
+
   $scope.clearNewBroker = function(cluster){
+       delete cluster.edit_index;
     delete cluster.newBroker;
   }
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/39949c38/webapp/app/partials/cubeDesigner/streamingConfig.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubeDesigner/streamingConfig.html 
b/webapp/app/partials/cubeDesigner/streamingConfig.html
index 24b3438..3b7801e 100644
--- a/webapp/app/partials/cubeDesigner/streamingConfig.html
+++ b/webapp/app/partials/cubeDesigner/streamingConfig.html
@@ -66,12 +66,22 @@
             </thead>
             <tbody>
             <tr ng-repeat="broker in cluster.brokers| filter: 
state.measureFilter track by $index">
-              <td>{{broker.id}}</td>
-              <td>{{broker.host}}</td>
-              <td>{{broker.port}}</td>
+              <td style="vertical-align: middle;">{{broker.id}}</td>
+              <td ng-if="cluster.edit_index!=$index">{{broker.host}}</td>
+              <td ng-if="cluster.edit_index==$index">
+                <div class="input-group">
+                  <input class="form-control" type="text" 
ng-model="cluster.newBroker.host" name="broker_host" placeholder="Input broker 
host">
+                </div>
+              </td>
+              <td ng-if="cluster.edit_index!=$index">{{broker.port}}</td>
+              <td ng-if="cluster.edit_index==$index">
+                <div class="input-group">
+                  <input class="form-control" type="text" 
ng-model="cluster.newBroker.port" name="broker_port" placeholder="Input broker 
port" onInput="this.value=this.value.replace(/[^0-9]/g, '')">
+                </div>
+              </td>
               <td ng-if="state.mode=='edit'">
                 <!--Edit Button -->
-                <button class="btn btn-xs btn-info" 
ng-click="addBroker(cluster,broker)">
+                <button ng-if="cluster.edit_index!=$index" class="btn btn-xs 
btn-info" ng-click="addBroker(cluster,broker)">
                   <i class="fa fa-pencil"></i>
                 </button>
 
@@ -79,7 +89,7 @@
                 </button>
               </td>
             </tr>
-            <tr ng-if="cluster.newBroker">
+            <tr ng-if="cluster.newBroker&&cluster.edit_index===undefined">
               <td>
                 <div class="input-group">
                   <input class="form-control" type="text" 
ng-model="cluster.newBroker.id" name="broker_id" placeholder="Input broker ID" 
onInput="this.value=this.value.replace(/[^0-9]/g, '')"/>

Reply via email to