1d4659e3c56717fd30584e57c47f1be5341d08b6
[portal/sdk.git] /
1 appDS2.controller('droolsController', function($scope, $modal, $routeParams, DroolsService, modalService) {
2         $scope.tableDate=[];
3         $scope.resultsString = "";
4         $scope.postDroolsBean={
5                         droolsFile:'',
6                         className:'',
7                         selectedRules:''
8         };
9         $scope.filenameFromUrl = $routeParams.filename;
10         if($scope.filenameFromUrl!='' && $scope.filenameFromUrl!='0')
11                 $scope.postDroolsBean.droolsFile = $scope.filenameFromUrl
12         $scope.execute = function(postDroolsBean) {
13                 if($scope.postDroolsBean.droolsFile=='' ||$scope.postDroolsBean.className=='' || $scope.postDroolsBean.selectedRules=='' ){
14                         modalService.errorPopUp ("Required fields cannot be empty");
15                         return;
16                 }
17                 var uuu = "post_drools/execute";
18                 var postData={postDroolsBean:postDroolsBean};
19                 DroolsService.executeDrools(postData).then(function(data){      
20                         $scope.resultsString=data.resultsString;
21                         modalService.successPopUp($scope.resultsString);
22                 },function(error){
23                         modalService.errorPopUp (error);
24                 });
25         };      
26 });
27
28 appDS2.controller('droolsListController', function($scope, $modal, DroolsService, modalService) {
29         $scope.tableDate=[];
30         $scope.resultsString = "";
31         $scope.postDroolsBean="";
32         
33         $scope.getDroolsList = function(){
34                 DroolsService.getDroolsList().then(function(data){
35                         var j = data;
36                         $scope.tableData = JSON.parse(j.data);
37                         $scope.buildTable();
38                 },function(error){
39                         modalService.errorPopUp (error);
40                 });
41         }
42         
43         $scope.buildTable = function(){
44                 for(x in $scope.tableData){
45                         if($scope.tableData[x].active_yn=='Y')
46                                 $scope.tableData[x].active_yn=true;
47                         else
48                                 $scope.tableData[x].active_yn=false;
49                 }
50         }       
51     
52 });
53