From b54df0ddd0c6a0372327c5aa3668e5a6458fcd64 Mon Sep 17 00:00:00 2001 From: st782s Date: Thu, 4 May 2017 07:48:42 -0400 Subject: [PORTAL-7] Rebase This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: I9a24a338665c7cd058978e8636bc412d9e2fdce8 Signed-off-by: st782s --- .../client/app/services/admins/admins.service.js | 221 ++++++++ .../services/applications/applications.service.js | 591 +++++++++++++++++++++ .../app/services/audit-log/audit-log.service.js | 92 ++++ .../client/app/services/base64/base64.service.js | 69 +++ .../basic-auth-account.service.js | 124 +++++ .../be-property-reader.service.js | 70 +++ .../client/app/services/catalog/catalog.service.js | 172 ++++++ .../services/confirm-box/confirm-box.service.js | 236 ++++++++ .../app/services/contact-us/contact-us.service.js | 247 +++++++++ .../app/services/dashboard/dashboard.service.js | 185 +++++++ .../error-messages/error-messages.service.js | 22 + .../external-request-access-service.js | 63 +++ .../functionalMenu/functionalMenu.service.js | 318 +++++++++++ .../services/global-constants/global-constants.js | 23 + .../app/services/manifest/manifest.service.js | 64 +++ .../client/app/services/menus/menus.service.js | 147 +++++ .../services/microservice/microservice.service.js | 218 ++++++++ .../services/notification/notification.service.js | 322 +++++++++++ .../portal-admins/portal-admins.service.js | 112 ++++ .../client/app/services/role/role.service.js | 190 +++++++ .../support/getAccess/get-access.service.js | 62 +++ .../app/services/userbar/userbar.update.service.js | 97 ++++ .../client/app/services/users/users.service.js | 215 ++++++++ .../client/app/services/utils/utils.service.js | 55 ++ .../widgets-catalog/widgets-catalog.service.js | 358 +++++++++++++ .../client/app/services/widgets/widgets.service.js | 206 +++++++ 26 files changed, 4479 insertions(+) create mode 100644 ecomp-portal-FE-common/client/app/services/admins/admins.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/applications/applications.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/audit-log/audit-log.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/base64/base64.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/basic-auth-account/basic-auth-account.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/be-property-reader/be-property-reader.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/catalog/catalog.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/confirm-box/confirm-box.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/contact-us/contact-us.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/dashboard/dashboard.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/error-messages/error-messages.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/external-request-access-service/external-request-access-service.js create mode 100644 ecomp-portal-FE-common/client/app/services/functionalMenu/functionalMenu.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/global-constants/global-constants.js create mode 100644 ecomp-portal-FE-common/client/app/services/manifest/manifest.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/menus/menus.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/microservice/microservice.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/notification/notification.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/portal-admins/portal-admins.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/role/role.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/support/getAccess/get-access.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/userbar/userbar.update.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/users/users.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/utils/utils.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/widgets-catalog/widgets-catalog.service.js create mode 100644 ecomp-portal-FE-common/client/app/services/widgets/widgets.service.js (limited to 'ecomp-portal-FE-common/client/app/services') diff --git a/ecomp-portal-FE-common/client/app/services/admins/admins.service.js b/ecomp-portal-FE-common/client/app/services/admins/admins.service.js new file mode 100644 index 00000000..3658052c --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/admins/admins.service.js @@ -0,0 +1,221 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by nnaffar on 11/22/2015. + */ +'use strict'; + +(function () { + class AdminsService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + getAccountAdmins() { + let deferred = this.$q.defer(); + //this.$log.info('AdminsService::get all applications admins list'); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.accountAdmins, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('AdminsService::getAccountAdmins Failed'); + deferred.reject("AdminsService::getAccountAdmins Failed"); + } else { + // this.$log.info('AdminsService::getAccountAdmins Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('AdminsService::getAccountAdmins Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + } + + getAdminAppsRoles(orgUserId) { + let deferred = this.$q.defer(); + //this.$log.info('AdminsService::getAdminAppsRoles.adminAppsRoles'); + + this.$http({ + method: "GET", + url: this.conf.api.adminAppsRoles, + params: {user: orgUserId}, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('AdminsService::getAdminAppsRoles.adminAppsRoles Failed'); + deferred.reject("AdminsService::getAdminAppsRoles.adminAppsRoles Failed"); + } else { + // this.$log.info('AdminsService::getAdminAppsRoles.adminAppsRoles Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('AdminsService::getAdminAppsRoles.adminAppsRoles Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + } + /*Author: Rui*/ + getRolesByApp(appId) { + let deferred = this.$q.defer(); + this.$log.info('AdminsService::getRolesByApp'); + let url = this.conf.api.adminAppsRoles + '/' + appId; + this.$http({ + method: "GET", + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0) { + deferred.reject("AdminsService::getAdminAppsRoles.getRolesByApp Failed"); + } else { + this.$log.info('AdminsService::getAdminAppsRoles.getRolesByApp Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + updateAdminAppsRoles(newAdminAppRoles) { + let deferred = this.$q.defer(); + // this.$log.info('AdminsService::updateAdminAppsRoles'); + this.$http({ + method: "PUT", + url: this.conf.api.adminAppsRoles, + data: newAdminAppRoles, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('AdminsService::updateAdminAppsRoles Failed'); + deferred.reject("AdminsService::updateAdminAppsRoles Failed"); + } else { + //this.$log.info('AdminsService::updateAdminAppsRoles success:'); + deferred.resolve(res.data); + } + + }) + .catch( status => { + this.$log.error('AdminsService::updateAdminAppsRoles: rejection:' + status); + deferred.reject(status); + }); + + return deferred.promise; + } + + /** + * Tests the specified password against complexity requirements. + * Returns an explanation message if the test fails; null if it passes. + */ + isComplexPassword(str) { + let minLength = 8; + let message = 'Password is too simple. Minimum length is '+ minLength + ', ' + + 'and it must use letters, digits and special characters.'; + if (str == null) + return message; + + let hasLetter = false; + let hasDigit = false; + let hasSpecial = false; + var code, i, len; + for (i = 0, len = str.length; i < len; i++) { + code = str.charCodeAt(i); + if (code > 47 && code < 58) // numeric (0-9) + hasDigit = true; + else if ((code > 64 && code < 91) || (code > 96 && code < 123)) // A-Z, a-z + hasLetter = true; + else + hasSpecial = true; + } // for + + if (str.length < minLength || !hasLetter || !hasDigit || !hasSpecial) + return message; + + // All is well. + return null; + } + + addNewUser(newUser,checkDuplicate) { + // this.$log.info(newContactUs) + let deferred = this.$q.defer(); + // this.$log.info('ContactUsService:: add Contact Us' + JSON.stringify(newContactUs)); + + var newUserObj={ + firstName:newUser.firstName, + middleInitial:newUser.middleName, + lastName:newUser.lastName, + email:newUser.emailAddress, + loginId:newUser.loginId, + loginPwd:newUser.loginPwd, + }; + this.$http({ + url: this.conf.api.saveNewUser + "?isCheck=" + checkDuplicate, + method: 'POST', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + }, + data: newUserObj + }).then(res => { + // this.$log.info('ContactUsService:: add Contact Us res' ,res); + // If response comes back as a redirected HTML page which IS NOT a success + if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') { + deferred.reject("Add new User failed"); + this.$log.error('adminService:: add New User failed'); + } else { + deferred.resolve(res.data); + } + }).catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + } + AdminsService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('adminsService', AdminsService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/applications/applications.service.js b/ecomp-portal-FE-common/client/app/services/applications/applications.service.js new file mode 100644 index 00000000..d723a277 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/applications/applications.service.js @@ -0,0 +1,591 @@ +/*- + * ================================================================================ + * 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 ApplicationsService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService + } + + getPersUserApps() { + let deferred = this.$q.defer(); + var _this0 = this; + // this.$log.info('ApplicationsService::getPersUserApps'); + this.$http.get(this.conf.api.persUserApps, + { + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null || _this0.utilsService.isValidJSON(res.data) == false) { + deferred.reject("ApplicationsService::getPersUserApps Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getAppsOrderBySortPref(userAppSortTypePref) { + let deferred = this.$q.defer(); + var _this1 = this; + // this.$log.info('ApplicationsService::getAppsOrderBySortPref'); + this.$http.get(this.conf.api.userAppsOrderBySortPref, + { + cache: false, + params:{'mparams':userAppSortTypePref}, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null || _this1.utilsService.isValidJSON(res.data)== false) { + deferred.reject("ApplicationsService::getAppsOrderBySortPref Failed"); + } else { + // this.$log.info('ApplicationsService::getAppsOrderBySortPref Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + saveAppsSortTypeManual(appsSortManual){ + let deferred = this.$q.defer(); + if (appsSortManual== undefined + || appsSortManual == null + || appsSortManual.length == 0) { + this.$log.error('ApplicationsService::saveAppsSortTypeManual: Apps Sort Manual received empty string!'); + return deferred.reject('Apps Sort Manual received empty string '); + } + + this.$http({ + method: 'PUT', + url: this.conf.api.saveUserAppsSortingManual, + data: appsSortManual, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS + // NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null) { + deferred.reject("ApplicationsService::saveAppsSortTypeManual Failed"); + } else { + // this.$log.info('ApplicationsService::saveAppsSortTypeManual + // Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + saveAppsSortTypePreference(appsSortPreference){ + let deferred = this.$q.defer(); + var _this2 = this; + if (appsSortPreference== undefined + || appsSortPreference == null + || appsSortPreference.length == 0){ + this.$log.error('ApplicationsService::saveAppsSortTypePreference: Apps Sort type Preference received empty string!'); + return deferred.reject('Apps Sort type Preference received empty string '); + } + this.$http({ + method: 'PUT', + url: this.conf.api.saveUserAppsSortingPreference, + data: appsSortPreference, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null || _this2.utilsService.isValidJSON(res) == false) { + deferred.reject("ApplicationsService::saveAppsSortTypePreference Failed"); + } else { + // this.$log.info('ApplicationsService::saveAppsSortTypePreference Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getUserAppsSortTypePreference() { + let deferred = this.$q.defer(); + var _this3 = this; + this.$http({ + method: "GET", + url: this.conf.api.userAppsSortTypePreference, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + if (res == null || res.data == null || _this3.utilsService.isValidJSON(res) == false) { + deferred.reject("ApplicationsService::getSortTypePreference Failed"); + } else { + // this.$log.info('ApplicationsService::getUserAppsSortTypePreference Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + saveWidgetsSortManual(widgetsSortManual){ + let deferred = this.$q.defer(); + var _this4 = this; + if (widgetsSortManual== undefined + || widgetsSortManual == null + || widgetsSortManual.length == 0){ + this.$log.error('ApplicationsService::saveWidgetsSortManual: Widegts Sort type Preference received empty string!'); + return deferred.reject('Widgets Sort Manual received empty string '); + } + this.$http({ + method: 'PUT', + url: this.conf.api.saveUserWidgetsSortManual, + data: widgetsSortManual, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (res == null || res.data == null || _this4.utilsService.isValidJSON(res) == false) { + deferred.reject("ApplicationsService::saveWidgetsSortManual Failed"); + } else { + // this.$log.info('ApplicationsService::saveWidgetsSortManual + // Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + delWidgetsSortPref(widgetsData){ + let deferred = this.$q.defer(); + var _this5 = this; + + if (widgetsData== undefined + || widgetsData == null + || widgetsData.length == 0){ + this.$log.error('ApplicationsService::delWidgetsSortPref: While deleting, widgets received empty string!'); + return deferred.reject('Widgets received empty string '); + } + + this.$http({ + method: 'PUT', + url: this.conf.api.updateWidgetsSortPref, + data: widgetsData, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (res == null || res.data == null || _this5.utilsService.isValidJSON(res) == false) { + deferred.reject("ApplicationsService::delWidgetsSortPref Failed"); + } else { + // this.$log.info('ApplicationsService::delWidgetsSortPref + // Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getAvailableApps() { + let deferred = this.$q.defer(); + var _this6 = this; + // this.$log.info('ApplicationsService::getAvailableApps'); + + this.$http( + { + method: "GET", + url: this.conf.api.availableApps, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + if (res == null || res.data == null || _this6.utilsService.isValidJSON(res) == false) { + deferred.reject("ApplicationsService::getAvailableApps Failed"); + } else { + // this.$log.info('ApplicationsService::getAvailableApps Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + getAdminApps(){ + var _this7 = this; + let canceller = this.$q.defer(); + let isActive = false; + + let cancel = () => { + if(isActive){ + this.$log.debug('ApplicationsService::getAdminApps: canceling the request'); + canceller.resolve(); + } + }; + + let promise = () => { + isActive = true; + let deferred = this.$q.defer(); + // this.$log.info('ApplicationsService::getAdminApps: starting'); + this.$http({method: "GET", + url: this.conf.api.adminApps, + cache: false, + timeout: canceller.promise, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + isActive = false; + if (res == null || res.data == null || _this7.utilsService.isValidJSON(res) == false) { + deferred.reject("ApplicationsService::adminApps Failed"); + } else { + // this.$log.info('ApplicationsService::adminApps Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(status => { + isActive = false; + deferred.reject(status); + }); + return deferred.promise; + }; + + return { + cancel: cancel, + promise: promise + }; + } + + getLeftMenuItems(){ + let deferred = this.$q.defer(); + var _this8 = this; + // this.$log.info('ApplicationsService::getAppsForSuperAdminAndAccountAdmin'); + this.$http({method: "GET", + url: this.conf.api.leftmenuItems, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + this.$log.debug('getLeftMenuItems::getAdminApps: canceling the request',res); + + if (res == null || res.data == null || _this8.utilsService.isValidJSON(res) == false) { + deferred.reject("ApplicationsService::getLeftMenuItems Failed"); + } else { + // this.$log.info('ApplicationsService::getAppsForSuperAdminAndAccountAdmin Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getAppsForSuperAdminAndAccountAdmin(){ + let deferred = this.$q.defer(); + var _this9 = this; + // this.$log.info('ApplicationsService::getAppsForSuperAdminAndAccountAdmin'); + this.$http({method: "GET", + url: this.conf.api.appsForSuperAdminAndAccountAdmin, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null || _this9.utilsService.isValidJSON(res) == false) { + deferred.reject("ApplicationsService::getAppsForSuperAdminAndAccountAdmin Failed"); + } else { + // this.$log.info('ApplicationsService::getAppsForSuperAdminAndAccountAdmin Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getAdminAppsSimpler(){ + let deferred = this.$q.defer(); + var _this10 = this; + // this.$log.info('ApplicationsService::getAdminAppsSimpler'); + this.$http({method: "GET", + url: this.conf.api.adminApps, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null || _this10.utilsService.isValidJSON(res.data) == false) { + deferred.reject("ApplicationsService::getAdminAppsSimpler Failed"); + } else { + // this.$log.info('ApplicationsService::getAdminAppsSimpler Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getOnboardingApps(){ + let deferred = this.$q.defer(); + var _this11 = this; + // this.$log.debug('applications-service::getOnboardingApps'); + this.$http.get(this.conf.api.onboardingApps, + { + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null || _this11.utilsService.isValidJSON(res.data) == false) { + deferred.reject("ApplicationsService::getOnboardingApps Failed"); + } else { + // this.$log.info('ApplicationsService::getOnboardingApps Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + addOnboardingApp(newApp){ + let deferred = this.$q.defer(); + // this.$log.debug('applications-service::addOnboardingApp with:', newApp); + this.$http({ + method: "POST", + url: this.conf.api.onboardingApps, + data: newApp, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null) { + deferred.reject("ApplicationsService::addOnboardingApp Failed"); + } else { + // this.$log.info('ApplicationsService::addOnboardingApp Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + updateOnboardingApp(appData){ + let deferred = this.$q.defer(); + // this.$log.info('ApplicationsService::addOnboardingApp'); + if(!appData.id){ + this.$log.error('ApplicationsService::addOnboardingApp: App id not found!'); + return deferred.reject('App id not found'); + } + + this.$http({ + method: "PUT", + url: this.conf.api.onboardingApps, + data: appData, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null) { + deferred.reject("ApplicationsService::updateOnboardingApp Failed"); + } else { + // this.$log.info('ApplicationsService::updateOnboardingApp Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + saveUserAppsRoles(UserAppRolesRequest) { + let deferred = this.$q.defer(); + + if (UserAppRolesRequest== undefined + || UserAppRolesRequest == null + || UserAppRolesRequest.length == 0){ + this.$log.error('ApplicationsService::saveAppsSortTypeManual: Apps Sort Manual received empty string!'); + return deferred.reject('Apps Sort Manual received empty string '); + } + // var manualAppsJson = angular.toJson(appsSortManual); + + // console.log(manual_jsonData); + this.$http({ + method: 'PUT', + url: this.conf.api.saveUserAppRoles, + data: UserAppRolesRequest, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS + // NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null) { + deferred.reject("ApplicationsService::saveAppsSortTypeManual Failed"); + } else { + // this.$log.info('ApplicationsService::saveAppsSortTypeManual + // Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + + } + + + deleteOnboardingApp(appId) { + let deferred = this.$q.defer(); + let url = this.conf.api.onboardingApps + '/' + appId; + // this.$log.info('applications.service::deleteOnboardingApp' +appId); + + this.$http({ + method: "DELETE", + url: url, + cache: false, + data:'', + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null) { + deferred.reject("applications.service::deleteOnboardingApp Failed"); + } else { + // this.$log.info('applications.service::deleteOnboardingApp succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + getTopMenuData(selectedApp) { + let deferred = this.$q.defer(); + // this.$log.info('ApplicationsService:getTopMenuData'); + this.$log.debug('ApplicationsService:getTopMenuData with:', selectedApp); + } + + ping(){ + let deferred = this.$q.defer(); + // this.$log.info('ApplicationsService::ping: '); + this.$http.get(this.conf.api.ping, + { + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .success( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res).length == 0) { + deferred.reject("ApplicationsService::ping: Failed"); + } else { + // this.$log.info('ApplicationsService::ping: Succeeded'); + deferred.resolve(res); + } + }) + .error( status => { + deferred.reject(status); + }); + + return deferred.promise; + } + } + ApplicationsService.$inject = ['$q', '$log', '$http', 'conf','uuid4','utilsService']; + angular.module('ecompApp').service('applicationsService', ApplicationsService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/audit-log/audit-log.service.js b/ecomp-portal-FE-common/client/app/services/audit-log/audit-log.service.js new file mode 100644 index 00000000..93a61310 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/audit-log/audit-log.service.js @@ -0,0 +1,92 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by robertlo on 11/18/2016. + */ +'use strict'; + +(function () { + class AuditLogService { + constructor($q, $log, $http, conf, uuid) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + + this.uuid = uuid; + } + storeAudit(affectedAppId) { + // this.$log.error('ecomp::storeAudit storeAudit',affectedAppId); + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.storeAuditLog+'?affectedAppId=' + affectedAppId +"&type=''&comment=''", + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + return deferred.promise; + } + + storeAudit(affectedAppId,type) { + // this.$log.error('ecomp::storeAudit storeAudit',affectedAppId + " " +type); + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.storeAuditLog+'?affectedAppId=' + affectedAppId + '&type='+type+"&comment=''", + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + return deferred.promise; + } + storeAudit(affectedAppId,type,comment) { + comment = filterDummyValue(comment); + let deferred = this.$q.defer(); + var url =this.conf.api.storeAuditLog+'?affectedAppId=' + affectedAppId; + if(type!=''){ + url= url+'&type='+type; + } + if(comment!=''){ + url= url+'&comment='+comment; + } + this.$http({ + method: "GET", + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + return deferred.promise; + } + } + AuditLogService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4']; + angular.module('ecompApp').service('auditLogService', AuditLogService) +})(); + +function filterDummyValue(comment){ + var n = comment.indexOf("?dummyVar"); + if(n!=-1) + comment = comment.substring(0, n); + return comment; +} diff --git a/ecomp-portal-FE-common/client/app/services/base64/base64.service.js b/ecomp-portal-FE-common/client/app/services/base64/base64.service.js new file mode 100644 index 00000000..5a684784 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/base64/base64.service.js @@ -0,0 +1,69 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Author: Rui Lu + * 12/15/2016 + */ +(function () { + class Base64Service { + constructor(){ + + } + encode(input) { + var keyStr = 'ABCDEFGHIJKLMNOP' + + 'QRSTUVWXYZabcdef' + + 'ghijklmnopqrstuv' + + 'wxyz0123456789+/' + + '='; + var output = ""; + var chr1, chr2, chr3 = ""; + var enc1, enc2, enc3, enc4 = ""; + var i = 0; + + do { + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + + output = output + + keyStr.charAt(enc1) + + keyStr.charAt(enc2) + + keyStr.charAt(enc3) + + keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ""; + enc1 = enc2 = enc3 = enc4 = ""; + } while (i < input.length); + + return output; + } + } + angular.module('ecompApp').service('base64Service', Base64Service) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/basic-auth-account/basic-auth-account.service.js b/ecomp-portal-FE-common/client/app/services/basic-auth-account/basic-auth-account.service.js new file mode 100644 index 00000000..a95e0c04 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/basic-auth-account/basic-auth-account.service.js @@ -0,0 +1,124 @@ +'use strict'; + +(function () { + class BasicAuthAccountService { + constructor($q, $log, $http, conf,uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + createAccount(newAccount) { + let deferred = this.$q.defer(); + this.$http({ + method: "POST", + url: this.conf.api.basicAuthAccount, + data: newAccount, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('BasicAuthAccountService::createAccount Failed: Result or result.data is null'); + deferred.reject("BasicAuthAccountService::createAccount Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('BasicAuthAccountService::createAccount Failed: Invalid JSON format'); + deferred.reject("BasicAuthAccountService::createAccount Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + updateAccount(accountId, newAccount) { + let deferred = this.$q.defer(); + this.$http({ + method: "PUT", + url: this.conf.api.basicAuthAccount + "/" + accountId, + data: newAccount, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('BasicAuthAccountService::updateAccount Failed: Result or result.data is null'); + deferred.reject("BasicAuthAccountService::updateAccount Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('BasicAuthAccountService::updateAccount Failed: Invalid JSON format'); + deferred.reject("BasicAuthAccountService::updateAccount Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + getAccountList() { + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.basicAuthAccount, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('BasicAuthAccountService::getAccountList Failed: Result or result.data is null'); + deferred.reject("BasicAuthAccountService::getAccountList Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('BasicAuthAccountService::getAccountList Failed: Invalid JSON format'); + deferred.reject("BasicAuthAccountService::getAccountList Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data.response); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + deleteAccount(accountId) { + let deferred = this.$q.defer(); + this.$http({ + method: "DELETE", + url: this.conf.api.basicAuthAccount + "/" + accountId, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('BasicAuthAccountService::deleteAccount Failed: Result or result.data is null'); + deferred.reject("BasicAuthAccountService::deleteAccount Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('BasicAuthAccountService::deleteAccount Failed: Invalid JSON format'); + deferred.reject("BasicAuthAccountService::deleteAccount Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + } + + BasicAuthAccountService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('basicAuthAccountService', BasicAuthAccountService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/be-property-reader/be-property-reader.service.js b/ecomp-portal-FE-common/client/app/services/be-property-reader/be-property-reader.service.js new file mode 100644 index 00000000..b3ad6b36 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/be-property-reader/be-property-reader.service.js @@ -0,0 +1,70 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by nnaffar on 11/22/2015. + */ +'use strict'; + +(function () { + class BeReaderService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + getProperty(property) { + let deferred = this.$q.defer(); + //this.$log.info('BeReaderService::get all applications admins list'); + + let url = this.conf.api.beProperty + "?key=" + property; + this.$http({ + method: "GET", + cache: false, + url: url, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + //if (this.utilsService.isValidJSON(res)=== false) { + // this.$log.error('BeReaderService::getAccountAdmins Failed'); + // deferred.reject("BeReaderService::getAccountAdmins Failed"); + //} else { + // this.$log.info('BeReaderService::getAccountAdmins Succeeded'); + deferred.resolve(res.data); + //} + }) + .catch( status => { + this.$log.error('BeReaderService::getAccountAdmins Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + + } + } + BeReaderService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('beReaderService', BeReaderService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/catalog/catalog.service.js b/ecomp-portal-FE-common/client/app/services/catalog/catalog.service.js new file mode 100644 index 00000000..63d5b966 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/catalog/catalog.service.js @@ -0,0 +1,172 @@ +/*- + * ================================================================================ + * 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 CatalogService { + + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.debug = false; + this.utilsService = utilsService; + } + + getAppCatalog() { + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.appCatalog, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + if (this.debug) + this.$log.debug('CatalogService::getAppCatalog: result is ' + JSON.stringify(res)); + // Res is always JSON, but the data object might be an HTML error page. + if (! this.utilsService.isValidJSON(res.data)) { + var msg = 'CatalogService::getAppCatalog: result data is not JSON'; + if (this.debug) + this.$log.debug(msg); + deferred.reject(msg); + } else { + if (this.debug) + this.$log.debug('CatalogService::getAppCatalog: success'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('CatalogService:getAppCatalog failed: ' + status); + deferred.reject(status); + }); + return deferred.promise; + } + + // Expects an object with fields matching model class AppCatalogSelection: + // appId (number), select (boolean), pending (boolean). + updateAppCatalog(appData) { + let deferred = this.$q.defer(); + // Validate the request, maybe this is overkill + if (appData == null || appData.appId == null || appData.select == null) { + var msg = 'CatalogService::updateAppCatalog: field appId and/or select not found'; + this.$log.error(msg); + return deferred.reject(msg); + } + this.$http({ + method: "PUT", + url: this.conf.api.appCatalog, + data: appData, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // Detect missing result + if (res == null || res.data == null) { + deferred.reject("CatalogService::updateAppCatalog Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('CatalogService:updateAppCatalog failed: ' + status); + deferred.reject(status); + }); + return deferred.promise; + } + + // Expects an object with fields and used to update records for ep_pers_user_app_man_sort table: + // appId (number), select (boolean). + updateManualAppSort(appData) { + let deferred = this.$q.defer(); + + // Validate the request, maybe this is overkill + if (appData == null || appData.appId == null || appData.select == null) { + var msg = 'CatalogService::updateManualAppSort: field appId and/or select not found'; + this.$log.error(msg); + return deferred.reject(msg); + } + this.$http({ + method: "PUT", + url: this.conf.api.UpdateUserAppsSortManual, + data: appData, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // Detect missing result + if (res == null || res.data == null) { + deferred.reject("CatalogService::updateManualAppSort Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('CatalogService:updateManualAppSort failed: ' + status); + deferred.reject(status); + }); + + return deferred.promise; + } + + getuserAppRolesCatalog(item) { + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.appCatalogRoles, + params:{appName:item}, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + if (this.debug) + this.$log.debug('CatalogService::getAppCatalog: result is ' + JSON.stringify(res)); + // Res is always JSON, but the data object might be an HTML error page. + if (! this.utilsService.isValidJSON(res.data)) { + var msg = 'CatalogService::getAppCatalog: result data is not JSON'; + if (this.debug) + this.$log.debug(msg); + deferred.reject(msg); + } else { + if (this.debug) + this.$log.debug('CatalogService::getAppCatalog: success'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('CatalogService:getAppCatalog failed: ' + status); + deferred.reject(status); + }); + return deferred.promise; + } + + + + } + + CatalogService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('catalogService', CatalogService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/confirm-box/confirm-box.service.js b/ecomp-portal-FE-common/client/app/services/confirm-box/confirm-box.service.js new file mode 100644 index 00000000..97ebb1e5 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/confirm-box/confirm-box.service.js @@ -0,0 +1,236 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by nnaffar on 1/18/16. + */ +'use strict'; + +(function () { + class ConfirmBoxService { + constructor($q, $log, ngDialog) { + this.$q = $q; + this.$log = $log; + this.ngDialog = ngDialog; + } + + showInformation(message) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/information-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + editItem(message) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/confirmation-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + + showDynamicInformation(message, templatePath, controller) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: templatePath, + controller: controller, + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + confirm(message) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/confirmation-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + deleteItem(item) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/confirmation-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + item: item, + title: 'Functional Menu - Delete' + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + moveMenuItem(message) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/dragdrop-confirmation-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message, + title:'Functional Menu - Move' + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + makeAdminChanges(message) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message, + title: 'Admin Update' + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + + makeUserAppRoleCatalogChanges(message) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message, + title: 'UserRoles Update' + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + + webAnalyticsChanges(message) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message, + title: 'Add WebAnalytics Source' + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + + updateWebAnalyticsReport(message) { + let deferred = this.$q.defer(); + this.ngDialog.open({ + templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html', + controller: 'ConfirmationBoxCtrl', + controllerAs: 'confirmBox', + className: 'confirm-box ngdialog-theme-default', + showClose: false, + data: { + message: message, + title: 'Update WebAnalytics Source' + } + }).closePromise.then(confirmed => { + deferred.resolve(confirmed.value); + }).catch(err => { + deferred.reject(err); + }); + return deferred.promise; + }; + + } + ConfirmBoxService.$inject = ['$q', '$log', 'ngDialog']; + angular.module('ecompApp').service('confirmBoxService', ConfirmBoxService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/contact-us/contact-us.service.js b/ecomp-portal-FE-common/client/app/services/contact-us/contact-us.service.js new file mode 100644 index 00000000..45c95e9c --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/contact-us/contact-us.service.js @@ -0,0 +1,247 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by robertlo on 10/10/2016. + */ +'use strict'; + +(function () { + class ContactUsService { + constructor($q, $log, $http, conf, uuid) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + getListOfApp() { + // this.$log.info('ContactUsService::getListOfavailableApps: get all app list'); + let deferred = this.$q.defer(); + // this.$log.info('ContactUsService::getListOfavailableApps: ', this.conf.api.listOfApp); + this.$http({ + method: "GET", + url: this.conf.api.availableApps, + cache: false + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // this.$log.info('ContactUsService::getListOfavailableApps availableApps response: ', res); + if (Object.keys(res).length == 0) { + deferred.reject("ContactUsService::getListOfavailableApps: Failed"); + } else { + // this.$log.debug('ContactUsService::getListOfavailableApps: Succeeded results: ', res); + deferred.resolve(res); + } + }).catch( status => { + this.$log.error('ContactUsService::getListOfavailableApps: query error: ',status); + deferred.reject(status); + }); + return deferred.promise; + } + + getContactUs() { + let deferred = this.$q.defer(); + // this.$log.info('ContactUsService::get all Contact Us list'); + this.$http({ + url: this.conf.api.getContactUS, + method: 'GET', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0) { + deferred.reject("ContactUsService::getContactUs Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getAppsAndContacts() { + let deferred = this.$q.defer(); + // this.$log.info('ContactUsService::getAppsAndContacts'); + this.$http({ + url: this.conf.api.getAppsAndContacts, + method: 'GET', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0) { + deferred.reject("ContactUsService::getAppsAndContacts Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getContactUSPortalDetails(){ + let deferred = this.$q.defer(); + // this.$log.info('ContactUsService::get all Contact Us Portal Details'); + this.$http({ + url: this.conf.api.getContactUSPortalDetails, + method: 'GET', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0) { + deferred.reject("ContactUsService::getContactUSPortalDetails Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getAppCategoryFunctions(){ + let deferred = this.$q.defer(); + // this.$log.info('ContactUsService::get all App Category Functions'); + this.$http({ + url: this.conf.api.getAppCategoryFunctions, + method: 'GET', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0) { + deferred.reject("ContactUsService::getAppCategoryFunctions Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + addContactUs(newContactUs) { + // this.$log.info('ContactUsService::add a new Contact Us'); + // this.$log.info(newContactUs) + let deferred = this.$q.defer(); + // this.$log.info('ContactUsService:: add Contact Us' + JSON.stringify(newContactUs)); + + var contactUsObj={ + appId:newContactUs.app.value, + appName:newContactUs.app.title, + description:newContactUs.desc, + contactName:newContactUs.name, + contactEmail:newContactUs.email, + url:newContactUs.url, + }; + this.$http({ + url: this.conf.api.saveContactUS, + method: 'POST', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + }, + data: contactUsObj + }).then(res => { + // this.$log.info('ContactUsService:: add Contact Us res' ,res); + // If response comes back as a redirected HTML page which IS NOT a success + if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') { + deferred.reject("Add Contact Us failed"); + this.$log.error('ContactUsService:: add Contact Us failed'); + } else { + deferred.resolve(res.data); + } + }).catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + modifyContactUs(contactUsObj) { + // this.$log.info('ContactUsService::edit Contact Us',contactUsObj); + let deferred = this.$q.defer(); + this.$http({ + url: this.conf.api.saveContactUS, + method: 'POST', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + }, + data: contactUsObj + }).then(res => { + // this.$log.info('ContactUsService:: edit Contact Us res' ,res); + // If response comes back as a redirected HTML page which IS NOT a success + if (res==null || Object.keys(res.data).length == 0 || res.data.message == 'failure') { + deferred.reject("Edit Contact Us failed"); + this.$log.error('ContactUsService:: edit Contact Us failed'); + } else { + deferred.resolve(res.data); + } + }).catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + removeContactUs(id) { + let deferred = this.$q.defer(); + let url = this.conf.api.deleteContactUS + '/' + id; + // this.$log.info('ContactUsService:: remove Contact Us'); + this.$http({ + url: url, + method: 'POST', + cache: false, + data: '', + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + // this.$log.info("ContactUsService::removeContactUs res",res); + deferred.resolve(res.data); + if (Object.keys(res.data).length == 0) { + deferred.reject("ContactUsService::removeContactUs Failed"); + } else { + deferred.resolve(res.data); + } + }).catch(errRes => { + deferred.reject(errRes); + }); + + return deferred.promise; + } + } + ContactUsService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4']; + angular.module('ecompApp').service('contactUsService', ContactUsService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/dashboard/dashboard.service.js b/ecomp-portal-FE-common/client/app/services/dashboard/dashboard.service.js new file mode 100644 index 00000000..c4b2e578 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/dashboard/dashboard.service.js @@ -0,0 +1,185 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by robertlo on 09/26/2016. + */ +'use strict'; + +(function () { + class DashboardService { + constructor($q, $log, $http, conf, uuid) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.dashboardService = null; + this.uuid = uuid; + } + + getCommonWidgetData(widgetType) { + // this.$log.info('ecomp::dashboard-service::getting news data'); + let deferred = this.$q.defer(); + let url = this.conf.api.commonWidget + '?resourceType=' + widgetType; + + this.$http({ + method: "GET", + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // this.$log.info('ecomp::dashboard-service::getting news data',res); + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0 || Object.keys(res.data.response) ==null || Object.keys(res.data.response.items) ==null) { + deferred.reject("ecomp::dashboard-service::getNewsData Failed"); + } else { + this.userProfile = res.data; + // this.$log.info('ecomp::dashboard-service::getNewsData Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + saveCommonWidgetData(newData){ + let deferred = this.$q.defer(); + //this.$log.info('ecomp::dashboard-service::saveCommonWidgetData'); + //this.$log.debug('ecomp::dashboard-service::saveCommonWidgetData with:', newData); + + this.$http({ + method: "POST", + url: this.conf.api.commonWidget, + data: newData, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // this.$log.info(res.data); + if (Object.keys(res.data).length == 0) { + deferred.reject("ecomp::dashboard-service::saveCommonWidgetData Failed"); + } else { + // this.$log.info('ecomp::dashboard-service::saveCommonWidgetData Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + + + removeCommonWidgetData(widgetToRemove){ + let deferred = this.$q.defer(); + // this.$log.info('ecomp::dashboard-service::removeCommonWidgetData'); + // this.$log.debug('ecomp::dashboard-service::removeCommonWidgetData with:', widgetToRemove); + this.$http({ + method: "POST", + url: this.conf.api.deleteCommonWidget, + data: widgetToRemove, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // this.$log.info(res.data); + if (Object.keys(res.data).length == 0) { + deferred.reject("ecomp::dashboard-service::saveCommonWidgetData Failed"); + } else { + // this.$log.info('ecomp::dashboard-service::saveCommonWidgetData Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getSearchAllByStringResults(searchStr) { + // this.$log.info('ecomp::getSearchAllByStringResults::getting search by string results'); + let deferred = this.$q.defer(); + let url = this.conf.api.getSearchAllByStringResults; + + this.$http({ + method: "GET", + url : url, + params : { + 'searchString' : searchStr + }, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0) { + deferred.reject("ecomp::dashboard-service::getSearchAllByStringResults Failed"); + } else { + //this.searchResults = res.data; + // this.$log.info('ecomp::dashboard-service::getSearchAllByStringResults Succeeded'); + deferred.resolve(res.data.response); + } + }).catch( status => { + this.$log.error('ecomp::getSearchAllByStringResults error'); + deferred.reject(status); + }); + return deferred.promise; + + } + + getOnlineUserUpdateRate() { + let deferred = this.$q.defer(); + let url = this.conf.api.onlineUserUpdateRate; + this.$http({ + method: "GET", + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0) { + deferred.reject("ecomp::dashboard-service::getOnlineUserUpdateRate Failed"); + } else { + // this.$log.info('ecomp::dashboard-service::getOnlineUserUpdateRate Succeeded',res); + deferred.resolve(res.data); + } + }).catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + } + + DashboardService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4']; + angular.module('ecompApp').service('dashboardService', DashboardService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/error-messages/error-messages.service.js b/ecomp-portal-FE-common/client/app/services/error-messages/error-messages.service.js new file mode 100644 index 00000000..a19f5093 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/error-messages/error-messages.service.js @@ -0,0 +1,22 @@ +/*- + * ================================================================================ + * 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'; +let errorMessageByCode = {1201: 'Value already exists'}; +angular.module('ecompApp').constant('errorMessageByCode', errorMessageByCode); \ No newline at end of file diff --git a/ecomp-portal-FE-common/client/app/services/external-request-access-service/external-request-access-service.js b/ecomp-portal-FE-common/client/app/services/external-request-access-service/external-request-access-service.js new file mode 100644 index 00000000..0ef930c6 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/external-request-access-service/external-request-access-service.js @@ -0,0 +1,63 @@ +/*- + * ================================================================================ + * 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 ExternalRequestAccessService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + getExternalRequestAccessServiceInfo() { + let deferred = this.$q.defer(); + var _this = this; + let url = this.conf.api.externalRequestAccessSystem; + this.$http({ + method: "GET", + cache: false, + url: url, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + if (res == null || res.data == null || _this.utilsService.isValidJSON(res.data) == false) { + deferred.reject("ExternalRequestAccessService::getExternalRequestAccessServiceInfo Failed"); + }else{ + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('ExternalRequestAccessService::getExternalRequestAccessServiceInfo Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + + } + } + ExternalRequestAccessService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('ExternalRequestAccessService', ExternalRequestAccessService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/functionalMenu/functionalMenu.service.js b/ecomp-portal-FE-common/client/app/services/functionalMenu/functionalMenu.service.js new file mode 100644 index 00000000..742b9847 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/functionalMenu/functionalMenu.service.js @@ -0,0 +1,318 @@ +/*- + * ================================================================================ + * 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 FunctionalMenuService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + + getManagedRolesMenu( appId ) + { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::getManagedRolesMenu'); + let url = this.conf.api.appRoles.replace(':appId', appId); + this.$log.info('FunctionalMenuService::getManagedRolesMenu url: '+url); + + this.$http({ + method: 'GET', + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('functionalMenu.service::getManagedRolesMenu Failed'); + } else { + this.$log.info('functionalMenu.service::getManagedRolesMenu succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getAvailableApplications() + { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::getManagedRolesMenu:getAvailableApplications'); + + this.$http({ + method: 'GET', +// url: this.conf.api.availableApps, + url: this.conf.api.allAvailableApps, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::getManagedRolesMenu:getAvailableApplications Failed'); + } else { + this.$log.info('FunctionalMenuService::getManagedRolesMenu:getAvailableApplications succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + getMenuDetails( menuId ) + { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::getMenuDetails:getMenuDetails'); + let url = this.conf.api.functionalMenuItemDetails.replace(':menuId',menuId); + this.$log.info('FunctionalMenuService::getMenuDetails url: '+url); + + + this.$http({ + method: 'GET', + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::getMenuDetails:getMenuDetails Failed'); + } else { + this.$log.info('FunctionalMenuService::getMenuDetails:getMenuDetails succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + + getManagedFunctionalMenu() { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::getMenuDetails:getManagedFunctionalMenu'); + + this.$http({ + method: 'GET', +// url: this.conf.api.functionalMenuForAuthUser, + url: this.conf.api.functionalMenuForEditing, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::getManagedFunctionalMenu Failed'); + } else { + this.$log.info('FunctionalMenuService::getManagedFunctionalMenu succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getManagedFunctionalMenuForNotificationTree() { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::getMenuDetails:getManagedFunctionalMenuForNotificationTree'); + this.$http({ + method: 'GET', + url: this.conf.api.functionalMenuForNotificationTree, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::getManagedFunctionalMenuForNotificationTree Failed'); + + } else { + this.$log.info('FunctionalMenuService::getManagedFunctionalMenuForNotificationTree succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + + regenerateFunctionalMenuAncestors() { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::regenerateFunctionalMenuAncestors'); + + this.$http({ + method: 'GET', + url: this.conf.api.regenerateFunctionalMenuAncestors, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::regenerateFunctionalMenuAncestors Failed'); + } else { + this.$log.info('FunctionalMenuService::regenerateFunctionalMenuAncestors succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + saveEditedMenuItem(menuData) { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::saveEditedMenuItem: ' + menuData); + + let url = this.conf.api.functionalMenuItem; + this.$http({ + method: 'PUT', + url: url, + cache: false, + data: menuData, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::saveEditedMenuItem Failed'); + } else { + this.$log.info('FunctionalMenuService::saveEditedMenuItem succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + saveMenuItem(menuData) { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::saveMenuItem: ' + JSON.stringify(menuData)); + + let url = this.conf.api.functionalMenuItem; + this.$http({ + method: 'POST', + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + }, + data: menuData + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::saveMenuItem: Failed'); + } else { + this.$log.info('FunctionalMenuService::saveMenuItem: succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + + deleteMenuItem(menuId) { + let deferred = this.$q.defer(); + let url = this.conf.api.functionalMenuItem + '/' + menuId; + + this.$log.info('FunctionalMenuService::deleteMenuItem: ' +menuId); + + this.$http({ + method: 'DELETE', + url: url, + cache: false, + data:'', + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::deleteMenuItem Failed'); + } else { + this.$log.info('FunctionalMenuService::deleteMenuItem succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + + getFunctionalMenuRole() + { + let deferred = this.$q.defer(); + this.$log.info('FunctionalMenuService::getFunctionalMenuRole'); + + this.$http({ + method: 'GET', + url: this.conf.api.getFunctionalMenuRole, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('FunctionalMenuService::getFunctionalMenuRole Failed'); + } else { + this.$log.info('FunctionalMenuService::getFunctionalMenuRole succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + +} + FunctionalMenuService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('functionalMenuService', FunctionalMenuService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/global-constants/global-constants.js b/ecomp-portal-FE-common/client/app/services/global-constants/global-constants.js new file mode 100644 index 00000000..3e3e1a5f --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/global-constants/global-constants.js @@ -0,0 +1,23 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by nnaffar on 1/21/16. + */ +angular.module('ecompApp').value('ECOMP_URL_REGEX', /^((?:https?\:\/\/|ftp?\:\/\/)?(w{3}.)?(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)[^-_.]$/i); diff --git a/ecomp-portal-FE-common/client/app/services/manifest/manifest.service.js b/ecomp-portal-FE-common/client/app/services/manifest/manifest.service.js new file mode 100644 index 00000000..120cb640 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/manifest/manifest.service.js @@ -0,0 +1,64 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by mlittle on 9/9/2016. + */ +'use strict'; + +(function () { + class ManifestService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + getManifest() { + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.getManifest, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (this.utilsService.isValidJSON(res)== false) { + this.$log.error('ManifestService.getManifest failed: '); + deferred.reject('ManifestService.getManifest: response.data null or not object'); + } else { + // this.$log.info('ManifestService.getManifest Succeeded'); + // this.$log.debug('ManifestService.getManifest: ', JSON.stringify(res)) + deferred.resolve(res.data); + } + }).catch( status => { + this.$log.error('ManifestService.getManifest failed: ' + status.data); + deferred.reject(status); + }); + return deferred.promise; + } + + } + ManifestService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4', 'utilsService']; + angular.module('ecompApp').service('manifestService', ManifestService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/menus/menus.service.js b/ecomp-portal-FE-common/client/app/services/menus/menus.service.js new file mode 100644 index 00000000..6cc0eff9 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/menus/menus.service.js @@ -0,0 +1,147 @@ +/*- + * ================================================================================ + * 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 MenusService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + GetFunctionalMenuForUser() { + let deferred = this.$q.defer(); + // this.$log.info('MenusService::GetFunctionalMenuForUser via REST API'); + this.$http({ + method: 'GET', + url: this.conf.api.functionalMenuForAuthUser, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('MenusService::GetFunctionalMenuForUser Failed'); + } else { + // this.$log.info('MenusService::GetFunctionalMenuForUser success:'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('MenusService::rejection:' + status); + deferred.reject(status); + }); + + return deferred.promise; + } + + getFavoriteItems() { + let deferred = this.$q.defer(); + // this.$log.info('MenusService::getFavoriteItems via REST API'); + this.$http({ + method: 'GET', + url: this.conf.api.getFavoriteItems +'?date='+new Date().getTime(), + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('MenusService::getFavoriteItems has no favorites'); + } else { + // this.$log.info('MenusService::getFavoriteItems success:'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('MenusService::getFavoriteItems rejection:' + status); + deferred.reject(status); + }); + + return deferred.promise; + } + + setFavoriteItem(menuId) { + let deferred = this.$q.defer(); + // this.$log.info('menus-service.service::setFavoriteItem via REST API' + menuId); + let url = this.conf.api.setFavoriteItem; + this.$http({ + method: 'POST', + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate(), + 'Content-Type': 'application/json' + }, + data: menuId + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('MenusService::setFavoriteItem Failed'); + } else { + // this.$log.info('MenusService::setFavoriteItem success:'); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + this.$log.error('MenusService::setFavoriteItem rejection:' + JSON.stringify(errRes)); + deferred.reject(errRes); + }); + return deferred.promise; + } + + removeFavoriteItem(menuId) { + let deferred = this.$q.defer(); + // this.$log.info('menus-service.service::removeFavoriteItem via REST API'); + let url = this.conf.api.removeFavoriteItem.replace(':menuId', menuId); + this.$http({ + method: 'DELETE', + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('MenusService::removeFavoriteItem Failed'); + } else { + // this.$log.info('MenusService::removeFavoriteItem success:'); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + this.$log.error('MenusService::removeFavoriteItem rejection:' + status); + deferred.reject(errRes); + }); + return deferred.promise; + } + + + } + MenusService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4', 'utilsService']; + angular.module('ecompApp').service('menusService', MenusService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/microservice/microservice.service.js b/ecomp-portal-FE-common/client/app/services/microservice/microservice.service.js new file mode 100644 index 00000000..cb27cd4c --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/microservice/microservice.service.js @@ -0,0 +1,218 @@ +/*- + * ================================================================================ + * 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 MicroserviceService { + constructor($q, $log, $http, conf,uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + createService(newService) { + let deferred = this.$q.defer(); + this.$http({ + method: "POST", + url: this.conf.api.widgetCommon, + data: newService, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('MicroserviceService::createService Failed: Result or result.data is null'); + deferred.reject("MicroserviceService::createService Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('MicroserviceService::createService Failed: Invalid JSON format'); + deferred.reject("MicroserviceService::createService Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + + updateService(serviceId, newService) { + let deferred = this.$q.defer(); + this.$http({ + method: "PUT", + url: this.conf.api.widgetCommon + "/" + serviceId, + data: newService, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('MicroserviceService::updateService Failed: Result or result.data is null'); + deferred.reject("MicroserviceService::updateService Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('MicroserviceService::updateService Failed: Invalid JSON format'); + deferred.reject("MicroserviceService::updateService Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + deleteService(serviceId) { + let deferred = this.$q.defer(); + this.$http({ + method: "DELETE", + url: this.conf.api.widgetCommon + "/" + serviceId, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('MicroserviceService::deleteService Failed: Result or result.data is null'); + deferred.reject("MicroserviceService::deleteService Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('MicroserviceService::deleteService Failed: Invalid JSON format'); + deferred.reject("MicroserviceService::deleteService Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + getServiceList() { + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.widgetCommon, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('MicroserviceService::getServiceList Failed: Result or result.data is null'); + deferred.reject("MicroserviceService::getServiceList Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('MicroserviceService::getServiceList Failed: Invalid JSON format'); + deferred.reject("MicroserviceService::getServiceList Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + getWidgetListByService(serviceId) { + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.widgetCommon + '/' + serviceId, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('MicroserviceService::getWidgetListByService Failed: Result or result.data is null'); + deferred.reject("MicroserviceService::getWidgetListByService Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('MicroserviceService::getWidgetListByService Failed: Invalid JSON format'); + deferred.reject("MicroserviceService::getWidgetListByService Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + getUserParameterById(paramId){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.widgetCommon + '/services/' + paramId, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('MicroserviceService::getUserParameterById Failed: Result or result.data is null'); + deferred.reject("MicroserviceService::getUserParameterById Failed: Result or result.data is null"); + } else if (!this.utilsService.isValidJSON(res.data)) { + this.$log.error('MicroserviceService::getUserParameterById Failed: Invalid JSON format'); + deferred.reject("MicroserviceService::getUserParameterById Failed: Invalid JSON format"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + deleteUserParameterById(paramId){ + let deferred = this.$q.defer(); + this.$http({ + method: "DELETE", + url: this.conf.api.widgetCommon + '/services/' + paramId, + cache: false, + headers:{ + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('MicroserviceService::deleteUserParameterById Failed: Result or result.data is null'); + deferred.reject("MicroserviceService::deleteUserParameterById Failed: Result or result.data is null"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + } + + MicroserviceService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('microserviceService', MicroserviceService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/notification/notification.service.js b/ecomp-portal-FE-common/client/app/services/notification/notification.service.js new file mode 100644 index 00000000..cf180e83 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/notification/notification.service.js @@ -0,0 +1,322 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by wl849v on 12/14/2016. + */ +'use strict'; +(function () { + class NotificationService { + constructor($q, $log, $http, conf, uuid,utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.notificationCount = {count:0}; + this.refreshCount = 0; + this.maxCount = 0; + this.utilsService = utilsService; + } + getNotificationCount() { + return this.notificationCount; + } + setNotificationCount(count) { + this.notificationCount.count = count; + } + getRefreshCount() { + return this.refreshCount; + } + setRefreshCount(count){ + this.refreshCount = count; + } + setMaxRefreshCount(count){ + this.maxCount = count; + } + decrementRefreshCount(){ + this.refreshCount = this.refreshCount - 1; + } + + getNotificationRate() { + let deferred = this.$q.defer(); + let url = this.conf.api.notificationUpdateRate; + this.$http({ + method: "GET", + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (Object.keys(res.data).length == 0) { + deferred.reject("ecomp::NotificationService::getNotificationRate Failed"); + } else { + deferred.resolve(res.data); + } + }).catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getNotification(){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.getNotifications, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('NotificationService::getNotification Failed'); + deferred.reject("NotificationService::getNotification Failed"); + } else { + deferred.resolve(res); + } + }) + .catch( status => { + this.$log.error('NotificationService::getNotification Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + } + getNotificationHistory(){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.getNotificationHistory, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('NotificationService::getNotification Failed'); + deferred.reject("NotificationService::getNotification Failed"); + } else { + deferred.resolve(res); + } + }) + .catch( status => { + this.$log.error('NotificationService::getNotification Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + } + + getAdminNotification(){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.getAdminNotifications, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('NotificationService::getAdminNotification Failed'); + deferred.reject("NotificationService::getAdminNotification Failed"); + } else { + deferred.resolve(res); + } + }) + .catch( status => { + this.$log.error('NotificationService::getAdminNotification Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + } + + + getMessageRecipients(notificationId){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.getMessageRecipients+"?notificationId="+notificationId, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res.data)=== false) { + this.$log.error('NotificationService::getMessageRecipients Failed'); + deferred.reject("NotificationService::getMessageRecipients Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('NotificationService::getMappedRecipients Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + } + + getAppRoleIds(){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.getAllAppRoleIds, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('NotificationService::getAppRoleIds Failed'); + deferred.reject("NotificationService::getAppRoleIds Failed"); + } else { + deferred.resolve(res); + } + }) + .catch( status => { + this.$log.error('NotificationService::getAppRoleIds Failed', status); + deferred.reject(status); + }); + return deferred.promise; + } + + getNotificationRoles(notificationId){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.getNotificationRoles + '/'+notificationId+'/roles', + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('NotificationService::getAdminNotification Failed'); + deferred.reject("NotificationService::getAdminNotification Failed"); + } else { + deferred.resolve(res); + } + }) + .catch( status => { + this.$log.error('NotificationService::getAdminNotification Failed', status); + deferred.reject(status); + }); + return deferred.promise; + } + + addAdminNotification(newAdminNotif){ + let deferred = this.$q.defer(); + // this.$log.debug('applications-service::addOnboardingApp with:', newApp); + + this.$http({ + method: "POST", + url: this.conf.api.saveNotification, + data: newAdminNotif, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null) { + deferred.reject("NotificationService::addAdminNotification Failed"); + } else { + // this.$log.info('NotificationService::addAdminNotification Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + updateAdminNotification(adminNotif){ + let deferred = this.$q.defer(); + this.$http({ + method: "POST", + url: this.conf.api.saveNotification, + data: adminNotif, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + // But don't declare an empty list to be an error. + if (res == null || res.data == null) { + deferred.reject("NotificationService::updateAdminNotification Failed"); + } else { + // this.$log.info('NotificationService::updateAdminNotification Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + setNotificationRead(notificationId){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.notificationRead+"?notificationId="+notificationId, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)=== false) { + this.$log.error('NotificationService::setNotificationRead Failed'); + deferred.reject("NotificationService::setNotificationRead Failed"); + } else { + deferred.resolve(res); + } + }) + .catch( status => { + this.$log.error('NotificationService::setNotificationRead Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + } + } + NotificationService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4','utilsService']; + angular.module('ecompApp').service('notificationService', NotificationService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/portal-admins/portal-admins.service.js b/ecomp-portal-FE-common/client/app/services/portal-admins/portal-admins.service.js new file mode 100644 index 00000000..12518cea --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/portal-admins/portal-admins.service.js @@ -0,0 +1,112 @@ +/*- + * ================================================================================ + * 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 PortalAdminsService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + getPortalAdmins() { + let deferred = this.$q.defer(); + this.$log.info('PortalAdminsService::get all portal admins list'); + this.$http({ + url: this.conf.api.portalAdmins, + method: 'GET', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('PortalAdminsService::getPortalAdmins Failed'); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + addPortalAdmin(userData) { + let deferred = this.$q.defer(); + this.$log.info('PortalAdminsService::addPortalAdmin: ' + JSON.stringify(userData)); + this.$http({ + url: this.conf.api.portalAdmin, + method: 'POST', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + }, + data: userData + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + this.$log.debug('PortalAdminsService:: this.conf.api.portalAdmin: ' + JSON.stringify(res)); + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('PortalAdminsService::addPortalAdmin Failed'); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + this.$log.debug('PortalAdminsService:: this.conf.api.portalAdmin: ' + JSON.stringify(errRes)); + deferred.reject(errRes); + }); + return deferred.promise; + } + + removePortalAdmin(userId,orUserId) { + let deferred = this.$q.defer(); + let userInfo = userId+"-"+orUserId; + let url = this.conf.api.portalAdmin + '/' + userInfo; + this.$log.info('PortalAdminsService:: remove Portal Admin'); + this.$http({ + url: url, + method: 'DELETE', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('PortalAdminsService::removePortalAdmin Failed'); + } else { + deferred.resolve(res.data); + } + }).catch(errRes => { + deferred.reject(errRes); + }); + + return deferred.promise; + } + } + PortalAdminsService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4', 'utilsService']; + angular.module('ecompApp').service('portalAdminsService', PortalAdminsService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/role/role.service.js b/ecomp-portal-FE-common/client/app/services/role/role.service.js new file mode 100644 index 00000000..f8fee136 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/role/role.service.js @@ -0,0 +1,190 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +app.factory('RoleService', function ($http, $q, conf,uuid4) { + return { + getRoles: function() { + return $http.get(conf.api.getRoles,{ + cache: false, + headers: { + 'X-ECOMP-RequestID':uuid4.generate() + } + }) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + saveRoleFunction: function() { + return $http.post(conf.api.saveRoleFuncion) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getRoleFunctionList: function() { + return $http.get(conf.api.getRoleFunctions,{ + cache: false, + headers: { + 'X-ECOMP-RequestID':uuid4.generate() + } + }) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getFnMenuItems: function(){ + + return $http.get('admin_fn_menu') + .then(function(response) { + if (typeof response.data === 'object') { + + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getCacheRegions: function() { + return $http.get('get_regions') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getUsageList: function() { + return $http.get('get_usage_list') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getBroadcastList: function() { + return $http.get('get_broadcast_list') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getBroadcast: function(messageLocationId, messageLocation, messageId) { + return $http.get('get_broadcast?message_location_id='+messageLocationId + '&message_location=' + messageLocation + ((messageId != null) ? '&message_id=' + messageId : '')) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getCollaborateList: function() { + return $http.get('get_collaborate_list') + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + }, + + getRole: function(roleId) { + + return $http.get(conf.api.getRole + '?role_id=' + roleId,{ + cache: false, + headers: { + 'X-ECOMP-RequestID':uuid4.generate() + } + }) + .then(function(response) { + if (typeof response.data === 'object') { + return response.data; + } else { + return $q.reject(response.data); + } + + }, function(response) { + // something went wrong + return $q.reject(response.data); + }); + } + }; +}); diff --git a/ecomp-portal-FE-common/client/app/services/support/getAccess/get-access.service.js b/ecomp-portal-FE-common/client/app/services/support/getAccess/get-access.service.js new file mode 100644 index 00000000..4b2ac500 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/support/getAccess/get-access.service.js @@ -0,0 +1,62 @@ +/*- + * ================================================================================ + * 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 GetAccessService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + getListOfApp(searchStr) { + //this.$log.info('GetAccessService::getListOfApp: get all app list'); + let deferred = this.$q.defer(); + //this.$log.info('GetAccessService::getListOfApp: searchStr', searchStr); + //this.$log.info('GetAccessService::getListOfApp: ', this.conf.api.listOfApp); + this.$http({ + method: 'GET', + url: this.conf.api.listOfApp, + params: {search:searchStr}, + cache: false + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success +// this.$log.info('GetAccessService::getListOfApp response: ', res); + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('GetAccessService::getListOfApp: Failed'); + } else { + // this.$log.debug('GetAccessService::getListOfApp: query results: ', res); + // this.$log.info('GetAccessService::getListOfApp Succeeded'); + deferred.resolve(res); + } + }).catch( status => { + this.$log.error('GetAccessService::getListOfApp: query error: ',status); + deferred.reject(status); + }); + return deferred.promise; + } + + } + GetAccessService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('getAccessService', GetAccessService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/userbar/userbar.update.service.js b/ecomp-portal-FE-common/client/app/services/userbar/userbar.update.service.js new file mode 100644 index 00000000..70899f29 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/userbar/userbar.update.service.js @@ -0,0 +1,97 @@ +/*- + * ================================================================================ + * 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 userbarUpdateService { + constructor($q, $log, $http, conf, uuid) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.refreshCount = 0; + this.maxCount = 0; + } + + getRefreshCount() { + return this.refreshCount; + } + setRefreshCount(count){ + this.refreshCount = count; + } + setMaxRefreshCount(count){ + this.maxCount = count; + } + decrementRefreshCount(){ + this.refreshCount = this.refreshCount - 1; + } + + getWidthThresholdLeftMenu() { + let deferred = this.$q.defer(); + this.$log.info('userbarUpdateService::getWidthThresholdLeftMenu'); + this.$http({ + url: this.conf.api.getWidthThresholdLeftMenu, + method: 'GET', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (Object.keys(res.data).length == 0) { + deferred.reject("userbarUpdateService::getWidthThresholdLeftMenu Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getWidthThresholdRightMenu() { + let deferred = this.$q.defer(); + this.$log.info('userbarUpdateService::getWidthThresholdRightMenu'); + this.$http({ + url: this.conf.api.getWidthThresholdRightMenu, + method: 'GET', + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (Object.keys(res.data).length == 0) { + deferred.reject("userbarUpdateService::getWidthThresholdRightMenu Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + + } + userbarUpdateService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4']; + angular.module('ecompApp').service('userbarUpdateService', userbarUpdateService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/users/users.service.js b/ecomp-portal-FE-common/client/app/services/users/users.service.js new file mode 100644 index 00000000..894aac0d --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/users/users.service.js @@ -0,0 +1,215 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by doritrieur on 12/8/15. + */ +'use strict'; + +(function () { + class UsersService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + + searchUsers(queryString) { + let canceller = this.$q.defer(); + let isActive = false; + + let cancel = () => { + if(isActive){ + this.$log.debug('UsersService::searchUsers: canceling the request'); + canceller.resolve(); + } + }; + + let promise = () => { + let deferred = this.$q.defer(); + if(!queryString){ + return deferred.reject(new Error('query string is mandatory')); + } + isActive = true; + this.$http({ + method: 'GET', + url: this.conf.api.queryUsers, + params: {search: queryString}, + cache: false, + timeout: canceller.promise, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('UsersService::queryUsers Failed'); + } else { + //this.$log.info('UsersService::queryUsers Succeeded'); + isActive = false; + deferred.resolve(res.data); + } + }).catch( status => { + isActive = false; + deferred.reject('UsersService::searchUsers:: API Failed with status: ' + status); + }); + return deferred.promise; + }; + + return { + cancel: cancel, + promise: promise + }; + + } + + getAccountUsers(appId) { + let deferred = this.$q.defer(); + let log = this.$log; + // this.$log.debug('UsersService::getAccountUsers for appId: ' + appId); + + let url = this.conf.api.accountUsers.replace(':appId', appId); + this.$http({ + method: 'GET', + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('UsersService::getAccountUsers for appId Failed'); + } else { + // log.info('UsersService::getAccountUsers(appId) Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + log.error('getAccountUsers(appId) $http error = ', status); + deferred.reject(status); + }); + + return deferred.promise; + } + + getUserAppRoles(appid, orgUserId){ +// let deferred = this.$q.defer(); + let canceller = this.$q.defer(); + let isActive = false; + + let cancel = () => { + if(isActive){ + this.$log.debug('UsersService::getUserAppRoles: canceling the request'); + canceller.resolve(); + } + }; + + // this.$log.info('UsersService::getUserAppRoles'); + + let promise = () => { + let deferred = this.$q.defer(); + isActive = false; + this.$http({ + method: 'GET', + url: this.conf.api.userAppRoles, + params: {user: orgUserId, app: appid}, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + //this.$log.debug('getUserAppRoles response: ', JSON.stringify(res)) + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('UsersService::getUserAppRoles: Failed'); + } else { + isActive = false; + //this.$log.info('UsersService::getUserAppRoles: Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + isActive = false; + deferred.reject(status); + }); + + return deferred.promise; + }; + + return { + cancel: cancel, + promise: promise + }; + } + + updateUserAppRoles(newUserAppRoles) { +// let deferred = this.$q.defer(); + let canceller = this.$q.defer(); + let isActive = false; + + let cancel = () => { + if(isActive){ + this.$log.debug('UsersService::updateUserAppRoles: canceling the request'); + canceller.resolve(); + } + }; + + // this.$log.info('UsersService::updateUserAppRoles'); + let promise = () => { + let deferred = this.$q.defer(); + this.$http({ + method: 'PUT', + url: this.conf.api.userAppRoles, + data: newUserAppRoles, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // this.$log.debug('getUserAppRoles response: ', JSON.stringify(res)) + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('UsersService::updateUserAppRoles: Failed'); + } else { + // this.$log.info('UsersService::updateUserAppRoles: Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + + return deferred.promise; + }; + + return { + cancel: cancel, + promise: promise + }; + + } + + } + UsersService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('usersService', UsersService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/utils/utils.service.js b/ecomp-portal-FE-common/client/app/services/utils/utils.service.js new file mode 100644 index 00000000..1cbb3ca8 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/utils/utils.service.js @@ -0,0 +1,55 @@ +/*- + * ================================================================================ + * 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 UtilsService { + constructor($log) { + this.$log = $log; + } + + isRunningInLocalDevEnv() { + var myHostName; + myHostName = location.host; + + if (myHostName.includes('localhost')) { + return true; + } else { + return false; + } + } + + isValidJSON(json) { + try { + var checkJSON = JSON.parse(JSON.stringify(json)); + if (checkJSON && typeof checkJSON === 'object' && checkJSON !== null) { + // this.$log.debug('UtilsService::isValidJSON: JSON is valid!'); + return true; + } + } catch (err) { + this.$log.debug('UtilsService::isValidJSON: json passed is not valid: ' + JSON.stringify(err)); + } + return false; + } + + } + UtilsService.$inject = ['$log']; + angular.module('ecompApp').service('utilsService', UtilsService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/widgets-catalog/widgets-catalog.service.js b/ecomp-portal-FE-common/client/app/services/widgets-catalog/widgets-catalog.service.js new file mode 100644 index 00000000..99ace1cb --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/widgets-catalog/widgets-catalog.service.js @@ -0,0 +1,358 @@ +/*- + * ================================================================================ + * 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 WidgetsCatalogService { + constructor($q, $log, $http, conf,uuid,base64Service, beReaderService, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.base64Service = base64Service; + this.beReaderService = beReaderService; + this.utilsService = utilsService; + } + + getUserWidgets(loginName) { + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.widgetCommon + '/widgetCatalog' + '/' + loginName, + cache: false, + headers: { + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + deferred.reject("WidgetsCatalogService::getUserWidgets Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getManagedWidgets() { + let deferred = this.$q.defer(); + let url = this.conf.api.widgetCommon + '/widgetCatalog'; + this.$http({ + method: "GET", + url: url, + cache: false, + headers: { + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + deferred.reject("WidgetsCatalogService::getManagedWidgets Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + createWidget(newWidget, file) { + console.log(newWidget); + let deferred = this.$q.defer(); + var formData = new FormData(); + formData.append('file', file); + this.$http({ + method: "POST", + url: this.conf.api.widgetCommon + '/widgetCatalog', + transformRequest: angular.identity, + data: formData, + headers:{ + 'Content-Type': undefined, + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + }, + params:{ + 'newWidget': newWidget + } + }).then(res => { + if (res == null || res.data == null) { + deferred.reject("WidgetsCatalogService::getManagedWidgets Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + updateWidgetWithFile(file, widgetId, newWidget){ + console.log(widgetId); + let deferred = this.$q.defer(); + var formData = new FormData(); + formData.append('file', file); + let url = this.conf.api.widgetCommon + '/widgetCatalog/' + widgetId; + this.$http({ + method: 'POST', + url: url, + transformRequest: angular.identity, + data: formData, + headers: { + 'Content-Type': undefined, + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + }, + params:{ + 'newWidget': newWidget + } + }) + .then(res => { + if (res == null || res.data == null) + deferred.reject("WidgetsCatalogService::saveWidgetFile Failed"); + else + deferred.resolve(res.data); + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + updateWidget(widgetId, widgetData) { + let deferred = this.$q.defer(); + let url = this.conf.api.widgetCommon + '/widgetCatalog' + '/' + widgetId; + this.$http({ + method: 'PUT', + url: url, + cache: false, + data: widgetData, + headers: { + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then(res => { + deferred.resolve(res.data); + }) + .catch(errRes => { + deferred.reject(errRes); + }); + + return deferred.promise; + } + + + deleteWidgetFile(widgetName) { + let deferred = this.$q.defer(); + this.$log.info('WidgetsCatalogService::deleteWidgetCatalog'); + let url = this.conf.api.widgetCommon + '/doUpload' + '/' + widgetName; + this.$http({ + method: "DELETE", + url: url, + cache: false, + headers:{ + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + deferred.resolve(res.data); + }) + .catch(status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + deleteWidget(widgetId) { + let deferred = this.$q.defer(); + this.$log.info('WidgetsCatalogService::deleteWidgetCatalog'); + let url = this.conf.api.widgetCommon + '/widgetCatalog' + '/' + widgetId; + this.$http({ + method: "DELETE", + url: url, + cache: false, + headers:{ + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + deferred.resolve(res.data); + }) + .catch(status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + downloadWidgetFile(widgetId) { + let deferred = this.$q.defer(); + this.$log.info('WidgetsCatalogService::downloadWidgetFile'); + let url = this.conf.api.widgetCommon + '/download/' + widgetId; + console.log(url); + this.$http({ + method: "GET", + url: url, + cache: false, + responseType: "arraybuffer", + headers:{ + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + deferred.resolve(res.data); + }) + .catch(status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + updateWidgetCatalog(appData){ + let deferred = this.$q.defer(); + // Validate the request, maybe this is overkill + if (appData == null || appData.widgetId == null || appData.select == null) { + var msg = 'WidgetCatalogService::updateAppCatalog: field appId and/or select not found'; + this.$log.error(msg); + return deferred.reject(msg); + } + this.$http({ + method: "PUT", + url: this.conf.api.widgetCatalogSelection, + data: appData, + headers: { + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + // Detect non-JSON + if (res == null || res.data == null) { + deferred.reject("WidgetCatalogService::updateAppCatalog Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('WidgetCatalogService:updateAppCatalog failed: ' + status); + deferred.reject(status); + }); + return deferred.promise; + } + + getServiceJSON(serviceId){ + let deferred = this.$q.defer(); + this.$log.info('WidgetsCatalogService::getServiceJSON'); + let url = this.conf.api.microserviceProxy + "/" + serviceId; + console.log(url); + this.$http({ + method: "GET", + url: url, + cache: false, + headers:{ + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res == null) { + this.$log.error('WidgetCatalogService::getServiceJSON Failed: Result or result.data is null'); + deferred.reject("WidgetCatalogService::getServiceJSON Failed: Result or result.data is null"); + } else{ + deferred.resolve(res.data); + } + + }) + .catch(status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + getWidgetCatalogParameters(widgetId){ + let deferred = this.$q.defer(); + this.$log.info('WidgetsCatalogService::getWidgetCatalogParameters'); + let url = this.conf.api.widgetCommon + "/parameters/" + widgetId; + console.log(url); + this.$http({ + method: "GET", + url: url, + cache: false, + headers:{ + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('WidgetCatalogService::getWidgetCatalogParameters Failed: Result or result.data is null'); + deferred.reject("WidgetCatalogService::getWidgetCatalogParameters Failed: Result or result.data is null"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + + saveWidgetParameter(widgetParamObject){ + let deferred = this.$q.defer(); + this.$log.info('WidgetsCatalogService::saveWidgetParameter'); + let url = this.conf.api.widgetCommon + "/parameters"; + this.$http({ + method: "POST", + url: url, + cache: false, + data: widgetParamObject, + headers:{ + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (res == null || res.data == null) { + this.$log.error('WidgetCatalogService::getWidgetCatalogParameters Failed: Result or result.data is null'); + deferred.reject("WidgetCatalogService::getWidgetCatalogParameters Failed: Result or result.data is null"); + } else { + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + } + + WidgetsCatalogService.$inject = ['$q', '$log', '$http', 'conf','uuid4','base64Service', 'beReaderService', 'utilsService']; + angular.module('ecompApp').service('widgetsCatalogService', WidgetsCatalogService) +})(); diff --git a/ecomp-portal-FE-common/client/app/services/widgets/widgets.service.js b/ecomp-portal-FE-common/client/app/services/widgets/widgets.service.js new file mode 100644 index 00000000..735a7319 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/widgets/widgets.service.js @@ -0,0 +1,206 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ +/** + * Created by doritrieur on 12/3/15. + */ +'use strict'; + +(function () { + class WidgetsService { + constructor($q, $log, $http, conf, uuid, utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.utilsService = utilsService; + } + + getUserWidgets() { + let deferred = this.$q.defer(); + this.$log.info('WidgetsService::getUserWidgets'); + this.$http({ + method: 'GET', + url: this.conf.api.widgets, + cache: false, + headers: { + 'X-Widgets-Type': 'all', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res) == false) { + var msg = 'WidgetsService::getUserWidgets Failed'; + this.$log.error(msg); + deferred.reject(msg); + } else { + // this.$log.info('WidgetsService::getUserWidgets Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getManagedWidgets() { + let deferred = this.$q.defer(); + this.$log.info('WidgetsService::getManagedWidgets'); + this.$http({ + method: 'GET', + url: this.conf.api.widgets, + cache: false, + headers: { + 'X-Widgets-Type': 'managed', + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('WidgetsService::getManagedWidgets Failed'); + } else if(Object.keys(res).length == 0 && this.utilsService.isValidJSON(res)) { + deferred.resolve(null); + } else { + this.$log.info('WidgetsService::getManagedWidgets Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + createWidget(widgetData) { + let deferred = this.$q.defer(); + this.$log.info('WidgetsService::createWidget'); + this.$http({ + method: 'POST', + url: this.conf.api.widgets, + cache: false, + data: widgetData, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('WidgetsService::createWidget Failed'); + } else { + this.$log.info('WidgetsService::createWidget Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + updateWidget(widgetId, widgetData) { + let deferred = this.$q.defer(); + this.$log.info('WidgetsService::updateWidget'); + let url = this.conf.api.widgets + '/' + widgetId; + this.$http({ + method: 'PUT', + url: url, + cache: false, + data: widgetData, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('WidgetsService::updateWidget Failed'); + } else { + this.$log.info('WidgetsService::updateWidget Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + deleteWidget(widgetId) { + let deferred = this.$q.defer(); + this.$log.info('WidgetsService::deleteWidget'); + let url = this.conf.api.widgets + '/' + widgetId; + this.$http({ + method: 'DELETE', + url: url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + // If response comes back as a redirected HTML page which IS NOT a success + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('WidgetsService::deleteWidget Failed'); + } else { + this.$log.info('WidgetsService::deleteWidget Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + checkIfWidgetUrlExists(urlToValidate) { + let deferred = this.$q.defer(); + this.$log.info('WidgetsService::checkIfWidgetUrlExists:' + urlToValidate); + let reqBody = { + url: urlToValidate + }; + this.$http({ + method: 'POST', + url: this.conf.api.widgetsValidation, + cache: false, + data: reqBody, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(() => { + //if exists return true + deferred.resolve(true); + }) + .catch(response => { + if (this.utilsService.isValidJSON(res)== false) { + deferred.reject('WidgetsService::checkIfWidgetUrlExists Failed'); + } else { + if (response.data.status === 404) { + deferred.resolve(false); + } else { + deferred.reject(response.data); + } + } + }); + return deferred.promise; + } + + } + WidgetsService.$inject = ['$q', '$log', '$http', 'conf','uuid4', 'utilsService']; + angular.module('ecompApp').service('widgetsService', WidgetsService) +})(); -- cgit 1.2.3-korg