diff --git a/js/messages.php b/js/messages.php index 4824ee2559..d2e5fc3d6b 100644 --- a/js/messages.php +++ b/js/messages.php @@ -322,16 +322,6 @@ $javascriptMessages = [ 'strAnalyzeQuery' => __('Analyse query'), - /* Server status advisor */ - - 'strPerformanceIssues' => __('Possible performance issues'), - 'strIssuse' => __('Issue'), - 'strRecommendation' => __('Recommendation'), - 'strRuleDetails' => __('Rule details'), - 'strJustification' => __('Justification'), - 'strFormula' => __('Used variable / formula'), - 'strTest' => __('Test'), - /* For query editor */ 'strFormatting' => __('Formatting SQL…'), 'strNoParam' => __('No parameters found!'), diff --git a/js/server/status/advisor.js b/js/server/status/advisor.js deleted file mode 100644 index 5251989332..0000000000 --- a/js/server/status/advisor.js +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Server Status Advisor - * - * @package PhpMyAdmin - */ - -/** - * Unbind all event handlers before tearing down a page - */ -AJAX.registerTeardown('server/status/advisor.js', function () { - $('#statustabs_advisor').html(''); - $('#advisorDialog').remove(); -}); - -AJAX.registerOnload('server/status/advisor.js', function () { - // if no advisor is loaded - if ($('#advisorData').length === 0) { - return; - } - - /** ** Server config advisor ****/ - var $dialog = $('
').attr('id', 'advisorDialog'); - - var $cnt = $('#statustabs_advisor'); - var $tbody; - var $tr; - var even = true; - - var data = JSON.parse($('#advisorData').text()); - $cnt.html(''); - - if (data.parse.errors.length > 0) { - $cnt.append('Rules file not well formed, following errors were found:
- '); - $cnt.append(data.parse.errors.join('
- ')); - $cnt.append('

'); - } - - if (data.run.errors.length > 0) { - $cnt.append('Errors occurred while executing rule expressions:
- '); - $cnt.append(data.run.errors.join('
- ')); - $cnt.append('

'); - } - - if (data.run.fired.length > 0) { - $cnt.append('

' + Messages.strPerformanceIssues + '

'); - $cnt.append('' + - '
' + Messages.strIssuse + '' + Messages.strRecommendation + - '
'); - $tbody = $cnt.find('table#rulesFired'); - - var rcStripped; - - $.each(data.run.fired, function (key, value) { - // recommendation may contain links, don't show those in overview table (clicking on them redirects the user) - rcStripped = $.trim($('
').html(value.recommendation).text()); - $tbody.append($tr = $('' + - value.issue + '' + rcStripped + ' ')); - even = !even; - $tr.data('rule', value); - - $tr.on('click', function () { - var rule = $(this).data('rule'); - $dialog - .dialog({ title: Messages.strRuleDetails }) - .html( - '

' + Messages.strIssuse + ':
' + rule.issue + '

' + - '

' + Messages.strRecommendation + ':
' + rule.recommendation + '

' + - '

' + Messages.strJustification + ':
' + rule.justification + '

' + - '

' + Messages.strFormula + ':
' + rule.formula + '

' + - '

' + Messages.strTest + ':
' + rule.test + '

' - ); - - var dlgBtns = {}; - dlgBtns[Messages.strClose] = function () { - $(this).dialog('close'); - }; - - $dialog.dialog({ width: 600, buttons: dlgBtns }); - }); - }); - } -}); diff --git a/libraries/classes/Controllers/Server/Status/AdvisorController.php b/libraries/classes/Controllers/Server/Status/AdvisorController.php index 9d8fd694d9..0b385087bc 100644 --- a/libraries/classes/Controllers/Server/Status/AdvisorController.php +++ b/libraries/classes/Controllers/Server/Status/AdvisorController.php @@ -1,7 +1,5 @@ response->getHeader()->getScripts(); - $scripts->addFile('server/status/advisor.js'); - - $data = ''; + $data = []; if ($this->data->dataLoaded) { - $data = json_encode($this->advisor->run()); + $data = $this->advisor->run(); } $this->response->addHTML($this->template->render('server/status/advisor/index', [ diff --git a/templates/server/status/advisor/index.twig b/templates/server/status/advisor/index.twig index 48965fcf82..476ca3a9c0 100644 --- a/templates/server/status/advisor/index.twig +++ b/templates/server/status/advisor/index.twig @@ -5,9 +5,10 @@

{% trans 'Advisor system' %}

- {% if data is not empty %} - - @@ -49,11 +50,63 @@
-
+ {% if data.parse.errors|length > 0 %} + + {% endif %} -
{{ data }}
- {% else %} - {{ 'Not enough privilege to view the advisor.'|trans|error }} + {% if data.run.errors|length > 0 %} + + {% endif %} + + {% if data.run.fired|length > 0 %} +

{% trans 'Possible performance issues' %}

+ +
+ {% for rule in data.run.fired %} +
+
+ +
+
+
+
+
{% trans 'Issue:' %}
+
{{ rule.issue }}
+ +
{% trans 'Recommendation:' %}
+
{{ rule.recommendation|raw }}
+ +
{% trans 'Justification:' %}
+
{{ rule.justification }}
+ +
{% trans 'Used variable / formula:' %}
+
{{ rule.formula }}
+ +
{% trans 'Test:' %}
+
{{ rule.test }}
+
+
+
+
+ {% endfor %} +
+ {% endif %} {% endif %} {% endblock %} diff --git a/test/classes/Controllers/Server/Status/AdvisorControllerTest.php b/test/classes/Controllers/Server/Status/AdvisorControllerTest.php index cccd81ac6b..e83a66e61b 100644 --- a/test/classes/Controllers/Server/Status/AdvisorControllerTest.php +++ b/test/classes/Controllers/Server/Status/AdvisorControllerTest.php @@ -120,21 +120,5 @@ class AdvisorControllerTest extends TestCase 'Do note however that this system provides recommendations', $html ); - $this->assertStringContainsString( - '
', - $html - ); - $this->assertStringContainsString( - htmlspecialchars(json_encode('parse')), - $html - ); - $this->assertStringContainsString( - htmlspecialchars(json_encode('errors')), - $html - ); - $this->assertStringContainsString( - htmlspecialchars(json_encode('run')), - $html - ); } } diff --git a/themes/metro/scss/_card.scss b/themes/metro/scss/_card.scss index 27fc2f200d..83653687cb 100644 --- a/themes/metro/scss/_card.scss +++ b/themes/metro/scss/_card.scss @@ -7,3 +7,22 @@ .card-body ul { padding-#{$left}: 0; } + +.accordion { + > .card { + border-radius: 0; + + > .card-header { + background-color: $button-background; + + .btn { + color: $button-color; + + &:hover, + &:active { + text-decoration: none; + } + } + } + } +} diff --git a/themes/pmahomme/scss/_card.scss b/themes/pmahomme/scss/_card.scss index 597258c82d..45bfbb7dbb 100644 --- a/themes/pmahomme/scss/_card.scss +++ b/themes/pmahomme/scss/_card.scss @@ -19,3 +19,24 @@ -webkit-box-shadow: 1px 1px 15px #999 inset; box-shadow: 1px 1px 15px #999 inset; } + +.accordion { + > .card { + > .card-header { + background-color: inherit; + box-shadow: none; + + .btn { + color: #235a81; + + &:active { + box-shadow: none; + } + } + } + + .card-body { + background-color: #fff; + } + } +}