<commit_before>{% extends "base.html" %}
{% load verbatim %}
{% block navbar %}
<ul class="nav">
    <li class="dropdown">
        {% if label_name %}
            <a href="#" class="dropdown-toggle label_menu" data-toggle="dropdown">{{ label_name }}<span class="changed_label_indicator">*</span> <b class="caret"></b></a>
        {% else %}
            <a href="#" class="dropdown-toggle label_menu" data-toggle="dropdown">Label <b class="caret"></b></a>
        {% endif %}
        <ul class="dropdown-menu">
            {% if label_name %}
            <li><a href="#">Save<span class="changed_label_indicator">*</span></a></li>
                <li><a href="#save-new-label" data-toggle="modal">Save as...</a></li>
                <li><a href="#">Remove</a></li>
            {% else %}
                <li><a href="#save-new-label" data-toggle="modal">Save as...</a></li>
            {% endif %}
            <li class="divider"></li>
            {% for label in labels %}
                <li><a href="/?label={{label.label_name}}">{{ label.label_name }}</a></li>
            {% endfor %}
        </ul>
    </li>
</ul>
<ul class="nav pull-right">
    <li class="divider-vertical"></li>
    <li class="streaming"><a href="#" data-toggle="collapse" data-target="#collapse-form" class="" id="streaming">Streaming</a></li>
