2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
39 import { Component, OnInit, Input} from '@angular/core';
40 import { ContactUsService } from '../../../shared/services/index';
41 import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
44 selector: 'app-contact-us-manage',
45 templateUrl: './contact-us-manage.component.html',
46 styleUrls: ['./contact-us-manage.component.scss']
48 export class ContactUsManageComponent implements OnInit {
51 contactUsAllAppList = [];
54 showEdit: boolean = false;
66 constructor(public activeModal: NgbActiveModal, public ngbModal: NgbModal, public contactUsService: ContactUsService) { }
70 this.getContactUsList();
75 console.log("getContactUsList called...");
76 this.contactUsService.getContactUs()
77 .subscribe( _data => {
79 console.log("getContactUsList Data :: ", _data);
80 if (this.result.response == null || this.result.response == 'undefined') {
81 console.log('ContactUsService::getContactUsList Failed: Result or result.data is null');
83 for(var i=0; i<this.result.response.length;i++){
84 if(this.result.response[i].appId!=1)
85 this.contactUsList.push(this.result.response[i]);
94 console.log("getListOfApp called...");
95 this.contactUsService.getListOfApp()
96 .subscribe( _data => {
98 console.log("getListOfApp Data :: ", _data);
99 if (this.result == null || this.result == 'undefined') {
100 console.log('ContactUsService::getListOfApp Failed: Result or result.data is null');
102 let res1 = this.result;
103 let realAppIndex = 0;
104 this.contactUsAllAppList.length=0;
105 console.log("this.contactUsList ",this.contactUsList)
106 for (var i = 1; i <= res1.length; i++) {
107 if (!res1[i - 1].restrictedApp) {
109 for(var j =0; j<this.contactUsList.length;j++){
110 if(res1[i - 1].title == this.contactUsList[j].appName){
112 console.log("okToAdd=false res1[i - 1].title ",res1[i - 1].title);
115 // not allowed to add(duplicate) another entry if the app is already available in the table
117 if(res1[i - 1].title){
118 this.contactUsAllAppList.push({
120 title: res1[i - 1].title,
121 value: res1[i - 1].index
124 realAppIndex = realAppIndex + 1;
135 console.log("Calling addNewContactUs");
136 let selectedApplication = this.selectedApp;
137 this.newContactUs.appId = selectedApplication.value;
138 this.newContactUs.appName = selectedApplication.title;
139 console.log("newContactUsObj ",this.newContactUs);
140 this.contactUsService.addContactUs(this.newContactUs)
141 .subscribe( _data => {
143 console.log("addContactUs response :: ", _data);
144 this.contactUsList.push(this.newContactUs);
150 editContactUs(contactObj: any){
153 appId:contactObj.appId,
154 appName:contactObj.appName,
155 description:contactObj.description,
156 contactName:contactObj.contactName,
157 contactEmail:contactObj.contactEmail,
161 this.contactUsService.modifyContactUs(contactUsObj)
162 .subscribe( _data => {
164 console.log("editContactUsFun response :: ", _data);
171 delContactUs(appObj: any){
172 this.contactUsService.removeContactUs(appObj.appId)
173 .subscribe( _data => {
175 console.log("delContactUsFun response :: ", _data);
176 this.contactUsList.splice(appObj, 1);