Groovy scripts header correction
[so.git] / bpmn / MSOURN-plugin / src / main / resources / plugin-webapp / urnMap-plugin / app / plugin.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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 define(['angular'], function(angular) {
22
23   var DashboardController = ["$scope", "$http", "Uri", function($scope, $http, Uri) {
24
25     $http.get(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance"))
26       .success(function(data) {
27         $scope.UrnDataMap = data;
28       });
29  
30     //enable saveRow button
31     $scope.enableButton=function(urnData)
32     {
33         document.getElementById("btn_" + urnData.urnname + "_key").disabled = false;
34     };
35     
36     $scope.enableAddRowBtn=function()
37     {
38         if(document.getElementById("new_key").value.trim().length >0)
39                  document.getElementById("addRow_BTN").disabled = false;
40         else
41                 document.getElementById("addRow_BTN").disabled = true;
42     };
43     
44     
45     $scope.addNewRow = function() 
46     {
47         var newKey = document.getElementById("new_key").value.trim();
48         var newValue = document.getElementById("new_value").value.trim();
49         var x;
50         
51         for (var i=0;i<$scope.UrnDataMap.length;i++)
52         {
53                 var n = $scope.UrnDataMap[i].urnname.localeCompare(newKey);
54                 if(n == 0){
55                         x = "match";
56                 }
57         }
58         
59         if(Boolean(x))
60         {
61                 alert("URN Name already exists, please check the KEY!");
62         }
63         else
64         {
65                 if(newKey.length >0 )
66                 {
67
68                         var temp = newKey + "|" + newValue;
69                 
70                         $http.put(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance"), temp);
71          
72                 document.getElementById("new_key").value = "";
73                 document.getElementById("new_value").value = "";
74
75                 }
76                 
77         }
78         //this.enableAddRowBtn;
79         document.getElementById("addRow_BTN").disabled = true;
80         
81      $http.get(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance"))
82         .success(function(data) {
83           $scope.UrnDataMap = data;
84         });
85         
86         
87       }
88     
89     $scope.retrieveData = function() {
90         
91          $http.get(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance"))
92          .success(function(data) {
93            $scope.UrnDataMap = data;
94          });
95     }
96     
97      $scope.SaveRow = function(user) 
98     {   
99         $http.post(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance"), user);
100                    
101         document.getElementById("btn_" + user.urnname + "_key").disabled = true;
102         document.getElementById(user.urnname + "_status").style.display = "";
103         this.enableAddRowBtn;
104         
105         $http.get(Uri.appUri("plugin://urnMap-plugin/:engine/process-instance"))
106         .success(function(data) {
107           $scope.UrnDataMap = data;
108         });
109         
110         };
111   }];
112
113   var Configuration = ['ViewsProvider', function(ViewsProvider) {
114
115     ViewsProvider.registerDefaultView('cockpit.dashboard', {
116       id: 'process-definitions',
117       label: 'Deployed Processes',
118       url: 'plugin://urnMap-plugin/static/app/dashboard.html',
119       controller: DashboardController,
120        // make sure we have a higher priority than the default plugin
121       priority: 12
122     });
123   }];
124 //START
125 //END
126   
127   var ngModule = angular.module('cockpit.plugin.urnMap-plugin', []);
128
129   ngModule.config(Configuration);
130
131   return ngModule;
132 });