Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/scale/ |
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/scale/server.min.js |
(function(e){if(BX.Scale.Server)return;BX.Scale.Server=function(e,t){this.hostname=e;this.ip=t.ip;this.roles={};this.bxEnvVer=t.BX_ENV_VER||false;this.bxEnvNeedUpdate=t.BX_ENV_NEED_UPDATE||false;this.roles["SERVER"]=new BX.Scale.Role("SERVER",e,{noActions:this.bxEnvNeedUpdate});this.bxInfoError=t.BX_INFO_ERROR||false;this.mustChangeBitrixUsrPass=t.LAST_PASSWORD_CHANGE&&t.LAST_PASSWORD_CHANGE.search(/^password must be changed/)!=-1;if(t.roles!==undefined){for(var s in BX.Scale.rolesList){if(!BX.Scale.rolesList.hasOwnProperty(s))continue;var i={};if(s!="SERVER"){if(!t.roles[s]||typeof t.roles[s]==="function"){i.type="norole";if(BX.Scale.rolesList[s].HIDE_NOROLE)continue}else if(t.roles[s].type){i.type=t.roles[s].type}}i.noActions=this.bxEnvNeedUpdate&&this.mustChangeBitrixUsrPass;i.showMenu=!this.bxInfoError&&!this.bxEnvNeedUpdate;if(s=="web"&&t.roles["mgmt"]!==undefined)i.noActions=true;else if(s=="mysql")i.state=t.BX_INFO.mysql_service_status;this.roles[s]=new BX.Scale.Role(s,e,i)}var a={};for(var r in this.roles){if(!this.roles.hasOwnProperty(r))continue;var n=this.roles[r].getMonitoringCategories(e);for(var o in n){if(!n.hasOwnProperty(o))continue;if(BX.Scale.monitoringCategories[e][o]&&this.roles[r].type!="norole")a[o]=BX.Scale.monitoringCategories[e][o]}}if(BX.Scale.monitoringEnabled&&BX.Scale.isMonitoringDbCreated[this.hostname])this.infoTable=new BX.Scale.InfoTable(this.hostname,a)}this.domObj=null;this.idPrefix=e;this.showDel=t.showDel===true};BX.Scale.Server.prototype.getRolesObj=function(){var e=document.createElement("div");BX.addClass(e,"adm-scale-cont-block");for(var t in this.roles){var s=this.roles[t].getDomObj();if(s){e.appendChild(s)}}return e};BX.Scale.Server.prototype.getMenuObj=function(){var e=document.createElement("span");BX.addClass(e,"adm-scale-menu-btn");e.innerHTML=BX.message("SCALE_PANEL_JS_MENU");BX.bind(e,"click",BX.proxy(this.actionsMenuOpen,this));return e};BX.Scale.Server.prototype.actionsMenuOpen=function(t){t=t||e.event;var s=t.target||t.srcElement;var i=[];var a=this.getAviableActionsList();for(var r in a){var n=BX.Scale.actionsCollection.getObject(r);if(n){i.push({TEXT:n.name,ONCLICK:"BX.Scale.actionsCollection.getObject('"+r+"').start('"+this.hostname+"');"})}}if(!s.OPENER)BX.adminShowMenu(s,i,{active_class:"bx-adm-scale-menu-butt-active"});else s.OPENER.SetMenu(i);return BX.PreventDefault(t)};BX.Scale.Server.prototype.getHeaderObj=function(){var t=document.createElement("div"),s=this;BX.addClass(t,"adm-scale-block-header");if(!BX.Scale.isObjEmpty(this.getAviableActionsList()))t.appendChild(this.getMenuObj());var i=document.createElement("span");BX.addClass(i,"adm-scale-title");var a="";if(this.bxEnvVer){if(this.bxEnvNeedUpdate){a=BX.message("SCALE_PANEL_JS_BX_ENV_VERSION")+" "+"<span style='color: red;' title='"+BX.message("SCALE_PANEL_JS_BX_ENV_NEED_UPDATE")+"'>"+this.bxEnvVer+" ("+BX.message("SCALE_PANEL_JS_BX_ENV_NEED_UPDATE2")+")</span>"}else{a=BX.message("SCALE_PANEL_JS_BX_ENV_VERSION")+" "+"<span>"+this.bxEnvVer+"</span>";i.title=BX.message("SCALE_JS_SERVER_TITLE_TITLE");BX.bind(i,"click",function(t){e.location.href=BX.Scale.AdminFrame.graphPageUrl+"&SERVER_HOSTNAME="+s.hostname})}}else if(this.bxInfoError){a="<span style='color: red;' title='"+this.bxInfoError+"'>"+BX.message("SCALE_PANEL_JS_BX_INFO_ERROR")+"</span>"}else{a="<span style='color: red;'>"+BX.message("SCALE_PANEL_JS_BX_VER_ERROR")+"</span>"}i.innerHTML=this.hostname+" / "+this.ip+" / "+a;t.appendChild(i);if(this.showDel){var r=document.createElement("span");BX.addClass(r,"adm-scale-block-del");t.appendChild(r)}var n=document.createElement("span");BX.addClass(n,"adm-scale-img");t.appendChild(n);return t};BX.Scale.Server.prototype.getDomObj=function(){if(!this.domObj){this.domObj=document.createElement("div");this.domObj.id=this.idPrefix;BX.addClass(this.domObj,"adm-scale-block");this.domObj.appendChild(this.getHeaderObj());this.domObj.appendChild(this.getRolesObj());if(this.infoTable){this.domObj.appendChild(this.infoTable.getDomObj())}else if(BX.Scale.bitrixEnvType!="crm"){if(!BX.Scale.monitoringEnabled)this.domObj.appendChild(BX.create("DIV",{props:{className:"adm-scale-block-bottom"},html:BX.message("SCALE_PANEL_MONITORING_DISABLED")}));else if(!BX.Scale.isMonitoringDbCreated[this.hostname])this.domObj.appendChild(BX.create("DIV",{props:{className:"adm-scale-block-bottom"},html:BX.message("SCALE_PANEL_JS_MONITORING_DATABASE_CREATING")}))}}return this.domObj};BX.Scale.Server.prototype.getAviableActionsList=function(){var e={DEL_SERVER:true};if(this.bxInfoError)return e;if(!this.bxEnvNeedUpdate&&!this.mustChangeBitrixUsrPass){for(var t in this.roles){if(this.roles[t].type=="norole")continue;if(BX.Scale.rolesList[t]){var s=BX.Scale.rolesList[t];for(var i in s.ACTIONS){if(s.ACTIONS[i]=="DEL_SERVER"){var a=0;for(var r in this.roles)if(r!="SERVER"&&this.roles[r].type!="norole")a++;if(a>0){delete e["DEL_SERVER"];continue}}if(!e[s.ACTIONS[i]])e[s.ACTIONS[i]]=true}}else{BX.debug("Error! Role "+this.roles[t]+" not exist")}}}else if(this.mustChangeBitrixUsrPass){e["CHANGE_PASSWD_BITRIX"]=true}else if(this.bxEnvNeedUpdate){e["UPDATE_BVM"]=true}return e};BX.Scale.Server.prototype.getMonitoringParams=function(){var e={};if(this.infoTable)e=this.infoTable.getStructure();return e};BX.Scale.Server.prototype.setMonitoringValues=function(e){var t=false;if(this.infoTable)t=this.infoTable.setValues(e);return t}})(window);