Repository: kylin
Updated Branches:
  refs/heads/yang-m1 517bcc6fa -> 4e1d2792e


KYLIN-1647 refresh cube status after action


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

Branch: refs/heads/yang-m1
Commit: 4e1d2792e4fbb4cf4765ca049c318c3e3dc200ee
Parents: 517bcc6
Author: Jason <jiat...@163.com>
Authored: Fri May 6 11:53:30 2016 +0800
Committer: Jason <jiat...@163.com>
Committed: Fri May 6 11:54:31 2016 +0800

----------------------------------------------------------------------
 webapp/app/js/controllers/cubes.js   | 96 +++++++++++++++++++++++--------
 webapp/app/partials/cubes/cubes.html | 16 +++---
 2 files changed, 81 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/4e1d2792/webapp/app/js/controllers/cubes.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubes.js 
b/webapp/app/js/controllers/cubes.js
index 7ea626a..8576354 100644
--- a/webapp/app/js/controllers/cubes.js
+++ b/webapp/app/js/controllers/cubes.js
@@ -44,6 +44,26 @@ KylinApp
       dimensionFilter: '', measureFilter: ''
     };
 
+    $scope.refreshCube = function(cube){
+      var queryParam = {
+        cubeName: cube.name,
+        projectName: $scope.projectModel.selectedProject
+      };
+      var defer = $q.defer();
+      CubeService.list(queryParam, function(cubes){
+        for(var index in cubes){
+          if(cube.name === cubes[index].name){
+            defer.resolve(cubes[index]);
+            break;
+          }
+        }
+        defer.resolve([]);
+      },function(e){
+        defer.resolve([]);
+      })
+      return defer.promise;
+    }
+
     $scope.list = function (offset, limit) {
       var defer = $q.defer();
       if (!$scope.projectModel.projects.length) {
@@ -62,16 +82,13 @@ KylinApp
       $scope.loading = true;
 
       return CubeList.list(queryParam).then(function (resp) {
-
-        StreamingList.list().then(function(_resp){
-          angular.forEach($scope.cubeList.cubes,function(item,index){
-            var result = StreamingList.checkCubeExist(item.name);
-            if(result.exist == true){
-              item.streaming = result.streaming;
-              var kfkConfig = 
StreamingList.getKafkaConfig(result.streaming.name);
-              item.kfkConfig = kfkConfig;
-            }
-          })
+        angular.forEach($scope.cubeList.cubes,function(item,index){
+          var result = StreamingList.checkCubeExist(item.name);
+          if(result.exist == true){
+            item.streaming = result.streaming;
+            var kfkConfig = 
StreamingList.getKafkaConfig(result.streaming.name);
+            item.kfkConfig = kfkConfig;
+          }
         })
 
         $scope.loading = false;
@@ -140,7 +157,7 @@ KylinApp
     };
 
 //    Cube Action
-    $scope.enable = function (cube) {
+    $scope.enable = function (cube, cubeIndex) {
       SweetAlert.swal({
         title: '',
         text: 'Are you sure to enable the cube? Please note: if cube schema is 
changed in the disabled period, all segments of the cube will be discarded due 
to data and schema mismatch.',
@@ -156,7 +173,11 @@ KylinApp
           CubeService.enable({cubeId: cube.name}, {}, function (result) {
 
             loadingRequest.hide();
-            cube.status = 'READY';
+            $scope.refreshCube(cube).then(function(_cube){
+              if(_cube && _cube.name){
+                $scope.cubeList.cubes[cubeIndex] = _cube;
+              }
+            });
             SweetAlert.swal('Success!', 'Enable job was submitted 
successfully', 'success');
           },function(e){
 
@@ -173,7 +194,7 @@ KylinApp
       });
     };
 
-    $scope.purge = function (cube) {
+    $scope.purge = function (cube, cubeIndex) {
       SweetAlert.swal({
         title: '',
         text: 'Are you sure to purge the cube? ',
@@ -189,8 +210,11 @@ KylinApp
           CubeService.purge({cubeId: cube.name}, {}, function (result) {
 
             loadingRequest.hide();
-//                    CubeList.removeAll();
-//                    $scope.reload();
+            $scope.refreshCube(cube).then(function(_cube){
+              if(_cube && _cube.name){
+                $scope.cubeList.cubes[cubeIndex] = _cube;
+              }
+            });
             SweetAlert.swal('Success!', 'Purge job was submitted 
successfully', 'success');
           },function(e){
             loadingRequest.hide();
@@ -206,7 +230,7 @@ KylinApp
       });
     }
 
-    $scope.disable = function (cube) {
+    $scope.disable = function (cube, cubeIndex) {
 
       SweetAlert.swal({
         title: '',
@@ -223,7 +247,11 @@ KylinApp
           CubeService.disable({cubeId: cube.name}, {}, function (result) {
 
             loadingRequest.hide();
-            cube.status = 'DISABLED';
+            $scope.refreshCube(cube).then(function(_cube){
+              if(_cube && _cube.name){
+                $scope.cubeList.cubes[cubeIndex] = _cube;
+              }
+            });
             SweetAlert.swal('Success!', 'Disable job was submitted 
successfully', 'success');
           },function(e){
 
@@ -243,7 +271,7 @@ KylinApp
 
 
 
-    $scope.dropCube = function (cube) {
+    $scope.dropCube = function (cube, cubeIndex) {
 
       SweetAlert.swal({
         title: '',
@@ -260,7 +288,7 @@ KylinApp
           CubeService.drop({cubeId: cube.name}, {}, function (result) {
             loadingRequest.hide();
             SweetAlert.swal('Success!', 'Cube drop is done successfully', 
'success');
-            location.reload();
+            $scope.cubeList.cubes.splice(cubeIndex,1);
           },function(e){
 
             loadingRequest.hide();
@@ -277,7 +305,7 @@ KylinApp
       });
     };
 
-    $scope.startJobSubmit = function (cube) {
+    $scope.startJobSubmit = function (cube, cubeIndex) {
       $scope.loadDetail(cube);
       // for streaming cube build tip
       if(cube.streaming){
@@ -307,6 +335,12 @@ KylinApp
               },
               buildType: function () {
                 return 'BUILD';
+              },
+              scope:function(){
+                return $scope;
+              },
+              cubeIndex:function(){
+                return cubeIndex;
               }
             }
           });
@@ -355,7 +389,7 @@ KylinApp
       }
     };
 
-    $scope.startRefresh = function (cube) {
+    $scope.startRefresh = function (cube, cubeIndex) {
       $scope.metaModel={
         model:modelsManager.getModelByCube(cube.name)
       };
@@ -371,6 +405,12 @@ KylinApp
           },
           buildType: function () {
             return 'REFRESH';
+          },
+          scope:function(){
+            return $scope;
+          },
+          cubeIndex:function(){
+            return cubeIndex;
           }
         }
       });
@@ -396,7 +436,7 @@ KylinApp
     $scope.cubeEdit = function (cube) {
       $location.path("cubes/edit/" + cube.name);
     }
-    $scope.startMerge = function (cube) {
+    $scope.startMerge = function (cube, cubeIndex) {
       $scope.metaModel={
         model:modelsManager.getModelByCube(cube.name)
       };
@@ -412,6 +452,12 @@ KylinApp
           },
           buildType: function () {
             return 'MERGE';
+          },
+          scope:function(){
+            return $scope;
+          },
+          cubeIndex:function(){
+            return cubeIndex;
           }
         }
       });
@@ -471,7 +517,8 @@ var cubeCloneCtrl = function ($scope, $modalInstance, 
CubeService, MessageServic
 }
 
 
-var jobSubmitCtrl = function ($scope, $modalInstance, CubeService, 
MessageService, $location, cube, metaModel, buildType, SweetAlert, 
loadingRequest) {
+var jobSubmitCtrl = function ($scope, $modalInstance, CubeService, 
MessageService, $location, cube, metaModel, buildType, SweetAlert, 
loadingRequest, scope, cubeIndex, CubeList) {
+  $scope.cubeList = CubeList;
   $scope.cube = cube;
   $scope.metaModel = metaModel;
   $scope.jobBuildRequest = {
@@ -497,6 +544,9 @@ var jobSubmitCtrl = function ($scope, $modalInstance, 
CubeService, MessageServic
       loadingRequest.hide();
       $modalInstance.dismiss('cancel');
       SweetAlert.swal('Success!', 'Rebuild job was submitted successfully', 
'success');
+      scope.refreshCube(cube).then(function(_cube){
+          $scope.cubeList.cubes[cubeIndex] = _cube;
+        });
     }, function (e) {
 
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/4e1d2792/webapp/app/partials/cubes/cubes.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubes/cubes.html 
b/webapp/app/partials/cubes/cubes.html
index a1f5e1c..8886249 100644
--- a/webapp/app/partials/cubes/cubes.html
+++ b/webapp/app/partials/cubes/cubes.html
@@ -49,7 +49,7 @@
         </tr>
         </thead>
         <!--Body-->
-        <tbody ng-repeat="cube in cubeList.cubes | 
orderObjectBy:state.filterAttr:state.filterReverse">
+        <tbody ng-repeat="cube in cubeList.cubes track by $index| 
orderObjectBy:state.filterAttr:state.filterReverse">
         <tr ng-class="{accordion:true}" style="cursor: pointer"  
ng-click="cube.showDetail=!cube.showDetail;loadDetail(cube)">
             <td>
                 <i ng-show="!cube.showDetail" class="fa 
fa-chevron-circle-right blue"></i>
@@ -81,16 +81,16 @@
                     </button>
                     <ul class="dropdown-menu" role="menu">
                         <li ng-if="cube.status=='DISABLED' && 
userService.hasRole('ROLE_ADMIN') ">
-                            <a ng-click="dropCube(cube)" tooltip="Drop the 
cube, related jobs and data permanently.">Drop</a></li>
+                            <a ng-click="dropCube(cube, $index)" tooltip="Drop 
the cube, related jobs and data permanently.">Drop</a></li>
                         <li ng-if="cube.status=='DISABLED' && 
(userService.hasRole('ROLE_ADMIN') || hasPermission(cube, 
permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask))">
                             <a ng-click="cubeEdit(cube);">Edit</a></li>
                       <li ng-if="cube.streaming && cube.status=='DISABLED' && 
(userService.hasRole('ROLE_ADMIN') || hasPermission(cube, 
permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask))">
-                        <li><a ng-click="startJobSubmit(cube);">Build</a></li>
-                        <li><a ng-click="startRefresh(cube)">Refresh</a></li>
-                        <li><a ng-click="startMerge(cube)">Merge</a></li>
-                        <li ng-if="cube.status!='DISABLED'"><a 
ng-click="disable(cube)">Disable</a></li>
-                        <li ng-if="cube.status=='DISABLED'"><a 
ng-click="enable(cube)">Enable</a></li>
-                        <li ng-if="cube.status=='DISABLED'"><a 
ng-click="purge(cube)">Purge</a></li>
+                        <li><a ng-click="startJobSubmit(cube, 
$index);">Build</a></li>
+                        <li><a ng-click="startRefresh(cube, 
$index)">Refresh</a></li>
+                        <li><a ng-click="startMerge(cube, 
$index)">Merge</a></li>
+                        <li ng-if="cube.status!='DISABLED'"><a 
ng-click="disable(cube, $index)">Disable</a></li>
+                        <li ng-if="cube.status=='DISABLED'"><a 
ng-click="enable(cube, $index)">Enable</a></li>
+                        <li ng-if="cube.status=='DISABLED'"><a 
ng-click="purge(cube, $index)">Purge</a></li>
                         <li><a ng-click="cloneCube(cube)">Clone</a></li>
 
                     </ul>

Reply via email to