2016-07-07 18:03:32 +02:00
|
|
|
/*
|
|
|
|
Copyright (c) 2016 VMware, Inc. All Rights Reserved.
|
|
|
|
Licensed 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.
|
|
|
|
*/
|
2016-04-22 18:49:52 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.log')
|
|
|
|
.directive('advancedSearch', advancedSearch);
|
|
|
|
|
2016-04-25 08:31:05 +02:00
|
|
|
AdvancedSearchController.$inject = ['$scope', 'ListLogService'];
|
2016-04-22 18:49:52 +02:00
|
|
|
|
2016-04-25 08:31:05 +02:00
|
|
|
function AdvancedSearchController($scope, ListLogService) {
|
2016-04-22 18:49:52 +02:00
|
|
|
var vm = this;
|
2016-04-28 19:36:39 +02:00
|
|
|
|
2016-04-22 18:49:52 +02:00
|
|
|
vm.checkOperation = checkOperation;
|
2016-06-28 02:10:58 +02:00
|
|
|
vm.close = close;
|
2016-04-22 18:49:52 +02:00
|
|
|
|
|
|
|
vm.opAll = true;
|
2016-07-04 11:09:45 +02:00
|
|
|
|
2016-07-04 13:09:19 +02:00
|
|
|
vm.doSearch = doSearch;
|
|
|
|
|
2016-07-04 11:09:45 +02:00
|
|
|
$scope.$watch('vm.op', function(current) {
|
|
|
|
if(current && vm.op[0] === 'all') {
|
|
|
|
vm.opCreate = true;
|
|
|
|
vm.opPull = true;
|
|
|
|
vm.opPush = true;
|
|
|
|
vm.opDelete = true;
|
|
|
|
vm.opOthers = true;
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
|
|
|
|
$scope.$watch('vm.fromDate', function(current) {
|
|
|
|
if(current) {
|
|
|
|
vm.fromDate = current;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.$watch('vm.toDate', function(current) {
|
|
|
|
if(current) {
|
|
|
|
vm.toDate = current;
|
|
|
|
}
|
|
|
|
});
|
2016-07-04 13:09:19 +02:00
|
|
|
|
|
|
|
|
2016-04-22 18:49:52 +02:00
|
|
|
vm.opCreate = true;
|
|
|
|
vm.opPull = true;
|
|
|
|
vm.opPush = true;
|
|
|
|
vm.opDelete = true;
|
|
|
|
vm.opOthers = true;
|
2016-07-04 13:09:19 +02:00
|
|
|
vm.others = '';
|
2016-04-28 19:36:39 +02:00
|
|
|
|
2016-04-25 08:31:05 +02:00
|
|
|
vm.op = [];
|
|
|
|
vm.op.push('all');
|
2016-04-22 18:49:52 +02:00
|
|
|
function checkOperation(e) {
|
2016-05-23 12:29:17 +02:00
|
|
|
if(e.checked === 'all') {
|
2016-04-22 18:49:52 +02:00
|
|
|
vm.opCreate = vm.opAll;
|
|
|
|
vm.opPull = vm.opAll;
|
|
|
|
vm.opPush = vm.opAll;
|
|
|
|
vm.opDelete = vm.opAll;
|
|
|
|
vm.opOthers = vm.opAll;
|
2016-04-25 08:31:05 +02:00
|
|
|
}else {
|
|
|
|
vm.opAll = false;
|
|
|
|
}
|
|
|
|
|
2016-07-05 03:06:36 +02:00
|
|
|
vm.op = [];
|
|
|
|
|
2016-04-25 08:31:05 +02:00
|
|
|
if(vm.opCreate) {
|
|
|
|
vm.op.push('create');
|
|
|
|
}
|
|
|
|
if(vm.opPull) {
|
2016-07-04 13:09:19 +02:00
|
|
|
vm.op.push('pull');
|
2016-04-25 08:31:05 +02:00
|
|
|
}
|
|
|
|
if(vm.opPush) {
|
2016-07-04 13:09:19 +02:00
|
|
|
vm.op.push('push');
|
2016-04-25 08:31:05 +02:00
|
|
|
}
|
|
|
|
if(vm.opDelete) {
|
2016-07-04 13:09:19 +02:00
|
|
|
vm.op.push('delete');
|
|
|
|
}
|
|
|
|
if(vm.opOthers && $.trim(vm.others) !== '') {
|
|
|
|
vm.op.push($.trim(vm.others));
|
2016-04-22 18:49:52 +02:00
|
|
|
}
|
2016-04-28 19:36:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
vm.pickUp = pickUp;
|
|
|
|
|
|
|
|
function pickUp(e) {
|
|
|
|
switch(e.key){
|
|
|
|
case 'fromDate':
|
|
|
|
vm.fromDate = e.value;
|
|
|
|
break;
|
|
|
|
case 'toDate':
|
|
|
|
vm.toDate = e.value;
|
|
|
|
break;
|
2016-04-25 08:31:05 +02:00
|
|
|
}
|
2016-04-28 19:36:39 +02:00
|
|
|
$scope.$apply();
|
2016-04-22 18:49:52 +02:00
|
|
|
}
|
2016-04-28 19:36:39 +02:00
|
|
|
|
2016-06-28 02:10:58 +02:00
|
|
|
function close() {
|
2016-07-04 11:09:45 +02:00
|
|
|
vm.op = [];
|
|
|
|
vm.op.push('all');
|
|
|
|
vm.fromDate = '';
|
|
|
|
vm.toDate = '';
|
|
|
|
vm.others = '';
|
2016-06-28 02:10:58 +02:00
|
|
|
vm.isOpen = false;
|
|
|
|
}
|
2016-07-04 13:09:19 +02:00
|
|
|
|
|
|
|
function doSearch (e){
|
|
|
|
if(vm.opOthers && $.trim(vm.others) !== '') {
|
|
|
|
e.op.push(vm.others);
|
|
|
|
}
|
|
|
|
vm.search(e);
|
|
|
|
}
|
2016-04-22 18:49:52 +02:00
|
|
|
}
|
|
|
|
|
2016-07-06 19:12:20 +02:00
|
|
|
function advancedSearch(I18nService) {
|
2016-04-22 18:49:52 +02:00
|
|
|
var directive = {
|
|
|
|
'restrict': 'E',
|
2016-06-16 08:10:35 +02:00
|
|
|
'templateUrl': '/static/resources/js/components/log/advanced-search.directive.html',
|
2016-04-22 18:49:52 +02:00
|
|
|
'scope': {
|
2016-04-27 12:29:55 +02:00
|
|
|
'isOpen': '=',
|
|
|
|
'op': '=',
|
2016-07-04 13:09:19 +02:00
|
|
|
'opOthers': '=',
|
2016-04-27 12:29:55 +02:00
|
|
|
'others': '=',
|
2016-04-28 19:36:39 +02:00
|
|
|
'fromDate': '=',
|
|
|
|
'toDate': '=',
|
2016-04-27 12:29:55 +02:00
|
|
|
'search': '&'
|
2016-04-22 18:49:52 +02:00
|
|
|
},
|
2016-04-28 19:36:39 +02:00
|
|
|
'link': link,
|
2016-04-22 18:49:52 +02:00
|
|
|
'controller': AdvancedSearchController,
|
|
|
|
'controllerAs': 'vm',
|
|
|
|
'bindToController': true
|
|
|
|
};
|
|
|
|
return directive;
|
2016-04-28 19:36:39 +02:00
|
|
|
|
|
|
|
function link(scope, element, attrs, ctrl) {
|
|
|
|
element.find('.datetimepicker').datetimepicker({
|
2016-07-06 19:12:20 +02:00
|
|
|
locale: I18nService().getCurrentLanguage(),
|
2016-04-28 19:36:39 +02:00
|
|
|
ignoreReadonly: true,
|
|
|
|
format: 'L',
|
|
|
|
showClear: true
|
|
|
|
});
|
|
|
|
element.find('#fromDatePicker').on('blur', function(){
|
|
|
|
ctrl.pickUp({'key': 'fromDate', 'value': $(this).val()});
|
|
|
|
});
|
|
|
|
element.find('#toDatePicker').on('blur', function(){
|
|
|
|
ctrl.pickUp({'key': 'toDate', 'value': $(this).val()});
|
|
|
|
});
|
2016-07-08 03:24:27 +02:00
|
|
|
|
2016-04-28 19:36:39 +02:00
|
|
|
}
|
2016-04-22 18:49:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
})();
|