Viewing File: /usr/local/cpanel/whostmgr/docroot/templates/mysqlhost/index.cmb.min.js

define("app/directives/mysqlhost_domain_validators",["angular","cjt/validator/validator-utils","cjt/util/locale","cjt/util/inet6","cjt/validator/domain-validators","cjt/validator/validateDirectiveFactory"],(function(e,t,o,r,i){var s=/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,a={hostnameOrIp:function(e){var a,l=t.initializeValidationResult(),c=!1;if(n(e))c=!0;else if(a=e,r.isValid(a)||s.test(a))c=!0;else{var p=i.methods.fqdn(e);if(!(c=p.isValid))for(var u=0,f=p.messages.length;u<f;u++)l.add(p.messages[u].name,p.messages[u].message)}return c||(l.isValid=!1,l.add("hostnameOrIp",o.maketext("The host must be a valid [asis,IP] address or [asis,hostname]."))),l},loopback:function(e){var r=t.initializeValidationResult();return n(e)?r.isValid=!0:(r.isValid=!1,r.add("localhost",o.maketext("The value must be a valid [asis,loopback] address."))),r}};function n(e){switch(e){case"localhost":case"localhost.localdomain":case"0000:0000:0000:0000:0000:0000:0000:0001":case"0:0:0:0:0:0:0:1":case":1":case"::1":case"0:0:0:0":case"0000:0000:0000:0000:0000:0000:0000:0000":return!0;default:if(/^0000:0000:0000:0000:0000:ffff:7f/.test(e)||/^::ffff:127\./.test(e)||/^127\./.test(e))return!0}return!1}return e.module("cjt2.validate").run(["validatorFactory",function(e){e.generate(a)}]),{methods:a,name:"mysqlhostDomainValidators",description:"Validation directives for ip address and hostname.",version:11.52}})),define("app/models/MysqlProfile",["lodash"],(function(e){function t(t){e.isObject(t)||(t={}),this.type="mysql",this.active=!1,this.name=t.name||"",this.host=t.host||"",this.port=t.port||3306,this.account=t.account||"",this.password=t.password||"",this.comment=t.comment||"",this.is_local=t.is_local||void 0,this.is_supported=t.is_supported||void 0}return t.prototype.activate=function(){this.active=!0},t.prototype.deactivate=function(){this.active=!1},t.prototype.convertToProfileObject=function(e){return new e({active:this.active,name:this.name,host:this.host,account:this.account,comment:this.comment,is_local:this.is_local,is_supported:this.is_supported})},t})),define("app/models/MysqlProfileUsingSsh",["lodash"],(function(e){function t(t){e.isObject(t)||(t={}),this.type="ssh",this.active=!1,this.name=t.name||"",this.host=t.host||"",this.port=t.port||22,this.account=t.account||"",this.password=t.password||"",this.ssh_key=t.ssh_key||"",this.ssh_passphrase=t.ssh_passphrase||"",this.escalation_type=t.escalation_type||"",this.escalation_password=t.escalation_password||"",this.comment=t.comment||"",this.is_local=t.is_local||void 0,this.is_supported=t.is_supported||void 0}return t.prototype.activate=function(){this.active=!0},t.prototype.deactivate=function(){this.active=!1},t.prototype.convertToProfileObject=function(e){return new e({active:this.active,name:this.name,host:this.host,account:this.account,comment:this.comment,is_local:this.is_local,is_supported:this.is_supported})},t})),define("app/services/MySQLHostDataSource",["angular","jquery","lodash","cjt/util/locale","cjt/util/parse","cjt/io/api","cjt/io/whm-v1-request","cjt/io/whm-v1","app/models/MysqlProfile","app/models/MysqlProfileUsingSsh"],(function(e,t,o,r,i,s,a,n,l,c){return e.module("App").factory("MySQLHostDataSource",["$q",function(e){var t={profiles:{},clearCache:function(){t.profiles={}},generateErrorMessageForDisplay:function(e){if(!e)return r.maketext("An unexpected error occurred.");for(var t=o.escape(e.reason)+"<br><br>",i=0,s=e.error_count,a=[];i<s;i++)a.push(o.escape(e.errors[i]));return t+=a.join("<br>")},createObjectForTransport:function(e){var t={};return e instanceof l?(t={name:e.name,mysql_host:e.host,mysql_port:e.port,mysql_user:e.account,mysql_pass:e.password},e.hasOwnProperty("active")&&(t.active=e.active?1:0)):e instanceof c&&(t={name:e.name,host:e.host,port:e.port,user:e.account,password:e.password,sshkey_name:e.ssh_key,sshkey_passphrase:e.ssh_passphrase,root_escalation_method:e.escalation_type},e.hasOwnProperty("active")&&(t.active=e.active?1:0),"su"===e.escalation_type&&(t.root_password=e.escalation_password)),t},createObjectFromAPI:function(e,t){var o=new l({name:e,host:t.mysql_host,port:t.mysql_port,account:t.mysql_user,password:t.mysql_pass,comment:t.setup_via,is_local:t.is_localhost_profile,is_supported:t.mysql_version_is_supported});return i.parsePerlBoolean(t.active)?o.activate():o.deactivate(),o},createObjectsFromAPI:function(e){for(var r={},i=0,s=o.keys(e),a=s.length;i<a;i++){var n=s[i],l=t.createObjectFromAPI(n,e[s[i]]);r[n]=l}return r},createProfile:function(r){var i=e.defer(),n=new a.Class;"ssh"===r.type?n.initialize("","remote_mysql_create_profile_via_ssh"):n.initialize("","remote_mysql_create_profile");for(var l=t.createObjectForTransport(r),c=0,p=o.keys(l),u=p.length;c<u;c++){var f=l[p[c]];n.addArgument(p[c],f)}return s.promise(n.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(t.profiles[e.data.profile_saved]=t.createObjectFromAPI(e.data.profile_saved,e.data.profile_details),i.resolve(null)):i.reject(t.generateErrorMessageForDisplay(e.meta))})),i.promise},updateProfile:function(r){var i=e.defer(),n=new a.Class;n.initialize("","remote_mysql_update_profile");for(var l=t.createObjectForTransport(r),c=0,p=o.keys(l),u=p.length;c<u;c++){var f=l[p[c]];n.addArgument(p[c],f)}return s.promise(n.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(t.profiles[e.data.profile_saved]=t.createObjectFromAPI(e.data.profile_saved,e.data.profile_details),i.resolve(null)):i.reject(t.generateErrorMessageForDisplay(e.meta))})),i.promise},loadProfiles:function(){var o=e.defer(),r=new a.Class;return r.initialize("","remote_mysql_read_profiles"),s.promise(r.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(t.profiles=t.createObjectsFromAPI(e.data),o.resolve(null)):o.reject(t.generateErrorMessageForDisplay(e.meta))})),o.promise},deleteProfile:function(o){var r=e.defer(),i=new a.Class;return i.initialize("","remote_mysql_delete_profile"),i.addArgument("name",o),s.promise(i.getRunArguments()).done((function(e){(e=e.parsedResponse).status?(delete t.profiles[o],r.resolve(null)):r.reject(t.generateErrorMessageForDisplay(e.meta))})),r.promise},validateProfile:function(o){var r=e.defer(),i=new a.Class;return i.initialize("","remote_mysql_validate_profile"),i.addArgument("name",o),s.promise(i.getRunArguments()).done((function(e){var i;(e=e.parsedResponse).status?r.resolve(e.data.profile_validated):(i=t.generateErrorMessageForDisplay(e.meta),i=t.appendTroubleshootingLink({html:i,linkId:"validate-troubleshoot-link-"+o}),r.reject(i))})),r.promise},activateProfile:function(o){var r=e.defer(),i=new a.Class;return i.initialize("","remote_mysql_initiate_profile_activation"),i.addArgument("name",o),s.promise(i.getRunArguments()).done((function(e){(e=e.parsedResponse).status?r.resolve(e.data.activation_job_started):r.reject(t.generateErrorMessageForDisplay(e.meta))})),r.promise},monitorActivation:function(t){var o=e.defer(),r=new a.Class;return r.initialize("","remote_mysql_monitor_profile_activation"),s.promise(r.getRunArguments()).done((function(e){(e=e.parsedResponse).data.job_in_progress||"FAILED"!==e.data.last_job_details.status?o.resolve(e.data):o.reject(e.data)})),o.promise},activationInProgress:function(){var t=e.defer(),r=new a.Class;return r.initialize("","remote_mysql_monitor_profile_activation"),s.promise(r.getRunArguments()).done((function(e){e=e.parsedResponse;var r={};o.isNull(e.data.job_in_progress)&&o.isNull(e.data.last_job_details)&&t.reject({in_progress:!1}),r.in_progress=!!e.data.job_in_progress,r.in_progress?r.payload=e.data.job_in_progress:r.payload=e.data.last_job_details,t.resolve(r)})),t.promise},appendTroubleshootingLink:function(e){var t=e.html,o=e.linkId;return t+='<div class="growl-troubleshooting-link">'+r.maketext("For more information, read our [output,url,_1,documentation,target,_2,id,_3].","https://go.cpanel.net/troubleshootmysqlprofiles","troubleshootingDocs",o)+"</div>"}};return t}])})),define("app/views/profiles",["angular","lodash","cjt/util/locale","cjt/util/parse","app/directives/mysqlhost_domain_validators","cjt/validator/datatype-validators","cjt/validator/length-validators","uiBootstrap","cjt/directives/validationContainerDirective","cjt/directives/validationItemDirective","cjt/decorators/growlDecorator","cjt/directives/actionButtonDirective","app/services/MySQLHostDataSource"],(function(e,t,o,r,i){"use strict";return e.module("App").controller("profilesController",["$scope","$uibModal","$location","$timeout","growl","MySQLHostDataSource","growlMessages",function(e,r,i,s,a,n,l){var c;function p(t){for(var o=e.lastActivation.final_step;o<t.steps.length;o++)e.lastActivation.steps.push(t.steps[o]);for(var r=0;r<t.steps.length;r++)e.lastActivation.steps[r].status=t.steps[r].status;e.lastActivation.final_step=o}e.profiles={},e.activeProfile="",e.loadingProfiles=!0,e.modalInstance=null,e.lastActivation={in_progress:!1,profile:"",steps:[],final_step:0,expanded:!1},e.messages={DONE:o.maketext("This step completed."),FAILED:o.maketext("This step failed."),SKIPPED:o.maketext("This step was skipped."),INPROGRESS:o.maketext("This step is in progress.")},e.message=function(t){return e.messages[t]},e.profileListIsEmpty=function(){return!(e.loadingProfiles||e.profiles&&Object.keys(e.profiles).length>0)},e.confirmDeleteProfile=function(t){return e.currentProfileName=t,e.modalInstance=r.open({templateUrl:"confirmprofiledeletion.html",scope:e}),e.modalInstance.result.then((function(t){return e.deleteProfile(t)}),(function(){e.clearModalInstance()}))},e.confirmActivateProfile=function(t){return e.currentProfileName=t.name,e.is_not_supported=t.is_local&&!t.is_supported,e.modalInstance=r.open({templateUrl:"confirmprofileactivation.html",scope:e}),e.modalInstance.result.then((function(t){return e.changeActiveProfile(t)}),(function(){e.clearModalInstance()}))},e.clearModalInstance=function(){e.modalInstance&&(e.modalInstance.close(),e.modalInstance=null)},e.disableProfileOperations=function(t){return!(!e.lastActivation.in_progress&&!e.profiles[t].active)},e.monitorProfileChange=function(r){return n.monitorActivation(r).then((function(i){return i.job_in_progress?(e.lastActivation.in_progress=!0,p(i.job_in_progress),c=s((function(){return e.monitorProfileChange(i.job_in_progress.profile_name)}),2e3)):(s.cancel(c),p(i.last_job_details),e.activeProfile&&""!==e.activeProfile&&e.profiles[e.activeProfile]&&e.profiles[e.activeProfile].deactivate(),e.profiles[i.last_job_details.profile_name].activate(),e.activeProfile=i.last_job_details.profile_name,e.lastActivation.in_progress=!1,l.destroyAllMessages(),a.success(o.maketext("Activation completed for “[_1]”.",t.escape(r))),null)}),(function(i){s.cancel(c),p(i.last_job_details);var u=o.maketext("Activation failed for “[_1]” during step “[_2]” because of an error: [_3]",t.escape(i.last_job_details.profile_name),t.escape(i.last_job_details.steps[i.last_job_details.steps.length-1].name),t.escape(i.last_job_details.steps[i.last_job_details.steps.length-1].error));u=n.appendTroubleshootingLink({html:u,linkId:"monitor-troubleshoot-link-"+r}),l.destroyAllMessages(),a.error(u),e.lastActivation.in_progress=!1}))},e.changeActiveProfile=function(r){return e.lastActivation.profile=r,e.lastActivation.final_step=0,e.lastActivation.steps=[],e.lastActivation.in_progress=!0,n.activateProfile(r).then((function(){return e.lastActivation.expanded=!0,a.info(o.maketext("Activation in progress for “[_1]”.",t.escape(r))),s((function(){return e.monitorProfileChange(r)}),2e3)}),(function(t){l.destroyAllMessages(),a.error(t),e.lastActivation.in_progress=!1}))},e.deleteProfile=function(r){return e.clearModalInstance(),n.deleteProfile(r).then((function(){e.profiles=n.profiles,a.success(o.maketext("You have successfully deleted the profile, “[_1]”.",t.escape(r)))}),(function(e){a.error(e)}))},e.validateProfile=function(e){return n.validateProfile(e).then((function(){a.success(o.maketext("The profile “[_1]” is valid.",t.escape(e)))}),(function(e){a.error(e)}))},e.initialMonitorCheck=function(){return n.activationInProgress().then((function(t){if(e.lastActivation.profile=t.payload.profile_name,p(t.payload),t.in_progress)return e.lastActivation.in_progress=!0,e.monitorProfileChange(t.payload.profile_name)}))},e.loadProfiles=function(){return e.loadingProfiles=!0,n.loadProfiles().then((function(){for(var t in e.profiles=n.profiles,e.profiles)if(e.profiles[t].hasOwnProperty("active")&&e.profiles[t].active){e.activeProfile=t;break}}),(function(e){a.error(e)})).finally((function(){e.loadingProfiles=!1}))},e.hasLocalhostProfile=function(){for(var o=0,r=t.keys(e.profiles),i=r.length;o<i;o++)if(e.profiles[r[o]].is_local)return!0;return!1},e.forceLoadProfiles=function(){e.lastActivation.in_progress||(e.profiles={},e.loadProfiles())},e.goToAddProfile=function(){if(!e.lastActivation.in_progress)return i.path("/profiles/new")},e.goToAddLocalhostProfile=function(){if(!e.lastActivation.in_progress)return i.path("/profiles/newlocalhost")};e.loadProfiles().then((function(){e.initialMonitorCheck()}))}])})),define("app/views/profile_details",["angular","lodash","cjt/util/locale","cjt/validator/datatype-validators","cjt/validator/compare-validators","cjt/validator/length-validators","uiBootstrap","cjt/directives/validationContainerDirective","cjt/directives/validationItemDirective","cjt/decorators/growlDecorator","cjt/directives/actionButtonDirective","app/services/MySQLHostDataSource","app/directives/mysqlhost_domain_validators"],(function(e,t,o){return e.module("App").controller("profileDetailsController",["$scope","$location","$q","$routeParams","growl","MySQLHostDataSource",function(e,r,i,s,a,n){e.currentProfile=null,e.loadingProfiles=!1,e.disableSave=function(t){return t.$dirty&&t.$invalid||e.loadingProfiles},e.saveProfile=function(i){if(i.$valid)return n.updateProfile(e.currentProfile).then((function(){a.success(o.maketext("You have successfully updated the profile, “[_1]”.",t.escape(e.currentProfile.name))),r.path("/profiles")}),(function(e){a.error(e)}))},e.loadProfiles=function(){return e.loadingProfiles=!0,n.loadProfiles().then((function(){e.loadingProfiles=!1}),(function(t){a.error(t),e.loadingProfiles=!0}))},e.loadProfileData=function(t){var o=n.profiles[t];return void 0!==o&&(e.currentProfile=o,!0)},e.loadProfiles().then((function(){e.loadProfileData(s.profileName)?e.loadingProfiles=!1:r.path("profiles")}))}])})),define("app/views/add_profile",["angular","lodash","cjt/util/locale","app/models/MysqlProfile","app/models/MysqlProfileUsingSsh","cjt/validator/datatype-validators","cjt/validator/compare-validators","cjt/validator/length-validators","uiBootstrap","cjt/directives/validationContainerDirective","cjt/directives/validationItemDirective","cjt/decorators/growlDecorator","cjt/directives/actionButtonDirective","app/services/MySQLHostDataSource","app/directives/mysqlhost_domain_validators"],(function(e,t,o,r,i){"use strict";return e.module("App").controller("addProfileController",["$scope","$location","$q","$routeParams","growl","MySQLHostDataSource",function(e,s,a,n,l,c){e.currentProfile=null,e.workflow={currentProfileAuthType:"password",disableSshProfileAuthType:!1},e.ssh_keys={},e.enableCreateViaSSH=!0,e.disableSave=function(e){return e.$dirty&&e.$invalid},e.saveProfile=function(r){if(r.$valid)return!e.workflow.disableSshProfileAuthType&&e.currentProfile.sshKey&&e.currentProfile.sshKey.key&&(e.currentProfile.ssh_key=e.currentProfile.sshKey.key),c.createProfile(e.currentProfile).then((function(){l.success(o.maketext("You have successfully created the profile, “[_1]”.",t.escape(e.currentProfile.name))),s.path("/profiles")}),(function(e){l.error(e)}))},e.convertProfileType=function(t){"ssh"===t?(e.currentProfile=e.currentProfile.convertToProfileObject(i),e.currentProfile.sshKey=e.ssh_keys[0]):"mysql"===t&&(e.currentProfile=e.currentProfile.convertToProfileObject(r))},e.requiresEscalation=function(){return e.currentProfile&&"ssh"===e.currentProfile.type&&e.currentProfile.account&&e.currentProfile.account.length>0&&"root"!==e.currentProfile.account},e.currentRoute=s.path(),"/profiles/newlocalhost"===e.currentRoute?(e.currentProfile=new r({name:"localhost",host:"localhost",port:3306,account:"root"}),e.enableCreateViaSSH=!1):e.currentProfile=new i,e.currentProfile.sshKey=e.currentProfile.ssh_key,void 0!==PAGE.key_list&&PAGE.key_list.length>0?(e.ssh_keys=PAGE.key_list,e.currentProfile.sshKey=e.ssh_keys[0]):(e.workflow.disableSshProfileAuthType=!0,e.workflow.currentProfileAuthType="password")}])})),define("app/index",["angular","jquery","lodash","cjt/core","cjt/modules","ngRoute","uiBootstrap","ngSanitize","ngAnimate"],(function(e,t,o,r){return function(){return e.module("App",["cjt2.config.whm.configProvider","ngRoute","ui.bootstrap","ngSanitize","ngAnimate","angular-growl","cjt2.whm"]),require(["cjt/bootstrap","cjt/util/locale","cjt/util/inet6","app/views/profiles","app/views/profile_details","app/views/add_profile","app/directives/mysqlhost_domain_validators"],(function(t,o){var i=e.module("App");i.config(["$routeProvider",function(e){e.when("/profiles",{controller:"profilesController",templateUrl:r.buildFullPath("mysqlhost/views/profiles.ptt")}),e.when("/profiles/profile-:profileName",{controller:"profileDetailsController",templateUrl:r.buildFullPath("mysqlhost/views/profile_details.ptt")}),e.when("/profiles/new",{controller:"addProfileController",templateUrl:r.buildFullPath("mysqlhost/views/add_profile.ptt")}),e.when("/profiles/newlocalhost",{controller:"addProfileController",templateUrl:r.buildFullPath("mysqlhost/views/add_profile.ptt")}),e.otherwise({redirectTo:"/profiles"})}]),i.run(["$rootScope","$timeout","$location","growl","growlMessages",function(e,t,o,r,i){}]),t(document)}))}}));
Back to Directory File Manager