This commit is contained in:
cutemeli
2025-12-22 10:35:30 +00:00
parent 0bfc6c8425
commit 5ce7ca2c5d
38927 changed files with 0 additions and 4594700 deletions

View File

@@ -1,238 +0,0 @@
// Copyright 1999-2024. WebPros International GmbH. All rights reserved.
const PanelMigrator = {};
function formatMessage()
{
var result = arguments[0];
for (var i = 1; i < arguments.length; i++) {
result = result.replace("%" + i, arguments[i]);
}
return result;
}
// Convert newlines to HTML line breaks (<br/> tag)
function nl2br(str)
{
return str.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br/>$2');
}
function formatStr(str)
{
return nl2br(str.escapeHTML());
}
// Get URL to migrator's image (from htdocs/images directory) specified by image filename,
// which could be used in "src" attribute of <img> tag.
function migratorImage(image)
{
return "/modules/panel-migrator/images/" + image;
}
// Shortcut to set on click handler for child elements of specified root element matching specified CSS class.
function observeClickOnChildElement(rootElement, childClass, callback)
{
rootElement.select('.' + childClass).each(function(childElement) {
childElement.observe('click', callback);
});
}
// Shortcut to toggle (show/hide) child elements of specified root element matching specified CSS class.
function toggleChildElement(rootElement, childClass, isToggle)
{
rootElement.select('.' + childClass).each(function(childElement) {
childElement.toggle(isToggle);
});
}
// Shortcut to get text content of a child element
function getChildElementText(rootElement, childClass)
{
var result = null;
rootElement.select('.' + childClass).each(function(childElement) {
result = childElement.textContent;
});
return result;
}
// Count items in an array which conform to some condition.
function countItems(object, conditionFunction)
{
var result = 0;
for (var key in object) {
if (object.hasOwnProperty(key)) {
if (conditionFunction(key, object[key])) {
result += 1;
}
}
}
return result;
}
// Check if array contains an element conforming some condition.
// Condition is specified by function, which should accept one argument - item from the array,
// and return true if item conforms to the condition, false otherwise.
function containsElement(array, conditionFunction)
{
for (var i = 0; i < array.length; i++) {
if (conditionFunction(array[i])) {
return true;
}
}
return false;
}
// Shortcut to check if item is in array
function inArray(item, array)
{
return array.indexOf(item) >= 0;
}
// Get property recursively by list of property names
// For example, if we have object
// o = {'a': {'b': {'c': 'd', 'e': 'f'}}}
// the function call
// getPropertyChain(o, ['a', 'b', 'c'])
// will return
// 'd'
// Also, default value could be specified - if any of the properties in the chain is not found,
// the default value is returned
function getPropertyChain(object, propertiesList, defaultValue)
{
var item = object;
for (var i = 0; i < propertiesList.length; i++) {
var propertyName = propertiesList[i];
if (item.hasOwnProperty(propertyName)) {
item = item[propertyName];
} else {
return defaultValue;
}
}
return item;
}
// Show only one element from specified list, hide all the others
function showOnly(allElements, elementToShow)
{
for (var i = 0; i < allElements.length; i++) {
var element = allElements[i];
if (element === elementToShow) {
element.show();
} else {
element.hide();
}
}
}
// Simple comparison function to compare properties of 2 objects
function objectsEqual(obj1, obj2) {
if (obj1 === obj2) {
return true;
}
if (!(obj1 instanceof Object) || !(obj2 instanceof Object)) {
return false;
}
for (var key1 in obj1) {
if (obj1.hasOwnProperty(key1)) {
if (!obj2.hasOwnProperty(key1)) {
return false;
}
if (!objectsEqual(obj1[key1], obj2[key1])) {
return false;
}
}
}
for (var key2 in obj2) {
if (obj2.hasOwnProperty(key2)) {
if (!obj1.hasOwnProperty(key2)) {
return false;
}
if (!objectsEqual(obj1[key2], obj2[key2])) {
return false;
}
}
}
return true;
}
// Disable button and show spinner that operation is in progress
function disableButtonInProgress(button, progressLocaleKey)
{
disableButtonPlain(button);
button.update('<span class="wait">' + migratorLocale.lmsg(progressLocaleKey) + '</span>')
}
// Disable button
function disableButtonPlain(button)
{
button.disabled = true;
button.up().addClassName('disabled');
}
// Common enumerations
var issueSeverity = {
ERROR: 'error',
WARNING: 'warning'
};
var statuses = {
FINISHED_OK: 'finished-ok',
FINISHED_ERRORS: 'finished-errors',
FINISHED_WARNINGS: 'finished-warnings',
ON_HOLD: 'on-hold',
IN_PROGRESS: 'in-progress',
CANCELLED: 'cancelled',
NOT_STARTED: 'not-started'
};
Jsw.onReady(function() {
var lastKeys = [];
var pass = 'pleskmigratoriddqd';
Event.observe(document, 'keypress', function(event) {
var key = event.key;
lastKeys.push(key);
if (lastKeys.length > pass.length) {
lastKeys.shift();
}
if (lastKeys.length == pass.length) {
if (pass == lastKeys.join('')) {
new Ajax.Request('/modules/panel-migrator/index.php/index/toggle-advanced-mode', {
onSuccess: function (response) {
window.location.reload(true);
}
});
}
}
});
});
PanelMigrator.initAppState = function () {
const state = { mounted: true };
const pathChangeObserver = PanelMigrator.observePathChange(() => {
state.mounted = false;
pathChangeObserver.disconnect();
});
return state;
}
PanelMigrator.observePathChange = function (callback) {
let oldPathname = document.location.pathname;
const body = document.querySelector('body');
const observer = new MutationObserver(() => {
if (oldPathname !== document.location.pathname) {
oldPathname = document.location.pathname;
callback();
}
});
observer.observe(body, { childList: true, subtree: true });
return observer;
};

View File

@@ -1,25 +0,0 @@
function formatDateFromTimestamp(timestamp)
{
var date = new Date();
date.setTime(timestamp * 1000);
var year = date.getFullYear();
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var month = months[date.getMonth()];
var day = date.getDate();
var hour = padZero(date.getHours());
var min = padZero(date.getMinutes());
var sec = padZero(date.getSeconds());
return day + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
}
function padZero(value)
{
if (value < 10) {
return "0" + value;
} else {
return value;
}
}

View File

@@ -1,33 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
function finishMigration(sessionId) {
new Ajax.Request(URL_GET_SUBSCRIPTIONS_IN_QUEUE_COUNT + '/session/' + sessionId, {
onSuccess: function (response) {
var subscriptionsInQueue = response.responseText.evalJSON();
var messageBoxParams = {
'type': Jsw.messageBox.TYPE_YESNO,
'subtype': 'delete',
'text': MESSAGE_FINISH_MIGRATION_CONFIRMATION,
'onYesClick': function () {
Jsw.redirectPost(URL_REMOVE_SESSION, {
session: sessionId
});
},
'buttonTitles': {
'yes': MESSAGE_FINISH_MIGRATION_YES,
'no': MESSAGE_FINISH_MIGRATION_NO
}
};
if (subscriptionsInQueue > 0) {
messageBoxParams.needAttention = true;
messageBoxParams.needAttentionText = formatMessage(
MESSAGE_FINISH_MIGRATION_STOP_TASKS, subscriptionsInQueue
);
messageBoxParams.needAttentionBlockSubmit = true;
}
Jsw.messageBox.show(messageBoxParams);
}
});
}

View File

@@ -1,47 +0,0 @@
function configureFormSubmitPopup() {
// Hack to make popup after form is submitted and processed at controller side:
// redefine _onSuccess function, which will display popup and call the original _onSuccess
// function.
var formComponent = Jsw.getComponent('select-objects-to-migrate-form');
var oldFunction = formComponent._onSuccess;
formComponent._onSuccess = function(req) {
var response = req.responseText.evalJSON();
var result = oldFunction.apply(this, arguments);
var taskId = response.task;
if (taskId) {
// If pre-migration checks were started - show popup with progress
showPreChecksPopup(taskId, true, false);
}
return result;
}
}
// Configure handling of "Show existing subscriptions" checkbox for all modes of selection (by subscription,
// by customer, by reseller, by plan)
function configureToggleExistingSubscriptions() {
var showExistingSubscriptionElement = $('show-existing-subscriptions');
function toggleExistingSubscriptions() {
var listComponentIds = [
'subscriptionList',
'customerList',
'resellerList',
'planList'
];
listComponentIds.forEach(function (listComponentId) {
var listComponent = Jsw.getComponent(listComponentId);
if (showExistingSubscriptionElement.checked) {
listComponent.filterItems(null);
} else {
listComponent.filterItems(function (item) {
return !item.alreadyExists;
});
}
});
}
toggleExistingSubscriptions();
showExistingSubscriptionElement.observe('click', toggleExistingSubscriptions);
}

View File

@@ -1,35 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
migratorLocale = {
_data: {},
// Format locale message. Arguments:
// - key - string key of locale message, check keys at "resources/locales/en-US.php"
// - args - optional argument - dictionary with arguments to be substituted
lmsg: function(key, args) {
var message = this._data[key];
if (!message) {
return key;
}
if (args) {
for (var argKey in args) {
if (args.hasOwnProperty(argKey)) {
message = message.replace('%%' + argKey + '%%', args[argKey]);
}
}
}
return message;
},
// Add new locale messages.
// Should be called when constructing page (in view script - views/*.phtml)
// which uses these locale messages from JavaScript.
addKeys: function(keys) {
var self = this;
Object.keys(keys).forEach(function(key) {
self._data[key] = keys[key];
});
}
};

View File

@@ -1,18 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Extension over lookup control, with ability to enable and disable it
Jsw.LookUpExtended = Class.create(Jsw.LookUp, {
'disable': function() {
this._inputField.disable();
this._inputField.stopObserving('focus');
this._inputField.stopObserving('paste');
this._inputField.stopObserving('blur');
this._inputField.stopObserving('keyup');
this._inputField.stopObserving('keydown');
this._lookUpButton.stopObserving('click');
},
'enable': function() {
this._inputField.enable();
this._addEvents(function() {});
}
});

View File

@@ -1,436 +0,0 @@
// Copyright 1999-2024. WebPros International GmbH. All rights reserved.
Jsw.onReady(function() {
const appState = PanelMigrator.initAppState();
// Global variable representing current status of migration. Updated periodically with AJAX request.
var statusData = MIGRATION_STATUS_DATA;
// Run specified function for each customer in results column (from raw migration list)
// callback - function that receives 2 arguments: customer login as string and status item HTML element
function foreachResultCustomer(callback) {
$$('.customerStatus').each(function(element) {
var customerLogin = element.select(".customerLogin")[0].textContent.strip();
callback(customerLogin, element);
});
}
// Run specified function for each reseller in results column (from raw migration list)
// callback - function that receives 2 arguments: reseller login as string and status item HTML element
function foreachResultReseller(callback) {
$$('.resellerStatus').each(function(element) {
var resellerLogin = element.select(".resellerLogin")[0].textContent.strip();
callback(resellerLogin, element);
});
}
// Run specified function for each subscription in results column (from raw migration list)
// callback - function that receives 2 arguments: subscription name as string and status item HTML element
function foreachResultSubscription(callback) {
$$('.subscription-finished').each(function (element) {
var subscriptionName = element.select(".subscription-name")[0].textContent.strip();
callback(subscriptionName, element)
});
}
// Run specified function for each subscription in queue column (from raw migration list)
// callback - function that receives 2 arguments: subscription name as string and queue item HTML element
function foreachQueueSubscription(callback) {
$$('.subscription-in-progress').each(function (element) {
var subscriptionName = element.select(".subscription-name")[0].textContent.strip();
callback(subscriptionName, element);
});
}
// Run specified function for overall result
// callback - function that receives 1 argument: overall item HTML element
function forResultOverall(callback) {
var overallElement = $$('.overallStatus')[0];
callback(overallElement);
}
function forResultServerSettings(callback) {
var serverElement = $('migration-status-block-results-server-settings');
callback(serverElement);
}
// Root update function: called once we get new data about migration status with AJAX request
function updateMigrationStatus()
{
updateQueue();
updatePreChecks();
updateResults();
}
// Update left column: migration queue
function updateQueue()
{
updateQueueOverallAction();
updateQueueCount();
updateQueueSubscriptions();
}
// Update right column: migration results
function updateResults()
{
updateResultsSubscription();
updateResultsServerSettings();
updateResultsReseller();
updateResultsCustomer();
updateResultsOverall();
updateSubscriptionCounts();
}
// Update overall action - action executed on all subscriptions
function updateQueueOverallAction()
{
if (statusData.overall.action) {
$('overall-status-text').textContent = getPropertyChain(statusData, ['overall', 'action'], '');
$('overall-status').show();
} else {
$('overall-status').hide();
}
}
// Update number of subscriptions in queue
function updateQueueCount()
{
$('queue-count').textContent = countItems(
getPropertyChain(statusData, ['subscriptions'], []), function(_, subscription) {
return inArray(subscription.status, [statuses.IN_PROGRESS, statuses.ON_HOLD])
}
);
}
function updatePreChecks()
{
var preCheckTasksCount = 0;
$$('.migration-status-pre-check-task').each(function(element) {
var taskId = getChildElementText(element, 'task-id');
var taskStatus = getPropertyChain(statusData, ['preCheckTasks', taskId, 'status'], null);
if (taskStatus == 'not-started' || taskStatus == 'pre-checks-completed') {
var link = element.select('a').first();
link.stopObserving('click');
link.observe('click', function() {
showPreChecksPopup(taskId, false);
});
element.show();
preCheckTasksCount++;
} else {
element.hide();
}
});
$('migration-status-block-pre-checks').toggle(preCheckTasksCount > 0);
}
// Update status of each subscription in queue
function updateQueueSubscriptions()
{
foreachQueueSubscription(function(subscriptionName, element) {
var subscriptionStatus = getPropertyChain(
statusData, ['subscriptions', subscriptionName, 'status'], statuses.NOT_STARTED
);
var action = getPropertyChain(
statusData, ['subscriptions', subscriptionName, 'action'], ''
);
var details = getPropertyChain(
statusData, ['subscriptions', subscriptionName, 'details'], ''
);
toggleChildElement(
element, 'image-status-in-progress', subscriptionStatus == statuses.IN_PROGRESS
);
toggleChildElement(
element, 'image-status-on-hold', subscriptionStatus == statuses.ON_HOLD
);
element.toggle(inArray(subscriptionStatus, [statuses.IN_PROGRESS, statuses.ON_HOLD]));
var statusTextElement = element.select(".status-text")[0];
var detailsTextElement = element.select(".details-text")[0];
var detailsTextContainer = element.select(".details-text-container")[0];
var showAction = (
action &&
// Show action text only if subscription is "In progress". There could be situation when
// progress file (which contains action) and subscription status files (which contains status)
// are not in sync. For example, we need such check to avoid display actions for
// subscriptions marked as "On hold".
subscriptionStatus == statuses.IN_PROGRESS
);
if (showAction) {
statusTextElement.textContent = action;
if (detailsTextElement && detailsTextContainer) {
detailsTextElement.textContent = details;
if (details) {
detailsTextContainer.show();
} else {
detailsTextContainer.hide();
}
}
} else {
statusTextElement.textContent = '';
if (detailsTextElement && detailsTextContainer) {
detailsTextElement.textContent = '';
detailsTextContainer.hide();
}
}
toggleChildElement(element, 'status-separator', showAction);
toggleChildElement(element, 'status-text', showAction);
updateSubscriptionNameColumn(element);
});
}
// Update migration results for subscriptions
function updateResultsSubscription()
{
var hasSubscriptionsDisplayed = false;
foreachResultSubscription(function(subscriptionName, element) {
var issues = getPropertyChain(
statusData, ['subscriptionIssues', subscriptionName], []
);
var status = getPropertyChain(
statusData, ['subscriptions', subscriptionName, 'status'], statuses.NOT_STARTED
);
var isStatusFinished = inArray(
status, [statuses.FINISHED_OK, statuses.FINISHED_WARNINGS, statuses.FINISHED_ERRORS]
);
var isStatusQueued = inArray(
status, [statuses.IN_PROGRESS, statuses.ON_HOLD]
);
// Show subscription in 2 cases:
// 1) There are issues for that subscription (even if migration is still running).
// 2) Migration of the subscription finished.
if (issues.length > 0 || isStatusFinished) {
// Show status of the last operation for subscription, if available - otherwise detect by issues
if (isStatusFinished) {
updateStatusImageByStatus(element, status);
} else {
updateStatusImageByIssues(element, issues)
}
toggleChildElement(
element, 'action-resync',
(
!isStatusQueued &&
status != statuses.NOT_STARTED &&
status != statuses.CANCELLED
)
);
element.show();
hasSubscriptionsDisplayed = true;
} else {
element.hide();
}
updateSubscriptionNameColumn(element);
});
$('migration-status-block-results-subscription').toggle(hasSubscriptionsDisplayed);
}
// Update migration results for resellers
function updateResultsReseller()
{
var hasResellerWithIssues = false;
foreachResultReseller(function(resellerLogin, element) {
var issues = getPropertyChain(statusData, ['resellerIssues', resellerLogin], []);
element.toggle(issues.length > 0);
hasResellerWithIssues = hasResellerWithIssues || issues.length > 0;
});
$('migration-status-block-results-reseller').toggle(hasResellerWithIssues);
}
// Update migration results for customer
function updateResultsCustomer()
{
var hasCustomerWithIssues = false;
foreachResultCustomer(function(customerLogin, element) {
var issues = getPropertyChain(statusData, ['customerIssues', customerLogin], []);
element.toggle(issues.length > 0);
hasCustomerWithIssues = hasCustomerWithIssues || issues.length > 0;
});
$('migration-status-block-results-customer').toggle(hasCustomerWithIssues);
}
// Update overall migration results
function updateResultsOverall()
{
forResultOverall(function(element) {
var issues = getPropertyChain(statusData, ['overallIssues'], []);
$('migration-status-block-results-overall').toggle(issues.length > 0);
});
}
// Update server configuration migration results
function updateResultsServerSettings()
{
forResultServerSettings(function(element) {
let migrationStatuses = getPropertyChain(statusData, ['serverSettingsStatuses'], null);
let configurationResult = $('migration-status-block-results-server-configuration');
let extensionResult = $('migration-status-block-results-extensions');
let configurationStatus = migrationStatuses.configuration;
let extensionStatus = migrationStatuses.extensions;
configurationResult.toggle(showBlock(configurationStatus));
updateStatusImageByStatus(configurationResult, configurationStatus);
extensionResult.toggle(showBlock(extensionStatus));
updateStatusImageByStatus(extensionResult, extensionStatus);
element.toggle(showBlock(configurationStatus) || showBlock(extensionStatus));
function showBlock(status) {
return inArray(status, [statuses.FINISHED_ERRORS, statuses.FINISHED_OK, statuses.FINISHED_WARNINGS])
}
});
}
// Update counts of successful/failed subscriptions
function updateSubscriptionCounts()
{
// update right column: list of finished subscriptions
const statusCounts = [
{ status: statuses.FINISHED_OK, elementId: 'success-count' },
{ status: statuses.FINISHED_ERRORS, elementId: 'failed-count' },
{ status: statuses.FINISHED_WARNINGS, elementId: 'warning-count' }
];
statusCounts.forEach(({ status, elementId}) => {
const count = countItems(
statusData.subscriptions, function(_, subscription) {
return subscription.status === status;
}
);
const element = $(elementId);
element.textContent = count
element.parentNode.toggle(count > 0);
});
}
// Update migration status periodically with AJAX
function periodicUpdateMigrationStatus() {
if (!appState.mounted) return;
new Ajax.Request(URL_GET_MIGRATION_STATUS, {
onSuccess: function (response) {
if (!appState.mounted) return;
statusData = response.responseText.evalJSON();
updateMigrationStatus();
},
onComplete: function() {
setTimeout(function() {periodicUpdateMigrationStatus()}, 2000);
}
});
}
// Utility function to show proper icon according to migration status
function updateStatusImageByStatus(element, status)
{
toggleChildElement(element, 'image-status-success', status == statuses.FINISHED_OK);
toggleChildElement(element, 'image-status-warning', status == statuses.FINISHED_WARNINGS);
toggleChildElement(element, 'image-status-failure', status == statuses.FINISHED_ERRORS);
}
// Utility function to show proper icon according to issues list
function updateStatusImageByIssues(element, issues) {
var hasErrors = containsElement(issues, function(issue) { return issue.severity == issueSeverity.ERROR; });
var hasWarnings = containsElement(issues, function(issue) { return issue.severity == issueSeverity.WARNING; });
toggleChildElement(element, 'image-status-success', !hasErrors && !hasWarnings);
toggleChildElement(element, 'image-status-warning', !hasErrors && hasWarnings);
toggleChildElement(element, 'image-status-failure', hasErrors);
}
function assignControlHandlers() {
foreachResultSubscription(function(subscriptionName, element) {
observeClickOnChildElement(element, 'action-resync', function() {
showResyncPopup([subscriptionName], null, SHOW_SERVER_CONFIGURATION_BLOCK, SHOW_EXTENSIONS_SETTINGS_BLOCK);
});
});
foreachResultSubscription(function(subscriptionName, element) {
observeClickOnChildElement(element, 'action-details', function() {
var issues = getPropertyChain(
statusData, ['subscriptionIssues', subscriptionName], []
);
showIssuesPopupDialog(
migratorLocale.lmsg('issuesPopupTitleSubscription', {'subscription': subscriptionName}),
issues
);
});
});
foreachResultReseller(function(resellerLogin, element) {
observeClickOnChildElement(element, 'action-details', function() {
var issues = getPropertyChain(statusData, ['resellerIssues', resellerLogin], []);
showIssuesPopupDialog(
migratorLocale.lmsg('issuesPopupTitleReseller', {'reseller': resellerLogin}),
issues
);
});
});
foreachResultCustomer(function(customerLogin, element) {
observeClickOnChildElement(element, 'action-details', function() {
var issues = getPropertyChain(statusData, ['customerIssues', customerLogin], []);
showIssuesPopupDialog(
migratorLocale.lmsg('issuesPopupTitleCustomer', {'customer': customerLogin}),
issues
);
});
});
forResultOverall(function(element) {
observeClickOnChildElement(element, 'action-details', function() {
var issues = getPropertyChain(statusData, ['overallIssues'], []);
showIssuesPopupDialog(
migratorLocale.lmsg('issuesPopupTitleOverall'),
issues
);
});
});
forResultServerSettings(function(element) {
let configurationResult = element.select('#migration-status-block-results-server-configuration').first();
let extensionResult = element.select('#migration-status-block-results-extensions').first();
observeClickOnChildElement(configurationResult, 'action-details', function() {
let issues = getPropertyChain(statusData, ['serverSettingIssues'], []);
showIssuesPopupDialog(
migratorLocale.lmsg('issuesPopupTitleServerConfiguration'),
issues.Configuration || []
);
});
observeClickOnChildElement(extensionResult, 'action-details', function() {
let issues = getPropertyChain(statusData, ['serverSettingIssues'], []);
showIssuesPopupDialog(
migratorLocale.lmsg('issuesPopupTitleExtensions'),
issues.Extensions || []
);
});
});
}
// Update subscription name column - show link to subscription overview page if subscription
// exists in Plesk
function updateSubscriptionNameColumn(element)
{
var subscriptionNameNormalized = getChildElementText(element, 'subscription-name-normalized').strip();
var pleskSubscriptionUrl = getPropertyChain(
statusData, ['pleskSubscriptionUrls', subscriptionNameNormalized], null
);
var linkExists = pleskSubscriptionUrl !== null;
toggleChildElement(element, 'subscription-name-plain', !linkExists);
toggleChildElement(element, 'subscription-name-link', linkExists);
if (pleskSubscriptionUrl) {
var link = element.select('.subscription-name-link').first().select('a').first();
link.writeAttribute('href', pleskSubscriptionUrl);
}
}
// Perform initial update from data passed in HTML
updateMigrationStatus();
// Schedule run periodic updates with AJAX
periodicUpdateMigrationStatus();
// Assign handlers to various action buttons
assignControlHandlers();
});

