1 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 * Server Status Advisor
9 * Unbind all event handlers before tearing down a page
11 AJAX.registerTeardown('server_status_advisor.js', function () {
12 $('a[href="#openAdvisorInstructions"]').unbind('click');
13 $('#statustabs_advisor').html('');
14 $('#advisorDialog').remove();
15 $('#instructionsDialog').remove();
18 AJAX.registerOnload('server_status_advisor.js', function () {
20 // if no advisor is loaded
21 if ($('#advisorData').length == 0) {
25 /**** Server config advisor ****/
26 var $dialog = $('<div />').attr('id', 'advisorDialog');
27 var $instructionsDialog = $('<div />')
28 .attr('id', 'instructionsDialog')
29 .html($('#advisorInstructionsDialog').html());
31 $('a[href="#openAdvisorInstructions"]').click(function () {
33 dlgBtns[PMA_messages.strClose] = function () {
34 $(this).dialog('close');
36 $instructionsDialog.dialog({
37 title: PMA_messages.strAdvisorSystem,
43 var $cnt = $('#statustabs_advisor');
44 var $tbody, $tr, str, even = true;
46 data = JSON.parse($('#advisorData').text());
49 if (data.parse.errors.length > 0) {
50 $cnt.append('<b>Rules file not well formed, following errors were found:</b><br />- ');
51 $cnt.append(data.parse.errors.join('<br/>- '));
52 $cnt.append('<p></p>');
55 if (data.run.errors.length > 0) {
56 $cnt.append('<b>Errors occurred while executing rule expressions:</b><br />- ');
57 $cnt.append(data.run.errors.join('<br/>- '));
58 $cnt.append('<p></p>');
61 if (data.run.fired.length > 0) {
62 $cnt.append('<p><b>' + PMA_messages.strPerformanceIssues + '</b></p>');
63 $cnt.append('<table class="data" id="rulesFired" border="0"><thead><tr>' +
64 '<th>' + PMA_messages.strIssuse + '</th><th>' + PMA_messages.strRecommendation +
65 '</th></tr></thead><tbody></tbody></table>');
66 $tbody = $cnt.find('table#rulesFired');
70 $.each(data.run.fired, function (key, value) {
71 // recommendation may contain links, don't show those in overview table (clicking on them redirects the user)
72 rc_stripped = $.trim($('<div>').html(value.recommendation).text());
73 $tbody.append($tr = $('<tr class="linkElem noclick"><td>' +
74 value.issue + '</td><td>' + rc_stripped + ' </td></tr>'));
76 $tr.data('rule', value);
78 $tr.click(function () {
79 var rule = $(this).data('rule');
81 .dialog({title: PMA_messages.strRuleDetails})
83 '<p><b>' + PMA_messages.strIssuse + ':</b><br />' + rule.issue + '</p>' +
84 '<p><b>' + PMA_messages.strRecommendation + ':</b><br />' + rule.recommendation + '</p>' +
85 '<p><b>' + PMA_messages.strJustification + ':</b><br />' + rule.justification + '</p>' +
86 '<p><b>' + PMA_messages.strFormula + ':</b><br />' + rule.formula + '</p>' +
87 '<p><b>' + PMA_messages.strTest + ':</b><br />' + rule.test + '</p>'
91 dlgBtns[PMA_messages.strClose] = function () {
92 $(this).dialog('close');
95 $dialog.dialog({ width: 600, buttons: dlgBtns });