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"]').off('click');
13 $('#statustabs_advisor').html('');
14 $('#advisorDialog').remove();
15 $('#instructionsDialog').remove();
18 AJAX.registerOnload('server_status_advisor.js', function () {
19 // if no advisor is loaded
20 if ($('#advisorData').length === 0) {
24 /** ** Server config advisor ****/
25 var $dialog = $('<div />').attr('id', 'advisorDialog');
26 var $instructionsDialog = $('<div />')
27 .attr('id', 'instructionsDialog')
28 .html($('#advisorInstructionsDialog').html());
30 $('a[href="#openAdvisorInstructions"]').click(function () {
32 dlgBtns[PMA_messages.strClose] = function () {
33 $(this).dialog('close');
35 $instructionsDialog.dialog({
36 title: PMA_messages.strAdvisorSystem,
42 var $cnt = $('#statustabs_advisor');
48 data = JSON.parse($('#advisorData').text());
51 if (data.parse.errors.length > 0) {
52 $cnt.append('<b>Rules file not well formed, following errors were found:</b><br />- ');
53 $cnt.append(data.parse.errors.join('<br/>- '));
54 $cnt.append('<p></p>');
57 if (data.run.errors.length > 0) {
58 $cnt.append('<b>Errors occurred while executing rule expressions:</b><br />- ');
59 $cnt.append(data.run.errors.join('<br/>- '));
60 $cnt.append('<p></p>');
63 if (data.run.fired.length > 0) {
64 $cnt.append('<p><b>' + PMA_messages.strPerformanceIssues + '</b></p>');
65 $cnt.append('<table class="data" id="rulesFired" border="0"><thead><tr>' +
66 '<th>' + PMA_messages.strIssuse + '</th><th>' + PMA_messages.strRecommendation +
67 '</th></tr></thead><tbody></tbody></table>');
68 $tbody = $cnt.find('table#rulesFired');
72 $.each(data.run.fired, function (key, value) {
73 // recommendation may contain links, don't show those in overview table (clicking on them redirects the user)
74 rc_stripped = $.trim($('<div>').html(value.recommendation).text());
75 $tbody.append($tr = $('<tr class="linkElem noclick"><td>' +
76 value.issue + '</td><td>' + rc_stripped + ' </td></tr>'));
78 $tr.data('rule', value);
80 $tr.click(function () {
81 var rule = $(this).data('rule');
83 .dialog({ title: PMA_messages.strRuleDetails })
85 '<p><b>' + PMA_messages.strIssuse + ':</b><br />' + rule.issue + '</p>' +
86 '<p><b>' + PMA_messages.strRecommendation + ':</b><br />' + rule.recommendation + '</p>' +
87 '<p><b>' + PMA_messages.strJustification + ':</b><br />' + rule.justification + '</p>' +
88 '<p><b>' + PMA_messages.strFormula + ':</b><br />' + rule.formula + '</p>' +
89 '<p><b>' + PMA_messages.strTest + ':</b><br />' + rule.test + '</p>'
93 dlgBtns[PMA_messages.strClose] = function () {
94 $(this).dialog('close');
97 $dialog.dialog({ width: 600, buttons: dlgBtns });