2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
24 constructor($log, $scope, $cookies, $timeout, userProfileService, sessionService, dashboardService) {
28 function showHideSearchSnippet() {
30 setTimeout(function() {
31 jQuery("#mainSearchSnippet").click();
34 setTimeout(function() {
35 jQuery("#mainSearchText").focus();
39 jQuery("#mainSearchDiv").keyup(function(event){
40 if(event.keyCode == 13){
41 // there is a watch on this variable which will trigger the database pull
42 dashboardService.searchString = jQuery("#mainSearchText").val();
45 var popupDomObj = jQuery("[content='searchSnippet.html']");
46 if(popupDomObj.length == 0) {
47 showHideSearchSnippet();
49 jQuery("#mainSearchSnippet").click();
50 showHideSearchSnippet();
66 class SearchSnippetCtrl {
67 constructor($log, $scope, $cookies, $timeout, userProfileService, sessionService, dashboardService,applicationsService, $window, $state) {
70 $scope.goToUrl = goToUrl;
71 $scope.dService = dashboardService;
75 function goToUrl (item, type) {
76 $log.info("goToUrl called")
77 $log.info(item + "/" + type);
82 var intraSearcLink = "http://to_do_link.com";
83 var intraSpecSearcLink = intraSearcLink + encodeURIComponent(dashboardService.searchString);
84 $window.open(intraSpecSearcLink, '_blank');
86 } else if (type == 'extra') {
87 var extraSearcLink = "https://to_do_link.com";
88 var extraSpecSearcLink = extraSearcLink + encodeURIComponent(dashboardService.searchString);
89 $window.open(extraSpecSearcLink, '_blank');
92 let url = item.target;
93 let restrictedApp = item.uuid;
94 let getAccessState = "root.getAccess"
97 applicationsService.goGetAccessAppName = item.name;
98 if($state.current.name == getAccessState)
101 $state.go(getAccessState);
102 //$log.info('No url found for this application, doing nothing..');
106 if (restrictedApp != "true") {
107 $window.open(url, '_blank');
109 if(item.url=="root.access"){
111 var tabContent = { id: new Date(), title: 'Home', url: url };
112 $cookies.putObject('addTab', tabContent );
114 var tabContent = { id: new Date(), title: item.name, url: url };
115 $cookies.putObject('addTab', tabContent );
121 function getItems(searchString) {
124 var itemMap = dashboardService.getSearchAllByStringResults(searchString)
131 $log.error('Couldnt get search results...', err)
136 $scope.$watch('dService.searchString', function(searchString) {
137 if(searchString != undefined )
138 getItems(searchString);
152 SearchCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService', 'dashboardService'];
153 SearchSnippetCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService', 'dashboardService','applicationsService', '$window','$state'];
154 angular.module('ecompApp').controller('searchCtrl', SearchCtrl);
155 angular.module('ecompApp').controller('searchSnippetCtrl', SearchSnippetCtrl);
156 angular.module('ecompApp').directive('searchBox', function() {
159 templateUrl: 'app/views/search/search.tpl.html',
160 link: function(scope, element) {
162 //var iframeId = "#tabframe-" + scope.$parent.tab.title.split(' ').join('-');
163 // jQuery(iframeId).load(function() {
165 // }); //.attr("src",'{{tab.content | trusted}}' ); //src='{{tab.content | trusted}}'
166 // jQuery(iframeId).attr('src', '{{tab.content | trusted}}');
168 //element.childNodes[0].on('load', function() {
174 angular.module( 'ecompApp' ).config( [
176 function( $compileProvider )
178 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension|qto):/);