angularJS项目


前前后后5周。整理总结备用,知识点:

1、路由;

2、页面跳转;

3、页面弹框;

4、过滤器;

5、生成完doc后再初始化echarts。


<!DOCTYPE html>
<html ng-app="home.controller">

	<head>

		<meta charset="utf-8">
		<title>平台</title>

		<link href="page/common/css/bootstrap.min.css" rel="stylesheet"/>  
		<link href="page/common/css/site.min.css?1507601668481" rel="stylesheet"/> 
 
		<script src="page/common/js/angular.js"></script>
		<script src="page/common/js/angular-animate.min.js"></script> 
		<script src="page/common/js/ui-bootstrap-tpls.js"></script>
        <script src="page/common/js/jquery-1.10.2.js"></script>
        <script src="page/common/js/angular-ui-router.min.js"></script>
        <script src="page/common/js/echarts-all.js"></script>


        <script src="page/app/js/home-controller.js"></script>
        <script src="page/app/js/createdrl-controller.js"> </script>
        <script src="page/app/js/pcd-api.js"> </script>
        <script src="page/app/js/ruleteam-controller.js"> </script>



		<style type="text/css">
            .login_header {
                background: url(./page/pictures/logo_idm.jpg) center left no-repeat;
                width: 100%;
                height: 100px;
                background-color: #FFFFFF;
                margin-top: 0px;
            }
			.spinner {
			  left: 30% ;
			  width: 60px;
			  height: 60px;
			  background-color: #67CF22; 
			  margin: 100px auto;
			  -webkit-animation: rotateplane 1.2s infinite ease-in-out;
			  animation: rotateplane 1.2s infinite ease-in-out;
			}
			 
			@-webkit-keyframes rotateplane {
			  0% { -webkit-transform: perspective(120px) }
			  50% { -webkit-transform: perspective(120px) rotateY(180deg) }
			  100% { -webkit-transform: perspective(120px) rotateY(180deg)  rotateX(180deg) }
			}
			 
			@keyframes rotateplane {
			  0% {
			    transform: perspective(120px) rotateX(0deg) rotateY(0deg);
			    -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg)
			  } 50% {
			    transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg);
			    -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg)
			  } 100% {
			    transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
			    -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg);
			  }
			}

            ul {
                margin: 0;
                padding: 0;
            }

            li {
                margin: 0;
                padding: 0;
            }

            #myTab li {
                width: 25%;
                float: left;
                height: 40px;
                list-style: none;
                margin: 0;
                padding: 0;
            }

             #myTab li img {
                 float: left;
                 height: 40px;
             }

             #myTab li a {
                 color: white;
                 text-align: center;
                 position: relative;
                 display: block;
                 padding: 10px 15px;
             }

            .blue {
                background: #0f9af2;
            }

            .gray {
                background: #dfdfdf;
            }

            .tabPaneUl {
                width: 700px;
                margin: 0 auto;
                list-style: none;
            }

              .tabPaneUl li {
                  height: 40px;
                  line-height: 40px;
              }

            .tab-pane {
                margin-top: 50px;
            }


		</style>

	</head>

	<body style="background-color: #ebebeb">

        <header class="login_header"></header>

		<div>
			<div class="col-xs-1">
                <br />
                <br /> 
                <div class="row"> 
                </div>
				<ul class="">
			 		<li>
						<a ui-sref="ruleteam" ui-sref-opts="{reload:true}">我的团队</a>
					</li> 
				</ul>
			</div>
			<div class="col-xs-10">
				<div ui-view></div>
				<br/>
				<br/> 
			</div>
		</div>
	</body>

</html>




<div class="container projects"> 
  
    <div ng-show="team_info_show">
        <div>
            <div class="col-md-10">
            </div>
            <div class="col-md-2">
                <button type="button" class="btn btn-success" data-toggle="modal" ng-click="addOneTeam()">
                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>  团队(TEAM)
                </button>
            </div>
        </div>
        <div class="projects-header page-header">
        </div>
       
       <div class="row">
            <div class="col-sm-6 col-md-4 col-lg-3 " ng-repeat="team in rule_teams">
                <div class="thumbnail">
                    <a href=""  ng-click="showRuleByTeamId(team.teamId , team.ruleNum)">
                        <img src="./page/pictures/rule_teams.jpg" width="300" height="150">
                    </a>
                    <div class="caption">
                        <h3>
                            {{team.teamName}}
                        </h3> 
                        <small>拥有</small>
                        <br />
                        <h1>
                            <font color="blue">{{team.ruleNum}}</font> 
                        </h1>
                        <div class="btn-group">
                            <button type="button"  class="btn btn-default" data-toggle="modal"  ng-click="addRule(team.teamId ,team.teamName)">
                                <span class="glyphicon glyphicon-plus" aria-hidden="true">
                                    规则
                                </span>
                            </button>
                            <button type="button" class="btn btn-default" data-toggle="modal" ng-click="deleteTeam(team.teamId , team.ruleNum)">
                                <span class="glyphicon glyphicon-minus" aria-hidden="true">
                                    团队
                                </span>
                            </button>
                        </div>
                </div>
            </div>
        </div>

       </div>
   </div>

    <div ng-show="rules_info_show">  
                    <div class="col-md-12 main-content" ng-repeat="rule in rules_info"  on-finish>  
                        <article class="post" style="background-color: #FFFFFF;">
                            <div class="row">
                                <div class="col-md-4">
                                    <h3>{{rule.ruleDrlName}}</h3>
                                </div>
                                <div  class="col-md-2">
                                    <img src="./page/pictures/yes.jpg" height="60" width="60" class="img-circle" ng-show="rule.active">
                                    <img src="./page/pictures/no.jpg" height="60" width="60" class="img-circle" ng-hide="rule.active">
                                </div>
                                
                                <div class="col-md-6">
                                    <br/>
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-default" data-toggle="modal" ng-click="updateDrl(rule)">
                                            <span class="glyphicon glyphicon-edit" aria-hidden="true">
                                                编辑
                                            </span>
                                        </button>
                                        <button type="button" class="btn btn-default" data-toggle="modal" ng-click="deleteRule(rule.ruleId , rule.teamId)">
                                            <span class="glyphicon glyphicon-minus" aria-hidden="true">
                                                删除
                                            </span>
                                        </button>
                                        <button type="button" class="btn btn-default" data-toggle="modal" ng-click="activeRule(rule.teamId , rule.ruleId)">
                                            <span class="glyphicon glyphicon-edit" aria-hidden="true">
                                                {{rule.deploy | ableFilter}}
                                            </span>
                                        </button>
                                        <button type="button" class="btn btn-default" data-toggle="modal" ng-click="ruleDeploy(rule.ruleId)">
                                            <span class="glyphicon glyphicon-edit" aria-hidden="true">
                                                部署
                                            </span>
                                        </button>
                                    </div>
                                 </div>
                             </div> 
                            <div class="post-content"> 
                                <span class="label label-info" style="display:inline-block; width:80px;">ruleId:</span> {{rule.ruleId}} <br />
                                <span class="label label-info" style="display:inline-block; width:80px;">CheckId:</span>{{rule.ruleCheck}}<br/>
                                <span class="label label-info" style="display:inline-block; width:80px;">POJO:</span> {{rule.ruleJavabeanClassname}}<br/>
                                <span class="label label-info" style="display:inline-block; width:80px;">ArtifactId:</span> {{rule.pomArtifactId}}<br />
                                <span class="label label-info" style="display:inline-block; width:80px;">GroupId:</span> {{rule.pomGroupId}}<br />
                                <span class="label label-info" style="display:inline-block; width:80px;">Version:</span> {{rule.pomVersion}}<br />
                                <div id="resourceDom{{rule.ruleId}}" style="width: 100%;height:400px;">
                                </div>
                            </div>  

                        </article>
                        <footer class="post-footer clearfix"></footer>
                    </div>
                  
    </div>

    <div class="spinner" ng-show="is_loading">  </div>
