/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Server Status Advisor * * @package PhpMyAdmin */ /** * Unbind all event handlers before tearing down a page */ AJAX.registerTeardown('server_status_advisor.js', function () { $('a[href="#openAdvisorInstructions"]').off('click'); $('#statustabs_advisor').html(''); $('#advisorDialog').remove(); $('#instructionsDialog').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 $instructionsDialog = $('
') .attr('id', 'instructionsDialog') .html($('#advisorInstructionsDialog').html()); $('a[href="#openAdvisorInstructions"]').click(function () { var dlgBtns = {}; dlgBtns[PMA_messages.strClose] = function () { $(this).dialog('close'); }; $instructionsDialog.dialog({ title: PMA_messages.strAdvisorSystem, width: '60%', buttons: dlgBtns }); }); var $cnt = $('#statustabs_advisor'); var $tbody; var $tr; var str; var even = true; 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('

' + PMA_messages.strPerformanceIssues + '

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

' + PMA_messages.strIssuse + ':
' + rule.issue + '

' + '

' + PMA_messages.strRecommendation + ':
' + rule.recommendation + '

' + '

' + PMA_messages.strJustification + ':
' + rule.justification + '

' + '

' + PMA_messages.strFormula + ':
' + rule.formula + '

' + '

' + PMA_messages.strTest + ':
' + rule.test + '

' ); var dlgBtns = {}; dlgBtns[PMA_messages.strClose] = function () { $(this).dialog('close'); }; $dialog.dialog({ width: 600, buttons: dlgBtns }); }); }); } });