Commit 05a16a80 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

multiple configs

parent ae5148ff
Loading
Loading
Loading
Loading
+96 −32
Original line number Original line Diff line number Diff line
@@ -244,10 +244,12 @@ function fill_content_rebind_events(){
        if ($(this).prop("checked")) flags = "p"+flags;
        if ($(this).prop("checked")) flags = "p"+flags;
        else                         flags = "_";
        else                         flags = "_";
        
        
        debugfs_data[index].configs[0].lines[subindex].flags = flags;
        var j = dropdown_active_config(debugfs_data[index]);

        debugfs_data[index].configs[j].lines[subindex].flags = flags;
        //console.log($(this).attr("file")+", "+$(this).attr("line")+", "+$(this).prop("checked"));
        //console.log($(this).attr("file")+", "+$(this).attr("line")+", "+$(this).prop("checked"));
        $.ajax({
        $.ajax({
            url: "debugfs.php?cmd=echo&file="+$(this).attr("file")+"&line="+$(this).attr("line")+"&flags="+flags,
            url: "debugfs.php?cmd=echo&conf="+j+"&file="+$(this).attr("file")+"&line="+$(this).attr("line")+"&flags="+flags,
            queue: true
            queue: true
        });
        });
    });
    });
@@ -338,7 +340,7 @@ function init_ui_controls(record,index){
                //apply existing checkboxes to rec
                //apply existing checkboxes to rec
                oldrec = debugfs_data[id];
                oldrec = debugfs_data[id];
                
                
                j = init_ui_dropdown(rec,id);
                j = dropdown_active_config(rec,id);
                
                
                lnew = rec.configs[j].lines.length;
                lnew = rec.configs[j].lines.length;
                lold = debugfs_data[id].configs[j].lines.length;
                lold = debugfs_data[id].configs[j].lines.length;
@@ -379,12 +381,55 @@ function init_ui_controls(record,index){


    var dc0_li_in = $("<input>",{
    var dc0_li_in = $("<input>",{
        type:"text",
        type:"text",
        placeholder:"create new"
        placeholder:"create new",
        myindex:index
    }).css({
    }).css({
        width:"100px"
        width:"100px"
    });
    });


    dc0_li_in.change(function(){
    dc0_li_in.change(function(){
        //name?
        var value = $(this).val();
        var index = $(this).attr("myindex");
        
        var configs = debugfs_data[index].configs;
        
        var exists = false;
        var active = 0;
        var existing = 0;
        
        for(var i=0;i<configs.length;i++){
            if (value==configs[i].name) {
                exists = true;
                existing = i;
            }
            if (configs[i].state==1){
                active = i;
            }
        }
        if (!exists){
            //add to debugfs_data - copy current checkboxes - then select
            //add to list, add to front
            //apply to debugfs
            var arr = debugfs_data[index].configs[active];
            debugfs_data[index].configs[i] = JSON.parse(JSON.stringify(arr));
            debugfs_data[index].configs[i].name = value;
            
            dropdown_add_list_item(record,index,i);
            //sync for now should be enough
            //dropdown_clone_new_config(value,active);
            update_debugfs_config();
            existing = i;
        }else{
            //select and restore checkboxes
            console.log("This config already exists, selecting");
        }
        //select anyway
        debugfs_data[index].configs[active].state = 0;
        debugfs_data[index].configs[existing].state = 1;
        
        $("#dropdown_"+index).html(record.configs[existing].name+caret);
        
        $(this).parent().click();
        $(this).parent().click();
        //check ze name if dose note exist add to list and to config then apply config
        //check ze name if dose note exist add to list and to config then apply config
    });
    });
@@ -401,8 +446,29 @@ function init_ui_controls(record,index){
}
}


function init_ui_dropdown(record,index){
function init_ui_dropdown(record,index){
    for(var j=0;j<record.configs.length;j++){
    var res = 0;
    var res = 0;
    for(var j=0;j<record.configs.length;j++){

        dropdown_add_list_item(record,index,j);

        if (record.configs[j].state==1){
            $("#dropdown_"+index).html(record.configs[j].name+caret);
            res = j;
        }
    }
    return res;
}

function dropdown_active_config(record){
    for(var j=0;j<record.configs.length;j++){
        if (record.configs[j].state==1){
            return j;
        }
    }
    return 0;
}

function dropdown_add_list_item(record,index,j){
    var lentry = $("<li>",{
    var lentry = $("<li>",{
        myindex:index,
        myindex:index,
        confindex:j
        confindex:j
@@ -427,17 +493,15 @@ function init_ui_dropdown(record,index){
            console.log("Already selected, doing nothing");
            console.log("Already selected, doing nothing");
        }else{
        }else{
            //select config action here: rename, and restore checkboxes' states
            //select config action here: rename, and restore checkboxes' states
            $("#dropdown_"+index).html(record.configs[confindex].name+caret);
            var ac = dropdown_active_config(record);
            record.configs[ac].state = 0;
            record.configs[confindex].state = 1;
            update_debugfs_config();
        }
        }
    });
    });
    
    
    $("#controls_"+index).find("ul").append(lentry);
    $("#controls_"+index).find("ul").append(lentry);

        if (record.configs[j].state==1){
            $("#dropdown_"+index).html(record.configs[j].name+caret);
            res = j;
        }
    }
    return res;
}
}


function update_debugfs_config(){
function update_debugfs_config(){
+3 −2
Original line number Original line Diff line number Diff line
@@ -148,7 +148,7 @@ function apply_flag($flag){
    
    
}
}


function sync_from_debugfs_to_config($file,$line,$flags,$sign){
function sync_from_debugfs_to_config($config_index,$file,$line,$flags,$sign){
    global $tmp_config;
    global $tmp_config;


    //$arr_debugfs = get_control("/sys/kernel/debug/dynamic_debug/control");
    //$arr_debugfs = get_control("/sys/kernel/debug/dynamic_debug/control");
@@ -239,6 +239,7 @@ if ($cmd=="echo") {
    $file = $_GET['file'];
    $file = $_GET['file'];
    $line = $_GET['line'];
    $line = $_GET['line'];
    $flags = $_GET['flags'];
    $flags = $_GET['flags'];
    $config_index = intval($_GET['conf']);
    //$config name
    //$config name
    
    
    if (strpos($flags,"p")===FALSE){
    if (strpos($flags,"p")===FALSE){
@@ -247,7 +248,7 @@ if ($cmd=="echo") {
        $sign = "+";
        $sign = "+";
    }
    }
    exec("echo -n 'file $file line $line ${sign}${flags}' > $DEBUGFSFILE");
    exec("echo -n 'file $file line $line ${sign}${flags}' > $DEBUGFSFILE");
    sync_from_debugfs_to_config($file,$line,$flags,$sign);
    sync_from_debugfs_to_config($config_index,$file,$line,$flags,$sign);
}
}


$debugfs_configs = "debugfs_configs";
$debugfs_configs = "debugfs_configs";