</div> 


<script type="text/ng-template" id="addOneTeam.html">
    <div class="modal-header update-modal-title">
        <label>+团队(TEME)</label>
    </div>

    <br />
    <br />

    <span class="label label-info">描述:</span>
    <input type="text" class="form-control" style="width:500px;" ng-model="description" required>
    <br />
    <br />    

    <div class="modal-footer ">
        <button class="btn" ng-click="addOneTeam(description)">确定</button>
        <button class="btn" ng-click="cancel()">取消</button>
    </div>
</script>  

<div>
    <div id="page-inner">
        <br />
        <br />  
        <div class="row">
            <ul id="myTab" role="tablist">
                <li id="step1Li" class="active blue">
                    <a role="tab" data-toggle="tab">
                        加载依赖
                    </a>
                </li>
                <li id="step2Li" class="gray">
                    <img id="step2Img" src="page/pictures/blue_gray.png" />
                    <a role="tab" data-toggle="tab">
                        绑定引用
                    </a>
                </li>
                <li id="step3Li" class="gray">
                    <img id="step3Img" src="page/pictures/gray_gray.png" />
                    <a role="tab" data-toggle="tab">
                        规则配置
                    </a>
                </li>
                <li id="step4Li" class="gray">
                    <img id="step4Img" src="page/pictures/gray_gray.png" />
                    <a role="tab" data-toggle="tab">
                        编译测试
                    </a>
                </li>
            </ul>

            <div id="step1" class="tab-pane fade active in" ng-hide="hide_step1">
                <br />
                <br />
                <form class="form-inline" role="form" name="step1From">
                    <label>团队名称:{{teamName}} </label> <br />
                    <label>规则名称:</label>
                    <input type="text" class="form-control" placeholder="请输入规则名称" ng-model="drlName" required>
                    <label>groupId:</label>
                    <input type="text" class="form-control" placeholder="请输入groupId" ng-model="groupId" required>
                    <label>artifactId:</label>
                    <input type="text" class="form-control" placeholder="请输入artifactId" ng-model="artifactId" required>
                    <label>version:</label>
                    <input type="text" class="form-control" placeholder="请输入version" ng-model="version" required>
                    <div class="pager wizard">
                        <button class="btn btn-primary btn-lg" ng-click="mavenJarDownLoad(drlName, groupId, artifactId, version)">下一步</button>
                    </div>
                </form>
            </div>

            <div id="step2" class="tab-pane fade active in" ng-hide="hide_step2">

                <div class="form-inline">
                    <label>规则名称:</label> <label ng-bind="drlName"></label>
                    <br />
                    <label>规则ID:</label> <label ng-bind="ruleId"></label>
                    <br />
                    <span class="label label-danger">在Jar中选择要绑定的POJO,完全不涉及的Jar包请移除:</span>
                    <br />
                    <label>可绑定的Jar:  </label>
                    <button class="btn btn-default" ng-click="getOldJars()">取消移除</button>
                    <br />
                    <table>
                        <tbody>
                            <tr ng-repeat="jar_name in jarNames">
                                <td ng-click="getClassJavaBeanName(jar_name)">
                                    <a href="">{{jar_name}}</a>
                                </td>
                                <td>
                                    <button type="button" class="btn btn-default" data-toggle="modal" ng-click="removeJarName(jar_name)">
                                        <span class="glyphicon glyphicon-minus" aria-hidden="true"></span>移除
                                    </button>
                                </td>
                            </tr>
                        </tbody>
                    </table>


                    <label> 绑定的POJO:</label><label ng-bind="beanName"></label>
                    <div class="pager wizard">
                        <button class="btn btn-primary btn-lg" ng-click="buildrl(ruleId , beanName)">下一步</button>
                    </div>
                </div>
            </div>

            <div id="step3" class="tab-pane fade active in" ng-hide="hide_step3">
                <div id="content" class="row-fluid">
                    <div class="col-md-9">
                        <label>规则名称:</label> <label ng-bind="drlName"></label>
                        <br />
                        <label>规则ID:</label> <label ng-bind="ruleId"></label>
                        <br />
                        <label>绑定的POJO:</label> <label ng-bind="beanName"></label>
                    </div>
                    <div class="col-md-3">
                        <button type="button" class="btn btn-success" data-toggle="modal" ng-click="addOneRowRule()">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>规则(RULE)
                        </button>
                         
                        <button type="button" class="btn btn-success" data-toggle="modal" ng-click="drlAutoGenerate(ruleId)">
                            编译(RULE)
                        </button>
                    </div>
                </div>

                <div class="row"></div>

                <div ng-repeat="row_rule in rules_info" style="background-color: #FFFFFF;">
                    <h3>
                        <font color="blue">{{row_rule.detailDescription}}</font> 
                    </h3>
                    <div class="btn-group">
                        <button type="button" class="btn btn-default" data-toggle="modal" ng-click="addOneConstraint(row_rule.detailId , row_rule.ruleId)">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>条件(WHEN)
                        </button>
                        <button type="button" class="btn btn-default" data-toggle="modal" ng-click="addOneResult(row_rule.detailId , row_rule.ruleId)">
                            <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>结论(THEN)
                        </button>
                        <button type="button" class="btn btn-default" data-toggle="modal" ng-click="deleteRuleDetail(row_rule.detailId , row_rule.ruleId)">
                            <span class="glyphicon glyphicon-minus" aria-hidden="true"></span>规则(RULE)
                        </button>
                    </div>
                    <div>
                        <div class="col-md-6">
                            <table class="table table-hover">
                                <tbody>
                                    <tr ng-repeat="conditions in row_rule.conditions">
                                        <td>{{conditions.conditionDescription}}</td>
                                        <td>{{conditions.type}} {{conditions.conditionField}}</td>
                                        <td>{{conditions.operationDescription}}</td>
                                        <td>{{conditions.conditionValue}}</td>
                                        <td>
                                            <button class="btn btn-xs" ng-click="deleteCondition(conditions.conditionId , row_rule.ruleId)">删除</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>

                        <div class="col-md-6">
                            <table class="table table-hover">
                                <tbody>
                                    <tr ng-repeat="results in row_rule.results">
                                        <td>{{results.resultDescription}}</td>
                                        <td>{{results.resultMethod}}</td>
                                        <td>{{results.resultValue}}</td>
                                        <td>
                                            <button class="btn btn-xs" ng-click="deleteResult(results.resultId , row_rule.ruleId)">删除</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="row"> </div>
                </div>
            </div>

            <div id="step4" class="tab-pane fade active in" ng-hide="hide_step4">
                <label>规则名称:</label> <label ng-bind="drlName"></label>
                <br />
                <label>规则ID:</label> <label ng-bind="ruleId"></label>
                <br />
                <div class="btn-group" data-toggle="buttons">
                    <label class="btn btn-default">
                        <input type="radio" name="options" id="option1" ng-click="step4search(ruleId)"> 查看
                    </label> 
                    <label class="btn btn-default">
                        <input type="radio" name="options" id="option4" ng-click="step4update(ruleId)"> 编辑
                    </label>
                    <label class="btn btn-default">
                        <input type="radio" name="options" id="option2" ng-click="downloadDrlByRuleId(ruleId)"> 下载
                    </label>
                    <label class="btn btn-default">
                        <input type="radio" name="options" id="option3" ng-click="step4testDrl(ruleId)"> 测试
                    </label> 
                </div>

                <div class="panel panel-default" ng-hide="hide_step4search">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            {{ruleId}}.drl
                        </h3>
                    </div>
                    <div class="panel-body">
                        <pre ng-bind-html="drl_codes | to_trusted"></pre>
                    </div>
                </div>

                <div ng-hide="hide_step4testDrl">

                    <div class="container">
                        <div class="row">

                            <div class="col-sm-6">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <form class="form-inline">
                                            <div class="row"> 
                                                <div class="col-xs-6">
                                                    <span class="label label-danger">确保测试数据为JSON数组!</span>
                                                </div>
                                                <div class="col-xs-6 text-right">
                                                    <button type="button" class="btn btn-success btn-sm" ng-click="ruleTest(ruleId , jsonData)" >点击测试</button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <div class="panel-body">
                                        <textarea class="form-control" ng-model="jsonData" style="min-height:300px" required>
                         
                                        </textarea>
                                    </div>
                                </div>
                            </div>

                            <div class="col-sm-6">
                                <div class="panel panel-default">
                                    <div class="panel-heading">
                                        <form class="form-inline">
                                            <div class="row">
                                                <div class="col-xs-6">
                                                    测试结果: 命中<font color="red">{{fireNum}}</font>条规则
                                                </div>
                                                <div class="col-xs-6 text-right">  
                                                    <a href="http://www.json.cn/" target="_blank">JSON解析</a>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    <div class="panel-body">
                                        <textarea class="form-control" ng-model="reslutJsonData" style="min-height:300px">
                                        </textarea>
                                    </div>
                                </div> 
                            </div>

                        </div>


                    </div>


                </div>

            </div>
            <div class="spinner" ng-show="is_loading">  </div>
        </div>

    </div>
