File manager - Edit - /usr/local/cpanel/whostmgr/docroot/templates/transfer_tool/services/workerNodes.min.js
Back
define(["angular","lodash","cjt/util/locale"],(function(angular,_,LOCALE){"use strict";var MODULE_NAMESPACE="whm.transfers.services.workerNodes";var SERVICE_NAME="WorkerNodesService";var MODULE_REQUIREMENTS=[];var SERVICE_INJECTABLES=["LOCAL_WORKER_NODES","REMOTE_WORKER_NODES","DEFAULT_WORKER_OPTIONS"];var SERVICE_FACTORY=function(LOCAL_WORKER_NODES,REMOTE_WORKER_NODES,DEFAULT_WORKER_OPTIONS){var Service=function(){};Service.prototype=Object.create({});_.assign(Service.prototype,{_localWorkerNodes:null,_remoteWorkerNodes:null,_workerOptionTypes:null,_defaultWorkerOptions:null,_accountWorkerNodeOptions:{},_accountWorkerDefaultValues:{},_parseWorkerNode:function _parseWorkerNode(rawWorkerNode){var workerNode={alias:rawWorkerNode["alias"],hostname:rawWorkerNode["hostname"],workerCapabilities:Object.keys(rawWorkerNode.worker_capabilities)};return workerNode},_parseWorkerNodes:function _parseWorkerNodes(rawWorkerNodes){return rawWorkerNodes.map(this._parseWorkerNode)},getRemoteWorkerNodes:function getRemoteWorkerNodes(){if(_.isNull(this._remoteWorkerNodes)){this._remoteWorkerNodes=this._parseWorkerNodes(REMOTE_WORKER_NODES)}return this._remoteWorkerNodes},getLocalWorkerNodes:function getLocalWorkerNodes(){if(_.isNull(this._localWorkerNodes)){this._localWorkerNodes=this._parseWorkerNodes(LOCAL_WORKER_NODES)}return this._localWorkerNodes},getDefaultWorkerOptions:function getDefaultWorkerOptions(){if(_.isNull(this._defaultWorkerOptions)){this._defaultWorkerOptions=DEFAULT_WORKER_OPTIONS;Object.keys(this._defaultWorkerOptions).filter((function(workerType){return!this.getWorkerByAlias(this.getLocalWorkerNodes(),this._defaultWorkerOptions[workerType].value)}),this).forEach((function(workerType){this._defaultWorkerOptions[workerType].value=".local"}),this)}return this._defaultWorkerOptions},getWorkerOptionTypes:function getWorkerOptionTypes(){if(_.isNull(this._workerOptionTypes)){this._workerOptionTypes=Object.keys(this.getDefaultWorkerOptions())}return this._workerOptionTypes},getWorkerByHostname:function getWorkerByHostname(workerList,hostname,desiredWorkerType){if(!workerList){return}return _.find(workerList,(function(worker){return worker.hostname===hostname&&worker.workerCapabilities.indexOf(desiredWorkerType)>-1}))},getWorkerByAlias:function getWorkerByAlias(workerList,alias){if(!workerList){return}return _.find(workerList,(function(worker){return worker.alias===alias}))},_createWorkerListTypeItem:function _createWorkerListTypeItem(label,value,type){var defaultWorkerOptions=this.getDefaultWorkerOptions();var workerOption={label:label,value:value,modelKey:defaultWorkerOptions[type].modelKey};return workerOption},_createAccountWorkerListType:function _createAccountWorkerListType(account,workerType){var defaultWorkerOptions=this.getDefaultWorkerOptions();var remoteWorkerNodes=this.getRemoteWorkerNodes();var localWorkerNodes=this.getLocalWorkerNodes();var existingNodeFound;var workerTypeList=[];workerTypeList.push(this._createWorkerListTypeItem(LOCALE.maketext("Use only this server. Transfer or restore locally."),".local",workerType));if(account.workerNodes&&account.workerNodes[workerType]){var remoteWorker=this.getWorkerByAlias(remoteWorkerNodes,account.workerNodes[workerType]);var matchingLocalWorker=remoteWorker&&this.getWorkerByHostname(localWorkerNodes,remoteWorker.hostname,workerType);if(matchingLocalWorker){existingNodeFound=matchingLocalWorker.alias;workerTypeList.push(this._createWorkerListTypeItem(LOCALE.maketext("Use the [asis,cPanel] account’s package configuration.")+" ("+matchingLocalWorker.hostname+")",existingNodeFound,workerType))}}localWorkerNodes.filter((function(workerNode){return workerNode.alias!==existingNodeFound})).forEach((function(workerNode){workerTypeList.push(this._createWorkerListTypeItem(workerNode.alias+" ("+workerNode.hostname+")",workerNode.alias,workerType))}),this);var defaultAlias=existingNodeFound?existingNodeFound:defaultWorkerOptions[workerType].value;workerTypeList.filter((function(workerItem){return workerItem.value===defaultAlias})).forEach((function(workerItem){workerItem.isDefault=true}));return workerTypeList},_createAccountWorkerLists:function _createAccountWorkerLists(account){var workerLists={};this.getWorkerOptionTypes().forEach((function(workerType){workerLists[workerType]=this._createAccountWorkerListType(account,workerType)}),this);return workerLists},getAccountWorkerNodeOptions:function getAccountWorkerNodeOptions(account){var cacheKey=this._getAccountCacheKey(account);if(_.isUndefined(this._accountWorkerNodeOptions[cacheKey])){this._accountWorkerNodeOptions[cacheKey]=this._createAccountWorkerLists(account)}return this._accountWorkerNodeOptions[cacheKey]},checkWorkerOptionsAltered:function checkWorkerOptionsAltered(account){return this.getAccountWorkerDefaultValues(account).some((function(workerDefaultObj){var modelKey=workerDefaultObj.modelKey;var defaultValue=workerDefaultObj.value;if(account[modelKey]!==defaultValue){return true}return false}))},getAccountWorkerDefaultValues:function getAccountWorkerDefaultValues(account){var cacheKey=this._getAccountCacheKey(account);if(_.isUndefined(this._accountWorkerDefaultValues[cacheKey])){var workerNodeOptions=this.getAccountWorkerNodeOptions(account);var defaultWorkerOptions=this.getDefaultWorkerOptions();var accountDefaults=[];Object.keys(workerNodeOptions).forEach((function(workerType){var accountDefault={workerType:workerType,modelKey:defaultWorkerOptions[workerType].modelKey};workerNodeOptions[workerType].forEach((function(workerOption){if(workerOption.isDefault){accountDefault.value=workerOption.value}}));if(!accountDefault.value){accountDefault.value=defaultWorkerOptions[workerType].value}accountDefaults.push(accountDefault)}));this._accountWorkerDefaultValues[cacheKey]=accountDefaults}return this._accountWorkerDefaultValues[cacheKey]},resetAccountToDefaults:function resetAccountToDefaults(account){var defaultValues=this.getAccountWorkerDefaultValues(account);defaultValues.forEach((function(defaultValueObj){account[defaultValueObj.modelKey]=defaultValueObj.value}),this)},_getAccountCacheKey:function _getAccountCacheKey(account){return account.remote_user+"|"+account.domain}});return new Service};SERVICE_INJECTABLES.push(SERVICE_FACTORY);var app=angular.module(MODULE_NAMESPACE,MODULE_REQUIREMENTS);app.value("DEFAULT_WORKER_OPTIONS",{Mail:{value:".local",modelKey:"mail_location"}});app.factory(SERVICE_NAME,SERVICE_INJECTABLES);return{class:SERVICE_FACTORY,serviceName:SERVICE_NAME,namespace:MODULE_NAMESPACE}}));
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings