Skip to content

Commit

Permalink
Improve table maintenance pages
Browse files Browse the repository at this point in the history
Replaces tables with list group cards.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Aug 28, 2020
1 parent bade581 commit d82d598
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 97 deletions.
28 changes: 24 additions & 4 deletions libraries/classes/Table/Maintenance.php
Expand Up @@ -31,7 +31,12 @@ public function getAnalyzeTableRows(string $db, array $tables): array
$query = 'ANALYZE TABLE ' . implode(', ', $backQuotedTables) . ';';

$this->dbi->selectDb($db);
$rows = $this->dbi->fetchResult($query);
$result = $this->dbi->fetchResult($query);

$rows = [];
foreach ($result as $row) {
$rows[$row['Table']][] = $row;
}

return [$rows, $query];
}
Expand All @@ -47,7 +52,12 @@ public function getCheckTableRows(string $db, array $tables): array
$query = 'CHECK TABLE ' . implode(', ', $backQuotedTables) . ';';

$this->dbi->selectDb($db);
$rows = $this->dbi->fetchResult($query);
$result = $this->dbi->fetchResult($query);

$rows = [];
foreach ($result as $row) {
$rows[$row['Table']][] = $row;
}

return [$rows, $query];
}
Expand Down Expand Up @@ -99,7 +109,12 @@ public function getOptimizeTableRows(string $db, array $tables): array
$query = 'OPTIMIZE TABLE ' . implode(', ', $backQuotedTables) . ';';

$this->dbi->selectDb($db);
$rows = $this->dbi->fetchResult($query);
$result = $this->dbi->fetchResult($query);

$rows = [];
foreach ($result as $row) {
$rows[$row['Table']][] = $row;
}

return [$rows, $query];
}
Expand All @@ -115,7 +130,12 @@ public function getRepairTableRows(string $db, array $tables): array
$query = 'REPAIR TABLE ' . implode(', ', $backQuotedTables) . ';';

$this->dbi->selectDb($db);
$rows = $this->dbi->fetchResult($query);
$result = $this->dbi->fetchResult($query);

$rows = [];
foreach ($result as $row) {
$rows[$row['Table']][] = $row;
}

return [$rows, $query];
}
Expand Down
52 changes: 31 additions & 21 deletions templates/table/maintenance/analyze.twig
@@ -1,29 +1,39 @@
<div class="container-fluid">
<h2>
{% trans 'Analyzing tables' %}
{% trans 'Analyze table' %}
{{ show_mysql_docu('ANALYZE_TABLE') }}
</h2>

{{ message|raw }}

<table class="mt-3">
<thead>
<tr>
<th>{% trans 'Table' %}</th>
<th>{% trans 'Operation' %}</th>
<th>{% trans 'Message type' %}</th>
<th>{% trans 'Message' %}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.Table }}</td>
<td>{{ row.Op|title }}</td>
<td>{{ row.Msg_type|title }}</td>
<td>{{ row.Msg_text }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% for name, table in rows %}
<div class="card mb-3">
<div class="card-header">{{ name }}</div>

<ul class="list-group list-group-flush">
{% for row in table %}
<li class="list-group-item">
{% if row.Op|lower != 'analyze' %}
<span class="badge badge-secondary">{{ row.Op|title }}</span>
{% endif %}

{% set badge_variation %}
{%- if row.Msg_type|lower == 'error' -%}
badge-danger
{%- elseif row.Msg_type|lower == 'warning' -%}
badge-warning
{%- elseif row.Msg_type|lower == 'info' or row.Msg_type|lower == 'note' -%}
badge-info
{%- else -%}
badge-secondary
{%- endif -%}
{% endset %}
<span class="badge {{ badge_variation }}">{{ row.Msg_type|title }}</span>

{{ row.Msg_text }}
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
50 changes: 31 additions & 19 deletions templates/table/maintenance/check.twig
@@ -1,29 +1,41 @@
<div class="container-fluid">
<h2>
{% trans 'Checking tables' %}
{% trans 'Check table' %}
{{ show_mysql_docu('CHECK_TABLE') }}
</h2>

{{ message|raw }}

<table class="mt-3">
<thead>
<tr>
<th>{% trans 'Table' %}</th>
<th>{% trans 'Message type' %}</th>
<th>{% trans 'Message' %}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.Table }}</td>
<td>{{ row.Msg_type|title }}</td>
<td>{{ row.Msg_text }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% for name, table in rows %}
<div class="card mb-3">
<div class="card-header">{{ name }}</div>

<ul class="list-group list-group-flush">
{% for row in table %}
<li class="list-group-item">
{% if row.Op|lower != 'check' %}
<span class="badge badge-secondary">{{ row.Op|title }}</span>
{% endif %}

