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;
73 $scope.searchResDialog = false;
74 $scope.searchDialogToggle = function($event){
75 var keyCode = $event.which || $event.keyCode;
77 $scope.searchResDialog = true;
78 dashboardService.searchString = jQuery("#mainSearchText").val();
83 window.onclick = function() {
84 if ($scope.searchResDialog) {
85 $scope.searchResDialog = false;
89 function goToUrl (item, type) {
90 $log.info("goToUrl called")
91 $log.info(item + "/" + type);
96 var intraSearcLink = "";
97 var intraSpecSearcLink = intraSearcLink + encodeURIComponent(dashboardService.searchString);
98 $window.open(intraSpecSearcLink, '_blank');
100 } else if (type == 'extra') {
101 var extraSearcLink = "";
102 var extraSpecSearcLink = extraSearcLink + encodeURIComponent(dashboardService.searchString);
103 $window.open(extraSpecSearcLink, '_blank');
106 let url = item.target;
107 let restrictedApp = item.uuid;
108 let getAccessState = "root.getAccess"
111 applicationsService.goGetAccessAppName = item.name;
112 if($state.current.name == getAccessState)
115 $state.go(getAccessState);
116 //$log.info('No url found for this application, doing nothing..');
120 if (restrictedApp != "true") {
121 $window.open(url, '_blank');
123 if(item.url=="root.access"){
125 var tabContent = { id: new Date(), title: 'Home', url: url };
126 $cookies.putObject('addTab', tabContent );
128 var tabContent = { id: new Date(), title: item.name, url: url };
129 $cookies.putObject('addTab', tabContent );
135 function getItems(searchString) {
138 var itemMap = dashboardService.getSearchAllByStringResults(searchString)
145 $log.error('Couldnt get search results...', err)
150 $scope.$watch('dService.searchString', function(searchString) {
151 if(searchString != undefined )
152 getItems(searchString);
166 SearchCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService', 'dashboardService'];
167 SearchSnippetCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService', 'dashboardService','applicationsService', '$window','$state'];
168 angular.module('ecompApp').controller('searchCtrl', SearchCtrl);
169 angular.module('ecompApp').controller('searchSnippetCtrl', SearchSnippetCtrl);
170 angular.module('ecompApp').directive('searchBox', function() {
173 templateUrl: 'app/views/search/search.tpl.html',
174 link: function(scope, element) {
176 //var iframeId = "#tabframe-" + scope.$parent.tab.title.split(' ').join('-');
177 // jQuery(iframeId).load(function() {
179 // }); //.attr("src",'{{tab.content | trusted}}' ); //src='{{tab.content | trusted}}'
180 // jQuery(iframeId).attr('src', '{{tab.content | trusted}}');
182 //element.childNodes[0].on('load', function() {
188 angular.module( 'ecompApp' ).config( [
190 function( $compileProvider )
192 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension|qto):/);