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