From 28deb4a4a7eb12bdfd96bde64e3cc225de9d972e Mon Sep 17 00:00:00 2001 From: zx chen <346839943@qq.com> Date: Tue, 19 Jul 2016 13:50:42 +0800 Subject: [PATCH] KYLIN-1848 web fix sort cubes issue --- webapp/app/js/config.js | 4 ++++ webapp/app/js/controllers/cubes.js | 41 +++++++++++++----------------------- webapp/app/partials/cubes/cubes.html | 18 ++++++++-------- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/webapp/app/js/config.js b/webapp/app/js/config.js index 46fdecd..c4a693f 100644 --- a/webapp/app/js/config.js +++ b/webapp/app/js/config.js @@ -116,6 +116,10 @@ KylinApp.config(function ($routeProvider, $httpProvider, $locationProvider, $log }); // This runs when all code has loaded, and loads the config and route json manifests, before bootstrapping angular. + + + + window.onload = function () { // Files to load initially. diff --git a/webapp/app/js/controllers/cubes.js b/webapp/app/js/controllers/cubes.js index c103e54..85c7825 100644 --- a/webapp/app/js/controllers/cubes.js +++ b/webapp/app/js/controllers/cubes.js @@ -185,7 +185,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, }; // Cube Action - $scope.enable = function (cube, cubeIndex) { + $scope.enable = function (cube) { 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.', @@ -203,7 +203,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, loadingRequest.hide(); $scope.refreshCube(cube).then(function(_cube){ if(_cube && _cube.name){ - $scope.cubeList.cubes[cubeIndex] = _cube; + $scope.cubeList.cubes[$scope.cubeList.cubes.indexOf(cube)] = _cube; } }); SweetAlert.swal('Success!', 'Enable job was submitted successfully', 'success'); @@ -222,7 +222,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, }); }; - $scope.purge = function (cube, cubeIndex) { + $scope.purge = function (cube) { SweetAlert.swal({ title: '', text: 'Are you sure to purge the cube? ', @@ -239,9 +239,9 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, loadingRequest.hide(); $scope.refreshCube(cube).then(function(_cube){ - if(_cube && _cube.name){ - $scope.cubeList.cubes[cubeIndex] = _cube; - } + if(_cube && _cube.name){ + $scope.cubeList.cubes[$scope.cubeList.cubes.indexOf(cube)] = _cube; + } }); SweetAlert.swal('Success!', 'Purge job was submitted successfully', 'success'); },function(e){ @@ -258,7 +258,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, }); } - $scope.disable = function (cube, cubeIndex) { + $scope.disable = function (cube) { SweetAlert.swal({ title: '', @@ -277,7 +277,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, loadingRequest.hide(); $scope.refreshCube(cube).then(function(_cube){ if(_cube && _cube.name){ - $scope.cubeList.cubes[cubeIndex] = _cube; + $scope.cubeList.cubes[$scope.cubeList.cubes.indexOf(cube)] = _cube; } }); SweetAlert.swal('Success!', 'Disable job was submitted successfully', 'success'); @@ -297,9 +297,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, }); }; - - - $scope.dropCube = function (cube, cubeIndex) { + $scope.dropCube = function (cube) { SweetAlert.swal({ title: '', @@ -316,7 +314,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, CubeService.drop({cubeId: cube.name}, {}, function (result) { loadingRequest.hide(); SweetAlert.swal('Success!', 'Cube drop is done successfully', 'success'); - $scope.cubeList.cubes.splice(cubeIndex,1); + $scope.cubeList.cubes.splice($scope.cubeList.cubes.indexOf(cube),1); },function(e){ loadingRequest.hide(); @@ -333,7 +331,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, }); }; - $scope.startJobSubmit = function (cube, cubeIndex) { + $scope.startJobSubmit = function (cube) { $scope.loadDetail(cube); // for streaming cube build tip if(cube.streaming){ @@ -366,9 +364,6 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, }, scope:function(){ return $scope; - }, - cubeIndex:function(){ - return cubeIndex; } } }); @@ -417,7 +412,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, } }; - $scope.startRefresh = function (cube, cubeIndex) { + $scope.startRefresh = function (cube) { $scope.metaModel={ model:modelsManager.getModelByCube(cube.name) }; @@ -436,9 +431,6 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, }, scope:function(){ return $scope; - }, - cubeIndex:function(){ - return cubeIndex; } } }); @@ -464,7 +456,7 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, $scope.cubeEdit = function (cube) { $location.path("cubes/edit/" + cube.name); } - $scope.startMerge = function (cube, cubeIndex) { + $scope.startMerge = function (cube) { $scope.metaModel={ model:modelsManager.getModelByCube(cube.name) }; @@ -483,9 +475,6 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location, }, scope:function(){ return $scope; - }, - cubeIndex:function(){ - return cubeIndex; } } }); @@ -550,7 +539,7 @@ var cubeCloneCtrl = function ($scope, $modalInstance, CubeService, MessageServic } -var jobSubmitCtrl = function ($scope, $modalInstance, CubeService, MessageService, $location, cube, metaModel, buildType, SweetAlert, loadingRequest, scope, cubeIndex, CubeList) { +var jobSubmitCtrl = function ($scope, $modalInstance, CubeService, MessageService, $location, cube, metaModel, buildType, SweetAlert, loadingRequest, scope, CubeList) { $scope.cubeList = CubeList; $scope.cube = cube; $scope.metaModel = metaModel; @@ -578,7 +567,7 @@ var jobSubmitCtrl = function ($scope, $modalInstance, CubeService, MessageServic $modalInstance.dismiss('cancel'); SweetAlert.swal('Success!', 'Rebuild job was submitted successfully', 'success'); scope.refreshCube(cube).then(function(_cube){ - $scope.cubeList.cubes[cubeIndex] = _cube; + $scope.cubeList.cubes[$scope.cubeList.cubes.indexOf(cube)] = _cube; }); }, function (e) { diff --git a/webapp/app/partials/cubes/cubes.html b/webapp/app/partials/cubes/cubes.html index 6f33ed7..72a3222 100644 --- a/webapp/app/partials/cubes/cubes.html +++ b/webapp/app/partials/cubes/cubes.html @@ -49,7 +49,7 @@ -
+