You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by bi...@apache.org on 2017/02/04 04:43:42 UTC
[13/47] kylin git commit: KYLIN 2370 Refine unload and reload table
KYLIN 2370 Refine unload and reload table
Signed-off-by: zhongjian <ji...@163.com>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/a853a7c4
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/a853a7c4
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/a853a7c4
Branch: refs/heads/KYLIN-2361
Commit: a853a7c4b6b7d42cc3ffd066b618f5ea72ca0d9f
Parents: 85a1eb3
Author: chenzhx <34...@qq.com>
Authored: Mon Jan 9 15:09:16 2017 +0800
Committer: zhongjian <ji...@163.com>
Committed: Fri Jan 20 16:21:11 2017 +0800
----------------------------------------------------------------------
webapp/app/css/AdminLTE.css | 27 +++
webapp/app/js/controllers/sourceMeta.js | 175 ++++++++-----------
.../js/directives/kylin_abn_tree_directive.js | 7 +-
.../app/partials/tables/source_table_tree.html | 6 +-
webapp/app/partials/tables/table_unload.html | 33 ----
5 files changed, 111 insertions(+), 137 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/a853a7c4/webapp/app/css/AdminLTE.css
----------------------------------------------------------------------
diff --git a/webapp/app/css/AdminLTE.css b/webapp/app/css/AdminLTE.css
index 857dbf7..c7740d1 100644
--- a/webapp/app/css/AdminLTE.css
+++ b/webapp/app/css/AdminLTE.css
@@ -4800,3 +4800,30 @@ Gradient Background colors
white-space: normal !important;
}
}
+
+.abn-tree .abn-tree-row .tree-table-btn{
+ width: 4%;
+ float: right;
+ border-radius: 5px;
+ margin-right: 5px;
+ padding: 3px 16px 2px 5px;
+ color: #ffffff;
+ position:static;
+}
+.abn-tree .abn-tree-row .tree-table-btn .tooltip{
+ overflow:visible;
+}
+.abn-tree .abn-tree-row .btn-info:hover{
+ background-color:#269abc;
+}
+.abn-tree > .abn-tree-row.active > .btn-info{
+ background-color:#269abc;
+ border-left-color:#269abc;
+}
+.abn-tree .abn-tree-row .btn-success:hover{
+ background-color:#008d4c;
+}
+.abn-tree > .abn-tree-row.active > .btn-success{
+ background-color:#008d4c;
+ border-left-color:#008d4c;
+}
http://git-wip-us.apache.org/repos/asf/kylin/blob/a853a7c4/webapp/app/js/controllers/sourceMeta.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/sourceMeta.js b/webapp/app/js/controllers/sourceMeta.js
index a53a35f..5421673 100755
--- a/webapp/app/js/controllers/sourceMeta.js
+++ b/webapp/app/js/controllers/sourceMeta.js
@@ -132,31 +132,83 @@ KylinApp
});
};
- $scope.openUnLoadModal = function () {
- if(!$scope.projectModel.selectedProject){
- SweetAlert.swal('Oops...', "Please select a project.", 'info');
+ $scope.reloadTable = function (tableName,projectName){
+ loadingRequest.show();
+ TableService.loadHiveTable({tableName: tableName, 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.removeList = function (tableName,projectName) {
+ if (tableName.trim() === "") {
+ SweetAlert.swal('', 'Please input table(s) you want to unload.', '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;
- }
+ if (!projectName) {
+ SweetAlert.swal('', 'Please choose your project first!.', 'info');
+ return;
+ }
+ loadingRequest.show();
+ TableService.unLoadHiveTable({tableName: tableName, 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();
+ })
+ }
var ModalInstanceCtrl = function ($scope, $location, $modalInstance, tableNames, MessageService, projectName, isCalculate, scope, kylinConfig) {
$scope.tableNames = "";
@@ -340,88 +392,11 @@ KylinApp
}
$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.reloadTable ($scope.tableNames,projectName);
}
- $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();
- })
- }
};
$scope.editStreamingConfig = function(tableName){
http://git-wip-us.apache.org/repos/asf/kylin/blob/a853a7c4/webapp/app/js/directives/kylin_abn_tree_directive.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/directives/kylin_abn_tree_directive.js b/webapp/app/js/directives/kylin_abn_tree_directive.js
index a3023ab..7545666 100644
--- a/webapp/app/js/directives/kylin_abn_tree_directive.js
+++ b/webapp/app/js/directives/kylin_abn_tree_directive.js
@@ -31,9 +31,13 @@
'$timeout', function($timeout) {
return {
restrict: 'E',
- template: "<ul class=\"nav nav-list nav-pills nav-stacked abn-tree\">\n <li ng-repeat=\"row in tree_rows | filter:{visible:true} track by row.branch.uid\" ng-animate=\"'abn-tree-animate'\" ng-class=\"'level-' + {{ row.level }} + (row.branch.selected ? ' active':'') + ' ' +row.classes.join(' ')\" class=\"abn-tree-row\"><a ng-click=\"user_clicks_branch(row.branch)\" ng-dblclick=\"user_dbClicks_branch(row.branch)\"><i ng-class=\"row.tree_icon\" class=\"indented tree-icon\"> </i><span class=\"indented tree-label\">{{ row.label }} </span></a></li>\n</ul>",
+ template: "<ul class=\"nav nav-list nav-pills nav-stacked abn-tree\">\n <li data=\"{{row.branch.fullName}}\" ng-repeat=\"row in tree_rows | filter:{visible:true} track by row.branch.uid\" ng-animate=\"'abn-tree-animate'\" ng-class=\"'level-' + {{ row.level }} + (row.branch.selected ? ' active':'') + ' ' +row.classes.join(' ')\" class=\"abn-tree-row\" ><a ng-click=\"user_clicks_branch(row.branch)\" ng-dblclick=\"user_dbClicks_branch(row.branch)\" style=\"width:80%;float:left;\"><i ng-class=\"row.tree_icon\" class=\"indented tree-icon\" > </i><span class=\"indented tree-label\">{{ row.label }} </span></a> <a class=\"btn btn-xs btn-info tree-table-btn\" ng-if=\"row.branch.data.exd&&row.level==2&&userService.hasRole('ROLE_ADMIN')&&row.branch.data.source_type==0 \" tooltip=\"UnLoad Hive Table\" tooltip-placement=\"left\" ng-click=\"unloadTable({tableName:row.branch.label,projectName:projectName})\" ><i class=\"fa fa-remove\"></i></a> <a class=\"btn btn-xs btn-success tree-ta
ble-btn\" tooltip-placement=\"left\" tooltip=\"ReLoad Hive Table\" ng-if=\"row.level==2&&userService.hasRole('ROLE_ADMIN')&&row.branch.data.source_type==0\" ng-click=\"reloadTable({tableName:row.branch.label,projectName:projectName})\"><i class=\"fa fa-download\"></i></a> </li>\n</ul>",
replace: true,
scope: {
+ userService:'=',
+ reloadTable:'&',
+ unloadTable:'&',
+ projectName:'@',
treeData: '=',
onSelect: '&',
onDblclick:'&',
@@ -186,7 +190,6 @@
return b.uid = "" + Math.random();
}
});
- console.log('UIDs are set.');
for_each_branch(function(b) {
var child, _i, _len, _ref, _results;
if (angular.isArray(b.children)) {
http://git-wip-us.apache.org/repos/asf/kylin/blob/a853a7c4/webapp/app/partials/tables/source_table_tree.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/tables/source_table_tree.html b/webapp/app/partials/tables/source_table_tree.html
index 3008d8c..eb1ad79 100755
--- a/webapp/app/partials/tables/source_table_tree.html
+++ b/webapp/app/partials/tables/source_table_tree.html
@@ -27,7 +27,6 @@
<div class="pull-right">
<a class="btn btn-xs btn-primary" tooltip="Load Hive Table" ng-if="userService.hasRole('ROLE_ADMIN')" ng-click="openModal()"><i class="fa fa-download"></i></a>
<a class="btn btn-xs btn-info" tooltip="Load Hive Table From Tree" ng-if="userService.hasRole('ROLE_ADMIN')" ng-click="openTreeModal()"><i class="fa fa-download"></i></a>
- <a class="btn btn-xs btn-info" tooltip="Unload Hive Table" ng-if="userService.hasRole('ROLE_ADMIN')" ng-click="openUnLoadModal()"><i class="fa fa-remove"></i></a>
<a class="btn btn-xs btn-primary" tooltip="Add Streaming Table" ng-if="userService.hasRole('ROLE_ADMIN')" ng-click="openStreamingSourceModal()"><i class="fa fa-area-chart"></i></a>
</div>
</div>
@@ -37,6 +36,10 @@
<!--tree-->
<div style="width:100%; height:{{window}}px; overflow:auto;">
<abn-tree
+ user-service = "userService"
+ reload-table = "reloadTable(tableName,projectName)"
+ unload-table = "removeList(tableName,projectName)"
+ project-name = "{{projectModel.selectedProject}}"
tree-data = "tableModel.selectedSrcDb"
tree-control = "my_tree"
icon-leaf = "fa fa-columns"
@@ -75,4 +78,3 @@
</script>
<div ng-include="'partials/tables/table_load.html'"></div>
-<div ng-include="'partials/tables/table_unload.html'"></div>
http://git-wip-us.apache.org/repos/asf/kylin/blob/a853a7c4/webapp/app/partials/tables/table_unload.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/tables/table_unload.html b/webapp/app/partials/tables/table_unload.html
deleted file mode 100644
index 258551e..0000000
--- a/webapp/app/partials/tables/table_unload.html
+++ /dev/null
@@ -1,33 +0,0 @@
-<!--
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
--->
-
- <script type="text/ng-template" id="removeHiveTable.html">
- <div class="modal-header">
- <h4>Unload Hive Table Metadata</h4>
- </div>
- <div class="modal-body">
- <span><strong>Project: </strong>{{ $parent.projectName!=null?$parent.projectName:'NULL'}}</span>
- <label for="tables"> Table Names:(Seperate with comma)</label>
- <textarea ng-model="$parent.tableNames" class="form-control" id="tables"
- placeholder="table1,table2 By default,system will choose 'Default' as database,you can specify database like this 'database.table'"></textarea>
- </div>
- <div class="modal-footer">
- <button class="btn btn-primary" ng-click="remove()">Unload</button>
- <button class="btn btn-primary" ng-click="cancel()">Cancel</button>
- </div>
- </script>