KYLIN-2082 support update streaming config
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/1ceaf9ee Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/1ceaf9ee Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/1ceaf9ee Branch: refs/heads/KYLIN-1971 Commit: 1ceaf9eebe2be35071e526e90d14ac59196268d1 Parents: 5547712 Author: Jason <jiat...@163.com> Authored: Thu Oct 20 11:17:48 2016 +0800 Committer: Jason <jiat...@163.com> Committed: Thu Oct 20 11:20:15 2016 +0800 ---------------------------------------------------------------------- webapp/app/js/controllers/sourceMeta.js | 102 +++++++++++++++++++ webapp/app/js/controllers/streamingConfig.js | 49 ++++++--- webapp/app/less/component.less | 16 +++ .../partials/cubeDesigner/streamingConfig.html | 9 +- webapp/app/partials/tables/table_detail.html | 6 ++ webapp/app/partials/tables/table_load.html | 30 ++++++ 6 files changed, 194 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/1ceaf9ee/webapp/app/js/controllers/sourceMeta.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/sourceMeta.js b/webapp/app/js/controllers/sourceMeta.js index e3ab0ac..3bbdfc0 100755 --- a/webapp/app/js/controllers/sourceMeta.js +++ b/webapp/app/js/controllers/sourceMeta.js @@ -424,6 +424,35 @@ KylinApp } }; + $scope.editStreamingConfig = function(tableName){ + var modalInstance = $modal.open({ + templateUrl: 'editStreamingSource.html', + controller: EditStreamingSourceCtrl, + backdrop : 'static', + resolve: { + tableNames: function () { + return $scope.tableNames; + }, + projectName: function () { + return $scope.projectModel.selectedProject; + }, + tableName: function(){ + return tableName; + }, + scope: function () { + return $scope; + } + } + }); + + modalInstance.result.then(function () { + $scope.$broadcast('StreamingConfigEdited'); + }, function () { + $scope.$broadcast('StreamingConfigEdited'); + }); + + + } //streaming model $scope.openStreamingSourceModal = function () { @@ -449,6 +478,78 @@ KylinApp }); }; + var EditStreamingSourceCtrl = function ($scope, $interpolate, $templateCache, tableName, $modalInstance, tableNames, MessageService, projectName, scope, tableConfig,cubeConfig,StreamingModel,StreamingService) { + + $scope.state = { + tableName : tableName, + mode: "edit", + target:"kfkConfig" + } + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + + $scope.projectName = projectName; + $scope.streamingMeta = StreamingModel.createStreamingConfig(); + $scope.kafkaMeta = StreamingModel.createKafkaConfig(); + $scope.updateStreamingMeta = function(val){ + $scope.streamingMeta = val; + } + $scope.updateKafkaMeta = function(val){ + $scope.kafkaMeta = val; + } + + $scope.streamingResultTmpl = function (notification) { + // Get the static notification template. + var tmpl = notification.type == 'success' ? 'streamingResultSuccess.html' : 'streamingResultError.html'; + return $interpolate($templateCache.get(tmpl))(notification); + }; + + $scope.updateStreamingSchema = function(){ + StreamingService.update({}, { + project: $scope.projectName, + tableData:angular.toJson(""), + streamingConfig: angular.toJson($scope.streamingMeta), + kafkaConfig: angular.toJson($scope.kafkaMeta) + }, function (request) { + if (request.successful) { + SweetAlert.swal('', 'Updated the streaming successfully.', 'success'); + $scope.cancel(); + } else { + var message = request.message; + var msg = !!(message) ? message : 'Failed to take action.'; + MessageService.sendMsg($scope.streamingResultTmpl({ + 'text': msg, + 'streamingSchema': angular.toJson($scope.streamingMeta,true), + 'kfkSchema': angular.toJson($scope.kafkaMeta,true) + }), 'error', {}, true, 'top_center'); + } + loadingRequest.hide(); + }, function (e) { + if (e.data && e.data.exception) { + var message = e.data.exception; + var msg = !!(message) ? message : 'Failed to take action.'; + MessageService.sendMsg($scope.streamingResultTmpl({ + 'text': msg, + 'streamingSchema': angular.toJson($scope.streamingMeta,true), + 'kfkSchema': angular.toJson($scope.kafkaMeta,true) + }), 'error', {}, true, 'top_center'); + } else { + MessageService.sendMsg($scope.streamingResultTmpl({ + 'text': msg, + 'streamingSchema': angular.toJson($scope.streamingMeta,true), + 'kfkSchema': angular.toJson($scope.kafkaMeta,true) + }), 'error', {}, true, 'top_center'); + } + //end loading + loadingRequest.hide(); + + }) + } + + } + var StreamingSourceCtrl = function ($scope, $location,$interpolate,$templateCache, $modalInstance, tableNames, MessageService, projectName, scope, tableConfig,cubeConfig,StreamingModel,StreamingService) { $scope.cubeState={ @@ -462,6 +563,7 @@ KylinApp $scope.kafkaMeta = StreamingModel.createKafkaConfig(); + $scope.steps = { curStep:1 }; http://git-wip-us.apache.org/repos/asf/kylin/blob/1ceaf9ee/webapp/app/js/controllers/streamingConfig.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/streamingConfig.js b/webapp/app/js/controllers/streamingConfig.js index 33dae64..1caa32e 100644 --- a/webapp/app/js/controllers/streamingConfig.js +++ b/webapp/app/js/controllers/streamingConfig.js @@ -27,6 +27,19 @@ KylinApp.controller('streamingConfigCtrl', function ($scope,StreamingService, $q $scope.kafkaMeta = StreamingModel.createKafkaConfig(); } + if($scope.state.mode=='edit'&& $scope.state.target=='kfkConfig' && $scope.state.tableName){ + StreamingService.getConfig({table:$scope.state.tableName}, function (configs) { + if(!!configs[0]&&configs[0].name.toUpperCase() == $scope.state.tableName.toUpperCase()){ + $scope.updateStreamingMeta(configs[0]); + StreamingService.getKfkConfig({kafkaConfigName:$scope.streamingMeta.name}, function (streamings) { + if(!!streamings[0]&&streamings[0].name.toUpperCase() == $scope.state.tableName.toUpperCase()){ + $scope.updateKafkaMeta(streamings[0]); + } + }) + } + }) + } + $scope.addCluster = function () { $scope.kafkaMeta.clusters.push(StreamingModel.createKafkaCluster()); @@ -94,22 +107,30 @@ KylinApp.controller('streamingConfigCtrl', function ($scope,StreamingService, $q } //view model if($scope.state.mode == 'view' && $scope.tableModel.selectedSrcTable.source_type==1){ - var table = $scope.tableModel.selectedSrcTable; - var streamingName = table.database+"."+table.name; - $scope.streamingMeta = {}; - $scope.kafkaMeta = {}; - StreamingService.getConfig({table:streamingName}, function (configs) { - if(!!configs[0]&&configs[0].name.toUpperCase() == streamingName.toUpperCase()){ - $scope.streamingMeta = configs[0]; - StreamingService.getKfkConfig({kafkaConfigName:$scope.streamingMeta.name}, function (streamings) { - if(!!streamings[0]&&streamings[0].name.toUpperCase() == streamingName.toUpperCase()){ - $scope.kafkaMeta = streamings[0]; - } - }) - } - }) + $scope.reloadMeta(); } }); + $scope.$on('StreamingConfigEdited', function (event) { + $scope.reloadMeta(); + }); + + $scope.reloadMeta = function(){ + var table = $scope.tableModel.selectedSrcTable; + var streamingName = table.database+"."+table.name; + $scope.streamingMeta = {}; + $scope.kafkaMeta = {}; + StreamingService.getConfig({table:streamingName}, function (configs) { + if(!!configs[0]&&configs[0].name.toUpperCase() == streamingName.toUpperCase()){ + $scope.streamingMeta = configs[0]; + StreamingService.getKfkConfig({kafkaConfigName:$scope.streamingMeta.name}, function (streamings) { + if(!!streamings[0]&&streamings[0].name.toUpperCase() == streamingName.toUpperCase()){ + $scope.kafkaMeta = streamings[0]; + } + }) + } + }) + } + }); http://git-wip-us.apache.org/repos/asf/kylin/blob/1ceaf9ee/webapp/app/less/component.less ---------------------------------------------------------------------- diff --git a/webapp/app/less/component.less b/webapp/app/less/component.less index ed1c9b7..1102b49 100644 --- a/webapp/app/less/component.less +++ b/webapp/app/less/component.less @@ -1176,3 +1176,19 @@ ul.abn-tree li.abn-tree-row a { .modal-body.streaming-source .ace_editor { height: 600px !important; } + +.pdb-12{ + padding-bottom: 10px; +} + +.pdt-12{ + padding-top: 10px; +} + +.ofh{ + overflow: hidden; +} + +.floatR{ + float: right; +} http://git-wip-us.apache.org/repos/asf/kylin/blob/1ceaf9ee/webapp/app/partials/cubeDesigner/streamingConfig.html ---------------------------------------------------------------------- diff --git a/webapp/app/partials/cubeDesigner/streamingConfig.html b/webapp/app/partials/cubeDesigner/streamingConfig.html index 83acdd9..0148ac3 100644 --- a/webapp/app/partials/cubeDesigner/streamingConfig.html +++ b/webapp/app/partials/cubeDesigner/streamingConfig.html @@ -17,6 +17,7 @@ --> <div ng-controller="streamingConfigCtrl"> + <form name="form.cube_streaming_form" novalidate> <div> @@ -145,7 +146,7 @@ ng-class="{'has-error':form.cube_streaming_form.timeout.$invalid && (form.cube_streaming_form.timeout.$dirty||form.cube_streaming_form.$submitted)}"> <input ng-if="state.mode=='edit'" name="timeout" required ng-model="kafkaMeta.timeout" type="text" placeholder="Input kafkaConfig timeout" - ng-maxlength=100 ng-pattern="/^\+?[1-9][0-9]*$/" + ng-pattern="/^\+?[1-9][0-9]*$/" class="form-control"/> <small class="help-block" ng-show="!form.cube_streaming_form.timeout.$error.required && form.cube_streaming_form.timeout.$invalid && (form.cube_streaming_form.timeout.$dirty||form.cube_streaming_form.$submitted)"> @@ -171,7 +172,7 @@ ng-class="{'has-error':form.cube_streaming_form.bufferSize.$invalid && (form.cube_streaming_form.bufferSize.$dirty||form.cube_streaming_form.$submitted)}"> <input ng-if="state.mode=='edit'" name="bufferSize" required ng-model="kafkaMeta.bufferSize" type="text" placeholder="Input kafkaConfig bufferSize" - ng-maxlength=100 ng-pattern="/^\+?[1-9][0-9]*$/" + ng-pattern="/^\+?[1-9][0-9]*$/" class="form-control"/> <small class="help-block" ng-show="!form.cube_streaming_form.bufferSize.$error.required && form.cube_streaming_form.bufferSize.$invalid && (form.cube_streaming_form.bufferSize.$dirty||form.cube_streaming_form.$submitted)"> @@ -197,7 +198,7 @@ ng-class="{'has-error':form.cube_streaming_form.margin.$invalid && (form.cube_streaming_form.margin.$dirty||form.cube_streaming_form.$submitted)}"> <input ng-if="state.mode=='edit'" name="margin" required ng-model="kafkaMeta.margin" type="text" placeholder="Input kafkaConfig margin" - ng-maxlength=100 ng-pattern="/^\+?[1-9][0-9]*$/" + ng-pattern="/^\+?[1-9][0-9]*$/" class="form-control"/> <small class="help-block" ng-show="!form.cube_streaming_form.margin.$error.required && form.cube_streaming_form.margin.$invalid && (form.cube_streaming_form.margin.$dirty||form.cube_streaming_form.$submitted)"> @@ -248,7 +249,7 @@ </div> </div> </div> - <div class="form-group middle-popover" ng-if="state.mode=='edit'" ng-class="{'required':state.mode=='edit'}"> + <div class="form-group middle-popover" ng-if="state.mode=='edit'&&state.target!=='kfkConfig'" ng-class="{'required':state.mode=='edit'}"> <div class="row"> <label class="col-xs-12 col-sm-3 control-label no-padding-right"> <b>Parser Timestamp Field</b> http://git-wip-us.apache.org/repos/asf/kylin/blob/1ceaf9ee/webapp/app/partials/tables/table_detail.html ---------------------------------------------------------------------- diff --git a/webapp/app/partials/tables/table_detail.html b/webapp/app/partials/tables/table_detail.html index 5bae00f..361ccbf 100644 --- a/webapp/app/partials/tables/table_detail.html +++ b/webapp/app/partials/tables/table_detail.html @@ -153,6 +153,12 @@ <!--streaming--> <div id="streaming" ng-show="tableModel.selectedSrcTable.source_type==1" class="tab-pane"> + <div class="col-xs-12 pdb-12 pdt-12"> + <div class="ofh"> + <a class="btn btn-info floatR" ng-click="editStreamingConfig(tableModel.selectedSrcTable.database+'.'+tableModel.selectedSrcTable.name)"><i class="fa fa-edit"></i>Edit</a> + </div> + </div> + <div ng-include="'partials/cubeDesigner/streamingConfig.html'" ng-init="state.mode='view'"></div> </div> http://git-wip-us.apache.org/repos/asf/kylin/blob/1ceaf9ee/webapp/app/partials/tables/table_load.html ---------------------------------------------------------------------- diff --git a/webapp/app/partials/tables/table_load.html b/webapp/app/partials/tables/table_load.html index 834abda..5c72c15 100644 --- a/webapp/app/partials/tables/table_load.html +++ b/webapp/app/partials/tables/table_load.html @@ -71,3 +71,33 @@ </div> </div> </script> + +<script type="text/ng-template" id="editStreamingSource.html"> + + <div class="modal-header"> + <div class="box-header"> + <h3 class="box-title">Streaming Table And Cluster Info</h3> + + <div class="box-tools pull-right"> + <button type="button" class="btn btn-box-tool" ng-click="cancel()" data-widget="remove"><i class="fa fa-times"></i></button> + </div> + </div> + </div> + + <div class="modal-body streaming-source" style="height: 660px;overflow-y:auto;"> + <div ng-include="'partials/cubeDesigner/streamingConfig.html'"></div> + </div> + <div class="modal-footer"> + <div class="row"> + <div class="col-xs-8"> + <div> + </div> + </div> + <div class="col-xs-4"> + <button class="btn btn-primary" ng-click="updateStreamingSchema()"> + Submit + </button> + </div> + </div> + </div> +</script>