</div>


<script type="text/ng-template" id="newFunctionReminder.html">
    <div class="modal-header update-modal-title">
    </div>
    <table class="table table-hover">
        <tbody>
            <tr>
                <th>选择POJO</th>
            </tr>
            <tr ng-repeat="beanName in beanNames" ng-click="setbeanName(beanName)">
                <td>
                    <a href="">
                        <font size="1">{{beanName.pre}}</font>
                        <font size="1" color="red">{{beanName.last}}</font>
                    </a>
                </td>
            </tr>
        </tbody>
    </table>
    <div class="modal-footer ">
        <button class="btn" ng-click="cancel()">退出</button>
    </div>
</script>


<script type="text/ng-template" id="addOneRowRule.html">
    <div class="modal-header update-modal-title">
        <label>添加一条规则</label>
    </div>

    <div>
        <label>规则描述:</label>
        <input type="text" class="form-control" placeholder="请输入规则描述" ng-model="rule_description" required>
    </div>

    <div class="modal-footer ">
        <button class="btn" ng-click="submitRuleDscription(rule_description)">确定</button>
        <button class="btn" ng-click="cancel()">取消</button>
    </div>
</script>


<script type="text/ng-template" id="addOneConstraint.html">
    <div class="modal-header update-modal-title">
        <label>+约束(WHEN)</label>
    </div>

    <span class="label label-info">描述:</span>
    <input type="text" class="form-control" style="width:500px;" ng-model="description" required>
    <span class="label label-info">字段:</span>
    <br />
    <select style="width:500px;" ng-model="fileds" ng-options="fileds.show for fileds in declaredFields"></select>
    <br />
    <span class="label label-info">操作: </span>
    <br />
    <select style="width:500px;" ng-model="operation" ng-options="operation.desc for operation in ruleOperation"></select>
    <br />
    <span class="label label-info">值域:</span>
    <input type="text" class="form-control" style="width:500px;" ng-model="value">
    <br />

    <div class="modal-footer ">
        <button class="btn" ng-click="submitOneConstraint(description , fileds , operation , value)">确定</button>
        <button class="btn" ng-click="cancel()">取消</button>
    </div>
</script>


<script type="text/ng-template" id="addOneResult.html">
    <div class="modal-header update-modal-title">
        <label>+结论(THEN)</label>
    </div>

    <span class="label label-info">描述:</span>
    <input type="text" class="form-control" style="width:500px;" ng-model="description" required>
    <span class="label label-info">方法:</span>
    <br />
    <select style="width:500px;" ng-model="method" ng-options="method.show for method  in methods"></select>
    <br />
    <span class="label label-info">值域:</span>
    <input type="text" class="form-control" style="width:500px;" ng-model="value" required>
    <br />

    <div class="modal-footer ">
        <button class="btn" ng-click="submitOneResult(description , method  , value)">确定</button>
        <button class="btn" ng-click="cancel()">取消</button>
    </div>
