Repository: kylin Updated Branches: refs/heads/1.x-staging f86314869 -> 2f5d89a8e
minor,use angularjs to convert GMT0 timestamp for partition_date Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/2f5d89a8 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/2f5d89a8 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/2f5d89a8 Branch: refs/heads/1.x-staging Commit: 2f5d89a8eda0db57e669063c6af887293f31575d Parents: f863148 Author: jian <zhongj...@apache.org> Authored: Thu Jan 21 01:32:48 2016 +0800 Committer: jian <zhongj...@apache.org> Committed: Thu Jan 21 01:33:12 2016 +0800 ---------------------------------------------------------------------- webapp/app/js/controllers/cubeEdit.js | 16 ------------- webapp/app/js/controllers/cubes.js | 12 ---------- webapp/app/js/directives/directives.js | 24 +++++++++++++++++++- webapp/app/js/model/metaModel.js | 5 ---- .../app/partials/cubeDesigner/incremental.html | 3 +-- webapp/app/partials/jobs/job_submit.html | 11 ++------- 6 files changed, 26 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/2f5d89a8/webapp/app/js/controllers/cubeEdit.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/cubeEdit.js b/webapp/app/js/controllers/cubeEdit.js index 1178bee..0095fde 100755 --- a/webapp/app/js/controllers/cubeEdit.js +++ b/webapp/app/js/controllers/cubeEdit.js @@ -95,13 +95,6 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio if (model) { MetaModel.setMetaModel(model); $scope.metaModel = MetaModel; - - //use - //convert GMT mills ,to make sure partition date show GMT Date - //should run only one time - if (model.partition_desc && model.partition_desc.partition_date_start) { - MetaModel.converDateToGMT(); - } } }); $scope.state.cubeSchema = angular.toJson($scope.cubeMetaFrame, true); @@ -129,11 +122,6 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio if ($scope.metaModel.model.partition_desc.partition_date_column && ($scope.metaModel.model.partition_desc.partition_date_start | $scope.metaModel.model.partition_desc.partition_date_start == 0)) { - var dateStart = new Date($scope.metaModel.model.partition_desc.partition_date_start); - dateStart = (dateStart.getFullYear() + "-" + (dateStart.getMonth() + 1) + "-" + dateStart.getDate()); - //switch selected time to utc timestamp - $scope.metaModel.model.partition_desc.partition_date_start = new Date(moment.utc(dateStart, "YYYY-MM-DD").format()).getTime(); - if ($scope.metaModel.model.partition_desc.partition_date_column.indexOf(".") == -1) { $scope.metaModel.model.partition_desc.partition_date_column = $scope.metaModel.model.fact_table + "." + $scope.metaModel.model.partition_desc.partition_date_column; @@ -286,10 +274,6 @@ KylinApp.controller('CubeEditCtrl', function ($scope, $q, $routeParams, $locatio // reverse the date $scope.saveCubeRollBack = function () { - if ($scope.metaModel.model && ($scope.metaModel.model.partition_desc.partition_date_start || $scope.metaModel.model.partition_desc.partition_date_start == 0)) { - $scope.metaModel.model.partition_desc.partition_date_start += new Date().getTimezoneOffset() * 60000; - } - //update model last modified $scope.statusRefresh(); } http://git-wip-us.apache.org/repos/asf/kylin/blob/2f5d89a8/webapp/app/js/controllers/cubes.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/cubes.js b/webapp/app/js/controllers/cubes.js index d277dc1..2896a1a 100755 --- a/webapp/app/js/controllers/cubes.js +++ b/webapp/app/js/controllers/cubes.js @@ -457,8 +457,6 @@ var jobSubmitCtrl = function ($scope, $modalInstance, CubeService, MessageServic $scope.rebuild = function (jobsubmit) { $scope.message = null; - $scope.jobBuildRequest.startTime = new Date($scope.jobBuildRequest.startTime).getTime(); - $scope.jobBuildRequest.endTime = new Date($scope.jobBuildRequest.endTime).getTime(); if ($scope.jobBuildRequest.startTime >= $scope.jobBuildRequest.endTime) { $scope.message = "WARNING: End time should be later than the start time."; @@ -548,16 +546,6 @@ var jobSubmitCtrl = function ($scope, $modalInstance, CubeService, MessageServic } }; - $scope.updateDate = function () { - $scope.jobBuildRequest.endTime = $scope.formatDate($scope.jobBuildRequest.endTime); - }; - - $scope.formatDate = function (timestemp) { - var dateStart = new Date(timestemp); - dateStart = (dateStart.getFullYear() + "-" + (dateStart.getMonth() + 1) + "-" + dateStart.getDate()); - //switch selected time to utc timestamp - return new Date(moment.utc(dateStart, "YYYY-MM-DD").format()).getTime(); - }; $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; http://git-wip-us.apache.org/repos/asf/kylin/blob/2f5d89a8/webapp/app/js/directives/directives.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/directives/directives.js b/webapp/app/js/directives/directives.js index 7e2dbf9..f73b8a8 100644 --- a/webapp/app/js/directives/directives.js +++ b/webapp/app/js/directives/directives.js @@ -206,4 +206,26 @@ KylinApp.directive('kylinPagination', function ($parse, $q) { }); } } - }); + }).directive('datepickerTimezone', function () { + // this directive workaround to convert GMT0 timestamp to GMT date for datepicker + return { + restrict: 'A', + priority: 1, + require: 'ngModel', + link: function (scope, element, attrs, ctrl) { + ctrl.$formatters.push(function (value) { + //return value; + var date = new Date(value + (60000 * new Date().getTimezoneOffset())); + return date; + }); + + ctrl.$parsers.push(function (value) { + if (isNaN(value)) { + return value; + } + value = new Date(value.getFullYear(), value.getMonth(), value.getDate(), 0, 0, 0, 0); + return value.getTime()-(60000 * value.getTimezoneOffset()); + }); + } + }; + });; http://git-wip-us.apache.org/repos/asf/kylin/blob/2f5d89a8/webapp/app/js/model/metaModel.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/model/metaModel.js b/webapp/app/js/model/metaModel.js index 8afd273..d714ff4 100644 --- a/webapp/app/js/model/metaModel.js +++ b/webapp/app/js/model/metaModel.js @@ -58,11 +58,6 @@ KylinApp.service('MetaModel', function () { }; - this.converDateToGMT = function () { - if (this.model.partition_desc && this.model.partition_desc.partition_date_start) { - this.model.partition_desc.partition_date_start += new Date().getTimezoneOffset() * 60000; - } - }; // this.createNew = function () { var metaModel = { http://git-wip-us.apache.org/repos/asf/kylin/blob/2f5d89a8/webapp/app/partials/cubeDesigner/incremental.html ---------------------------------------------------------------------- diff --git a/webapp/app/partials/cubeDesigner/incremental.html b/webapp/app/partials/cubeDesigner/incremental.html index 808305f..1531abd 100755 --- a/webapp/app/partials/cubeDesigner/incremental.html +++ b/webapp/app/partials/cubeDesigner/incremental.html @@ -61,8 +61,7 @@ <div class="row"> <label class="control-label col-xs-12 col-sm-3 no-padding-right font-color-default"><b>Start Date</b></label> <div class="col-xs-12 col-sm-6"> - <!--edit model will convert in MetaModel.converDateToGMT--> - <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd" + <input type="text" class="form-control" datepicker-popup="yyyy-MM-dd" datepicker-timezone ng-model="metaModel.model.partition_desc.partition_date_start" ng-if="state.mode=='edit'" placeholder="Click to choose start date..." is-open="opened" /> <!--vier model will convert use filter--> http://git-wip-us.apache.org/repos/asf/kylin/blob/2f5d89a8/webapp/app/partials/jobs/job_submit.html ---------------------------------------------------------------------- diff --git a/webapp/app/partials/jobs/job_submit.html b/webapp/app/partials/jobs/job_submit.html index 1036dee..390cb3e 100644 --- a/webapp/app/partials/jobs/job_submit.html +++ b/webapp/app/partials/jobs/job_submit.html @@ -46,20 +46,13 @@ <div ng-if="metaModel.model.partition_desc.partition_type=='APPEND'"> {{ jobBuildRequest.startTime = cube.segments[cube.segments.length-1].date_range_end| reverseToGMT0 }} </div> - <!--<div ng-if="metaModel.model.partition_desc.cube_partition_type=='UPDATE_INSERT'">--> - <!--<!–<datepicker ng-model="jobBuildRequest.startTime" show-weeks="true"–>--> - <!--<!–required class="well well-sm"></datepicker>–>--> - <!--<input type="text" datepicker-popup="yyyy-MM-dd" class="input-sm" style="width: 98%"--> - <!--ng-model="jobBuildRequest.startTime"--> - <!--placeholder="Click to choose START date..." is-open="opened" />--> - <!--</div>--> </div> </td> </tr> <tr> <td>End Date (Exclude)</td> <td> - <input type="text" datepicker-popup="yyyy-MM-dd" class="input-sm" style="width: 98%" + <input type="text" datepicker-popup="yyyy-MM-dd" datepicker-timezone class="input-sm" style="width: 98%" ng-model="jobBuildRequest.endTime" placeholder="Click to choose END date..." is-open="opened" /> </td> @@ -79,7 +72,7 @@ </div> </div> <div class="modal-footer"> - <button class="btn btn-success" ng-click="updateDate();rebuild(true)" ng-disabled="jobBuildRequest.endTime<=0">Submit</button> + <button class="btn btn-success" ng-click="rebuild(true)" ng-disabled="jobBuildRequest.endTime<=0">Submit</button> <button class="btn btn-primary" ng-click="cancel()">Close</button> </div> </script>