Updates for restriction timespan.

This commit is contained in:
kunw 2016-11-17 12:17:07 +08:00
parent 00c41c5860
commit 15c713f927
4 changed files with 32 additions and 4 deletions

View File

@ -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) {

View File

@ -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'];

View File

@ -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.'
};

View File

@ -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': '起始日期不能晚于结束日期。'
};