</ul>
{% endblock %}
{% block content %}
{% verbatim %}
    <script id="log_messages" type="text/html">
    {{#objects}}
    <tr class="sev-{{ severity }}{{#old}} old-data{{/old}}">
        <td><span class="label">{{ severity }}</span></td>
        <td><span class="">{{ datetime }}</span></td>
        <td><span class="">{{ application.username }}</span></td>
        <td><span class="">{{ server_ip }}</span></td>
        <td><span class="">{{ short_desc }}</span></td>
    </tr>
    {{/objects}}
    </script>
    <script id="refresh_notice_template" type="text/html">
        <a href="#">Click here to display {{ count }} new message(s).</a>
    </script>
{% endverbatim %}
<form class="well filters form-search collapse non-expanded" id="collapse-form">
    <div id="form-wrapper">
        <input type="hidden" name="order_by" value="-datetime">
        <div id="severity-checkboxes">
            {{ lqf.severity__in }}
        </div>
        <div id="severity-buttons" class="btn-group" data-toggle="buttons-checkbox">
            {% for id, name,active in lqf.severity_choices %}
            <a href='#' class="btn {% if active %} active {% endif %}sev-{{ name }}" data-value="{{ id }}"><span class="dot">&nbsp;</span>{{ name|capfirst }}</a>
            {% endfor %}
        </div>
        {{lqf.search}}
        <div id="advanced">
            <hr />
            <div class="control-group">
                <label class="control-label" for="id_application__in">Applications</label>
                <div class="controls">
                    {{lqf.application__in}}
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="id_application__in">Servers</label>
                <div class="controls">
                    {{ lqf.server_ip__in }}
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="id_datetime__gte">Start of time range</label>
                <div class="controls">
                    {{ lqf.datetime__gte }} 
                </div>
                <label class="control-label" for="id_datetime__lte">End of time range (optional)</label>
                <div class="controls">
                    {{ lqf.datetime__lte }}
                </div>
            </div>
        </form>
    </div>
</div>
<div class="modal fade" id="save-new-label">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">x</a>
        <h3>Save new label</h3>
    </div>
    <div class="modal-body">
        <form>
            <label class="control-label">Save this search as a label</label>
            <div class="controls">
                {{ label_field }}
            </div>
        </form>
    </div>
    <div class="modal-footer">
        <a href="#" id="label-save" class="btn btn-primary">Save</a>
        <a href="#" class="btn" data-dismiss="modal">Close</a>
    </div>
</div>
<div id="refresh_notice" class="well"></div>
<table class="table">
    <thead>
        <tr>
            <th id="severity" class="sortable sorted-desc">Severity</th>
            <th id="datetime" class="sortable sorted-desc sorted-active">Time</th>
            <th id="application__username" class="sortable sorted-desc">Application</th>
            <th id="server_ip" class="sortable sorted-desc">Server</th>
            <th>Message</th>
        </tr>
    </thead>
    <tbody>
        <!-- no log messages loaded -->
    </tbody>
</table>
<div id="lazyload-trigger"></div>
<script src="{{ STATIC_URL }}js/api.js" type="text/javascript"></script>
<script type="text/javascript">
    $('.filters input, .filters select').change(function() {
        $(".changed_label_indicator").show();
    });
    $('#lazyload-trigger').appear(lazyloadTrigger, { 'one': false });
    $("#label-save").click(function(){
        var query = $(".filters").serialize();
        $.post("/label/", {
            csrfmiddlewaretoken : "{{ csrf_token }}",
            query_string : query,
            name: $("#id_label").val()
            }, 
            function(data) {
                console.log(data);
                window.location=data;
            }
        );
    });
    $("#collapse-form").on('show', function(){
        $("#collapse-form").removeClass("non-expanded");
        $("#streaming").addClass("streaming-deactivated");
        $("#streaming").html("Streaming paused");
        streamingMode = false;
    });
    $("#collapse-form").on('hide', function(){
        $("#collapse-form").addClass("non-expanded");
        $("#streaming").removeClass("streaming-deactivated");
        $("#streaming").html("Streaming");
        streamingMode = true;
    });
    $(document).ready(function() {
        $("#severity-checkboxes").hide();
        var datetimepickerFormat = {timeFormat: 'hh:mm:ss', dateFormat: 'yy-mm-dd', separator :'T'};
        $("#id_datetime__gte").datetimepicker(datetimepickerFormat);
        $("#id_datetime__lte").datetimepicker(datetimepickerFormat);
    });
    var toggleSeverity = function(button) {
        var checkbox = $("form.filters input[value='" + button.dataset['value'] + "']");
        checkbox.prop("checked", ! checkbox.prop("checked"));
        checkbox.change();
    };
    $("#severity-buttons a").bind('click', function(event){
        toggleSeverity(this);
    });
    $("th.sortable").append('<i class="icon-sortable"></i>');
    $("th.sortable").bind('click', function(event){
        if ($(this).hasClass('sorted-active')) {
            // already sorted on this column, so user wants to switch direction of sort
            $(this).toggleClass('sorted-desc').toggleClass('sorted-asc');
        } else {
            $("th.sortable").removeClass('sorted-active');
            $(this).toggleClass('sorted-active');
        }

        var ordering_param = ($(this).hasClass('sorted-desc') ? '-' : '') + this.id;
        $('form.filters input[name="order_by"]').attr('value', ordering_param);
        $('form.filters input[name="order_by"]').change();
    });
</script>
{% endblock %}
<commit_msg>Make save-option in menu trigger the save-label function<commit_after>{% extends "base.html" %}
{% load verbatim %}
{% block navbar %}
<ul class="nav">
    <li class="dropdown">
        {% if label_name %}
            <a href="#" class="dropdown-toggle label_menu" data-toggle="dropdown">{{ label_name }}<span class="changed_label_indicator">*</span> <b class="caret"></b></a>
        {% else %}
            <a href="#" class="dropdown-toggle label_menu" data-toggle="dropdown">Label <b class="caret"></b></a>
        {% endif %}
        <ul class="dropdown-menu">
            {% if label_name %}
            <li><a href="#" class="label-save">Save<span class="changed_label_indicator">*</span></a></li>
                <li><a href="#save-new-label" data-toggle="modal">Save as...</a></li>
                <li><a href="#">Remove</a></li>
            {% else %}
                <li><a href="#save-new-label" data-toggle="modal">Save as...</a></li>
            {% endif %}
            <li class="divider"></li>
            {% for label in labels %}
                <li><a href="/?label={{label.label_name}}">{{ label.label_name }}</a></li>
            {% endfor %}
        </ul>
    </li>
</ul>
<ul class="nav pull-right">
    <li class="divider-vertical"></li>
    <li class="streaming"><a href="#" data-toggle="collapse" data-target="#collapse-form" class="" id="streaming">Streaming</a></li>
</ul>
{% endblock %}
{% block content %}
{% verbatim %}
    <script id="log_messages" type="text/html">
    {{#objects}}
    <tr class="sev-{{ severity }}{{#old}} old-data{{/old}}">
        <td><span class="label">{{ severity }}</span></td>
        <td><span class="">{{ datetime }}</span></td>
        <td><span class="">{{ application.username }}</span></td>
        <td><span class="">{{ server_ip }}</span></td>
        <td><span class="">{{ short_desc }}</span></td>
    </tr>
    {{/objects}}
    </script>
    <script id="refresh_notice_template" type="text/html">
        <a href="#">Click here to display {{ count }} new message(s).</a>
    </script>
{% endverbatim %}
<form class="well filters form-search collapse non-expanded" id="collapse-form">
    <div id="form-wrapper">
        <input type="hidden" name="order_by" value="-datetime">
        <div id="severity-checkboxes">
            {{ lqf.severity__in }}
        </div>
        <div id="severity-buttons" class="btn-group" data-toggle="buttons-checkbox">
            {% for id, name,active in lqf.severity_choices %}
            <a href='#' class="btn {% if active %} active {% endif %}sev-{{ name }}" data-value="{{ id }}"><span class="dot">&nbsp;</span>{{ name|capfirst }}</a>
            {% endfor %}
        </div>
        {{lqf.search}}
        <div id="advanced">
            <hr />
            <div class="control-group">
                <label class="control-label" for="id_application__in">Applications</label>
                <div class="controls">
                    {{lqf.application__in}}
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="id_application__in">Servers</label>
                <div class="controls">
                    {{ lqf.server_ip__in }}
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="id_datetime__gte">Start of time range</label>
                <div class="controls">
                    {{ lqf.datetime__gte }} 
                </div>
                <label class="control-label" for="id_datetime__lte">End of time range (optional)</label>
                <div class="controls">
                    {{ lqf.datetime__lte }}
                </div>
            </div>
        </form>
    </div>
</div>
<div class="modal fade" id="save-new-label">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">x</a>
        <h3>Save new label</h3>
    </div>
    <div class="modal-body">
        <form>
            <label class="control-label">Save this search as a label</label>
            <div class="controls">
                {{ label_field }}
            </div>
        </form>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn btn-primary label-save">Save</a>
        <a href="#" class="btn" data-dismiss="modal">Close</a>
    </div>
</div>
<div id="refresh_notice" class="well"></div>
<table class="table">
    <thead>
        <tr>
            <th id="severity" class="sortable sorted-desc">Severity</th>
            <th id="datetime" class="sortable sorted-desc sorted-active">Time</th>
            <th id="application__username" class="sortable sorted-desc">Application</th>
            <th id="server_ip" class="sortable sorted-desc">Server</th>
            <th>Message</th>
        </tr>
    </thead>
    <tbody>
        <!-- no log messages loaded -->
    </tbody>
</table>
<div id="lazyload-trigger"></div>
<script src="{{ STATIC_URL }}js/api.js" type="text/javascript"></script>
<script type="text/javascript">
    $('.filters input, .filters select').change(function() {
        $(".changed_label_indicator").show();
    });
    $('#lazyload-trigger').appear(lazyloadTrigger, { 'one': false });
    $(".label-save").click(function(){
        var query = $(".filters").serialize();
        $.post("/label/", {
            csrfmiddlewaretoken : "{{ csrf_token }}",
            query_string : query,
            name: $("#id_label").val()
            }, 
            function(data) {
                console.log(data);
                window.location=data;
            }
        );
    });
    $("#collapse-form").on('show', function(){
        $("#collapse-form").removeClass("non-expanded");
        $("#streaming").addClass("streaming-deactivated");
        $("#streaming").html("Streaming paused");
        streamingMode = false;
    });
    $("#collapse-form").on('hide', function(){
        $("#collapse-form").addClass("non-expanded");
        $("#streaming").removeClass("streaming-deactivated");
        $("#streaming").html("Streaming");
        streamingMode = true;
    });
    $(document).ready(function() {
        $("#severity-checkboxes").hide();
        var datetimepickerFormat = {timeFormat: 'hh:mm:ss', dateFormat: 'yy-mm-dd', separator :'T'};
        $("#id_datetime__gte").datetimepicker(datetimepickerFormat);
        $("#id_datetime__lte").datetimepicker(datetimepickerFormat);
    });
    var toggleSeverity = function(button) {
        var checkbox = $("form.filters input[value='" + button.dataset['value'] + "']");
        checkbox.prop("checked", ! checkbox.prop("checked"));
        checkbox.change();
    };
    $("#severity-buttons a").bind('click', function(event){
        toggleSeverity(this);
    });
    $("th.sortable").append('<i class="icon-sortable"></i>');
    $("th.sortable").bind('click', function(event){
        if ($(this).hasClass('sorted-active')) {
            // already sorted on this column, so user wants to switch direction of sort
            $(this).toggleClass('sorted-desc').toggleClass('sorted-asc');
        } else {
            $("th.sortable").removeClass('sorted-active');
            $(this).toggleClass('sorted-active');
        }

        var ordering_param = ($(this).hasClass('sorted-desc') ? '-' : '') + this.id;
        $('form.filters input[name="order_by"]').attr('value', ordering_param);
        $('form.filters input[name="order_by"]').change();
    });
</script>
{% endblock %}

{'fraction_non_alphanumeric': 0.20338641402942956, 'fraction_numerical': 0.00026876301820869447, 'mean_word_length': 2.398949531856588, 'pattern_counts': {'":': 0, '<': 333, '<?xml version=': 0, '>': 333, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5425036', 'n_tokens_mistral': 4548, 'n_tokens_neox': 4393, 'n_words': 816}