View File

@@ -1,88 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
Jsw.MigratorDoubleListSelector = Class.create(Jsw.EnhancedDoubleListSelector, {
// overridden to have description of element under title, as we have in non-enhanced double list selector
// that is necessary to show subscriptions that already exist on the target host (were already migrated before)
_getItemText: function($super, element, highlight) {
var result = $super(element, highlight);
if (element.description) {
result += '<div style="color: grey;">' + element.description + '</div>';
}
return result;
},
filterItems: function(filterFunction) {
this._filterFunction = filterFunction;
var searchElement = $(this._id + '-search-unselected');
this.onToggleSearch('unselected', searchElement.value);
},
// overridden for ability to hide/show already migrated subscriptions (customers/resellers/plans with
// all migrated subscriptions)
onToggleSearch: function(columnId, searchString) {
searchString = searchString.strip().toLowerCase();
if (searchString.length) {
this._toggleSearchButtonIcon(columnId, true);
this._showSearchItems(columnId, searchString);
} else {
this._toggleSearchButtonIcon(columnId, false);
this._showAllItems(columnId);
}
},
_showSearchItems: function(columnId, searchString) {
var isSelected = (columnId === 'selected');
var self = this;
this._list.each(function(element, index) {
var item = $(this._id + '-' + index + '-' + columnId + '-item');
if (
this._isSearchMatched(element, searchString) &&
// overridden here: check if we want to show that element
(
isSelected || // always show items from the right column
!self._filterFunction || // filter function not set - show all items
self._filterFunction(element) // filter function is set - check if we should show the element
)
) {
item.down('.edls-text').update(this._getItemText(element, searchString));
if (isSelected === element.selected) {
item.show();
}
} else {
item.down('.edls-text').update(this._getItemText(element));
var checkbox = item.down('.edls-check input');
if (item.visible() && checkbox.checked) {
this._toggleItemCheckbox(checkbox, false);
}
item.hide();
}
}, this);
},
// overridden for ability to hide/show already migrated subscriptions (customers/resellers/plans with
// all migrated subscriptions)
_showAllItems: function(columnId) {
var isSelected = (columnId === 'selected');
var self = this;
this._list.each(function(element, index) {
var item = $(this._id + '-' + index + '-' + columnId + '-item');
item.down('.edls-text').update(this._getItemText(element));
if (
isSelected === element.selected &&
// overridden here: check if we want to show that element
(
isSelected || // always show items from the right column
!self._filterFunction || // filter function not set - show all items
self._filterFunction(element) // filter function is set - check if we should show the element
)
) {
item.show();
} else {
item.hide();
}
}, this);
}
});

View File

@@ -1,22 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
Jsw.onReady(function() {
var form = $('new-migration-form');
var hostingDescriptionFileRow = $('sourceServer-sourceHostingDescriptionFile-form-row');
function panelTypeChanged() {
var sourcePanel = $$('input:checked[type=radio][name="sourceServer[sourcePanelType]"]').first().value;
if (sourcePanel == 'custom') {
hostingDescriptionFileRow.show();
} else {
hostingDescriptionFileRow.hide();
}
}
panelTypeChanged();
$$('input[name="sourceServer[sourcePanelType]"]').each(function(elem) {
elem.observe('change', panelTypeChanged);
});
});

View File

@@ -1,28 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
Jsw.onReady(function() {
var radioRemoteSmarterMailAutomaticDeploy = $(
'remoteSmarterMailServer-targetRemoteSmarterMailRPCAgentDeployMode-automatic'
);
var radioRemoteSmarterMailManualDeploy = $(
'remoteSmarterMailServer-targetRemoteSmarterMailRPCAgentDeployMode-manual'
);
function updateRemoteSmarterMailRPCAgentDeployType()
{
if (radioRemoteSmarterMailAutomaticDeploy.checked) {
$('remoteSmarterMailServer-targetRemoteSmarterMailWindowsLogin-form-row').show();
$('remoteSmarterMailServer-targetRemoteSmarterMailWindowsPassword-form-row').show();
$('remoteSmarterMailServer-rpcAgentDownload-form-row').hide();
} else {
$('remoteSmarterMailServer-targetRemoteSmarterMailWindowsLogin-form-row').hide();
$('remoteSmarterMailServer-targetRemoteSmarterMailWindowsPassword-form-row').hide();
$('remoteSmarterMailServer-rpcAgentDownload-form-row').show();
}
}
radioRemoteSmarterMailAutomaticDeploy.observe('change', updateRemoteSmarterMailRPCAgentDeployType);
radioRemoteSmarterMailManualDeploy.observe('change', updateRemoteSmarterMailRPCAgentDeployType);
updateRemoteSmarterMailRPCAgentDeployType();
});

View File

@@ -1,22 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
Jsw.onReady(function() {
var radioSSHAuthPassword = $('sourceServer-sourceSSHAuthType-password');
var radioSSHAuthKey = $('sourceServer-sourceSSHAuthType-key');
function updateSSHAuthType()
{
if (radioSSHAuthPassword.checked) {
$('sourceServer-sourceSSHPassword-form-row').show();
$('sourceServer-sourceSSHKeyPath-form-row').hide();
} else {
$('sourceServer-sourceSSHPassword-form-row').hide();
$('sourceServer-sourceSSHKeyPath-form-row').show();
}
}
radioSSHAuthPassword.observe('change', updateSSHAuthType);
radioSSHAuthKey.observe('change', updateSSHAuthType);
updateSSHAuthType();
});

View File

@@ -1,53 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
Jsw.onReady(function() {
var radioAutomaticDeploy = $('sourceServer-sourceRPCAgentDeployMode-automatic');
var radioManualDeploy = $('sourceServer-sourceRPCAgentDeployMode-manual');
function updateRPCAgentDeployType()
{
if (radioAutomaticDeploy.checked) {
$('sourceServer-sourceWindowsLogin-form-row').show();
$('sourceServer-sourceWindowsPassword-form-row').show();
$('sourceServer-rpcAgentDownload-form-row').hide();
} else {
$('sourceServer-sourceWindowsLogin-form-row').hide();
$('sourceServer-sourceWindowsPassword-form-row').hide();
$('sourceServer-rpcAgentDownload-form-row').show();
}
}
// Special handling for Helm 3, for which we should specify login and password of Helm administrator Windows
// user (instead of built-in Windows administrator as we do it for all the other panels).
function panelTypeChanged() {
var elemInputLogin = $('sourceServer-sourceWindowsLogin');
var sourcePanel = $$('input:checked[type=radio][name="sourceServer[sourcePanelType]"]').first().value;
var elemLabelLogin = $$('label[for="sourceServer-sourceWindowsLogin"]').first().childNodes[0];
var elemLabelPassword = $$('label[for="sourceServer-sourceWindowsPassword"]').first().childNodes[0];
if (sourcePanel == 'helm3') {
if ('Administrator' == elemInputLogin.value) {
elemInputLogin.value = 'HELM_ADMIN';
}
elemLabelLogin.nodeValue = MESSAGE_LABEL_HELM_ADMIN_LOGIN + ' ';
elemLabelPassword.nodeValue = MESSAGE_LABEL_HELM_ADMIN_PASSWORD + ' ';
} else {
if ('HELM_ADMIN' == elemInputLogin.value) {
elemInputLogin.value = 'Administrator';
}
elemLabelLogin.nodeValue = MESSAGE_LABEL_BUILT_IN_ADMIN_LOGIN + ' ';
elemLabelPassword.nodeValue = MESSAGE_LABEL_BUILT_IN_ADMIN_PASSWORD + ' ';
}
}
radioAutomaticDeploy.observe('change', updateRPCAgentDeployType);
radioManualDeploy.observe('change', updateRPCAgentDeployType);
updateRPCAgentDeployType();
$$('input[name="sourceServer[sourcePanelType]"]').each(function(elem) {
elem.observe('change', panelTypeChanged);
});
});

View File

@@ -1,9 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
var overallStatus = {
NOT_STARTED: 'not-started',
FINISHED_OK: 'finished-ok',
FINISHED_WARNINGS: 'finished-warnings',
FINISHED_ERRORS: 'finished-errors',
IN_PROGRESS: 'in-progress'
};

View File

@@ -1,28 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with confirmation to cancel migration of subscriptions (remove them from queue).
// Arguments: subscriptions - list of subscription names.
// - onSuccess - function that will be called once cancel of these subscriptions is performed.
function showCancelPopup(subscriptions, onSuccess) {
Jsw.messageBox.show({
'type': Jsw.messageBox.TYPE_YESNO,
'subtype': 'delete',
'text': MESSAGE_POPUP_CANCEL_DESCRIPTION,
'onYesClick': function () {
new Ajax.Request(URL_CANCEL_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions)
},
onSuccess: function() {
if (onSuccess) {
onSuccess();
}
}
});
},
'buttonTitles': {
'yes': MESSAGE_POPUP_CANCEL_BUTTON_YES,
'no': MESSAGE_POPUP_CANCEL_BUTTON_NO
}
});
}

View File

@@ -1,41 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with confirmation to cancel all running migrations.
function showCancelAllPopup() {
// Hack to create dialog box, which does not immediately close dialog when "Yes" button is clicked
var CancelMessageBox = Class.create(
// take MessageBox class as superclass of AjaxMessageBox, because MessageBox class is not public since 17.8
Jsw.AjaxMessageBox.superclass,
{
_defaultOnButtonClick: function() {}
}
);
var messageBox = new CancelMessageBox({
'type': Jsw.messageBox.TYPE_YESNO,
'subtype': 'delete',
'text': migratorLocale.lmsg('popupCancelAllDescription'),
'onYesClick': function () {
this._componentElement.select('button').each(function(button) {
button.disabled = true;
button.up().addClassName('disabled');
});
this._componentElement.select('button').first().update(
'<span class="wait">' + migratorLocale.lmsg('popupCancelAllInProgress') + '</span>'
);
new Ajax.Request(URL_CANCEL, {
onSuccess: function() {
messageBox.hide();
}
});
},
'onNoClick': function () {
this.hide();
},
'buttonTitles': {
'yes': migratorLocale.lmsg('popupCancelAllButtonYes'),
'no': migratorLocale.lmsg('popupCancelAllButtonNo')
}
});
messageBox.show();
}

View File

