2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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('msHeaderDefaultValuesDictGridController', function ($scope, PolicyAppService, modalService, $modal){
21 $( "#dialog" ).hide();
23 PolicyAppService.getData('getDictionary/get_MicroServiceHeaderDefaultsData').then(function (data) {
25 $scope.data = JSON.parse(j.data);
26 console.log($scope.data);
27 $scope.microServiceHeaderDefaultDatas = JSON.parse($scope.data.microServiceHeaderDefaultDatas);
28 console.log("microServiceHeaderDefaultDatas: " + $scope.microServiceHeaderDefaultDatas);
30 console.log("failed");
33 PolicyAppService.getData('getDictionary/get_MicroServiceModelsDataByName').then(function (data) {
35 $scope.data = JSON.parse(j.data);
36 console.log($scope.data);
37 $scope.microServiceModelsDictionaryDatas = JSON.parse($scope.data.microServiceModelsDictionaryDatas);
38 console.log($scope.microServiceModelsDictionaryDatas);
40 console.log("failed");
43 PolicyAppService.getData('getDictionary/get_RiskTypeDataByName').then(function (data) {
45 $scope.data = JSON.parse(j.data);
46 console.log("riskTypeDictionaryDatas: " + $scope.data);
47 $scope.riskTypeDictionaryDatas = JSON.parse($scope.data.riskTypeDictionaryDatas);
48 console.log($scope.riskTypeDictionaryDatas);
50 console.log("failed");
53 PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
55 $scope.data = JSON.parse(j.data);
56 console.log($scope.data);
57 $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas);
58 console.log($scope.onapNameDictionaryDatas);
60 console.log("failed");
63 PolicyAppService.getData('get_DCAEPriorityValues').then(function (data) {
65 $scope.data = JSON.parse(j.data);
66 console.log($scope.data);
67 $scope.priorityDatas = JSON.parse($scope.data.priorityDatas);
68 console.log($scope.priorityDatas);
70 console.log("failed");
73 PolicyAppService.getData('get_LockDownData').then(function(data){
75 $scope.data = JSON.parse(j.data);
76 $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
77 if($scope.lockdowndata[0].lockdown == true){
78 $scope.msHeaderDefaultValuesDictionaryGrid.columnDefs[0].visible = false;
79 $scope.gridApi.grid.refresh();
81 $scope.msHeaderDefaultValuesDictionaryGrid.columnDefs[0].visible = true;
82 $scope.gridApi.grid.refresh();
85 console.log("failed");
88 $scope.msHeaderDefaultValuesDictionaryGrid = {
89 data : 'microServiceHeaderDefaultDatas',
90 enableFiltering: true,
92 field: 'id', enableFiltering: false, headerCellTemplate: '' +
93 '<button id=\'New\' ng-click="grid.appScope.createNewModelAttributeWindow()" class="btn btn-success">' + 'Create</button>',
95 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editModelHeaderDefaultsWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
96 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteModelAttribute(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
97 },{ field: 'modelName', displayName :'MicroService', sort: { direction: 'asc', priority: 0 }},
98 { field: 'guard', displayName :'Guard'}, { field: 'priority', displayName :'Priority'},{ field: 'riskType', displayName :'Risk Type'},{ field: 'riskLevel', displayName :'Risk Level'},{field: 'onapName' , displayName :'Onap Name' }
102 $scope.editModelAttribute = null;
103 $scope.createNewModelAttributeWindow = function(){
104 $scope.editModelAttribute = null;
105 var modalInstance = $modal.open({
106 backdrop: 'static', keyboard: false,
107 templateUrl : 'add_HeaderDefaultValues_popup.html',
108 controller: 'editMSHeaderDefaultValuesController',
110 message: function () {
112 microServiceAttributeDictionaryDatas: $scope.editModelAttribute
118 modalInstance.result.then(function(response){
119 console.log('response', response);
120 $scope.microServiceHeaderDefaultDatas=response.microServiceHeaderDefaultDatas;
124 $scope.editModelHeaderDefaultsWindow = function(modelAttributeDictionaryData) {
125 $scope.editHeaderDefaults = modelAttributeDictionaryData;
126 var modalInstance = $modal.open({
127 backdrop: 'static', keyboard: false,
128 templateUrl : 'add_HeaderDefaultValues_popup.html',
129 controller: 'editMSHeaderDefaultValuesController',
131 message: function () {
133 modelAttributeDictionaryData: $scope.editHeaderDefaults
139 modalInstance.result.then(function(response){
140 console.log('response', response);
141 $scope.modelAttributeDictionaryDataa = response.modelAttributeDictionaryDatas;
145 $scope.deleteModelAttribute = function(data) {
146 modalService.popupConfirmWin("Confirm","You are about to delete the Header Default Values : "+data.modelName+". Do you want to continue?",
148 var uuu = "deleteDictionary/ms_dictionary/remove_headerDefaults";
149 var postData={data: data};
154 contentType: 'application/json',
155 data: JSON.stringify(postData),
156 success : function(data){
157 $scope.$apply(function(){$scope.microServiceHeaderDefaultDatas=data.microServiceHeaderDefaultDatas;});
159 error : function(data){
161 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);