summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-os/client/src/views/search
diff options
context:
space:
mode:
authorst782s <statta@research.att.com>2017-05-04 07:48:42 -0400
committerst782s <statta@research.att.com>2017-05-04 12:28:17 -0400
commitb54df0ddd0c6a0372327c5aa3668e5a6458fcd64 (patch)
treee69cfa9b314a801bd187cf0145d1d4306436229c /ecomp-portal-FE-os/client/src/views/search
parent39d1e62c84041831bfc52cca73b5ed5efaf57d27 (diff)
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: I9a24a338665c7cd058978e8636bc412d9e2fdce8 Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-portal-FE-os/client/src/views/search')
-rw-r--r--ecomp-portal-FE-os/client/src/views/search/search.controller.js198
-rw-r--r--ecomp-portal-FE-os/client/src/views/search/search.controller.spec.js19
-rw-r--r--ecomp-portal-FE-os/client/src/views/search/search.tpl.html84
3 files changed, 301 insertions, 0 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
new file mode 100644
index 00000000..3c3c2a03
--- /dev/null
+++ b/ecomp-portal-FE-os/client/src/views/search/search.controller.js
@@ -0,0 +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):/);
+ }
+ ]);
+
+})();
+
+
diff --git a/ecomp-portal-FE-os/client/src/views/search/search.controller.spec.js b/ecomp-portal-FE-os/client/src/views/search/search.controller.spec.js
new file mode 100644
index 00000000..3841a2b3
--- /dev/null
+++ b/ecomp-portal-FE-os/client/src/views/search/search.controller.spec.js
@@ -0,0 +1,19 @@
+/*-
+ * ================================================================================
+ * 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.
+ * ================================================================================
+ */
diff --git a/ecomp-portal-FE-os/client/src/views/search/search.tpl.html b/ecomp-portal-FE-os/client/src/views/search/search.tpl.html
new file mode 100644
index 00000000..a08d0aa6
--- /dev/null
+++ b/ecomp-portal-FE-os/client/src/views/search/search.tpl.html
@@ -0,0 +1,84 @@
+<!--
+ ================================================================================
+ 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.
+ ================================================================================
+ -->
+<div class="search-div" ng-controller="searchSnippetCtrl">
+ <div class="notification-div">
+ <div class="form-field form-field__small">
+ <div class="search-input">
+ <input id="mainSearchText" type="text"
+ ng-keypress="searchDialogToggle($event)"
+ placeholder="What are you looking for?"
+ class="form-field form-field__small" />
+ </div>
+ <span class="icon-search-span"> <i class="icon-search">&nbsp;</i>
+ </span>
+
+ </div>
+ </div>
+ <div ng-show="searchResDialog" class="search-res-dialog">
+ <div id="reg-header-snippet">
+
+ <div tabindex="0" class="reg-profileDetails" id="reg-searchPop-id">
+ <div id="contentVertical" att-scrollbar="y"
+ class="ng-scope vertical" style="position: relative;">
+ <ul class="searchUl">
+ <li><a class="icon-tiles"></a> <a id="search-app-title"
+ ng-click="goToUrl(item)" class="searchLiHeader">Applications:</a>
+ </li>
+ <li ng-repeat='item in items.application'><a
+ id="search-app-item-{{item.name.split(' ').join('-')}}-{{$index}}"
+ ng-click="goToUrl(item)" class="searchLiItems">{{item.name}}</a>
+ </li>
+ </ul>
+
+ <ul class="searchUl">
+ <li><a class="icon-tiles-small"></a> <a
+ id="seach-functional-menu-title" ng-click="goToUrl(item)"
+ class="searchLiHeader">Functional Menus:</a></li>
+ <li ng-repeat='item in items.menu'><a
+ id="search-functional-menu-item-{{item.name.split(' ').join('-')}}-{{$index}}"
+ ng-click="goToUrl(item)" class="searchLiItems">{{item.name}}</a>
+ </li>
+ </ul>
+
+
+ <ul class="searchUl">
+ <li><a class="full-linear-icon-person"
+ style="font-size: 16px;"></a> <a id="search-user-title"
+ ng-click="goToUrl(item)" class="searchLiHeader">Users:</a></li>
+ <li ng-repeat='item in items.user'><a
+ id="search-user-item-{{item.name.split(' ').join('-')}}-{{$index}}"
+ ng-href="mailto:{{item.target}}" class="searchLiItems">{{item.name}}</a>
+
+ </li>
+ </ul>
+
+ <ul class="searchUl">
+ <li><a class="full-linear-icon-person"
+ style="font-size: 16px;"></a> <a id="search-widgets-title"
+ ng-click="goToUrl(item)" class="searchLiHeader">Widgets:</a></li>
+ <li ng-repeat='item in items.widget'><a
+ id="search-widgets-item-{{item.name.split(' ').join('-')}}-{{$index}}"
+ ng-href="widgetCatalog" class="searchLiItems">{{item.name}}</a></li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>