--- /dev/null
+/*-\r
+ * ================================================================================\r
+ * ECOMP Portal\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ================================================================================\r
+ */\r
+'use strict';\r
+(function () {\r
+\r
+ class SearchCtrl {\r
+ constructor($log, $scope, $cookies, $timeout, userProfileService, sessionService, dashboardService) {\r
+ $scope.firstName="";\r
+ $scope.lastName="";\r
+ \r
+ function showHideSearchSnippet() {\r
+ \r
+ setTimeout(function() {\r
+ jQuery("#mainSearchSnippet").click();\r
+ },500);\r
+ \r
+ setTimeout(function() {\r
+ jQuery("#mainSearchText").focus();\r
+ },1000);\r
+ }\r
+ \r
+ jQuery("#mainSearchDiv").keyup(function(event){\r
+ if(event.keyCode == 13){\r
+ // there is a watch on this variable which will trigger the database pull\r
+ dashboardService.searchString = jQuery("#mainSearchText").val();\r
+ \r
+ // opens the popup\r
+ var popupDomObj = jQuery("[content='searchSnippet.html']");\r
+ if(popupDomObj.length == 0) {\r
+ showHideSearchSnippet();\r
+ } else {\r
+ jQuery("#mainSearchSnippet").click();\r
+ showHideSearchSnippet();\r
+ }\r
+ \r
+ \r
+ \r
+ }\r
+ });\r
+ \r
+ \r
+ \r
+ }\r
+ \r
+ \r
+ }\r
+ \r
+ \r
+ class SearchSnippetCtrl {\r
+ constructor($log, $scope, $cookies, $timeout, userProfileService, sessionService, dashboardService,applicationsService, $window, $state) {\r
+ $scope.firstName="";\r
+ $scope.lastName="";\r
+ $scope.goToUrl = goToUrl;\r
+ $scope.dService = dashboardService;\r
+ \r
+ $scope.searchResDialog = false;\r
+ $scope.searchDialogToggle = function($event){\r
+ var keyCode = $event.which || $event.keyCode;\r
+ if (keyCode === 13) {\r
+ $scope.searchResDialog = true; \r
+ dashboardService.searchString = jQuery("#mainSearchText").val();\r
+ }\r
+ \r
+ }\r
+ \r
+ window.onclick = function() {\r
+ if ($scope.searchResDialog) {\r
+ $scope.searchResDialog = false;\r
+ $scope.$apply();\r
+ }\r
+ }; \r
+ function goToUrl (item, type) {\r
+ $log.info("goToUrl called")\r
+ $log.info(item + "/" + type);\r
+ \r
+ \r
+ if(type == 'intra') {\r
+ \r
+ var intraSearcLink = "";\r
+ var intraSpecSearcLink = intraSearcLink + encodeURIComponent(dashboardService.searchString);\r
+ $window.open(intraSpecSearcLink, '_blank');\r
+ \r
+ } else if (type == 'extra') {\r
+ var extraSearcLink = "";\r
+ var extraSpecSearcLink = extraSearcLink + encodeURIComponent(dashboardService.searchString);\r
+ $window.open(extraSpecSearcLink, '_blank');\r
+ }\r
+\r
+ let url = item.target;\r
+ let restrictedApp = item.uuid;\r
+ let getAccessState = "root.getAccess"\r
+ if (!url) {\r
+ \r
+ applicationsService.goGetAccessAppName = item.name;\r
+ if($state.current.name == getAccessState)\r
+ $state.reload();\r
+ else\r
+ $state.go(getAccessState);\r
+ //$log.info('No url found for this application, doing nothing..');\r
+ return;\r
+ }\r
+ \r
+ if (restrictedApp != "true") {\r
+ $window.open(url, '_blank');\r
+ } else {\r
+ if(item.url=="root.access"){\r
+ $state.go(url);\r
+ var tabContent = { id: new Date(), title: 'Home', url: url };\r
+ $cookies.putObject('addTab', tabContent );\r
+ } else {\r
+ var tabContent = { id: new Date(), title: item.name, url: url };\r
+ $cookies.putObject('addTab', tabContent );\r
+ }\r
+ }\r
+\r
+ }\r
+ \r
+ function getItems(searchString) {\r
+ \r
+ var items;\r
+ var itemMap = dashboardService.getSearchAllByStringResults(searchString) \r
+ .then(res => {\r
+ $scope.items = res;\r
+ \r
+ \r
+ }).catch(err => {\r
+ $scope.items = [];\r
+ $log.error('Couldnt get search results...', err)\r
+ });\r
+\r
+ }\r
+ \r
+ $scope.$watch('dService.searchString', function(searchString) {\r
+ if(searchString != undefined )\r
+ getItems(searchString);\r
+\r
+ });\r
+ \r
+ \r
+ \r
+ }\r
+ \r
+ \r
+ \r
+ }\r
+ \r
+ \r
+\r
+ SearchCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService', 'dashboardService'];\r
+ SearchSnippetCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService', 'dashboardService','applicationsService', '$window','$state'];\r
+ angular.module('ecompApp').controller('searchCtrl', SearchCtrl); \r
+ angular.module('ecompApp').controller('searchSnippetCtrl', SearchSnippetCtrl);\r
+ angular.module('ecompApp').directive('searchBox', function() {\r
+ return {\r
+ restrict: "E",\r
+ templateUrl: 'app/views/search/search.tpl.html',\r
+ link: function(scope, element) {\r
+ \r
+ //var iframeId = "#tabframe-" + scope.$parent.tab.title.split(' ').join('-');\r
+ // jQuery(iframeId).load(function() {\r
+ // alert("hello");\r
+ // }); //.attr("src",'{{tab.content | trusted}}' ); //src='{{tab.content | trusted}}'\r
+ // jQuery(iframeId).attr('src', '{{tab.content | trusted}}');\r
+ \r
+ //element.childNodes[0].on('load', function() {\r
+ // alert('hello');\r
+ //});\r
+ }\r
+ }\r
+ });\r
+ angular.module( 'ecompApp' ).config( [\r
+ '$compileProvider',\r
+ function( $compileProvider )\r
+ { \r
+ $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension|qto):/);\r
+ }\r
+ ]);\r
+\r
+})();\r
+\r
+\r