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