From 15c713f9271032c727142a78896cc185bb2ca92a Mon Sep 17 00:00:00 2001 From: kunw Date: Thu, 17 Nov 2016 12:17:07 +0800 Subject: [PATCH] Updates for restriction timespan. --- .../components/log/advanced-search.directive.js | 17 +++++++++++++++-- .../replication/list-replication.directive.js | 13 +++++++++++++ .../js/services/i18n/locale_messages_en-US.js | 3 ++- .../js/services/i18n/locale_messages_zh-CN.js | 3 ++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/ui/static/resources/js/components/log/advanced-search.directive.js b/src/ui/static/resources/js/components/log/advanced-search.directive.js index 31a858deb..338c717dc 100644 --- a/src/ui/static/resources/js/components/log/advanced-search.directive.js +++ b/src/ui/static/resources/js/components/log/advanced-search.directive.js @@ -20,9 +20,9 @@ .module('harbor.log') .directive('advancedSearch', advancedSearch); - AdvancedSearchController.$inject = ['$scope', 'ListLogService']; + AdvancedSearchController.$inject = ['$scope', 'ListLogService', '$filter', 'trFilter']; - function AdvancedSearchController($scope, ListLogService) { + function AdvancedSearchController($scope, ListLogService, $filter, trFilter) { var vm = this; vm.checkOperation = checkOperation; @@ -121,8 +121,21 @@ if(vm.opOthers && $.trim(vm.others) !== '') { e.op.push(vm.others); } + if(vm.fromDate && vm.toDate && (getDateValue(vm.fromDate) > getDateValue(vm.toDate))) { + $scope.$emit('modalTitle', $filter('tr')('error')); + $scope.$emit('modalMessage', $filter('tr')('begin_date_is_later_than_end_date')); + $scope.$emit('raiseError', true); + return + } vm.search(e); } + + function getDateValue(date) { + if(date) { + return new Date(date); + } + return 0; + } } function advancedSearch(I18nService) { diff --git a/src/ui/static/resources/js/components/replication/list-replication.directive.js b/src/ui/static/resources/js/components/replication/list-replication.directive.js index 166afdcc0..94b820220 100644 --- a/src/ui/static/resources/js/components/replication/list-replication.directive.js +++ b/src/ui/static/resources/js/components/replication/list-replication.directive.js @@ -105,6 +105,12 @@ } function refreshReplicationJob() { + if(vm.fromDate && vm.toDate && (getDateValue(vm.fromDate) > getDateValue(vm.toDate))) { + $scope.$emit('modalTitle', $filter('tr')('error')); + $scope.$emit('modalMessage', $filter('tr')('begin_date_is_later_than_end_date')); + $scope.$emit('raiseError', true); + return; + } if(vm.lastPolicyId !== -1) { vm.refreshJobTIP = true; vm.retrieveJob(vm.lastPolicyId, vm.page, vm.pageSize); @@ -288,6 +294,13 @@ return t.getTime() / 1000; } + function getDateValue(date) { + if(date) { + return new Date(date); + } + return 0; + } + } listReplication.inject = ['$timeout', 'I18nService']; diff --git a/src/ui/static/resources/js/services/i18n/locale_messages_en-US.js b/src/ui/static/resources/js/services/i18n/locale_messages_en-US.js index fb41cd4b6..4cc8a3a6f 100644 --- a/src/ui/static/resources/js/services/i18n/locale_messages_en-US.js +++ b/src/ui/static/resources/js/services/i18n/locale_messages_en-US.js @@ -282,5 +282,6 @@ var locale_messages = { 'confirm_to_toggle_enabled_policy_title': 'Enable Policy', 'confirm_to_toggle_enabled_policy': 'After enabling the replication policy, all repositories under the project will be replicated to the destination registry. Please confirm to continue.', 'confirm_to_toggle_disabled_policy_title': 'Disable Policy', - 'confirm_to_toggle_disabled_policy': 'After disabling the policy, all unfinished replication jobs of this policy will be stopped and canceled. Please confirm to continue.' + 'confirm_to_toggle_disabled_policy': 'After disabling the policy, all unfinished replication jobs of this policy will be stopped and canceled. Please confirm to continue.', + 'begin_date_is_later_than_end_date': 'Begin date should not be later than end date.' }; diff --git a/src/ui/static/resources/js/services/i18n/locale_messages_zh-CN.js b/src/ui/static/resources/js/services/i18n/locale_messages_zh-CN.js index 777589bc5..6ab9329b5 100644 --- a/src/ui/static/resources/js/services/i18n/locale_messages_zh-CN.js +++ b/src/ui/static/resources/js/services/i18n/locale_messages_zh-CN.js @@ -284,5 +284,6 @@ var locale_messages = { 'confirm_to_toggle_enabled_policy_title': '启用策略', 'confirm_to_toggle_enabled_policy': '启用策略后,该项目下的所有镜像仓库将复制到目标实例。请确认继续。', 'confirm_to_toggle_disabled_policy_title': '停用策略', - 'confirm_to_toggle_disabled_policy': '停用策略后,所有未完成的复制任务将被终止和取消。请确认继续。' + 'confirm_to_toggle_disabled_policy': '停用策略后,所有未完成的复制任务将被终止和取消。请确认继续。', + 'begin_date_is_later_than_end_date': '起始日期不能晚于结束日期。' };