</script>  


var app = angular.module("home.controller", ["ui.router", "createdrl.controller", "ruleteam.controller"]) ;  
  
app.config(function ($stateProvider, $urlRouterProvider) {  

    $urlRouterProvider.otherwise('/home');

    $stateProvider
        .state('home', {  
            url:'/home',
            cache: false,
            templateUrl: './page/app/html/ruleteam.html',
            controller: 'ruleteamCtrl'  
        })   
        .state('ruleteam', {  
            url: '/ruleteam',
            cache: false,
            templateUrl: './page/app/html/ruleteam.html',  
            controller: 'ruleteamCtrl'  
        })
        .state('createdrl', {  
            url:'/createdrl/:teamId/:teamName/:drlName/:ruleId/:beanName',
            templateUrl: './page/app/html/createdrl.html',  
            controller: 'createdrlCtrl'  
        });  

});  

var app = angular.module("ruleteam.controller", ["pcdApi.service", "ui.bootstrap", "ui.router"]);

app.controller("ruleteamCtrl",
    ["$scope", '$http', '$q', '$location','$state' , '$uibModal', "pcdApiService",
        function ($scope, $http, $q, $location, $state,  $uibModal, pcdApiService ) {

    $scope.initWeb = function () {
        $scope.userId = 2;
        $scope.is_loading = true; 
        $scope.team_info_show = true;
        $scope.rules_info_show = false;
        pcdApiService.showTeam($scope.userId).then(function (data) { 
            $scope.is_loading = false;
            if (data.status == "failed") {
                alert(data.infomation);
            }
            else { 
                $scope.rule_teams = data.data;
            }
        }, function (data) {
            $defer.resolve([]);
        });
    };

    $scope.initWeb();

    $scope.addOneTeam = function (){
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'addOneTeam.html',
            controller: 'addOneTeamCtrl',
            size: 'lg',
            scope: $scope,
            resolve: { 
            	 items: function () { 
                     item = {
                     }
                     return item; 
                 }
            }
        });

        modalInstance.result.then(function (req) {
            $scope.is_loading = true;
            $scope.rule_teams = null;
            pcdApiService.addTeam($scope.userId, req.description).then(function (data) {
                $scope.is_loading = false;
                if (data.status == "failed") {
                }
                else {
                    $scope.rule_teams = data.data;
                }
            }, function (data) {
                $defer.resolve([]);
            });
        }, function (reason) {

        });  
    };

    $scope.deleteTeam = function (teamId, ruleNum) {
        if (ruleNum > 0) {
            return ;
        }
        $scope.is_loading = true;
        $scope.rule_teams = null;
        pcdApiService.deleteTeam($scope.userId, teamId).then(function (data) {
            $scope.is_loading = false;
            if (data.status == "failed") {
                alert(data.infomation);
            }
            else {
                $scope.rule_teams = data.data;
            }
        }, function (data) {
            $defer.resolve([]);
        });
    };

    $scope.addRule = function (teamId, teamName) { 
         $state.go(
             'createdrl',
             {
                 teamId: teamId,
                 teamName: teamName,
                 drlName: "",
                 ruleId: -1 ,
                 beanName: ""
             }
         );
    };
    

    $scope.showRuleByTeamId = function (teamId, ruleNum) {
        if (ruleNum <= 0) {
            return;
        }
        $scope.team_info_show = false; 
        $scope.rules_info_show = true; 
        $scope.rule_teams = null;
        $scope.is_loading = true;
        pcdApiService.showRuleByTeamId(teamId).then(function (data) {
            $scope.is_loading = false; 
            if (data.status == "failed") {
                alert(data.infomation);
            }
            else {
                $scope.rules_info = data.data ; 
            }
        }, function (data) {
            $defer.resolve([]);
        }); 
    };


    $scope.$on('ngRepeatFinished', function (ngRepeatFinishedEvent) {
        console.log("sbb");
        for (i = 0; i < $scope.rules_info.length; i++) {
            ruleId = $scope.rules_info[i].ruleId; 
            var myChart = echarts.init(document.getElementById('resourceDom' + ruleId));
            option = {
                title: {
                    // text: '调用',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'axis',
                    formatter: function (params) { 
                        return params[0].name + '调用' + params[0].data + '次'; 
                    }
                },
                legend: {
                    show: true,
                    data: ['最近一个月调用次数'],
                    x: 'left'
                },
                toolbox: {
                    show: false,
                },
                dataZoom: {
                    show: false,
                    realtime: true,
                    start: 0,
                    end: 100
                },
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: false,
                        axisLine: { onZero: false },
                        data: $scope.rules_info[i].droolsCall.callDates 
                    }
                ],
                yAxis: [
                    {
                        name: '(次/天)',
                        type: 'value',
                    }
                ],
                series: [
                    {
                        name: '最近一个月调用次数',
                        type: 'line',
                        itemStyle: { normal: { areaStyle: { type: 'default' } } },
                        data: $scope.rules_info[i].droolsCall.callCounts 
                    }
                ]
            }; 
            myChart.setOption(option);    
        }
    });

    $scope.deleteRule = function (ruleId, teamId) {
        if (confirm("确定删除吗?") == false) {
            return;
        }
        $scope.team_info_show = false;
        $scope.rules_info_show = false;
        $scope.rule_teams = null;
        $scope.is_loading = true;
        pcdApiService.deleteRule(ruleId, teamId).then(function (data) {
            $scope.is_loading = false;
            $scope.rules_info_show = true;
            if (data.status == "failed") {
                alert(data.infomation);
            }
            else {
                $scope.rules_info = data.data;
            }
        }, function (data) {
            $defer.resolve([]);
        });
    };

    $scope.activeRule = function (teamId ,ruleId) { 
        $scope.is_loading = true;
        $scope.rules_info_show = false;
        pcdApiService.activeRule(teamId , ruleId).then(function (data) {
            $scope.is_loading = false;  
            $scope.rules_info_show = true; 
            $scope.rules_info = data.data;
        }, function (data) {
            $defer.resolve([]);
        });
    };

    $scope.ruleDeploy = function (ruleId) {
        if (confirm("确定要部署吗?") == false) {
            return;
        }
        $scope.is_loading = true;
        $scope.rules_info_show = false;
        pcdApiService.ruleDeploy(ruleId).then(function (data) {
            $scope.is_loading = false;
            $scope.rules_info_show = true;
            alert(data.infomation);
        }, function (data) {
            $defer.resolve([]);
        });
    };
     


    $scope.updateDrl = function (rule) {
        $state.go(
            'createdrl',
            {
            	teamId: -1,
                teamName: "",
                drlName: rule.ruleDrlName,
                ruleId: rule.ruleId,
                beanName: rule.ruleJavabeanClassname
            }
        );
    };
   


}]);