@@ -1,174 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with settings to start migration.
// Arguments: subscriptions - list of subscription names.
function showChangeIPPopup(subscriptions, onSuccess) {
// compose title - it is different when one subscription is selected
// and when multiple subscriptions are selected
var title = '';
if (subscriptions.length > 1) {
title = formatMessage(MESSAGE_POPUP_CHANGE_IP_TITLE_MULTIPLE, subscriptions.length);
} else if (subscriptions.length == 1) {
title = formatMessage(MESSAGE_POPUP_CHANGE_IP_TITLE_SINGLE, subscriptions[0]);
} else {
// no subscriptions - no sense to show dialog
return;
}
new Ajax.Request(URL_LIST_IP_ADDRESSES, {
onSuccess: function (response) {
var ipAddresses = response.responseText.evalJSON();
function sectionTitle(title) {
return (
'<div class="title">' +
'<div class="title-area"><h3><span>' + title + '</span></h3></div>' +
'</div>'
);
}
function formRows(ipType) {
return (
'<div class="form-row">' +
'<div class="field-name">' + MESSAGE_POPUP_CHANGE_IP_MAP_TO + '</div>' +
'<div class="field-value">' +
'<div class="text-value">' +
'<div class="indent-box">' +
'<input type="radio" name="mappingType' + ipType + '" class="radio" id="mappingAuto' + ipType + '" value="auto" checked="checked"> ' +
'<label for="mappingAuto' + ipType + '">' +
MESSAGE_POPUP_CHANGE_IP_MAPPING_AUTO +
'</label>' +
'</div>' +
'<div class="indent-box">' +
'<input type="radio" name="mappingType' + ipType + '" class="radio" id="mappingShared' + ipType + '" value="shared"> ' +
'<label for="mappingShared' + ipType + '">' +
MESSAGE_POPUP_CHANGE_IP_MAPPING_SHARED +
'</label>' +
'</div>' +
'<div class="indent-box">' +
'<input type="radio" name="mappingType' + ipType + '" class="radio" id="mappingDedicated' + ipType + '" value="dedicated"> ' +
'<label for="mappingDedicated' + ipType + '">' +
MESSAGE_POPUP_CHANGE_IP_MAPPING_DEDICATED +
'</label>' +
'</div>' +
'<div class="indent-box">' +
'<input type="radio" name="mappingType' + ipType + '" class="radio" id="mappingSelected' + ipType + '" value="selected"> ' +
'<label for="mappingSelected' + ipType + '">' +
MESSAGE_POPUP_CHANGE_IP_MAPPING_SELECTED +
'</label>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="form-row">' +
'<div class="field-name">' + MESSAGE_POPUP_CHANGE_IP_MAP_TO_SELECTED + '</div>' +
'<div class="field-value">' +
'<div id="change-ip-' + ipType + '-input-container"></div>' +
'</div>' +
'</div>'
);
}
popupContent = '';
if (ipAddresses.v6.length > 0) {
popupContent += sectionTitle(MESSAGE_POPUP_CHANGE_IP_IPV4);
}
popupContent += formRows('v4');
if (ipAddresses.v6.length > 0) {
popupContent += sectionTitle(MESSAGE_POPUP_CHANGE_IP_IPV6);
popupContent += formRows('v6');
}
popupContent = '<div class="form-box">' + popupContent + '</div>';
var popup = new Jsw.Popup({
title: title,
content: popupContent,
buttons: [
{
id: 'changeIpOkButton',
title: MESSAGE_POPUP_CHANGE_IP_BUTTON_OK,
class: 'action',
handler: function (event, popup) {
function getValue(ipType) {
var value = $$('input:checked[type=radio][name=mappingType' + ipType + ']').first().value;
if (value == 'selected') {
value = $$('input[name="change-ip-' + ipType + '"]').first().value;
}
return value;
}
var parameters = {
subscriptions: Object.toJSON(subscriptions)
};
parameters.ipv4 = getValue('v4');
if (ipAddresses.v6.length > 0) {
parameters.ipv6 = getValue('v6');
}
disableButtonInProgress($('changeIpOkButton'), 'changingButtonTitle');
disableButtonPlain($('changeIpCancelButton'));
new Ajax.Request(URL_CHANGE_IP_SUBSCRIPTIONS, {
parameters: parameters,
onSuccess: function (response) {
if (onSuccess) {
onSuccess();
}
popup.hide();
}
});
}
},
{
id: 'changeIpCancelButton',
title: MESSAGE_POPUP_CHANGE_IP_BUTTON_CANCEL,
handler: function (event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered migrator-popup-reassign'
});
popup.show();
function addLookup(ipType, ipAddresses)
{
var ipLookupData = [];
for (var i = 0; i < ipAddresses.length; i++) {
var ip = ipAddresses[i];
ipLookupData.push({id: ip, title: ip});
}
var lookup = new Jsw.LookUpExtended({
id: 'change-ip-' + ipType,
name: 'change-ip-' + ipType,
renderTo: 'change-ip-' + ipType + '-input-container',
data: ipLookupData,
value: '',
locale: CHANGE_IP_LOCALE
});
function updateLookupStatus() {
if ($('mappingSelected' + ipType).checked) {
lookup.enable();
} else {
lookup.disable();
}
}
$$('input[name="mappingType' + ipType + '"]').each(function(element) {
element.observe('change', updateLookupStatus)
});
updateLookupStatus();
}
addLookup('v4', ipAddresses.v4);
if (ipAddresses.v6.length > 0) {
addLookup('v6', ipAddresses.v6);
}
}
});
}

View File

@@ -1,147 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
function showFetchSourcePopup(session, onFinishedSuccess, onCloseWithErrors) {
var errorMessage = null;
var errorId = null;
var cancel = false;
var popup = new Jsw.Popup({
title: 'Preparing migration',
content: (
'<div style="margin-bottom: 10px;">' +
'<div id="fetch-source-action-text">' +
migratorLocale.lmsg('fetchSourceStarting') +
'</div>' +
'<div id="fetch-source-error-text" style="display: none">' +
'</div>' +
'<div id="fetch-source-download-rpc-agent" style="margin-top: 15px; display: none;">' +
'<a href="' + URL_DOWNLOAD_RPC_AGENT + '">' +
migratorLocale.lmsg('downloadRpcAgent') +
'</a>' +
'</div>' +
'</div>' +
'<div class="migrator-progress-bar" id="fetch-source-progress-bar">' +
'<div class="migrator-progress-bar-wrap">' +
'<div style="width: 100%;" class="migrator-progress-bar-fill"><span></span></div>' +
'</div>' +
'</div>'
),
buttons: [
{
id: 'fetch-source-cancel-button',
title: migratorLocale.lmsg('fetchSourceButtonCancel'),
handler: function (event, popup) {
cancel = true;
elemActionText.show();
elemErrorText.hide();
elemErrorDownloadRpcAgent.hide();
elemProgressBar.show();
elemCancelButton.show();
elemCloseButton.hide();
elemActionText.update(migratorLocale.lmsg('fetchSourceCancelling'));
new Ajax.Request(URL_CANCEL_FETCH_SOURCE + '/session/' + session);
}
},
{
id: 'fetch-source-close-button',
title: migratorLocale.lmsg('fetchSourceButtonClose'),
handler: function (event, popup) {
popup.hide();
if (errorMessage && onCloseWithErrors) {
onCloseWithErrors(errorId, errorMessage);
}
}
}
],
popupCls: 'popup-panel popup-panel-centered'
});
popup.show();
var elemActionText = $('fetch-source-action-text');
var elemErrorText = $('fetch-source-error-text');
var elemErrorDownloadRpcAgent = $('fetch-source-download-rpc-agent');
var elemProgressBar = $('fetch-source-progress-bar');
var elemCancelButton = $('fetch-source-cancel-button').up();
var elemCloseButton = $('fetch-source-close-button').up();
elemCloseButton.hide();
function pollProgress() {
new Ajax.Request(URL_GET_PROGRESS + '/session/' + session, {
onSuccess: function (response) {
var progress = response.responseText.evalJSON();
if (
progress.status == overallStatus.FINISHED_OK ||
progress.status == overallStatus.FINISHED_WARNINGS
) {
if (cancel) {
cancel = false;
popup.hide();
return;
}
// Show that operation has finished and redirect to object selections screen
elemActionText.show();
elemErrorText.hide();
elemErrorDownloadRpcAgent.hide();
elemProgressBar.hide();
elemActionText.update(migratorLocale.lmsg('fetchSourceFinished'));
if (onFinishedSuccess) {
onFinishedSuccess();
}
} else if (
progress.status == overallStatus.FINISHED_ERRORS
) {
if (cancel) {
cancel = false;
popup.hide();
return;
}
// Show error message
elemActionText.hide();
elemErrorText.show();
if (progress.errorId && progress.errorId.indexOf('RPC_AGENT_') === 0) {
elemErrorDownloadRpcAgent.show();
} else {
elemErrorDownloadRpcAgent.hide();
}
elemProgressBar.hide();
elemCancelButton.hide();
elemCloseButton.show();
elemErrorText.update(formatStr(progress.errorMessage));
// Set error variables so they could be passed back to display error handler
errorMessage = progress.errorMessage;
errorId = progress.errorId;
} else { // Not started or in progress
// Update progress message if exists
if (!cancel) {
elemActionText.show();
elemErrorText.hide();
elemErrorDownloadRpcAgent.hide();
elemProgressBar.show();
elemCancelButton.show();
elemCloseButton.hide();
if (progress.action) {
elemActionText.update(formatStr(progress.action));
}
}
// Poll progress once more
setTimeout(pollProgress, FETCH_SOURCE_POLL_INTERVAL);
}
},
onFailure: function() {
setTimeout(pollProgress, FETCH_SOURCE_POLL_INTERVAL);
}
});
}
pollProgress();
}

View File

@@ -1,179 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with settings to start migration.
// Arguments:
// - subscriptions - list of subscription names.
// - onSuccess - function that will be called once migration of these subscriptions is scheduled.
function showMigratePopup(subscriptions, onSuccess, showServerConfigurationBlock, showExtensionsSettingsBlock) {
// compose title - it is different when one subscription is selected
// and when multiple subscriptions are selected
var title = '';
if (subscriptions.length > 1) {
title = formatMessage(MESSAGE_POPUP_MIGRATE_TITLE_MIGRATE_MULTIPLE, subscriptions.length);
} else if (subscriptions.length == 1) {
title = formatMessage(MESSAGE_POPUP_MIGRATE_TITLE_MIGRATE_SINGLE, subscriptions[0]);
} else {
// no subscriptions - no sense to show dialog
return;
}
function getServerSettingsBlock() {
let html = '';
if (showServerConfigurationBlock) {
html += (
'<div>' +
'<input type="checkbox" class="checkbox" id="copyMailSettings"> ' +
'<label for="copyMailSettings">' +
MESSAGE_POPUP_MIGRATE_COPY_MAIL_SETTINGS +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="copyAdminProfile"> ' +
'<label for="copyAdminProfile">' +
MESSAGE_POPUP_MIGRATE_COPY_ADMIN_PROFILE +
'</label>' +
'</div>'
)
}
if (showExtensionsSettingsBlock) {
html += (
'<div>' +
'<input type="checkbox" class="checkbox" id="copyExtensionsSettings"> ' +
'<label for="copyExtensionsSettings">' +
MESSAGE_POPUP_MIGRATE_COPY_EXTENSIONS_SETTINGS +
'</label>' +
'</div>'
);
}
if (html) {
html = (
'<div class="field-name">' + MESSAGE_POPUP_MIGRATE_SERVER_SETTINGS + '</div>' +
'<div class="field-value">' +
html +
'</div>' +
'<br />'
);
}
return html;
}
var popup = new Jsw.Popup({
title: title,
content: (
'<div class="form-row">' +
'<div class="field-name">' + MESSAGE_POPUP_MIGRATE_CONTENT + '</div>' +
'<div class="field-value">' +
'<div>' +
'<input type="checkbox" class="checkbox" id="copyFiles" checked="checked"> ' +
'<label for="copyFiles">' +
MESSAGE_POPUP_MIGRATE_COPY_FILES +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="copyDatabases" checked="checked"> ' +
'<label for="copyDatabases">' +
MESSAGE_POPUP_MIGRATE_COPY_DATABASES +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="copyMail" checked="checked"> ' +
'<label for="copyMail">' +
MESSAGE_POPUP_MIGRATE_COPY_MAIL +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="copyId" checked="checked"> ' +
'<label for="copyId">' +
MESSAGE_POPUP_MIGRATE_COPY_ID +
'</label>' +
'</div>' +
'</div>' +
'<br />' +
getServerSettingsBlock() +
'<div class="field-name">' + migratorLocale.lmsg('popupMigratePreChecks') + '</div>' +
'<div class="field-value">' +
'<input type="checkbox" class="checkbox" id="runPreChecks" checked="checked"> ' +
'</div>' +
'</div>'
),
buttons: [
{
id: 'migrateOkButton',
title: MESSAGE_POPUP_MIGRATE_BUTTON_OK,
class: 'action',
handler: function (event, popup) {
var elemCopyFiles = $('copyFiles');
var elemCopyDatabases = $('copyDatabases');
var elemCopyMail = $('copyMail');
var elemCopyId = $('copyId');
var elemMailSettings = $('copyMailSettings');
var elemExtensionsSettings = $('copyExtensionsSettings');
var elemAdminProfile = $('copyAdminProfile');
var elemRunPreChecks = $('runPreChecks');
disableButtonInProgress($('migrateOkButton'), 'schedulingButtonTitle');
disableButtonPlain($('migrateCancelButton'));
if (elemRunPreChecks.checked) {
// Run pre-migration checks
new Ajax.Request(URL_RUN_PRE_MIGRATION_CHECKS, {
parameters: {
subscriptions: Object.toJSON(subscriptions),
copyFiles: elemCopyFiles.checked,
copyDatabases: elemCopyDatabases.checked,
copyMail: elemCopyMail.checked,
copyId: elemCopyId.checked,
copyMailSettings: elemMailSettings ? elemMailSettings.checked : false,
copyExtensionsSettings: elemExtensionsSettings ? elemExtensionsSettings.checked : false,
copyAdminProfile: elemAdminProfile ? elemAdminProfile.checked : false,
},
onSuccess: function (response) {
var result = response.responseText.evalJSON();
if (onSuccess) {
onSuccess();
}
popup.hide();
showPreChecksPopup(result.task, true, true);
}
});
} else {
// Start migration immediately
new Ajax.Request(URL_MIGRATE_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions),
copyFiles: elemCopyFiles.checked,
copyDatabases: elemCopyDatabases.checked,
copyMail: elemCopyMail.checked,
copyId: elemCopyId.checked,
copyMailSettings: elemMailSettings ? elemMailSettings.checked : false,
copyExtensionsSettings: elemExtensionsSettings ? elemExtensionsSettings.checked : false,
copyAdminProfile: elemAdminProfile ? elemAdminProfile.checked : false,
},
onSuccess: function (response) {
if (onSuccess) {
onSuccess();
}
popup.hide();
}
});
}
}
},
{
id: 'migrateCancelButton',
title: MESSAGE_POPUP_MIGRATE_BUTTON_CANCEL,
handler: function (event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered'
});
popup.show();
}

View File

@@ -1,115 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with settings to start post-migration checks.
// Arguments:
// - subscriptions - list of subscription names.
// - onSuccess - function that will be called once post migration checks of these subscriptions is scheduled.
function showPostMigrationChecksPopup(subscriptions, onSuccess) {
// compose title - it is different when one subscription is selected
// and when multiple subscriptions are selected
var title = '';
if (subscriptions.length > 1) {
title = formatMessage(MESSAGE_POPUP_POST_MIGRATION_CHECKS_TITLE_MULTIPLE, subscriptions.length);
} else if (subscriptions.length == 1) {
title = formatMessage(MESSAGE_POPUP_POST_MIGRATION_CHECKS_TITLE_SINGLE, subscriptions[0]);
} else {
// no subscriptions - no sense to show dialog
return;
}
var popup = new Jsw.Popup({
title: title,
content: (
'<div class="form-row">' +
'<div class="field-name">' + MESSAGE_POPUP_POST_MIGRATION_CHECKS_WHAT + '</div>' +
'<div class="field-value">' +
'<div>' +
'<input type="checkbox" class="checkbox" id="testSites" checked="checked"> ' +
'<label for="testSites">' +
MESSAGE_POPUP_POST_MIGRATION_CHECKS_SITES +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="testMail" checked="checked"> ' +
'<label for="testMail">' +
MESSAGE_POPUP_POST_MIGRATION_CHECKS_MAIL +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="testDatabases" checked="checked"> ' +
'<label for="testDatabases">' +
MESSAGE_POPUP_POST_MIGRATION_CHECKS_DATABASES +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="testDNS" checked="checked"> ' +
'<label for="testDNS">' +
MESSAGE_POPUP_POST_MIGRATION_CHECKS_DNS +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="testUsers" checked="checked"> ' +
'<label for="testUsers">' +
MESSAGE_POPUP_POST_MIGRATION_CHECKS_USERS +
'</label>' +
'</div>' +
'</div>' +
'</div>'
),
buttons: [
{
id: 'postMigrationChecksOkButton',
title: MESSAGE_POPUP_POST_MIGRATION_CHECKS_BUTTON_OK,
class: 'action',
handler: function(event, popup) {
var elemTestSites = $('testSites');
var elemTestMail = $('testMail');
var elemTestDatabases = $('testDatabases');
var elemTestDNS = $('testDNS');
var elemTestUsers = $('testUsers');
if (
!elemTestSites.checked &&
!elemTestMail.checked &&
!elemTestDatabases.checked &&
!elemTestDNS.checked &&
!elemTestUsers.checked
) {
popup.hide();
return;
}
disableButtonInProgress($('postMigrationChecksOkButton'), 'schedulingButtonTitle');
disableButtonPlain($('postMigrationChecksCancelButton'));
new Ajax.Request(URL_POST_MIGRATION_CHECKS_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions),
testSites: elemTestSites.checked,
testMail: elemTestMail.checked,
testDatabases: elemTestDatabases.checked,
testDNS: elemTestDNS.checked,
testUsers: elemTestUsers.checked
},
onSuccess: function (response) {
if (onSuccess) {
onSuccess();
}
popup.hide();
}
});
}
},
{
id: 'postMigrationChecksCancelButton',
title: MESSAGE_POPUP_POST_MIGRATION_CHECKS_BUTTON_CANCEL,
handler: function(event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered'
});
popup.show();
}

View File

@@ -1,156 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
function showPreChecksPopup(taskId, proceedToMigrationIfNoIssues, redirectToListOfSubscriptions) {
var skipChecks = false;
var skipChecksFinished = false;
var successRedirectUrl = URL_MIGRATION_STATUS;
var redirectToListOfSubscriptionsVal = 'false';
if (redirectToListOfSubscriptions) {
successRedirectUrl = URL_LIST_OF_SUBSCRIPTIONS;
redirectToListOfSubscriptionsVal = 'true';
}
var popup = new Jsw.Popup({
title: migratorLocale.lmsg('preMigrationChecksTitle'),
content: (
'<div style="margin-bottom: 10px;">' +
'<span id="pre-checks-action-text">' +
migratorLocale.lmsg('preMigrationChecksStarting') +
'</span>' +
'<span id="pre-checks-error-text" style="display: none">' +
'</span>' +
'</div>' +
'<div class="migrator-progress-bar" id="pre-checks-progress-bar">' +
'<div class="migrator-progress-bar-wrap">' +
'<div style="width: 100%;" class="migrator-progress-bar-fill"><span></span></div>' +
'</div>' +
'</div>'
),
buttons: [
{
id: 'pre-check-skip-button',
title: migratorLocale.lmsg('preMigrationChecksSkipButton'),
handler: function (event, popup) {
skipChecks = true;
var skipButton = $('pre-check-skip-button');
var inBackgroundButton = $('pre-check-in-background');
skipButton.up().addClassName('disabled');
inBackgroundButton.up().addClassName('disabled');
skipButton.disabled = true;
inBackgroundButton.disabled = true;
skipButton.update(
'<span class="wait">' + migratorLocale.lmsg('waitButtonTitle') + '</span>'
);
elemActionText.update(migratorLocale.lmsg('preMigrationChecksCancelling'));
new Ajax.Request(URL_CANCEL_PRE_CHECKS + '/task/' + taskId, {
onSuccess: function() {
skipChecksFinished = true;
}
});
}
},
{
id: 'pre-check-in-background',
title: migratorLocale.lmsg('preMigrationChecksInBackgroud'),
handler: function(event, popup) {
var skipButton = $('pre-check-skip-button');
var inBackgroundButton = $('pre-check-in-background');
skipButton.up().addClassName('disabled');
inBackgroundButton.up().addClassName('disabled');
skipButton.disabled = true;
inBackgroundButton.disabled = true;
inBackgroundButton.update(
'<span class="wait">' + migratorLocale.lmsg('waitButtonTitle') + '</span>'
);
Jsw.redirect(successRedirectUrl);
}
}
],
popupCls: 'popup-panel popup-panel-centered'
});
popup.show();
var elemActionText = $('pre-checks-action-text');
function pollProgress() {
new Ajax.Request(URL_GET_PROGRESS_PRE_CHECKS + '/task/' + taskId, {
onSuccess: function (response) {
var progress = response.responseText.evalJSON();
if (
progress.status == overallStatus.FINISHED_OK ||
progress.status == overallStatus.FINISHED_WARNINGS ||
progress.status == overallStatus.FINISHED_ERRORS
) {
if (skipChecks) {
new Ajax.Request(URL_START_MIGRATION + '/task/' + taskId, {
onSuccess: function (response) {
Jsw.redirect(successRedirectUrl);
}
});
return;
}
if (proceedToMigrationIfNoIssues) {
elemActionText.update(migratorLocale.lmsg('preMigrationChecksFinishedCheckIssues'));
new Ajax.Request(URL_HAS_PRE_MIGRATION_ISSUES + '/task/' + taskId, {
onSuccess: function (response) {
var hasPreMigrationIssues = response.responseText.evalJSON();
if (hasPreMigrationIssues) {
elemActionText.update(migratorLocale.lmsg('preMigrationChecksFinishedCheckIssues'));
Jsw.redirect(
URL_PRE_MIGRATION_CHECK_RESULTS +
'/task/' + taskId +
'/redirect-to-list-of-subscriptions/' + redirectToListOfSubscriptionsVal
);
} else {
elemActionText.update(migratorLocale.lmsg('preMigrationChecksFinishedStartingMigration'));
new Ajax.Request(URL_START_MIGRATION + '/task/' + taskId, {
onSuccess: function (response) {
Jsw.redirect(successRedirectUrl);
}
});
}
}
});
} else {
elemActionText.update(migratorLocale.lmsg('preMigrationChecksFinishedRedirecting'));
Jsw.redirect(
URL_PRE_MIGRATION_CHECK_RESULTS +
'/task/' + taskId +
'/redirect-to-list-of-subscriptions/' + redirectToListOfSubscriptionsVal
);
}
} else if (!progress.status && skipChecksFinished) {
new Ajax.Request(URL_START_MIGRATION + '/task/' + taskId, {
onSuccess: function (response) {
Jsw.redirect(successRedirectUrl);
}
});
} else {
if (!skipChecks) {
if (progress.action) {
elemActionText.update(formatStr(progress.action));
} else if (progress.status == null) {
elemActionText.update(migratorLocale.lmsg('preMigrationChecksWaitingForTasks'))
}
}
// Poll progress once more
setTimeout(pollProgress, PRE_CHECKS_POLL_INTERVAL);
}
},
onFailure: function() {
setTimeout(pollProgress, PRE_CHECKS_POLL_INTERVAL);
}
});
}
pollProgress();
}

View File

@@ -1,78 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog to reassign owner of subscriptions.
// Arguments: subscriptions - list of subscription names.
function showReassignOwnerPopup(subscriptions, onSuccess) {
// compose title - it is different when one subscription is selected
// and when multiple subscriptions are selected
var title = '';
if (subscriptions.length > 1) {
title = formatMessage(MESSAGE_POPUP_REASSIGN_OWNER_TITLE_MULTIPLE, subscriptions.length);
} else if (subscriptions.length == 1) {
title = formatMessage(MESSAGE_POPUP_REASSIGN_OWNER_TITLE_MIGRATE_SINGLE, subscriptions[0]);
} else {
// no subscriptions - no sense to show dialog
return;
}
var popup = new Jsw.Popup({
title: title,
content: (
'<div class="form-row">' +
'<div class="field-name">' + MESSAGE_POPUP_REASSIGN_OWNER_NAME + '</div>' +
'<div class="field-value">' +
'<div id="reassign-input-container"></div>' +
'</div>' +
'</div>'
),
buttons: [
{
id: 'reassignOwnerOkButton',
title: MESSAGE_POPUP_REASSIGN_OWNER_BUTTON_OK,
class: 'action',
handler: function (event, popup) {
var elemReassignOwner = $$('input[name="reassign-owner"]').first();
var ownerInfo = elemReassignOwner.value.evalJSON();
var ownerType = ownerInfo[0];
var ownerLogin = ownerInfo[1];
disableButtonInProgress($('reassignOwnerOkButton'), 'changingButtonTitle');
disableButtonPlain($('reassignOwnerCancelButton'));
new Ajax.Request(URL_REASSIGN_OWNER_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions),
ownerType: ownerType,
ownerLogin: ownerLogin
},
onSuccess: function (response) {
if (onSuccess) {
onSuccess();
}
popup.hide();
}
});
}
},
{
id: 'reassignOwnerCancelButton',
title: MESSAGE_POPUP_REASSIGN_OWNER_BUTTON_CANCEL,
handler: function (event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered migrator-popup-reassign'
});
popup.show();
new Jsw.LookUp({
id: 'reassign-owner',
name: 'reassign-owner',
renderTo: 'reassign-input-container',
data: REASSIGN_OWNER_DATA,
value: '',
locale: REASSIGN_OWNER_LOCALE
});
}

View File

@@ -1,83 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog to reassign plan of subscriptions.
// Arguments: subscriptions - list of subscription names.
function showReassignPlanPopup(subscriptions, onSuccess) {
// compose title - it is different when one subscription is selected
// and when multiple subscriptions are selected
var title = '';
if (subscriptions.length > 1) {
title = formatMessage(MESSAGE_POPUP_REASSIGN_PLAN_TITLE_MULTIPLE, subscriptions.length);
} else if (subscriptions.length == 1) {
title = formatMessage(MESSAGE_POPUP_REASSIGN_PLAN_TITLE_MIGRATE_SINGLE, subscriptions[0]);
} else {
// no subscriptions - no sense to show dialog
return;
}
new Ajax.Request(URL_GET_REASSIGN_PLAN_CONTROL_DATA, {
parameters: {
subscriptions: Object.toJSON(subscriptions)
},
onSuccess: function(response) {
var planControlData = response.responseText.evalJSON();
var popup = new Jsw.Popup({
title: title,
content: (
'<div class="form-row">' +
'<div class="field-name">' + MESSAGE_POPUP_REASSIGN_PLAN_NEW_PLAN + '</div>' +
'<div class="field-value">' +
'<div id="reassign-plan-input-container"></div>' +
'</div>' +
'</div>'
),
buttons: [
{
id: 'reassignPlanOkButton',
title: MESSAGE_POPUP_REASSIGN_PLAN_BUTTON_OK,
class: 'action',
handler: function (event, popup) {
var elemReassignPlan = $$('input[name="reassign-plan"]').first();
disableButtonInProgress($('reassignPlanOkButton'), 'changingButtonTitle');
disableButtonPlain($('reassignPlanCancelButton'));
new Ajax.Request(URL_REASSIGN_PLAN_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions),
plan: elemReassignPlan.value
},
onSuccess: function (response) {
if (onSuccess) {
onSuccess();
}
popup.hide();
}
});
}
},
{
id: 'reassignPlanCancelButton',
title: MESSAGE_POPUP_REASSIGN_PLAN_BUTTON_CANCEL,
handler: function (event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered migrator-popup-reassign'
});
popup.show();
new Jsw.LookUp({
id: 'reassign-plan',
name: 'reassign-plan',
renderTo: 'reassign-plan-input-container',
data: planControlData,
value: '',
locale: REASSIGN_PLAN_LOCALE
});
}
});
}

View File

@@ -1,48 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with confirmation to remove subscriptions from target server.
// Arguments: subscriptions - list of subscription names.
function showRemovePopup(subscriptions, onSuccess) {
// Hack to create dialog box, which does not immediately close dialog when "Yes" button is clicked
var RemoveMessageBox = Class.create(
// take MessageBox class as superclass of AjaxMessageBox, because MessageBox class is not public since 17.8
Jsw.AjaxMessageBox.superclass,
{
_defaultOnButtonClick: function() {}
}
);
var messageBox = new RemoveMessageBox({
'type': Jsw.messageBox.TYPE_YESNO,
'subtype': 'delete',
'text': migratorLocale.lmsg('popupRemoveDescription'),
'onYesClick': function () {
this._componentElement.select('button').each(function(button) {
button.disabled = true;
button.up().addClassName('disabled');
});
this._componentElement.select('button').first().update(
'<span class="wait">' + migratorLocale.lmsg('popupRemoveInProgress') + '</span>'
);
new Ajax.Request(URL_REMOVE_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions)
},
onSuccess: function() {
messageBox.hide();
if (onSuccess) {
onSuccess();
}
}
});
},
'onNoClick': function () {
this.hide();
},
'buttonTitles': {
'yes': migratorLocale.lmsg('popupRemoveButtonYes'),
'no': migratorLocale.lmsg('popupRemoveButtonNo')
}
});
messageBox.show();
}

