2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  20 app.controller('msModelsDictGridController', function ($scope, PolicyAppService, modalService, $modal){
 
  21     $( "#dialog" ).hide();
 
  23     PolicyAppService.getData('getDictionary/get_MicroServiceModelsData').then(function (data) {
 
  25         $scope.data = JSON.parse(j.data);
 
  26         console.log($scope.data);
 
  27         $scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
 
  28         console.log($scope.microServiceModelsDictionaryDatas);
 
  30         console.log("failed");
 
  33     PolicyAppService.getData('get_LockDownData').then(function(data){
 
  35         $scope.data = JSON.parse(j.data);
 
  36         $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
 
  37         if($scope.lockdowndata[0].lockdown == true){
 
  38                 $scope.msModelsDictionaryGrid.columnDefs[0].visible = false;
 
  39                 $scope.gridApi.grid.refresh();
 
  41                 $scope.msModelsDictionaryGrid.columnDefs[0].visible = true;
 
  42                 $scope.gridApi.grid.refresh();
 
  45         console.log("failed");
 
  48     $scope.msModelsDictionaryGrid = {
 
  49         data : 'microServiceModelsDictionaryDatas',
 
  50         enableFiltering: true,
 
  52             field: 'id', enableFiltering: false, headerCellTemplate: '' +
 
  53             '<button id=\'New\' ng-click="grid.appScope.createNewMSModelsWindow()" class="btn btn-success">' + 'Create</button>',
 
  55                 '<button  type="button"  class="btn btn-danger"  ng-click="grid.appScope.deleteMSModels(row.entity)" ><i class="fa fa-trash-o"></i></button> ',  width: '8%'
 
  56         },{ field: 'modelName', displayName : 'Micro Service Model', sort: { direction: 'asc', priority: 0 }},
 
  57             { field: 'description' },
 
  58             { field: 'version', displayName : 'Model Version' },
 
  59             {field: 'userCreatedBy.userName', displayName : 'Imported By' }
 
  62     $scope.editMSmodelName = null;
 
  63     $scope.createNewMSModelsWindow = function(){
 
  64         $scope.editMSmodelName = null;
 
  65         var modalInstance = $modal.open({
 
  66                 backdrop: 'static', keyboard: false,
 
  67             templateUrl : 'add_msModel_popup.html',
 
  68             controller: 'editMSModelController',
 
  70                 message: function () {
 
  72                         microServiceModelsDictionaryDatas: $scope.editMSmodelName
 
  78         modalInstance.result.then(function(response){
 
  79             console.log('response', response);
 
  80             $scope.microServiceModelsDictionaryDatas=response.microServiceModelsDictionaryDatas;
 
  84     $scope.editMSModelsWindow = function(microServiceModelsDictionaryData) {
 
  85         $scope.editMSmodelName = microServiceModelsDictionaryData;
 
  86         var modalInstance = $modal.open({
 
  87                 backdrop: 'static', keyboard: false,
 
  88             templateUrl : 'add_msModel_popup.html',
 
  89             controller: 'editMSModelController',
 
  91                 message: function () {
 
  93                         microServiceModelsDictionaryData: $scope.editMSmodelName
 
  99         modalInstance.result.then(function(response){
 
 100             console.log('response', response);
 
 101             $scope.microServiceModelsDictionaryDatas = response.microServiceModelsDictionaryDatas;
 
 105     $scope.deleteMSModels = function(data) {
 
 106         modalService.popupConfirmWin("Confirm","You are about to delete the MicroService Model : "+data.modelName+". Do you want to continue?",
 
 108                 var uuu = "deleteDictionary/ms_dictionary/remove_msModel";
 
 109                 var postData={data: data};
 
 114                     contentType: 'application/json',
 
 115                     data: JSON.stringify(postData),
 
 116                     success : function(data){
 
 117                         $scope.$apply(function(){$scope.microServiceModelsDictionaryDatas=data.microServiceModelsDictionaryDatas;});
 
 119                     error : function(data){
 
 121                         modalService.showFailure("Fail","Error while deleting: "+ data.responseText);