blob: f262f5fd0f01d017064802771b6179e4cbd0ce1f [file] [log] [blame]
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001window.angular && (function(angular) {
2 'use strict';
Iftekharul Islam8b4828a2017-04-19 14:37:55 -05003
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004 angular
5 .module('app.common.directives')
6 .directive('logSearchControl', ['APIUtils', function(APIUtils) {
7 return {
8 'restrict': 'E',
9 'template': require('./log-search-control.html'),
10 'controller': ['$rootScope', '$scope', 'dataService', '$location', function($rootScope, $scope, dataService, $location) {
11 $scope.dataService = dataService;
12 $scope.doSearchOnEnter = function(event) {
13 var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
14 if (event.keyCode === 13 &&
15 search.length >= 2) {
16 $scope.clearSearchItem();
17 $scope.addSearchItem(search);
18 }
19 else {
20 if (search.length == 0) {
21 $scope.clearSearchItem();
22 }
23 }
24 };
Iftekharul Islam8b4828a2017-04-19 14:37:55 -050025
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070026 $scope.clear = function() {
27 $scope.customSearch = '';
28 $scope.clearSearchItem();
29 };
Iftekharul Islam171c6a12017-08-11 08:35:47 -050030
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070031 $scope.doSearchOnClick = function() {
32 var search = $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, '');
33 if (search.length >= 2) {
34 $scope.clearSearchItem();
35 $scope.addSearchItem(search);
36 }
37 else {
38 if (search.length == 0) {
39 $scope.clearSearchItem();
40 }
41 }
42 };
43 }]
44 };
45 }]);
Iftekharul Islam8b4828a2017-04-19 14:37:55 -050046})(window.angular);