[PORTAL-16 PORTAL-18] Widget ms; staging
[portal.git] / ecomp-portal-FE-common / client / app / views / support / contact-us / contact-us.controller.js
index 0d39a65..eddde0d 100644 (file)
-/*-\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
-\r
-(function () { \r
-               \r
-    class ContactUsCtrl {\r
-       constructor($log, contactUsService, applicationsService, $modal, ngDialog, $state,$anchorScroll,$location) {  \r
-               \r
-               contactUsService.getContactUSPortalDetails().then(res => {\r
-                       // $log.info('ContactUsCtrl:: contactUsService getContactUSPortalDetails res',res);\r
-                // $log.info('getting res',res);\r
-                var result = (typeof(res.response) != "undefined" && res.response!=null)?res.response:null;\r
-                //     $log.info('result',result);\r
-                //     $log.info('done');\r
-                var source = JSON.parse(result);\r
-                //     $log.info(source); \r
-                this.ush_TicketInfoUrl = source.ush_ticket_url; \r
-                this.portalInfo_Address = source.feedback_email_address; \r
-                this.feedback_Url = source.portal_info_url;                    \r
-               }).catch(err=> {\r
-                       $log.error('ContactUsCtrl:error:: ', err);\r
-            }).finally(() => {\r
-           });\r
-               \r
-               let init = () => {\r
-                // $log.info('ecomp app::contact-us-controller::initializing...');\r
-                this.appTable=[];\r
-                this.functionalTableData=[];\r
-            };\r
-            init();     \r
-            \r
-            let updateContactUsTable = () => {\r
-               contactUsService.getAppsAndContacts().then(res=> {\r
-                               // $log.info('ContactUsCtrl:: contactUsService getAppsAndContacts res',res);\r
-                       var tableData=[];\r
-                       // $log.info('getting res',res);\r
-                       var result = (typeof(res.response) != "undefined" && res.response!=null)?res.response:null;\r
-                       // $log.info('result',result);\r
-                       // $log.info('done');\r
-                       var source = result;\r
-                       // $log.info(source);\r
-                       // Drop Portal app, empty name entries\r
-                       for(var i=0;i<source.length; i++) {\r
-                               var dataArr = source[i];\r
-                               if ( !dataArr.appName  || dataArr.appId == 1) {\r
-                                       continue;\r
-                               }\r
-                       var dataTemp={\r
-                               app_name: dataArr.appName,\r
-                               contact_name: dataArr.contactName,\r
-                               contact_email: dataArr.contactEmail,\r
-                               desc: dataArr.description,\r
-                               url_Info: dataArr.url,\r
-                               app_Id: dataArr.appId,\r
-                       }\r
-                       tableData.push(dataTemp);\r
-                       }               \r
-                       this.appTable=tableData;\r
-                 }).catch(err=> {\r
-                                $log.error('ContactUsCtrl.updateContactUsTable:error:: ', err);\r
-                        })\r
-            };\r
-            \r
-            contactUsService.getAppCategoryFunctions().then(res=> {\r
-                       // $log.info('ContactUsCtrl:: contactUsService getAppCategoryFunctionsthen res',res);\r
-               var tablefunctionalData=[];\r
-               // $log.info('getting res',res);\r
-               var result = (typeof(res.response) != "undefined" && res.response!=null)?res.response:null;\r
-               // $log.info('result',result);\r
-               // $log.info('done');\r
-               var source = result;\r
-               // $log.info(source);                   \r
-               for(var i=0;i<source.length; i++) {\r
-                       var datafunctionalArr = source[i];\r
-                       var datafuntionalTemp={\r
-                               category: datafunctionalArr.category,\r
-                               app_Name: datafunctionalArr.application,\r
-                               functions: datafunctionalArr.functions,\r
-                               app_Id: datafunctionalArr.appId,\r
-                       }\r
-                       tablefunctionalData.push(datafuntionalTemp);\r
-               }               \r
-               this.functionalTableData=tablefunctionalData;\r
-             }).catch(err=> {\r
-                        $log.error('ContactUsCtrl:error:: ', err);\r
-                })\r
-            \r
-            updateContactUsTable();\r
-            this.editContactUsModalPopup = () => {\r
-                 // $log.debug('ContactUsCtrl::editContactUsModalPopup updating table data...');               \r
-                 var modalInstance = ngDialog.open({\r
-                     templateUrl: 'app/views/support/contact-us/contact-us-manage/contact-us-manage.html',\r
-                     controller: 'ContactUsManageController',\r
-                     resolve: {\r
-                         message: function message() {\r
-                             var message = {\r
-                                 type: 'Contact',\r
-                             };\r
-                             return message;\r
-                         }\r
-                     }\r
-                 }).closePromise.then(needUpdate => {                   \r
-                        updateContactUsTable();\r
-                    });       \r
-             };\r
-             \r
-             this.goToSection = (id) => {\r
-               \r
-                var targetDiv = document.getElementById(id);  \r
-                \r
-                var offSetHeight = 0;\r
-                for(var i=0;i<this.appTable.length;i++){  \r
-                        if(this.appTable[i].app_Id==id)\r
-                                break;\r
-                        if(this.appTable[i].showFlag==true){\r
-                                offSetHeight+=document.getElementById('collapse'+i).clientHeight;                              \r
-                        }\r
-                }\r
-                console.log(offSetHeight);\r
-                this.appTable.forEach(d => d.showFlag = false);\r
-               // let index = this.appTable.findIndex(a => a.app_Id == id);\r
-                var index =-1;\r
-                for(var i=0; i<this.appTable.length;i++){\r
-                        if(this.appTable[i].app_Id==id){\r
-                                index = i;\r
-                                break;\r
-                        }\r
-                }\r
-                console.log(index);\r
-                if (index > -1) {\r
-                        // setting the showFlag to true based on index comparing with the app_Id \r
-                        this.appTable[index].showFlag = true;\r
-                        $location.hash('appId'+index);\r
-                     $anchorScroll();\r
-               /*       $('#contentId').animate({\r
-                           scrollTop: targetDiv.offsetTop-offSetHeight\r
-                       }, 'fast');*/\r
-                }                               \r
-                \r
-             };\r
-             \r
-             // Take the user to the application on the get access page.\r
-             this.goGetAccess = (appName) => {\r
-                // $log.debug('ContactUsCtrl::goGetAccess received name ' + appName);\r
-                applicationsService.goGetAccessAppName = appName;\r
-                $state.go('root.getAccess');\r
-             };\r
-             \r
-        }\r
-    }\r
-    ContactUsCtrl.$inject = ['$log','contactUsService', 'applicationsService', '$modal', 'ngDialog', '$state','$anchorScroll','$location'];\r
-    angular.module('ecompApp').controller('ContactUsCtrl', ContactUsCtrl);\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 ContactUsCtrl {
+       constructor($log, contactUsService, applicationsService, $modal, ngDialog, $state,$anchorScroll,$location) {  
+               
+               contactUsService.getContactUSPortalDetails().then(res => {
+                       // $log.info('ContactUsCtrl:: contactUsService getContactUSPortalDetails res',res);
+                // $log.info('getting res',res);
+                var result = (typeof(res.response) != "undefined" && res.response!=null)?res.response:null;
+                //     $log.info('result',result);
+                //     $log.info('done');
+                var source = JSON.parse(result);
+                //     $log.info(source); 
+                this.ush_TicketInfoUrl = source.ush_ticket_url; 
+                this.portalInfo_Address = source.feedback_email_address; 
+                this.feedback_Url = source.portal_info_url;                    
+               }).catch(err=> {
+                       $log.error('ContactUsCtrl:error:: ', err);
+            }).finally(() => {
+           });
+               
+               let init = () => {
+                // $log.info('ecomp app::contact-us-controller::initializing...');
+                this.appTable=[];
+                this.functionalTableData=[];
+            };
+            init();     
+            
+            let updateContactUsTable = () => {
+               contactUsService.getAppsAndContacts().then(res=> {
+                               // $log.info('ContactUsCtrl:: contactUsService getAppsAndContacts res',res);
+                       var tableData=[];
+                       // $log.info('getting res',res);
+                       var result = (typeof(res.response) != "undefined" && res.response!=null)?res.response:null;
+                       // $log.info('result',result);
+                       // $log.info('done');
+                       var source = result;
+                       // $log.info(source);
+                       // Drop Portal app, empty name entries
+                       for(var i=0;i<source.length; i++) {
+                               var dataArr = source[i];
+                               if ( !dataArr.appName  || dataArr.appId == 1) {
+                                       continue;
+                               }
+                       var dataTemp={
+                               app_name: dataArr.appName,
+                               contact_name: dataArr.contactName,
+                               contact_email: dataArr.contactEmail,
+                               desc: dataArr.description,
+                               url_Info: dataArr.url,
+                               app_Id: dataArr.appId,
+                       }
+                       tableData.push(dataTemp);
+                       }               
+                       this.appTable=tableData;
+                 }).catch(err=> {
+                                $log.error('ContactUsCtrl.updateContactUsTable:error:: ', err);
+                        })
+            };
+            
+            contactUsService.getAppCategoryFunctions().then(res=> {
+                       // $log.info('ContactUsCtrl:: contactUsService getAppCategoryFunctionsthen res',res);
+               var tablefunctionalData=[];
+               // $log.info('getting res',res);
+               var result = (typeof(res.response) != "undefined" && res.response!=null)?res.response:null;
+               // $log.info('result',result);
+               // $log.info('done');
+               var source = result;
+               // $log.info(source);                   
+               for(var i=0;i<source.length; i++) {
+                       var datafunctionalArr = source[i];
+                       var datafuntionalTemp={
+                               category: datafunctionalArr.category,
+                               app_Name: datafunctionalArr.application,
+                               functions: datafunctionalArr.functions,
+                               app_Id: datafunctionalArr.appId,
+                       }
+                       tablefunctionalData.push(datafuntionalTemp);
+               }               
+               this.functionalTableData=tablefunctionalData;
+             }).catch(err=> {
+                        $log.error('ContactUsCtrl:error:: ', err);
+                })
+            
+            updateContactUsTable();
+            this.editContactUsModalPopup = () => {
+                 // $log.debug('ContactUsCtrl::editContactUsModalPopup updating table data...');               
+                 var modalInstance = ngDialog.open({
+                     templateUrl: 'app/views/support/contact-us/contact-us-manage/contact-us-manage.html',
+                     controller: 'ContactUsManageController',
+                     resolve: {
+                         message: function message() {
+                             var message = {
+                                 type: 'Contact',
+                             };
+                             return message;
+                         }
+                     }
+                 }).closePromise.then(needUpdate => {                   
+                        updateContactUsTable();
+                    });       
+             };
+             
+             this.goToSection = (id) => {
+               
+                var targetDiv = document.getElementById(id);  
+                
+                var offSetHeight = 0;
+                for(var i=0;i<this.appTable.length;i++){  
+                        if(this.appTable[i].app_Id==id)
+                                break;
+                        if(this.appTable[i].showFlag==true){
+                                offSetHeight+=document.getElementById('collapse'+i).clientHeight;                              
+                        }
+                }
+                console.log(offSetHeight);
+                this.appTable.forEach(d => d.showFlag = false);
+               // let index = this.appTable.findIndex(a => a.app_Id == id);
+                var index =-1;
+                for(var i=0; i<this.appTable.length;i++){
+                        if(this.appTable[i].app_Id==id){
+                                index = i;
+                                break;
+                        }
+                }
+                console.log(index);
+                if (index > -1) {
+                        // setting the showFlag to true based on index comparing with the app_Id 
+                        this.appTable[index].showFlag = true;
+                        $location.hash('appId'+index);
+                     $anchorScroll();
+               /*       $('#contentId').animate({
+                           scrollTop: targetDiv.offsetTop-offSetHeight
+                       }, 'fast');*/
+                }                               
+                
+             };
+             
+             // Take the user to the application on the get access page.
+             this.goGetAccess = (appName) => {
+                // $log.debug('ContactUsCtrl::goGetAccess received name ' + appName);
+                applicationsService.goGetAccessAppName = appName;
+                $state.go('root.getAccess');
+             };
+             
+        }
+    }
+    ContactUsCtrl.$inject = ['$log','contactUsService', 'applicationsService', '$modal', 'ngDialog', '$state','$anchorScroll','$location'];
+    angular.module('ecompApp').controller('ContactUsCtrl', ContactUsCtrl);
+})();