View File

@@ -1,179 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with settings to start re-sync of content (web, databases, mail).
// Arguments:
// - subscriptions - list of subscription names.
// - onSuccess - function that will be called once resync of these subscriptions is scheduled.
function showResyncPopup(subscriptions, onSuccess, showServerConfigurationBlock, showExtensionsSettingsBlock) {
// compose title - it is different when one subscription is selected
// and when multiple subscriptions are selected
var title = '';
if (subscriptions.length > 1) {
title = formatMessage(MESSAGE_POPUP_RESYNC_TITLE_MULTIPLE, subscriptions.length);
} else if (subscriptions.length == 1) {
title = formatMessage(MESSAGE_POPUP_RESYNC_TITLE_SINGLE, subscriptions[0]);
} else {
// no subscriptions - no sense to show dialog
return;
}
function getServerSettingsBlock() {
let html = '';
if (showServerConfigurationBlock) {
html += (
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncMailSettings"> ' +
'<label for="resyncMailSettings">' +
MESSAGE_POPUP_RESYNC_MAIL_SETTINGS +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncAdminProfile"> ' +
'<label for="resyncAdminProfile">' +
MESSAGE_POPUP_RESYNC_ADMIN_PROFILE +
'</label>' +
'</div>'
)
}
if (showExtensionsSettingsBlock) {
html += (
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncExtensionsSettings"> ' +
'<label for="resyncExtensionsSettings">' +
MESSAGE_POPUP_RESYNC_EXTENSIONS_SETTINGS +
'</label>' +
'</div>'
);
}
if (html) {
html = (
'<br />' +
'<div class="field-name">' + MESSAGE_POPUP_RESYNC_SERVER_SETTINGS + '</div>' +
'<div class="field-value">' +
html +
'</div>'
);
}
return html;
}
var popup = new Jsw.Popup({
title: title,
content: (
'<div class="form-row">' +
'<div class="field-name">' + MESSAGE_POPUP_RESYNC_CONTENT + '</div>' +
'<div class="field-value">' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncBusinessObjects"> ' +
'<label for="resyncBusinessObjects">' +
MESSAGE_POPUP_RESYNC_BUSINESS_OBJECTS +
'</label>' +
'</div>' +
'<div style="padding-left: 20px">' +
'<input type="checkbox" class="checkbox" id="resyncId"> ' +
'<label for="resyncId">' +
MESSAGE_POPUP_RESYNC_ID +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncFiles" checked="checked"> ' +
'<label for="resyncFiles">' +
MESSAGE_POPUP_RESYNC_FILES +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncDatabases" checked="checked"> ' +
'<label for="resyncDatabases">' +
MESSAGE_POPUP_RESYNC_DATABASES +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncMail" checked="checked"> ' +
'<label for="resyncMail">' +
MESSAGE_POPUP_RESYNC_MAIL +
'</label>' +
'</div>' +
'</div>' +
getServerSettingsBlock() +
'</div>'
),
buttons: [
{
id: 'resyncOkButton',
title: MESSAGE_POPUP_RESYNC_BUTTON_OK,
class: 'action',
handler: function(event, popup) {
var elemResyncBusinessObjects = $('resyncBusinessObjects');
var elemResyncFiles = $('resyncFiles');
var elemResyncDatabases = $('resyncDatabases');
var elemResyncMail = $('resyncMail');
var elemResyncId = $('resyncId');
var elemResyncMailSettings = $('resyncMailSettings');
var elemResyncAdminProfile = $('resyncAdminProfile');
var elemResyncExtensionsSettings = $('resyncExtensionsSettings');
var someResyncChecked = [
elemResyncBusinessObjects,
elemResyncFiles,
elemResyncDatabases,
elemResyncMail,
elemResyncId,
elemResyncMailSettings,
elemResyncAdminProfile,
elemResyncExtensionsSettings
].some(elem => elem && elem.checked);
if (someResyncChecked) {
disableButtonInProgress($('resyncOkButton'), 'schedulingButtonTitle');
disableButtonPlain($('resyncCancelButton'));
new Ajax.Request(URL_RESYNC_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions),
resyncBusinessObjects: elemResyncBusinessObjects.checked,
resyncFiles: elemResyncFiles.checked,
resyncDatabases: elemResyncDatabases.checked,
resyncMail: elemResyncMail.checked,
resyncId: elemResyncId.checked,
resyncMailSettings: elemResyncMailSettings ? elemResyncMailSettings.checked : false,
resyncAdminProfile: elemResyncAdminProfile ? elemResyncAdminProfile.checked : false,
resyncExtensionsSettings: elemResyncExtensionsSettings ? elemResyncExtensionsSettings.checked : false,
},
onSuccess: function (response) {
if (onSuccess) {
onSuccess();
}
popup.hide();
}
});
} else {
popup.hide();
}
}
},
{
id: 'resyncCancelButton',
title: MESSAGE_POPUP_RESYNC_BUTTON_CANCEL,
handler: function(event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered'
});
var resyncBusinessObjectsCheckbox = document.getElementById('resyncBusinessObjects');
var resyncIdCheckbox = document.getElementById('resyncId');
resyncIdCheckbox.disabled = true;
resyncBusinessObjectsCheckbox.addEventListener('change', (event) => {
resyncIdCheckbox.disabled = !event.target.checked;
resyncIdCheckbox.checked = event.target.checked;
})
popup.show();
}

View File

@@ -1,29 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with confirmation to revert DNS forwarding.
// Arguments:
// - subscriptions - list of subscription names.
// - onSuccess - function that will be called once DNS revert of these subscriptions is scheduled.
function showRevertDnsPopup(subscriptions, onSuccess) {
Jsw.messageBox.show({
'type': Jsw.messageBox.TYPE_YESNO,
'subtype': 'delete',
'text': MESSAGE_POPUP_REVERT_DNS_DESCRIPTION,
'onYesClick': function () {
new Ajax.Request(URL_REVERT_DNS_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions)
},
onSuccess: function() {
if (onSuccess) {
onSuccess();
}
}
});
},
'buttonTitles': {
'yes': MESSAGE_POPUP_REVERT_DNS_BUTTON_YES,
'no': MESSAGE_POPUP_REVERT_DNS_BUTTON_NO
}
});
}

View File

