Changeset - 9f19d1fa1474
[Not reviewed]
default
0 1 0
domruf - 8 years ago 2017-08-22 21:10:14
dominikruf@gmail.com
statistics: hide checkboxes, instead click on user names directly

This look much better.

The now hidden checkboxes are still used to store the status.

TODO: maybe we'll find a better cleaner way to do this in the future
1 file changed with 14 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/summary/statistics.html
Show inline comments
 
@@ -149,25 +149,31 @@ function SummaryPlot(from,to,dataset,ove
 
    }
 
    var dataset = dataset;
 
    var overview_dataset = [overview_dataset];
 
    var choiceContainer = $("#legend_choices")[0];
 
    var choiceContainerTable = $("#legend_choices_tables")[0];
 
    var $plotContainer = $('#commit_history');
 
    var plotContainer = $('#commit_history')[0];
 
    var $overviewContainer = $('#overview');
 
    var overviewContainer = $('#overview')[0];
 

	
 
    var plot_options = {
 
        bars: {show:true, align: 'center', lineWidth: 4},
 
        legend: {show:true, container: "#legend_container"},
 
        legend: {show:true,
 
                container: "#legend_container",
 
                labelFormatter: function(label, series) {
 
                        // series is the series object for the label
 
                        return '<a href="javascript:void(0)"> ' + label + '</a>';
 
                    }
 
        },
 
        points: {show:true, radius: 0, fill: false},
 
        yaxis: {tickDecimals: 0},
 
        xaxis: {
 
            mode: "time",
 
            timeformat: "%d/%m",
 
            min: from,
 
            max: to
 
        },
 
        grid: {
 
            hoverable: true,
 
            clickable: true,
 
            autoHighlight: true,
 
@@ -207,25 +213,25 @@ function SummaryPlot(from,to,dataset,ove
 
     * @returns
 
     */
 
    function generateCheckboxes(data) {
 
        //append checkboxes
 
        var i = 0;
 
        choiceContainerTable.innerHTML = '';
 
        for(var pos in data) {
 

	
 
            data[pos].color = i;
 
            i++;
 
            if(data[pos].label != ''){
 
                choiceContainerTable.innerHTML +=
 
                    '<tr><td><label><input type="checkbox" id="id_user_{0}" name="{0}" checked="checked" /> \
 
                    '<tr style="display:none"><td><label><input type="checkbox" id="id_user_{0}" name="{0}" checked="checked" /> \
 
                     {0}</label></td></tr>'.format(data[pos].label);
 
            }
 
        }
 
    }
 

	
 
    /**
 
     * ToolTip show
 
     */
 
    function showTooltip(x, y, contents) {
 
        var div=document.getElementById('tooltip');
 
        if(!div) {
 
            div = document.createElement('div');
 
@@ -283,24 +289,25 @@ function SummaryPlot(from,to,dataset,ove
 
    }
 

	
 
    /**
 
    * redraw using new checkbox data
 
    */
 
    function plotchoiced(e){
 
        args = e.data;
 
        var cur_data = args[0];
 
        var cur_ranges = args[1];
 

	
 
        var new_data = [];
 
        var inputs = choiceContainer.getElementsByTagName("input");
 
        inputs[$(e.target).parents('tr').index()].click();
 

	
 
        //show only checked labels
 
        for(var i=0; i<inputs.length; i++) {
 
            var checkbox_key = inputs[i].name;
 

	
 
            if(inputs[i].checked){
 
                for(var d in cur_data){
 
                    if(cur_data[d].label == checkbox_key){
 
                        new_data.push(cur_data[d]);
 
                    }
 
                }
 
            }
 
@@ -320,24 +327,27 @@ function SummaryPlot(from,to,dataset,ove
 
        });
 
        if (!new_data){
 
            new_data = [[0,1]];
 
        }
 
        // do the zooming
 
       plot = $.plot(plotContainer, new_data, new_options);
 

	
 
       $plotContainer.on("plotselected", plotselected);
 

	
 
       //resubscribe plothover
 
       $plotContainer.on("plothover", plothover);
 

	
 
       //resubscribe this function after plot update
 
       $('#legend_container tr a').on("click", [cur_data, cur_ranges], plotchoiced);
 

	
 
       // don't fire event on the overview to prevent eternal loop
 
       overview.setSelection(cur_ranges, true);
 

	
 
    }
 

	
 
    /**
 
     * plot only selected items from overview
 
     * @param ranges
 
     * @returns
 
     */
 
    function plotselected(e, ranges) {
 
        //updates the data for new plot
 
@@ -355,25 +365,25 @@ function SummaryPlot(from,to,dataset,ove
 
        // do the zooming
 
        plot = $.plot(plotContainer, data, new_options);
 

	
 
        $plotContainer.on("plotselected", plotselected);
 

	
 
        //resubscribe plothover
 
        $plotContainer.on("plothover", plothover);
 

	
 
        // don't fire event on the overview to prevent eternal loop
 
        overview.setSelection(ranges, true);
 

	
 
        //resubscribe choiced
 
        $(choiceContainer.getElementsByTagName("input")).on("click", [data, ranges], plotchoiced);
 
        $('#legend_container tr a').on("click", [data, ranges], plotchoiced);
 
    }
 

	
 
    var previousPoint = null;
 

	
 
    function plothover(e, pos, item) {
 
        if (item) {
 
            if (previousPoint != item.datapoint) {
 
                previousPoint = item.datapoint;
 

	
 
                var tooltip = $("#tooltip")[0];
 
                if(tooltip) {
 
                      tooltip.parentNode.removeChild(tooltip);
 
@@ -435,19 +445,19 @@ function SummaryPlot(from,to,dataset,ove
 

	
 
    //show initial selection on overview
 
    overview.setSelection(initial_ranges);
 

	
 
    $plotContainer.on("plotselected", plotselected);
 
    $plotContainer.on("plothover", plothover);
 

	
 
    $overviewContainer.on("plotselected", function (e, ranges) {
 
        plot.setSelection(ranges);
 
    });
 

	
 
    // user choices on overview
 
    $(choiceContainer.getElementsByTagName("input")).on("click", [data, initial_ranges], plotchoiced);
 
    $('#legend_container tr a').on("click", [data, initial_ranges], plotchoiced);
 
}
 

	
 
SummaryPlot(${h.js(c.ts_min)}, ${h.js(c.ts_max)}, ${h.js(c.commit_data)}, ${h.js(c.overview_data)});
 
</script>
 

	
 
</%def>
0 comments (0 inline, 0 general)