D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
htdocs
/
modules
/
site-import
/
scripts
/
popup
/
Filename :
issues.js
back
Copy
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved. // Show popup dialog with site migration issues for an object (application/database/folder/mail address pair) // Arguments: // - title: popup dialog title // - issues - array of objects, each object describes an issue and contains problem text, solution text, etc, function showIssuesPopupDialog(title, issues) { var popupContent = ''; popupContent += '<div>'; function composeIssueHtml(issue) { var image = migratorImage('status-success.png'); if (issue.severity == issueSeverity.ERROR) { image = migratorImage('status-error.png'); } else if (issue.severity == issueSeverity.WARNING) { image = migratorImage('status-warning.png'); } var html = ''; html += '<div>'; html += '<img src="' + image.escapeHTML() + '" style="width: 16px;">'; html += ' '; html += formatStr(issue['problem_text']); if (issue['details_text']) { html += ' '; html += '<a href="javascript:;" class="site-migration-issue-show-details">'; html += ('[' + migratorLocale.lmsg('siteMigrationShowDetails') + ']').escapeHTML(); html += '</a>'; html += '<a href="javascript:;" class="site-migration-issue-hide-details" style="display: none;">'; html += ('[' + migratorLocale.lmsg('siteMigrationHideDetails') + ']').escapeHTML(); html += '</a>'; html += '<div class="site-migration-issue-details" style="display: none;">'; html += formatStr(issue['details_text']); html += '</div>'; } html += '</div>'; return html; } function configureShowHideButtons() { $$('.site-migration-issue-show-details').each(function(element) { element.observe('click', function() { var rootElem = element.up(0); toggleChildElement(rootElem, 'site-migration-issue-hide-details', true); toggleChildElement(rootElem, 'site-migration-issue-details', true); element.hide(); }); }); $$('.site-migration-issue-hide-details').each(function(element) { element.observe('click', function() { var rootElem = element.up(0); toggleChildElement(rootElem, 'site-migration-issue-show-details', true); toggleChildElement(rootElem, 'site-migration-issue-details', false); element.hide(); }); }); } if (issues.length > 0) { // Step #1: Group issues by date var groupedIssues = {}; issues.each(function(issue) { var date = issue['execution_date']; if (!groupedIssues[date]) { groupedIssues[date] = []; } groupedIssues[date].push(issue); }); // Step #2: Order issue dates for further iteration var executionDates = Object.keys(groupedIssues); executionDates.sort(); executionDates.reverse(); // Step #3: Iterate over dates and issues, composing the popup contents executionDates.forEach(function(date) { var issuesOfDate = groupedIssues[date]; popupContent += ( '<h4>' + formatDateFromTimestamp(date).escapeHTML() + '</h4><hr/>' ); issuesOfDate.each(function(issue) { popupContent += composeIssueHtml(issue); if ( // not the last issue in the dialog, to avoid duplication of <hr/> which is // displayed by popup itself !( date == executionDates[executionDates.length - 1] && issue == issuesOfDate[issuesOfDate.length - 1] ) ) { popupContent += '<hr/>'; } }); }); } else { popupContent += migratorLocale.lmsg('siteMigrationPopupIssuesNoIssues').escapeHTML(); } popupContent += '</div>'; var popup = new Jsw.Popup({ title: title.escapeHTML(), content: popupContent, buttons: [ { title: migratorLocale.lmsg('siteMigrationPopupIssuesButtonOk'), class: 'action', handler: function(event, popup) { popup.hide(); } } ], popupCls: 'popup-panel popup-panel-xl popup-panel-centered' }); popup.show(); configureShowHideButtons(); }