app.filter('to_trusted', ['$sce', function ($sce) {
    return function (text) {
        return $sce.trustAsHtml(text);
    };
}]);


app.controller("addOneTeamCtrl", ["$scope", '$http', "$uibModalInstance", "items",
    function ($scope, $http, $uibModalInstance, items) {

        $scope.cancel = function () {
            $uibModalInstance.dismiss('cancel');
        };
         
        $scope.addOneTeam = function (description) { 
            $uibModalInstance.close(
                {
                    description: description 
                }
            );
            $uibModalInstance.dismiss('cancel');
        };

 }]);


app.filter('ableFilter', function () { //可以注入依赖
    return function (param) {
        if (param == true) {
            return "禁用";
        }
        else {
            return "启用";
        }
    }
});


app.directive('onFinish', function ($timeout) {
    return {
        restrict: 'A',
        link: function (scope, element, attr) {
            if (scope.$last === true) {
                $timeout(function () {
                    scope.$emit('ngRepeatFinished');
                });
            }
        }
    }
}); 



var app = angular.module("createdrl.controller", ["pcdApi.service", "ui.bootstrap", "ui.router"]) ;

app.controller("createdrlCtrl", ["$scope", '$http', '$q', '$location', '$state', '$stateParams' ,'$uibModal' , "pcdApiService",
    function ($scope, $http, $q, $location, $state, $stateParams, $uibModal, pcdApiService) { 

    $scope.is_loading = false;

    $scope.setStep = function (index) {
        $scope.is_loading = false;
        $scope.hide_step1 = true;
        $scope.hide_step2 = true;
        $scope.hide_step3 = true;
        $scope.hide_step4 = true;
        if (1 == index) {
            $scope.hide_step1 = false;
        }
        else if (2 == index) {
            $scope.hide_step2 = false;
        }
        else if (3 == index) {
            $scope.hide_step3 = false;
        }
        else if (4 == index) {
            $scope.hide_step4 = false;
        }

        for (var i = 2; i <= index; i++) {
            $("#step" + i + "Li").addClass("blue").removeClass("gray");
            $("#step" + i + "Img").attr("src", "page/pictures/blue_blue.png");
        }
        for (var i = index + 1; i <= 4; i++) {
            $("#step" + i + "Li").addClass("gray").removeClass("blue");
            $("#step" + i + "Img").attr("src", "page/pictures/gray_gray.png");
        }
        $("#step" + (index + 1) + "Img").attr("src", "page/pictures/blue_gray.png");
    };

    $scope.teamId = $stateParams.teamId;
    $scope.teamName = $stateParams.teamName;
    $scope.drlName = $stateParams.drlName;
    $scope.ruleId = $stateParams.ruleId;
    $scope.beanName = $stateParams.beanName;
    if ($scope.teamId > -1){
        $scope.setStep(1);
    }
    if ($scope.ruleId > -1) {   
        $scope.setStep(3); 
        $scope.rules_info = null;
        $scope.is_loading = true;
        pcdApiService.findRuleDetailsByRuleId($scope.ruleId).then(function (data) {
            if (data.status == "failed") {
                alert(data.infomation);
                $scope.is_loading = false;
            }
            else {
                $scope.rules_info = data.data.ruleDetails;
                $scope.jarPaths = data.data.jarPaths;
                $scope.is_loading = false;
            }
        }, function (data) {
            $defer.resolve([]);
        });
    } 
/*
    $scope.setStep(3);
    $scope.beanName = "com.ceair.pss.psdp.brms.cust.arpupg.domain.ArpUpgRuleFactor";
    $scope.ruleId = 61;
    $scope.jarPaths = ["C:\\Users\\liyang\\Desktop\\brms-cust-module-1.0.1.jar",
        "C:\\Users\\liyang\\Desktop\\cmp-custinfo-domain-1.0.0.jar",
        "C:\\Users\\liyang\\Desktop\\pss-utils-1.0.0.jar"];
    $scope.jarNames = ["brms-cust-module-1.0.1.jar",
        "cmp-custinfo-domain-1.0.0.jar",
        "pss-utils-1.0.0.jar"];
*/

    

    $scope.createDrlByDrlUID = function (drluid) {
        if (drluid == "" || drluid == null || drluid == undefined) {
            return;
        }
        $scope.is_loading = true;
        pcdApiService.addRule(drluid).then(function (data) {
            if (data.status == "failed") {
                alert(data.infomation);
                $scope.is_loading = false;
            }
            else {
                $scope.drluid = drluid;
                $scope.ruleId = data.data.ruleId;
                $scope.setStep(2);
            }
        }, function (data) {
            $defer.resolve([]);
        });   
    };


    $scope.getOldJars = function () {
        $scope.jarNames = $scope.all_jarNames;
        $scope.jarPaths = $scope.all_jarPaths;
    }


    $scope.removeJarName = function (jar_name) { 
        jarNames = [];
        for (i = 0; i < $scope.jarNames.length; i++) {
            if ($scope.jarNames[i].indexOf(jar_name) == -1) {
                jarNames.push($scope.jarNames[i]);
            }
        } 

        jarPaths = [];
        for (i = 0; i < $scope.jarPaths.length; i++) {
            if ($scope.jarPaths[i].indexOf(jar_name) == -1) {
                jarPaths.push($scope.jarPaths[i]);
            }
        } 

        $scope.jarNames = jarNames ;
        $scope.jarPaths = jarPaths ;
    };

    $scope.mavenJarDownLoad = function (drlName, groupId, artifactId, version) {
        teamId = $scope.teamId;
        if (drlName == undefined || drlName == null || drlName == "" ||
            groupId == undefined || groupId == null || groupId == "" ||
            artifactId == undefined || artifactId == null || artifactId == "" ||
            version == undefined || version == null || version == "" ||
            teamId == undefined || teamId == null || teamId == "") {
            return;
        } 
        $scope.is_loading = true;
        $scope.hide_step1 = true;
        pcdApiService.mavenJarDownLoad(drlName, groupId, artifactId, version, teamId).then(function (data) {
            if (data.status == "failed") {
                alert(data.infomation);
                $scope.is_loading = false;
                $scope.hide_step1 = false;
            }
            else {
                $scope.all_jarNames = data.data.jarNames;
                $scope.all_jarPaths = data.data.jarPaths; 
                $scope.jarNames = $scope.all_jarNames;
                $scope.jarPaths = $scope.all_jarPaths; 
                $scope.drlName = drlName;
                $scope.ruleId = data.data.ruleId;
                $scope.is_loading = false;
                $scope.setStep(2);
            }
        }, function (data) {
            $defer.resolve([]);
        });   
    }

    $scope.deleteRuleDetail = function (detailId, ruleId) {
        if (!confirm("确定要删除吗?")) {
            return;
        }
        $scope.rules_info = null;
        $scope.is_loading = true;
        pcdApiService.deleteRuleDetail(detailId, ruleId).then(function (data) {
            if (data.status == "failed") {
                alert(data.infomation);
                $scope.is_loading = false;
            }
            else {
                $scope.rules_info = data.data; 
                $scope.is_loading = false;
            }
        }, function (data) {
            $defer.resolve([]);
        });
    }

    $scope.buildrl = function (ruleId , beanName) {
        if (beanName == "" || beanName == null || beanName == undefined) {
            alert("请绑定POJO!");
            return;
        }
        $scope.hide_step2 = true;
        $scope.is_loading = true; 
        pcdApiService.updateRule(ruleId, beanName).then(function (req) {
            if (req.status == "failed") {
                alert(req.infomation);
                $scope.is_loading = false;
            }
            else {
                $scope.is_loading = false;
                $scope.setStep(3);  
            }
        }, function (req) {
            $defer.resolve([]);
        });   
    }


    $scope.getClassJavaBeanName = function (jarName) {
        var modalInstance = $uibModal.open({  
            animation:true,  
            templateUrl : 'newFunctionReminder.html',   
            controller : 'AllModalInstanceCtrl', 
            size: 'lg',  
            scope: $scope,
            resolve:{  
                 items: function () {   
                	 item ={
                	     ruleId: $scope.ruleId,
                	     jarPaths :$scope.jarPaths ,
                	     jarName: jarName 		 
                	 }
                     return item  ; 
                 }  
            }  
        });  

        modalInstance.result.then(function (result) {
            $scope.beanName = result ;  
        }, function (reason) {
              
        });  

    };


    $scope.addOneRowRule = function () {
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'addOneRowRule.html',   
            controller: 'AddOneRowRuleModalInstanceCtrl', 
            size: 'lg',  
            scope: $scope,
            resolve: {
                items: function () { 
                    item = {
                    }
                    return item; 
                }
            }
        });

        modalInstance.result.then(function (rule_description) {
            if (rule_description == undefined || rule_description == null || rule_description == "") {
                return; 
            }
            $scope.is_loading = true;
            $scope.rules_info = null;
            pcdApiService.addRuleDetail($scope.ruleId, rule_description).then(function (req) {
                if (req.status == "failed") { 

                    $scope.is_loading = false;
                }
                else {
                    $scope.rules_info = req.data;
                    $scope.is_loading = false;
                }
            }, function (req) {
                $defer.resolve([]);
            });   
            
            
        }, function (reason) { 
        }); 
    }; 

    $scope.addOneConstraint = function (detailId, ruleId) {
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'addOneConstraint.html',   
            controller: 'addOneConstraintCtrl', 
            size: 'lg',  
            scope: $scope,
            resolve: {
                items: function () { 
                    item = {
                        classJaveBeanName: $scope.beanName , 
                        addJarPathFiles: $scope.jarPaths 
                    }
                    return item; 
                }
            }
        });

        modalInstance.result.then(function (result) {
            $scope.is_loading = true;
            $scope.rules_info = null;

            $http({
                method: 'post',
                url: 'api/addCondition',
                data: {
                    detailId: detailId,
                    ruleId: ruleId,
                    description: result.description,
                    field: result.filed,
                    type: result.type,
                    operation:result.operation,
                    value:result.value
                }
            }).success(function (req) {
                $scope.is_loading = false;
                $scope.rules_info = req.data ;
            })
        }, function (reason) {

        });

    };

    $scope.deleteCondition = function (conditionId, ruleId) {
        if (!confirm("确定要删除吗?")) {
            return;
        }
        $scope.rules_info = null;
        $scope.is_loading = true;
        pcdApiService.deleteCondition(conditionId, ruleId).then(function (data) {
            if (data.status == "failed") {
                alert(data.infomation);
                $scope.is_loading = false;
            }
            else {
                $scope.rules_info = data.data;
                $scope.is_loading = false;
            }
        }, function (data) {
            $defer.resolve([]);
        });
    };

    $scope.deleteResult = function (resultId, ruleId) {
        if (!confirm("确定要删除吗?")) {
            return;
        }
        $scope.rules_info = null;
        $scope.is_loading = true;
        pcdApiService.deleteResult(resultId, ruleId).then(function (data) {
            if (data.status == "failed") {
                alert(data.infomation);
                $scope.is_loading = false;
            }
            else {
                $scope.rules_info = data.data;
                $scope.is_loading = false;
            }
        }, function (data) {
            $defer.resolve([]);
        });
    };

    $scope.drlAutoGenerate = function (ruleId) {
        $scope.hide_step3 = true;
        $scope.is_loading = true;
        pcdApiService.drlAutoGenerate(ruleId).then(function (data) {
            if (data.status == "failed") {
                alert(data.infomation);
                $scope.is_loading = false;
            }
            else {
                $scope.drl_codes = data.data;
                $scope.is_loading = false;
                $scope.setStep(4);
                $scope.hide_step4search = false;
            }
        }, function (data) {
            $defer.resolve([]);
        });
    };

    $scope.step4Hide = function () {
        $scope.hide_step4search = true;
        $scope.hide_step4testDrl = true;
    };
    $scope.step4Hide();

    $scope.step4search = function (ruleId) {
        $scope.step4Hide();
        $scope.hide_step4search = false;
    };

    $scope.step4testDrl = function (ruleId) {
        $scope.step4Hide();
        $scope.hide_step4testDrl = false;
    };

    
    $scope.step4update = function (ruleId) {
        $scope.step4Hide();
        $scope.setStep(3);
    };
    

    $scope.ruleTest = function (ruleId, jsonData) {
        if (jsonData == undefined || jsonData == null || jsonData == "") {
            alert("请输入测试数据!");
            return;
        }
        $scope.hide_step4testDrl = true;
        $scope.is_loading = true;
        $http({
            method: 'post',
            url: 'api/ruleTestForWeb',
            data: { 
                ruleId: ruleId,
                jsonData: jsonData 
            }
        }).success(function (req) {
            if (req.status == "failed") {
                alert("测试失败!");
            }
            $scope.reslutJsonData = req.data.resultJsonData; 
            $scope.fireNum = req.data.fireNum; 
            $scope.hide_step4testDrl = false;
            $scope.is_loading = false ;
        })
    };

    $scope.downloadDrlByRuleId = function (ruleId) {
        $http.get("api/downloadDrlByRuleId?ruleId=" + ruleId, { responseType: 'arraybuffer' })
            .success(function (data, status, headers) {
                var octetStreamMime = 'application/octet-stream';
                var success = false;
                headers = headers();
                filename = "" + ruleId +  ".drl";
                var contentType = headers['content-type'] || octetStreamMime;
                try {
                    var blob = new Blob([data], { type: contentType });
                    if (navigator.msSaveBlob)
                        navigator.msSaveBlob(blob, filename);
                    else {
                        var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
                        if (saveBlob === undefined) throw "Not supported";
                        saveBlob(blob, filename);
                    }
                    success = true;
                } catch (ex) { }

                if (!success) {
                    var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
                    if (urlCreator) {
                        var link = document.createElement('a');
                        if ('download' in link) {
                            try {
                                var blob = new Blob([data], { type: contentType });
                                var url = urlCreator.createObjectURL(blob);
                                link.setAttribute('href', url);
                                link.setAttribute("download", filename);
                                var event = document.createEvent('MouseEvents');
                                event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
                                link.dispatchEvent(event);
                                success = true;
                            } catch (ex) {
                                console.log(ex);
                            }
                        }
                        if (!success) {
                            try {
                                var blob = new Blob([data], { type: octetStreamMime });
                                var url = urlCreator.createObjectURL(blob);
                                window.location = url;
                                success = true;
                            } catch (ex) {
                                console.log(ex);
                            }
                        }

                    }
                }

                if (!success) {
                    window.open(httpPath, '_blank', '');
                }
            })
            .error(function (data, status) {
                console.log("Request failed with status: " + status);
                $scope.errorDetails = "Request failed with status: " + status;
            });
    };


    $scope.addOneResult = function (detailId, ruleId) {
        var modalInstance = $uibModal.open({
            animation: true,
            templateUrl: 'addOneResult.html',   
            controller: 'addOneResultCtrl', 
            size: 'lg', 
            scope: $scope,
            resolve: {
                items: function () {
                    console.log($scope.beanName);
                    console.log($scope.jarPaths);

                    item = {
                        classJaveBeanName: $scope.beanName,
                        addJarPathFiles: $scope.jarPaths
                    }
                    return item;  
                }
            }
        });

        modalInstance.result.then(function (result) {
            $scope.is_loading = true;
            $scope.rules_info = null;

            $http({
                method: 'post',
                url: 'api/addResult',
                data: {
                    detailId: detailId,
                    ruleId: ruleId,
                    description: result.description,
                    method: result.method,
                    value: result.value 
                }
            }).success(function (req) {
                $scope.is_loading = false;
                $scope.rules_info = req.data;
            })
        }, function (reason) {

        });

    };



}]);


