From 87f66af79e3195f0e63e8e2bebcdd4c7b933fc8e Mon Sep 17 00:00:00 2001 From: chenzhx <346839943@qq.com> Date: Tue, 17 Jan 2017 18:21:44 +0800 Subject: [PATCH] KYLIN 2370 Refine unload and reload table --- webapp/app/js/controllers/sourceMeta.js | 210 +++++++++------------- webapp/app/partials/tables/source_table_tree.html | 3 +- webapp/app/partials/tables/table_detail.html | 3 +- webapp/app/partials/tables/table_unload.html | 33 ---- 4 files changed, 92 insertions(+), 157 deletions(-) delete mode 100644 webapp/app/partials/tables/table_unload.html diff --git a/webapp/app/js/controllers/sourceMeta.js b/webapp/app/js/controllers/sourceMeta.js index a53a35faf..9b841a76b 100755 --- a/webapp/app/js/controllers/sourceMeta.js +++ b/webapp/app/js/controllers/sourceMeta.js @@ -80,6 +80,83 @@ KylinApp $scope.aceSrcTbLoaded(true); }; + $scope.reloadTable = function (tableNames) { + var delay = $q.defer(); + loadingRequest.show(); + TableService.loadHiveTable({tableName: tableNames, action:$scope.projectModel.selectedProject}, {calculate: $scope.isCalculate}, function (result) { + var loadTableInfo = ""; + angular.forEach(result['result.loaded'], function (table) { + loadTableInfo += "\n" + table; + }); + var unloadedTableInfo = ""; + angular.forEach(result['result.unloaded'], function (table) { + unloadedTableInfo += "\n" + table; + }); + if (result['result.unloaded'].length != 0 && result['result.loaded'].length == 0) { + SweetAlert.swal('Failed!', 'Failed to load following table(s): ' + unloadedTableInfo, 'error'); + } + if (result['result.loaded'].length != 0 && result['result.unloaded'].length == 0) { + SweetAlert.swal('Success!', 'The following table(s) have been successfully loaded: ' + loadTableInfo, 'success'); + } + if (result['result.loaded'].length != 0 && result['result.unloaded'].length != 0) { + SweetAlert.swal('Partial loaded!', 'The following table(s) have been successfully loaded: ' + loadTableInfo + "\n\n Failed to load following table(s):" + unloadedTableInfo, 'warning'); + } + loadingRequest.hide(); + delay.resolve(""); + }, function (e) { + if (e.data && e.data.exception) { + var message = e.data.exception; + var msg = !!(message) ? message : 'Failed to take action.'; + SweetAlert.swal('Oops...', msg, 'error'); + } else { + SweetAlert.swal('Oops...', "Failed to take action.", 'error'); + } + loadingRequest.hide(); + }) + return delay.promise; + } + + $scope.unloadTable = function (tableNames) { + if (tableNames.trim() === "") { + SweetAlert.swal('', 'Please input table(s) you want to unload.', 'info'); + return; + } + if (!$scope.projectModel.selectedProject) { + SweetAlert.swal('', 'Please choose your project first!.', 'info'); + return; + } + loadingRequest.show(); + TableService.unLoadHiveTable({tableName: tableNames, action: $scope.projectModel.selectedProject}, {}, function (result) { + var removedTableInfo = ""; + angular.forEach(result['result.unload.success'], function (table) { + removedTableInfo += "\n" + table; + }) + var unRemovedTableInfo = ""; + angular.forEach(result['result.unload.fail'], function (table) { + unRemovedTableInfo += "\n" + table; + }) + if (result['result.unload.fail'].length != 0 && result['result.unload.success'].length == 0) { + SweetAlert.swal('Failed!', 'Failed to unload following table(s): ' + unRemovedTableInfo, 'error'); + } + if (result['result.unload.success'].length != 0 && result['result.unload.fail'].length == 0) { + SweetAlert.swal('Success!', 'The following table(s) have been successfully unloaded: ' + removedTableInfo, 'success'); + } + if (result['result.unload.success'].length != 0 && result['result.unload.fail'].length != 0) { + SweetAlert.swal('Partial unloaded!', 'The following table(s) have been successfully unloaded: ' + removedTableInfo + "\n\n Failed to unload following table(s):" + unRemovedTableInfo, 'warning'); + } + loadingRequest.hide(); + $scope.aceSrcTbLoaded(true); + }, function (e) { + if (e.data && e.data.exception) { + var message = e.data.exception; + var msg = !!(message) ? message : 'Failed to take action.'; + SweetAlert.swal('Oops...', msg, 'error'); + } else { + SweetAlert.swal('Oops...', "Failed to take action.", 'error'); + } + loadingRequest.hide(); + }) + } $scope.openModal = function () { if(!$scope.projectModel.selectedProject){ @@ -132,31 +209,7 @@ KylinApp }); }; - $scope.openUnLoadModal = function () { - if(!$scope.projectModel.selectedProject){ - SweetAlert.swal('Oops...', "Please select a project.", 'info'); - return; - } - $modal.open({ - templateUrl: 'removeHiveTable.html', - controller: ModalInstanceCtrl, - backdrop : 'static', - resolve: { - tableNames: function () { - return $scope.tableNames; - }, - projectName: function () { - return $scope.projectModel.selectedProject; - }, - isCalculate: function () { - return $scope.isCalculate; - }, - scope: function () { - return $scope; - } - } - }); - }; + var ModalInstanceCtrl = function ($scope, $location, $modalInstance, tableNames, MessageService, projectName, isCalculate, scope, kylinConfig) { $scope.tableNames = ""; @@ -316,11 +369,7 @@ KylinApp $scope.loadHive(); } - - - $scope.add = function () { - if($scope.tableNames.length === 0 && $scope.selectedNodes.length > 0) { for(var i = 0; i < $scope.selectedNodes.length; i++){ if($scope.selectedNodes[i].label.indexOf(".") >= 0){ @@ -328,100 +377,19 @@ KylinApp } } } - if ($scope.tableNames.trim() === "") { SweetAlert.swal('', 'Please input table(s) you want to load.', 'info'); - return; - } - - if (!$scope.projectName) { - SweetAlert.swal('', 'Please choose your project first!.', 'info'); - return; - } - - $scope.cancel(); - loadingRequest.show(); - TableService.loadHiveTable({tableName: $scope.tableNames, action: projectName}, {calculate: $scope.isCalculate}, function (result) { - var loadTableInfo = ""; - angular.forEach(result['result.loaded'], function (table) { - loadTableInfo += "\n" + table; - }) - var unloadedTableInfo = ""; - angular.forEach(result['result.unloaded'], function (table) { - unloadedTableInfo += "\n" + table; - }) - - if (result['result.unloaded'].length != 0 && result['result.loaded'].length == 0) { - SweetAlert.swal('Failed!', 'Failed to load following table(s): ' + unloadedTableInfo, 'error'); - } - if (result['result.loaded'].length != 0 && result['result.unloaded'].length == 0) { - SweetAlert.swal('Success!', 'The following table(s) have been successfully loaded: ' + loadTableInfo, 'success'); - } - if (result['result.loaded'].length != 0 && result['result.unloaded'].length != 0) { - SweetAlert.swal('Partial loaded!', 'The following table(s) have been successfully loaded: ' + loadTableInfo + "\n\n Failed to load following table(s):" + unloadedTableInfo, 'warning'); - } - loadingRequest.hide(); - scope.aceSrcTbLoaded(true); - - }, function (e) { - if (e.data && e.data.exception) { - var message = e.data.exception; - var msg = !!(message) ? message : 'Failed to take action.'; - SweetAlert.swal('Oops...', msg, 'error'); - } else { - SweetAlert.swal('Oops...', "Failed to take action.", 'error'); - } - loadingRequest.hide(); - }) - } - - - $scope.remove = function () { - if ($scope.tableNames.trim() === "") { - SweetAlert.swal('', 'Please input table(s) you want to unload.', 'info'); - return; - } - - if (!$scope.projectName) { - SweetAlert.swal('', 'Please choose your project first!.', 'info'); - return; - } - - $scope.cancel(); - loadingRequest.show(); - TableService.unLoadHiveTable({tableName: $scope.tableNames, action: projectName}, {}, function (result) { - var removedTableInfo = ""; - angular.forEach(result['result.unload.success'], function (table) { - removedTableInfo += "\n" + table; - }) - var unRemovedTableInfo = ""; - angular.forEach(result['result.unload.fail'], function (table) { - unRemovedTableInfo += "\n" + table; - }) - - if (result['result.unload.fail'].length != 0 && result['result.unload.success'].length == 0) { - SweetAlert.swal('Failed!', 'Failed to unload following table(s): ' + unRemovedTableInfo, 'error'); - } - if (result['result.unload.success'].length != 0 && result['result.unload.fail'].length == 0) { - SweetAlert.swal('Success!', 'The following table(s) have been successfully unloaded: ' + removedTableInfo, 'success'); - } - if (result['result.unload.success'].length != 0 && result['result.unload.fail'].length != 0) { - SweetAlert.swal('Partial unloaded!', 'The following table(s) have been successfully unloaded: ' + removedTableInfo + "\n\n Failed to unload following table(s):" + unRemovedTableInfo, 'warning'); - } - loadingRequest.hide(); - scope.aceSrcTbLoaded(true); - - }, function (e) { - if (e.data && e.data.exception) { - var message = e.data.exception; - var msg = !!(message) ? message : 'Failed to take action.'; - SweetAlert.swal('Oops...', msg, 'error'); - } else { - SweetAlert.swal('Oops...', "Failed to take action.", 'error'); - } - loadingRequest.hide(); - }) - } + return; + } + if (!$scope.projectName) { + SweetAlert.swal('', 'Please choose your project first!.', 'info'); + return; + } + $scope.cancel(); + scope.reloadTable($scope.tableNames).then(function(){ + scope.aceSrcTbLoaded(true); + }); + } }; $scope.editStreamingConfig = function(tableName){ diff --git a/webapp/app/partials/tables/source_table_tree.html b/webapp/app/partials/tables/source_table_tree.html index 3008d8c11..1d25fff77 100755 --- a/webapp/app/partials/tables/source_table_tree.html +++ b/webapp/app/partials/tables/source_table_tree.html @@ -27,7 +27,6 @@
-
@@ -75,4 +74,4 @@
-
+ diff --git a/webapp/app/partials/tables/table_detail.html b/webapp/app/partials/tables/table_detail.html index f22782658..7f299b476 100644 --- a/webapp/app/partials/tables/table_detail.html +++ b/webapp/app/partials/tables/table_detail.html @@ -19,7 +19,8 @@