Adding a Jinja2 Template

This commit is contained in:
Jean-Marie Renouard 2022-02-12 23:33:59 +01:00
parent f18570b96f
commit 191b16c21b
2 changed files with 115 additions and 2 deletions

View file

@ -256,6 +256,7 @@ my @dblist;
# Super structure containing all information
my %result;
$result{'MySQLTuner'}{'version'} = $tunerversion;
$result{'MySQLTuner'}{'datetime'} =`date '+%d-%m-%Y %H:%M:%S'`;
$result{'MySQLTuner'}{'options'} = \%opt;
# Functions that handle the print styles
@ -6639,7 +6640,7 @@ sub mysql_triggers() {
# Take the two recommendation arrays and display them at the end of the output
sub make_recommendations {
$result{'Recommendations'} = \@generalrec;
$result{'Adjust variables'} = \@adjvars;
$result{'AdjustVariables'} = \@adjvars;
subheaderprint "Recommendations";
if ( @generalrec > 0 ) {
prettyprint "General recommendations:";
@ -6665,7 +6666,9 @@ sub close_outputfile {
sub headerprint {
prettyprint
" >> MySQLTuner $tunerversion - Major Hayden <major\@mhtx.net>\n"
" >> MySQLTuner $tunerversion\n"
. "\t * Jean-Marie Renouard <jmrenouard\@gmail.com>\n".
. "\t * Major Hayden <major\@mhtx.net>\n"
. " >> Bug reports, feature requests, and downloads at http://mysqltuner.pl/\n"
. " >> Run with '--help' for additional options and output filtering";
}

110
templates/basic.html.j2 Normal file
View file

@ -0,0 +1,110 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">
<link href="https://fonts.googleapis.com/css2?family=Material+Icons" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
<title>MySQL Tuner {{ MySQLTuner.version }} - {{ MySQLTuner.datetime | default(' ??? ') }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>MySQL Tuner {{ MySQLTuner.version }} - {{ MySQLTuner.datetime | default(' ??? ') }}</h1>
<div class="d-flex align-items-start">
<div class="nav flex-column nav-pills me-3" id="v-pills-tab" role="tablist" aria-orientation="vertical">
{% for etab in [ "Recommendations", "Variables", "Status", "Calculations" ] %}
<button class="nav-link{% if loop.index == 1 %} active{% endif %}" id="v-pills-{{ etab }}-tab" data-bs-toggle="pill" data-bs-target="#v-pills-{{ etab }}" type="button" role="tab" aria-controls="v-pills-{{ etab }}" aria-selected="true">{{ etab }}</button>
{% endfor %}
</div>
<div class="tab-content" id="v-pills-tabContent">
<div class="tab-pane fade show active" id="v-pills-Recommendations" role="tabpanel" aria-labelledby="v-pills-Recommendations-tab">
<h3><i class="bi bi-list-check"></i>Recommendations</h3>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Recommandations</th>
</tr>
</thead>
<tbody>{% for result in Recommendations %}
<tr>
<td> {{ loop.index }}</td>
<td> {{ result }}</td>
</tr>{% endfor %}
</tbody>
</table>
</div>
<div class="tab-pane fade" id="v-pills-Variables" role="tabpanel" aria-labelledby="v-pills-Variables-tab">
<h3><i class="bi bi-list-check"></i>System variables</h3>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Variable</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>{% for vari in Variables %}
<tr>
<td> {{ loop.index }}</td>
<td> {{ vari }}</td>
<td> {{ Variables[vari] }}</td>
</tr>{% endfor %}
</tbody>
</table>
</div>
<div class="tab-pane fade" id="v-pills-Status" role="tabpanel" aria-labelledby="v-pills-Status-tab">
<h3><i class="bi bi-list-check"></i>Status Variables</h3>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Variable de status</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>{% for vari in Status %}
<tr>
<td> {{ loop.index }}</td>
<td> {{ vari }}</td>
<td> {{ Status[vari] }}</td>
</tr>{% endfor %}
</tbody>
</table>
</div>
<div class="tab-pane fade" id="v-pills-Calculations" role="tabpanel" aria-labelledby="v-pills-Calculations-tab">
<h3><i class="bi bi-list-check"></i>Calculated variables</h3>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Calculated variables</th>
<th scope="col">Value</th>
</tr>
</thead>
<tbody>{% for vari in Calculations %}
<tr>
<td> {{ loop.index }}</td>
<td> {{ vari }}</td>
<td> {{ Calculations[vari] }}</td>
</tr>{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>