Commit 1222ee72 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

added debugfs-webgui

parent a2e29be3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line


# Runs 'make', 'make install', and 'make clean' in specified subdirectories
# Runs 'make', 'make install', and 'make clean' in specified subdirectories
SUBDIRS := src/php_top src/python_tests # src1
SUBDIRS := src/php_top src/python_tests src/debugfs-webgui # src1
INSTALLDIRS = $(SUBDIRS:%=install-%)
INSTALLDIRS = $(SUBDIRS:%=install-%)
CLEANDIRS =   $(SUBDIRS:%=clean-%)
CLEANDIRS =   $(SUBDIRS:%=clean-%)


+21 −0
Original line number Original line Diff line number Diff line
DOCUMENTROOT=$(DESTDIR)/www/pages
OWN = -o root -g root
INSTDOCS = 0644
INSTALL = install
DOCS=       debugfs.html \
            debugfs.css \
            debugfs.js

PHP_SCRIPTS=debugfs.php

all:
	@echo "make all in src"

install:
	@echo "make install in src"
	$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
	$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(DOCUMENTROOT)
	$(INSTALL) $(OWN) -m $(INSTDOCS) $(PHP_SCRIPTS) $(DOCUMENTROOT)

clean:
	@echo "make clean in src"
+56 −0
Original line number Original line Diff line number Diff line
html{
    font-family: Arial;
    font-size: 0.8em;
}

body{
    padding: 10px;
}

table{
    border-collapse:collapse;
    border-radius: 3px;
}

th, td{
    text-align: left;
    padding: 3px 10px 3px 10px;
    border-radius: 0px;
    border: 1px solid rgba(180,180,180,0.5)
}

th {
    background-color: rgba(200,200,200,0.5);
}

.even {
    background-color: rgba(235,235,235,0.5);
}

.odd {
    background-color: rgba(255,255,255,0.5);
}

.special {
    background-color: rgba(100,200,100,0.5);
}

select {
    border: 1px solid rgba(200,200,200,1);
    border-radius: 2px;
    font-family: Arial;
    font-size: 1em;
    background-color: rgba(200,200,200,0.5);
    margin: 0px;
    padding: 1px;
}

input {
	-moz-appearance: none;
	border: 1px solid rgba(200,200,200,1);
}

.tp{
    width:20px;
    height:20px;
}
 No newline at end of file
+11 −0
Original line number Original line Diff line number Diff line
<html>
  <head>
    <script src="js/jquery-2.2.3.min.js"></script>
    <script src="debugfs.js"></script>
    <script src="js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="js/bootstrap/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="debugfs.css"/>
  </head>
  <body onload='init()'>
  </body>
</html>
 No newline at end of file
+141 −0
Original line number Original line Diff line number Diff line
var debugfs_data;

function init(){
    
    $("body").html("<h3>DebugFS:</h3>");
    
    var b0 = $("<button>",{id:"b0"}).html("toggle hidden");
    b0.prop("state",0);
    
    b0.click(function(){
        if ($(this).prop("state")==0){
            $(this).prop("state",1)
            $(".hidden_rows").show();
        }else{
            $(this).prop("state",0)
            $(".hidden_rows").hide();
        }
    });
    
    $("body").append($("<div>").css({padding:"0px 0px 10px 0px"}).append(b0));
    
    var t = $("<table border=\"1\">").html("\
        <tr>\
            <th style='display:none;' class='hidden_rows'>Show</th>\
            <th>File</th>\
        </tr>\
    ");
    
    $("body").append(t);
    
    $.ajax({
        url: "debugfs.php",
        success: function(data){
            var r = jQuery.parseJSON(data);
            //global
            debugfs_data = r;
            
            for(var i=0;i<r.length;i++){
                                
                l = $("<tr>",{id:"row_"+i}).html("\
                    <td class='hidden_rows' style='text-align:center;display:none' >\
                        <input id='cb_"+i+"' class='tp visibility_cb' type='checkbox'>\
                    </td>\
                    <td class='special filename' id='header_"+i+" '>"+r[i].file+"</td>\
                ");
                
                if (r[i].state==0){
                    l.addClass("hidden_rows").hide();
                    l.find("input").prop("checked",false);
                }else{
                    l.removeClass("hidden_rows").show();
                    l.find("input").prop("checked",true);
                }
                
                content = $("<tr>",{
                    id: "content_"+i
                }).css({
                    display: "none",
                    border: "0px solid rgba(255,255,255,0)"
                });                
                
                content.append(
                    $("<td>").addClass("hidden_rows").hide()
                ).append(
                    $("<td>").append(
                        $("<table>").css({margin:"5px"})
                    )
                );
                
                //.append($("<td>").addClass("hidden_rows").css({display:"none"}))
                
                t.append(l).append(content);
                
                var r1 = r[i].configs[0].lines;
                
                for (var j=0;j<r1.length;j++){

                    ttl  = "module:      "+r1[j].module+"\n";
                    ttl += "function:    "+r1[j].function+"\n";
                    ttl += "format:      "+r1[j].format;
                
                    if (r1[j].flags=="p"){
                        checked = "checked";
                    }else{
                        checked = "";
                    }
                
                    l  = "<tr>";
                    l += "  <td style='text-align:center' title='"+ttl+"'>"+r1[j].lineno+"</td>";
                    l += "  <td style='text-align:center'><input type='checkbox' class='tp debug' "+checked+" file='"+r1[j].file+"' line='"+r1[j].lineno+"' /></td>";
                    l += "</tr>";
                    content.find("table").append(l);
                }
            }
            
            //init actions
            $(".debug").change(function(){
                console.log($(this).attr("file")+", "+$(this).attr("line")+", "+$(this).prop("checked"));
                $.ajax({
                    url: "debugfs.php?cmd=echo&file="+$(this).attr("file")+"&line="+$(this).attr("line")+"&pflag="+$(this).prop("checked")
                });
            });
            
            $(".filename").click(function(){
                var id = $(this).attr("id");
                id = id.substr(id.indexOf("_")+1);
                console.log(id);
                $("#content_"+id).toggle();
            });
            
            $(".visibility_cb").change(function(){
                var id = $(this).attr("id");
                id = id.substr(id.indexOf("_")+1);
                if ($(this).prop("checked")){
                    $("#row_"+id).removeClass("hidden_rows");
                    debugfs_data[id].state = 1;
                }else{
                    $("#row_"+id).addClass("hidden_rows");
                    $("#content_"+id).hide();
                    debugfs_data[id].state = 0;
                }
                update_debugfs_config();
            });
            
            //when everything is parsed. do something.
            // unique IDs
            // save config
        }
    });
}

function update_debugfs_config(){
    console.log("syncing debugfs config");
    console.log(debugfs_data);
    $.ajax({
        type: "POST",
        url: "debugfs.php?cmd=sync",
        data: JSON.stringify(debugfs_data),
        dataType: "json"
    });
}
Loading