Example #1
0
define("host_health_add",function(require,exports,module){
    var config = require("host_dispatch_cfg").config;

    config.global.updateCache("health80",{
        rows:[
        {id:1,type:"是"},
        {id:0,type:"否"}
        ]
    });

    exports.menu = config.menu;
    exports.page = "pages/host/dispatch/ipsetAdd.html";
});
Example #2
0
define("host_probep_add",function(require,exports,module){
    var config = require("host_dispatch_cfg").config,
    Dy = new require("Dynamic_add").actions,
    actions = new Dy();
      config.global.updateCache("health80",{
        rows:[
        {id:1,type:"是"},
        {id:0,type:"否"}
        ]
    });
    exports.menu = config.menu;
    exports.page = "pages/host/dispatch/probepAdd.html";

    exports.execute = function(toModule){
        $hostAddBody = $("#hostDispatch_add");

        actions.setOpt({
            tpl: $("#add_dispatchTpl").html(),
            container: "#table_body",
            formSelector: "#addHostDispath_form",
            url: config.urls.addProbeStrategy
        });

        actions.renderNewTr().
                initDel("a.deleteTr").
                initSave("a.subTr",function($this,$tr){
                    $this.hide();
                    $tr.find("a.editTr").addClass("showInLine");
                    $tr.find("a.ipconfig").attr("data-status","unable");
                }).
                initEdit("a.editTr",function($this,$tr){
                   $this.removeClass("showInLine");
                   $tr.find("a.subTr").show();
                   $tr.find("a.ipconfig").removeAttr("data-status"); 
                });

        $hostAddBody.on("click","a.hostDispatchAdd-add",function(){
            actions.renderNewTr();
        });

        $("#hostDispatchAdd-sub").on("click",function(){
            actions.submit(function(r){
                $.alert(r.message);
                if(r.code == 1){
                    toModule("host_dispatch:index=4");
                }
            });
        });

        $(".hostDispatchAdd-del").on("click",function(){
            $.confirm('确定要删除吗?').yes(function(){
                var $checked = $hostAddBody.find(".delCheck:checkbox:checked");

                $checked.each(function(){
                    var $this = $(this),
                    $tr = $this.parents("tr");

                    $tr.remove();
                });
            });
        });

      
    };
});
Example #3
0
define("host_dispatch",function(require,exports,module){
    var config = require("host_dispatch_cfg").config;

    Handlebars.registerHelper('probeTypeToCN', function(value) {
        return ["默认","大文件","https","不探测"][value];
    });
    Handlebars.registerHelper('strategyTypeToCN', function(value) {
        return ["不采用策略","主备","轮询"][value];
    });

    Handlebars.registerHelper('is_traceToCN', function(value) {
        return ["否","是"][value];
    });
    Handlebars.registerHelper('operator', function(value) {
        return ["否","是"][value];
    });
   

    Handlebars.registerHelper("_",function(index){
        return index+1;
    });
    config.global.updateCache("health80",{
        rows:[
        {id:1,type:"是"},
        {id:0,type:"否"}
        ]
    });
    
    exports.menu = config.menu;
    exports.page = "pages/host/manage/hostDispatch.html";

    exports.init = function(){
        $('#myTab a:first').tab('show');//初始化显示哪个tab 
      
        $('#myTab a').click(function (e) { 
            e.preventDefault();//阻止a链接的跳转行为 
            $(this).tab('show');//显示当前选中的链接及关联的content 
            $('.detail').text( $(this).text());
        });
    }
    exports.execute = function(toModule,data){
        if(data.index != undefined){
            $("#myTab li").eq(data.index).find("a").trigger("click");
        }

        var getChecked = function(obj,url,selector,pramName,callback){
            var $checked = obj.find(selector+":checkbox:checked"),
            ids = [];

            $checked.each(function(){
                var $this = $(this),
                id = $this.attr("data-id");
                ids.push(id);
            });
            var pram = {};

            pram[pramName] = ids.join(",");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: url,
                    data:pram,
                    type:"post",
                    dataType:"json",
                    success: function(r){
                        if(r.code == 1){
                            $.alert("删除成功");
                            toModule("host_dispatch",function(){
                                callback&callback();
                            });
                        }else{
                            $.alert(r.message);
                        }
                    }
                });
                return false;
            });
        }
        //调度策略 操作
        var $dispatch = $("#dispatch_list");

        $dispatch.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.delSchStrategy,
                    data: {Id:id},
                    dataType:"json",
                    success: function(r){
                        
                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(0).find("a").trigger("click");
                            });
                            
                        }else{
                            alert(r.message);
                        }
                    }
                });
            });
        });

        $(".hostDispatch-del").on("click",function(){
            getChecked($dispatch,config.urls.delSchStrategy,".delCheck","Id",function(){
                $("#myTab li").eq(0).find("a").trigger("click");
            });
        });


        /// territory 操作
        var $territory = $("#dispatch_list1");

        $territory.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.delTerritory,
                    data: {Ids:id},
                    dataType:"json",
                    success: function(r){
                        
                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(1).find("a").trigger("click");
                            });
                            
                        }else{
                            $.alert(r.message);
                        }
                    }
                });
            });
            
        });
        $(".territory-del").on("click",function(){
            getChecked($territory,config.urls.delTerritory,".delTCheck","Ids",function(){
                $("#myTab li").eq(1).find("a").trigger("click");
            });
        });

        config.global.updateCache("/ApiScheduleStrategy/listTerritoryStrategy");//清除缓存
        //ipset 删除
        var $ipSet = $("#dispatch_list2");

        $ipSet.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.delIpSet,
                    data: {ids:id},
                    dataType:"json",
                    success: function(r){
                        
                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(2).find("a").trigger("click");
                            });
                            
                        }else{
                            $.alert(r.message);
                        }
                    }
                });
            });
        });
        $(".ipset-del").on("click",function(){
            getChecked($ipSet,config.urls.delIpSet,".delIPCheck","ids",function(){
                $("#myTab li").eq(2).find("a").trigger("click");
            });
        });
        //probe*********************
        
         var $probe = $("#disprobe_list");

        $probe.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.delProbe,
                    data: {ids:id},
                    dataType:"json",
                    success: function(r){

                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(3).find("a").trigger("click");
                            });

                        }else{
                            $.alert(r.message);
                        }
                    }
                });
            });
        });
        $(".probe-del").on("click",function(){
            getChecked($probe,config.urls.delProbe,".delProbeCheck","ids",function(){
                $("#myTab li").eq(3).find("a").trigger("click");
            });
        });
        //探测策略类型


         var $probep = $("#disprobe_list1");

        $probep.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.deleteProbeStrategy,
                    data: {ids:id},
                    dataType:"json",
                    success: function(r){

                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(4).find("a").trigger("click");
                            });

                        }else{
                            $.alert(r.message);
                        }
                    }
                });
            });
        });
        $(".hostDispatch1-del").on("click",function(){
            getChecked($probep,config.urls.deleteProbeStrategy,".delProbePCheck","ids",function(){
                $("#myTab li").eq(4).find("a").trigger("click");
            });
        });
        

        //健康度阀值设置
        var $heath = $("#dispatch_healthy"),
        sendHeathTpl = $("#sendHeathTpl").html(),
        html = Handlebars.compile(sendHeathTpl)({});

        $heath.on("click","#sendHeath",function(){
            $.dialog(html,{title:"下发的设备"}).yes(function(){
                var ids = [];
                $("#sendTpl-form .new-checks input:checked").each(function(){
                    ids.push($(this).val())
                });
                $.ajax({
                    url:config.urls.sendHeath,
                    data:{device_ids:ids.join(",")},
                    type:"get",
                    dataType:"json",
                    success: function(r){
                        $.alert(r.message);
                    }
                });
                return false;
            });
        });
    }
});
Example #4
0
define("host_probe_add",function(require,exports,module){
    var config = require("host_dispatch_cfg").config;
     config.global.updateCache("is_probe_active",{
        rows:[
        {id:1,type:"是"},
        {id:0,type:"否"}
        ]
    });
      
    exports.menu = config.menu;
    exports.page = "pages/host/dispatch/probeAdd.html";

    exports.execute=function(toModule){

        $('#probe_id').on('change',function(){
           
            switch(this.value){
                case '1':
                    $('#probe100').children('div').hide();
                    $('#probe100').find('#probe1').show();
                    $('#probe100 input:not(.ZUI-radio)').val('');
                    break;
                case '2':
                    $('#probe100').children('div').hide();
                    $('#probe100').find('#probe2').show();
                    $('#probe100').find('#probe3').show();
                    $('#probe100').find('#probe5').show();
                    $('#probe100').find('#probe6').show();
                    $('#probe100').find('#probe7').show();
                    $('#probe100 input:not(.ZUI-radio)').val('');
                    $('#P5').val('3');
                    $('#P6').val('3');
                    $('#P7').val('0');
                    break;
                case '3':
                    $('#probe100').children('div').hide();
                    $('#probe100').find('#probe2').show();
                    $('#probe100').find('#probe3').show();
                    $('#probe100').find('#probe4').show();
                    $('#probe100').find('#probe5').show();
                    $('#probe100').find('#probe6').show();
                    $('#probe100').find('#probe7').show();
                    $('#probe100').find('#probe8').show();
                    $('#probe100 input:not(.ZUI-radio)').val('');
                    $('#P5').val('3');
                    $('#P6').val('2');
                    $('#P7').val('3');
                    break;
                case '4':
                    $('#probe100').children('div').hide();
                    $('#probe100').find('#probe2').show();
                    $('#probe100').find('#probe5').show();
                    $('#probe100 input:not(.ZUI-radio)').val('');
                    $('#P5').val('2');
                    break;
                case '5' :
                    $('#probe100').children('div').hide();
                    $('#probe100').find('#probe2').show();
                    $('#probe100 input:not(.ZUI-radio)').val('');
                    break;
                case '6':
                    $('#probe100').children('div').hide();
                    $('#probe100').find('#probe2').show();
                    $('#probe100 input:not(.ZUI-radio)').val('');
                    break;
                default :
                     $('#probe100').children('div').hide();
            }

        }).change();

        $('input[name=is_probe_active]').on('change',function(){
           switch(this.value){
            case '1' :
                $('#probe_active_timeout').hide();
                $('#P9').hide();
                break;
            default :
                $('#probe_active_timeout').show();
                $('#P9').show();
           }
        }).change();
    };
   
});
Example #5
0
    exports.execute = function(toModule,data){
        if(data.index != undefined){
            $("#myTab li").eq(data.index).find("a").trigger("click");
        }

        var getChecked = function(obj,url,selector,pramName,callback){
            var $checked = obj.find(selector+":checkbox:checked"),
            ids = [];

            $checked.each(function(){
                var $this = $(this),
                id = $this.attr("data-id");
                ids.push(id);
            });
            var pram = {};

            pram[pramName] = ids.join(",");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: url,
                    data:pram,
                    type:"post",
                    dataType:"json",
                    success: function(r){
                        if(r.code == 1){
                            $.alert("删除成功");
                            toModule("host_dispatch",function(){
                                callback&callback();
                            });
                        }else{
                            $.alert(r.message);
                        }
                    }
                });
                return false;
            });
        }
        //调度策略 操作
        var $dispatch = $("#dispatch_list");

        $dispatch.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.delSchStrategy,
                    data: {Id:id},
                    dataType:"json",
                    success: function(r){
                        
                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(0).find("a").trigger("click");
                            });
                            
                        }else{
                            alert(r.message);
                        }
                    }
                });
            });
        });

        $(".hostDispatch-del").on("click",function(){
            getChecked($dispatch,config.urls.delSchStrategy,".delCheck","Id",function(){
                $("#myTab li").eq(0).find("a").trigger("click");
            });
        });


        /// territory 操作
        var $territory = $("#dispatch_list1");

        $territory.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.delTerritory,
                    data: {Ids:id},
                    dataType:"json",
                    success: function(r){
                        
                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(1).find("a").trigger("click");
                            });
                            
                        }else{
                            $.alert(r.message);
                        }
                    }
                });
            });
            
        });
        $(".territory-del").on("click",function(){
            getChecked($territory,config.urls.delTerritory,".delTCheck","Ids",function(){
                $("#myTab li").eq(1).find("a").trigger("click");
            });
        });

        config.global.updateCache("/ApiScheduleStrategy/listTerritoryStrategy");//清除缓存
        //ipset 删除
        var $ipSet = $("#dispatch_list2");

        $ipSet.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.delIpSet,
                    data: {ids:id},
                    dataType:"json",
                    success: function(r){
                        
                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(2).find("a").trigger("click");
                            });
                            
                        }else{
                            $.alert(r.message);
                        }
                    }
                });
            });
        });
        $(".ipset-del").on("click",function(){
            getChecked($ipSet,config.urls.delIpSet,".delIPCheck","ids",function(){
                $("#myTab li").eq(2).find("a").trigger("click");
            });
        });
        //probe*********************
        
         var $probe = $("#disprobe_list");

        $probe.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.delProbe,
                    data: {ids:id},
                    dataType:"json",
                    success: function(r){

                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(3).find("a").trigger("click");
                            });

                        }else{
                            $.alert(r.message);
                        }
                    }
                });
            });
        });
        $(".probe-del").on("click",function(){
            getChecked($probe,config.urls.delProbe,".delProbeCheck","ids",function(){
                $("#myTab li").eq(3).find("a").trigger("click");
            });
        });
        //探测策略类型


         var $probep = $("#disprobe_list1");

        $probep.on("click","a.delete",function(){
            var $this = $(this),
            $td = $this.parent(),
            id = $td.attr("data-id");

            $.confirm('确定要删除吗?').yes(function(){
                $.ajax({
                    url: config.urls.deleteProbeStrategy,
                    data: {ids:id},
                    dataType:"json",
                    success: function(r){

                        if(r.code == 1){
                            toModule("host_dispatch",function(){
                                $("#myTab li").eq(4).find("a").trigger("click");
                            });

                        }else{
                            $.alert(r.message);
                        }
                    }
                });
            });
        });
        $(".hostDispatch1-del").on("click",function(){
            getChecked($probep,config.urls.deleteProbeStrategy,".delProbePCheck","ids",function(){
                $("#myTab li").eq(4).find("a").trigger("click");
            });
        });
        

        //健康度阀值设置
        var $heath = $("#dispatch_healthy"),
        sendHeathTpl = $("#sendHeathTpl").html(),
        html = Handlebars.compile(sendHeathTpl)({});

        $heath.on("click","#sendHeath",function(){
            $.dialog(html,{title:"下发的设备"}).yes(function(){
                var ids = [];
                $("#sendTpl-form .new-checks input:checked").each(function(){
                    ids.push($(this).val())
                });
                $.ajax({
                    url:config.urls.sendHeath,
                    data:{device_ids:ids.join(",")},
                    type:"get",
                    dataType:"json",
                    success: function(r){
                        $.alert(r.message);
                    }
                });
                return false;
            });
        });
    }