diff options
author | talasila <talasila@research.att.com> | 2017-02-07 15:03:57 -0500 |
---|---|---|
committer | talasila <talasila@research.att.com> | 2017-02-07 15:05:15 -0500 |
commit | 4ad39a5c96dd99acf819ce189b13fec946d7506b (patch) | |
tree | a1449286441947cc3d07a45227fa0d6f978e1a7d /ecomp-portal-FE/client/app/services | |
parent | 5500448cbd1f374d0ac743ee2fd636fe2d3c0027 (diff) |
Initial OpenECOMP Portal commit
Change-Id: I804b80e0830c092e307da1599bd9fbb5c3e2da77
Signed-off-by: talasila <talasila@research.att.com>
Diffstat (limited to 'ecomp-portal-FE/client/app/services')
20 files changed, 2850 insertions, 0 deletions
diff --git a/ecomp-portal-FE/client/app/services/admins/admins.service.js b/ecomp-portal-FE/client/app/services/admins/admins.service.js new file mode 100644 index 00000000..ee742af8 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/admins/admins.service.js @@ -0,0 +1,176 @@ +/*- + * ================================================================================ + * 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 AdminsService { + constructor($q, $log, $http, conf,uuid) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + + 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 (Object.keys(res.data).length == 0) { + deferred.reject("AdminsService::getAccountAdmins Failed"); + } else { + this.$log.info('AdminsService::getAccountAdmins Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( 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: {orgUserId: orgUserId}, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (Object.keys(res.data).length == 0) { + deferred.reject("AdminsService::getAdminAppsRoles.adminAppsRoles Failed"); + } else { + this.$log.info('AdminsService::getAdminAppsRoles.adminAppsRoles 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 => { + deferred.resolve(res.data); + }) + .catch( status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + 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; + } + + /** + * 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; + } + + } + AdminsService.$inject = ['$q', '$log', '$http', 'conf','uuid4']; + angular.module('ecompApp').service('adminsService', AdminsService) +})(); diff --git a/ecomp-portal-FE/client/app/services/applications/applications.service.js b/ecomp-portal-FE/client/app/services/applications/applications.service.js new file mode 100644 index 00000000..38cfd650 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/applications/applications.service.js @@ -0,0 +1,346 @@ +/*- + * ================================================================================ + * 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) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + + getPersUserApps() { + let deferred = this.$q.defer(); + // 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) { + deferred.reject("ApplicationsService::getPersUserApps Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getUserApps(){ + let deferred = this.$q.defer(); + this.$log.info('ApplicationsService::getUserApps'); + this.$http.get(this.conf.api.userApps, + { + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + if (Object.keys(res.data).length == 0) { + deferred.reject("ApplicationsService::getUserApps Failed"); + } else { + this.$log.info('ApplicationsService::getUserApps Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + getAvailableApps() { + let deferred = this.$q.defer(); + 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 (Object.keys(res.data).length == 0) { + 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(){ + 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 (Object.keys(res.data).length == 0) { + 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 + }; + } + + getAppsForSuperAdminAndAccountAdmin(){ + let deferred = this.$q.defer(); + 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 (Object.keys(res.data).length == 0) { + 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(); + this.$log.info('ApplicationsService::getAdminApps'); + this.$http({method: "GET", + url: this.conf.api.adminApps, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (Object.keys(res.data).length == 0) { + deferred.reject("ApplicationsService::getAdminApps Failed"); + } else { + this.$log.info('ApplicationsService::getAdminApps Succeeded'); + deferred.resolve(res.data); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getOnboardingApps(){ + let deferred = this.$q.defer(); + this.$log.info('ApplicationsService::getOnboardingApps'); + + this.$http.get(this.conf.api.onboardingApps, + { + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + if (Object.keys(res.data).length == 0) { + 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.info('applications-service::addOnboardingApp'); + 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + deferred.reject("ApplicationsService::updateOnboardingApp Failed"); + } else { + this.$log.info('ApplicationsService::updateOnboardingApp 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 (Object.keys(res.data).length == 0) { + 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 (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']; + angular.module('ecompApp').service('applicationsService', ApplicationsService) +})(); diff --git a/ecomp-portal-FE/client/app/services/catalog/catalog.service.js b/ecomp-portal-FE/client/app/services/catalog/catalog.service.js new file mode 100644 index 00000000..2ad594a2 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/catalog/catalog.service.js @@ -0,0 +1,95 @@ +/*- + * ================================================================================ + * 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) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + + 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 => { + // Detect non-JSON + if (res == null || res.data == null) { + deferred.reject("CatalogService::getAppCatalog Failed"); + } else { + 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 non-JSON + 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; + } + + } + + CatalogService.$inject = ['$q', '$log', '$http', 'conf','uuid4']; + angular.module('ecompApp').service('catalogService', CatalogService) +})(); diff --git a/ecomp-portal-FE/client/app/services/confirm-box/confirm-box.service.js b/ecomp-portal-FE/client/app/services/confirm-box/confirm-box.service.js new file mode 100644 index 00000000..affc6d3f --- /dev/null +++ b/ecomp-portal-FE/client/app/services/confirm-box/confirm-box.service.js @@ -0,0 +1,153 @@ +/*- + * ================================================================================ + * 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 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; + }; + + 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; + }; + + + 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; + }; + + 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; + }; + + + } + ConfirmBoxService.$inject = ['$q', '$log', 'ngDialog']; + angular.module('ecompApp').service('confirmBoxService', ConfirmBoxService) +})(); diff --git a/ecomp-portal-FE/client/app/services/contact-us/contact-us.service.js b/ecomp-portal-FE/client/app/services/contact-us/contact-us.service.js new file mode 100644 index 00000000..241a12ab --- /dev/null +++ b/ecomp-portal-FE/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) +})();
\ No newline at end of file diff --git a/ecomp-portal-FE/client/app/services/dashboard/dashboard.service.js b/ecomp-portal-FE/client/app/services/dashboard/dashboard.service.js new file mode 100644 index 00000000..bc9c9cee --- /dev/null +++ b/ecomp-portal-FE/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/client/app/services/error-messages/error-messages.service.js b/ecomp-portal-FE/client/app/services/error-messages/error-messages.service.js new file mode 100644 index 00000000..032fb803 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/error-messages/error-messages.service.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. + * ================================================================================ + */ + +'use strict'; +let errorMessageByCode = {1201: 'Value already exists'}; +angular.module('ecompApp').constant('errorMessageByCode', errorMessageByCode); diff --git a/ecomp-portal-FE/client/app/services/functionalMenu/functionalMenu.service.js b/ecomp-portal-FE/client/app/services/functionalMenu/functionalMenu.service.js new file mode 100644 index 00000000..ec3bd387 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/functionalMenu/functionalMenu.service.js @@ -0,0 +1,253 @@ +/*- + * ================================================================================ + * 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) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + + + 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + 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.functionalMenuForEditing, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (Object.keys(res.data).length == 0) { + deferred.reject("FunctionalMenuService::getManagedFunctionalMenu Failed"); + } else { + this.$log.info('FunctionalMenuService::getManagedFunctionalMenu 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + deferred.reject("FunctionalMenuService::deleteMenuItem Failed"); + } else { + this.$log.info('FunctionalMenuService::deleteMenuItem succeeded: '); + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + +} + FunctionalMenuService.$inject = ['$q', '$log', '$http', 'conf','uuid4']; + angular.module('ecompApp').service('functionalMenuService', FunctionalMenuService) +})(); diff --git a/ecomp-portal-FE/client/app/services/global-constants/global-constants.js b/ecomp-portal-FE/client/app/services/global-constants/global-constants.js new file mode 100644 index 00000000..fa13dae4 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/global-constants/global-constants.js @@ -0,0 +1,21 @@ +/*- + * ================================================================================ + * 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. + * ================================================================================ + */ + +angular.module('ecompApp').value('ECOMP_URL_REGEX', /^((?:https?\:\/\/|ftp?\:\/\/)?(w{3}.)?(?:[-a-z0-9]+\.)*[-a-z0-9]+.*)[^-_.]$/i); diff --git a/ecomp-portal-FE/client/app/services/kpi-dashboard/kpi-dashboard.service.js b/ecomp-portal-FE/client/app/services/kpi-dashboard/kpi-dashboard.service.js new file mode 100644 index 00000000..ff9b66b8 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/kpi-dashboard/kpi-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. + * ================================================================================ + */ + +'use strict'; + +(function () { + class KpiDashboardService { + constructor($q, $log, $http, conf, uuid) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.applicationsHomeUrl = 'kpidash'; + } + + kpiApiCall(ApiName) { + let deferred = this.$q.defer(); + this.$log.info('KpiDashboardService::kpiApiCall: '+ApiName); + this.$http({ + method: 'GET', + url: this.conf.api[ApiName], + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + this.$log.debug("KpiDashboardService::kpiApiCall: response successfully retrieved"); + if (Object.keys(res.data).length == 0) { + deferred.reject("KpiDashboardService::kpiApiCall: "+ ApiName+ " Failed"); + } else { + deferred.resolve(res); + } + }) + .catch(status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getKpiUserStoriesStats(){ + return this.kpiApiCall("getKpiDashUserStoriesStats"); + } + getKpiUserApiStats(){ + return this.kpiApiCall("getKpiDashUserApiStats"); + } + getKpiLocStats(){ + return this.kpiApiCall("getKpiDashLocStats"); + } + getKpiLocStatsCat(){ + return this.kpiApiCall("getKpiDashLocStatsCat"); + } + getKpiServiceSupported(){ + return this.kpiApiCall("getKpiDashServiceSupported"); + } + getKpiPublishedDelivered(){ + return this.kpiApiCall("getKpiDashPublishedDelivered"); + } + getKpiFeedStats(){ + return this.kpiApiCall("getKpiDashFeedStats"); + } + getKpiUserApis(){ + return this.kpiApiCall("getKpiDashUserApis"); + } + getKpiGeoMapUrl(){ + return this.kpiApiCall("getKpiDashGeoMapUrl"); + } + getKpiRCloudAUrl(){ + return this.kpiApiCall("getKpiDashRCloudAUrl"); + } + getKpiGeoMapApiUrl(){ + return this.kpiApiCall("getKpiDashGeoMapApiUrl"); + } + + getToplevelgTabs1() { + var toplevelgTabs1=[{ + title : 'eCOMP', + id : 'ECOMP', + url : this.applicationsHomeUrl, + state : 'root.kpidash_ECOMP' + }] + return toplevelgTabs1; + } + + getToplevelgTabs2() { + var toplevelgTabs2 = [ { + title : 'A&AI', + id : 'A&AI', + url : this.applicationsHomeUrl, + state : 'root.kpidash_AAI' + }, { + title : 'APP-C', + id : 'APP-C', + url : this.applicationsHomeUrl, + state : 'root.kpidash_APPC' + }, { + title : 'ASDC', + id : 'ASDC', + url : this.applicationsHomeUrl, + state : 'root.kpidash_ASDC' + }, { + title : 'DCAE', + id : 'DCAE', + url : this.applicationsHomeUrl, + state : 'root.kpidash_DCAE' + }, { + title : 'OpenECOMP Portal', + id : 'OpenECOMP Portal', + url : this.applicationsHomeUrl, + state : 'root.kpidash_ECOMP_Portal' + }, { + title : 'i-Portal', + id : 'i-Portal', + url : this.applicationsHomeUrl, + state : 'root.kpidash_InfrastructurePortal' + }, { + title : 'MSO', + id : 'MSO', + url : this.applicationsHomeUrl, + state : 'root.kpidash_MSO' + }, { + title : 'Policy', + id : 'Policy', + url : this.applicationsHomeUrl, + state : 'root.kpidash_Policy' + }]; + return toplevelgTabs2; + } + + getToplevelgTabs3() { + var toplevelgTabs3 = [ { + title : 'Closed Loop', + id : 'Closedloop', + url : this.applicationsHomeUrl, + state : 'root.kpidash_Closedloop' + }, { + title : 'eDMaaP', + id : 'DMaaP', + url : this.applicationsHomeUrl, + state : 'root.kpidash_DMaaP' + } ]; + return toplevelgTabs3; + } + + getGenericTabs(activeTab) { + var gTabs = [ { + title : 'KPI', + id : 'KPI', + url : this.applicationsHomeUrl, + state : 'root.kpidash_'+activeTab+'_KPI' + }, { + title : 'User Defined KPI', + id : 'User Defined KPI', + url : this.applicationsHomeUrl, + state : 'root.kpidash_'+activeTab+'_UserDefinedKPI' + }, { + title : 'Metrics', + id : 'Metrics', + url : this.applicationsHomeUrl, + state : 'root.kpidash_'+activeTab+'_Metrics' + } ]; + return gTabs; + } + } + + KpiDashboardService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4']; + angular.module('ecompApp').service('KpiDashboardService', KpiDashboardService) +})(); diff --git a/ecomp-portal-FE/client/app/services/manifest/manifest.service.js b/ecomp-portal-FE/client/app/services/manifest/manifest.service.js new file mode 100644 index 00000000..4341a138 --- /dev/null +++ b/ecomp-portal-FE/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/client/app/services/menus/menus.service.js b/ecomp-portal-FE/client/app/services/menus/menus.service.js new file mode 100644 index 00000000..19bb385b --- /dev/null +++ b/ecomp-portal-FE/client/app/services/menus/menus.service.js @@ -0,0 +1,145 @@ +/*- + * ================================================================================ + * 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) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + + 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 (Object.keys(res.data).length == 0) { + deferred.reject("MenusService::GetFunctionalMenuForUser Failed"); + } else { + this.$log.info('MenusService::GetFunctionalMenuForUser success:'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.info('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 (Object.keys(res.data).length == 0) { + deferred.reject("MenusService::getFavoriteItems Failed"); + } 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + 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']; + angular.module('ecompApp').service('menusService', MenusService) +})(); diff --git a/ecomp-portal-FE/client/app/services/portal-admins/portal-admins.service.js b/ecomp-portal-FE/client/app/services/portal-admins/portal-admins.service.js new file mode 100644 index 00000000..683c0f02 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/portal-admins/portal-admins.service.js @@ -0,0 +1,107 @@ +/*- + * ================================================================================ + * 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) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + + 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 (Object.keys(res.data).length == 0) { + 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:: add Portal Admin' + 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 (Object.keys(res.data).length == 0) { + deferred.reject("PortalAdminsService::addPortalAdmin Failed"); + } else { + deferred.resolve(res.data); + } + }) + .catch(errRes => { + deferred.reject(errRes); + }); + return deferred.promise; + } + + removePortalAdmin(userId) { + let deferred = this.$q.defer(); + let url = this.conf.api.portalAdmin + '/' + userId; + this.$log.info('PortalAdminsService:: remove Portal Admin'); + this.$http({ + url: url, + method: 'DELETE', + cache: false, + data: '', + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then(res => { + if (Object.keys(res.data).length == 0) { + 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']; + angular.module('ecompApp').service('portalAdminsService', PortalAdminsService) +})(); diff --git a/ecomp-portal-FE/client/app/services/support/getAccess/get-access.service.js b/ecomp-portal-FE/client/app/services/support/getAccess/get-access.service.js new file mode 100644 index 00000000..24b6945d --- /dev/null +++ b/ecomp-portal-FE/client/app/services/support/getAccess/get-access.service.js @@ -0,0 +1,61 @@ +/*- + * ================================================================================ + * 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) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + 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 => { + // this.$log.info('GetAccessService::getListOfApp response: ', res); + if (Object.keys(res).length == 0) { + 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']; + angular.module('ecompApp').service('getAccessService', GetAccessService) +})(); diff --git a/ecomp-portal-FE/client/app/services/support/session/session.service.js b/ecomp-portal-FE/client/app/services/support/session/session.service.js new file mode 100644 index 00000000..d18c42a4 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/support/session/session.service.js @@ -0,0 +1,56 @@ +/*- + * ================================================================================ + * 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 SessionService { + constructor($q, $log, $http, conf,uuid,$sce) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.$sce = $sce; + } + + logout(appStr) { + this.$log.info('SessionService::logout from App'); + let deferred = this.$q.defer(); + this.$log.info('SessionService appStr: ', appStr); + + var eaccessPattern = '\https?\:\/\/[^/]+/[^/]+/[^/]+'; + var standardPattern = '\https?\:\/\/[^/]+/[^/]+'; + + if(appStr.includes("e-access")) { + standardPattern = eaccessPattern; + } + + var contextUrl = appStr.match(new RegExp(standardPattern)); + var logoutUrl = contextUrl + "/logout.htm" ; + this.$sce.trustAsResourceUrl(logoutUrl); + console.log('logoutUrl ' + logoutUrl); + jQuery('#reg-logout-div').append("<iframe style='display:none' src='" + logoutUrl + "' />"); + } + + } + SessionService.$inject = ['$q', '$log', '$http', 'conf','uuid4','$sce']; + angular.module('ecompApp').service('sessionService', SessionService) +})(); diff --git a/ecomp-portal-FE/client/app/services/userProfile/userProfile.service.js b/ecomp-portal-FE/client/app/services/userProfile/userProfile.service.js new file mode 100644 index 00000000..001e9ae4 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/userProfile/userProfile.service.js @@ -0,0 +1,240 @@ +/*- + * ================================================================================ + * 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 UserProfileService { + constructor($q, $log, $http, conf, uuid,$rootScope) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.userProfile = null; + this.uuid = uuid; + this.$rootScope = $rootScope; + } + + + broadCastUpdatedUserInfo() { + this.$rootScope.$broadcast('handleUpdateUserInfo'); + } + + refreshUserBusinessCard(){ + this.$rootScope.$broadcast('refreshUserBusinessCard'); + } + + getUserProfile() { + this.$log.info('UserProfileService::getUserProfile: get logged user profile'); + let deferred = this.$q.defer(); + let url = this.conf.api.userProfile; + // if(this.userProfile){ + // return deferred.resolve(this.userProfile); + // } + 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 + // this.$log.debug('Profile-service::getUserProfile: res: ', res); + if (Object.keys(res.data).length == 0) { + deferred.reject('UserProfileService::getUserProfile unexpected result: ', res); + } else { + this.userProfile = res.data; + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getSortedUserIdCombination(user1, user2) { + + var combination = ""; + if(user1<user2) { + combination = user1+"-"+user2; + } else if (user1>user2){ + combination = user2+"-"+user1; + } else { + + return "self"; + } + + var collaborateUrl = 'opencollaboration?chat_id=' + combination ; + + return collaborateUrl; + + + + } + + getCurrentUserProfile(loginId) { + this.$log.info('UserProfileService::getCurrentUserProfile: get logged user profile'); + let deferred = this.$q.defer(); + let url = this.conf.api.currentUserProfile + '/' + loginId; + // if(this.userProfile){ + // return deferred.resolve(this.userProfile); + // } + 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 + // this.$log.debug('Profile-service::getUserProfile: res: ', res); + if (Object.keys(res.data).length == 0) { + deferred.reject('UserProfileService::CurrentgetUserProfile unexpected result: ', res); + } else { + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + updateRemoteUserProfile(loginId,appId) { + this.$log.info('UserProfileService::updateRemoteUserProfile: update remote user profile'); + let deferred = this.$q.defer(); + let url = this.conf.api.updateRemoteUserProfile + "?loginId=" + loginId + '&appId=' + appId; + // if(this.userProfile){ + // return deferred.resolve(this.userProfile); + // } + 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 + // this.$log.debug('Profile-service::getUserProfile: res: ', res); + if (Object.keys(res.data).length == 0) { + deferred.reject('UserProfileService::update remote user profile unexpected result: ', res); + } else { + deferred.resolve(res.data); + } + }) + .catch( status => { + deferred.reject(status); + }); + return deferred.promise; + } + + getFunctionalMenuStaticInfo() { + this.$log.info('UserProfileService::getFunctionalMenuStaticInfo: get logged user profile'); + let deferred = this.$q.defer(); + let url = this.conf.api.functionalMenuStaticInfo; + + this.$http({ + method: "GET", + url : url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (Object.keys(res.data).length == 0) { + deferred.reject("UserProfileService::getFunctionalMenuStaticInfo Failed"); + } else { + this.userProfile = res.data; + this.$log.info('UserProfileService::getFunctionalMenuStaticInfo Succeeded'); + deferred.resolve(res.data); + } + }).catch( status => { + this.$log.error('UserProfileService::getFunctionalMenuStaticInfo error'); + deferred.reject(status); + }); + return deferred.promise; + } + + resetFunctionalMenuStaticInfo() { + this.$log.info('UserProfileService::getFunctionalMenuStaticInfo: get logged user profile'); + let deferred = this.$q.defer(); + let url = this.conf.api.resetFunctionalMenuStaticInfo; + + this.$http({ + method: "GET", + url : url, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (res.data.message != "success") { + deferred.reject("UserProfileService::resetFunctionalMenuStaticInfo Failed"); + } else { + this.userProfile = res.data; + this.$log.info('UserProfileService::resetFunctionalMenuStaticInfo Succeeded'); + deferred.resolve(res.data); + } + }).catch( status => { + this.$log.error('UserProfileService::resetFunctionalMenuStaticInfo error'); + deferred.reject(status); + }); + return deferred.promise; + } + + + getActiveUser() { + this.$log.info('ecomp::getActiveUser::get active users'); + let deferred = this.$q.defer(); + let url = this.conf.api.getActiveUser; + + 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::userProfile-service::getActiveUser Failed"); + } else { + this.$log.info('ecomp::userProfile-service::getActiveUser Succeeded'); + deferred.resolve(res.data); + } + }).catch( status => { + this.$log.error('ecomp::getActiveUser error'); + deferred.reject(status); + }); + return deferred.promise; + } + + } + UserProfileService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4', '$rootScope']; + angular.module('ecompApp').service('userProfileService', UserProfileService) +})(); diff --git a/ecomp-portal-FE/client/app/services/userbar/userbar.update.service.js b/ecomp-portal-FE/client/app/services/userbar/userbar.update.service.js new file mode 100644 index 00000000..70899f29 --- /dev/null +++ b/ecomp-portal-FE/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/client/app/services/users/users.service.js b/ecomp-portal-FE/client/app/services/users/users.service.js new file mode 100644 index 00000000..79da9439 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/users/users.service.js @@ -0,0 +1,161 @@ +/*- + * ================================================================================ + * 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 UsersService { + constructor($q, $log, $http, conf,uuid) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + + + 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + 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(); + this.$log.info('UsersService::getUserAppRoles'); + + this.$http({ + method: "GET", + url: this.conf.api.userAppRoles, + params: {orgUserId: orgUserId, app: appid}, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (Object.keys(res.data).length == 0) { + deferred.reject("UsersService::getUserAppRoles: Failed"); + } else { + this.$log.info('UsersService::getUserAppRoles: Succeeded'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.debug("UsersService::getUserAppRoles: status.headers(FEErrorString)"); + this.$log.debug('UsersService::getUserAppRoles status.headers(FEErrorString)', status.headers('FEErrorString')); + deferred.reject(status); + }); + return deferred.promise; + } + + updateUserAppRoles(newUserAppRoles) { + let deferred = this.$q.defer(); + this.$log.info('UsersService::updateUserAppRoles'); + this.$http({ + method: "PUT", + url: this.conf.api.userAppRoles, + data: newUserAppRoles, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + deferred.resolve(res.data); + }) + .catch( status => { + deferred.reject(status); + }); + + return deferred.promise; + } + + } + UsersService.$inject = ['$q', '$log', '$http', 'conf','uuid4']; + angular.module('ecompApp').service('usersService', UsersService) +})(); diff --git a/ecomp-portal-FE/client/app/services/utils/utils.service.js b/ecomp-portal-FE/client/app/services/utils/utils.service.js new file mode 100644 index 00000000..6473a0cb --- /dev/null +++ b/ecomp-portal-FE/client/app/services/utils/utils.service.js @@ -0,0 +1,57 @@ +/*- + * ================================================================================ + * 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; + let myDebugServer = "www.mytesturl.com" + + if ((myHostName.includes(myDebugServer) || 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! REMOVE THIS BEFORE COMMIT'); + return true; + } + } catch (err) { + this.$log.error('UtilsService::isValidJSON: json passed is not valid: '+ err); + return false; + } + } + + } + UtilsService.$inject = ['$log']; + angular.module('ecompApp').service('utilsService', UtilsService) +})(); diff --git a/ecomp-portal-FE/client/app/services/widgets/widgets.service.js b/ecomp-portal-FE/client/app/services/widgets/widgets.service.js new file mode 100644 index 00000000..fd749c46 --- /dev/null +++ b/ecomp-portal-FE/client/app/services/widgets/widgets.service.js @@ -0,0 +1,178 @@ +/** + * Created by doritrieur on 12/3/15. + */ +'use strict'; + +(function () { + class WidgetsService { + constructor($q, $log, $http, conf,uuid) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + } + + 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 (res == null || res.data==null) { + deferred.reject("WidgetsService::getUserWidgets Failed"); + } 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 (Object.keys(res.data).length == 0) { + deferred.reject("WidgetsService::getManagedWidgets Failed"); + } 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + 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 (Object.keys(res.data).length == 0) { + 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(response.data.status === 404){ + deferred.resolve(false); + }else{ + deferred.reject(response.data); + } + }); + return deferred.promise; + } + + } + WidgetsService.$inject = ['$q', '$log', '$http', 'conf','uuid4']; + angular.module('ecompApp').service('widgetsService', WidgetsService) +})(); |