Viewing File: /usr/local/cpanel/whostmgr/docroot/templates/server_profile/index.cmb.min.js
define("app/filters/rolesLocaleString",["angular","cjt/util/locale","lodash"],(function(e,t,i){"use strict";e.module("whm.serverProfile.rolesLocaleString",[]).filter("rolesLocaleString",(function(){return function(e,o){var l=i.map(e,"name");return t.makevar(o,l,e.length)}}))})),define("app/services/serverProfileService",["angular","cjt/util/parse","cjt/io/batch-request","cjt/io/whm-v1-request","cjt/services/APICatcher","cjt/io/whm-v1"],(function(e,t,i,o){"use strict";return e.module("whm.serverProfile.serverProfileService",["cjt2.services.apicatcher","cjt2.services.api"]).factory("serverProfileService",["APICatcher","$q","PAGE",function(e,l,n){var r={availableProfiles:void 0,currentProfile:void 0,logId:void 0,optionalRoles:[],selectedProfile:void 0};if(n.availableProfiles&&(r.availableProfiles=n.availableProfiles,r.availableProfiles.length>0&&n.currentProfile))for(var a=0;a<r.availableProfiles.length;a++)if(r.availableProfiles[a].code===n.currentProfile.code){r.currentProfile=r.selectedProfile=r.availableProfiles[a];break}return{activateProfile:function(t,i){var l=(new o.Class).initialize("","start_profile_activation",{code:t,optional:JSON.stringify(i)});return e.promise(l)},areRolesEnabled:function(n){if(0===n.length)return l((function(e){e({data:[]})}));var r=n.map((function(e){return(new o.Class).initialize("","is_role_enabled",{role:e})}));return e.promise(new i.Class(r)).then((function(e){return e.data.map((function(e){return t.parsePerlBoolean(e.data.enabled)}))}))},getAvailableProfiles:function(){var t=l.defer();if(r.availableProfiles)t.resolve({data:r.availableProfiles});else{var i=(new o.Class).initialize("","get_available_profiles");e.promise(i).then((function(e){r.availableProfiles=e.data,t.resolve(e)}),(function(e){t.reject(e)}))}return t.promise},getCurrentProfile:function(){var t=l.defer();if(r.currentProfile)t.resolve({data:r.currentProfile});else{var i=(new o.Class).initialize("","get_current_profile");e.promise(i).then((function(e){r.currentProfile=e.data,t.resolve(e)}),(function(e){t.reject(e)}))}return t.promise},getLogId:function(){return r.logId},getOptionalRoles:function(){return r.optionalRoles},getSelectedProfile:function(){return r.selectedProfile},isRoleEnabled:function(t){var i=(new o.Class).initialize("","is_role_enabled",{role:t});return e.promise(i)},setCurrentProfile:function(e){r.currentProfile=e},setOptionalRoles:function(e){r.optionalRoles=e},setSelectedProfile:function(e){r.selectedProfile=e},setLogId:function(e){r.logId=e}}}])})),define("app/views/activatingProfileView",["angular","cjt/core","cjt/util/parse","cjt/util/locale","cjt/io/eventsource"],(function(e,t,i,o,l){"use strict";var n=e.module("whm.serverProfile");function r(e){var t=this;e.addEventListener("finish",(function(i){e.close(),t._meta=JSON.parse(i.data),t._onclose&&t._onclose()})),this._sse=e}r.prototype.succeeded=function(){return this._meta&&i.parsePerlBoolean(this._meta.SUCCESS)},r.prototype.onmessage=function(e){this._sse.addEventListener("message",(function(t){e(JSON.parse(t.data))}))},r.prototype.onclose=function(e){this._onclose=e},n.controller("activatingProfileController",["$scope","$location","$document","$q","alertService","serverProfileService",function(e,i,n,a,s,c){e.settingProfile=!0,e.$emit("ActivateProfileEvent"),e.back=function(){i.path("/selectProfile")},e.pageTitle=o.maketext("Activating Profile …"),e.activationState="inProgress",e.activationInitiated=!0,e.logId=c.getLogId(),e.selected=c.getSelectedProfile(),e.actionLog="",e.transferLogMessage=o.maketext("The profile activation log is located at: [_1]","/var/cpanel/logs/activate_profile/"+e.logId+"/txt"),e.showDetails=!1,e.toggleDetails=function(){e.showDetails=!e.showDetails};var f=t.securityToken+"/sse/ActivateProfile?log_id="+c.getLogId();l.create(f).then((function(t){var i=new r(t.target);i.onmessage((function(t){e.actionLog+=t,e.$apply(),e.logElement||(e.logElement=n[0].getElementById("activationLog")),e.logElement&&(e.logElement.scrollTop=e.logElement.scrollHeight)})),i.onclose((function(){e.logElement&&(e.logElement.scrollTop=e.logElement.scrollHeight),i.succeeded()?(c.setCurrentProfile(e.selected),e.activationState="success",e.pageTitle=o.maketext("Activation Successful"),s.add({type:"success",message:o.maketext("Successfully changed the server profile to “[_1]”.",e.selected.name),closeable:!0,autoClose:5e3})):(e.activationState="failed",e.pageTitle=o.maketext("Activation Failed"),s.add({type:"danger",message:o.maketext("The system failed to change the server profile to “[_1]”.",e.selected.name),closeable:!0}),e.showDetails=!0),e.settingProfile=!1,e.$apply()}))})).catch((function(e){s.add({type:"danger",message:e,closeable:!0})}))}])})),define("app/views/confirmProfileView",["angular","lodash","cjt/util/locale"],(function(e,t,i){"use strict";e.module("whm.serverProfile").controller("confirmProfileController",["$rootScope","$scope","$location","serverProfileService",function(e,o,l,n){var r=i.maketext("Enabled"),a=i.maketext("Disabled");o.loading=!0,o.selected=n.getSelectedProfile(),o.newEnabled=[],o.newDisabled=[],o.optional=n.getOptionalRoles(),o.unchanged=[];var s=function(e,t){return e+" ("+(t?r:a)+")"};n.getCurrentProfile().then((function(e){o.current=e.data;var i=[];t.forEach(o.selected.enabled_roles,(function(e){t.includes(o.current.enabled_roles,e)?o.unchanged.push(t.assign({},e,{name:s(e.name,!0)})):i.push(e.module)})),t.forEach(o.selected.disabled_roles,(function(e){t.includes(o.current.disabled_roles,e)?o.unchanged.push(t.assign({},e,{name:s(e.name,!1)})):i.push(e.module)})),t.forEach(o.optional,(function(e){e.current===e.selected?o.unchanged.push(t.assign({},e,{name:s(e.name,e.current)})):e.current?o.newDisabled.push(e):o.newEnabled.push(e)})),n.areRolesEnabled(i).then((function(e){for(var l=0;l<e.length;l++){var n,r=e[l];(n=t.find(o.selected.enabled_roles,(function(e){return e.module===i[l]})))?r?o.unchanged.push(t.assign({},n,{name:s(n.name,!0)})):o.newEnabled.push(n):(n=t.find(o.selected.disabled_roles,(function(e){return e.module===i[l]})))&&(r?o.newDisabled.push(n):o.unchanged.push(t.assign({},n,{name:s(n.name,!1)})))}})).finally((function(){o.loading=!1}))}),(function(){o.loading=!1})),o.cancel=function(){l.path("/selectProfile")},o.continue=function(e){o.settingProfile=!0;var i={};return t.each(o.optional,(function(e){i[e.module]=e.selected?1:0})),n.activateProfile(e.code,i).then((function(e){n.setLogId(e.data.log_id),l.path("/activatingProfile")})).finally((function(){o.settingProfile=!1}))}}])})),define("app/views/selectOptionsView",["angular","lodash","cjt/util/locale"],(function(e,t,i,o){"use strict";e.module("whm.serverProfile").controller("selectOptionsController",["$scope","$location","serverProfileService","LICENSE_BASED_SERVER_PROFILE",function(e,i,o,l){e.loading=!0,e.licenseBasedServerProfile=l;var n=[];e.selectedProfile=o.getSelectedProfile(),e.optional=t.map(e.selectedProfile.optional_roles,(function(e){var t={name:e.name,description:e.description,module:e.module,selected:!1};return n.push(e.module),t})),o.areRolesEnabled(n).then((function(t){for(var i=0;i<t.length;i++){var o=t[i];e.optional[i].current=e.optional[i].selected=o}})).finally((function(){e.loading=!1})),e.cancel=function(){i.path("/selectProfile")},e.continue=function(){o.setOptionalRoles(e.optional),i.path("/confirmProfile")}}])})),define("app/views/selectProfileView",["angular"],(function(e){"use strict";e.module("whm.serverProfile").controller("selectProfileController",["$scope","$location","serverProfileService",function(e,t,i){e.profiles={},i.getAvailableProfiles().then((function(t){return e.profiles.available=t.data,i.getCurrentProfile().then((function(t){e.profiles.selected=e.profiles.current=t.data}))})),e.continue=function(){i.setSelectedProfile(e.profiles.selected),0===e.profiles.selected.optional_roles.length?(i.setOptionalRoles([]),t.path("/confirmProfile")):t.path("/selectOptions")},e.info=function(t){e.openInfo=t===e.openInfo?void 0:t}}])})),define("app/index",["angular","cjt/core","cjt/modules","app/filters/rolesLocaleString","app/services/serverProfileService"],(function(e,t){"use strict";var i="whm.serverProfile",o="ServerProfileSelector";return function(){e.module(i,["cjt2.config.whm.configProvider","cjt2.whm","cjt2.services.alert","whm.serverProfile.rolesLocaleString","whm.serverProfile.serverProfileService"]),require(["cjt/bootstrap","app/views/activatingProfileView","app/views/confirmProfileView","app/views/selectOptionsView","app/views/selectProfileView"],(function(l){var n=e.module(i),r=1===PAGE.availableProfiles.length,a=!!PAGE.currentProfile.optional_roles.length;n.value("PAGE",PAGE),n.value("LICENSE_BASED_SERVER_PROFILE",r),n.config(["$routeProvider",function(e){r||e.when("/selectProfile",{controller:"selectProfileController",templateUrl:t.buildFullPath("server_profile/views/selectProfileView.ptt")}),e.when("/selectOptions",{controller:"selectOptionsController",templateUrl:t.buildFullPath("server_profile/views/selectOptionsView.ptt")}),e.when("/confirmProfile",{controller:"confirmProfileController",templateUrl:t.buildFullPath("server_profile/views/confirmProfileView.ptt")}),e.when("/activatingProfile",{controller:"activatingProfileController",templateUrl:t.buildFullPath("server_profile/views/activatingProfileView.ptt")}),r?e.otherwise("/selectOptions"):e.otherwise("/selectProfile")}]),n.controller("baseController",["$scope","componentSettingSaverService","$location","$timeout",function(e,t,i,l){e.licenseBasedServerProfile=r,e.noOptionalRoles=!a,e.$on("ActivateProfileEvent",(function(){e.activationInitiated=!0})),e.$on("$destroy",(function(){t.unregister(o)})),e.dismissWarning=function(){t.set(o,{dismissedWarning:!0}),e.dismissedWarning=!0};var n=t.register(o);n?n.then((function(t){t&&void 0!==t.dismissedWarning&&(e.dismissedWarning=!0)})).finally((function(){i.path("/selectProfile"),l((function(){e.loaded=!0}))})):(i.path("/selectProfile"),l((function(){e.loaded=!0})))}]),l("#contentContainer",i)}))}}));
Back to Directory
File Manager