summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-common/client/app/views/support/contact-us/contact-us.controller.js
blob: c65a8ccb760dfdd81d0d09deb0ae9c5892186b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*-
 * ============LICENSE_START==========================================
 * ONAP Portal
 * ===================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ===================================================================
 *
 * Unless otherwise specified, all software contained herein is licensed
 * under the Apache License, Version 2.0 (the "License");
 * you may not use this software 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.
 *
 * Unless otherwise specified, all documentation contained herein is licensed
 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 * you may not use this documentation except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *             https://creativecommons.org/licenses/by/4.0/
 *
 * Unless required by applicable law or agreed to in writing, documentation
 * 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.
 *
 * ============LICENSE_END============================================
 *
 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
 */
'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 = () => {
            	var modalInstance = $modal.open({
                    templateUrl: 'app/views/support/contact-us/contact-us-manage/contact-us-manage.html',
                    controller: 'ContactUsManageController',
                    windowClass: 'modal-docked',
                    resolve: {
                        message: function message() {
                            var message = {
                                type: 'Contact',
                            };
                            return message;
                        }
                    }
                });
            	
            	modalInstance.result.finally(function (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);
})();