From dc1ed2621d18ef223b226e021fd3522fee37fdb7 Mon Sep 17 00:00:00 2001 From: chenzhx Date: Fri, 26 Jan 2018 14:29:23 +0800 Subject: [PATCH] KYLIN 3116 Fix cardinality caculate checkbox issue when loading tables --- webapp/app/js/controllers/query.js | 2 +- webapp/app/js/controllers/sourceMeta.js | 41 +++++++++++++++++++---- webapp/app/partials/tables/source_table_tree.html | 2 +- webapp/app/partials/tables/table_detail.html | 2 +- webapp/app/partials/tables/table_load.html | 17 +++++++++- 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/webapp/app/js/controllers/query.js b/webapp/app/js/controllers/query.js index e7190ccc4..e9ea61445 100644 --- a/webapp/app/js/controllers/query.js +++ b/webapp/app/js/controllers/query.js @@ -353,7 +353,7 @@ KylinApp } $scope.listCachedQueries = function () { - $scope.cachedQueries = storage.get("saved_queries"); + $scope.cachedQueries = storage.get("saved_queries") || []; $scope.cachedFilterQueries = $scope.cachedQueries.filter(function (query) { return query.project === $scope.projectModel.selectedProject; }); diff --git a/webapp/app/js/controllers/sourceMeta.js b/webapp/app/js/controllers/sourceMeta.js index 4f341f028..7deef7633 100755 --- a/webapp/app/js/controllers/sourceMeta.js +++ b/webapp/app/js/controllers/sourceMeta.js @@ -107,11 +107,34 @@ KylinApp }); }; + $scope.openReloadModal = function () { + $modal.open({ + templateUrl: 'reloadTable.html', + controller: ModalInstanceCtrl, + backdrop : 'static', + resolve: { + tableNames: function () { + return $scope.tableModel.selectedSrcTable.database + '.'+ $scope.tableModel.selectedSrcTable.name; + }, + projectName: function () { + return $scope.projectModel.selectedProject; + }, + isCalculate: function () { + return $scope.isCalculate; + }, + scope: function () { + return $scope; + } + } + }); + }; + $scope.openTreeModal = function () { if(!$scope.projectModel.selectedProject){ SweetAlert.swal('Oops...', "Please select a project.", 'info'); return; } + $modal.open({ templateUrl: 'addHiveTableFromTree.html', controller: ModalInstanceCtrl, @@ -132,10 +155,10 @@ KylinApp }); }; - $scope.reloadTable = function (tableName){ + $scope.reloadTable = function (tableName, isCalculate){ var delay = $q.defer(); loadingRequest.show(); - TableService.loadHiveTable({tableName: tableName, action: $scope.projectModel.selectedProject}, {calculate: $scope.isCalculate}, function (result) { + TableService.loadHiveTable({tableName: tableName, action: $scope.projectModel.selectedProject}, {calculate: isCalculate}, function (result) { var loadTableInfo = ""; angular.forEach(result['result.loaded'], function (table) { loadTableInfo += "\n" + table; @@ -169,7 +192,6 @@ KylinApp } - $scope.unloadTable = function (tableName) { SweetAlert.swal({ title: "", @@ -222,8 +244,11 @@ KylinApp var ModalInstanceCtrl = function ($scope, $location, $modalInstance, tableNames, MessageService, projectName, isCalculate, scope, kylinConfig) { $scope.tableNames = ""; + $scope.selectTable = tableNames; $scope.projectName = projectName; - $scope.isCalculate = isCalculate; + $scope.isCalculate = { + val: true + } $scope.cancel = function () { $modalInstance.dismiss('cancel'); @@ -387,7 +412,11 @@ KylinApp $scope.loadHive(); } - + $scope.confirmReload = function() { + scope.reloadTable($scope.selectTable, $scope.isCalculate.val).then(function() { + $scope.cancel(); + }) + } $scope.add = function () { @@ -411,7 +440,7 @@ KylinApp } $scope.cancel(); - scope.reloadTable($scope.tableNames).then(function(){ + scope.reloadTable($scope.tableNames, $scope.isCalculate.val).then(function(){ scope.aceSrcTbLoaded(true); }); } diff --git a/webapp/app/partials/tables/source_table_tree.html b/webapp/app/partials/tables/source_table_tree.html index b5c55d122..30cfc8b7d 100755 --- a/webapp/app/partials/tables/source_table_tree.html +++ b/webapp/app/partials/tables/source_table_tree.html @@ -63,7 +63,7 @@ {{node.label}} - +