CLAMP Model policy creation support
[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-2019 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", "Optimization 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","Header Default Values","MicroService ConfigName","MicroService Location", "MicroService Models", "MicroService Dictionary","MicroService Dictionary Input"],
31         ["ONAP Optimization Models"],
32         ["Closed Loop", "Group Policy Scope", "Resource", "Service", "Type"],
33         ["Risk Type", "Safe Policy Warning"]];
34 app.controller('dictionaryTabController', function ($scope, PolicyAppService, modalService, $modal){
35         $( "#dialog" ).hide();
36         
37         $scope.isDisabled = true;
38         PolicyAppService.getData('get_LockDownData').then(function(data){
39                  var j = data;
40                  $scope.data = JSON.parse(j.data);
41                  $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
42                  if($scope.lockdowndata[0].lockdown == true){
43                          $scope.isDisabled = true;
44                          this.isDisabled = true;
45                  }else{
46                          $scope.isDisabled = false;
47                          this.isDisabled = false;
48                  }
49                  console.log($scope.data);
50          },function(error){
51                  console.log("failed");
52          });
53          
54         $scope.options1 = mainDictionarys;
55         $scope.options2 = [];
56         $scope.getOptions2 = function(){
57                 var key = $scope.options1.indexOf($scope.option1);
58                 var myNewOptions = subDictionarys[key];
59                 $scope.options2 = myNewOptions;
60         };
61         
62         $scope.import = function() {
63                 $scope.data = {};
64                 var modalInstance = $modal.open({
65                         backdrop: 'static', keyboard: false,
66                         templateUrl : 'import_dictionary_popup.html',
67                         controller: 'importDictionaryController',
68                         resolve: {
69                                 message: function () {
70                                         var message = {
71                                                 data: $scope.data
72                                         };
73                                         return message;
74                                 }                                       
75                         }
76                 }); 
77                 modalInstance.result.then(function(response){
78                         console.log('response', response);
79                 });
80         };
81
82 });