app.controller("AddOneRowRuleModalInstanceCtrl", ["$scope", '$http', "$uibModalInstance", "items",
    function ($scope, $http, $uibModalInstance, items) {  

        $scope.cancel = function () {
            $uibModalInstance.dismiss('cancel');
        };
         
        $scope.submitRuleDscription = function (rule_description) { 
            $uibModalInstance.close(rule_description);
            $uibModalInstance.dismiss('cancel');
        };

}]);  




app.controller("AllModalInstanceCtrl", ["$scope" , '$http'  , "$uibModalInstance"  , "items" , 
                                        function($scope , $http ,  $uibModalInstance  , items){  
    
    $http({
        method: 'post',
        url: 'api/getClassJavaBeanName',
        data: {
            ruleId: items.ruleId,
            jarPaths: items.jarPaths ,
            jarName: items.jarName 
        }
    }).success(function (req) { 
        $scope.beanNames = [];
        for (i = 0; i < req.data.length; i++) {
            str = req.data[i];
            $scope.beanNames.push(
                {
                    pre: str.substring(0, str.lastIndexOf(".")+1) ,
                    last: str.substring(str.lastIndexOf(".") + 1)
                }
            )
        }
    })
    
    $scope.cancel = function(){  
         $uibModalInstance.dismiss('cancel');  
    };  


    $scope.setbeanName = function (beanName) {
        $scope.beanName = beanName.pre + beanName.last; 
        $uibModalInstance.close($scope.beanName);  
        $uibModalInstance.dismiss('cancel'); 
    }; 
    
}]);  



