datatable options

This commit is contained in:
Adrien MALINGREY 2025-02-07 01:25:58 +01:00
parent b5606b5ad0
commit e5e94288b7

View File

@ -10,18 +10,14 @@
<xsl:output method="html" encoding="UTF-8" indent="yes" /> <xsl:output method="html" encoding="UTF-8" indent="yes" />
<xsl:strip-space elements='*' /> <xsl:strip-space elements='*' />
<xsl:variable name="stylesheetURL" <xsl:variable name="stylesheetURL" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'), '?')" />
select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'href=&quot;'), '?')" />
<xsl:variable name="base" select="concat($stylesheetURL, '/../../')" /> <xsl:variable name="base" select="concat($stylesheetURL, '/../../')" />
<xsl:variable name="name" <xsl:variable name="name" select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'name='), '&quot;')" />
select="substring-before(substring-after(processing-instruction('xml-stylesheet'),'name='), '&quot;')" />
<xsl:template match="nmaprun"> <xsl:template match="nmaprun">
<xsl:variable name="targets" select="substring-after(@args, '-oX - ')" /> <xsl:variable name="targets" select="substring-after(@args, '-oX - ')" />
<xsl:variable <xsl:variable name="current" select="." />
name="current" select="." /> <xsl:variable name="init" select="document(concat($base, 'scans/', $name, '.xml'))/nmaprun" />
<xsl:variable name="init"
select="document(concat($base, 'scans/', $name, '.xml'))/nmaprun" />
<html lang="fr"> <html lang="fr">
<xsl:apply-templates select="." mode="head"> <xsl:apply-templates select="." mode="head">
@ -50,8 +46,7 @@
</xsl:choose> </xsl:choose>
</h1> </h1>
<table id="scanResultsTable" style="width:100%" role="grid" <table id="scanResultsTable" style="width:100%" role="grid" class="ui sortable small compact stuck striped table">
class="ui sortable small compact stuck striped table">
<thead> <thead>
<tr> <tr>
<th style="width: min-width">Etat</th> <th style="width: min-width">Etat</th>
@ -65,8 +60,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<xsl:apply-templates <xsl:apply-templates select="host | $init/host[not(address/@addr=$current/host/address/@addr)][not(status/@state='down')]">
select="host | $init/host[not(address/@addr=$current/host/address/@addr)][not(status/@state='down')]">
<xsl:with-param name="init" select="$init" /> <xsl:with-param name="init" select="$init" />
<xsl:with-param name="current" select="$current" /> <xsl:with-param name="current" select="$current" />
</xsl:apply-templates> </xsl:apply-templates>
@ -76,25 +70,29 @@
<script> <script>
var table = $('#scanResultsTable').DataTable({ var table = $('#scanResultsTable').DataTable({
layout: { responsive: true,
topStart: { colReorder: true,
buttons: [ fixedHeader: true,
'copy', 'excel', 'pdf' lengthMenu : [256, 512, 1024, 2048, { label: 'Tout', value: -1 }],
] language: {
lengthMenu: 'Afficher _MENU_ résultats'
},
layout: {
topStart: { search: {text: 'Filtrer', placeholder: 'Filtre'} },
topEnd: {
buttons: [
'print',
{
extend: 'collection',
text: 'Exporter',
buttons: ['csv', 'excel', 'pdf']
},
],
}, },
topEnd: 'search',
bottomStart: 'pageLength', bottomStart: 'pageLength',
bottomEnd: 'paging', bottomEnd: 'paging',
bottom2Start: 'info', bottom2Start: 'info',
}, },
fixedHeader: true,
lengthMenu : [
[256, 512, 1024, 2048, -1],
[256, 512, 1024, 2048, "All"]
],
responsive: true,
colReorder: true,
buttons : ['copy', 'excel', 'pdf']
}) })
table.order([1, 'asc']).draw() table.order([1, 'asc']).draw()
@ -112,12 +110,9 @@ $('.ui.dropdown').dropdown()
<xsl:template match="host"> <xsl:template match="host">
<xsl:param name="init" /> <xsl:param name="init" />
<xsl:param name="current" /> <xsl:param name="current" />
<xsl:variable name="addr" <xsl:variable name="addr" select="address/@addr" />
select="address/@addr" /> <xsl:variable name="initHost" select="$init/host[address/@addr=$addr]" />
<xsl:variable name="initHost" <xsl:variable name="currentHost" select="$current/host[address/@addr=$addr]" />
select="$init/host[address/@addr=$addr]" />
<xsl:variable name="currentHost"
select="$current/host[address/@addr=$addr]" />
<xsl:variable name="hostAddress"> <xsl:variable name="hostAddress">
<xsl:choose> <xsl:choose>
<xsl:when test="hostnames/hostname/@name"> <xsl:when test="hostnames/hostname/@name">
@ -164,17 +159,14 @@ $('.ui.dropdown').dropdown()
<xsl:if test="substring-after(hostnames/hostname/@name, '.')"> <xsl:if test="substring-after(hostnames/hostname/@name, '.')">
<wbr /> <wbr />
<xsl:text>.</xsl:text> <xsl:text>.</xsl:text>
<xsl:value-of <xsl:value-of select="substring-after(hostnames/hostname/@name, '.')" />
select="substring-after(hostnames/hostname/@name, '.')" />
</xsl:if> </xsl:if>
</td> </td>
<td> <td>
<xsl:value-of select="address[@addrtype='mac']/@vendor" /> <xsl:value-of select="address[@addrtype='mac']/@vendor" />
</td> </td>
<td> <td>
<xsl:apply-templates <xsl:apply-templates select="ports/port | $initHost/ports/port[not(state/@state='closed')][not(@portid=$currentHost/ports/port/@portid)]" mode="service">
select="ports/port | $initHost/ports/port[not(state/@state='closed')][not(@portid=$currentHost/ports/port/@portid)]"
mode="service">
<xsl:with-param name="initHost" select="$initHost" /> <xsl:with-param name="initHost" select="$initHost" />
<xsl:with-param name="currentHost" select="$currentHost" /> <xsl:with-param name="currentHost" select="$currentHost" />
<xsl:with-param name="hostAddress" select="$hostAddress" /> <xsl:with-param name="hostAddress" select="$hostAddress" />