You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ch...@apache.org on 2018/02/09 06:41:29 UTC
kylin git commit: KYLIN-2884 Add delete segment function for portal
Repository: kylin
Updated Branches:
refs/heads/2.3.x 4adbbe089 -> bd88a718d
KYLIN-2884 Add delete segment function for portal
Signed-off-by: chenzhx <ch...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/bd88a718
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/bd88a718
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/bd88a718
Branch: refs/heads/2.3.x
Commit: bd88a718d8bd914fe2cbaf3c188a403318ef30b8
Parents: 4adbbe0
Author: sanjulian <ju...@hotmail.com>
Authored: Fri Feb 9 14:32:34 2018 +0800
Committer: chenzhx <ch...@apache.org>
Committed: Fri Feb 9 14:41:24 2018 +0800
----------------------------------------------------------------------
webapp/app/js/controllers/cubes.js | 66 ++++++++++++++-
webapp/app/js/services/cubes.js | 1 +
.../app/partials/cubes/cube_delete_segment.html | 89 ++++++++++++++++++++
webapp/app/partials/cubes/cubes.html | 3 +-
4 files changed, 156 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/bd88a718/webapp/app/js/controllers/cubes.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/controllers/cubes.js b/webapp/app/js/controllers/cubes.js
index cc28a8d..a386202 100644
--- a/webapp/app/js/controllers/cubes.js
+++ b/webapp/app/js/controllers/cubes.js
@@ -520,8 +520,25 @@ KylinApp.controller('CubesCtrl', function ($scope, $q, $routeParams, $location,
}
});
})
- }
+ };
+ $scope.startDeleteSegment = function (cube) {
+ $scope.metaModel={
+ model:modelsManager.getModelByCube(cube.name)
+ };
+ $modal.open({
+ templateUrl: 'deleteSegment.html',
+ controller: deleteSegmentCtrl,
+ resolve: {
+ cube: function () {
+ return cube;
+ },
+ scope: function() {
+ return $scope;
+ }
+ }
+ });
+ };
});
@@ -715,4 +732,49 @@ var streamingBuildCtrl = function ($scope, $modalInstance,kylinConfig) {
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
-}
+};
+
+var deleteSegmentCtrl = function($scope, $modalInstance, CubeService, SweetAlert, loadingRequest, cube, scope) {
+ $scope.cube = cube;
+ $scope.deleteSegments = [];
+ $scope.segment = {};
+
+ $scope.cancel = function () {
+ $modalInstance.dismiss('cancel');
+ };
+
+ $scope.deleteSegment = function() {
+ SweetAlert.swal({
+ title: '',
+ text: 'Are you sure to delete segment ['+$scope.segment.selected.name+']? ',
+ type: '',
+ showCancelButton: true,
+ confirmButtonColor: '#DD6B55',
+ confirmButtonText: "Yes",
+ closeOnConfirm: true
+ }, function(isConfirm) {
+ if(isConfirm){
+ loadingRequest.show();
+ CubeService.deleteSegment({cubeId: cube.name, propValue: $scope.segment.selected.name}, {}, function (result) {
+ loadingRequest.hide();
+ $modalInstance.dismiss('cancel');
+ scope.refreshCube(cube).then(function(_cube){
+ if(_cube && _cube.name){
+ scope.cubeList.cubes[scope.cubeList.cubes.indexOf(cube)] = _cube;
+ }
+ });
+ SweetAlert.swal('Success!', 'Delete segment successfully', 'success');
+ },function(e){
+ loadingRequest.hide();
+ if(e.data&& e.data.exception){
+ var message =e.data.exception;
+ var msg = !!(message) ? message : 'Failed to delete segment.';
+ SweetAlert.swal('Oops...', msg, 'error');
+ }else{
+ SweetAlert.swal('Oops...', 'Failed to delete segment.', 'error');
+ }
+ });
+ }
+ });
+ };
+};
http://git-wip-us.apache.org/repos/asf/kylin/blob/bd88a718/webapp/app/js/services/cubes.js
----------------------------------------------------------------------
diff --git a/webapp/app/js/services/cubes.js b/webapp/app/js/services/cubes.js
index 30c2a3f..6140521 100644
--- a/webapp/app/js/services/cubes.js
+++ b/webapp/app/js/services/cubes.js
@@ -50,6 +50,7 @@ KylinApp.factory('CubeService', ['$resource', function ($resource, config) {
enable: {method: 'PUT', params: {action: 'enable'}, isArray: false},
purge: {method: 'PUT', params: {action: 'purge'}, isArray: false},
clone: {method: 'PUT', params: {action: 'clone'}, isArray: false},
+ deleteSegment: {method: 'DELETE', params: {propName: 'segs'}, isArray: false},
drop: {method: 'DELETE', params: {}, isArray: false},
save: {method: 'POST', params: {}, isArray: false},
update: {method: 'PUT', params: {}, isArray: false},
http://git-wip-us.apache.org/repos/asf/kylin/blob/bd88a718/webapp/app/partials/cubes/cube_delete_segment.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubes/cube_delete_segment.html b/webapp/app/partials/cubes/cube_delete_segment.html
new file mode 100644
index 0000000..8500f3f
--- /dev/null
+++ b/webapp/app/partials/cubes/cube_delete_segment.html
@@ -0,0 +1,89 @@
+<!--
+* 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="deleteSegment.html">
+ <div class="modal-header">
+ <h4 tooltip="refresh">CUBE SEGMENT DELETE CONFIRM</h4>
+ </div>
+ <div class="modal-body" style="background-color: white">
+ <div ng-if="cube.model.partition_desc.partition_date_column" class="row">
+ <div class="col-md-2"></div>
+ <div class="col-md-8">
+ <div ng-if="!!!(cube.segments) || cube.segments.length == 0">
+ <span class="text-info">No Segment to Delete.</span>
+ </div>
+ <div ng-if="cube.segments && cube.segments.length > 0" class="row">
+ <table class="table table-striped list">
+ <tbody>
+ <tr>
+ <td>DELETE SEGMENT</td>
+ <td>
+ <select ng-model="segment.selected"
+ ng-init="segment.selected=cube.segments[0];"
+ ng-options="segment as segment.name for segment in cube.segments">
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>SEGMENT DETAIL</td>
+ <td>
+ <table class="table table-condensed">
+ <tr>
+ <td>Start Date (Include)</td>
+ <td>{{segment.selected.date_range_start | reverseToGMT0}}</td>
+ </tr>
+ <tr>
+ <td>End Date (Exclude)</td>
+ <td>{{segment.selected.date_range_end | reverseToGMT0}}</td>
+ </tr>
+ <tr>
+ <td>Last build Time</td>
+ <td>{{segment.selected.last_build_time | utcToConfigTimeZone}}</td>
+ </tr>
+ <tr>
+ <td>Last build ID</td>
+ <td>{{segment.selected.last_build_job_id}}</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+ <div ng-if="segment.selected && segment.selected.name !== cube.segments[0].name && segment.selected.name !== cube.segments[cube.segments.length-1].name">
+ <span class="text-warning">Cube will gap if you delete selected segment.</span>
+ </div>
+ </div>
+ </div>
+ <div class="col-md-2"></div>
+ </div>
+ <div ng-if="!cube.model.partition_desc.partition_date_column" class="row">
+ <div class="col-md-2"></div>
+ <div class="col-md-8">
+ <span>No partition date column defined. If you want to drop the cube, please click "Drop".</span>
+ </div>
+ <div class="col-md-2"></div>
+ </div>
+ </div>
+
+ <div class="modal-footer">
+ <button class="btn btn-primary" ng-click="cancel()">Close</button>
+ <button class="btn btn-success" ng-click="deleteSegment()">Delete
+ </button>
+ </div>
+</script>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/kylin/blob/bd88a718/webapp/app/partials/cubes/cubes.html
----------------------------------------------------------------------
diff --git a/webapp/app/partials/cubes/cubes.html b/webapp/app/partials/cubes/cubes.html
index f61afbf..3fd5e61 100644
--- a/webapp/app/partials/cubes/cubes.html
+++ b/webapp/app/partials/cubes/cubes.html
@@ -97,6 +97,7 @@
<li ng-if="cube.status!='DESCBROKEN'"><a ng-click="startMerge(cube)">Merge</a></li>
<li ng-if="cube.status=='READY' && (userService.hasRole('ROLE_ADMIN') || hasPermission('cube',cube, permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask))"><a ng-click="disable(cube)">Disable</a></li>
<li ng-if="cube.status=='DISABLED' && (userService.hasRole('ROLE_ADMIN') || hasPermission('cube',cube, permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask))"><a ng-click="enable(cube)">Enable</a></li>
+ <li ng-if="cube.status=='DISABLED' && (userService.hasRole('ROLE_ADMIN') || hasPermission('cube',cube, permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask))"><a ng-click="startDeleteSegment(cube)">Delete Segment</a></li>
<li ng-if="cube.status=='DISABLED' && (userService.hasRole('ROLE_ADMIN') || hasPermission('cube',cube, permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask))"><a ng-click="purge(cube)">Purge</a></li>
<li ng-if="cube.status!='DESCBROKEN' && (userService.hasRole('ROLE_ADMIN') || hasPermission('cube',cube, permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask))"><a ng-click="cloneCube(cube)">Clone</a></li>
<li ng-if="cube.status=='READY' && isAutoMigrateCubeEnabled() && (userService.hasRole('ROLE_ADMIN') || hasPermission('cube',cube, permissions.ADMINISTRATION.mask, permissions.MANAGEMENT.mask)) "><a ng-click="migrateCube(cube)">Migrate</a></li>
@@ -144,5 +145,5 @@
<div ng-include="'partials/projects/project_create.html'"></div>
<div ng-include="'partials/models/model_detail.html'"></div>
<div ng-include="'partials/cubes/cube_clone.html'"></div>
-
+<div ng-include="'partials/cubes/cube_delete_segment.html'"></div>
</div>