2  * ============LICENSE_START==========================================
 
   4  * ===================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * ===================================================================
 
   8  * Unless otherwise specified, all software contained herein is licensed
 
   9  * under the Apache License, Version 2.0 (the "License");
 
  10  * you may not use this software except in compliance with the License.
 
  11  * You may obtain a copy of the License at
 
  13  *             http://www.apache.org/licenses/LICENSE-2.0
 
  15  * Unless required by applicable law or agreed to in writing, software
 
  16  * distributed under the License is distributed on an "AS IS" BASIS,
 
  17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  18  * See the License for the specific language governing permissions and
 
  19  * limitations under the License.
 
  21  * Unless otherwise specified, all documentation contained herein is licensed
 
  22  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
 
  23  * you may not use this documentation except in compliance with the License.
 
  24  * You may obtain a copy of the License at
 
  26  *             https://creativecommons.org/licenses/by/4.0/
 
  28  * Unless required by applicable law or agreed to in writing, documentation
 
  29  * distributed under the License is distributed on an "AS IS" BASIS,
 
  30  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  31  * See the License for the specific language governing permissions and
 
  32  * limitations under the License.
 
  34  * ============LICENSE_END============================================
 
  36  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
 
  40     class MicroserviceOnboardingCtrl {
 
  41         constructor($log, applicationsService, microserviceService, ngDialog, confirmBoxService,
 
  42                     userProfileService, $cookies, $scope,$modal) {
 
  45             let getOnboardingServices = () => {
 
  46                 microserviceService.getServiceList().then(res => {
 
  47                      $scope.serviceList = res;
 
  49                     $log.error('MicroserviceOnboardingCtrl::getOnboardingServices caught error', err);
 
  56                 $scope.serviceList = [];
 
  57                 getOnboardingServices();
 
  58                 this.serviceTableHeaders = [
 
  59                     {name: 'Microservice Name', value: 'name', isSortable: false},
 
  60                     {name: 'Service Endpoint URL', value: 'url', isSortable: false},
 
  61                     {name: 'Security Type', value: 'securityType', isSortable: false}
 
  65             this.openAddNewMicroserviceModal = (selectedService) => {
 
  68                                         if(!selectedService.id){
 
  69                                                 $log.error('MicroserviceOnboardingCtrl:openAddNewMicroserviceModal:service id not found');
 
  73                                                 service:selectedService,
 
  74                                                 list: $scope.serviceList
 
  78                                                 list: $scope.serviceList        
 
  82                                 var modalInstance = $modal.open({
 
  83                     templateUrl: 'app/views/microservice-onboarding/microservice-add-details/microservice-add-details.html',
 
  84                     controller: 'MicroserviceAddDetailsCtrl as microserviceAddDetails',
 
  85                     sizeClass: 'modal-large', 
 
  93                 modalInstance.result.finally(function (){
 
  94                                 getOnboardingServices();
 
  99             this.deleteService = service => { 
 
 100                    confirmBoxService.deleteItem(service.name).then(isConfirmed => {   
 
 102                                 if(!service || !service.id){
 
 103                            $log.error('MicroserviceOnboardingCtrl::deleteService: No service or ID... cannot delete');
 
 106                        microserviceService.deleteService(service.id).then((res) => {                               
 
 107                            if(res.status == "WARN"){
 
 108                                    confirmBoxService.showInformation("Failed: widgets " +  res.response + " are assoicated with this microservice!");
 
 110                                    $scope.serviceList.splice($scope.serviceList.indexOf(service), 1);
 
 113                            $log.error('MicroserviceOnboardingCtrl::deleteService error:',err);
 
 117                    $log.error('MicroserviceOnboardingCtrl::deleteService error:',err);
 
 126     MicroserviceOnboardingCtrl.$inject = ['$log', 'applicationsService', 'microserviceService', 'ngDialog', 'confirmBoxService',
 
 127         'userProfileService','$cookies', '$scope','$modal'];
 
 128     angular.module('ecompApp').controller('MicroserviceOnboardingCtrl', MicroserviceOnboardingCtrl);