<div class="row">
	<div class="col-md-12 col-lg-12 mt-3">
		{{ page_utils.print_page_title(i18n("about.alert_defines")) }}
	</div>
</div>
<div class="row">
	<div class="col-md-12">
		<table id="alert-overview" class="table table-striped table-bordered w-100">
            <thead>
                <tr>
                    <th width="10%"> {{ i18n("scripts_overview.alert_key") }} </th>
                    <th width="35%"> {{ i18n("scripts_overview.alert_key_string") }} </th>
                    <th width="20%"> {{ i18n("scripts_overview.alert_name") }} </th>
                    <th width="10%"> {{ i18n("scripts_overview.has_attacker") }} </th>
                    <th width="10%"> {{ i18n("scripts_overview.has_victim") }} </th>
                    <th width="10%"> {{ i18n("scripts_overview.status_key") }} </th>
                </tr>
            </thead>
            <tbody>
			{% for alert_key = 0, 65535 do %}
			{% local alert_type = alert_consts.getAlertType(alert_key) %}
			{% if alert_type and alert_consts.alert_types[alert_type] then %}

			<tr>
				<td class="text-center"> {{ string.format("%i", alert_key) }} </td>
				<td> {{ string.format("%s", alert_type) }} </td>
				{% if alert_consts.alert_types[alert_type].meta then %}

				<td>
				  {{ string.format("%s", alert_consts.alertTypeLabel(alert_key, true)) }}
				</td>

				{% if alert_consts.alert_types[alert_type].meta.has_attacker or alert_consts.alert_types[alert_type].meta.has_victim then %}
				<td class="text-right">
				  {% if alert_consts.alert_types[alert_type].meta.has_attacker then %}
				  <strong>
				    <span style="color: #008000;">✓</span>
				  </strong>
				  {% end %}
				</td>

				<td class="text-right">
				  {% if alert_consts.alert_types[alert_type].meta.has_victim then %}
				  <strong>
				    <span style="color: #008000;">✓</span>
				  </strong>
				  {% end %}
				</td>
				{% else %}
					<td class="text-right"></td>
					<td class="text-right"></td>
				{% end %}

				<td class="text-right">
				{% if alert_consts.alert_types[alert_type].meta.status_key then %}
				{{ string.format("%i", alert_consts.alert_types[alert_type].meta.status_key) }}
				{% end %}
				</td>

				{% else %}
				<td><small><i>*To be migrated</i></small></td>
				{% end %}
			</tr>
			{% end %}
			{% end %}
            </tbody>
        </table>
	</div>
</div>
<script type="text/javascript">
    i18n_ext.warning ="{{ i18n('warning', {}) }}";
    i18n_ext.showing_x_to_y_rows = "{{ i18n('showing_x_to_y_rows', {x='_START_', y='_END_', tot='_TOTAL_'}) }}";
    i18n_ext.search = "{{ i18n('search') }}";
    i18n_ext.edit = "{{ i18n('edit') }}";
    i18n_ext.remove = "{{ i18n('remove') }}";
    i18n_ext.all = "{{ i18n('all') }}";
</script>
<script type="text/javascript">
    $(document).ready(function() {
    
        let dtConfig = DataTableUtils.getStdDatatableConfig();
        dtConfig = DataTableUtils.extendConfig(dtConfig, {
            columnsDefs: [{
                targets: [0,5], render: function (data, type) {
                    if (type === "display") return NtopUtils.fint(data);
                    return data;
                }
            }]
        })

        const $sitesDatatable = $(`#alert-overview`).DataTable(dtConfig);

    });
</script>