@@ -1,145 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with service node and IP address type selection for Plesk Multi Server.
// Arguments: subscriptions - list of subscription names.
function showSelectNodePopup(subscriptions, onSuccess) {
// compose title - it is different when one subscription is selected
// and when multiple subscriptions are selected
var title = '';
if (subscriptions.length > 1) {
title = migratorLocale.lmsg('popupSelectNodeTitleMultiple', { count: subscriptions.length } );
} else if (subscriptions.length == 1) {
title = migratorLocale.lmsg('popupSelectNodeTitleSingle', { subscriptionName: subscriptions[0] });
} else {
// no subscriptions - no sense to show dialog
return;
}
new Ajax.Request(URL_LIST_PLESK_MULTI_SERVER_NODES, {
onSuccess: function (response) {
var nodeIPs = response.responseText.evalJSON();
var popupContent = '<div class="form-box">' +
'<div class="form-row">' +
'<div class="field-name">' + migratorLocale.lmsg('popupSelectNodeNode') + '</div>' +
'<div class="field-value">' +
'<div id="select-node-input-container"></div>' +
'</div>' +
'</div>' +
'<div class="form-row">' +
'<div class="field-name">' + migratorLocale.lmsg('popupSelectNodeIPv4Type') + '</div>' +
'<div class="field-value">' +
'<div class="text-value">' +
'<div class="indent-box">' +
'<input type="radio" name="mappingTypeV4" id="mappingTypeV4Shared" class="radio" value="shared" checked="checked"> ' +
'<label for="mappingTypeV4Shared">' +
migratorLocale.lmsg('popupSelectNodeIPShared') +
'</label>' +
'</div>' +
'<div class="indent-box">' +
'<input type="radio" name="mappingTypeV4" id="mappingTypeV4Dedicated" class="radio" value="dedicated"> ' +
'<label for="mappingTypeV4Dedicated">' +
migratorLocale.lmsg('popupSelectNodeIPDedicated') +
'</label>' +
'</div>' +
'<div class="indent-box">' +
'<input type="radio" name="mappingTypeV4" class="radio" id="mappingTypeV4None" value="none"> ' +
'<label for="mappingTypeV4None">' +
migratorLocale.lmsg('popupSelectNodeIPNone') +
'</label>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'<div class="form-row">' +
'<div class="field-name">' + migratorLocale.lmsg('popupSelectNodeIPv6Type') + '</div>' +
'<div class="field-value">' +
'<div class="text-value">' +
'<div class="indent-box">' +
'<input type="radio" name="mappingTypeV6" id="mappingTypeV6Shared" class="radio" value="shared"> ' +
'<label for="mappingTypeV6Shared">' +
migratorLocale.lmsg('popupSelectNodeIPShared') +
'</label>' +
'</div>' +
'<div class="indent-box">' +
'<input type="radio" name="mappingTypeV6" id="mappingTypeV6Dedicated" class="radio" value="dedicated"> ' +
'<label for="mappingTypeV6Dedicated">' +
migratorLocale.lmsg('popupSelectNodeIPDedicated') +
'</label>' +
'</div>' +
'<div class="indent-box">' +
'<input type="radio" name="mappingTypeV6" class="radio" id="mappingTypeV6None" value="none" checked="checked"> ' +
'<label for="mappingTypeV6None">' +
migratorLocale.lmsg('popupSelectNodeIPNone') +
'</label>' +
'</div>' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
var popup = new Jsw.Popup({
title: title,
content: popupContent,
buttons: [
{
id: 'selectNodeOkButton',
title: migratorLocale.lmsg('popupSelectNodeButtonOk'),
class: 'action',
handler: function (event, popup) {
disableButtonInProgress($('selectNodeOkButton'), 'changingButtonTitle');
disableButtonPlain($('selectNodeCancelButton'));
var parameters = {
subscriptions: Object.toJSON(subscriptions),
ipv4: $$('input:checked[type=radio][name=mappingTypeV4]').first().value,
ipv6: $$('input:checked[type=radio][name=mappingTypeV6]').first().value,
nodeIP: $$('input[name=select-node]').first().value
};
new Ajax.Request(URL_CHANGE_IP_SUBSCRIPTIONS, {
parameters: parameters,
onSuccess: function (response) {
if (onSuccess) {
onSuccess();
}
popup.hide();
}
});
}
},
{
id: 'selectNodeCancelButton',
title: migratorLocale.lmsg('popupSelectNodeButtonCancel'),
handler: function (event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered migrator-popup-reassign'
});
popup.show();
function addLookup(nodeIPAddresses)
{
var nodeIPLookupData = [];
for (var i = 0; i < nodeIPAddresses.length; i++) {
var ip = nodeIPAddresses[i];
nodeIPLookupData.push({id: ip, title: ip});
}
var lookup = new Jsw.LookUpExtended({
id: 'select-node',
name: 'select-node',
renderTo: 'select-node-input-container',
data: nodeIPLookupData,
value: '',
locale: SELECT_NODE_LOCALE
});
}
addLookup(nodeIPs);
}
});
}

View File

@@ -1,107 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with migration issues for some object
// Arguments:
// - title: popup dialog title
// - issues - array of objects, each object describes an issue and contains problem text, solution text, etc,
// see asDictionary method of Modules_PanelMigrator_Backend_Issue
function showIssuesPopupDialog(title, issues) {
var popupContent = '';
popupContent += '<div class="status-details-dialog-content">';
function composeIssueHtml(issue) {
var image = migratorImage('subscription-status-success.png');
if (issue.severity == issueSeverity.ERROR) {
image = migratorImage('subscription-status-error.png');
} else if (issue.severity == issueSeverity.WARNING) {
image = migratorImage('subscription-status-warning.png');
}
var html = '';
html += '<div>';
html += '<img src="' + image + '" class="status-details-dialog-issue-icon">';
html += '&nbsp;';
html += formatStr(issue.problemText);
if (issue.solutionText) {
html += '<br/>';
html += formatStr(issue.solutionText);
}
html += '</div>';
return html;
}
if (issues.length > 0) {
// Step #1: Group issues by date and operation
var groupedIssues = {};
issues.each(function(issue) {
var date = issue.executionDate;
var operation = issue.executionCommandTitle;
if (!groupedIssues[date]) {
groupedIssues[date] = {};
}
if (!groupedIssues[date][operation]) {
groupedIssues[date][operation] = [];
}
groupedIssues[date][operation].push(issue);
});
// Step #2: Order issue dates for further iteration
var executionDates = Object.keys(groupedIssues);
executionDates.sort();
executionDates.reverse();
// Step #3: Iterate over dates, operations and issues, composing the popup contents
executionDates.forEach(function(date) {
var operations = Object.keys(groupedIssues[date]);
operations.forEach(function(operation) {
var issuesOfDateAndOperation = groupedIssues[date][operation];
popupContent += (
'<h4>[' + formatDateFromTimestamp(date) + '] ' + operation + '</h4><hr/>'
);
issuesOfDateAndOperation.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] &&
operation == operations[operations.length - 1] &&
issue == issuesOfDateAndOperation[issuesOfDateAndOperation.length - 1]
)
) {
popupContent += '<hr/>';
}
});
});
});
} else {
popupContent += migratorLocale.lmsg('popupStatusDetailsNoIssues');
}
popupContent += '</div>';
var popup = new Jsw.Popup({
title: title,
content: popupContent,
buttons: [
{
title: migratorLocale.lmsg('popupStatusDetailsButtonOk'),
class: 'action',
handler: function(event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-xl popup-panel-centered'
});
popup.show();
}

View File

@@ -1,103 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Show popup dialog with settings to start DNS switching.
// Arguments:
// - subscriptions - list of subscription names.
// - onSuccess - function that will be called once DNS switch of these subscriptions is scheduled.
function showSwitchDNSPopup(subscriptions, onSuccess) {
// compose title - it is different when one subscription is selected
// and when multiple subscriptions are selected
var title = '';
if (subscriptions.length > 1) {
title = formatMessage(MESSAGE_POPUP_SWITCH_DNS_TITLE_MULTIPLE, subscriptions.length);
} else if (subscriptions.length == 1) {
title = formatMessage(MESSAGE_POPUP_SWITCH_DNS_TITLE_SINGLE, subscriptions[0]);
} else {
// no subscriptions - no sense to show dialog
return;
}
var popup = new Jsw.Popup({
title: title,
content: (
'<div class="form-row">' +
'<div>' + migratorLocale.lmsg('dnsSwitchDescription') + '</div>' +
// TODO: implement support
/*'<div class="field-name">' + MESSAGE_POPUP_SWITCH_DNS_BEFORE + '</div>' +
'<div class="field-value">' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncBusinessObjects"> ' +
'<label for="resyncBusinessObjects">' +
MESSAGE_POPUP_SWITCH_DNS_RESYNC_BUSINESS_OBJECTS +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncFiles" checked="checked"> ' +
'<label for="resyncFiles">' +
MESSAGE_POPUP_SWITCH_DNS_RESYNC_FILES +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncDatabases" checked="checked"> ' +
'<label for="resyncDatabases">' +
MESSAGE_POPUP_SWITCH_DNS_RESYNC_DATABASES +
'</label>' +
'</div>' +
'<div>' +
'<input type="checkbox" class="checkbox" id="resyncMail" checked="checked"> ' +
'<label for="resyncMail">' +
MESSAGE_POPUP_SWITCH_DNS_RESYNC_MAIL +
'</label>' +
'</div>' +
'</div>' + */
'</div>'
),
buttons: [
{
id: 'switchDnsOkButton',
title: MESSAGE_POPUP_SWITCH_DNS_BUTTON_OK,
class: 'action',
handler: function(event, popup) {
// TODO: implement support
/*
var elemResyncBusinessObjects = $('resyncBusinessObjects');
var elemResyncFiles = $('resyncFiles');
var elemResyncDatabases = $('resyncDatabases');
var elemResyncMail = $('resyncMail');
*/
disableButtonInProgress($('switchDnsOkButton'), 'schedulingButtonTitle');
disableButtonPlain($('switchDnsCancelButton'));
new Ajax.Request(URL_SWITCH_DNS_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptions)
// TODO: implement support
/*
resyncBusinessObjects: elemResyncBusinessObjects.checked,
resyncFiles: elemResyncFiles.checked,
resyncDatabases: elemResyncDatabases.checked,
resyncMail: elemResyncMail.checked
*/
},
onSuccess: function (response) {
if (onSuccess) {
onSuccess();
}
popup.hide();
}
});
}
},
{
id: 'switchDnsCancelButton',
title: MESSAGE_POPUP_SWITCH_DNS_BUTTON_CANCEL,
handler: function(event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered'
});
popup.show();
}

View File

@@ -1,149 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
Jsw.onReady(function() {
var continueButton = $('pre-checks-continue');
var refreshButton = $('pre-checks-refresh');
var closeButton = $('pre-checks-close');
var discardButton = $('pre-checks-discard');
var successRedirectUrl = URL_MIGRATION_STATUS;
if (REDIRECT_TO_LIST_OF_SUBSCRIPTIONS) {
successRedirectUrl = URL_LIST_OF_SUBSCRIPTIONS;
}
function disableButtons(mainButton)
{
[continueButton, refreshButton, closeButton, discardButton].each(function(button) {
button.disabled = true;
button.up().addClassName('disabled');
});
mainButton.update(
'<span class="wait">' + migratorLocale.lmsg('waitButtonTitle') + '</span>'
);
}
continueButton.observe('click', function() {
disableButtons(continueButton);
new Ajax.Request(URL_START_MIGRATION + '/task/' + TASK_ID, {
onSuccess: function (response) {
Jsw.redirect(successRedirectUrl);
}
});
});
refreshButton.observe('click', function() {
disableButtons(refreshButton);
new Ajax.Request(URL_REFRESH_PRE_MIGRATION_CHECKS + '/task/' + TASK_ID, {
onSuccess: function (response) {
var data = response.responseText.evalJSON();
showPreChecksPopup(data.task, false, REDIRECT_TO_LIST_OF_SUBSCRIPTIONS);
}
});
});
closeButton.observe('click', function() {
disableButtons(closeButton);
Jsw.redirect(successRedirectUrl);
});
discardButton.observe('click', function() {
disableButtons(discardButton);
new Ajax.Request(URL_DISCARD_PRE_MIGRATION_CHECKS + '/task/' + TASK_ID, {
onSuccess: function (response) {
Jsw.redirect(successRedirectUrl);
}
});
});
Jsw.Tooltip.init(continueButton, {text: migratorLocale.lmsg('preMigrationResultsButtonContinueHint')});
Jsw.Tooltip.init(refreshButton, {text: migratorLocale.lmsg('preMigrationResultsButtonRefreshHint')});
Jsw.Tooltip.init(closeButton, {text: migratorLocale.lmsg('preMigrationResultsButtonCloseHint')});
Jsw.Tooltip.init(discardButton, {text: migratorLocale.lmsg('preMigrationResultsButtonDiscardHint')});
function showAffectedObjectsPopup(title, description, objectNames) {
var content = '<div>';
content += description;
content += '<ul>';
objectNames.each(function(object) {
content += '<li>' + object + '</li>';
});
content += '</ul>';
content += '</div>';
var popup = new Jsw.Popup({
title: title,
content: content,
buttons: [
{
id: 'affected-objects-close-button',
title: migratorLocale.lmsg('preMigrationResultsAffectedObjectButtonClose'),
handler: function (event, popup) {
popup.hide();
}
}
],
popupCls: 'popup-panel popup-panel-centered'
});
popup.show();
}
function displayAffectedObjects() {
}
$$('.affected-objects').each(function(element) {
var issueNum = element.select('.issue-num').first().textContent;
var affectedObjects = AFFECTED_OBJECTS[issueNum];
if (affectedObjects.length > 0) {
element.show();
var sameTypeObjects = true;
var firstObjectType = affectedObjects[0].object_type;
var affectedObjectNames = [];
affectedObjects.each(function(affectedObject) {
if (affectedObject.object_type != firstObjectType) {
sameTypeObjects = false;
}
affectedObjectNames.push(affectedObject.name);
});
var title = '';
var description = '';
if (sameTypeObjects) {
if (firstObjectType == 'subscription') {
title = migratorLocale.lmsg('preMigrationResultsTitleAffectedSubscriptions');
description = migratorLocale.lmsg('preMigrationResultsDescriptionAffectedSubscriptions');
} else if (firstObjectType == 'mssql-server') {
title = migratorLocale.lmsg('preMigrationResultsTitleAffectedMssqlServers');
description = migratorLocale.lmsg('preMigrationResultsDescriptionAffectedMssqlServers');
} else {
title = migratorLocale.lmsg('preMigrationResultsTitleAffectedObjects');
description = migratorLocale.lmsg('preMigrationResultsDescriptionAffectedObjects');
}
} else {
title = migratorLocale.lmsg('preMigrationResultsTitleAffectedObjects');
description = migratorLocale.lmsg('preMigrationResultsDescriptionAffectedObjects');
}
if (affectedObjects.length > MAX_AFFECTED_OBJECTS_INLINE) {
var link = new Element('a').update(title + ' (' + affectedObjects.length + ')');
link.observe('click', function() {
showAffectedObjectsPopup(title, description, affectedObjectNames);
});
element.update(link);
} else {
var html = '';
html += '<div>' + description + '</div>';
html += '<ul>';
affectedObjectNames.each(function(name) {
html += '<li>' + name + '</li>';
});
html += '</ul>';
element.update(html);
}
}
});
});

View File

@@ -1,180 +0,0 @@
// Copyright 1999-2024. WebPros International GmbH. All rights reserved.
Jsw.onReady(function() {
const appState = PanelMigrator.initAppState();
// Update whole progress status control
function updateProgressStatus(statusInfo) {
updateProgressStatusElementsVisibility();
updateProgressStatusCountElements(statusInfo);
updateProgressStatusState(statusInfo);
}
// Update visibility of "add subscriptions" link and failed/success/warning count elements.
// Visibility of these elements is specified by 2 global variables. It depends which are set according to the
// current page.
function updateProgressStatusElementsVisibility()
{
$$('.progress-status-count-box').each(function(element) {
if (SHOW_STATUS_ICONS) {
element.show();
} else {
element.hide();
}
});
$$('.progress-status-add-subscriptions-link').each(function(element) {
if (SHOW_ADD_SUBSCRIPTIONS_LINK) {
element.show();
} else {
element.hide();
}
});
}
// Update number of failed/success/warning subscriptions, and visibility of corresponding elements:
// they are not displayed if there are no subscriptions with corresponding status
function updateProgressStatusCountElements(statusInfo)
{
$$('.progress-status-count-item-success').each(function(element) {
if (statusInfo.queueFinishedSuccessSubscriptions > 0) {
element.show();
} else {
element.hide();
}
});
$$('.progress-status-count-item-failed').each(function(element) {
if (statusInfo.queueFinishedFailedSubscriptions > 0) {
element.show();
} else {
element.hide();
}
});
$$('.progress-status-count-item-warning').each(function(element) {
if (statusInfo.queueFinishedWarningSubscriptions > 0) {
element.show();
} else {
element.hide();
}
});
$$('.progress-status-count-value-success').each(function(element) {
element.update(statusInfo.queueFinishedSuccessSubscriptions);
});
$$('.progress-status-count-value-failed').each(function(element) {
element.update(statusInfo.queueFinishedFailedSubscriptions);
});
$$('.progress-status-count-value-warning').each(function(element) {
element.update(statusInfo.queueFinishedWarningSubscriptions);
});
}
// Update state and messages of progress status control: display one of four states:
// 1) migration was not started yet
// 2) migration is in progress right now: display progress bar
// 3) migration finished for several (but not all) subscriptions
// 4) migration finished for all subscriptions of the server
function updateProgressStatusState(statusInfo)
{
var totalLeftSubscriptions = statusInfo.totalSourceSubscriptions - statusInfo.totalMigratedSubscriptions;
if (statusInfo.overallStatus == 'finished-errors') {
$('progress-status-not-started').hide();
$('progress-status-in-progress').hide();
$('progress-status-queue-finished').hide();
$('progress-status-all-migrated').hide();
$('progress-status-overall-failure').show();
$('progress-status-text-overall-failure').update(statusInfo.overallErrorMessage);
} else if (
statusInfo.queueSubscriptions == 0 && statusInfo.totalMigratedSubscriptions == 0
) {
$('progress-status-not-started').show();
$('progress-status-in-progress').hide();
$('progress-status-queue-finished').hide();
$('progress-status-all-migrated').hide();
$('progress-status-overall-failure').hide();
} else if (
statusInfo.queueSubscriptions > 0 &&
statusInfo.queueFinishedSubscriptions < statusInfo.queueSubscriptions
) {
$('progress-status-text-subscriptions-in-queue').update(
formatMessage(
MESSAGE_SUBSCRIPTIONS_IN_QUEUE,
statusInfo.queueFinishedSubscriptions, statusInfo.queueSubscriptions
)
);
var progressPercentage = Math.round(
100 * statusInfo.queueFinishedSubscriptions / statusInfo.queueSubscriptions
);
$('progress-status-progress-bar').setStyle(
{'width': progressPercentage + "%"}
);
$('progress-status-not-started').hide();
$('progress-status-in-progress').show();
$('progress-status-queue-finished').hide();
$('progress-status-all-migrated').hide();
$('progress-status-overall-failure').hide();
} else if (statusInfo.totalMigratedSubscriptions < statusInfo.totalSourceSubscriptions) {
$('progress-status-text-subscriptions-migrated').update(
formatMessage(
MESSAGE_SUBSCRIPTIONS_MIGRATED, statusInfo.totalMigratedSubscriptions
)
);
$('progress-status-text-subscriptions-not-migrated').update(
formatMessage(
MESSAGE_SUBSCRIPTIONS_NOT_MIGRATED, totalLeftSubscriptions
)
);
$('progress-status-not-started').hide();
$('progress-status-in-progress').hide();
$('progress-status-queue-finished').show();
$('progress-status-all-migrated').hide();
$('progress-status-overall-failure').hide();
} else if (statusInfo.totalMigratedSubscriptions == statusInfo.totalSourceSubscriptions) {
$('progress-status-text-all-subscriptions-migrated').update(
formatMessage(
MESSAGE_ALL_SUBSCRIPTIONS_MIGRATED, statusInfo.totalMigratedSubscriptions
)
);
$('progress-status-not-started').hide();
$('progress-status-in-progress').hide();
$('progress-status-queue-finished').hide();
$('progress-status-all-migrated').show();
$('progress-status-overall-failure').hide();
} else {
$('progress-status-not-started').hide();
$('progress-status-in-progress').hide();
$('progress-status-queue-finished').hide();
$('progress-status-all-migrated').hide();
$('progress-status-overall-failure').hide();
}
}
function updateProgressStatusAjax()
{
if (!appState.mounted) return;
new Ajax.Request(URL_GET_SESSION_STATUS, {
onSuccess: function(response) {
if (!appState.mounted) return;
var json = response.responseText.evalJSON();
updateProgressStatus(json);
},
onComplete: function() {
setTimeout(updateProgressStatusAjax, PROGRESS_STATUS_UPDATE_INTERVAL);
}
});
}
// Perform initial update from data passed in HTML
updateProgressStatus(SESSION_STATUS);
// Schedule run periodic updates with AJAX
updateProgressStatusAjax();
$('progress-status-cancel').observe('click', function() {
showCancelAllPopup();
});
});

View File

@@ -1,67 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
function updateSessionStatus(session_id, sessionStatusInfo)
{
var blockNotStarted = sessionElement(session_id, 'block-not-started');
var blockInProgress = sessionElement(session_id, 'block-in-progress');
var blockAllMigrated = sessionElement(session_id, 'block-all-migrated');
var blockMigrated = sessionElement(session_id, 'block-migrated');
var allBlocks = [blockNotStarted, blockInProgress, blockAllMigrated, blockMigrated];
if (!sessionStatusInfo.started) {
showOnly(allBlocks, blockNotStarted);
} else if (sessionStatusInfo.queueSubscriptions > 0) {
showOnly(allBlocks, blockInProgress);
var progressPercentage = Math.round(
100 * sessionStatusInfo.queueFinishedSubscriptions / sessionStatusInfo.queueSubscriptions
);
sessionElement(session_id, 'progress-bar').setStyle(
{'width': progressPercentage + "%"}
);
sessionElement(session_id, 'text-in-progress').update(
formatMessage(
MESSAGE_SUBSCRIPTIONS_IN_PROGRESS,
sessionStatusInfo.queueFinishedSubscriptions,
sessionStatusInfo.queueSubscriptions
)
);
} else if (sessionStatusInfo.totalSourceSubscriptions == sessionStatusInfo.totalMigratedSubscriptions) {
showOnly(allBlocks, blockAllMigrated);
sessionElement(session_id, 'text-all-migrated').update(
formatMessage(MESSAGE_ALL_SUBSCRIPTIONS_MIGRATED, sessionStatusInfo.totalSourceSubscriptions)
);
} else {
showOnly(allBlocks, blockMigrated);
sessionElement(session_id, 'text-migrated').update(
formatMessage(MESSAGE_SUBSCRIPTIONS_MIGRATED, sessionStatusInfo.totalMigratedSubscriptions)
);
}
}
function periodicUpdateSessionStatus(session_id)
{
new Ajax.Request(URL_GET_SESSION_STATUS + '/session/' + session_id, {
onSuccess: function(response) {
var sessionStatusInfo = response.responseText.evalJSON();
updateSessionStatus(session_id, sessionStatusInfo);
if (sessionStatusInfo.queueSubscriptions > 0) {
// continue polling status for session in progress, don't poll status for all the others as
// it is unlikely that they will be started, and it could take much time to poll status
// of all sessions
setTimeout(function () {
periodicUpdateSessionStatus(session_id)
}, SESSION_PROGRESS_UPDATE_INTERVAL);
}
},
onFailure: function() {
setTimeout(function () {
periodicUpdateSessionStatus(session_id)
}, SESSION_PROGRESS_UPDATE_INTERVAL);
}
});
}
function sessionElement(session_id, element_id)
{
return $(element_id + "-" + session_id);
}

View File

@@ -1,35 +0,0 @@
Jsw.onReady(function() {
$$('.migrate-by-mode-selector-radio input').invoke('observe', 'change', function(e) {
$$('.migrate-by-mode-selector-radio').invoke('removeClassName', 'checked');
e.target.up('.migrate-by-mode-selector-radio').addClassName('checked');
});
var modes = ['subscription', 'customer', 'reseller', 'plan'];
function toggleModeRows()
{
for (var i = 0; i < modes.length; i++)
{
var mode = modes[i];
if ($('mode-' + mode).checked) {
$(mode + 'List-form-row').show();
} else {
$(mode + 'List-form-row').hide();
}
}
if ($('mode-subscription').checked) {
$('reassignOwner-form-row').show();
} else {
$('reassignOwner-form-row').hide();
}
}
for (var i = 0; i < modes.length; i++)
{
var mode = modes[i];
$('mode-' + mode).observe('change', toggleModeRows);
}
toggleModeRows();
});

View File

@@ -1,33 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Control to reassign migrated subscriptions to different client or reseller
// main function to initialize reassign control
function createReassignControl(id, data, value, lookupLocale)
{
// create lookup field
var reassignLookup = new Jsw.LookUpExtended({
id: id + '-value',
name: id + '[reassignTo]',
renderTo: id + '-reassign-container',
data: data,
value: value,
locale: lookupLocale
});
// handle switching of radio button: enable or disable lookup control
var radioReassign = $(id + '-reassign');
var radioDoNotChange = $(id + '-do-not-change');
function setLookupEnabled() {
if (radioReassign.checked) {
reassignLookup.enable();
} else {
reassignLookup.disable();
}
}
radioReassign.observe('change', setLookupEnabled);
radioDoNotChange.observe('change', setLookupEnabled);
setLookupEnabled();
}

View File

@@ -1,19 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
Jsw.onReady(function() {
// Start queue runner periodically in case in terminated for some reason, so
// even if it failed or there is race condition - customer will get migration
// running again by just visiting migration status page
function periodicRunQueue() {
new Ajax.Request(URL_RUN_QUEUE, {
onComplete: function (response) {
setTimeout(
function () { periodicRunQueue() },
RUN_QUEUE_PERIOD
);
}
})
}
periodicRunQueue();
});

View File

@@ -1,26 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
Jsw.onReady(function() {
var postChecksEnabledCheckbox = $('postChecksSettings-performPostMigrationChecks');
function updatePostCheckControls() {
var controls = [
$('postChecksSettings-externalDns'),
$('postChecksSettings-mailMessagesDeltaLimit'),
$('postChecksSettings-websiteAvailabilityCheckTimeout')
];
for (var i = 0; i < controls.length; i++) {
if (postChecksEnabledCheckbox.checked) {
controls[i].enable();
} else {
controls[i].disable();
}
}
}
postChecksEnabledCheckbox.observe('change', function() {
updatePostCheckControls();
});
updatePostCheckControls();
});

View File

@@ -1,347 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
// Identifiers of operations that we could perform on subscriptions
subscriptionOperation = {
MIGRATE: 'Migrate',
RESTART: 'Restart',
SWITCH_DNS: 'SwitchDns',
REASSIGN_OWNER: 'ReassignOwner',
REASSIGN_PLAN: 'ReassignPlan',
RESET_REASSIGN: 'ResetReassign',
CHANGE_IP_MAPPING: 'ChangeIpMapping',
SELECT_NODE: 'SelectNode',
RESYNC: 'Resync',
POST_MIGRATION_CHECKS: 'PostMigrationChecks',
REVERT_DNS: 'RevertDns',
REMOVE_FROM_QUEUE: 'RemoveFromQueue',
REMOVE_MIGRATED: 'RemoveMigrated'
// TODO: implement support
/* SHOW_LOG: 'ShowLog' */
};
// Descriptions of operations that we could perform on subscriptions
var subscriptionOperations = [];
subscriptionOperations.push({
name: subscriptionOperation.MIGRATE,
run: function(subscriptionNames, onSuccess) {
showMigratePopup(subscriptionNames, onSuccess, SHOW_SERVER_CONFIGURATION_BLOCK, SHOW_EXTENSIONS_SETTINGS_BLOCK);
},
isApplicable: function(subscriptionInfo) {
return !_isRunningOrQueued(subscriptionInfo);
},
isMain: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return inArray(migrationStatus, [statuses.NOT_STARTED, statuses.CANCELLED]);
},
titleMain: 'subscriptionsListActionMigrate',
titleGroupOperation: 'subscriptionsListButtonMigrateTitle',
descriptionGroupOperation: 'subscriptionsListButtonMigrateHint',
listReload: false,
});
subscriptionOperations.push({
name: subscriptionOperation.RESTART,
run: function(subscriptionNames, onSuccess) {
showMigratePopup(subscriptionNames, onSuccess, SHOW_SERVER_CONFIGURATION_BLOCK, SHOW_EXTENSIONS_SETTINGS_BLOCK);
},
isApplicable: function(subscriptionInfo) {
return !_isRunningOrQueued(subscriptionInfo);
},
titleMain: 'subscriptionsListActionRestart',
isMain: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return migrationStatus == statuses.FINISHED_ERRORS && !_isRunningOrQueued(subscriptionInfo);
},
listReload: false,
});
subscriptionOperations.push({
name: subscriptionOperation.SWITCH_DNS,
run: function(subscriptionNames, onSuccess) {
showSwitchDNSPopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
var switchDNSStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.DNS_SWITCH], statuses.NOT_STARTED
);
return (
(
migrationStatus == subscriptionStatus.FINISHED_OK ||
migrationStatus == subscriptionStatus.FINISHED_WARNINGS
) &&
(
switchDNSStatus == subscriptionStatus.NOT_STARTED ||
switchDNSStatus == subscriptionStatus.CANCELLED ||
switchDNSStatus == subscriptionStatus.REVERTED ||
switchDNSStatus == subscriptionStatus.FINISHED_ERRORS
) && !_isRunningOrQueued(subscriptionInfo)
);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonSwitchDnsTitle',
descriptionGroupOperation: 'subscriptionsListButtonSwitchDnsHint',
titleMenu: 'subscriptionActionSwitchDns',
listReload: false,
});
subscriptionOperations.push({
name: subscriptionOperation.REASSIGN_OWNER,
run: function(subscriptionNames, onSuccess) {
showReassignOwnerPopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return inArray(migrationStatus, [subscriptionStatus.NOT_STARTED, subscriptionStatus.CANCELLED]);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonReassignOwnerTitle',
descriptionGroupOperation: 'subscriptionsListButtonReassignOwnerHint',
titleMenu: 'subscriptionActionReassignOwner',
listReload: true,
});
subscriptionOperations.push({
name: subscriptionOperation.REASSIGN_PLAN,
run: function(subscriptionNames, onSuccess) {
showReassignPlanPopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return inArray(migrationStatus, [subscriptionStatus.NOT_STARTED, subscriptionStatus.CANCELLED]);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonReassignPlanTitle',
descriptionGroupOperation: 'subscriptionsListButtonReassignPlanHint',
titleMenu: 'subscriptionActionReassignPlan',
listReload: true,
});
subscriptionOperations.push({
name: subscriptionOperation.RESET_REASSIGN,
run: function(subscriptionNames, onSuccess) {
new Ajax.Request(URL_RESET_REASSIGN_SUBSCRIPTIONS, {
parameters: {
subscriptions: Object.toJSON(subscriptionNames)
},
onSuccess: function (response) {
onSuccess();
}
});
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return inArray(migrationStatus, [subscriptionStatus.NOT_STARTED, subscriptionStatus.CANCELLED]);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonResetReassignTitle',
descriptionGroupOperation: 'subscriptionsListButtonResetReassignHint',
titleMenu: 'subscriptionActionReassignReset',
listReload: true,
});
subscriptionOperations.push({
name: subscriptionOperation.CHANGE_IP_MAPPING,
run: function(subscriptionNames, onSuccess) {
showChangeIPPopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return inArray(migrationStatus, [subscriptionStatus.NOT_STARTED, subscriptionStatus.CANCELLED]);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonChangeIpMappingTitle',
descriptionGroupOperation: 'subscriptionsListButtonChangeIpMappingHint',
titleMenu: 'subscriptionActionChangeIpMapping',
listReload: true,
showIPMapping: true,
});
subscriptionOperations.push({
name: subscriptionOperation.SELECT_NODE,
run: function(subscriptionNames, onSuccess) {
showSelectNodePopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return inArray(migrationStatus, [subscriptionStatus.NOT_STARTED, subscriptionStatus.CANCELLED]);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonSelectNodeTitle',
descriptionGroupOperation: 'subscriptionsListButtonSelectNodeHint',
titleMenu: 'subscriptionActionSelectNode',
listReload: true,
showIPMapping: true,
});
subscriptionOperations.push({
name: subscriptionOperation.RESYNC,
run: function(subscriptionNames, onSuccess) {
showResyncPopup(subscriptionNames, onSuccess, SHOW_SERVER_CONFIGURATION_BLOCK, SHOW_EXTENSIONS_SETTINGS_BLOCK);
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return (
migrationStatus != statuses.NOT_STARTED && migrationStatus != statuses.CANCELLED &&
!_isRunningOrQueued(subscriptionInfo)
);
},
isMain: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
var switchDNSStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.DNS_SWITCH], statuses.NOT_STARTED
);
return (
(
migrationStatus == statuses.FINISHED_OK ||
migrationStatus == statuses.FINISHED_WARNINGS ||
switchDNSStatus == statuses.FINISHED_OK ||
switchDNSStatus == statuses.FINISHED_WARNINGS ||
switchDNSStatus == statuses.REVERTED
) && !_isRunningOrQueued(subscriptionInfo)
);
},
titleMain: 'subscriptionsListActionResync',
titleGroupOperation: 'subscriptionsListButtonResyncTitle',
descriptionGroupOperation: 'subscriptionsListButtonResyncHint',
});
subscriptionOperations.push({
name: subscriptionOperation.POST_MIGRATION_CHECKS,
run: function(subscriptionNames, onSuccess) {
showPostMigrationChecksPopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return (
migrationStatus != statuses.NOT_STARTED && migrationStatus != statuses.CANCELLED &&
!_isRunningOrQueued(subscriptionInfo)
);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonPostMigrationChecksTitle',
descriptionGroupOperation: 'subscriptionsListButtonPostMigrationChecksHint',
titleMenu: 'subscriptionActionRunPostMigrationChecks',
});
subscriptionOperations.push({
name: subscriptionOperation.REVERT_DNS,
run: function(subscriptionNames, onSuccess) {
showRevertDnsPopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
var switchDnsStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.DNS_SWITCH], statuses.NOT_STARTED
);
return (
(
switchDnsStatus == statuses.FINISHED_OK ||
switchDnsStatus == statuses.FINISHED_WARNINGS
) && !_isRunningOrQueued(subscriptionInfo)
);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonRevertDnsTitle',
descriptionGroupOperation: 'subscriptionsListButtonRevertDnsHint',
titleMenu: 'subscriptionActionRevertDns',
});
subscriptionOperations.push({
name: subscriptionOperation.REMOVE_FROM_QUEUE,
run: function(subscriptionNames, onSuccess) {
showCancelPopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
return _isRunningOrQueued(subscriptionInfo);
},
isMain: function(subscriptionInfo) {
return _isRunningOrQueued((subscriptionInfo));
},
titleMain: 'subscriptionsListActionCancel',
titleGroupOperation: 'subscriptionsListButtonRemoveFromQueueTitle',
descriptionGroupOperation: 'subscriptionsListButtonRemoveFromQueueHint',
});
subscriptionOperations.push({
name: subscriptionOperation.REMOVE_MIGRATED,
run: function(subscriptionNames, onSuccess) {
showRemovePopup(subscriptionNames, onSuccess);
},
isApplicable: function(subscriptionInfo) {
var migrationStatus = getPropertyChain(
subscriptionInfo, ['operationStatus', subscriptionStatusOperation.MIGRATION], statuses.NOT_STARTED
);
return (
migrationStatus != statuses.NOT_STARTED && migrationStatus != statuses.CANCELLED &&
!_isRunningOrQueued(subscriptionInfo)
);
},
isMain: function(subscriptionInfo) { return false; },
titleGroupOperation: 'subscriptionsListButtonRemoveMigratedTitle',
descriptionGroupOperation: 'subscriptionsListButtonRemoveMigratedHint'
});
// TODO: implement support
/*
subscriptionOperations.push({
name: subscriptionOperation.SHOW_LOG,
run: function(subscriptionNames, onSuccess) {
},
isApplicable: function(subscriptionInfo) {
return subscriptionInfo.status != subscriptionStatus.NOT_STARTED;
},
isMain: function(subscriptionInfo) { return false; },
titleMenu: 'subscriptionActionShowLog')
});
*/
// Check whether there is any operation (migrating, switch DNS, post-migration checks, etc)
// that is queued or in progress
function _isRunningOrQueued(subscriptionInfo) {
var operations = getPropertyChain(subscriptionInfo, ['operationStatus'], {});
for (var operationName in operations) {
if (operations.hasOwnProperty(operationName)) {
if (
operations[operationName] == subscriptionStatus.QUEUED ||
operations[operationName] == subscriptionStatus.IN_PROGRESS
) {
return true;
}
}
}
return false;
}
// Find information about operation by its identifier
function findOperation(operationName) {
for (var i = 0; i < subscriptionOperations.length; i++) {
var operation = subscriptionOperations[i];
if (operation.name == operationName) {
return operation;
}
}
}

View File

@@ -1,105 +0,0 @@
// Copyright 1999-2017. Plesk International GmbH. All Rights Reserved.
var subscriptionStatus = {
NOT_STARTED: 'not-started',
REVERTED: 'reverted',
FINISHED_OK: 'finished-ok',
FINISHED_WARNINGS: 'finished-warnings',
FINISHED_ERRORS: 'finished-errors',
QUEUED: 'on-hold',
CANCELLED: 'cancelled',
IN_PROGRESS: 'in-progress'
};
var subscriptionStatuses = [];
subscriptionStatuses.push({
'name': subscriptionStatus.QUEUED,
'titleSubscriptionsList': 'subscriptionsListStatusQueued',
'imageSubscriptionsList': null,
'showDetailsAction': true
});
subscriptionStatuses.push({
'name': subscriptionStatus.CANCELLED,
'titleSubscriptionsList': 'subscriptionsListStatusCancelled',
'imageSubscriptionsList': null,
'showDetailsAction': true
});
subscriptionStatuses.push({
'name': subscriptionStatus.IN_PROGRESS,
'titleSubscriptionsList': 'subscriptionsListStatusInProgress',
'imageSubscriptionsList': migratorImage('subscription-status-in-progress.gif'),
'showDetailsAction': true
});
subscriptionStatuses.push({
'name': subscriptionStatus.NOT_STARTED,
'titleSubscriptionsList': 'subscriptionsListStatusNotStarted',
'imageSubscriptionsList': null,
'showDetailsAction': false
});
subscriptionStatuses.push({
'name': subscriptionStatus.FINISHED_OK,
'titleSubscriptionsList': 'subscriptionsListStatusFinishedOk',
'imageSubscriptionsList': migratorImage('subscription-status-success.png'),
'showDetailsAction': true
});
subscriptionStatuses.push({
'name': subscriptionStatus.FINISHED_WARNINGS,
'titleSubscriptionsList': 'subscriptionsListStatusFinishedWarnings',
'imageSubscriptionsList': migratorImage('subscription-status-warning.png'),
'showDetailsAction': true
});
subscriptionStatuses.push({
'name': subscriptionStatus.FINISHED_ERRORS,
'titleSubscriptionsList': 'subscriptionsListStatusFinishedErrors',
'imageSubscriptionsList': migratorImage('subscription-status-error.png'),
'showDetailsAction': true
});
var subscriptionStatusOperation = {
MIGRATION: 'migrated',
CONTENT_SYNC: 'content-synced',
CONFIGURATION_SYNC: 'configuration-synced',
EXTENSIONS_SYNC: 'extensions-synced',
DNS_SWITCH: 'dns-switched',
POST_MIGRATION_CHECKS: 'post-migration-checks'
};
var subscriptionStatusOperations = [];
var serverStatusOperations = [];
subscriptionStatusOperations.push({
name: subscriptionStatusOperation.MIGRATION,
titleSubscriptionsList: 'subscriptionsListOperationMigration',
displayAlways: true
});
subscriptionStatusOperations.push({
name: subscriptionStatusOperation.CONTENT_SYNC,
titleSubscriptionsList: 'subscriptionsListOperationContentSync',
displayAlways: false
});
serverStatusOperations.push({
name: subscriptionStatusOperation.CONFIGURATION_SYNC,
titleSubscriptionsList: 'subscriptionsListOperationConfigurationSync',
displayAlways: false
});
serverStatusOperations.push({
name: subscriptionStatusOperation.EXTENSIONS_SYNC,
titleSubscriptionsList: 'subscriptionsListOperationExtensionsSync',
displayAlways: false
});
subscriptionStatusOperations.push({
name: subscriptionStatusOperation.DNS_SWITCH,
titleSubscriptionsList: 'subscriptionsListOperationDnsSwitch',
displayAlways: false
});
subscriptionStatusOperations.push({
name: subscriptionStatusOperation.POST_MIGRATION_CHECKS,
titleSubscriptionsList: 'subscriptionsListOperationPostMigrationCheck',
displayAlways: false
});

View File

@@ -1,667 +0,0 @@
// Copyright 1999-2024. WebPros International GmbH. All rights reserved.
Jsw.onReady(function() {
const appState = PanelMigrator.initAppState();
// Global variable representing current status of migration. Updated periodically with AJAX request.
var statusData = MIGRATION_STATUS_DATA;
function createGroupOperationButton(operationName, onApplied) {
var operation = findOperation(operationName);
return {
componentType: 'Jsw.SmallButton',
id: 'button' + operation.name,
title: migratorLocale.lmsg(operation.titleGroupOperation),
description: migratorLocale.lmsg(operation.descriptionGroupOperation),
handler: function() {
runGroupOperation(operation, operationOnSuccessHandler(operation));
}
}
}
function operationOnSuccessHandler(operation)
{
var onSuccess = null;
if (operation.listReload) {
if (operation.showIPMapping) {
onSuccess = function () {
showIPMapping = true;
configureIPColumn();
list.reload();
};
} else {
onSuccess = function () {
list.reload();
};
}
} else {
onSuccess = resetSubscriptionSelection;
}
return onSuccess;
}
// Execute specified function for each subscription in the list.
// Callback function should accept 2 arguments - subscription name and list row (<tr>) element.
function foreachListSubscription(callback) {
$$('.subscription-name').each(function (element) {
var subscriptionName = element.textContent;
var row = element.up('tr');
callback(subscriptionName, row);
});
}
var showIPMapping = false;
// Get list of subscription names, selected for group operations by checkbox in the first column of the table
function getSelectedSubscriptions() {
var selectedSubscriptions = [];
foreachListSubscription(function(subscriptionName, row) {
var checkbox = row.select('input[type="checkbox"]').first();
if (checkbox.checked) {
selectedSubscriptions.push(subscriptionName);
}
});
return selectedSubscriptions;
}
// Reset selection of subscriptions for group operations. Use this function once some group operation was
// scheduled or started
function resetSubscriptionSelection() {
foreachListSubscription(function(subscriptionName, row) {
var checkbox = row.select('input[type="checkbox"]').first();
row.removeClassName('selected');
checkbox.checked = false;
});
$$('input[name="listGlobalCheckbox"]').each(function(checkbox) {
checkbox.checked = false;
});
}
// Run group operation for selected subscriptions.
function runGroupOperation(operation, onSuccess) {
if (!list.checkNonEmptySelection()) {
return;
}
var selectedSubscriptions = getSelectedSubscriptions();
var operationApplicable = true;
selectedSubscriptions.each(function(subscriptionName) {
var item = list.getSubscriptionItem(subscriptionName);
if (!operation.isApplicable(item)) {
operationApplicable = false;
}
});
if (operationApplicable) {
list.hideItemsInvalidStatusWarning();
} else {
list.showItemsInvalidStatusWarning();
return;
}
if (onSuccess) {
operation.run(selectedSubscriptions, onSuccess);
} else {
operation.run(selectedSubscriptions);
}
}
// Configure action handlers for per-subscription actions at the last column of the table,
// for example "Migrate", "Re-sync", etc.
function configureActionHandlers() {
foreachListSubscription(function(subscriptionName, row) {
subscriptionOperations.each(function(subscriptionOperator) {
observeClickOnChildElement(
row, 'action-' + subscriptionOperator.name, function(actionElement) {
subscriptionOperator.run([subscriptionName]);
}
);
});
subscriptionStatusOperations.each(function(subscriptionStatusOperation) {
observeClickOnChildElement(row, 'action-details-' + subscriptionStatusOperation.name, function() {
let issues = getPropertyChain(statusData, ['subscriptionIssues', subscriptionName], []).filter(function(issue) {
return issue.executionCommandOperation === subscriptionStatusOperation.name;
});
showIssuesPopupDialog(
migratorLocale.lmsg('issuesPopupTitleSubscription', {'subscription': subscriptionName}),
issues
);
});
});
serverStatusOperations.each(function(serverOperation) {
const entityName = serverOperation.name.split('-')[0].replace(/^./, char => char.toUpperCase());
observeClickOnChildElement(row, `action-details-${serverOperation.name}`, function() {
const issues = getPropertyChain(statusData, ['serverSettingIssues', entityName], []);
showIssuesPopupDialog(
migratorLocale.lmsg(`issuesPopupTitle${entityName}`),
issues
);
});
});
});
}
// Configure IP column: display icon with tooltip or full mapping text, create tooltip
function configureIPColumn()
{
foreachListSubscription(function(subscriptionName, row) {
var ipMappingBlock = row.select('div[class="ipMappingBlock"]').first();
var ipMappingTooltip = row.select('div[class="ipMappingTooltip"]').first();
ipMappingBlock.toggle(showIPMapping);
ipMappingTooltip.toggle(!showIPMapping);
if (!showIPMapping) {
Jsw.Tooltip.init(ipMappingTooltip, {text: ipMappingBlock.innerHTML});
}
});
}
// Configure owner column: display hint
function configureOwnerColumn()
{
foreachListSubscription(function(subscriptionName, row) {
var ownerBlock = row.select('div[class="ownerBlock"]').first();
var ownerTooltipBlock = row.select('div[class="ownerTooltipBlock"]').first();
Jsw.Tooltip.init(ownerBlock, {text: ownerTooltipBlock.innerHTML});
});
}
// Create subscriptions list table, with group operations and search
var groupOperations = [];
groupOperations.push(createGroupOperationButton(subscriptionOperation.MIGRATE));
groupOperations.push({
componentType: 'Jsw.bar.Separator'
});
if (IS_DNS_SWITCH_SUPPORTED) {
groupOperations.push(createGroupOperationButton(subscriptionOperation.SWITCH_DNS));
}
groupOperations.push({
componentType: 'Jsw.list.AdditionalActions',
title: migratorLocale.lmsg('subscriptionsListButtonReassignTitle'),
operations: [
createGroupOperationButton(subscriptionOperation.REASSIGN_OWNER),
createGroupOperationButton(subscriptionOperation.REASSIGN_PLAN),
createGroupOperationButton(subscriptionOperation.RESET_REASSIGN)
]
});
var ipOperations = [
{
componentType: 'Jsw.SmallButton',
id: 'buttonShowIpMapping',
title: migratorLocale.lmsg('subscriptionsListButtonShowIpMappingTitle'),
description: migratorLocale.lmsg('subscriptionsListButtonShowIpMappingHint'),
handler: function() {
showIPMapping = true;
configureIPColumn();
}
}
];
if (IS_PLESK_MULTISERVER) {
ipOperations.push(createGroupOperationButton(subscriptionOperation.SELECT_NODE));
} else {
ipOperations.push(createGroupOperationButton(subscriptionOperation.CHANGE_IP_MAPPING));
}
groupOperations.push({
componentType: 'Jsw.list.AdditionalActions',
title: migratorLocale.lmsg('subscriptionsListButtonIpAddressesTitle'),
operations: ipOperations
});
groupOperations.push(createGroupOperationButton(subscriptionOperation.RESYNC));
groupOperations.push(createGroupOperationButton(subscriptionOperation.POST_MIGRATION_CHECKS));
groupOperations.push({
componentType: 'Jsw.bar.Separator'
});
if (IS_DNS_SWITCH_SUPPORTED) {
groupOperations.push(createGroupOperationButton(subscriptionOperation.REVERT_DNS));
}
groupOperations.push(createGroupOperationButton(subscriptionOperation.REMOVE_FROM_QUEUE));
groupOperations.push(createGroupOperationButton(subscriptionOperation.REMOVE_MIGRATED));
var menuActions = [
subscriptionOperation.SWITCH_DNS,
subscriptionOperation.REVERT_DNS,
subscriptionOperation.REASSIGN_OWNER,
subscriptionOperation.REASSIGN_PLAN,
subscriptionOperation.RESET_REASSIGN,
subscriptionOperation.CHANGE_IP_MAPPING,
subscriptionOperation.POST_MIGRATION_CHECKS
// TODO: implement support
/* subscriptionOperation.SHOW_LOG */
];
var listItemActions = {};
menuActions.each(function(menuAction) {
var operation = findOperation(menuAction);
listItemActions[menuAction] = function(item) {
var onSuccess = operationOnSuccessHandler(operation);
operation.run([item.subscription], onSuccess);
}
});
var SubscriptionsList = Class.create(Jsw.List, {
_splitListData: function($super, listData, place) {
if (!listData || !listData.data) {
return false;
}
var self = this;
listData.data.each(function(item) {
item.actions = self.getItemActions(item);
});
$super(listData, place);
},
getSubscriptionItem: function(subscriptionName) {
for (var i = 0; i < this._data.length; i++) {
var item = this._data[i];
if (item.subscription == subscriptionName) {
return item;
}
}
},
getItemActions: function(item) {
var actions = [];
menuActions.each(function(menuAction) {
var operation = findOperation(menuAction);
if (operation.isApplicable(item)) {
actions.push({
'name': menuAction,
'title': migratorLocale.lmsg(operation.titleMenu),
'href': 'javascript:;'
});
}
});
return actions;
},
updateSubscriptionStatus: function(subscriptionName, operationStatus) {
var changed = false;
for (var i = 0; i < this._data.length; i++) {
var item = this._data[i];
var subscriptionOperationStatus = getPropertyChain(
statusData, ['subscriptions', item.subscription, 'operationStatus'], null
);
if (!(objectsEqual(item.operationStatus, subscriptionOperationStatus))) {
item.operationStatus = subscriptionOperationStatus;
item.actions = this.getItemActions(item);
changed = true;
}
}
if (changed) {
this._contextMenu.onRedraw();
}
},
_itemActions: listItemActions,
showItemsInvalidStatusWarning: function() {
this.hideItemsInvalidStatusWarning();
var element = this._componentElement.down('items-invalid-status-warning');
if (element) {
element.show();
} else {
this._componentElement.down('.actions-box').insert({
top: (
'<div class="actions-msg-container" id="items-invalid-status-warning">' +
'<span class="list-actions-msg">' +
'<span>' +
migratorLocale.lmsg('subscriptionsListOperationsCanNotBeApplied') +
'</span>' +
'</span>' +
'</div>'
)
});
}
},
hideItemsInvalidStatusWarning: function() {
var element = this._componentElement.down('.actions-msg-container');
if (element) {
element.hide();
}
}
});
var list = new SubscriptionsList({
id: 'migration-subscriptions-list',
data: SUBSCRIPTIONS_LIST_DATA,
dataUrl: URL_SUBSCRIPTIONS_LIST,
searchFilters: SUBSCRIPTIONS_LIST_FILTER_CONFIG,
searchOveral: 'subscription',
operations: groupOperations,
itemActions: listItemActions,
columns: [
Jsw.list.COLUMN_SELECTION,
{
header: migratorLocale.lmsg('subscriptionsListTableSubscription'),
dataIndex: 'subscription',
sortable: true,
renderer: function(item, isDisabled) {
var html = '';
// Hidden content to identify subscription name for each table row
html += '<div class="subscription-name" style="display: none;">';
html += formatStr(item.subscription);
html += '</div>';
html += '<div class="subscription-name-normalized" style="display: none;">';
html += formatStr(item.subscriptionNameNormalized);
html += '</div>';
// Displayed content: 2 blocks:
// 1) Plain subscription name, if subscription does not exist in Plesk
// 2) Subscription name with link to overview page in Plesk, if subscription exists in Plesk
html += '<span class="subscription-name-plain">';
html += formatStr(item.subscription);
html += '</span>';
html += '<span class="subscription-name-link" style="display: none;">';
html += '<a href="">' + formatStr(item.subscription) + '</a>';
html += '</span>';
return html;
}
},
{
header: migratorLocale.lmsg('subscriptionsListTableOwner'),
dataIndex: 'owner',
renderer: function(item, isDisabled) {
var html = '';
// Format tooltip block: invisible, but used by configureOwnerColumn funtion, which creates
// tooltip control
html += '<div class="ownerTooltipBlock" style="display: none">';
function formatTitleTooltip(login, title) {
if (title) {
return title.escapeHTML() + ' (' + login.escapeHTML() + ')';
} else {
return login.escapeHTML();
}
}
if (item.ownerResellerLogin) {
if (item.ownerCustomerLogin) {
html += formatMessage(
migratorLocale.lmsg('hintOwnerByCustomerOwnedByReseller'),
formatTitleTooltip(item.ownerCustomerLogin, item.ownerCustomerTitle),
formatTitleTooltip(item.ownerResellerLogin, item.ownerResellerTitle)
);
} else {
html += formatMessage(
migratorLocale.lmsg('hintOwnedByReseller'),
formatTitleTooltip(item.ownerResellerLogin, item.ownerResellerTitle)
);
}
} else if (item.ownerCustomerLogin) {
html += formatMessage(
migratorLocale.lmsg('hintOwnerByCustomer'),
formatTitleTooltip(item.ownerCustomerLogin, item.ownerCustomerTitle)
);
} else {
html += migratorLocale.lmsg('hintOwnedByAdministrator');
}
html += '</div>';
// Format regularly displayed block
html += '<div class="ownerBlock">';
function formatTitleTable(login, title) {
if (title) {
return title.escapeHTML();
} else {
return login.escapeHTML();
}
}
if (item.ownerResellerLogin) {
html +=
'<div><img src="' + migratorImage('subscriptions-list-reseller.png') + '" alt="Reseller">' +
formatTitleTable(item.ownerResellerLogin, item.ownerResellerTitle) +
'</div>';
}
if (item.ownerCustomerLogin) {
html +=
'<div>' +
formatTitleTable(item.ownerCustomerLogin, item.ownerCustomerTitle) +
'</div>';
}
if (!item.ownerCustomerLogin && !item.ownerResellerLogin) {
html +=
'<div>' +
migratorLocale.lmsg('administratorTitle') +
'</div>';
}
if (item.reassignOwner) {
html +=
'<div class="reassign-text">(' +
formatMessage(migratorLocale.lmsg('reassignedTo'), item.reassignOwner.escapeHTML()) +
')</div>';
}
html += '</div>';
return html
},
sortable: true
},
{
header: migratorLocale.lmsg('subscriptionsListTablePlan'),
dataIndex: 'plan',
renderer: function(item, isDisabled) {
var html = '<div>' + item.plan.escapeHTML() + '</div>';
if (item.reassignPlan) {
html += (
'<div class="reassign-text">(' +
formatMessage(migratorLocale.lmsg('reassignedTo'), item.reassignPlan.escapeHTML()) +
')</div>'
);
}
return html
},
sortable: true
},
{
header: migratorLocale.lmsg('subscriptionsListTableIP'),
dataIndex: 'ip',
sortable: true,
renderer: function(item, isDisabled) {
var ipBlock = '';
if (HAS_IPV6_ADDRESSES || item.nodeIP) {
ipBlock += '<div>' + formatMessage(migratorLocale.lmsg('ipv4Address'), item.ipv4) + '</div>';
ipBlock += '<div>' + formatMessage(migratorLocale.lmsg('ipv6Address'), item.ipv6) + '</div>';
if (item.nodeIP) {
ipBlock += '<div>' + formatMessage(migratorLocale.lmsg('nodeIP'), item.nodeIP) + '</div>';
}
} else {
ipBlock += item.ipv4;
}
var html = '';
html += '<div style="display: none;" class="ipMappingBlock">' + ipBlock + '</div>';
html += '<div style="display: none;" class="ipMappingTooltip"><img src="' + migratorImage('server-info-toolbar-subscriptions.png') + '"></div>';
return html;
}
},
{
header: migratorLocale.lmsg('subscriptionsListTableStatus'),
dataIndex: 'status',
sortable: true,
renderer: function (item, isDisabled) {
var html = '';
subscriptionStatusOperations.concat(serverStatusOperations).each(function(subscriptionStatusOperation) {
subscriptionStatuses.each(function(subscriptionStatus) {
html += '<div class="subscription-status-' + subscriptionStatus.name + '-' + subscriptionStatusOperation.name + '" style="display: none;">';
if (subscriptionStatus.imageSubscriptionsList) {
html += '<img src="' + subscriptionStatus.imageSubscriptionsList + '" style="width: 16px; height: 16px;">&nbsp;';
} else {
html += '<img src="' + migratorImage('server-info-toolbar-subscriptions.png') + '" style="width: 16px; height: 16px;">&nbsp;';
}
html += migratorLocale.lmsg(subscriptionStatusOperation.titleSubscriptionsList) + ' - <span class="status-text-' + subscriptionStatus.name + '">';
html += migratorLocale.lmsg(subscriptionStatus.titleSubscriptionsList);
html += '</span>';
if (subscriptionStatus.showDetailsAction) {
html += '&nbsp;';
html += '<a class="action-details-' + subscriptionStatusOperation.name + '" href="javascript:;">' + migratorLocale.lmsg('actionDetails') + '</a>';
}
html += '</div>';
});
});
return html;
}
},
{
header: migratorLocale.lmsg('subscriptionsListTableActions'),
dataIndex: 'actions',
sortable: false,
renderer: function(item, isDisabled) {
var html = '';
subscriptionOperations.each(function(subscriptionOperation) {
if (!migratorLocale.lmsg(subscriptionOperation.titleMain)) {
return;
}
html += '<div class="subscription-main-action-' + subscriptionOperation.name + '" style="display: none;">';
html += '<a href="javascript:;" class="action-' + subscriptionOperation.name + '">';
html += migratorLocale.lmsg(subscriptionOperation.titleMain);
html += '</a>';
html += '</div>';
});
return html;
}
},
Jsw.list.COLUMN_ACTIONS
],
onRedraw: function() {
configureActionHandlers();
configureIPColumn();
configureOwnerColumn();
}
});
new Jsw.Panel({
cls: 'list-box',
renderTo: 'main',
items: [list]
});
function updateMigrationStatus()
{
foreachListSubscription(function(subscriptionName, row) {
var subscriptionInfo = getPropertyChain(statusData, ['subscriptions', subscriptionName], {});
var operationStatus = getPropertyChain(subscriptionInfo, ['operationStatus'], {});
// Toggle operations menu
subscriptionStatusOperations.each(function(subscriptionStatusOperation) {
var currentSubscriptionStatus = getPropertyChain(
operationStatus, [subscriptionStatusOperation.name], statuses.NOT_STARTED
);
subscriptionStatuses.each(function(currentStatus) {
toggleChildElement(
row, 'subscription-status-' + currentStatus.name + '-' + subscriptionStatusOperation.name,
(
currentSubscriptionStatus == currentStatus.name &&
(
currentStatus.name != statuses.NOT_STARTED ||
subscriptionStatusOperation.displayAlways
)
)
)
});
});
serverStatusOperations.each(function(serverOperation) {
const entity = serverOperation.name.split('-')[0];
let status = getPropertyChain(statusData, ['serverSettingsStatuses', entity], null);
if (status !== null) {
subscriptionStatuses.each(function(currentStatus) {
toggleChildElement(
row, 'subscription-status-' + currentStatus.name + '-' + serverOperation.name,
(
status === currentStatus.name
)
)
});
}
});
// Toggle main operation
subscriptionOperations.each(function(subscriptionOperation) {
toggleChildElement(
row, 'subscription-main-action-' + subscriptionOperation.name,
subscriptionOperation.isMain(subscriptionInfo)
)
});
// Toggle details button
subscriptionStatusOperations.each(function(subscriptionStatusOperation) {
var issues = getPropertyChain(
statusData, ['subscriptionIssues', subscriptionName], []
).filter(
function (issue) {
return issue.executionCommandOperation == subscriptionStatusOperation.name;
}
);
toggleChildElement(
row,
'action-details-' + subscriptionStatusOperation.name, issues.length > 0
);
});
serverStatusOperations.each(function(serverOperation) {
const entityName = serverOperation.name.split('-')[0].replace(/^./, char => char.toUpperCase());
const issues = getPropertyChain(statusData, ['serverSettingIssues', entityName], []);
toggleChildElement(
row,
`action-details-${serverOperation.name}`,
issues.length > 0
);
});
// Update subscription name column - show link to subscription overview page if subscription
// exists in Plesk
var subscriptionNameNormalized = getChildElementText(row, 'subscription-name-normalized');
var pleskSubscriptionUrl = getPropertyChain(
statusData, ['pleskSubscriptionUrls', subscriptionNameNormalized], null
);
var linkExists = pleskSubscriptionUrl !== null;
toggleChildElement(row, 'subscription-name-plain', !linkExists);
toggleChildElement(row, 'subscription-name-link', linkExists);
if (pleskSubscriptionUrl) {
var link = row.select('.subscription-name-link').first().select('a').first();
link.writeAttribute('href', pleskSubscriptionUrl);
}
});
list.updateSubscriptionStatus();
}
// Update status of each subscription periodically with AJAX
function periodicUpdateMigrationStatus() {
if (!appState.mounted) return;
new Ajax.Request(URL_GET_MIGRATION_STATUS, {
onSuccess: function (response) {
if (!appState.mounted) return;
// assign new status data into global variable
statusData = response.responseText.evalJSON();
updateMigrationStatus();
},
onComplete: function() {
setTimeout(function() {periodicUpdateMigrationStatus()}, 2000);
}
})
}
updateMigrationStatus();
periodicUpdateMigrationStatus();
});

View File

@@ -1,710 +0,0 @@
// Copyright 1999-2024. WebPros International GmbH. All rights reserved.
Jsw.onReady(function() {
const appState = PanelMigrator.initAppState();
var severityLevel = {
INFO: 1,
ERROR: 2,
WARNING: 3,
DEBUG: 4,
EXCEPTION: 5,
MIGRATOR_EXECUTION: 6
};
var severityProperties = {};
severityProperties[severityLevel.INFO] = {
'title': 'Info',
'rowCssClass': 'plesk-migrator-log-row-severity-info',
'severityCellCssClass': 'plesk-migrator-log-cell-severity-info'
};
severityProperties[severityLevel.ERROR] = {
'title': 'Error',
'rowCssClass': 'plesk-migrator-log-row-severity-error',
'severityCellCssClass': 'plesk-migrator-log-cell-severity-error'
};
severityProperties[severityLevel.WARNING] = {
'title': 'Warning',
'rowCssClass': 'plesk-migrator-log-row-severity-warning',
'severityCellCssClass': 'plesk-migrator-log-cell-severity-warning'
};
severityProperties[severityLevel.DEBUG] = {
'title': 'Debug',
'rowCssClass': 'plesk-migrator-log-row-severity-debug',
'severityCellCssClass': 'plesk-migrator-log-cell-severity-debug'
};
severityProperties[severityLevel.EXCEPTION] = {
'title': 'Exception',
'rowCssClass': 'plesk-migrator-log-row-severity-debug',
'severityCellCssClass': 'plesk-migrator-log-cell-severity-debug'
};
severityProperties[severityLevel.MIGRATOR_EXECUTION] = {
'title': 'Migrator execution',
'rowCssClass': 'plesk-migrator-log-row-severity-migrator-execution',
'severityCellCssClass': 'plesk-migrator-log-cell-severity-migrator-execution'
};
var LogRecords = Class.create({
initialize: function() {
this._records = {}; // recordId => LogRecord
this._expandedRecords = {};
this._rootRecords = [];
this._inProgressRecords = {};
this._htmlLogTable = $('migration-log-table');
this._htmlLogTableBody = this._htmlLogTable.select('tbody').first();
this._showDebug = false;
this._highlightText = null;
this._filterText = null;
},
appendRecords: function(recordsData) {
for (var i = 0; i < recordsData.length; i++) {
var recordData = recordsData[i];
this.appendRecord(recordData);
}
},
appendRecord: function(recordData) {
if (this._records[recordData.recordId]) {
var existingRecord = this._records[recordData.recordId];
this.updateRecordExpandability(existingRecord);
if (recordData.finished) {
existingRecord.finishRecord();
delete this._inProgressRecords[existingRecord.getRecordId()];
}
existingRecord.updateRecordChildErrorMark(recordData.hasChildErrors, recordData.hasChildWarnings);
return;
}
var parentRecord = null;
var rootParentRecordId = 2147483647;
if (recordData.parentRecordId != rootParentRecordId) {
parentRecord = this._records[recordData.parentRecordId];
}
var record = new LogRecord(this, recordData, parentRecord);
this._records[record.getRecordId()] = record;
if (!record.isFinished()) {
this._inProgressRecords[record.getRecordId()] = record;
}
if (parentRecord) {
parentRecord.appendChildRecord(record);
parentRecord.getHtmlEndRow().insert({before: record.getHtmlRow()});
parentRecord.getHtmlEndRow().insert({before: record.getHtmlEndRow()});
this.updateRecordExpandability(parentRecord);
} else {
this._htmlLogTableBody.insert(record.getHtmlRow());
this._htmlLogTableBody.insert(record.getHtmlEndRow());
this._rootRecords.push(record);
}
record.setCollapsed();
this.updateRecordExpandability(record);
record.highlightText(this._highlightText);
this.updateRecordVisibility(record);
},
expandRecord: function(record) {
this.expandRecordsByIds([record.getRecordId()]);
},
expandRecordsByIds: function(recordIds) {
var self = this;
var collapsedRecordIds = [];
for (var i = 0; i < recordIds.length; i++) {
var recordId = recordIds[i];
if (self._expandedRecords[recordId] != 1) {
collapsedRecordIds.push(recordId);
}
}
if (collapsedRecordIds.length == 0) {
return
}
var requestFunctions = [];
// divide list of records into parts, to handle long lists of expanded records:
// when there are too many records in a single AJAX request, backend could
// fail to respond (because of memory limit on response, or max execution time of PHP or CGI).
var maxPartSize = 50;
var collapsedRecordIdsParts = divideIntoParts(collapsedRecordIds, maxPartSize);
collapsedRecordIdsParts.forEach(function(collapsedRecordIdsPart) {
requestFunctions.push(function (onSuccess) {
new Ajax.Request(URL_GET_LOG_RECORDS, {
// perform POST request as list of parent IDs could be long and exceed URL length limit
// (the problem is more actual for IIS which has more strict limits)
method: 'post',
parameters: {
'parent-ids': collapsedRecordIdsPart.join()
},
onSuccess: function (response) {
var recordsData = response.responseText.evalJSON();
self.appendRecords(recordsData);
for (var i = 0; i < collapsedRecordIdsPart.length; i++) {
var recordId = collapsedRecordIdsPart[i];
self._records[recordId].setExpanded();
self._expandedRecords[recordId] = 1;
for (var j = 0; j < self._records[recordId].getChildRecords().length; j++) {
var childRecord = self._records[recordId].getChildRecords()[j];
self.updateRecordVisibility(childRecord);
}
}
},
onComplete: function() {
onSuccess();
}
});
});
});
callAsyncFunctionsChain(requestFunctions);
},
expandRecordsByIdsRaw: function(recordIds) {
var self = this;
for (var i = 0; i < recordIds.length; i++) {
var recordId = recordIds[i];
if (self._expandedRecords[recordId] == 1) {
continue;
}
if (!self._records[recordId].isExpandable()) {
continue;
}
self._records[recordId].setExpanded();
self._expandedRecords[recordId] = 1;
for (var j = 0; j < self._records[recordId].getChildRecords().length; j++) {
var childRecord = self._records[recordId].getChildRecords()[j];
self.updateRecordVisibility(childRecord);
}
}
},
collapseRecord: function(record) {
for (var i = 0; i < record.getChildRecords().length; i++) {
var childRecord = record.getChildRecords()[i];
for (var j = 0; j < childRecord.getChildRecords().length; j++) {
var childChildRecord = childRecord.getChildRecords()[j];
this._removeRecord(childChildRecord);
}
childRecord.removeAllChildRecords();
childRecord.hide();
childRecord.setCollapsed();
delete this._expandedRecords[childRecord.getRecordId()];
}
record.setCollapsed();
delete this._expandedRecords[record.getRecordId()];
},
_removeRecord: function(record) {
for (var i = 0; i < record.getChildRecords().length; i++) {
var childRecord = record.getChildRecords()[i];
this._removeRecord(childRecord);
}
delete this._records[record.getRecordId()];
record.getHtmlRow().remove();
record.getHtmlEndRow().remove();
},
toggleDebug: function() {
var self = this;
this._showDebug = !this._showDebug;
this._foreachRecord(function(record) {
self.updateRecordVisibility(record);
});
this._foreachRecord(function(record) {
self.updateRecordExpandability(record);
});
},
getExpandedRecordIds: function() {
return Object.keys(this._expandedRecords);
},
getInProgressRecords: function () {
return this._inProgressRecords;
},
getRootRecords: function() {
return this._rootRecords;
},
setHighlightText: function(searchText) {
var self = this;
this._highlightText = searchText;
this._foreachRecord(function(record) {
record.highlightText(searchText)
});
this._foreachRecord(function(record) {
self.updateRecordExpandability(record);
});
},
setFilterText: function(searchText) {
var self = this;
this._filterText = searchText;
this._foreachRecord(function(record) {
self.updateRecordVisibility(record);
});
this._foreachRecord(function(record) {
self.updateRecordExpandability(record);
});
},
updateRecordVisibility: function(record) {
if (this._isFiltered(record)) {
record.hide();
return;
}
if (record.getParentRecord() &&!record.getParentRecord().isExpanded()) {
record.hide();
return;
}
record.show();
},
updateRecordExpandability: function(record) {
for (var i = 0; i < record.getChildRecords().length; i++) {
var childRecord = record.getChildRecords()[i];
if (!this._isFiltered(childRecord)) {
record.setExpandable(true);
return;
}
}
record.setExpandable(false);
},
_foreachRecord: function(callback) {
var self = this;
Object.keys(this._records).forEach(function(key, index) {
var record = self._records[key];
callback(record);
});
},
_isFiltered: function(record) {
return (
(record.isDebug() && !this._showDebug) ||
(
this._filterText &&
!(record.getMessage().toLowerCase().indexOf(this._filterText.toLowerCase()) > -1)
)
);
}
});
var LogRecord = Class.create({
initialize: function(logRecords, logRecordData, parentRecord) {
this._logRecords = logRecords;
this._childRecords = [];
this._recordId = logRecordData.recordId;
this._severity = logRecordData.severity;
this._time = logRecordData.time;
this._message = logRecordData.message;
this._finished = logRecordData.finished;
this._parentRecord = parentRecord;
this._isExpandable = false;
this._initializeHtml();
this.updateRecordChildErrorMark(logRecordData.hasChildErrors, logRecordData.hasChildWarnings);
},
_initializeHtml: function() {
var messageCellProperties = {
'style': 'white-space: pre-wrap; word-wrap: break-word; padding-left: ' + (this.getLevel() * 50) + 'px',
'class': 'messageText'
};
var severityDescriptor = severityProperties[this._severity];
var rowProperties = {'class': severityDescriptor.rowCssClass + ' logItemRow', 'style': 'display: none'};
var severityCellProperties = {
'class': severityDescriptor.severityCellCssClass,
'style': 'white-space: nowrap'
};
this._htmlRow = new Element('tr', rowProperties);
this._htmlTimeCol = new Element('td', {'class': 'logRecordDate'}).update(this._time.escapeHTML());
this._htmlErrorIcon = new Element(
'img', {
'src': migratorImage('log/error.png'),
'style': 'width: 16px; height: 16px; margin-left: 8px; display: none;'
}
);
this._htmlWarningIcon = new Element(
'img', {
'src': migratorImage('log/warning.png'),
'style': 'width: 16px; height: 16px; margin-left: 8px; display: none;'
}
);
this._htmlSeverityCol = new Element('td', severityCellProperties).update(
severityDescriptor.title.escapeHTML()
).insert(this._htmlErrorIcon).insert(this._htmlWarningIcon);
this._htmlMessageCol = new Element('td', messageCellProperties);
var htmlMessageColContainer = new Element('div', {'class': 'plesk-migrator-log-container-message-column'});
this._htmlWorkingContainer = new Element('div', {'class': 'plesk-migrator-log-working-container'});
this._htmlExpandContainer = new Element('div', {'class': 'plesk-migrator-log-expand-container'});
this._htmlMessageContainer = new Element('div', {'class': 'plesk-migrator-log-message-container'});
this._htmlMessageContainer.update(this._message.escapeHTML());
htmlMessageColContainer.insert(this._htmlWorkingContainer);
htmlMessageColContainer.insert(this._htmlExpandContainer);
htmlMessageColContainer.insert(this._htmlMessageContainer);
this._htmlMessageCol.insert(htmlMessageColContainer);
this._htmlExpandIcon = new Element(
'img', {
'src': migratorImage('log-expand-icon.gif'),
'class': 'plesk-migrator-expand-image',
'style': 'display: none'
}
);
this._htmlCollapseIcon = new Element(
'img', {
'src': migratorImage('log-collapse-icon.gif'),
'class': 'plesk-migrator-expand-image',
'style': 'display: none'
}
);
if (!this._finished) {
this._htmlWorkingIcon = new Element(
'img', {
'src': migratorImage('log-record-working.gif'),
'style': 'width: 16px; height: 16px;'
}
);
this._htmlWorkingContainer.insert(this._htmlWorkingIcon);
} else {
this._htmlWorkingIcon = null;
}
this._htmlExpandContainer.insert(this._htmlExpandIcon);
this._htmlExpandContainer.insert(this._htmlCollapseIcon);
this._htmlRow.insert(this._htmlTimeCol);
this._htmlRow.insert(this._htmlSeverityCol);
this._htmlRow.insert(this._htmlMessageCol);
this._expanded = false;
this._endHtmlRow = new Element('tr', {'style': 'display: none'});
},
appendChildRecord: function(record) {
this._childRecords.push(record);
},
getChildRecords: function() {
return this._childRecords;
},
removeAllChildRecords: function() {
this._childRecords = [];
},
getHtmlRow: function() {
return this._htmlRow;
},
// Get fake hidden HTML row, which marks place right after the last child record.
// So, DOM tree will look like:
// <tr>This log record</tr>
// <tr>Child record #1</tr>
// <tr>Child record #2</tr>
// ...
// <tr>Child record #N (last child record)</tr>
// <tr>End record (hidden)</tr>
getHtmlEndRow: function () {
return this._endHtmlRow;
},
getRecordId: function() {
return this._recordId;
},
getMessage: function() {
return this._message;
},
getParentRecord: function() {
return this._parentRecord;
},
getLevel: function() {
var i = 0;
var parent = this.getParentRecord();
while (parent) {
i++;
parent = parent.getParentRecord();
}
return i;
},
hide: function() {
this.getHtmlRow().hide();
},
show: function() {
this.getHtmlRow().show();
},
setExpandable: function(isExpandable) {
this._isExpandable = isExpandable;
if (isExpandable) {
if (this._expanded) {
this._htmlCollapseIcon.show();
this._htmlExpandIcon.hide();
} else {
this._htmlCollapseIcon.hide();
this._htmlExpandIcon.show();
}
} else {
this._htmlCollapseIcon.hide();
this._htmlExpandIcon.hide();
}
},
isExpandable: function() {
return this._isExpandable;
},
setExpanded: function() {
var record = this;
this._htmlCollapseIcon.show();
this._htmlExpandIcon.hide();
this._htmlExpandContainer.stopObserving('click');
this._htmlExpandContainer.observe(
'click', function() {
record._logRecords.collapseRecord(record);
}
);
this._expanded = true;
},
setCollapsed: function() {
var record = this;
this._htmlCollapseIcon.hide();
this._htmlExpandIcon.show();
this._htmlExpandContainer.stopObserving('click');
this._htmlExpandContainer.observe(
'click', function () {
record._logRecords.expandRecord(record);
}
);
this._expanded = false;
},
finishRecord: function() {
this._finished = true;
if (this._htmlWorkingIcon) {
this._htmlWorkingIcon.remove();
this._htmlWorkingIcon = null;
}
},
updateRecordChildErrorMark: function(hasChildErrors, hasChildWarnings) {
if (hasChildErrors) {
this._htmlWarningIcon.hide();
this._htmlErrorIcon.show();
} else if (hasChildWarnings) {
this._htmlWarningIcon.show();
}
},
isFinished: function() {
return this._finished;
},
isExpanded: function() {
return this._expanded;
},
isDebug: function() {
return this._severity == severityLevel.DEBUG || this._severity == severityLevel.EXCEPTION;
},
highlightText: function(searchText) {
this._htmlMessageContainer.update(highlight(this._message, searchText));
}
});
function divideIntoParts(list, maxPartSize)
{
var parts = [];
for (var i = 0; i < list.length; i+= maxPartSize) {
parts.push(list.slice(i, i + maxPartSize))
}
return parts;
}
// Call chain of asynchronous functions, one-by-one: the first function is called, when it completes its
// async execution, the second function is called, when it completes its async execution, the third function
// is called, and so on.
// "functions" argument is a list, each item is a function, which accepts single argument - callback,
// which must be called by the function once it completes its async execution.
function callAsyncFunctionsChain(functions)
{
if (functions.length == 0) {
return;
}
var functionId = 0;
function callNextRequestFunction() {
if (functionId >= functions.length) {
return;
}
functions[functionId](function() {
functionId++;
setTimeout(function() {callNextRequestFunction();}, 0);
});
}
callNextRequestFunction();
}
// Update log periodically with AJAX
function periodicUpdateLog() {
if (!appState.mounted) return;
var rootParentRecordId = 2147483647;
var lastRootRecordId = rootParentRecordId;
var rootRecords = logRecords.getRootRecords();
if (rootRecords.length > 0) {
lastRootRecordId = rootRecords[rootRecords.length - 1].getRecordId();
}
var recordIdPairs = [
rootParentRecordId + '.' + lastRootRecordId
];
var inProgressRecs = logRecords.getInProgressRecords();
for (var recId in inProgressRecs) {
if (inProgressRecs.hasOwnProperty(recId)) {
var inProgressRecord = inProgressRecs[recId];
var childRecords = inProgressRecord.getChildRecords();
var lastChildRecordId = rootParentRecordId;
if (childRecords.length > 0) {
lastChildRecordId = childRecords[childRecords.length - 1].getRecordId();
}
recordIdPairs.push(inProgressRecord.getRecordId() + "." + lastChildRecordId)
}
}
var url = URL_GET_LOG_UPDATES;
if ($('automaticExpandBottom').checked) {
url += '/get-all-new-records/true';
}
new Ajax.Request(url, {
// perform POST request as list of parent IDs could be long and exceed URL length limit
// (the problem is more actual for IIS which has more strict limits)
method: 'post',
parameters: {
'in-progress-record-ids': recordIdPairs.join(",")
},
onSuccess: function (response) {
if (!appState.mounted) return;
var recordsData = response.responseText.evalJSON();
if (recordsData.length > 0) {
logRecords.appendRecords(recordsData);
if ($('automaticExpandBottom').checked) {
var recordIds = [];
recordsData.forEach(function (recordData) {
recordIds.push(recordData.recordId);
});
logRecords.expandRecordsByIdsRaw(recordIds);
}
if ($('automaticScrollBottom').checked) {
scrollToBottom();
}
}
},
onComplete: function() {
setTimeout(function() {periodicUpdateLog()}, 2000);
}
});
}
function scrollToBottom() {
window.scrollTo(0, document.body.scrollHeight);
}
function synchronizeScrollCheckboxes() {
$('automaticScrollTop').observe('change', function (e) {
$('automaticScrollBottom').checked = $('automaticScrollTop').checked;
});
$('automaticScrollBottom').observe('change', function (e) {
$('automaticScrollTop').checked = $('automaticScrollBottom').checked;
});
}
function observeDebugCheckboxes() {
$('showDebugTop').observe('change', function (e) {
$('showDebugBottom').checked = $('showDebugTop').checked;
logRecords.toggleDebug();
});
$('showDebugBottom').observe('change', function (e) {
$('showDebugTop').checked = $('showDebugBottom').checked;
logRecords.toggleDebug();
});
}
function synchronizeAutomaticExpandCheckboxes() {
$('automaticExpandTop').observe('change', function (e) {
$('automaticExpandBottom').checked = $('automaticExpandTop').checked;
});
$('automaticExpandBottom').observe('change', function (e) {
$('automaticExpandTop').checked = $('automaticExpandBottom').checked;
});
}
function observeSearch() {
function startSearch(searchText) {
if (!searchText) {
return;
}
new Ajax.Request(URL_SEARCH_LOG_RECORDS, {
parameters: {
'search-text': searchText
},
onSuccess: function (response) {
var parentRecordIds = response.responseText.evalJSON();
logRecords.expandRecordsByIds(parentRecordIds);
}
});
}
$('buttonSearch').observe('click', function() {
var searchText = $('searchText').value;
logRecords.setHighlightText(searchText);
logRecords.setFilterText('');
startSearch(searchText);
});
$('buttonFilter').observe('click', function() {
var searchText = $('searchText').value;
logRecords.setHighlightText(searchText);
logRecords.setFilterText(searchText);
startSearch(searchText);
});
}
function highlight(text, search) {
if (!search) {
return text.escapeHTML();
}
var startIndex = text.toLowerCase().indexOf(search.toLowerCase());
if (startIndex == -1) {
return text.escapeHTML();
} else {
return (
text.substr(0, startIndex).escapeHTML() +
'<span class="plesk-migrator-log-search-highlight">' +
text.substr(startIndex, search.length).escapeHTML() +
'</span>' +
highlight(text.substr(startIndex + search.length), search)
);
}
}
var logRecords = new LogRecords();
logRecords.appendRecords(INITIAL_LOG_RECORDS);
synchronizeScrollCheckboxes();
observeDebugCheckboxes();
synchronizeAutomaticExpandCheckboxes();
observeSearch();
periodicUpdateLog();
});