diff options
author | 2017-06-12 09:49:00 -0400 | |
---|---|---|
committer | 2017-06-12 13:42:43 -0400 | |
commit | 627badaf69987c01811c477219fd943757a635f5 (patch) | |
tree | 97df9449a411d1ecf830cc76d8afd6f9b5677bda /ecomp-portal-FE-os/client/src/views/search/search.controller.js | |
parent | ba838f2e13f1e8050c75e68bd3733d56d8f416d5 (diff) |
[PORTAL-16 PORTAL-18] Widget ms; staging
Remove staging repositories from poms.
Add widget microservice code base.
Add portal unit tests.
Repair defects.
Normalize line endings.
Change-Id: Ia5e48da2a3141b352439ecd548cddf918f4df585
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-portal-FE-os/client/src/views/search/search.controller.js')
-rw-r--r-- | ecomp-portal-FE-os/client/src/views/search/search.controller.js | 396 |
1 files changed, 198 insertions, 198 deletions
diff --git a/ecomp-portal-FE-os/client/src/views/search/search.controller.js b/ecomp-portal-FE-os/client/src/views/search/search.controller.js index 3c3c2a03..3cb22bfd 100644 --- a/ecomp-portal-FE-os/client/src/views/search/search.controller.js +++ b/ecomp-portal-FE-os/client/src/views/search/search.controller.js @@ -1,198 +1,198 @@ -/*-
- * ================================================================================
- * 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):/);
- }
- ]);
-
-})();
-
-
+/*- + * ================================================================================ + * 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):/); + } + ]); + +})(); + + |