--- /dev/null
+/*-\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
+/**\r
+ * Created by robertlo on 10/10/2016.\r
+ */\r
+'use strict';\r
+\r
+(function () {\r
+ class ContactUsService {\r
+ constructor($q, $log, $http, conf, uuid) {\r
+ this.$q = $q;\r
+ this.$log = $log;\r
+ this.$http = $http;\r
+ this.conf = conf;\r
+ this.uuid = uuid;\r
+ }\r
+ getListOfApp() {\r
+ // this.$log.info('ContactUsService::getListOfavailableApps: get all app list');\r
+ let deferred = this.$q.defer();\r
+ // this.$log.info('ContactUsService::getListOfavailableApps: ', this.conf.api.listOfApp);\r
+ this.$http({\r
+ method: "GET",\r
+ url: this.conf.api.availableApps, \r
+ cache: false\r
+ }).then( res => {\r
+ // If response comes back as a redirected HTML page which IS NOT a success\r
+ // this.$log.info('ContactUsService::getListOfavailableApps availableApps response: ', res);\r
+ if (Object.keys(res).length == 0) {\r
+ deferred.reject("ContactUsService::getListOfavailableApps: Failed"); \r
+ } else {\r
+ // this.$log.debug('ContactUsService::getListOfavailableApps: Succeeded results: ', res);\r
+ deferred.resolve(res);\r
+ }\r
+ }).catch( status => {\r
+ this.$log.error('ContactUsService::getListOfavailableApps: query error: ',status);\r
+ deferred.reject(status);\r
+ });\r
+ return deferred.promise; \r
+ }\r
+ \r
+ getContactUs() {\r
+ let deferred = this.$q.defer();\r
+ // this.$log.info('ContactUsService::get all Contact Us list');\r
+ this.$http({\r
+ url: this.conf.api.getContactUS,\r
+ method: 'GET',\r
+ cache: false,\r
+ headers: {\r
+ 'X-ECOMP-RequestID':this.uuid.generate()\r
+ }\r
+ }).then(res => {\r
+ // If response comes back as a redirected HTML page which IS NOT a success\r
+ if (Object.keys(res.data).length == 0) {\r
+ deferred.reject("ContactUsService::getContactUs Failed");\r
+ } else {\r
+ deferred.resolve(res.data);\r
+ }\r
+ })\r
+ .catch(status => {\r
+ deferred.reject(status);\r
+ });\r
+ return deferred.promise;\r
+ }\r
+ \r
+ getAppsAndContacts() {\r
+ let deferred = this.$q.defer();\r
+ // this.$log.info('ContactUsService::getAppsAndContacts');\r
+ this.$http({\r
+ url: this.conf.api.getAppsAndContacts,\r
+ method: 'GET',\r
+ cache: false,\r
+ headers: {\r
+ 'X-ECOMP-RequestID':this.uuid.generate()\r
+ }\r
+ }).then(res => {\r
+ // If response comes back as a redirected HTML page which IS NOT a success\r
+ if (Object.keys(res.data).length == 0) {\r
+ deferred.reject("ContactUsService::getAppsAndContacts Failed");\r
+ } else {\r
+ deferred.resolve(res.data);\r
+ }\r
+ })\r
+ .catch(status => {\r
+ deferred.reject(status);\r
+ });\r
+ return deferred.promise;\r
+ }\r
+\r
+ getContactUSPortalDetails(){\r
+ let deferred = this.$q.defer();\r
+ // this.$log.info('ContactUsService::get all Contact Us Portal Details');\r
+ this.$http({\r
+ url: this.conf.api.getContactUSPortalDetails,\r
+ method: 'GET',\r
+ cache: false,\r
+ headers: {\r
+ 'X-ECOMP-RequestID':this.uuid.generate()\r
+ }\r
+ }).then(res => {\r
+ // If response comes back as a redirected HTML page which IS NOT a success\r
+ if (Object.keys(res.data).length == 0) {\r
+ deferred.reject("ContactUsService::getContactUSPortalDetails Failed");\r
+ } else {\r
+ deferred.resolve(res.data);\r
+ }\r
+ })\r
+ .catch(status => {\r
+ deferred.reject(status);\r
+ });\r
+ return deferred.promise;\r
+ }\r
+\r
+ getAppCategoryFunctions(){\r
+ let deferred = this.$q.defer();\r
+ // this.$log.info('ContactUsService::get all App Category Functions');\r
+ this.$http({\r
+ url: this.conf.api.getAppCategoryFunctions,\r
+ method: 'GET',\r
+ cache: false,\r
+ headers: {\r
+ 'X-ECOMP-RequestID':this.uuid.generate()\r
+ }\r
+ }).then(res => {\r
+ // If response comes back as a redirected HTML page which IS NOT a success\r
+ if (Object.keys(res.data).length == 0) {\r
+ deferred.reject("ContactUsService::getAppCategoryFunctions Failed");\r
+ } else {\r
+ deferred.resolve(res.data);\r
+ }\r
+ })\r
+ .catch(status => {\r
+ deferred.reject(status);\r
+ });\r
+ return deferred.promise;\r
+ }\r
+ \r
+ addContactUs(newContactUs) {\r
+ // this.$log.info('ContactUsService::add a new Contact Us');\r
+ // this.$log.info(newContactUs)\r
+ let deferred = this.$q.defer();\r
+ // this.$log.info('ContactUsService:: add Contact Us' + JSON.stringify(newContactUs));\r
+ \r
+ var contactUsObj={\r
+ appId:newContactUs.app.value,\r
+ appName:newContactUs.app.title,\r
+ description:newContactUs.desc,\r
+ contactName:newContactUs.name,\r
+ contactEmail:newContactUs.email,\r
+ url:newContactUs.url, \r
+ };\r
+ this.$http({\r
+ url: this.conf.api.saveContactUS,\r
+ method: 'POST',\r
+ cache: false,\r
+ headers: {\r
+ 'X-ECOMP-RequestID':this.uuid.generate()\r
+ },\r
+ data: contactUsObj\r
+ }).then(res => {\r
+ // this.$log.info('ContactUsService:: add Contact Us res' ,res);\r
+ // If response comes back as a redirected HTML page which IS NOT a success\r
+ if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') {\r
+ deferred.reject("Add Contact Us failed");\r
+ this.$log.error('ContactUsService:: add Contact Us failed');\r
+ } else {\r
+ deferred.resolve(res.data);\r
+ }\r
+ }).catch(errRes => {\r
+ deferred.reject(errRes);\r
+ });\r
+ return deferred.promise;\r
+ }\r
+ \r
+ modifyContactUs(contactUsObj) {\r
+ // this.$log.info('ContactUsService::edit Contact Us',contactUsObj); \r
+ let deferred = this.$q.defer();\r
+ this.$http({\r
+ url: this.conf.api.saveContactUS,\r
+ method: 'POST',\r
+ cache: false,\r
+ headers: {\r
+ 'X-ECOMP-RequestID':this.uuid.generate()\r
+ },\r
+ data: contactUsObj\r
+ }).then(res => {\r
+ // this.$log.info('ContactUsService:: edit Contact Us res' ,res);\r
+ // If response comes back as a redirected HTML page which IS NOT a success\r
+ if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') {\r
+ deferred.reject("Edit Contact Us failed");\r
+ this.$log.error('ContactUsService:: edit Contact Us failed');\r
+ } else {\r
+ deferred.resolve(res.data);\r
+ }\r
+ }).catch(errRes => {\r
+ deferred.reject(errRes);\r
+ });\r
+ return deferred.promise;\r
+ }\r
+\r
+ removeContactUs(id) {\r
+ let deferred = this.$q.defer();\r
+ let url = this.conf.api.deleteContactUS + '/' + id;\r
+ // this.$log.info('ContactUsService:: remove Contact Us');\r
+ this.$http({\r
+ url: url,\r
+ method: 'POST',\r
+ cache: false,\r
+ data: '',\r
+ headers: {\r
+ 'X-ECOMP-RequestID':this.uuid.generate()\r
+ }\r
+ }).then(res => {\r
+ // If response comes back as a redirected HTML page which IS NOT a success\r
+ // this.$log.info("ContactUsService::removeContactUs res",res);\r
+ deferred.resolve(res.data);\r
+ if (Object.keys(res.data).length == 0) {\r
+ deferred.reject("ContactUsService::removeContactUs Failed");\r
+ } else {\r
+ deferred.resolve(res.data);\r
+ }\r
+ }).catch(errRes => {\r
+ deferred.reject(errRes);\r
+ });\r
+\r
+ return deferred.promise;\r
+ }\r
+ }\r
+ ContactUsService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4'];\r
+ angular.module('ecompApp').service('contactUsService', ContactUsService)\r
+})();\r