X-Git-Url: https://gerrit.onap.org/r/gitweb?p=portal.git;a=blobdiff_plain;f=ecomp-portal-FE-os%2Fclient%2Fsrc%2Fviews%2Fapplications%2Fapplication-details-dialog%2Fapplication-details.controller.js;h=bf480977d70fe8ba56348dac3860449ee0f01034;hp=550b9faf6080d8c4cd4b21af655d74be63faba2c;hb=e10ac2557a212fc18cbb7aee51adb8f7f606eade;hpb=978dbcf0a196acbafad72fe1e2478ec0e384f02f diff --git a/ecomp-portal-FE-os/client/src/views/applications/application-details-dialog/application-details.controller.js b/ecomp-portal-FE-os/client/src/views/applications/application-details-dialog/application-details.controller.js index 550b9faf..bf480977 100644 --- a/ecomp-portal-FE-os/client/src/views/applications/application-details-dialog/application-details.controller.js +++ b/ecomp-portal-FE-os/client/src/views/applications/application-details-dialog/application-details.controller.js @@ -1,26 +1,44 @@ /*- - * ================================================================================ - * 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. + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * 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. - * ================================================================================ + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. + * + * ============LICENSE_END============================================ + * + * */ 'use strict'; (function () { class AppDetailsModalCtrl { - constructor($scope, $log, applicationsService, errorMessageByCode, + constructor($scope, $log, $timeout, applicationsService, errorMessageByCode, ECOMP_URL_REGEX,userProfileService, $cookies, confirmBoxService,items) { // let emptyImg = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='; // empty image should really be empty, or it causes problems for the back end @@ -40,7 +58,7 @@ 'username': null, 'appPassword': null, 'thumbnail': emptyImg, - 'isEnabled': true, + 'isEnabled': false, 'restrictedApp': false, 'nameSpace': null, 'isCentralAuth': false @@ -116,8 +134,8 @@ userProfileService.getUserProfile() .then(profile=> { // $log.info(profile); - $scope.orgUserId = profile.attuid; - $log.debug('AppDetailsModalCtrl:emptyCookies for the following attuid: ' + profile.attuid); + $scope.orgUserId = profile.orgUserId; + $log.debug('AppDetailsModalCtrl:emptyCookies for the following orgUserId: ' + profile.orgUserId); if ($cookies.getObject($scope.orgUserId + '_apps') != undefined && $cookies.getObject($scope.orgUserId + '_apps') != null) { $cookies.remove($scope.orgUserId + '_apps'); $log.debug('AppDetailsModalCtrl:emptyCookies removed: ' + $scope.orgUserId + '_apps'); @@ -154,15 +172,45 @@ //*************************** this.saveChanges = () => { - //if valid.. - if(((angular.isUndefined(this.app.name) || !this.app.name)&&(angular.isUndefined(this.app.url) || !this.app.url) - &&(angular.isUndefined(this.app.username) || !this.app.username)&&(angular.isUndefined(this.app.appPassword) || !this.app.appPassword))) { - confirmBoxService.showInformation('Please fill in all required fields').then(isConfirmed => {}); - return; - }else if(!((angular.isUndefined(this.app.name) || !!this.app.name)&&(angular.isUndefined(this.app.url) || !!this.app.url))){ - confirmBoxService.showInformation('Please fill in all required fields').then(isConfirmed => {}); - return; - } + //if valid.. + if(this.app.isCentralAuth){ + //if valid. + if(!this.app.isEnabled) + { + if(((angular.isUndefined(this.app.name) || !this.app.name)||(angular.isUndefined(this.app.nameSpace) || !this.app.nameSpace) + ||(angular.isUndefined(this.app.username) || !this.app.username))) { + confirmBoxService.showInformation('Please fill in all required fields for centralized application').then(isConfirmed => {}); + return; + } + } + if(this.app.isEnabled){ + if(((angular.isUndefined(this.app.name) || !this.app.name)||(angular.isUndefined(this.app.url) || !this.app.url) + ||(angular.isUndefined(this.app.username) || !this.app.username)||(angular.isUndefined(this.app.nameSpace) || !this.app.nameSpace))) { + confirmBoxService.showInformation('Please fill in all required fields for centralized active application').then(isConfirmed => {}); + return; + } + } + }else{ + + if(!this.app.isEnabled) + { + if((angular.isUndefined(this.app.name) || !this.app.name)){ + confirmBoxService.showInformation('Please fill in all required field ApplicationName to Save the applictaion').then(isConfirmed => {}); + return; + } + }else if(this.app.isEnabled && !this.app.restrictedApp){ + if(((angular.isUndefined(this.app.name) || !this.app.name)||(angular.isUndefined(this.app.url) || !this.app.url) + ||(angular.isUndefined(this.app.username) || !this.app.username)||(angular.isUndefined(this.app.appPassword) || !this.app.appPassword))) { + confirmBoxService.showInformation('Please fill in all required fields along with password as the app is not centralized').then(isConfirmed => {}); + return; + } }else if(this.app.isEnabled && this.app.restrictedApp){ + if((angular.isUndefined(this.app.name) || !this.app.name) ||(angular.isUndefined(this.app.url) || !this.app.url)){ + confirmBoxService.showInformation('Please fill in all required fields').then(isConfirmed => {}); + return; + + } + } + } this.isSaving = true; // For a restricted app, null out all irrelevant fields if (this.app.restrictedApp) { @@ -245,6 +293,23 @@ } }; + + // Caches the file name supplied by the event handler. + $scope.appImageHandler = (event, files) => { + if(files[0]){ + var fileName = files[0].name; + var validFormats = ['jpg', 'jpeg', 'bmp', 'gif', 'png']; + //Get file extension + var ext = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase(); + //Check for valid format + if(validFormats.indexOf(ext) == -1){ + $scope.appImageTypeError=true; + $timeout(function(){ + $scope.appImageTypeError=false; + }, 5000); + } + } + }; // file change handler init(); @@ -275,7 +340,7 @@ }); } } - AppDetailsModalCtrl.$inject = ['$scope', '$log', 'applicationsService', 'errorMessageByCode', + AppDetailsModalCtrl.$inject = ['$scope', '$log', '$timeout', 'applicationsService', 'errorMessageByCode', 'ECOMP_URL_REGEX','userProfileService','$cookies', 'confirmBoxService','items']; angular.module('ecompApp').controller('AppDetailsModalCtrl', AppDetailsModalCtrl); -})(); \ No newline at end of file +})();