2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
42 constructor($log, $scope, $cookies, $timeout, userProfileService, sessionService, dashboardService) {
46 function showHideSearchSnippet() {
48 setTimeout(function() {
49 jQuery("#mainSearchSnippet").click();
52 setTimeout(function() {
53 jQuery("#mainSearchText").focus();
57 jQuery("#mainSearchDiv").keyup(function(event){
58 if(event.keyCode == 13){
59 // there is a watch on this variable which will trigger the database pull
60 dashboardService.searchString = jQuery("#mainSearchText").val();
63 var popupDomObj = jQuery("[content='searchSnippet.html']");
64 if(popupDomObj.length == 0) {
65 showHideSearchSnippet();
67 jQuery("#mainSearchSnippet").click();
68 showHideSearchSnippet();
84 class SearchSnippetCtrl {
85 constructor($log, $scope, $cookies, $timeout, userProfileService, sessionService, dashboardService,applicationsService, $window, $state) {
88 $scope.goToUrl = goToUrl;
89 $scope.dService = dashboardService;
91 $scope.searchResDialog = false;
92 $scope.searchDialogToggle = function($event){
93 var keyCode = $event.which || $event.keyCode;
95 $scope.searchResDialog = true;
96 dashboardService.searchString = jQuery("#mainSearchText").val();
101 window.onclick = function() {
102 if ($scope.searchResDialog) {
103 $scope.searchResDialog = false;
107 function goToUrl (item, type) {
108 $log.info("goToUrl called")
109 $log.info(item + "/" + type);
112 if(type == 'intra') {
114 var intraSearcLink = "";
115 var intraSpecSearcLink = intraSearcLink + encodeURIComponent(dashboardService.searchString);
116 $window.open(intraSpecSearcLink, '_blank');
118 } else if (type == 'extra') {
119 var extraSearcLink = "";
120 var extraSpecSearcLink = extraSearcLink + encodeURIComponent(dashboardService.searchString);
121 $window.open(extraSpecSearcLink, '_blank');
124 let url = item.target;
125 let restrictedApp = item.uuid;
126 let getAccessState = "root.getAccess"
129 applicationsService.goGetAccessAppName = item.name;
130 if($state.current.name == getAccessState)
133 $state.go(getAccessState);
134 //$log.info('No url found for this application, doing nothing..');
138 if (restrictedApp != "true") {
139 $window.open(url, '_blank');
141 if(item.url=="root.access"){
143 var tabContent = { id: new Date(), title: 'Home', url: url };
144 $cookies.putObject('addTab', tabContent );
146 var tabContent = { id: new Date(), title: item.name, url: url };
147 $cookies.putObject('addTab', tabContent );
153 function getItems(searchString) {
156 var itemMap = dashboardService.getSearchAllByStringResults(searchString)
163 $log.error('Couldnt get search results...', err)
168 $scope.$watch('dService.searchString', function(searchString) {
169 if(searchString != undefined )
170 getItems(searchString);
184 SearchCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService', 'dashboardService'];
185 SearchSnippetCtrl.$inject = ['$log', '$scope', '$cookies', '$timeout','userProfileService', 'sessionService', 'dashboardService','applicationsService', '$window','$state'];
186 angular.module('ecompApp').controller('searchCtrl', SearchCtrl);
187 angular.module('ecompApp').controller('searchSnippetCtrl', SearchSnippetCtrl);
188 angular.module('ecompApp').directive('searchBox', function() {
191 templateUrl: 'app/views/search/search.tpl.html',
192 link: function(scope, element) {
194 //var iframeId = "#tabframe-" + scope.$parent.tab.title.split(' ').join('-');
195 // jQuery(iframeId).load(function() {
197 // }); //.attr("src",'{{tab.content | trusted}}' ); //src='{{tab.content | trusted}}'
198 // jQuery(iframeId).attr('src', '{{tab.content | trusted}}');
200 //element.childNodes[0].on('load', function() {
206 angular.module( 'ecompApp' ).config( [
208 function( $compileProvider )
210 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension|qto):/);