app.controller("addOneConstraintCtrl", ["$scope", '$http', "$uibModalInstance", "items",
    function ($scope, $http, $uibModalInstance, items) {  

        $scope.ruleOperation = [
            { idx: 0, desc: "等于:==" },
            { idx: 1, desc: "不等于:!=" },
            { idx: 2, desc: "小于:<" },
            { idx: 3, desc: "小于等于:<=" },
            { idx: 4, desc: "大于:>" },
            { idx: 5, desc: "大于等于:>=" },
            { idx: 6, desc: "在闭区间内:[]" },
            { idx: 7, desc: "在两端区间:<= left or >= right" },
            { idx: 8, desc: "在列表内:in (,,)" },
            { idx: 9, desc: "不在列表内:not in(,,)" },
            { idx: 10, desc: "包含:contains" },
            { idx: 11, desc: "为空:is null" },
            { idx: 12, desc: "不为空:is not null" },
            { idx: 13, desc: "真:true" },
            { idx: 14, desc: "假:false" },
            { idx: 15, desc: "为空或空字符串:null or \"\"" },
        ];

        $http({
            method: 'post',
            url: 'api/getJarJavaBeanInfo',
            data: {
                classJaveBeanName: items.classJaveBeanName,
                addJarPathFiles: items.addJarPathFiles
            }
        }).success(function (req) {
            $scope.declaredFields = req.data.declaredFields;
        })

        $scope.cancel = function () {
            $uibModalInstance.dismiss('cancel');
        };

        filterStr = function (str) {
            if (str == null || str == undefined || str == "") {
                return "";
            }
            str = str.replace(new RegExp("\"", "gm"), "");
            str = str.replace(new RegExp("”", "gm"), "");
            str = str.replace(new RegExp("“", "gm"), "");
            str = str.replace(new RegExp(" ", "gm"), "");
            str = str.replace(new RegExp(",", "gm"), ",");
            return str;
        }
        

        $scope.submitOneConstraint = function (description, fileds, operation, value) {
            type = fileds.type;   
            value = filterStr(value); 
            if (operation.idx == 8 || operation.idx == 9) {
                if ("String" == type) {
                    fitm = [];
                    itm = value.split(",");
                    for (i = 0; i < itm.length; i++) {
                        if (itm[i] == null || itm[i] == undefined || itm[i] == "" || itm[i] == ",") {
                            continue;
                        }
                        fitm.push(itm[i]);
                    }
                    n = fitm.length;
                    value = "\"" + fitm[0] + "\"" ;
                    for (i = 1; i < n; i++) {
                        value = value + " , " + "\"" + fitm[i] + "\""  ;
                    }
                }
            }
            else {
                if ("String" == type) {
                    value = "\"" + value + "\"";
                }
                else if ("List<String>" == type) {
                    value = "\"" + value + "\"";
                }
            } 


            $uibModalInstance.close({
                description:description,
                filed: fileds.field,
                type: fileds.type,
                operation: operation.idx,
                value: value
            });
            $uibModalInstance.dismiss('cancel');
        };

    }]);  