{% set badge_variation %}
{%- if row.Msg_type|lower == 'error' -%}
badge-danger
{%- elseif row.Msg_type|lower == 'warning' -%}
badge-warning
{%- elseif row.Msg_type|lower == 'info' or row.Msg_type|lower == 'note' -%}
badge-info
{%- else -%}
badge-secondary
{%- endif -%}
{% endset %}
<span class="badge {{ badge_variation }}">{{ row.Msg_type|title }}</span>

{{ row.Msg_text }}
</li>
{% endfor %}
</ul>
</div>
{% endfor %}

{{ indexes_problems|raw }}
</div>
32 changes: 16 additions & 16 deletions templates/table/maintenance/checksum.twig
Expand Up @@ -8,24 +8,24 @@

<table class="my-3">
<thead>
<tr>
<th>{% trans 'Table' %}</th>
<th>{% trans 'Checksum' %}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.Table }}</td>
<td class="text-right">
{% if row.Checksum is not null %}
{{ row.Checksum }}
{% else %}
<em class="text-muted">NULL</em>
{% endif %}
</td>
<th>{% trans 'Table' %}</th>
<th>{% trans 'Checksum' %}</th>
</tr>
{% endfor %}
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.Table }}</td>
<td class="text-right">
{% if row.Checksum is not null %}
{{ row.Checksum }}
{% else %}
<em class="text-muted">NULL</em>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>

Expand Down
48 changes: 30 additions & 18 deletions templates/table/maintenance/optimize.twig
Expand Up @@ -6,22 +6,34 @@

{{ message|raw }}

<table class="mt-3">
<thead>
<tr>
<th>{% trans 'Table' %}</th>
<th>{% trans 'Message type' %}</th>
<th>{% trans 'Message' %}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.Table }}</td>
<td>{{ row.Msg_type|title }}</td>
<td>{{ row.Msg_text }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% for name, table in rows %}
<div class="card mb-3">
<div class="card-header">{{ name }}</div>

<ul class="list-group list-group-flush">
{% for row in table %}
<li class="list-group-item">
{% if row.Op|lower != 'optimize' %}
<span class="badge badge-secondary">{{ row.Op|title }}</span>
{% endif %}

{% set badge_variation %}
{%- if row.Msg_type|lower == 'error' -%}
badge-danger
{%- elseif row.Msg_type|lower == 'warning' -%}
badge-warning
{%- elseif row.Msg_type|lower == 'info' or row.Msg_type|lower == 'note' -%}
badge-info
{%- else -%}
badge-secondary
{%- endif -%}
{% endset %}
<span class="badge {{ badge_variation }}">{{ row.Msg_type|title }}</span>

{{ row.Msg_text }}
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
48 changes: 30 additions & 18 deletions templates/table/maintenance/repair.twig
Expand Up @@ -6,22 +6,34 @@

{{ message|raw }}

<table class="mt-3">
<thead>
<tr>
<th>{% trans 'Table' %}</th>
<th>{% trans 'Message type' %}</th>
<th>{% trans 'Message' %}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.Table }}</td>
<td>{{ row.Msg_type|title }}</td>
<td>{{ row.Msg_text }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% for name, table in rows %}
<div class="card mb-3">
<div class="card-header">{{ name }}</div>

<ul class="list-group list-group-flush">
{% for row in table %}
<li class="list-group-item">
{% if row.Op|lower != 'repair' %}
<span class="badge badge-secondary">{{ row.Op|title }}</span>
{% endif %}

{% set badge_variation %}
{%- if row.Msg_type|lower == 'error' -%}
badge-danger
{%- elseif row.Msg_type|lower == 'warning' -%}
badge-warning
{%- elseif row.Msg_type|lower == 'info' or row.Msg_type|lower == 'note' -%}
badge-info
{%- else -%}
badge-secondary
{%- endif -%}
{% endset %}
<span class="badge {{ badge_variation }}">{{ row.Msg_type|title }}</span>

{{ row.Msg_text }}
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
2 changes: 1 addition & 1 deletion themes/bootstrap/scss/_bootstrap.scss
Expand Up @@ -20,7 +20,7 @@
@import "../../../node_modules/bootstrap/scss/card";
@import "../../../node_modules/bootstrap/scss/breadcrumb";
//@import "../../../node_modules/bootstrap/scss/pagination";
//@import "../../../node_modules/bootstrap/scss/badge";
@import "../../../node_modules/bootstrap/scss/badge";
//@import "../../../node_modules/bootstrap/scss/jumbotron";
@import "../../../node_modules/bootstrap/scss/alert";
//@import "../../../node_modules/bootstrap/scss/progress";
Expand Down

0 comments on commit d82d598

Please sign in to comment.