Skip to content
Snippets Groups Projects
Commit 21cea572 authored by Jan Mach's avatar Jan Mach
Browse files

Fix: Fixed broken report statistics panel.

After previous changes the statistics panel in report detail view needed to be updated as well. I have also unified HTML coding style to match other similar views (eg. event dashboard view). (Redmine issue: #4321)
parent 9fe8199d
No related branches found
No related tags found
No related merge requests found
......@@ -68,207 +68,221 @@
<strong>{{ gettext('Report mailed') }}:</strong> {% if item.flag_mailed %}{{ babel_format_datetime(item.mail_dt) }} ({{ gettext('before') }} {{ babel_format_timedelta(current_datetime_utc - item.mail_dt) }}){% else %}{{ gettext('never')}}{% endif %}
</small>
</p>
</div>
</div>
<div class="row">
<div class="col-lg-12">
</div> <!-- /.col-lg-12 -->
</div> <!-- /.row -->
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#tab-report-message" aria-controls="tab-report-message" role="tab" data-toggle="tab">
<strong>{{ gettext('Message') }}</strong>
</a>
</li>
<li role="presentation">
<a href="#tab-report-metadata" aria-controls="tab-report-metadata" role="tab" data-toggle="tab">
<strong>{{ gettext('Metadata') }}</strong>
</a>
</li>
<li role="presentation">
<a href="#tab-report-stats" aria-controls="tab-report-stats" role="tab" data-toggle="tab">
<strong>{{ gettext('Statistics') }}</strong>
</a>
</li>
<li role="presentation">
<a href="#tab-report-data-json" aria-controls="tab-report-data-json" role="tab" data-toggle="tab">
<strong>{{ gettext('Data') }}</strong>
</a>
</li>
</ul>
<!-- Tab navigation - BEGIN --------------------------------------->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#tab-report-message" aria-controls="tab-report-message" role="tab" data-toggle="tab">
<strong>{{ gettext('Message') }}</strong>
</a>
</li>
<li role="presentation">
<a href="#tab-report-metadata" aria-controls="tab-report-metadata" role="tab" data-toggle="tab">
<strong>{{ gettext('Metadata') }}</strong>
</a>
</li>
<li role="presentation">
<a href="#tab-report-stats" aria-controls="tab-report-stats" role="tab" data-toggle="tab">
<strong>{{ gettext('Statistics') }}</strong>
</a>
</li>
<li role="presentation">
<a href="#tab-report-data-json" aria-controls="tab-report-data-json" role="tab" data-toggle="tab">
<strong>{{ gettext('Data') }}</strong>
</a>
</li>
</ul>
<!-- Tab navigation - END ----------------------------------------->
<!-- Tab panes -->
<div class="tab-content">
<!-- Tab panels - BEGIN ------------------------------------------->
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="tab-report-message">
<br>
<samp>
{{ item.message | replace("&", "&amp;") | replace("<", "&lt;") | replace(">", "&gt;") | replace("\n", "<br/>\n") | replace(' ', '&nbsp;') | replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;') | safe }}
</samp>
</div>
<!-- Tab panel - BEGIN ---------------------------------------->
<div role="tabpanel" class="tab-pane fade in active" id="tab-report-message">
<br>
<samp>
{{ item.message | replace("&", "&amp;") | replace("<", "&lt;") | replace(">", "&gt;") | replace("\n", "<br/>\n") | replace(' ', '&nbsp;') | replace("\t", '&nbsp;&nbsp;&nbsp;&nbsp;') | safe }}
</samp>
</div> <!-- /.tabpanel #tab-report-message -->
<div role="tabpanel" class="tab-pane fade" id="tab-report-metadata">
<table class="table table-condensed table-striped">
<tr>
<th>
{{ gettext('Type') }}:
</th>
<td>
{{ macros_site.render_report_label_type(item, True) }}
</td>
</tr>
<tr>
<th>
{{ gettext('Severity') }}:
</th>
<td>
{{ macros_site.render_report_label_severity(item, True) }}
</td>
</tr>
<tr>
<th>
{{ gettext('Report window') }}:
</th>
<td>
{{ babel_format_datetime(item.dt_from) }} - {{ babel_format_datetime(item.dt_to) }} ({{ babel_format_timedelta(item.delta) }})
</td>
</tr>
<tr>
<th>
{{ gettext('Report delay') }}:
</th>
<td>
{{ babel_format_timedelta(item.createtime - item.dt_to) }}
</td>
</tr>
<tr>
<th>
{{ gettext('Event count') }}:
</th>
<td>
{%- if item.type == 'summary': %}
<div class="progress" data-toggle="tooltip" title="{{ gettext('Number of events in this report in comparison with total number of events that matched reporting conditions.') }}">
{%- if item.evcount_thr %}
<div class="progress-bar progress-bar-warning progress-bar" style="width: {{ '{:3.0f}'.format(item.evcount_thr/item.evcount_all*100) }}%">
<span>{{ item.evcount_thr }} {{ gettext('new events')}}</span>
</div>
{%- endif %}
{%- if item.evcount_rlp %}
<div class="progress-bar progress-bar-danger" style="width: {{ '{:3.0f}'.format(item.evcount_rlp/item.evcount_all*100) }}%">
<span>{{ item.evcount_rlp }} {{ gettext('relapsed')}}</span>
</div>
{%- endif %}
</div>
{%- else %}
<div class="progress" data-toggle="tooltip" title="{{ gettext('Number of events in this report in comparison with total number of events in parent summary report.') }}">
<div class="progress-bar progress-bar-warning progress-bar" style="width: {{ '{:3.0f}'.format(item.evcount_rep/item.evcount_all*100) }}%">
<span>{{ item.evcount_rep }} {{ gettext('reported events')}}</span>
</div>
</div>
{%- endif %}
<strong>{{ item.evcount_rep }} ({{ babel_format_percent(item.evcount_rep / item.evcount_all) }})</strong> {{ gettext('reported') }}{% if item.type == 'summary' %}, {{ item.evcount_all }} ({{ babel_format_percent(item.evcount_all / item.evcount_all) }}) {{ gettext('matched') }}, {{ item.evcount_new }} ({{ babel_format_percent(item.evcount_new / item.evcount_all) }}) {{ gettext('new events') }}, {{ item.evcount_flt_blk }} ({{ babel_format_percent(item.evcount_flt_blk / item.evcount_all) }}) {{ gettext('filtered out') }}, {{ item.evcount_thr_blk }} ({{ babel_format_percent(item.evcount_thr_blk / item.evcount_all) }}) {{ gettext('thresholded') }}, {{ item.evcount_rlp }} ({{ babel_format_percent(item.evcount_rlp / item.evcount_all) }}) {{ gettext('relapsed') }}{% else %}, {{ item.evcount_all }} {{ gettext('total in parent summary report') }}{%- endif %}
</td>
</tr>
<tr>
<th>
{{ gettext('IP address count') }}:
</th>
<td>
{{ statistics['ips'] | count }}
</td>
</tr>
<tr>
<th>
{{ gettext('Target mail') }}:
</th>
<td>
{%- if item.flag_mailed %}
{% if item.mail_to %}{{ item.mail_to | join(', ') }}, {% endif %}{{ babel_format_datetime(item.mail_dt) }} ({{ gettext('before') }} {{ babel_format_timedelta(current_datetime_utc - item.mail_dt) }})
{%- else %}
{{ gettext('never')}}
<!-- Tab panel - BEGIN ---------------------------------------->
<div role="tabpanel" class="tab-pane fade" id="tab-report-metadata">
<br>
<table class="table table-condensed table-striped">
<tr>
<th>
{{ gettext('Type') }}:
</th>
<td>
{{ macros_site.render_report_label_type(item, True) }}
</td>
</tr>
<tr>
<th>
{{ gettext('Severity') }}:
</th>
<td>
{{ macros_site.render_report_label_severity(item, True) }}
</td>
</tr>
<tr>
<th>
{{ gettext('Report window') }}:
</th>
<td>
{{ babel_format_datetime(item.dt_from) }} - {{ babel_format_datetime(item.dt_to) }} ({{ babel_format_timedelta(item.delta) }})
</td>
</tr>
<tr>
<th>
{{ gettext('Report delay') }}:
</th>
<td>
{{ babel_format_timedelta(item.createtime - item.dt_to) }}
</td>
</tr>
<tr>
<th>
{{ gettext('Event count') }}:
</th>
<td>
{%- if item.type == 'summary': %}
<div class="progress" data-toggle="tooltip" title="{{ gettext('Number of events in this report in comparison with total number of events that matched reporting conditions.') }}">
{%- if item.evcount_thr %}
<div class="progress-bar progress-bar-warning progress-bar" style="width: {{ '{:3.0f}'.format(item.evcount_thr/item.evcount_all*100) }}%">
<span>{{ item.evcount_thr }} {{ gettext('new events')}}</span>
</div>
{%- endif %}
</td>
</tr>
<tr>
<th>
{{ gettext('Filtering') }}:
</th>
<td>
{%- if item.filtering %}
{%- for item in item.filtering | dictsort %}
<strong>{{ item[0] }}</strong> <span class="badge">{{ item[1] }}</span>{% if not loop.last %}<br>{% endif %}
{%- endfor %}
{%- else %}
{{ gettext('no filters matched')}}
{%- if item.evcount_rlp %}
<div class="progress-bar progress-bar-danger" style="width: {{ '{:3.0f}'.format(item.evcount_rlp/item.evcount_all*100) }}%">
<span>{{ item.evcount_rlp }} {{ gettext('relapsed')}}</span>
</div>
{%- endif %}
</td>
</tr>
</table>
</div>
</div>
{%- else %}
<div class="progress" data-toggle="tooltip" title="{{ gettext('Number of events in this report in comparison with total number of events in parent summary report.') }}">
<div class="progress-bar progress-bar-warning progress-bar" style="width: {{ '{:3.0f}'.format(item.evcount_rep/item.evcount_all*100) }}%">
<span>{{ item.evcount_rep }} {{ gettext('reported events')}}</span>
</div>
</div>
{%- endif %}
<strong>{{ item.evcount_rep }} ({{ babel_format_percent(item.evcount_rep / item.evcount_all) }})</strong> {{ gettext('reported') }}{% if item.type == 'summary' %}, {{ item.evcount_all }} ({{ babel_format_percent(item.evcount_all / item.evcount_all) }}) {{ gettext('matched') }}, {{ item.evcount_new }} ({{ babel_format_percent(item.evcount_new / item.evcount_all) }}) {{ gettext('new events') }}, {{ item.evcount_flt_blk }} ({{ babel_format_percent(item.evcount_flt_blk / item.evcount_all) }}) {{ gettext('filtered out') }}, {{ item.evcount_thr_blk }} ({{ babel_format_percent(item.evcount_thr_blk / item.evcount_all) }}) {{ gettext('thresholded') }}, {{ item.evcount_rlp }} ({{ babel_format_percent(item.evcount_rlp / item.evcount_all) }}) {{ gettext('relapsed') }}{% else %}, {{ item.evcount_all }} {{ gettext('total in parent summary report') }}{%- endif %}
</td>
</tr>
<tr>
<th>
{{ gettext('IP address count') }}:
</th>
<td>
{{ statistics['ips'] | count }}
</td>
</tr>
<tr>
<th>
{{ gettext('Target mail') }}:
</th>
<td>
{%- if item.flag_mailed %}
{% if item.mail_to %}{{ item.mail_to | join(', ') }}, {% endif %}{{ babel_format_datetime(item.mail_dt) }} ({{ gettext('before') }} {{ babel_format_timedelta(current_datetime_utc - item.mail_dt) }})
{%- else %}
{{ gettext('never')}}
{%- endif %}
</td>
</tr>
<tr>
<th>
{{ gettext('Filtering') }}:
</th>
<td>
{%- if item.filtering %}
{%- for item in item.filtering | dictsort %}
<strong>{{ item[0] }}</strong> <span class="badge">{{ item[1] }}</span>{% if not loop.last %}<br>{% endif %}
{%- endfor %}
{%- else %}
{{ gettext('no filters matched')}}
{%- endif %}
</td>
</tr>
</table>
</div> <!-- /.tabpanel #tab-report-metadata -->
<div role="tabpanel" class="tab-pane fade" id="tab-report-stats">
<!-- Tab panel - BEGIN ---------------------------------------->
<div role="tabpanel" class="tab-pane fade" id="tab-report-stats">
<br>
<!-- Search result dump - BEGIN ----------------------------------->
<script>
var search_result_statistics = {{ statistics | tojson }};
</script>
<!-- Search result dump - END ------------------------------------->
<ul class="nav nav-tabs nav-tabs-tooltipped" role="tablist">
{%- for chsection in ('analyzers', 'asns', 'categories', 'category_sets', 'countries', 'detectors', 'detectorsws', 'ips', 'classes', 'severities') %}
{%- if chsection in statistics %}
<li role="presentation" class="text-center{% if loop.first %} active{% endif %}">
<a role="tab" data-toggle="tab" href="#tab-report-stats-{{ chsection }}" class="chart-tab">
# {{ chsection }}
</a>
</li>
{%- endif %}
{%- endfor %}
</ul>
<div class="tab-content">
{%- for chsection in ('analyzers', 'asns', 'categories', 'category_sets', 'countries', 'detectors', 'detectorsws', 'ips', 'classes', 'severities') %}
{%- if chsection in statistics %}
<div role="tabpanel" class="tab-pane fade{% if loop.first %} in active{% endif %}" id="tab-report-stats-{{ chsection }}">
<h4>{{ _('Number of events per %(item)s', item = chsection) }}</h4>
<!-- Inner tab navigation - BEGIN ------------------------->
<ul class="nav nav-tabs nav-tabs-tooltipped nav-tabs-inner" role="tablist">
{{
macros_chart.render_dashboard_nav(
statistics,
'report-stats',
hide_sections = ['abuses'],
active_first = True
)
}}
</ul>
<!-- Inner tab navigation - END --------------------------->
{{ macros_chart.render_chart_pie(
'report_stats',
statistics,
chsection
)
}}
</div>
{%- endif %}
{%- endfor %}
</div>
</div>
<!-- Inner tab panels - BEGIN ----------------------------->
<div class="tab-content">
{{
macros_chart.render_dashboard_panels(
statistics,
'search_result_statistics',
'report-stats',
hide_sections = ['abuses'],
active_first = True
)
}}
</div>
<!-- Inner tab panels - END ------------------------------->
<div role="tabpanel" class="tab-pane fade" id="tab-report-data-json">
<br>
<button id="ajax-load-report-data" class="btn btn-default">
{{ get_icon('action-reload') }} {{ gettext('Load report data') }}
</button>
<div id="ajax-load-report-data-result" style="display: none">
<br>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#tab-ajax-report-data-raw" aria-controls="tab-ajax-report-data-raw" role="tab" data-toggle="tab">
<strong>{{ gettext('Raw data') }}</strong>
</a>
</li>
</ul>
</div> <!-- /.tabpanel #tab-report-stats -->
<!-- Tab panes -->
<div class="tab-content">
<!-- Tab panel - BEGIN ---------------------------------------->
<div role="tabpanel" class="tab-pane fade" id="tab-report-data-json">
<br>
<button id="ajax-load-report-data" class="btn btn-default">
{{ get_icon('action-reload') }} {{ gettext('Load report data') }}
</button>
<div role="tabpanel" class="tab-pane fade in active" id="tab-ajax-report-data-by-category">
<br>
<pre id="ajax-report-data-raw"></pre>
</div>
</div>
<div id="ajax-load-report-data-result" style="display: none">
<br>
<!-- Inner tab navigation - BEGIN --------------------->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#tab-ajax-report-data-raw" aria-controls="tab-ajax-report-data-raw" role="tab" data-toggle="tab">
<strong>{{ gettext('Raw data') }}</strong>
</a>
</li>
</ul>
<!-- Inner tab navigation - END ----------------------->
<!-- Inner tab panels - BEGIN ------------------------->
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="tab-ajax-report-data-by-category">
<br>
<pre id="ajax-report-data-raw"></pre>
</div>
</div>
<!-- Inner tab panels - END ------------------------------->
</div>
</div> <!-- #ajax-load-report-data-result -->
</div> <!-- /.tabpanel #tab-report-data-json -->
</div>
</div>
<!-- Tab panels - END --------------------------------------------->
{%- if permission_can('developer') %}
<hr>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment