cc3dd14ee190cadcd3a03ce9c1b71a2f11f7a095
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / controller / DictionaryController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 var mainDictionarys = ["Action Policy", "BRMS Policy", "Common Dictionary", "ClosedLoop Policy","Decision Policy", "Descriptive Policy",
22          "Firewall Policy", "MicroService Policy", "Policy Scope", "Safe Policy Dictionary"];
23 var subDictionarys = [["Action Dictionary"],
24         ["BRMS Controller" , "BRMS Dependency", "BRMS Param Template"],
25         ["Attribute Dictionary","OnapName Dictionary"],
26         ["PEP Options","Site Dictionary","Service Dictionary","Varbind Dictionary", "VNF Type","VSCL Action"],
27         ["Settings Dictionary","Rainy Day Allowed Treatments"],
28         ["Descriptive Scope"],
29         ["Action List", "Address Group", "Parent Dictionary List", "Port List", "Prefix List", "Protocol List", "Security Zone", "Service Group", "Service List", "Tag List", "Tag Picker List", "Term List", "Zone"],
30         ["DCAE UUID","MicroService ConfigName","MicroService Location", "MicroService Models", "MicroService Dictionary"],
31         ["Closed Loop", "Group Policy Scope", "Resource", "Service", "Type"],
32         ["Risk Type", "Safe Policy Warning"]];
33 app.controller('dictionaryTabController', function ($scope, PolicyAppService, modalService, $modal){
34         $( "#dialog" ).hide();
35         
36         $scope.isDisabled = true;
37         PolicyAppService.getData('get_LockDownData').then(function(data){
38                  var j = data;
39                  $scope.data = JSON.parse(j.data);
40                  $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
41                  if($scope.lockdowndata[0].lockdown == true){
42                          $scope.isDisabled = true;
43                          this.isDisabled = true;
44                  }else{
45                          $scope.isDisabled = false;
46                          this.isDisabled = false;
47                  }
48                  console.log($scope.data);
49          },function(error){
50                  console.log("failed");
51          });
52          
53         $scope.options1 = mainDictionarys;
54         $scope.options2 = [];
55         $scope.getOptions2 = function(){
56                 var key = $scope.options1.indexOf($scope.option1);
57                 var myNewOptions = subDictionarys[key];
58                 $scope.options2 = myNewOptions;
59         };
60         
61         $scope.import = function() {
62                 $scope.data = {};
63                 var modalInstance = $modal.open({
64                         backdrop: 'static', keyboard: false,
65                         templateUrl : 'import_dictionary_popup.html',
66                         controller: 'importDictionaryController',
67                         resolve: {
68                                 message: function () {
69                                         var message = {
70                                                 data: $scope.data
71                                         };
72                                         return message;
73                                 }                                       
74                         }
75                 }); 
76                 modalInstance.result.then(function(response){
77                         console.log('response', response);
78                 });
79         };
80
81 });