Iftekharul Islam | 0805441 | 2017-08-25 10:29:57 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Controller for index |
| 3 | * |
| 4 | * @module app/multi-server |
| 5 | * @exports multiServerController |
| 6 | * @name multiServerController |
Iftekharul Islam | 0805441 | 2017-08-25 10:29:57 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 9 | window.angular && (function(angular) { |
| 10 | 'use strict'; |
Iftekharul Islam | 0805441 | 2017-08-25 10:29:57 -0500 | [diff] [blame] | 11 | |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 12 | angular.module('app.overview').controller('multiServerController', [ |
| 13 | '$scope', '$window', 'APIUtils', 'dataService', |
| 14 | function($scope, $window, APIUtils, dataService) { |
| 15 | $scope.dataService = dataService; |
| 16 | $scope.customSearch = ''; |
| 17 | $scope.searchTerms = []; |
| 18 | $scope.loading = false; |
| 19 | $scope.clear = function() { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 20 | $scope.customSearch = ''; |
| 21 | $scope.searchTerms = []; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 22 | }; |
Iftekharul Islam | 0805441 | 2017-08-25 10:29:57 -0500 | [diff] [blame] | 23 | |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 24 | $scope.doSearchOnEnter = function(event) { |
| 25 | var search = |
| 26 | $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, ''); |
| 27 | if (event.keyCode === 13 && search.length >= 2) { |
| 28 | $scope.searchTerms = $scope.customSearch.split(' '); |
| 29 | } else { |
| 30 | if (search.length == 0) { |
| 31 | $scope.searchTerms = []; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 32 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 33 | } |
| 34 | }; |
Iftekharul Islam | 0805441 | 2017-08-25 10:29:57 -0500 | [diff] [blame] | 35 | |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 36 | $scope.doSearchOnClick = function() { |
| 37 | var search = |
| 38 | $scope.customSearch.replace(/^\s+/g, '').replace(/\s+$/g, ''); |
| 39 | if (search.length >= 2) { |
| 40 | $scope.searchTerms = $scope.customSearch.split(' '); |
| 41 | } else { |
| 42 | if (search.length == 0) { |
| 43 | $scope.searchTerms = []; |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 44 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 45 | } |
| 46 | }; |
| 47 | $scope.addServer = function() { |
| 48 | $scope.multi_server_add = !$scope.multi_server_add; |
| 49 | }; |
| 50 | } |
| 51 | ]); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 52 | })(angular); |