app.controller("addOneResultCtrl", ["$scope", '$http', "$uibModalInstance", "items",
    function ($scope, $http, $uibModalInstance, items) {  

        $http({
            method: 'post',
            url: 'api/getJarJavaBeanInfo',
            data: {
                classJaveBeanName: items.classJaveBeanName,
                addJarPathFiles: items.addJarPathFiles
            }
        }).success(function (req) { 
            $scope.methods = req.data.methods; 
        })

        $scope.cancel = function () {
            $uibModalInstance.dismiss('cancel');
        };

        filterStr = function (str) {
            if (str == null || str == undefined || str == "") {
                return "";
            }
            str = str.replace(new RegExp("\"", "gm"), "");
            str = str.replace(new RegExp("”", "gm"), "");
            str = str.replace(new RegExp("“", "gm"), "");
            str = str.replace(new RegExp(" ", "gm"), "");
            str = str.replace(new RegExp(",", "gm"), ",");
            return str;
        }

        $scope.submitOneResult = function (description, method, value) {
            value = filterStr(value); 
            fitm = [];
            itm = value.split(",");
            for (i = 0; i < itm.length; i++) {
                if (itm[i] == null || itm[i] == undefined || itm[i] == "" || itm[i] == ",") {
                    continue;
                }
                fitm.push(itm[i]);
            }
            methodName = method.methodName;
            types = method.types;
            n = types.length;
            stringVlue = "";
            for (i = 0; i < n; i++) {
                if ("String" == types[i]) {
                    stringVlue = stringVlue + " \"" + fitm[i] + "\" ";
                }
                else {
                    stringVlue = stringVlue +  " " + fitm[i] + " ";
                }
                if (i != n - 1) {
                    stringVlue += ","; 
                }
            }
            
            $uibModalInstance.close({
                description: description,
                method: methodName + "(" + stringVlue + ")" , 
                value: stringVlue 
            });
            $uibModalInstance.dismiss('cancel');
        };

    }]);  





app.filter('to_trusted', ['$sce', function($sce){
        return function(text) {
            return $sce.trustAsHtml(text);
        };
}]);

var app = angular.module("pcdApi.service", []);  
app.service("pcdApiService", ['$http' , '$q'  , function($http , $q){  
      
    this.addRule = function (ruleDrlName){  
        var deferred = $q.defer();  
        $http.get("api/addRule?ruleDrlName=" + ruleDrlName)
             .success(function(data) {  
                    deferred.resolve(data);  
              })  
              .error(function(data) {  
                    deferred.reject(data);  
              }) ;  
        return deferred.promise;  
    };  

    this.mavenJarDownLoad = function (ruleDrlName, groupId, artifactId, version, teamId) {
        var deferred = $q.defer();
        $http.get("api/mavenJarDownLoad?ruleDrlName=" + ruleDrlName + "&groupId=" + groupId + "&artifactId=" + artifactId + "&version=" + version + "&teamId=" + teamId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;  
    };

    
    this.addRuleDetail = function (ruleId, rule_description) {
        var deferred = $q.defer();
        $http.get("api/addRuleDetail?ruleId=" + ruleId + "&description=" + rule_description)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };


    this.deleteRuleDetail = function (detailId, ruleId) {
        var deferred = $q.defer();
        $http.get("api/deleteRuleDetail?detailId=" + detailId + "&ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.findRuleDetailsByRuleId = function (ruleId) {
        var deferred = $q.defer();
        $http.get("api/findRuleDetailsByRuleId?ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    }; 

    this.deleteCondition = function (conditionId, ruleId) {
        var deferred = $q.defer();
        $http.get("api/deleteCondition?conditionId=" + conditionId + "&ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.deleteResult = function (resultId, ruleId) {
        var deferred = $q.defer();
        $http.get("api/deleteResult?resultId=" + resultId + "&ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.updateRule = function (ruleId, javaBeanClassName) {
        var deferred = $q.defer();
        $http.get("api/updateRule?ruleId=" + ruleId + "&javaBeanClassName=" + javaBeanClassName)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.drlAutoGenerate = function (ruleId) {
        var deferred = $q.defer();
        $http.get("api/drlAutoGenerate?ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.showTeam = function (userId) {
        var deferred = $q.defer();
        $http.get("api/showTeam?userId=" + userId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.addTeam = function (userId, teamName) {
        var deferred = $q.defer();
        $http.get("api/addTeam?userId=" + userId + "&teamName=" + teamName)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.deleteTeam = function (userId, teamId) {
        var deferred = $q.defer();
        $http.get("api/deleteTeam?userId=" + userId + "&teamId=" + teamId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.showRuleByTeamId = function (teamId) {
        var deferred = $q.defer();
        $http.get("api/showRuleByTeamId?teamId=" + teamId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };

    this.getJarPathByRuleId = function (ruleId) {
        var deferred = $q.defer();
        $http.get("api/getJarPathByRuleId?ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    }; 

    this.deleteRule = function (ruleId, teamId) {
        var deferred = $q.defer();
        $http.get("api/deleteRule?ruleId=" + ruleId + "&teamId=" + teamId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };  

    this.updateJarVersion = function (ruleId) {
        var deferred = $q.defer();
        $http.get("api/updateJarVersion?ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };  

    this.ruleDeploy = function (ruleId) {
        var deferred = $q.defer();
        $http.get("api/ruleDeploy?ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };  

    this.activeRule = function (teamId , ruleId) {
        var deferred = $q.defer();
        $http.get("api/activeRule?teamId=" + teamId + "&ruleId=" + ruleId)
            .success(function (data) {
                deferred.resolve(data);
            })
            .error(function (data) {
                deferred.reject(data);
            });
        return deferred.promise;
    };  
    
    
      
}]);  





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值