From ee2f13832e0e349dc0461627d121a08881b0f87c Mon Sep 17 00:00:00 2001 From: luguosheng1314 <550175214@qq.com> Date: Thu, 4 Jan 2018 14:44:07 +0800 Subject: [PATCH] KYLIN-2918 table acl gui --- webapp/app/index.html | 3 + webapp/app/js/controllers/acl.js | 145 +++++++++++++++++++++++++++ webapp/app/js/services/acl.js | 26 +++++ webapp/app/partials/tables/table_access.html | 133 ++++++++++++++++++++++++ webapp/app/partials/tables/table_detail.html | 20 ++++ 5 files changed, 327 insertions(+) create mode 100644 webapp/app/js/controllers/acl.js create mode 100644 webapp/app/js/services/acl.js create mode 100644 webapp/app/partials/tables/table_access.html diff --git a/webapp/app/index.html b/webapp/app/index.html index 791aa4a..12daaa2 100644 --- a/webapp/app/index.html +++ b/webapp/app/index.html @@ -146,6 +146,7 @@ + @@ -193,6 +194,8 @@ + + diff --git a/webapp/app/js/controllers/acl.js b/webapp/app/js/controllers/acl.js new file mode 100644 index 0000000..6f83d21 --- /dev/null +++ b/webapp/app/js/controllers/acl.js @@ -0,0 +1,145 @@ +/* + * 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. + */ + +'use strict'; +KylinApp.controller('AclCtrl', function ($scope, AclService, TableModel,loadingRequest,SweetAlert,$modal, ProjectModel) { + $scope.tableModel = TableModel; + $scope.tableUserAclList = []; + $scope.tableGroupAclList = []; + $scope.selectTableName = ''; + $scope.projectModel = ProjectModel; + var loadTableAclList = function (loadtype) { + if (!loadtype || loadtype === 'user') { + AclService.getTableAclList({ + project:$scope.projectModel.selectedProject, + tablename:$scope.selectTableName, + type:'user' + }, function (result) { + $scope.tableUserAclList = result; + }) + } + if (!loadtype || loadtype === 'group') { + AclService.getTableAclList({ + project: $scope.projectModel.selectedProject, + tablename: $scope.selectTableName, + type: 'group' + }, function (result) { + $scope.tableGroupAclList = result; + }) + } + + } + + $scope.$watch('tableModel.selectedSrcTable.name',function(){ + $scope.selectTableName = TableModel.selectedSrcTable.database +'.'+ TableModel.selectedSrcTable.name + if(!TableModel.selectedSrcTable.name || !$scope.projectModel) { + return; + } + loadTableAclList(); + }); + $scope.delTableAcl = function (type, name) { + SweetAlert.swal({ + title: '', + text: "Are you sure to drop this table acl?", + type: '', + showCancelButton: true, + confirmButtonColor: '#DD6B55', + confirmButtonText: "Yes", + closeOnConfirm: true + }, function (isConfirm) { + if (isConfirm) { + loadingRequest.show(); + AclService.cancelAclSetOfTable({ + type:type, + project: $scope.projectModel.selectedProject, + tablename:$scope.selectTableName, + username: name + },function () { + loadingRequest.hide(); + loadTableAclList(type); + SweetAlert.swal('Success!', 'Table acl drop is done successfully', 'success'); + }) + } + }) + } + + $scope.addTableAcl = function(model){ + $modal.open({ + templateUrl: 'addTableAcl.html', + windowClass:"cubewindow", + controller: AclAddCtrl, + resolve: { + scope: function () { + return $scope; + } + } + }); + } + var AclAddCtrl = function ($scope, $modalInstance, AclService,SweetAlert,loadingRequest,ProjectModel,TableModel) { + $scope.newTableAcl = { + type: 'user', + name: '' + } + $scope.selectTableName = TableModel.selectedSrcTable.database +'.'+ TableModel.selectedSrcTable.name + $scope.projectModel = ProjectModel; + $scope.tableUserAclBlackList = [] + $scope.tableGroupAclBlackList = [] + AclService.getTableAclBlackList({ + project: $scope.projectModel.selectedProject, + tablename: $scope.selectTableName, + type:'user' + }, function (result) { + $scope.tableUserAclBlackList = result; + }) + AclService.getTableAclBlackList({ + project: $scope.projectModel.selectedProject, + tablename: $scope.selectTableName, + type:'group' + }, function (result) { + $scope.tableGroupAclBlackList = result; + }) + + $scope.userType = [{name:'User',value:'user'},{name:'Group',value:'group'}]; + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + $scope.addAcl = function () { + loadingRequest.show() + AclService.saveAclSetOfTable({ + type:$scope.newTableAcl.type, + project: $scope.projectModel.selectedProject, + tablename:$scope.selectTableName, + username: $scope.newTableAcl.name + },{},function () { + loadingRequest.hide(); + SweetAlert.swal('Success!', 'Table acl add successfully', 'success'); + loadTableAclList() + $scope.cancel() + },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(); + }) + } + } +}) diff --git a/webapp/app/js/services/acl.js b/webapp/app/js/services/acl.js new file mode 100644 index 0000000..0331665 --- /dev/null +++ b/webapp/app/js/services/acl.js @@ -0,0 +1,26 @@ +/* + * 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. + */ + +KylinApp.factory('AclService', ['$resource', function ($resource, config) { + return $resource(Config.service.url + 'acl/:kind/:project/:type/:black/:tablename/:username', {}, { + getTableAclList: {method: 'GET', params: {kind:'table'}, isArray: true}, + getTableAclBlackList : {method: 'GET', params: {kind:'table', black: 'black'}, isArray: true}, + saveAclSetOfTable : {method: 'POST', params: {kind:'table'}, isArray: true}, + cancelAclSetOfTable: {method: 'DELETE', params: {kind:'table'}, isArray: false} + }); +}]); diff --git a/webapp/app/partials/tables/table_access.html b/webapp/app/partials/tables/table_access.html new file mode 100644 index 0000000..1d09f95 --- /dev/null +++ b/webapp/app/partials/tables/table_access.html @@ -0,0 +1,133 @@ + +
+
+ + + + + + + + + + + + + + + + + + + +
+ Id + + User / Role name + + Actions +
+ {{ $index +1}} + + {{ groupAcl}} + + +
+ {{ $index +tableGroupAclList.length +1}} + + {{ userAcl}} + + +
+ + +
diff --git a/webapp/app/partials/tables/table_detail.html b/webapp/app/partials/tables/table_detail.html index 7ebe6d9..9e28194 100644 --- a/webapp/app/partials/tables/table_detail.html +++ b/webapp/app/partials/tables/table_detail.html @@ -32,6 +32,9 @@
  • Streaming Cluster
  • +
  • + Access +
  • @@ -166,7 +169,24 @@
    + +
    + + + +
    -- 2.9.2