Viewing File: /usr/local/cpanel/base/frontend/jupiter/domains/views/manageDomain.min.js

define(["angular","lodash","cjt/util/locale","cjt/modules","cjt/directives/callout","cjt/directives/actionButtonDirective","app/services/domains","app/directives/domainSearchModalDirective","cjt/services/cpanel/nvDataService"],(function(e,n,a){"use strict";var o="cpanel.domains.views.manageDomain";e.module(o,["cpanel.domains.domains.service","ngRoute","cjt2.services.alert"]).controller("manageDomain",["$scope","$location","$routeParams","$q","$timeout","$sce","domains","alertService","DOMAIN_TYPE_CONSTANTS","PAGE","nvDataService","domainSearchModalService",function(o,i,m,t,r,d,c,s,u,l,D,p){function g(){var a=e.copy(o.currentDomain);a.fullDocumentRoot=a.documentRoot,a.renameDomainConfirmed=!1;var i=a.documentRoot,m=a.homedir;if(i){var t=new RegExp("^"+n.escapeRegExp(m)+"(/)?");i=i.replace(t,""),o.requirePublicHTMLSubs&&(i=i.replace(/^public_html/,"").replace(/^\//,"")),a.documentRoot=i}return a}function f(){o.deletionDelayed=!0}e.extend(o,{associatedDomains:[],deletionDelayed:!1,temporaryDomainReplacementPending:!1,domainRenamePending:!1,domainRemovePending:!1,renameDomainLinkClicked:!1,currentDomain:c.findDomainByName(m.domain),requirePublicHTMLSubs:"1"===l.requirePublicHTMLSubs.toString(),webserverRoleAvailable:l.hasWebServerRole,mainDomain:c.getMainDomain(),getFormFieldClasses:function(e){return e&&!e.$pristine&&e.$invalid?"col-xs-12 col-md-6":"col-xs-12"},documentRootPattern:c.getDocumentRootPattern(),toggleAdvancedDetailFields:function(){o.showAdvancedDetailFields=!o.showAdvancedDetailFields},update:function(e,i){var m="updating_"+i.domain,r=c.generateFullDocumentRoot(i.documentRoot);if(i.rootDomain){var d=[];return e.newDocumentRoot.$pristine||d.push(c.updateDocumentRoot(i.domain,r).then((function(){s.add({type:"success",id:m,replace:!0,message:a.maketext("You have successfully updated the document root to “[_1]” for the “[_2]” domain.",n.escape(r),i.domain)}),o.workingDomain=g()}),(function(){s.removeById(m)}))),d.length?t.all(d):void 0}s.add({type:"danger",id:m,replace:!0,message:a.maketext("The domain userdata file for the “[_1]” domain appears to be missing.",i.domain)})},replace:function(e){o.temporaryDomainReplacementPending=!0;const m=c.generateFullDocumentRoot(e.documentRoot),t={documentRoot:e.documentRoot,domain:e.domain,newDomainName:e.newDomainName};return c.replaceTemporaryDomain(t).then((function(){s.add({type:"success",message:a.maketext("The domain “[_1]” has been converted to “[_2]”. Its document root is now “[_3]”.",t.domain,t.newDomainName,n.escape(m)),replace:!1});var e=c.findDomainByName(t.newDomainName);e&&(o.currentDomain=e,o.workingDomain=g()),o.replaceDomainLinkClicked=!1,i.search("domain",t.newDomainName),o.temporaryDomainReplacementPending=!1}))},renameDomain:function(e){var n=e.newDomainName;if(n){if(n!==e.domain){o.domainRenamePending=!0;var m={domain:e.domain,newDomainName:n};return c.renameDomain(m).then((function(){var n;n=e.is_temporary?a.maketext("The temporary domain “[_1]” has been replaced with “[_2]”.",m.domain,m.newDomainName):a.maketext("The domain “[_1]” has been renamed to “[_2]”.",m.domain,m.newDomainName),s.add({type:"success",message:n,replace:!1}),o.workingDomain.domain=m.newDomainName,o.workingDomain.is_temporary=!1,o.currentDomain.domain=m.newDomainName,o.currentDomain.is_temporary=!1,o.workingDomain.newDomainName="",o.workingDomain.renameDomainConfirmed=!1,o.renameDomainLinkClicked=!1,o.domainRenamePending=!1;var t=c.findDomainByName(m.newDomainName);t&&(o.currentDomain=t,o.workingDomain=g(),o.workingDomain.newDomainName=""),i.search("domain",m.newDomainName)})).catch((function(e){throw o.domainRenamePending=!1,o.workingDomain.renameDomainConfirmed=!1,e}))}s.add({type:"danger",message:a.maketext("The new domain must differ from the current domain."),replace:!0})}},confirmingRemoval:!1,removeDomain:function(){if(o.currentDomain.rootDomain){var e=r(f,1e3);return o.domainRemovePending=!0,c.remove(o.currentDomain.domain).then((function(){s.add({message:a.maketext("The system removed the “[_1]” domain and any associated redirections.",o.currentDomain.domain),type:"success"}),c.invalidate(),i.path("/").search("")})).finally((function(){o.deletionDelayed=!1,o.domainRemovePending=!1,r.cancel(e)}))}s.add({type:"danger",replace:!0,message:a.maketext("The domain userdata file for the “[_1]” domain appears to be missing.",o.currentDomain.domain)})},startRemovalConfirmation:function(){o.confirmingRemoval=!0},cancelRemoval:function(){o.confirmingRemoval=!1},deleteDependentDomainsError:function(e,n){return a.maketext("The system created the “[_1]” subdomain when it created the “[_2]” domain. To delete this subdomain, you must first delete the following [numerate,_3,domain,domains]:",e,n[0].domain,n.length)},replaceDomainLinkClicked:!1,toggleReplaceDomainSection:function(){o.replaceDomainLinkClicked=!o.replaceDomainLinkClicked},toggleRenameDomainSection:function(){o.renameDomainLinkClicked=!o.renameDomainLinkClicked,o.renameDomainLinkClicked?r((function(){var e=document.getElementById("renameDomainName");e&&e.focus()})):(o.workingDomain.newDomainName="",o.workingDomain.renameDomainConfirmed=!1,r((function(){var e=document.getElementById("rename_domain_link");e&&e.focus()})))},onUpdateNewDomainName:function(){o.workingDomain.newDomainName&&(o.workingDomain.documentRoot=o.workingDomain.newDomainName,o.workingDomain.fullDocumentRoot=c.generateFullDocumentRoot(o.workingDomain.newDomainName),o.workingDomain.subdomain=o.workingDomain.newDomainName)},currentDomainIsTemporaryMainDomain:function(){const e=o.workingDomain.type===u.MAIN;return(!0===o.mainDomain.is_temporary||"1"===String(o.mainDomain.is_temporary))&&e}}),o.domainRecommendationsEnabled=!!l.features.domain_recommendation,o.domainRecommendations=[],o.domainRecommendationPrice="",o.domainRecsLoading=!1;var h=null,v=null;if(o.domainRecsBannerDismissed=!!l.domainRecsBannerDismissed,o.domainRecommendationsEnabled&&!o.domainRecsBannerDismissed&&!o.currentDomain.is_temporary){var w=c.findDomainByName(m.domain);w&&w.domain&&(o.domainRecsLoading=!0,v=c.fetchRecommendations(w.domain).then((function(e){return o.domainRecommendations=e.banner.recommendations,e.banner.lowestPrice&&(o.domainRecommendationPrice=e.banner.lowestPrice+" / "+a.maketext("year")),h=e.explore})).catch((function(e){return console.error("Failed to load domain recommendations:",e),null})).finally((function(){o.domainRecsLoading=!1})))}o.dismissDomainRecommendations=function(){o.domainRecsBannerDismissed=!0,D.set("domain_recs_banner_dismissed","1",{nocache:!0}).catch((function(e){console.error("Failed to save banner dismissal:",e)}))},o.openExploreDomains=function(){p.open({cachedExploreData:h,source:"manage-domain-upsell-banner",exploreDataPromise:v,onAddDomain:function(e){c.setPendingAddDomain(e),i.path("/").search("")}})},o.currentDomain||(s.add({message:a.maketext("You did not specify a domain to manage."),type:"danger"}),i.path("/").search("")),o.showAdvancedDetailFields=!1,o.showSubdomainInDetails=o.currentDomain.type===u.ADDON,u.SUBDOMAIN===o.currentDomain.type&&c.get().then((function(e){e.forEach((function(e){e.subdomain===o.currentDomain.subdomain&&e.type===u.ADDON&&o.associatedDomains.push(e)}))})),o.canUpdateDocumentRoot=o.currentDomain.type!==u.ALIAS,o.workingDomain=g()}]);return{namespace:o}}));
Back to Directory