diff options
Diffstat (limited to 'ecomp-portal-FE-common/client/app/services')
19 files changed, 3150 insertions, 2952 deletions
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 index 3658052c..60a99f55 100644 --- a/ecomp-portal-FE-common/client/app/services/admins/admins.service.js +++ b/ecomp-portal-FE-common/client/app/services/admins/admins.service.js @@ -1,221 +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)
-})();
+/*- + * ================================================================================ + * 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/audit-log/audit-log.service.js b/ecomp-portal-FE-common/client/app/services/audit-log/audit-log.service.js index 93a61310..af48fd64 100644 --- 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 @@ -1,92 +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;
-}
+/*- + * ================================================================================ + * 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 index 5a684784..dccc5b20 100644 --- a/ecomp-portal-FE-common/client/app/services/base64/base64.service.js +++ b/ecomp-portal-FE-common/client/app/services/base64/base64.service.js @@ -1,69 +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)
-})();
+/*- + * ================================================================================ + * 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/be-property-reader/be-property-reader.service.js b/ecomp-portal-FE-common/client/app/services/be-property-reader/be-property-reader.service.js index b3ad6b36..8e30aa2e 100644 --- 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 @@ -1,70 +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)
-})();
+/*- + * ================================================================================ + * 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 index 63d5b966..6b89341d 100644 --- a/ecomp-portal-FE-common/client/app/services/catalog/catalog.service.js +++ b/ecomp-portal-FE-common/client/app/services/catalog/catalog.service.js @@ -1,172 +1,202 @@ -/*-
- * ================================================================================
- * 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)
-})();
+/*- + * ================================================================================ + * 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; + } + + getAppsFullList() { + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + url: this.conf.api.appsFullList, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }) + .then( res => { + if (this.debug) + this.$log.debug('CatalogService::getAppsFullList: 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::getAppsFullList: result data is not JSON'; + if (this.debug) + this.$log.error(msg); + deferred.reject(msg); + } else { + if (this.debug) + this.$log.debug('CatalogService::getAppsFullList: success'); + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('CatalogService:getAppsFullList 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 index 97ebb1e5..7379a29e 100644 --- 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 @@ -1,236 +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)
-})();
+/*- + * ================================================================================ + * 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 index 45c95e9c..6158498f 100644 --- 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 @@ -1,247 +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)
-})();
+/*- + * ================================================================================ + * 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 index c4b2e578..9e5e69be 100644 --- a/ecomp-portal-FE-common/client/app/services/dashboard/dashboard.service.js +++ b/ecomp-portal-FE-common/client/app/services/dashboard/dashboard.service.js @@ -1,185 +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)
-})();
+/*- + * ================================================================================ + * 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/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 index 0ef930c6..3be977b9 100644 --- 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 @@ -1,63 +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)
-})();
+/*- + * ================================================================================ + * 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/global-constants/global-constants.js b/ecomp-portal-FE-common/client/app/services/global-constants/global-constants.js index 3e3e1a5f..0bfbe531 100644 --- 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 @@ -1,23 +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);
+/*- + * ================================================================================ + * 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 index 120cb640..89709a84 100644 --- a/ecomp-portal-FE-common/client/app/services/manifest/manifest.service.js +++ b/ecomp-portal-FE-common/client/app/services/manifest/manifest.service.js @@ -1,64 +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)
-})();
+/*- + * ================================================================================ + * 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 index 6cc0eff9..957cb6d8 100644 --- a/ecomp-portal-FE-common/client/app/services/menus/menus.service.js +++ b/ecomp-portal-FE-common/client/app/services/menus/menus.service.js @@ -56,7 +56,34 @@ return deferred.promise; } - + + getEcompPortalTitle () { + let deferred = this.$q.defer(); + this.$http({ + method: 'GET', + url: this.conf.api.ecompTitle, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (res.data==null || !this.utilsService.isValidJSON(res.data)) { + deferred.reject('MenusService::getEcompPortalTitle rest call failed'); + } else { + if(res.data.status!='OK' && res.data.message!=null) + deferred.reject('MenusService::getEcompPortalTitle rest call failed ' + res.data.message); + else + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('MenusService::getEcompPortalTitle rejection:' + status); + deferred.reject(status); + }); + + return deferred.promise; + } + getFavoriteItems() { let deferred = this.$q.defer(); // this.$log.info('MenusService::getFavoriteItems via REST API'); 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 index cb27cd4c..393e7ccb 100644 --- a/ecomp-portal-FE-common/client/app/services/microservice/microservice.service.js +++ b/ecomp-portal-FE-common/client/app/services/microservice/microservice.service.js @@ -1,218 +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)
-})();
+/*- + * ================================================================================ + * 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 index cf180e83..d7d46079 100644 --- a/ecomp-portal-FE-common/client/app/services/notification/notification.service.js +++ b/ecomp-portal-FE-common/client/app/services/notification/notification.service.js @@ -1,322 +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)
-})();
+/*- + * ================================================================================ + * 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/recommendation/recommendation.service.js b/ecomp-portal-FE-common/client/app/services/recommendation/recommendation.service.js new file mode 100644 index 00000000..aa2a4631 --- /dev/null +++ b/ecomp-portal-FE-common/client/app/services/recommendation/recommendation.service.js @@ -0,0 +1,88 @@ +/*- + * ================================================================================ + * 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 RecommendationService { + constructor($q, $log, $http, conf, uuid,utilsService) { + this.$q = $q; + this.$log = $log; + this.$http = $http; + this.conf = conf; + this.uuid = uuid; + this.recommendationCount = {count:0}; + this.refreshCount = 0; + this.maxCount = 0; + this.utilsService = utilsService; + } + getRecommendationCount() { + return this.recommendationCount; + } + setRecommendationCount(count) { + this.recommendationCount.count = count; + } + getRefreshCount() { + return this.refreshCount; + } + setRefreshCount(count){ + this.refreshCount = count; + } + setMaxRefreshCount(count){ + this.maxCount = count; + } + decrementRefreshCount(){ + this.refreshCount = this.refreshCount - 1; + } + + + getRecommendations(){ + let deferred = this.$q.defer(); + this.$http({ + method: "GET", + cache: false, + url: this.conf.api.getRecommendations, + 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::getRecommendations Failed'); + deferred.reject("NotificationService::getRecommendations Failed"); + } else { + deferred.resolve(res); + } + }) + .catch( status => { + this.$log.error('NotificationService::getRecommendations Failed', status); + deferred.reject(status); + }); + + return deferred.promise; + } + + + } + RecommendationService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4','utilsService']; + angular.module('ecompApp').service('recommendationService', RecommendationService) +})(); 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 index f8fee136..ee2cd536 100644 --- a/ecomp-portal-FE-common/client/app/services/role/role.service.js +++ b/ecomp-portal-FE-common/client/app/services/role/role.service.js @@ -1,190 +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);
- });
- }
- };
-});
+/*- + * ================================================================================ + * 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/users/users.service.js b/ecomp-portal-FE-common/client/app/services/users/users.service.js index 894aac0d..808a6632 100644 --- a/ecomp-portal-FE-common/client/app/services/users/users.service.js +++ b/ecomp-portal-FE-common/client/app/services/users/users.service.js @@ -1,215 +1,268 @@ -/*-
- * ================================================================================
- * 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)
-})();
+/*- + * ================================================================================ + * 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, extRequestValue){ + let canceller = this.$q.defer(); + let isActive = false; + + let cancel = () => { + if(isActive){ + this.$log.debug('UsersService::getUserAppRoles: canceling the request'); + canceller.resolve(); + } + }; + + let promise = () => { + let deferred = this.$q.defer(); + isActive = false; + this.$http({ + method: 'GET', + url: this.conf.api.userAppRoles, + params: {user: orgUserId, app: appid, externalRequest: extRequestValue}, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate() + } + }).then( res => { + if (!this.utilsService.isValidJSON(res.data)) { + deferred.reject('UsersService::getUserAppRoles: Failed'); + } else { + isActive = false; + 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 + }; + + } + + getLoggedInUser () { + let deferred = this.$q.defer(); + this.$http({ + method: 'GET', + url: this.conf.api.loggedinUser, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate(), + 'Content-Type': 'application/json' + }, + data: '' + }).then( res => { + if (res.data==null || !this.utilsService.isValidJSON(res.data)) { + deferred.reject('MenusService::getLoggedInUser rest call failed'); + } else { + if(res.data.status!='OK' && res.data.message!=null) + deferred.reject('MenusService::getLoggedInUser rest call failed ' + res.data.message); + else + deferred.resolve(res.data); + } + }) + .catch( status => { + this.$log.error('MenusService::getLoggedInUser rejection:' + status); + deferred.reject(status); + }); + + return deferred.promise; + } + + modifyLoggedInUser (profileDetail) { + let deferred = this.$q.defer(); + this.$http({ + method: 'PUT', + url: this.conf.api.modifyLoggedinUser, + cache: false, + headers: { + 'X-ECOMP-RequestID':this.uuid.generate(), + 'Content-Type': 'application/json' + }, + data: profileDetail + }).then( res => { + if (res.data==null || !this.utilsService.isValidJSON(res.data)) { + deferred.reject('MenusService::getLoggedInUser rest call failed'); + } else { + if(res.data.status!='OK' && res.data.message!=null) + deferred.reject('MenusService::getLoggedInUser rest call failed ' + res.data.message); + else + deferred.resolve(res.data); + } + }) + .catch( status => { + console.log(status); + this.$log.error('MenusService::getLoggedInUser rejection:' + status); + deferred.reject(status); + }); + + return deferred.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/widgets-catalog/widgets-catalog.service.js b/ecomp-portal-FE-common/client/app/services/widgets-catalog/widgets-catalog.service.js index 99ace1cb..c3b57e37 100644 --- 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 @@ -1,358 +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)
-})();
+/*- + * ================================================================================ + * 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 index 735a7319..601c9ff9 100644 --- a/ecomp-portal-FE-common/client/app/services/widgets/widgets.service.js +++ b/ecomp-portal-FE-common/client/app/services/widgets/widgets.service.js @@ -1,206 +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)
-})();
+/*- + * ================================================================================ + * 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) +})(); |