Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/scale/ |
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/scale/role.min.js |
(function(e){if(BX.Scale.Role)return;BX.Scale.Role=function(e,t,i){this.id=e;this.hostname=t;this.domObj=null;this.showLoadBar=!!BX.Scale.rolesList[this.id].LOADBAR_INFO;this.showMenu=true;this.showMenuClose=false;this.type=null;this.state=null;this.color=BX.Scale.rolesList[this.id].COLOR||"invisible";this.noActions=false;if(i!==undefined){if(i.showMenu===false)this.showMenu=false;if(i.showMenuClose===true)this.showMenuClose=true;if(i.type!==undefined)this.type=i.type;if(i.type=="norole"){this.showLoadBar=false;if(this.color!="invisible")this.color=false}if(i.noActions&&i.noActions===true)this.noActions=true;if(i.state)this.state=i.state}if(this.showLoadBar)this.loadBar=new BX.Scale.LoadBar(t+"_"+e+"_lb");else this.loadBar=null;this.actionsIds=this.getAviableActionsList()};BX.Scale.Role.prototype.getMenuObj=function(){var e=BX.create("div",{props:{className:"adm-scale-item-menu"}});e.appendChild(BX.create("span",{props:{className:"adm-scale-item-menu-text"},html:BX.message("SCALE_PANEL_JS_MENU")}));BX.bind(e,"click",BX.proxy(this.menuOpen,this));if(this.showMenuClose)e.appendChild(BX.create("span",{props:{className:"adm-scale-item-close"}}));return e};BX.Scale.Role.prototype.menuOpen=function(t){t=t||e.event;var i=t.target||t.srcElement,s=[];for(var a in this.actionsIds){var o=BX.Scale.actionsCollection.getObject(a);if(o){s.push({TEXT:o.name,ONCLICK:"BX.Scale.actionsCollection.getObject('"+a+"').start('"+this.hostname+"');"})}}if(!i.OPENER)BX.adminShowMenu(i,s,{active_class:"bx-adm-scale-menu-butt-active"});else i.OPENER.SetMenu(s);return BX.PreventDefault(t)};BX.Scale.Role.prototype.getAviableActionsList=function(){var e={};if(!this.noActions){if(BX.Scale.rolesList[this.id]){var t=BX.Scale.rolesList[this.id],i=this.type||"notype",s;if(t.ROLE_ACTIONS&&t.ROLE_ACTIONS[i]){for(s in t.ROLE_ACTIONS[i]){if(!t.ROLE_ACTIONS[i].hasOwnProperty(s))continue;if(!e[t.ROLE_ACTIONS[i][s]]&&BX.Scale.actionsCollection.getObject(t.ROLE_ACTIONS[i][s])){e[t.ROLE_ACTIONS[i][s]]=true}}}if(this.state&&t.STATE_ACTIONS&&t.STATE_ACTIONS[this.state]){for(s in t.STATE_ACTIONS[this.state]){if(!t.STATE_ACTIONS[this.state].hasOwnProperty(s))continue;if(this.id=="mysql"&&this.type=="master"&&t.STATE_ACTIONS[this.state][s]=="MYSQL_STOP")continue;if(!e[t.STATE_ACTIONS[this.state][s]]&&BX.Scale.actionsCollection.getObject(t.STATE_ACTIONS[this.state][s])){e[t.STATE_ACTIONS[this.state][s]]=true}}}}}if(BX.Scale.isObjEmpty(e))e=null;return e};BX.Scale.Role.prototype.setLoadBarValue=function(e){var t=false;if(this.loadBar!==null)t=this.loadBar.setValue(e);return t};BX.Scale.Role.prototype.getDomObj=function(){if(this.color=="invisible")return null;if(!this.domObj){if(BX.Scale.rolesList[this.id]){this.domObj=document.createElement("div");this.domObj.id=this.hostname+"_"+this.id;BX.addClass(this.domObj,"adm-scale-item-block");var e=document.createElement("div");BX.addClass(e,"adm-scale-item");if(this.color)BX.addClass(e,"adm-scale-"+this.color);var t=document.createElement("span");BX.addClass(t,"adm-scale-item-alignment");e.appendChild(t);if(this.type&&this.type!="norole"){var i=document.createElement("div");BX.addClass(i,"adm-scale-item-btn");if(BX.Scale.rolesList[this.id].TYPES&&BX.Scale.rolesList[this.id].TYPES[this.type])i.innerHTML=BX.Scale.rolesList[this.id].TYPES[this.type];else i.innerHTML=this.type;e.appendChild(i)}var s=document.createElement("span");BX.addClass(s,"adm-scale-item-name");s.innerHTML=BX.Scale.rolesList[this.id].NAME;e.appendChild(s);if(this.state){e.appendChild(BX.create("span",{html:this.state,props:{className:"adm-scale-item-role-state"}}))}if(this.showMenu===true&&this.actionsIds){var a=this.getMenuObj();if(a)e.appendChild(a)}this.domObj.appendChild(e);if(this.loadBar!==null)this.domObj.appendChild(this.loadBar.getDomObj())}else{BX.debug("Error! Role "+this.id+" not defined")}}return this.domObj};BX.Scale.Role.prototype.getMonitoringCategories=function(e){var t={};if(BX.Scale.rolesList[this.id].MONITORING_CATEGORIES){for(var i in BX.Scale.rolesList[this.id].MONITORING_CATEGORIES){if(BX.Scale.monitoringCategories[e][BX.Scale.rolesList[this.id].MONITORING_CATEGORIES[i]])t[BX.Scale.rolesList[this.id].MONITORING_CATEGORIES[i]]=BX.Scale.monitoringCategories[e][BX.Scale.rolesList[this.id].MONITORING_CATEGORIES[i]]}}return t}})(window);