iobroker.admin 7.6.13 → 7.6.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -8
- package/adminWww/assets/{AdapterUpdateDialog-B8g_ZuhP.js → AdapterUpdateDialog-DnnNHIQJ.js} +1 -1
- package/adminWww/assets/{Adapters-XtPWdL3s.js → Adapters-Ctxos-gw.js} +4 -4
- package/adminWww/assets/{Config-Dhj9WMpz.js → Config-Dyad6_tq.js} +1 -1
- package/adminWww/assets/CustomModal-BNDSg_P8.js +1 -0
- package/adminWww/assets/{CustomTab-CSgGzXlh.js → CustomTab-BEL1ttN8.js} +1 -1
- package/adminWww/assets/{EasyMode-Bwx_UimW.js → EasyMode-3ydknWSd.js} +1 -1
- package/adminWww/assets/{Enums-B-PrqYys.js → Enums-nRoQYhch.js} +2 -2
- package/adminWww/assets/{Fields-CYjxm_8L.js → Fields-Bwvci3VO.js} +1 -1
- package/adminWww/assets/{Files-CsBMd5VX.js → Files-Dzs9GmrC.js} +1 -1
- package/adminWww/assets/{Hosts-D7aAXH9U.js → Hosts-BjpHSLCf.js} +3 -3
- package/adminWww/assets/{Instances-Bj8CqStT.js → Instances-BtTV4PMv.js} +2 -2
- package/adminWww/assets/Intro-DD3K3IVm.js +2 -0
- package/adminWww/assets/{Logs-Bb16bYuu.js → Logs-BXU61QOI.js} +1 -1
- package/adminWww/assets/{Objects-C7k5tHdx.js → Objects-jsWq-neK.js} +2 -2
- package/adminWww/assets/{State-DPLzxZ6D.js → State-CuA1h-bU.js} +1 -1
- package/adminWww/assets/{Users-BQ3pWAxq.js → Users-BFdQMyo4.js} +1 -1
- package/adminWww/assets/{ace-j1VT51C2.js → ace-CI9-Cq3I.js} +2 -2
- package/adminWww/assets/{bootstrap-BNkcLa73.js → bootstrap-FCtLxt0T.js} +14 -14
- package/adminWww/assets/{index-jZ28cZd6.js → index-3IvffoSA.js} +1 -1
- package/adminWww/assets/{index-C6O1p4S2.js → index-DPxBLJAn.js} +2 -2
- package/adminWww/assets/{sentry-9i5rBs6L.js → sentry-BNaNpYqi.js} +1 -1
- package/adminWww/assets/{zh-cn-CULr7ytT.js → zh-cn-CbEN7EL2.js} +1 -1
- package/adminWww/index.html +1 -1
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/remoteEntry.js +2 -2
- package/io-package.json +15 -15
- package/package.json +12 -7
- package/adminWww/assets/CustomModal-4eTuDNla.js +0 -1
- package/adminWww/assets/Intro-sAT0x17e.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as s,B as A,F as S,J as B}from"./DefaultPropsProvider-BrbE0teb.js";import{i as I,R as P}from"./iobroker_admin__loadShare__react__loadShare__-DtlEM_52.js";import{i as n,U as b,a as f,f as C,p as R,q as M,I as w,o as W,s as N,h as F}from"./bootstrap-FCtLxt0T.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BGyJCibC.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-CI9-Cq3I.js";import"./FilledInput-D-tz8rvg.js";import"./preload-helper-C1FmrZbK.js";import"./blueGrey-B0oIowPK.js";import"./emotion-cache.browser.esm-B8BFze5o.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-B1OZ7tj-.js";import"./extends-CF3RwP-h.js";const O="0 2px 2px 0 rgba(0, 0, 0, .14),0 3px 1px -2px rgba(0, 0, 0, .12),0 1px 5px 0 rgba(0, 0, 0, .2)",E="0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)",u={root:g=>({padding:".75rem",[g.breakpoints.up("xl")]:{flex:"0 1 20%"}}),card:{display:"flex",minHeight:"235px",position:"relative",overflow:"hidden",maxHeight:"235p","&:hover":{overflowY:"auto",boxShadow:E}},cardInfo:{display:"flex",minHeight:"235px",position:"relative",overflow:"initial",maxHeight:"235p",flexDirection:"column","&:hover":{boxShadow:E}},cardInfoHead:g=>({position:"sticky",top:0,background:g.palette.background.default,display:"flex",width:"100%",justifyContent:"space-between",borderBottom:"1px solid",padding:"5px 5px 0px 5px"}),edit:{opacity:.6,userSelect:"none",pointerEvents:"none"},media:g=>({backgroundColor:g.palette.mode==="dark"?"#535353":"#e2e2e2",maxWidth:"30%"}),img:{width:120,height:"auto",padding:"2rem .5rem",maxWidth:"100%"},contentContainer:{display:"flex",flexDirection:"column",flex:1},content:{height:"170px",flexGrow:1,overflowY:"hidden"},action:{minHeight:"49px",padding:"16px 24px"},expand:{position:"absolute",right:"10px",bottom:"10px"},collapse:{minHeight:"100%",backgroundColor:"#ffffff",position:"absolute",width:"100%"},enabled:{color:"#ffffff",backgroundColor:A[500],position:"absolute",top:8,right:8,boxShadow:O,"&:hover":{backgroundColor:A[300]},"&:focus":{backgroundColor:A[500]}},disabled:{color:"#ffffff",backgroundColor:S[500],position:"absolute",top:8,right:8,boxShadow:O,"&:hover":{backgroundColor:S[300]},"&:focus":{backgroundColor:S[500]}},editButton:{color:"#ffffff",backgroundColor:S[500],position:"absolute",top:64,right:8,boxShadow:O,"&:hover":{backgroundColor:S[300]},"&:focus":{backgroundColor:S[500]}},deleteButton:{color:"#ffffff",backgroundColor:B[500],position:"absolute",top:120,right:8,boxShadow:O,"&:hover":{backgroundColor:B[300]},"&:focus":{backgroundColor:B[500]}},contentGrid:{height:"100%"},colorOrange:{color:"#ffcc80"},tooltip:{pointerEvents:"none"}};class U extends I.Component{constructor(t){super(t),this.state={expanded:!1}}static getDerivedStateFromProps(t){return t.edit?{expanded:!1}:null}handleExpandClick(){this.setState({expanded:!this.state.expanded})}renderContent(){return this.props.children}openDialog(){}renderDialogs(){return null}render(){var o,i;const t=this.props.edit?u.edit:void 0;let e=this.props.action.text||this.props.t("Link");return typeof e=="object"&&(e=e[this.props.lang]||e.en),s.jsx(n.Grid2,{size:{xs:12,sm:6,md:4,lg:3,xl:2},sx:b.getStyle(this.props.theme,u.root,this.props.style),style:{maxWidth:500},children:s.jsx(n.Link,{href:!this.props.edit&&this.props.action&&this.props.action.link?this.props.action.link:null,underline:"none",target:"_blank",rel:"noopener noreferrer",children:s.jsxs(n.Card,{sx:u.card,onClick:d=>{d.stopPropagation(),this.openDialog()},children:[this.props.showInfo&&!this.props.offline&&s.jsx(n.Button,{style:{...u.expand,...t},variant:"contained",size:"small",disabled:this.props.disabled,onClick:()=>this.handleExpandClick(),color:"primary",children:this.props.t("Info")}),s.jsxs(n.Box,{component:"div",sx:b.getStyle(this.props.theme,u.media,t,this.props.color&&{backgroundColor:this.props.color},{display:"flex",flexDirection:"column"}),children:[s.jsx(n.CardMedia,{style:u.img,component:"img",image:this.props.image}),s.jsx("div",{style:{flex:1,display:"flex",paddingBottom:"5px",paddingLeft:"5px"},children:this.props.warning?s.jsx(n.Tooltip,{title:this.props.warning,slotProps:{popper:{sx:u.tooltip}},children:s.jsx(f.Warning,{style:{alignSelf:"end",fontSize:36}})}):null})]}),s.jsxs("div",{style:{...u.contentContainer,...t},children:[s.jsx(n.CardContent,{style:u.content,children:s.jsxs(n.Grid2,{container:!0,direction:"column",wrap:"nowrap",style:u.contentGrid,children:[s.jsx(n.Typography,{gutterBottom:!0,variant:"h5",component:"h5",children:this.props.title}),this.renderContent()]})}),((o=this.props.action)==null?void 0:o.link)&&s.jsx(n.Divider,{}),((i=this.props.action)==null?void 0:i.link)&&s.jsx(n.CardActions,{style:u.action,children:s.jsx("div",{style:u.colorOrange,children:C.getText(e,this.props.lang)})})]}),this.props.showInfo&&s.jsx(n.Collapse,{style:u.collapse,in:this.state.expanded,timeout:"auto",unmountOnExit:!0,children:s.jsxs(n.Card,{sx:u.cardInfo,children:[s.jsxs(n.Box,{component:"div",sx:u.cardInfoHead,children:[s.jsx(n.Typography,{gutterBottom:!0,variant:"h5",component:"h5",children:this.props.t("Info")}),s.jsxs("div",{children:[s.jsx(n.IconButton,{size:"small",onClick:()=>{this.props.getHostDescriptionAll&&b.copyToClipboard(this.props.getHostDescriptionAll().text),this.props.openSnackBarFunc&&this.props.openSnackBarFunc()},children:s.jsx(R,{})}),s.jsx(n.IconButton,{size:"small",onClick:()=>this.handleExpandClick(),children:s.jsx(f.Close,{})})]})]}),s.jsx(n.CardContent,{children:this.props.getHostDescriptionAll().el})]})}),this.props.edit&&this.props.toggleActivation&&s.jsx(n.IconButton,{size:"large",sx:this.props.enabled?u.enabled:u.disabled,onClick:()=>this.props.toggleActivation(),children:s.jsx(f.Check,{})}),this.props.edit&&this.props.onEdit&&s.jsx(n.IconButton,{size:"large",sx:u.editButton,onClick:()=>this.props.onEdit(),children:s.jsx(f.Create,{})}),this.props.edit&&this.props.onRemove&&s.jsx(n.IconButton,{size:"large",sx:u.deleteButton,onClick:()=>this.props.onRemove(),children:s.jsx(f.Delete,{})}),this.renderDialogs()]})})})}}const _={closeButton:g=>({position:"absolute",right:8,top:8,color:g.palette.grey[500]}),paper:{},typography:{paddingRight:30},img:{width:"100%",height:"100%",objectFit:"contain"}};class z extends I.Component{cameraUpdateTimer;cameraRef;constructor(t){super(t),this.cameraUpdateTimer=null,this.cameraRef=I.createRef()}componentDidMount(){this.props.camera&&this.props.camera!=="text"&&(this.cameraUpdateTimer=setInterval(()=>this.updateCamera(),Math.max(parseInt(this.props.interval,10),500)),this.updateCamera())}componentWillUnmount(){this.cameraUpdateTimer&&(clearInterval(this.cameraUpdateTimer),this.cameraUpdateTimer=null)}updateCamera(){if(this.cameraRef.current)if(this.props.camera==="custom"){let t=this.props.cameraUrl;this.props.addTs&&(t.includes("?")?t+=`&ts=${Date.now()}`:t+=`?ts=${Date.now()}`),this.cameraRef.current.src=t}else{const t=this.props.camera.split("."),e=t.shift(),o=t.shift();this.props.socket.sendTo(`${e}.${o}`,"image",{name:t.pop(),width:this.cameraRef.current.width}).then(i=>{i&&i.data&&this.cameraRef.current&&(this.cameraRef.current.src=`data:image/jpeg;base64,${i.data}`)})}}render(){return s.jsxs(n.Dialog,{onClose:()=>this.props.onClose(),open:!0,maxWidth:"xl",fullWidth:!0,fullScreen:!0,sx:{"& .MuiDialog-paper":_.paper},children:[s.jsx(n.DialogTitle,{children:s.jsxs(n.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":_.typography},children:[this.props.name,s.jsx(n.IconButton,{size:"large",sx:_.closeButton,onClick:()=>this.props.onClose(),children:s.jsx(f.Close,{})})]})}),s.jsx(n.DialogContent,{dividers:!0,children:s.jsx("img",{style:_.img,src:"",alt:"camera",ref:this.cameraRef})}),s.jsx(n.DialogActions,{children:s.jsx(n.Button,{variant:"contained",autoFocus:!0,onClick:t=>{t.stopPropagation(),this.props.onClose()},color:"primary",startIcon:s.jsx(f.Close,{}),children:this.props.t("Close")})})]})}}const D={cameraImg:{width:"100%",height:"100%",maxWidth:200,maxHeight:200,objectFit:"contain"},imgContainer:{height:"100%"},hidden:{display:"none"},imgSkeleton:{transform:"initial"}};class J extends U{cameraRef;cameraUpdateTimer;interval;constructor(t){super(t),Object.assign(this.state,{error:!1,dialog:!1,loaded:!1}),this.cameraRef=I.createRef(),this.cameraUpdateTimer=null,this.interval=t.interval}updateCamera(){if(this.cameraRef.current)if(this.props.camera==="custom"){let t=this.props.cameraUrl;this.props.addTs&&(t.includes("?")?t+=`&ts=${Date.now()}`:t+=`?ts=${Date.now()}`),this.cameraRef.current.src=t}else{const t=this.props.camera.split("."),e=t.shift(),o=t.shift();this.props.socket.sendTo(`${e}.${o}`,"image",{name:t.pop(),width:this.cameraRef.current.width}).then(i=>{i!=null&&i.data&&this.cameraRef.current&&(this.cameraRef.current.src=`data:image/jpeg;base64,${i.data}`)}).catch(i=>window.alert(`Cannot send to instance: ${i}`))}}componentDidMount(){this.props.camera&&this.props.camera!=="text"&&(this.cameraUpdateTimer=setInterval(()=>this.updateCamera(),Math.max(parseInt(this.props.interval,10),500)),this.updateCamera())}componentWillUnmount(){this.cameraUpdateTimer&&(clearInterval(this.cameraUpdateTimer),this.cameraUpdateTimer=null)}renderDialogs(){return this.state.dialog?s.jsx(z,{socket:this.props.socket,camera:this.props.camera,name:this.props.title,t:this.props.t,onClose:()=>{this.props.camera&&this.props.camera!=="text"&&(this.cameraUpdateTimer&&clearInterval(this.cameraUpdateTimer),this.cameraUpdateTimer=setInterval(()=>this.updateCamera(),Math.max(parseInt(this.props.interval,10),500)),this.updateCamera()),this.setState({dialog:!1})},cameraUrl:this.props.cameraUrl}):null}handleImageLoad(){this.state.loaded||this.setState({loaded:!0,error:!1})}handleImageError(){this.state.error||this.setState({loaded:!1,error:!0})}renderContent(){if(this.props.camera==="custom"){let t=this.props.cameraUrl;return this.props.addTs&&(t.includes("?")?t+=`&ts=${Date.now()}`:t+=`?ts=${Date.now()}`),s.jsxs(n.Grid2,{container:!0,style:D.imgContainer,justifyContent:"center",alignItems:"center",children:[s.jsx("img",{ref:this.cameraRef,src:t,alt:"Camera",style:this.state.loaded&&!this.state.error?D.cameraImg:D.hidden,onLoad:()=>this.handleImageLoad(),onError:()=>this.handleImageError()}),!this.state.loaded&&!this.state.error&&s.jsx(n.Skeleton,{height:"100%",width:"100%",animation:"wave",style:D.imgSkeleton}),this.state.error&&s.jsx(f.Error,{fontSize:"large"})]})}return this.props.camera.startsWith("cameras.")?s.jsx("img",{ref:this.cameraRef,src:"",alt:"camera",style:D.cameraImg}):null}render(){return this.props.camera&&this.props.camera!=="text"?this.interval!==this.props.interval&&(this.interval=this.props.interval,this.cameraUpdateTimer&&clearInterval(this.cameraUpdateTimer),this.cameraUpdateTimer=setInterval(()=>this.updateCamera(),Math.max(parseInt(this.props.interval,10),500))):this.cameraUpdateTimer&&(clearInterval(this.cameraUpdateTimer),this.cameraUpdateTimer=null),super.render()}}const x={formControl:{marginTop:32},rootGrid:{flexGrow:1},closeButton:g=>({position:"absolute",right:8,top:8,color:g.palette.grey[500]}),paper:{},typography:{paddingRight:30},editItem:{marginTop:8},editItemSlider:{marginTop:24},labelSlider:{marginTop:16,fontSize:"1rem"},editColor:{width:"100%"}};class $ extends I.Component{constructor(t){super(t),this.state={image:"",name:t.t("New link"),link:"http://",linkName:"",color:"",desc:"",addTs:!0,interval:5e3,camera:"text",cameraList:[],...t.link}}componentDidMount(){this.getCamerasInstances()}getCamerasInstances(){this.props.socket.getAdapterInstances("cameras",!0).then(t=>{const e=[],o=[];t.forEach(i=>{const d=i._id.replace("system.adapter.","");i.common&&i.common.enabled&&o.push(this.props.socket.getState(`${i._id}.alive`).then(a=>a&&a.val&&this.props.socket.sendTo(d,"list",null)).then(a=>a&&a.list&&a.list.forEach(r=>e.push({id:r.id,name:`${r.desc} [${d}/${r.name}]`}))))}),Promise.all(o).then(()=>this.setState({cameraList:e}))})}static getLinkNameFromLink(t){const e=t.trim().match(/^https?:\/\/([^/:]+)(:\d+)?/);return e?e[1]+(e[2]||""):""}render(){return s.jsxs(n.Dialog,{onClose:()=>this.props.onClose(),open:!0,maxWidth:"md",fullWidth:!0,sx:{"& .MuiDialog-paper":x.paper},children:[s.jsx(n.DialogTitle,{children:s.jsxs(n.Typography,{component:"h2",variant:"h6",sx:{"&.MuiTypography-root":x.typography},children:[this.props.isNew?this.props.t("Add new link: "):this.props.t("Edit link"),s.jsx(n.IconButton,{size:"large",sx:x.closeButton,onClick:()=>this.props.onClose(),children:s.jsx(f.Close,{})})]})}),s.jsx(n.DialogContent,{dividers:!0,children:s.jsxs(n.Grid2,{style:x.rootGrid,container:!0,direction:"row",children:[s.jsx(n.Grid2,{size:{xs:12,sm:6,md:8,lg:9},children:s.jsxs(n.Grid2,{container:!0,direction:"column",children:[s.jsxs(n.FormControl,{variant:"standard",style:x.formControl,children:[s.jsx(n.InputLabel,{id:"select-helper-label",children:this.props.t("Link type")}),s.jsxs(n.Select,{variant:"standard",labelId:"select-helper-label",value:this.state.camera,onChange:t=>this.setState({camera:t.target.value}),children:[s.jsx(n.MenuItem,{value:"text",children:s.jsx("em",{children:this.props.t("Description")})},"desc"),this.state.cameraList.map(t=>s.jsx(n.MenuItem,{value:t.id,children:t.name},t.id)),s.jsx(n.MenuItem,{value:"custom",children:this.props.t("Custom camera URL")},"custom")]})]}),s.jsx(n.TextField,{variant:"standard",label:this.props.t("URL"),value:this.state.link,style:x.editItem,onChange:t=>{const e=$.getLinkNameFromLink(this.state.link);e&&(!this.state.linkName||e===this.state.linkName)?this.setState({link:t.target.value,linkName:$.getLinkNameFromLink(t.target.value)}):this.setState({link:t.target.value})},slotProps:{input:{endAdornment:this.state.link?s.jsx(n.InputAdornment,{position:"end",children:s.jsx(n.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({link:""}),children:s.jsx(f.Close,{})})}):null}}}),s.jsx(n.TextField,{variant:"standard",style:x.editItem,label:this.props.t("Name"),value:this.state.name||"",onChange:t=>this.setState({name:t.target.value}),slotProps:{input:{endAdornment:this.state.name?s.jsx(n.InputAdornment,{position:"end",children:s.jsx(n.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({name:""}),children:s.jsx(f.Close,{})})}):null}}}),this.state.link?s.jsx(n.TextField,{variant:"standard",style:x.editItem,label:this.props.t("Link name"),value:this.state.linkName||"",onChange:t=>this.setState({linkName:t.target.value}),slotProps:{input:{endAdornment:this.state.linkName?s.jsx(n.InputAdornment,{position:"end",children:s.jsx(n.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({linkName:""}),children:s.jsx(f.Close,{})})}):null}}}):null,this.state.camera==="custom"||this.state.camera==="text"?s.jsx(n.TextField,{variant:"standard",style:x.editItem,label:this.state.camera==="custom"?this.props.t("Camera URL"):this.props.t("Description"),value:this.state.desc||"",onChange:t=>this.setState({desc:t.target.value}),slotProps:{input:{endAdornment:this.state.desc?s.jsx(n.InputAdornment,{position:"end",children:s.jsx(n.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setState({desc:""}),children:s.jsx(f.Close,{})})}):null}}}):null,this.state.camera==="custom"?s.jsx(n.FormControlLabel,{style:x.editItem,control:s.jsx(n.Checkbox,{checked:this.state.addTs,onChange:t=>this.setState({addTs:t.target.checked})}),label:this.props.t("Add timestamp to URL")}):null,this.state.camera!=="text"?s.jsx(n.Typography,{style:x.labelSlider,gutterBottom:!0,children:"Polling interval in ms"}):null,this.state.camera!=="text"?s.jsx(n.Slider,{style:x.editItemSlider,value:this.state.interval,getAriaValueText:()=>`${this.state.interval}ms`,onChange:(t,e)=>this.setState({interval:e}),step:100,min:500,max:6e4,valueLabelDisplay:"on"}):null,s.jsx("div",{style:{...x.editItem,width:50},children:s.jsx(n.TextField,{variant:"standard",fullWidth:!0,label:this.props.t("Color"),style:x.editColor,type:"color",value:this.state.color,onChange:t=>this.setState({color:t.target.value})})}),s.jsx(M,{disabled:!1,crop:!0,maxSize:256*1024,icon:this.state.image,removeIconFunc:()=>this.setState({image:""}),onChange:t=>this.setState({image:t})})]})}),s.jsx(n.Grid2,{size:{xs:12,sm:6,md:4,lg:3},children:this.state.camera==="text"?s.jsx(U,{image:this.state.image,title:this.state.name,action:{link:this.state.link,text:this.state.linkName},t:this.props.t,lang:this.props.lang,style:{width:"100% !important",maxWidth:"100% !important",marginLeft:"8px"},color:this.state.color,enabled:!0,theme:this.props.theme,children:this.state.desc}):s.jsx(J,{interval:this.state.interval,camera:this.state.camera,addTs:this.state.addTs,style:{width:"100% !important",maxWidth:"100% !important",marginLeft:"8px"},image:this.state.image,title:this.state.name,socket:this.props.socket,action:{link:this.state.link,text:this.state.linkName},t:this.props.t,lang:this.props.lang,color:this.state.color,enabled:!0,cameraUrl:this.state.desc,theme:this.props.theme})})]})}),s.jsxs(n.DialogActions,{children:[s.jsx(n.Button,{variant:"contained",autoFocus:!0,onClick:()=>{this.props.onClose({link:this.state.link,name:this.state.name,desc:this.state.desc,linkName:this.state.linkName,color:this.state.color,image:this.state.image,addTs:this.state.addTs,camera:this.state.camera,interval:this.state.interval})},color:"primary",startIcon:this.props.isNew?s.jsx(f.Add,{}):s.jsx(f.Check,{}),children:this.props.isNew?this.props.t("Add"):this.props.t("Save")}),s.jsx(n.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:s.jsx(f.Close,{}),children:this.props.t("Close")})]})]})}}class G extends P.Component{constructor(t){super(t),this.state={inProgress:!1,success:!1,error:"",finished:!1}}render(){return s.jsxs(n.Dialog,{open:!0,maxWidth:"lg",fullWidth:!0,children:[s.jsx(n.DialogTitle,{children:w.t("Node.js upgrade")}),s.jsxs(n.DialogContent,{style:{height:100,padding:"0 20px",overflow:"hidden"},children:[this.state.finished?null:s.jsx(n.Typography,{children:w.t("Performing this update will restart the js-controller afterwards!")}),this.state.inProgress?s.jsx(n.Box,{sx:{display:"flex",justifyContent:"center"},children:s.jsx(n.CircularProgress,{})}):null,this.state.success?s.jsx(n.Typography,{children:w.t("Node.js update successful, restarting controller now!")}):null,this.state.error?s.jsx(n.Typography,{sx:{color:"red"},children:w.t("Node.js update failed: %s",this.state.error)}):null]}),s.jsxs(n.DialogActions,{children:[s.jsx(n.Button,{disabled:this.state.inProgress||this.state.finished,color:"primary",variant:"contained",startIcon:s.jsx(f.Refresh,{}),onClick:()=>this.updateNodeJsVersion(),children:w.t("Upgrade")}),s.jsx(n.Button,{disabled:this.state.inProgress,variant:"contained",onClick:()=>{this.props.onClose()},color:"primary",startIcon:s.jsx(f.Close,{}),children:w.t("Close")})]})]})}async updateNodeJsVersion(){this.setState({inProgress:!0});const t=await this.props.socket.upgradeOsPackages(this.props.hostId,[{name:"nodejs"}],!0);this.setState({inProgress:!1,success:t.success,error:t.error,finished:!0})}}const m={button:{position:"absolute",bottom:16,right:16},saveButton:g=>({backgroundColor:g.palette.success.main,right:80,"&:hover":{backgroundColor:g.palette.success.dark}}),addButton:g=>({backgroundColor:g.palette.secondary.main,right:144,"&:hover":{backgroundColor:g.palette.secondary.dark}}),closeButton:g=>({backgroundColor:g.palette.error.main,"&:hover":{backgroundColor:g.palette.error.dark}}),bold:{fontWeight:"bold"},hostOffline:{color:"#bb0000"},updateExists:{color:"#c28700",marginRight:4},updateNo:{color:"#00b204",marginRight:4},nodeUpdate:{opacity:.6},instanceNumber:{opacity:.7,fontSize:16},updateIcon:{cursor:"pointer",fontSize:16},tooltip:{pointerEvents:"none"},viewModeDiv:{display:"flex",flexFlow:"wrap",overflow:"auto",justifyContent:"left"}},T={Uptime:C.formatSeconds,"System uptime":C.formatSeconds,RAM:C.formatRam,Speed:C.formatSpeed,"Disk size":C.formatBytes,"Disk free":C.formatBytes};class v extends P.Component{#t=30*60*1e3;#e=60*1e3;currentProxyPath=window.location.pathname;introLinksOriginal;deactivatedOriginal;t;getDataTimeout;constructor(t){super(t),this.state={instances:null,deactivated:[],edit:!1,link:null,introLinks:[],editLink:!1,editLinkIndex:-1,openSnackBar:!1,hasUnsavedChanges:!1,reverseProxy:null,alive:{},hostsData:{},hosts:null,hostTimeDiffMap:new Map,nodeUpdateSupported:!1,nodeUpdateDialog:null},this.t=t.t}checkBackendTime(){const t=this.state.hostTimeDiffMap;for(const[e,o]of Object.entries(this.state.hostsData)){const i=new Date,d=Math.abs(o.time-i.getTime());t.set(e,d)}this.setState({hostTimeDiffMap:t})}async componentDidMount(){var o;await this.getData(),this.props.instancesWorker.registerHandler(this.getDataDelayed),this.props.hostsWorker.registerHandler(this.updateHosts),this.props.hostsWorker.registerAliveHandler(this.updateHostsAlive);const t=await this.props.socket.checkFeatureSupported("CONTROLLER_OS_PACKAGE_UPGRADE"),e=await this.props.socket.getObject(`system.adapter.${this.props.adminInstance}`);this.setState({nodeUpdateSupported:t,reverseProxy:((o=e==null?void 0:e.native)==null?void 0:o.reverseProxy)||[]}),this.checkBackendTime()}componentWillUnmount(){this.getDataTimeout&&(clearTimeout(this.getDataTimeout),this.getDataTimeout=void 0),this.props.instancesWorker.unregisterHandler(this.getDataDelayed),this.props.hostsWorker.unregisterHandler(this.updateHosts),this.props.hostsWorker.unregisterAliveHandler(this.updateHostsAlive)}updateHostsAlive=async t=>{const e=JSON.parse(JSON.stringify(this.state.alive)),o=[];if(t.find(i=>i.type==="deleted")){this.getDataDelayed();return}if(t.forEach(i=>{!!e[i.id]!=!!i.alive&&(e[i.id]=i.alive,o.push(i.id))}),o.length){const i=JSON.parse(JSON.stringify(this.state.hostsData));(await Promise.all(o.map(a=>this.getHostData(a,e[a])))).forEach(a=>i[a.id]=v.preprocessHostData(a.data)),this.setState({alive:e,hostsData:i},()=>this.checkBackendTime())}};updateHosts=t=>{let e=[];if(t.find(o=>!o.obj)){this.getDataDelayed();return}if(e=t.map(o=>o.id),e.length){const o=JSON.parse(JSON.stringify(this.state.hostsData));Promise.all(e.map(i=>this.getHostData(i))).then(i=>{i.forEach(d=>o[d.id]=v.preprocessHostData(d.data)),this.setState({hostsData:o})})}};async activateEditMode(){var i;const t=await this.props.socket.getSystemConfig(!0),e=await this.getInstances(!0,null,t),o=(i=t==null?void 0:t.native)!=null&&i.introLinks?t.native.introLinks:[];this.introLinksOriginal=JSON.stringify(o),this.deactivatedOriginal=JSON.parse(JSON.stringify(e.deactivated)),this.setState({instances:e.instances,deactivated:e.deactivated,edit:!0,introLinks:o,hasUnsavedChanges:!1})}deactivateEditMode(){this.state.hasUnsavedChanges,this.setState({deactivated:this.deactivatedOriginal,introLinks:JSON.parse(this.introLinksOriginal),hasUnsavedChanges:!1,edit:!1},()=>{this.deactivatedOriginal=null,this.introLinksOriginal=null})}toggleCard(t,e){if(!this.state.instances||!this.state.instances.length)return;const o=JSON.parse(JSON.stringify(this.state.deactivated)),i=o.indexOf(`${t}_${e}`);i!==-1?o.splice(i,1):(o.push(`${t}_${e}`),o.sort());const d=JSON.stringify(o)!==JSON.stringify(this.deactivatedOriginal)||JSON.stringify(this.state.introLinks)!==this.introLinksOriginal;this.setState({deactivated:o,hasUnsavedChanges:d})}getInstancesCards(){var t;return(t=this.state.instances)==null?void 0:t.map(e=>{var i,d;const o=!((i=this.state.deactivated)!=null&&i.includes(`${e.id}_${e.linkName}`));if(o||this.state.edit){let a=e.link?e.link.replace(/^https?:\/\//,""):"";if(a=a.split("/")[0],e.id===this.props.adminInstance)return null;let r=window.isFinite(e.id.split(".").pop());r&&(r=!!((d=this.state.instances)!=null&&d.find(c=>c.id!==e.id&&e.name===c.name&&e.id.split(".")[0]===c.id.split(".")[0])));const l=this.state.hostsData?this.state.hostsData[e.id]:null,h=this.state.hostTimeDiffMap.get(e.id)??0;return s.jsx(U,{image:e.image,title:s.jsxs(s.Fragment,{children:[s.jsx("span",{style:e.name&&e.name.length>12?{fontSize:"1rem"}:void 0,children:e.name}),r?s.jsxs("span",{style:m.instanceNumber,children:[".",e.id.split(".").pop()]}):null]}),action:{link:e.link,text:a},t:this.props.t,lang:this.props.lang,color:e.color,showInfo:!!e.info,edit:this.state.edit,offline:l&&l.alive===!1,warning:h>this.#t?this.t("Backend time differs by %s minutes",Math.round(h/this.#e).toString()):null,enabled:o,disabled:!l||typeof l!="object",getHostDescriptionAll:()=>this.getHostDescriptionAll(e.id),toggleActivation:()=>this.toggleCard(e.id,e.linkName),openSnackBarFunc:()=>this.setState({openSnackBar:!0}),theme:this.props.theme,children:e.description||this.getHostDescription(e.id)},`${e.id}_${e.link}`)}return null})}toggleLinkCard(t){const e=JSON.parse(JSON.stringify(this.state.introLinks));e[t].enabled=!e[t].enabled;const o=JSON.stringify(this.state.deactivated)!==JSON.stringify(this.deactivatedOriginal)||JSON.stringify(e)!==this.introLinksOriginal;this.setState({introLinks:e,hasUnsavedChanges:o})}getLinkCards(){var t;return(t=this.state.introLinks)==null?void 0:t.map((e,o)=>!e.enabled&&!this.state.edit?null:e.camera==="custom"?s.jsx(J,{image:e.image,title:e.name,action:{link:e.link,text:e.linkName},t:this.props.t,socket:this.props.socket,color:e.color,edit:this.state.edit,interval:e.interval,camera:e.camera,addTs:e.addTs,onEdit:()=>{var i;return this.setState({editLink:!0,editLinkIndex:o,link:JSON.parse(JSON.stringify((i=this.state.introLinks)==null?void 0:i[o]))})},onRemove:()=>{const i=JSON.parse(JSON.stringify(this.state.introLinks));i.splice(o,1);const d=JSON.stringify(this.state.deactivated)!==JSON.stringify(this.deactivatedOriginal)||JSON.stringify(i)!==this.introLinksOriginal;this.setState({introLinks:i,hasUnsavedChanges:d})},enabled:e.enabled,lang:this.props.lang,toggleActivation:()=>this.toggleLinkCard(o),cameraUrl:e.desc,theme:this.props.theme},`link${o}`):s.jsx(U,{image:e.image,title:e.name,action:{link:e.link,text:e.linkName},t:this.props.t,color:e.color,edit:this.state.edit,onEdit:()=>{var i;return this.setState({editLink:!0,editLinkIndex:o,link:JSON.parse(JSON.stringify((i=this.state.introLinks)==null?void 0:i[o]))})},onRemove:()=>{const i=JSON.parse(JSON.stringify(this.state.introLinks));i.splice(o,1);const d=JSON.stringify(this.state.deactivated)!==JSON.stringify(this.deactivatedOriginal)||JSON.stringify(i)!==this.introLinksOriginal;this.setState({introLinks:i,hasUnsavedChanges:d})},enabled:e.enabled,lang:this.props.lang,toggleActivation:()=>this.toggleLinkCard(o),theme:this.props.theme,children:e.desc||""},`link${o}`))}editLinkCard(){return this.state.editLink?s.jsx($,{link:this.state.link,socket:this.props.socket,isNew:this.state.editLinkIndex===-1,t:this.props.t,lang:this.props.lang,theme:this.props.theme,onClose:t=>{if(t){const e=JSON.parse(JSON.stringify(this.state.introLinks));this.state.editLinkIndex===-1?(t.enabled=!0,e.push(t)):(t.enabled=e[this.state.editLinkIndex].enabled,e[this.state.editLinkIndex]=t);const o=JSON.stringify(this.state.deactivated)!==JSON.stringify(this.deactivatedOriginal)||JSON.stringify(e)!==this.introLinksOriginal;this.setState({introLinks:e,editLink:!1,hasUnsavedChanges:o,link:null})}else this.setState({editLink:!1})}}):null}getButtons(){const t=[];return this.state.edit?(t.push(s.jsx(n.Fab,{color:"primary",size:"small",sx:b.getStyle(this.props.theme,m.button,m.addButton),onClick:()=>this.setState({editLink:!0,editLinkIndex:-1,link:{}}),children:s.jsx(f.Add,{})},"add")),t.push(s.jsx(n.Fab,{size:"small",color:"primary",disabled:!this.state.hasUnsavedChanges,sx:b.getStyle(this.props.theme,m.button,m.saveButton),onClick:()=>this.saveCards(),children:s.jsx(f.Check,{})},"save")),t.push(s.jsx(n.Fab,{size:"small",color:"primary",sx:b.getStyle(this.props.theme,m.button,m.closeButton),onClick:()=>this.deactivateEditMode(),children:s.jsx(f.Close,{})},"close"))):t.push(s.jsx(n.Fab,{color:"primary",size:"small",style:m.button,onClick:()=>this.activateEditMode(),children:s.jsx(f.Create,{})},"edit")),t}async saveCards(){const t=await this.props.socket.getSystemConfig(!0);let e=!1;JSON.stringify(t.common.intro)!==JSON.stringify(this.state.deactivated)&&(t.common.intro=this.state.deactivated,e=!0),!e&&JSON.stringify(t.native.introLinks)!==JSON.stringify(this.state.introLinks)&&(e=!0,t.native.introLinks=this.state.introLinks),e?this.props.socket.setSystemConfig(t).then(()=>this.props.showAlert("Updated","success")).catch(o=>{console.log(o),this.props.showAlert(o,"error")}).then(()=>this.setState({edit:!1})):this.setState({edit:!1})}async getHostData(t,e){let o;if(e!==void 0)o={val:e};else try{o=await this.props.socket.getState(`${t}.alive`)}catch(a){console.error(`Cannot get state ${t}.alive: ${a}`),o={val:!1}}let i={alive:!1};if(o!=null&&o.val)try{i=await this.props.socket.getHostInfo(t,!1,1e4),i&&typeof i=="object"&&i.alive!==!1&&(i.alive=!0)}catch(a){console.error(`Cannot get host info for ${t}: ${a}`),i={alive:!1}}else i={alive:!1};const d=await this.props.socket.getForeignStates(`${t}.versions.*`);return Object.keys(d).forEach(a=>i[`_${a.split(".").pop()}`]=d[a].val),{id:t,data:i}}async getHostsData(t){const e=t.map(a=>this.getHostData(a._id)),o=await Promise.all(e),i={},d={};return o.forEach(a=>{i[a.id]=v.preprocessHostData(a.data),d[a.id]=a.data.alive}),{hostsData:i,alive:d}}static applyReverseProxy(t,e,o){t==null||t.paths.forEach(i=>{var d;if(i.instance===o.id)o.link=i.path;else if(i.instance.startsWith("web.")){const a=e[`system.adapter.${i.instance}`];if((d=a==null?void 0:a.native)!=null&&d.port&&o.link.includes(`:${a.native.port}`)){const r=new RegExp(`^.*:${a.native.port}/`);o.link&&(o.link=o.link.replace(r,i.path)),console.log(o.link)}}})}addLinks(t,e,o,i,d,a){var c;const r={id:t.id,name:t.name,description:t.description,color:t.color,image:t.icon,info:""},l=W(t.link,e.name,o,{instances:i,hostname:this.props.hostname,adminInstance:this.props.adminInstance,hosts:d});let h=null;if((c=this.state.reverseProxy)!=null&&c.length&&(h=this.state.reverseProxy.find(p=>p.globalPath===this.currentProxyPath)),l.length===1){r.link=l[0].url,r.port=l[0].port,v.applyReverseProxy(h,i,r);const p=a.find(k=>k.link===r.link);p?console.log(`Double links: "${r.id}" and "${p.id}"`):a.push(r)}else l.length>1&&l.forEach(p=>{const k=a.find(j=>j.link===p.url);if(k)console.log(`Double links: "${r.id}" and "${k.id}"`);else{const j={...r,link:p.url,port:p.port};v.applyReverseProxy(h,i,j),a.push(j)}})}static getText(t,e){return t?typeof t=="object"?t[e]||t.en||"":t||"":""}static normalizeLinks(t,e,o){if(!t.common.localLinks&&!t.common.localLink&&!t.common.welcomeScreen&&!t.common.welcomeScreenPro)return null;const i={id:t._id.replace("system.adapter.",""),link:"",name:v.getText(t.common.titleLang||t.common.title||t.common.name,e),order:t.common.order||1e3,intro:!0,description:v.getText(t.common.desc,e),icon:t.common.icon?`adapter/${t.common.name}/${t.common.icon}`:"img/no-image.svg"};let d=[];if(t.common.localLink)if(typeof t.common.localLink=="string")d.push({...i,link:t.common.localLink});else{const a=t.common.localLink;if(a.link){const r={...i,link:a.link};a.color&&(r.color=a.color),a.order!==void 0&&typeof a.order=="number"&&(r.order=a.order),a.icon&&a.img&&(r.icon=a.icon||a.img),d.push(r)}else console.warn(`Unknown localLink structure: ${JSON.stringify(t.common.localLink)}`)}if(t.common.localLinks&&typeof t.common.localLinks=="object"&&Object.keys(t.common.localLinks).forEach(a=>{const r=t.common.localLinks[a];if(typeof r=="string")d.push({...i,link:r});else{const l=r;if(l.link){const h={...i,id:t._id.replace("system.adapter.","")+(a==="_default"?"":` ${a}`),link:l.link,name:i.name+(a==="_default"?"":` ${a}`)};l.color&&(h.color=l.color),l.order!==void 0&&(h.order=parseInt(l.order,10)||1e3),l.icon&&l.img&&(h.icon=l.icon||l.img),l.description&&(h.description=v.getText(l.description,e)),l.pro!==void 0&&(typeof l.pro=="string"?h.pro=l.pro:h.pro=`${t.common.name}/index.html`),l.cloud!==void 0&&(h.cloud=l.cloud),l.intro!==void 0&&(h.intro=l.intro===!0),l.name&&(h.name=v.getText(l.name,e)),a==="_default"&&(h.default=!0),d.push(h)}else console.warn(`Unknown localLinks structure: ${JSON.stringify(r)}`)}}),t.common.welcomeScreen&&typeof t.common.welcomeScreen=="object"&&((Array.isArray(t.common.welcomeScreen)?t.common.welcomeScreen:[t.common.welcomeScreen]).forEach(r=>{if(r.link){const l={...i,id:`${t._id.replace("system.adapter.","")} cloud`,link:`%web_protocol%://%web_bind%:%web_port%/${r.link}`,cloud:r.link};if(r.color&&(l.color=r.color),r.order!==void 0&&typeof r.order=="number"&&(l.order=r.order),r.icon&&r.img&&(l.icon=r.icon||r.img),r.localLinks){const h=t.common.localLinks[r.localLinks];h&&typeof h=="string"?l.link=h:h&&typeof h=="object"&&h.link&&(l.link=h.link)}r.name&&(l.name=v.getText(r.name,e)),d.push(l)}}),t.common.welcomeScreenPro&&typeof t.common.welcomeScreenPro=="object"&&(Array.isArray(t.common.welcomeScreenPro)?t.common.welcomeScreenPro:[t.common.welcomeScreenPro]).forEach(l=>{if(l.link){const h={...i,id:`${t._id.replace("system.adapter.","")} pro`,link:`%web_protocol%://%web_bind%:%web_port%/${l.link}`,pro:l.link};if(l.color&&(h.color=l.color),l.order!==void 0&&typeof l.order=="number"&&(h.order=l.order),l.icon&&l.img&&(h.icon=l.icon||l.img),l.localLinks){const c=t.common.localLinks[l.localLinks];c&&typeof c=="string"?h.link=c:c&&typeof c=="object"&&c.link&&(h.link=c.link)}l.name&&(h.name=v.getText(l.name,e)),d.push(h)}})),d.forEach(a=>{!a.icon.startsWith("adapter/")&&!a.icon.startsWith("data:image/")&&!a.icon.startsWith("http://")&&!a.icon.startsWith("https://")&&a.icon!=="img/no-image.svg"&&(a.icon=`adapter/${t.common.name}/${a.icon}`)}),o){const a={};d.forEach(r=>{a[r.link]?(r.color&&(a[r.link].color=r.color),r.icon&&(a[r.link].icon=r.icon),r.cloud&&(a[r.link].cloud=r.cloud),r.pro&&(a[r.link].pro=r.pro),r.intro!==void 0&&(a[r.link].intro=r.intro),r.name&&typeof r.name=="object"&&(a[r.link].name=r.name),r.order!==void 0&&(a[r.link].order=r.order),r.default&&(a[r.link].default=r.default)):a[r.link]=r}),d=Object.values(a)}return d.sort((a,r)=>a.default===void 0&&r.default===void 0?a.order===void 0&&r.order===void 0?0:a.order===void 0?-1:r.order===void 0?1:a.order-r.order:a.default===void 0?-1:r.default===void 0?1:a.order===void 0&&r.order===void 0?0:a.order===void 0?-1:r.order===void 0?1:a.order-r.order),d}async getInstances(t,e,o){e=e||this.state.hosts;const i={};e.forEach(d=>i[d._id]=d);try{const d=await this.props.socket.getAdapterInstances("",t);let a=o.common.intro||[];Array.isArray(a)||(a=Object.keys(a),a.sort());const r=[],l={};d.forEach(c=>l[c._id]=c),d.forEach(c=>{if(!c)return;const p=c.common||null,k=c._id.split("."),j=parseInt(k.pop(),10);let y;if(p!=null&&p.name&&typeof p.name=="object"){const L=p==null?void 0:p.name;y=L[this.props.lang]||L.en}else y=(p==null?void 0:p.name)||"";if(!(y==="admin"&&p.localLink===(this.props.hostname||""))&&y!=="web"&&!(y&&y!=="vis-web-admin"&&y.match(/^vis-/)&&y!=="vis-2")&&!(y!=null&&y.match(/^icons-/))&&p&&(p.enabled||p.onlyWWW)){const L=v.normalizeLinks(c,this.props.lang,!0);L&&L.forEach(H=>this.addLinks(H,p,j,l,i,r))}}),r.forEach(c=>{c.link&&(c.linkName=c.link.replace("https://","").replace("http://","").replace(/^[^_]+:/,""))}),r.sort((c,p)=>{if(c.order!==void 0||p.order!==void 0){if(c.order=c.order===void 0?1e3:c.order,p.order=p.order===void 0?1e3:p.order,c.order<p.order)return-1;if(c.order>p.order)return 1}return c.id>p.id?1:c.id<p.id?-1:0}),e==null||e.forEach(c=>{const p=c==null?void 0:c.common;let k=p==null?void 0:p.name;if(typeof k=="object"&&k&&(k=k[this.props.lang]||k.en),p){const j={id:c._id,name:k||"",color:"",image:p.icon||"img/no-image.svg",info:this.t("Info"),linkName:""};r.push(j)}});const h=[];return a.forEach(c=>{r.find(p=>c===`${p.id}_${p.linkName}`)&&h.push(c)}),a=h,{instances:r,deactivated:a}}catch(d){return console.log(d),{instances:[],deactivated:[]}}}getHostDescription(t){const e=this.state.hostsData?this.state.hostsData[t]:null;if(e&&e.alive===!1)return s.jsx("div",{style:m.hostOffline,children:this.props.t("Offline")});let o="",i="";if(e){try{e._nodeNewest&&e["Node.js"]&&N.gt(e._nodeNewest,e["Node.js"].replace(/^v/,""))&&(o=e._nodeNewest)}catch{}try{e._nodeNewest!==e._nodeNewestNext&&e._nodeNewestNext&&e["Node.js"]&&e._nodeNewest&&N.gt(e._nodeNewestNext,e["Node.js"].replace(/^v/,""))&&N.gt(e._nodeNewestNext,e._nodeNewest)&&(o+=(o?" / ":"")+e._nodeNewestNext)}catch{}if(o){const d=this.state.nodeUpdateSupported&&e.Platform==="linux";o=s.jsx(n.Tooltip,{title:this.props.t("Some updates available"),slotProps:{popper:{sx:m.tooltip}},children:s.jsxs("span",{style:{...m.nodeUpdate,display:"inline-flex"},children:["(",o,")",d?s.jsx(f.Refresh,{style:m.updateIcon,onClick:()=>this.setState({nodeUpdateDialog:{hostId:t,version:e._nodeNewestNext}})}):null]})})}try{e._npmNewest&&e.NPM&&N.gt(e._npmNewest,e.NPM)&&(i=e._npmNewest)}catch{}try{e._npmNewest!==e._npmNewestNext&&e._npmNewestNext&&e.NPM&&e._npmNewest&&N.gt(e._npmNewestNext,e.NPM)&&N.gt(e._npmNewestNext,e._npmNewest)&&(i+=(i?" / ":"")+e._npmNewestNext)}catch{}i&&(i=s.jsx(n.Tooltip,{title:this.props.t("Some updates available"),slotProps:{popper:{sx:m.tooltip}},children:s.jsxs("span",{style:m.nodeUpdate,children:["(",i,")"]})}))}return e&&typeof e=="object"?s.jsxs("ul",{style:{textTransform:"none"},children:[s.jsx("li",{children:s.jsxs("span",{children:[s.jsxs("span",{style:m.bold,children:[this.t("Platform"),": "]}),e.Platform||"--"]})}),s.jsx("li",{children:s.jsxs("span",{children:[s.jsxs("span",{style:m.bold,children:[this.t("RAM"),": "]}),T.RAM(e.RAM)]})}),s.jsx("li",{children:s.jsxs("span",{children:[s.jsxs("span",{style:m.bold,children:[this.t("Node.js"),": "]}),s.jsx("span",{style:o?m.updateExists:m.updateNo,children:e["Node.js"]||"--"}),o]})}),s.jsx("li",{children:s.jsxs("span",{children:[s.jsxs("span",{style:m.bold,children:[this.t("NPM"),": "]}),s.jsx("span",{className:i?m.updateExists:m.updateNo,children:e.NPM||"--"}),i]})})]}):s.jsxs("ul",{children:[s.jsx(n.Skeleton,{}),s.jsx(n.Skeleton,{}),s.jsx(n.Skeleton,{}),s.jsx(n.Skeleton,{})]})}getHostDescriptionAll(t){const e=this.state.hostsData?this.state.hostsData[t]:null;return{el:s.jsx("ul",{style:{textTransform:"none"},children:e&&typeof e=="object"&&Object.keys(e).filter(o=>!o.startsWith("_")&&e[o]!==null&&e[o]!==void 0).map(o=>s.jsx("li",{children:e&&typeof e=="object"?s.jsxs("span",{children:[s.jsxs("span",{style:m.bold,children:[this.t(o),": "]}),T[o]?T[o](e[o],this.t):(typeof e[o]=="object"?JSON.stringify(e[o]):e[o].toString())||"--"]}):s.jsx(n.Skeleton,{})},o))}),text:e&&typeof e=="object"?Object.keys(e).reduce((o,i)=>`${o}${this.t(i)}:${T[i]?T[i](e[i],this.t):(typeof e[i]=="object"?JSON.stringify(e[i]):e[i])||"--"}
|
|
2
|
+
`):""}}getDataDelayed=t=>{this.getDataTimeout&&clearTimeout(this.getDataTimeout),this.getDataTimeout=setTimeout(()=>{this.getDataTimeout=void 0,this.getData(!0).catch(e=>console.error(`Cannot get data: ${e}`))},300)};async getData(t){try{const e=await this.props.socket.getSystemConfig(t),o=await this.props.socket.getCompactHosts(t),i=await this.getInstances(t,o,e);this.setState({instances:i.instances,hosts:o,deactivated:i.deactivated,introLinks:e&&e.native&&e.native.introLinks?e.native.introLinks:[]});const d=await this.getHostsData(o);await new Promise(a=>{this.setState(d,()=>a())})}catch(e){window.alert(`Cannot get data: ${e}`)}}renderCopiedToast(){return s.jsx(n.Snackbar,{anchorOrigin:{vertical:"bottom",horizontal:"left"},open:this.state.openSnackBar,autoHideDuration:3e3,onClose:()=>this.setState({openSnackBar:!1}),message:this.t("copied")})}render(){return this.state.instances?s.jsxs(F,{elevation:0,overflow:"visible",children:[this.renderCopiedToast(),this.state.nodeUpdateDialog?s.jsx(G,{onClose:()=>this.setState({nodeUpdateDialog:null}),socket:this.props.socket,...this.state.nodeUpdateDialog}):null,s.jsxs("div",{style:m.viewModeDiv,children:[this.getInstancesCards(),this.getLinkCards()]}),this.getButtons(),this.editLinkCard()]}):s.jsx(n.LinearProgress,{})}static preprocessHostData(t){var e;if((e=t.dockerInformation)!=null&&e.isDocker){let o=t.dockerInformation.isOfficial?"official image":"unofficial image";t.dockerInformation.isOfficial&&(o+=` - ${t.dockerInformation.officialVersion}`),t.Platform=`${t.Platform} (${o})`}return delete t.dockerInformation,t}}export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,F as j,J as C}from"./DefaultPropsProvider-BrbE0teb.js";import{i as I}from"./iobroker_admin__loadShare__react__loadShare__-DtlEM_52.js";import{w as D,i as s,f as T,b as v,U as R,a as p,g as z,h as B,T as E}from"./bootstrap-BNkcLa73.js";import{b as O}from"./index-HOidq_rM.js";import{a as y}from"./blueGrey-B0oIowPK.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BGyJCibC.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-j1VT51C2.js";import"./FilledInput-D-tz8rvg.js";import"./preload-helper-C1FmrZbK.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-B1OZ7tj-.js";import"./extends-CF3RwP-h.js";import"./iconBase-CgxZ5MMC.js";import"./emotion-cache.browser.esm-B8BFze5o.js";const _=3e3,r={container:{height:"100%"},table:{tableLayout:"fixed",minWidth:960,"& td,th":{padding:"3px 4px"},"& td:nth-of-type(5)":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},row:{"@media screen and (max-width: 450px)":{"& > *":{fontSize:"8px !important"}}},rowOdd:S=>({backgroundColor:S.palette.background.default}),cell:{verticalAlign:"top"},cellName:{lineHeight:"14px"},updatedRow:{animation:"updated 1s"},formControl:{width:"100%","@media screen and (max-width: 450px)":{"& > *":{fontSize:"10px !important"},position:"relative"}},light_error:{color:C[800]},light_warn:{color:y[800]},light_debug:{color:j[800]},light_silly:{color:j[700]},dark_error:{color:C[200]},dark_warn:{color:y[200]},dark_debug:{color:"#b1b1b1"},dark_silly:{color:"#7e7e7e"},source:{width:200,"@media screen and (max-width: 450px)":{width:120}},pid:{width:55,"@media screen and (max-width: 450px)":{width:40}},timestamp:{width:175,"@media screen and (max-width: 450px)":{width:100}},severity:{width:80,"@media screen and (max-width: 450px)":{width:61}},message:{minWidth:300,"@media screen and (max-width: 450px)":{minWidth:150}},hidden:{display:"none"},grow:{flexGrow:1},logSize:{marginRight:"1rem",marginLeft:"1rem"},logEstimated:{fontStyle:"italic"},closeButton:S=>({position:"absolute",right:8,top:8,color:S.palette.grey[500]}),header:S=>({"& .MuiFormLabel-root.Mui-disabled":{color:S.palette.text.primary},"& .MuiInput-underline::before":{content:'""',borderBottom:"none"},"@media screen and (max-width: 450px)":{"& > *":{fontSize:"10px !important"}}}),pauseButton:{minWidth:48},pauseCount:{color:y[500]},downloadLogSize:{color:j[500],marginLeft:16},downloadEntry:{display:"flex",justifyContent:"space-between"},pidSize:{fontSize:14,width:24,height:24,display:"flex",alignItems:"center"},messageText:{"@media screen and (max-width: 450px)":{"& > *":{fontSize:"10px !important"}}},badge:{top:10,right:10},badgeError:{},badgeWarn:{backgroundColor:y[500]},emptyButton:{width:48},icon:{width:16,height:16},iconSelect:{width:24,height:25,marginRight:4},name:{verticalAlign:"top",display:"inline-block",marginTop:1,marginLeft:2,overflow:"hidden",whiteSpace:"nowrap",width:"100%",textOverflow:"ellipsis"},iconAndName:{whiteSpace:"nowrap",display:"flex"},tooltip:{pointerEvents:"none"}},L=["#ffadad30","#ffd6a530","#fdffb630","#caffbf30","#9bf6ff30","#a0c4ff30","#bdb2ff30","#ffc6ff30","#fffffc30"],k=["rgba(255,109,109,0.1)","rgba(253,173,84,0.1)","rgba(241,255,88,0.1)","rgba(115,253,81,0.1)","rgba(71,235,255,0.1)","rgba(74,145,255,0.1)","rgba(108,85,255,0.1)","rgba(250,77,250,0.1)","rgba(255,255,105,0.1)"];class b extends I.Component{severities;t;ignoreNextLogs;lastRowRender;lastRowRenderTimeout=null;readLogsInProcess;hostsTimer=null;scrollToEnd;constructor(t){super(t),this.state={source:(window._localStorage||window.localStorage).getItem("Log.source")||"1",severity:(window._localStorage||window.localStorage).getItem("Log.severity")||"debug",message:(window._localStorage||window.localStorage).getItem("Log.message")||"",reverse:(window._localStorage||window.localStorage).getItem("Log.reverse")==="true",logDeleteDialog:!1,logDownloadDialog:null,logFiles:[],logs:null,logSize:null,logErrors:0,logWarnings:0,estimatedSize:!0,pause:0,pid:(window._localStorage||window.localStorage).getItem("Logs.pid")==="true",colors:(window._localStorage||window.localStorage).getItem("Logs.colors")==="true",adapters:{},sources:{},currentHost:this.props.currentHost,hosts:null},this.scrollToEnd=this.state.reverse,this.severities={silly:0,debug:1,info:2,warn:3,error:4},this.t=t.t}readLogs(t,o,l){this.props.logsWorker&&this.state.hosts?this.props.logsWorker.getLogs(t).then(i=>{if(!i)return;const a=[...i.logs],d=i.logSize;let f=0,c=0,m=!0;const u=JSON.parse(JSON.stringify(this.state.sources));Object.values(u).forEach(h=>h.active=!1),a.forEach(h=>{if(m=!m,h.odd=m,!h.time){const g=new Date(h.ts);h.time=`${g.getFullYear()}-${(g.getMonth()+1).toString().padStart(2,"0")}-${g.getDate().toString().padStart(2,"0")} ${g.getHours().toString().padStart(2,"0")}:${g.getMinutes().toString().padStart(2,"0")}:${g.getSeconds().toString().padStart(2,"0")}.${g.getMilliseconds().toString().padStart(3,"0")}`}h.severity==="error"?c++:h.severity==="warn"&&f++,h.from&&(u[h.from]?u[h.from].active=!0:u[h.from]={active:!0,icon:this.getSourceIcon(h.from)})});let x=0;const n=this.props.themeType==="dark"?k:L;Object.keys(u).sort().forEach(h=>{u[h].color=n[x%n.length],x++}),this.scrollToEnd=this.state.reverse;const w={logs:a,logSize:d,estimatedSize:!1,logErrors:c,logWarnings:f,sources:u};o&&(w.logFiles=o),this.setState(w,()=>l&&l())}):o&&this.setState({logFiles:o},()=>l&&l())}async readLogFiles(){const t=await this.props.socket.getLogsFiles(this.state.currentHost);if(t!=null&&t.length){const o=[];return t.reverse(),t.forEach(l=>{const a=l.fileName.split("/").pop().replace(/iobroker\.?/,"").replace(".log","");a[0]<="9"&&o.push({path:l,name:a})}),t.sort(),t.forEach(l=>{const a=l.fileName.split("/").pop().replace(/iobroker\.?/,"").replace(".log","");a[0]>"9"&&o.push({path:l,name:a})}),o}return[]}componentDidMount(){this.props.logsWorker.registerHandler(this.logHandler),this.props.clearErrors(),this.props.socket.getCompactAdapters().then(async t=>{const o=await this.props.socket.getCompactHosts(),l={};o.forEach(a=>l[a._id]=a),await new Promise(a=>{this.setState({adapters:t,hosts:l},()=>a())});const i=await this.readLogFiles();this.readLogs(!0,i)})}componentWillUnmount(){this.props.logsWorker.unregisterHandler(this.logHandler),this.props.clearErrors()}getSourceIcon(t){var i,a,d;const o=t.replace(/\.\d+$/,"");let l=(i=this.state.adapters[o])==null?void 0:i.icon;return l?l.startsWith("data:image")||(l=`./files/${o}.admin/${l}`):this.state.hosts&&(l=((d=(a=this.state.hosts[`system.${t}`])==null?void 0:a.common)==null?void 0:d.icon)||"img/no-image.svg"),l||null}logHandler=(t,o)=>{if(this.ignoreNextLogs){this.ignoreNextLogs=!1;return}const i=(this.state.logs||[]).concat(t);i.length>_&&i.splice(0,i.length-_);let a=0,d=0,f=!1,c,m=Object.keys(this.state.sources).length;const u=this.props.themeType==="dark"?k:L;i.forEach(n=>{var w,h;if(n.odd!==void 0?f=n.odd:(f=!f,n.odd=f),!n.time){const g=new Date(n.ts);n.time=`${g.getFullYear()}-${(g.getMonth()+1).toString().padStart(2,"0")}-${g.getDate().toString().padStart(2,"0")} ${g.getHours().toString().padStart(2,"0")}:${g.getMinutes().toString().padStart(2,"0")}:${g.getSeconds().toString().padStart(2,"0")}.${g.getMilliseconds().toString().padStart(3,"0")}`}n.severity==="error"?d++:n.severity==="warn"&&a++,n.from&&(!this.state.sources[n.from]&&!(c!=null&&c[n.from])?(c=c||JSON.parse(JSON.stringify(this.state.sources)),c[n.from]={active:!0,color:u[m%u.length],icon:this.getSourceIcon(n.from)},m++):!((w=this.state.sources[n.from])!=null&&w.active)&&!((h=c==null?void 0:c[n.from])!=null&&h.active)&&(c=c||JSON.parse(JSON.stringify(this.state.sources)),c[n.from].active=!0))});const x={logs:i,logSize:this.state.logSize+o,estimatedSize:!0,logWarnings:a,logErrors:d};if(c&&(x.sources=c),this.state.reverse){const n=document.getElementById("endOfLog");this.scrollToEnd=n?n.getBoundingClientRect().top<window.innerHeight:!0}this.setState(x)};clearLog(){var t;(t=this.props.logsWorker)==null||t.clearLines(),this.props.clearErrors(),this.setState({logs:[],logSize:null,logErrors:0,logWarnings:0})}handleMessageChange(t){(window._localStorage||window.localStorage).setItem("Log.message",t.target.value),this.setState({message:t.target.value})}handleSourceChange(t){(window._localStorage||window.localStorage).setItem("Log.source",t),this.setState({source:t})}handleSeverityChange(t){(window._localStorage||window.localStorage).setItem("Log.severity",t.target.value),this.setState({severity:t.target.value})}handleLogDelete(){this.props.socket.delLogs(this.state.currentHost).then(()=>this.clearLog()).then(()=>this.readLogs(!0,null,()=>this.setState({logDeleteDialog:!1}))).catch(t=>{this.setState({logDeleteDialog:!1}),window.alert(t)})}handleLogPause(){this.setState({pause:this.state.pause?0:this.state.logs.length})}static openTab(t){window.open(t,"_blank").focus()}getLogFiles(){return this.state.logFiles.map(t=>e.jsxs(s.MenuItem,{style:r.downloadEntry,onClick:()=>{b.openTab(t.path.fileName),this.setState({logDownloadDialog:null})},children:[t.name,e.jsx(s.Typography,{style:r.downloadLogSize,variant:"caption",children:T.formatBytes(t.path.size)||"-"})]},t.name))}getSeverities(){const t=[];for(const o in this.severities)t.push(e.jsx(s.MenuItem,{value:o,style:r[`${this.props.themeType}_${o}`],children:o},o));return t}getSources(){const t=Object.keys(this.state.sources).sort();return t.unshift("1"),t.map(o=>e.jsxs(s.MenuItem,{value:o,style:{backgroundColor:!this.state.colors||o==="1"?void 0:this.state.sources[o].color,display:"flex",alignItems:"center"},children:[o==="1"?null:e.jsx(v,{src:this.state.sources[o].icon||"",style:r.iconSelect}),o==="1"?this.t("Source (show all)"):o]},o))}getOneRow(t,o,l){var x,n;const i=this.state.logs[t];if(!i)return;const a=i.severity;let d=i.message||"",f="";if(typeof d!="object"){const w=new RegExp(`${i.from.replace(".","\\.").replace(")","\\)").replace("(","\\(")} \\(\\d+\\) `,"g"),h=d.match(w);h?(d=d.replace(h[0],""),f=h[0].split(" ")[1].match(/\d+/g)[0]):d=d.replace(`${i.from} `,"")}let m=l.sourceFilter!=="1"&&l.sourceFilter!==i.from||this.severities[a]<this.severities[this.state.severity];!m&&l.filterMessage&&(typeof d=="object"?m=!d.original.toLowerCase().includes(l.filterMessage):m=!d.toLowerCase().includes(l.filterMessage));const u=l.previousKey===i.key?t:i.key;l.previousKey=i.key,o.push(e.jsxs(s.TableRow,{id:l.length===t?"endOfLog":void 0,sx:R.getStyle(this.props.theme,r.row,i.odd&&r.rowOdd,m&&r.hidden,this.lastRowRender&&i.ts>this.lastRowRender&&r.updatedRow),style:this.state.colors?{backgroundColor:((x=this.state.sources[i.from])==null?void 0:x.color)||void 0}:{},hover:!0,children:[e.jsx(s.TableCell,{style:{...r.cell,...r.cellName},children:e.jsxs("div",{style:r.iconAndName,children:[e.jsx(v,{src:((n=this.state.sources[i.from])==null?void 0:n.icon)||"",style:r.icon}),e.jsx("div",{style:r.name,children:i.from})]})}),this.state.pid&&e.jsx(s.TableCell,{style:{...r.cell,...r[`${this.props.themeType}_${a}`]},children:f}),e.jsx(s.TableCell,{style:{...r.cell,...r[`${this.props.themeType}_${a}`]},children:i.time}),e.jsx(s.TableCell,{style:{...r.cell,...r[`${this.props.themeType}_${a}`],fontWeight:"bold"},children:i.severity}),e.jsx(s.TableCell,{style:{...r.cell,...r[`${this.props.themeType}_${a}`]},title:typeof d=="object"?d.original:d,children:typeof d=="object"?d.parts.map((w,h)=>e.jsx("span",{style:w.style,children:w.text},h)):d})]},l.keyPrefix+u))}getRows(){const t=[],o={filterMessage:this.state.message.toLowerCase(),sourceFilter:this.state.source,previousKey:0,keyPrefix:"",length:0},l=Object.keys(this.state.sources).sort();if(l.unshift("1"),l.includes(o.sourceFilter)||(o.sourceFilter="1"),o.previousKey=0,o.keyPrefix=this.state.reverse?"r":"",o.length=this.state.pause>0?this.state.pause-1:this.state.logs.length-1,this.state.reverse)for(let i=0;i<=o.length;i++)this.getOneRow(i,t,o);else for(let i=o.length;i>=0;i--)this.getOneRow(i,t,o);return o.length>0&&this.scrollToEnd&&(setTimeout(()=>{const i=document.getElementById("endOfLog");i==null||i.scrollIntoView()},200),this.scrollToEnd=!1),(!this.lastRowRender||Date.now()-this.lastRowRender>1e3)&&(this.lastRowRenderTimeout||(this.lastRowRenderTimeout=setTimeout(()=>{this.lastRowRenderTimeout=null,this.lastRowRender=Date.now()},1e3))),t}renderClearDialog(){return this.state.logDeleteDialog?e.jsxs(s.Dialog,{onClose:()=>this.setState({logDeleteDialog:!1}),open:!0,children:[e.jsxs(s.DialogTitle,{children:[this.t("Please confirm"),e.jsx(s.IconButton,{size:"large",sx:r.closeButton,onClick:()=>this.setState({logDeleteDialog:!1}),children:e.jsx(p.Close,{})})]}),e.jsx(s.DialogContent,{dividers:!0,children:e.jsx(s.Typography,{gutterBottom:!0,children:this.t("Log file will be deleted. Are you sure?")})}),e.jsxs(s.DialogActions,{children:[e.jsx(s.Button,{variant:"contained",autoFocus:!0,onClick:()=>this.handleLogDelete(),color:"primary",startIcon:e.jsx(p.Check,{}),children:this.t("Ok")}),e.jsx(s.Button,{variant:"contained",onClick:()=>this.setState({logDeleteDialog:!1}),color:"grey",startIcon:e.jsx(p.Close,{}),children:this.t("Cancel")})]})]}):null}changePid(){const t=!this.state.pid;(window._localStorage||window.localStorage).setItem("Logs.pid",t?"true":"false"),this.setState({pid:t})}renderToolbar(){var i;const t=this.state.pause?e.jsx(s.Typography,{style:r.pauseCount,children:this.state.logs.length-this.state.pause}):e.jsx(p.Pause,{}),o=this.props.width==="xs"||this.props.width==="sm",l=o?e.jsx(s.IconButton,{color:"primary",onClick:a=>this.setState({logDownloadDialog:a.currentTarget}),children:e.jsx(p.SaveAlt,{})}):e.jsx(s.Button,{variant:"contained",color:"primary",startIcon:e.jsx(p.SaveAlt,{}),onClick:a=>this.setState({logDownloadDialog:a.currentTarget}),children:this.t("Download log")});return e.jsxs(z,{children:[e.jsx(s.Tooltip,{title:this.props.t("Refresh log"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>this.readLogs(!0),children:e.jsx(p.Refresh,{})})}),e.jsx(s.Tooltip,{title:this.props.t("Pause output"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",style:r.pauseButton,onClick:()=>this.handleLogPause(),children:t})}),e.jsx(s.Tooltip,{title:this.props.t("Clear log"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>this.clearLog(),children:e.jsx(p.Delete,{})})}),e.jsx(s.Tooltip,{title:this.props.t("Clear on disk permanent"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>this.setState({logDeleteDialog:!0}),children:e.jsx(p.DeleteForever,{})})}),e.jsx(s.Tooltip,{title:this.props.t("Show/hide PID"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>this.changePid(),color:this.state.pid?"primary":"default",children:e.jsx("div",{style:r.pidSize,children:this.props.t("PID")})})}),e.jsx(s.Tooltip,{title:this.props.t("Show/hide colors"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>{(window._localStorage||window.localStorage).setItem("Logs.colors",this.state.colors?"false":"true"),this.setState({colors:!this.state.colors})},color:this.state.colors?"primary":"default",children:e.jsx(O,{style:{width:"0.8em",height:"0.8em"}})})}),e.jsx(s.Tooltip,{title:this.props.t("Reverse output direction"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>{(window._localStorage||window.localStorage).setItem("Log.reverse",this.state.reverse?"false":"true"),this.setState({reverse:!this.state.reverse}),setTimeout(()=>{const a=document.getElementById("endOfLog");a==null||a.scrollIntoView()},500)},color:this.state.reverse?"primary":"default",children:this.state.reverse?e.jsx(p.ArrowDownward,{}):e.jsx(p.ArrowUpward,{})})}),e.jsx(s.Tooltip,{title:this.props.t("Show errors"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.Badge,{badgeContent:this.state.logErrors,color:"error",sx:{"& .MuiBadge-badge":{...r.badge,...r.badgeError}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>{this.state.severity==="error"?this.setState({severity:"debug"}):this.setState({severity:"error",logErrors:0})},color:this.state.severity==="error"?"primary":"default",children:e.jsx(p.ErrorOutline,{})})})}),e.jsx(s.Tooltip,{title:this.props.t("Show errors and warnings"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.Badge,{badgeContent:this.state.logWarnings,color:"default",sx:{"& .MuiBadge-badge":{...r.badge,...r.badgeWarn}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>{this.state.severity==="warn"?this.setState({severity:"debug"}):this.setState({severity:"warn",logWarnings:0})},color:this.state.severity==="warn"?"primary":"default",children:e.jsx(p.Warning,{})})})}),e.jsx("div",{style:r.grow}),(i=this.state.logFiles)!=null&&i.length?l:null,this.state.logDownloadDialog?e.jsx(s.Menu,{id:"simple-menu",anchorEl:this.state.logDownloadDialog,keepMounted:!0,open:!!this.state.logDownloadDialog,onClose:()=>this.setState({logDownloadDialog:null}),children:this.getLogFiles()}):null,o?null:e.jsx("div",{style:r.grow}),o?null:e.jsxs(s.Typography,{variant:"body2",title:this.state.estimatedSize?this.props.t("Estimated size"):"",style:r.logSize,children:[this.t("Log size:")," ",e.jsx("span",{style:this.state.estimatedSize?r.logEstimated:void 0,children:this.state.logSize===null?"-":T.formatBytes(this.state.logSize)})]})]})}renderTableHeader(){const t=Object.keys(this.state.sources).sort();return t.unshift("1"),e.jsx(s.TableHead,{children:e.jsxs(s.TableRow,{children:[e.jsx(s.TableCell,{sx:r.source,children:e.jsxs(s.FormControl,{variant:"standard",sx:r.formControl,children:[e.jsx(s.Select,{variant:"standard",labelId:"source-label",value:t.includes(this.state.source)?this.state.source:"1",onChange:o=>this.handleSourceChange(o.target.value),renderValue:o=>e.jsxs("div",{style:{backgroundColor:!this.state.colors||o==="1"?void 0:this.state.sources[o].color,display:"flex",alignItems:"center"},children:[o==="1"?null:e.jsx(v,{src:this.state.sources[o].icon||"",style:r.iconSelect}),o==="1"?this.t("Source"):o]}),children:this.getSources()}),(t.includes(this.state.source)?this.state.source:"1")!=="1"?e.jsx(s.IconButton,{sx:{position:"absolute",top:1,right:15,zIndex:1},size:"small",onClick:()=>this.handleSourceChange("1"),children:e.jsx(p.Clear,{})}):null]})}),this.state.pid&&e.jsx(s.TableCell,{sx:r.pid,children:e.jsx(s.Box,{component:"div",sx:r.header,children:this.t("PID")})}),e.jsx(s.TableCell,{sx:r.timestamp,children:e.jsx(s.Box,{component:"div",sx:r.header,children:this.t("Time")})}),e.jsx(s.TableCell,{sx:r.severity,children:e.jsx(s.FormControl,{variant:"standard",style:r.formControl,children:e.jsx(s.Select,{variant:"standard",labelId:"severity-label",value:this.state.severity,onChange:o=>this.handleSeverityChange(o),renderValue:o=>e.jsx("span",{style:r[`${this.props.themeType}_${o}`],children:o}),children:this.getSeverities()})})}),e.jsx(s.TableCell,{sx:r.message,children:e.jsx(s.FormControl,{variant:"standard",style:r.formControl,children:e.jsx(s.TextField,{variant:"standard",sx:r.messageText,placeholder:this.t("Message"),onChange:o=>this.handleMessageChange(o),value:this.state.message,slotProps:{input:{endAdornment:this.state.message?e.jsx(s.IconButton,{size:"small",onClick:()=>{(window._localStorage||window.localStorage).removeItem("Log.message"),this.setState({message:""})},children:e.jsx(p.Close,{})}):null}}})})})]})})}render(){return this.state.logs?(this.state.logFiles===null&&!this.readLogsInProcess&&(this.readLogsInProcess=!0,setTimeout(()=>this.readLogFiles().then(t=>{this.readLogsInProcess=!1,this.setState({logFiles:t})}),100)),this.props.currentHost!==this.state.currentHost&&(this.hostsTimer=this.hostsTimer||setTimeout(()=>{this.hostsTimer=null,this.setState({currentHost:this.props.currentHost,logs:[],logFiles:null},()=>this.readLogs(!0))},200)),e.jsxs(B,{children:[this.renderToolbar(),e.jsx(E,{children:e.jsx(s.TableContainer,{style:r.container,children:e.jsxs(s.Table,{stickyHeader:!0,size:"small",sx:r.table,children:[this.renderTableHeader(),e.jsx(s.TableBody,{children:this.getRows()})]})})}),this.renderClearDialog()]})):e.jsx(s.LinearProgress,{})}}const Z=D()(b);export{Z as default};
|
|
1
|
+
import{j as e,F as j,J as C}from"./DefaultPropsProvider-BrbE0teb.js";import{i as I}from"./iobroker_admin__loadShare__react__loadShare__-DtlEM_52.js";import{w as D,i as s,f as T,b as v,U as R,a as p,g as z,h as B,T as E}from"./bootstrap-FCtLxt0T.js";import{b as O}from"./index-HOidq_rM.js";import{a as y}from"./blueGrey-B0oIowPK.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BGyJCibC.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-CI9-Cq3I.js";import"./FilledInput-D-tz8rvg.js";import"./preload-helper-C1FmrZbK.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-B1OZ7tj-.js";import"./extends-CF3RwP-h.js";import"./iconBase-CgxZ5MMC.js";import"./emotion-cache.browser.esm-B8BFze5o.js";const _=3e3,r={container:{height:"100%"},table:{tableLayout:"fixed",minWidth:960,"& td,th":{padding:"3px 4px"},"& td:nth-of-type(5)":{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"}},row:{"@media screen and (max-width: 450px)":{"& > *":{fontSize:"8px !important"}}},rowOdd:S=>({backgroundColor:S.palette.background.default}),cell:{verticalAlign:"top"},cellName:{lineHeight:"14px"},updatedRow:{animation:"updated 1s"},formControl:{width:"100%","@media screen and (max-width: 450px)":{"& > *":{fontSize:"10px !important"},position:"relative"}},light_error:{color:C[800]},light_warn:{color:y[800]},light_debug:{color:j[800]},light_silly:{color:j[700]},dark_error:{color:C[200]},dark_warn:{color:y[200]},dark_debug:{color:"#b1b1b1"},dark_silly:{color:"#7e7e7e"},source:{width:200,"@media screen and (max-width: 450px)":{width:120}},pid:{width:55,"@media screen and (max-width: 450px)":{width:40}},timestamp:{width:175,"@media screen and (max-width: 450px)":{width:100}},severity:{width:80,"@media screen and (max-width: 450px)":{width:61}},message:{minWidth:300,"@media screen and (max-width: 450px)":{minWidth:150}},hidden:{display:"none"},grow:{flexGrow:1},logSize:{marginRight:"1rem",marginLeft:"1rem"},logEstimated:{fontStyle:"italic"},closeButton:S=>({position:"absolute",right:8,top:8,color:S.palette.grey[500]}),header:S=>({"& .MuiFormLabel-root.Mui-disabled":{color:S.palette.text.primary},"& .MuiInput-underline::before":{content:'""',borderBottom:"none"},"@media screen and (max-width: 450px)":{"& > *":{fontSize:"10px !important"}}}),pauseButton:{minWidth:48},pauseCount:{color:y[500]},downloadLogSize:{color:j[500],marginLeft:16},downloadEntry:{display:"flex",justifyContent:"space-between"},pidSize:{fontSize:14,width:24,height:24,display:"flex",alignItems:"center"},messageText:{"@media screen and (max-width: 450px)":{"& > *":{fontSize:"10px !important"}}},badge:{top:10,right:10},badgeError:{},badgeWarn:{backgroundColor:y[500]},emptyButton:{width:48},icon:{width:16,height:16},iconSelect:{width:24,height:25,marginRight:4},name:{verticalAlign:"top",display:"inline-block",marginTop:1,marginLeft:2,overflow:"hidden",whiteSpace:"nowrap",width:"100%",textOverflow:"ellipsis"},iconAndName:{whiteSpace:"nowrap",display:"flex"},tooltip:{pointerEvents:"none"}},L=["#ffadad30","#ffd6a530","#fdffb630","#caffbf30","#9bf6ff30","#a0c4ff30","#bdb2ff30","#ffc6ff30","#fffffc30"],k=["rgba(255,109,109,0.1)","rgba(253,173,84,0.1)","rgba(241,255,88,0.1)","rgba(115,253,81,0.1)","rgba(71,235,255,0.1)","rgba(74,145,255,0.1)","rgba(108,85,255,0.1)","rgba(250,77,250,0.1)","rgba(255,255,105,0.1)"];class b extends I.Component{severities;t;ignoreNextLogs;lastRowRender;lastRowRenderTimeout=null;readLogsInProcess;hostsTimer=null;scrollToEnd;constructor(t){super(t),this.state={source:(window._localStorage||window.localStorage).getItem("Log.source")||"1",severity:(window._localStorage||window.localStorage).getItem("Log.severity")||"debug",message:(window._localStorage||window.localStorage).getItem("Log.message")||"",reverse:(window._localStorage||window.localStorage).getItem("Log.reverse")==="true",logDeleteDialog:!1,logDownloadDialog:null,logFiles:[],logs:null,logSize:null,logErrors:0,logWarnings:0,estimatedSize:!0,pause:0,pid:(window._localStorage||window.localStorage).getItem("Logs.pid")==="true",colors:(window._localStorage||window.localStorage).getItem("Logs.colors")==="true",adapters:{},sources:{},currentHost:this.props.currentHost,hosts:null},this.scrollToEnd=this.state.reverse,this.severities={silly:0,debug:1,info:2,warn:3,error:4},this.t=t.t}readLogs(t,o,l){this.props.logsWorker&&this.state.hosts?this.props.logsWorker.getLogs(t).then(i=>{if(!i)return;const a=[...i.logs],d=i.logSize;let f=0,c=0,m=!0;const u=JSON.parse(JSON.stringify(this.state.sources));Object.values(u).forEach(h=>h.active=!1),a.forEach(h=>{if(m=!m,h.odd=m,!h.time){const g=new Date(h.ts);h.time=`${g.getFullYear()}-${(g.getMonth()+1).toString().padStart(2,"0")}-${g.getDate().toString().padStart(2,"0")} ${g.getHours().toString().padStart(2,"0")}:${g.getMinutes().toString().padStart(2,"0")}:${g.getSeconds().toString().padStart(2,"0")}.${g.getMilliseconds().toString().padStart(3,"0")}`}h.severity==="error"?c++:h.severity==="warn"&&f++,h.from&&(u[h.from]?u[h.from].active=!0:u[h.from]={active:!0,icon:this.getSourceIcon(h.from)})});let x=0;const n=this.props.themeType==="dark"?k:L;Object.keys(u).sort().forEach(h=>{u[h].color=n[x%n.length],x++}),this.scrollToEnd=this.state.reverse;const w={logs:a,logSize:d,estimatedSize:!1,logErrors:c,logWarnings:f,sources:u};o&&(w.logFiles=o),this.setState(w,()=>l&&l())}):o&&this.setState({logFiles:o},()=>l&&l())}async readLogFiles(){const t=await this.props.socket.getLogsFiles(this.state.currentHost);if(t!=null&&t.length){const o=[];return t.reverse(),t.forEach(l=>{const a=l.fileName.split("/").pop().replace(/iobroker\.?/,"").replace(".log","");a[0]<="9"&&o.push({path:l,name:a})}),t.sort(),t.forEach(l=>{const a=l.fileName.split("/").pop().replace(/iobroker\.?/,"").replace(".log","");a[0]>"9"&&o.push({path:l,name:a})}),o}return[]}componentDidMount(){this.props.logsWorker.registerHandler(this.logHandler),this.props.clearErrors(),this.props.socket.getCompactAdapters().then(async t=>{const o=await this.props.socket.getCompactHosts(),l={};o.forEach(a=>l[a._id]=a),await new Promise(a=>{this.setState({adapters:t,hosts:l},()=>a())});const i=await this.readLogFiles();this.readLogs(!0,i)})}componentWillUnmount(){this.props.logsWorker.unregisterHandler(this.logHandler),this.props.clearErrors()}getSourceIcon(t){var i,a,d;const o=t.replace(/\.\d+$/,"");let l=(i=this.state.adapters[o])==null?void 0:i.icon;return l?l.startsWith("data:image")||(l=`./files/${o}.admin/${l}`):this.state.hosts&&(l=((d=(a=this.state.hosts[`system.${t}`])==null?void 0:a.common)==null?void 0:d.icon)||"img/no-image.svg"),l||null}logHandler=(t,o)=>{if(this.ignoreNextLogs){this.ignoreNextLogs=!1;return}const i=(this.state.logs||[]).concat(t);i.length>_&&i.splice(0,i.length-_);let a=0,d=0,f=!1,c,m=Object.keys(this.state.sources).length;const u=this.props.themeType==="dark"?k:L;i.forEach(n=>{var w,h;if(n.odd!==void 0?f=n.odd:(f=!f,n.odd=f),!n.time){const g=new Date(n.ts);n.time=`${g.getFullYear()}-${(g.getMonth()+1).toString().padStart(2,"0")}-${g.getDate().toString().padStart(2,"0")} ${g.getHours().toString().padStart(2,"0")}:${g.getMinutes().toString().padStart(2,"0")}:${g.getSeconds().toString().padStart(2,"0")}.${g.getMilliseconds().toString().padStart(3,"0")}`}n.severity==="error"?d++:n.severity==="warn"&&a++,n.from&&(!this.state.sources[n.from]&&!(c!=null&&c[n.from])?(c=c||JSON.parse(JSON.stringify(this.state.sources)),c[n.from]={active:!0,color:u[m%u.length],icon:this.getSourceIcon(n.from)},m++):!((w=this.state.sources[n.from])!=null&&w.active)&&!((h=c==null?void 0:c[n.from])!=null&&h.active)&&(c=c||JSON.parse(JSON.stringify(this.state.sources)),c[n.from].active=!0))});const x={logs:i,logSize:this.state.logSize+o,estimatedSize:!0,logWarnings:a,logErrors:d};if(c&&(x.sources=c),this.state.reverse){const n=document.getElementById("endOfLog");this.scrollToEnd=n?n.getBoundingClientRect().top<window.innerHeight:!0}this.setState(x)};clearLog(){var t;(t=this.props.logsWorker)==null||t.clearLines(),this.props.clearErrors(),this.setState({logs:[],logSize:null,logErrors:0,logWarnings:0})}handleMessageChange(t){(window._localStorage||window.localStorage).setItem("Log.message",t.target.value),this.setState({message:t.target.value})}handleSourceChange(t){(window._localStorage||window.localStorage).setItem("Log.source",t),this.setState({source:t})}handleSeverityChange(t){(window._localStorage||window.localStorage).setItem("Log.severity",t.target.value),this.setState({severity:t.target.value})}handleLogDelete(){this.props.socket.delLogs(this.state.currentHost).then(()=>this.clearLog()).then(()=>this.readLogs(!0,null,()=>this.setState({logDeleteDialog:!1}))).catch(t=>{this.setState({logDeleteDialog:!1}),window.alert(t)})}handleLogPause(){this.setState({pause:this.state.pause?0:this.state.logs.length})}static openTab(t){window.open(t,"_blank").focus()}getLogFiles(){return this.state.logFiles.map(t=>e.jsxs(s.MenuItem,{style:r.downloadEntry,onClick:()=>{b.openTab(t.path.fileName),this.setState({logDownloadDialog:null})},children:[t.name,e.jsx(s.Typography,{style:r.downloadLogSize,variant:"caption",children:T.formatBytes(t.path.size)||"-"})]},t.name))}getSeverities(){const t=[];for(const o in this.severities)t.push(e.jsx(s.MenuItem,{value:o,style:r[`${this.props.themeType}_${o}`],children:o},o));return t}getSources(){const t=Object.keys(this.state.sources).sort();return t.unshift("1"),t.map(o=>e.jsxs(s.MenuItem,{value:o,style:{backgroundColor:!this.state.colors||o==="1"?void 0:this.state.sources[o].color,display:"flex",alignItems:"center"},children:[o==="1"?null:e.jsx(v,{src:this.state.sources[o].icon||"",style:r.iconSelect}),o==="1"?this.t("Source (show all)"):o]},o))}getOneRow(t,o,l){var x,n;const i=this.state.logs[t];if(!i)return;const a=i.severity;let d=i.message||"",f="";if(typeof d!="object"){const w=new RegExp(`${i.from.replace(".","\\.").replace(")","\\)").replace("(","\\(")} \\(\\d+\\) `,"g"),h=d.match(w);h?(d=d.replace(h[0],""),f=h[0].split(" ")[1].match(/\d+/g)[0]):d=d.replace(`${i.from} `,"")}let m=l.sourceFilter!=="1"&&l.sourceFilter!==i.from||this.severities[a]<this.severities[this.state.severity];!m&&l.filterMessage&&(typeof d=="object"?m=!d.original.toLowerCase().includes(l.filterMessage):m=!d.toLowerCase().includes(l.filterMessage));const u=l.previousKey===i.key?t:i.key;l.previousKey=i.key,o.push(e.jsxs(s.TableRow,{id:l.length===t?"endOfLog":void 0,sx:R.getStyle(this.props.theme,r.row,i.odd&&r.rowOdd,m&&r.hidden,this.lastRowRender&&i.ts>this.lastRowRender&&r.updatedRow),style:this.state.colors?{backgroundColor:((x=this.state.sources[i.from])==null?void 0:x.color)||void 0}:{},hover:!0,children:[e.jsx(s.TableCell,{style:{...r.cell,...r.cellName},children:e.jsxs("div",{style:r.iconAndName,children:[e.jsx(v,{src:((n=this.state.sources[i.from])==null?void 0:n.icon)||"",style:r.icon}),e.jsx("div",{style:r.name,children:i.from})]})}),this.state.pid&&e.jsx(s.TableCell,{style:{...r.cell,...r[`${this.props.themeType}_${a}`]},children:f}),e.jsx(s.TableCell,{style:{...r.cell,...r[`${this.props.themeType}_${a}`]},children:i.time}),e.jsx(s.TableCell,{style:{...r.cell,...r[`${this.props.themeType}_${a}`],fontWeight:"bold"},children:i.severity}),e.jsx(s.TableCell,{style:{...r.cell,...r[`${this.props.themeType}_${a}`]},title:typeof d=="object"?d.original:d,children:typeof d=="object"?d.parts.map((w,h)=>e.jsx("span",{style:w.style,children:w.text},h)):d})]},l.keyPrefix+u))}getRows(){const t=[],o={filterMessage:this.state.message.toLowerCase(),sourceFilter:this.state.source,previousKey:0,keyPrefix:"",length:0},l=Object.keys(this.state.sources).sort();if(l.unshift("1"),l.includes(o.sourceFilter)||(o.sourceFilter="1"),o.previousKey=0,o.keyPrefix=this.state.reverse?"r":"",o.length=this.state.pause>0?this.state.pause-1:this.state.logs.length-1,this.state.reverse)for(let i=0;i<=o.length;i++)this.getOneRow(i,t,o);else for(let i=o.length;i>=0;i--)this.getOneRow(i,t,o);return o.length>0&&this.scrollToEnd&&(setTimeout(()=>{const i=document.getElementById("endOfLog");i==null||i.scrollIntoView()},200),this.scrollToEnd=!1),(!this.lastRowRender||Date.now()-this.lastRowRender>1e3)&&(this.lastRowRenderTimeout||(this.lastRowRenderTimeout=setTimeout(()=>{this.lastRowRenderTimeout=null,this.lastRowRender=Date.now()},1e3))),t}renderClearDialog(){return this.state.logDeleteDialog?e.jsxs(s.Dialog,{onClose:()=>this.setState({logDeleteDialog:!1}),open:!0,children:[e.jsxs(s.DialogTitle,{children:[this.t("Please confirm"),e.jsx(s.IconButton,{size:"large",sx:r.closeButton,onClick:()=>this.setState({logDeleteDialog:!1}),children:e.jsx(p.Close,{})})]}),e.jsx(s.DialogContent,{dividers:!0,children:e.jsx(s.Typography,{gutterBottom:!0,children:this.t("Log file will be deleted. Are you sure?")})}),e.jsxs(s.DialogActions,{children:[e.jsx(s.Button,{variant:"contained",autoFocus:!0,onClick:()=>this.handleLogDelete(),color:"primary",startIcon:e.jsx(p.Check,{}),children:this.t("Ok")}),e.jsx(s.Button,{variant:"contained",onClick:()=>this.setState({logDeleteDialog:!1}),color:"grey",startIcon:e.jsx(p.Close,{}),children:this.t("Cancel")})]})]}):null}changePid(){const t=!this.state.pid;(window._localStorage||window.localStorage).setItem("Logs.pid",t?"true":"false"),this.setState({pid:t})}renderToolbar(){var i;const t=this.state.pause?e.jsx(s.Typography,{style:r.pauseCount,children:this.state.logs.length-this.state.pause}):e.jsx(p.Pause,{}),o=this.props.width==="xs"||this.props.width==="sm",l=o?e.jsx(s.IconButton,{color:"primary",onClick:a=>this.setState({logDownloadDialog:a.currentTarget}),children:e.jsx(p.SaveAlt,{})}):e.jsx(s.Button,{variant:"contained",color:"primary",startIcon:e.jsx(p.SaveAlt,{}),onClick:a=>this.setState({logDownloadDialog:a.currentTarget}),children:this.t("Download log")});return e.jsxs(z,{children:[e.jsx(s.Tooltip,{title:this.props.t("Refresh log"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>this.readLogs(!0),children:e.jsx(p.Refresh,{})})}),e.jsx(s.Tooltip,{title:this.props.t("Pause output"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",style:r.pauseButton,onClick:()=>this.handleLogPause(),children:t})}),e.jsx(s.Tooltip,{title:this.props.t("Clear log"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>this.clearLog(),children:e.jsx(p.Delete,{})})}),e.jsx(s.Tooltip,{title:this.props.t("Clear on disk permanent"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>this.setState({logDeleteDialog:!0}),children:e.jsx(p.DeleteForever,{})})}),e.jsx(s.Tooltip,{title:this.props.t("Show/hide PID"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>this.changePid(),color:this.state.pid?"primary":"default",children:e.jsx("div",{style:r.pidSize,children:this.props.t("PID")})})}),e.jsx(s.Tooltip,{title:this.props.t("Show/hide colors"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>{(window._localStorage||window.localStorage).setItem("Logs.colors",this.state.colors?"false":"true"),this.setState({colors:!this.state.colors})},color:this.state.colors?"primary":"default",children:e.jsx(O,{style:{width:"0.8em",height:"0.8em"}})})}),e.jsx(s.Tooltip,{title:this.props.t("Reverse output direction"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>{(window._localStorage||window.localStorage).setItem("Log.reverse",this.state.reverse?"false":"true"),this.setState({reverse:!this.state.reverse}),setTimeout(()=>{const a=document.getElementById("endOfLog");a==null||a.scrollIntoView()},500)},color:this.state.reverse?"primary":"default",children:this.state.reverse?e.jsx(p.ArrowDownward,{}):e.jsx(p.ArrowUpward,{})})}),e.jsx(s.Tooltip,{title:this.props.t("Show errors"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.Badge,{badgeContent:this.state.logErrors,color:"error",sx:{"& .MuiBadge-badge":{...r.badge,...r.badgeError}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>{this.state.severity==="error"?this.setState({severity:"debug"}):this.setState({severity:"error",logErrors:0})},color:this.state.severity==="error"?"primary":"default",children:e.jsx(p.ErrorOutline,{})})})}),e.jsx(s.Tooltip,{title:this.props.t("Show errors and warnings"),slotProps:{popper:{sx:r.tooltip}},children:e.jsx(s.Badge,{badgeContent:this.state.logWarnings,color:"default",sx:{"& .MuiBadge-badge":{...r.badge,...r.badgeWarn}},children:e.jsx(s.IconButton,{size:"large",onClick:()=>{this.state.severity==="warn"?this.setState({severity:"debug"}):this.setState({severity:"warn",logWarnings:0})},color:this.state.severity==="warn"?"primary":"default",children:e.jsx(p.Warning,{})})})}),e.jsx("div",{style:r.grow}),(i=this.state.logFiles)!=null&&i.length?l:null,this.state.logDownloadDialog?e.jsx(s.Menu,{id:"simple-menu",anchorEl:this.state.logDownloadDialog,keepMounted:!0,open:!!this.state.logDownloadDialog,onClose:()=>this.setState({logDownloadDialog:null}),children:this.getLogFiles()}):null,o?null:e.jsx("div",{style:r.grow}),o?null:e.jsxs(s.Typography,{variant:"body2",title:this.state.estimatedSize?this.props.t("Estimated size"):"",style:r.logSize,children:[this.t("Log size:")," ",e.jsx("span",{style:this.state.estimatedSize?r.logEstimated:void 0,children:this.state.logSize===null?"-":T.formatBytes(this.state.logSize)})]})]})}renderTableHeader(){const t=Object.keys(this.state.sources).sort();return t.unshift("1"),e.jsx(s.TableHead,{children:e.jsxs(s.TableRow,{children:[e.jsx(s.TableCell,{sx:r.source,children:e.jsxs(s.FormControl,{variant:"standard",sx:r.formControl,children:[e.jsx(s.Select,{variant:"standard",labelId:"source-label",value:t.includes(this.state.source)?this.state.source:"1",onChange:o=>this.handleSourceChange(o.target.value),renderValue:o=>e.jsxs("div",{style:{backgroundColor:!this.state.colors||o==="1"?void 0:this.state.sources[o].color,display:"flex",alignItems:"center"},children:[o==="1"?null:e.jsx(v,{src:this.state.sources[o].icon||"",style:r.iconSelect}),o==="1"?this.t("Source"):o]}),children:this.getSources()}),(t.includes(this.state.source)?this.state.source:"1")!=="1"?e.jsx(s.IconButton,{sx:{position:"absolute",top:1,right:15,zIndex:1},size:"small",onClick:()=>this.handleSourceChange("1"),children:e.jsx(p.Clear,{})}):null]})}),this.state.pid&&e.jsx(s.TableCell,{sx:r.pid,children:e.jsx(s.Box,{component:"div",sx:r.header,children:this.t("PID")})}),e.jsx(s.TableCell,{sx:r.timestamp,children:e.jsx(s.Box,{component:"div",sx:r.header,children:this.t("Time")})}),e.jsx(s.TableCell,{sx:r.severity,children:e.jsx(s.FormControl,{variant:"standard",style:r.formControl,children:e.jsx(s.Select,{variant:"standard",labelId:"severity-label",value:this.state.severity,onChange:o=>this.handleSeverityChange(o),renderValue:o=>e.jsx("span",{style:r[`${this.props.themeType}_${o}`],children:o}),children:this.getSeverities()})})}),e.jsx(s.TableCell,{sx:r.message,children:e.jsx(s.FormControl,{variant:"standard",style:r.formControl,children:e.jsx(s.TextField,{variant:"standard",sx:r.messageText,placeholder:this.t("Message"),onChange:o=>this.handleMessageChange(o),value:this.state.message,slotProps:{input:{endAdornment:this.state.message?e.jsx(s.IconButton,{tabIndex:-1,size:"small",onClick:()=>{(window._localStorage||window.localStorage).removeItem("Log.message"),this.setState({message:""})},children:e.jsx(p.Close,{})}):null}}})})})]})})}render(){return this.state.logs?(this.state.logFiles===null&&!this.readLogsInProcess&&(this.readLogsInProcess=!0,setTimeout(()=>this.readLogFiles().then(t=>{this.readLogsInProcess=!1,this.setState({logFiles:t})}),100)),this.props.currentHost!==this.state.currentHost&&(this.hostsTimer=this.hostsTimer||setTimeout(()=>{this.hostsTimer=null,this.setState({currentHost:this.props.currentHost,logs:[],logFiles:null},()=>this.readLogs(!0))},200)),e.jsxs(B,{children:[this.renderToolbar(),e.jsx(E,{children:e.jsx(s.TableContainer,{style:r.container,children:e.jsxs(s.Table,{stickyHeader:!0,size:"small",sx:r.table,children:[this.renderTableHeader(),e.jsx(s.TableBody,{children:this.getRows()})]})})}),this.renderClearDialog()]})):e.jsx(s.LinearProgress,{})}}const Z=D()(b);export{Z as default};
|