iobroker.admin 7.6.3 → 7.6.4
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 -4
- package/admin/custom/assets/AdminComponentEasyAccessSet__loadShare___mf_0_iobroker_mf_1_adapter_mf_2_react_mf_2_v5__loadShare__-DnBKtZGU.js +1 -0
- package/admin/custom/assets/AdminComponentEasyAccessSet__loadShare__react__loadShare__-CEWlgS6L.js +1 -0
- package/admin/custom/assets/AdminComponentEasyAccessSet__loadShare__react_mf_2_dom__loadShare__-BaTCLP1q.js +1 -0
- package/admin/custom/assets/Components-BGVs6Dmn.js +1 -0
- package/admin/custom/assets/TextField-ChPwodvp.js +109 -0
- package/admin/custom/assets/_commonjsHelpers-D6-XlEtG.js +1 -0
- package/admin/custom/assets/bootstrap-CTERJrgr.js +1 -0
- package/admin/custom/assets/createSvgIcon-D2osie2l.js +7 -0
- package/admin/custom/assets/defaultTheme-CFicWEn0.js +16 -0
- package/admin/custom/assets/hostInit-DAQ2zgXM.js +1 -1
- package/admin/custom/assets/index-BqaC8TTV.js +1397 -0
- package/admin/custom/assets/index-BwCOsmBT.js +31 -0
- package/admin/custom/assets/index-C9L9KccV.js +779 -0
- package/admin/custom/assets/index-CGID5h1b.js +779 -0
- package/{adminWww/assets/index-Di7Jseht.js → admin/custom/assets/index-Co3YA5NW.js} +1 -1
- package/admin/custom/assets/index-DIVai5gZ.js +119 -0
- package/admin/custom/assets/index-DrWcIcrD.js +1 -0
- package/admin/custom/assets/index-IIKn7Ixx.js +1 -0
- package/admin/custom/assets/index-PIXQ0sh_.js +2 -0
- package/admin/custom/assets/index-eQxyhk2m.js +24 -0
- package/admin/custom/assets/jsx-runtime-Bhtgc1Ek.js +9 -0
- package/admin/custom/assets/useTheme-COyz47gO.js +1 -0
- package/admin/custom/assets/virtualExposes-BufY-8i6.js +2 -0
- package/admin/custom/customComponents.js +2 -2
- package/admin/i18n/{de/translations.json → de.json} +35 -34
- package/admin/i18n/{en/translations.json → en.json} +38 -37
- package/admin/i18n/{es/translations.json → es.json} +39 -38
- package/admin/i18n/{fr/translations.json → fr.json} +39 -38
- package/admin/i18n/{it/translations.json → it.json} +39 -38
- package/admin/i18n/{nl/translations.json → nl.json} +39 -38
- package/admin/i18n/{pl/translations.json → pl.json} +39 -38
- package/admin/i18n/{pt/translations.json → pt.json} +39 -38
- package/admin/i18n/{ru/translations.json → ru.json} +39 -38
- package/admin/i18n/{uk/translations.json → uk.json} +7 -6
- package/admin/i18n/{zh-cn/translations.json → zh-cn.json} +39 -38
- package/admin/jsonConfig.json5 +9 -0
- package/adminWww/assets/{AdapterUpdateDialog-CRermRaB.js → AdapterUpdateDialog-D5A35Ofn.js} +1 -1
- package/adminWww/assets/{Adapters-Bs8G-cxo.js → Adapters-QfGvr9Xv.js} +1 -1
- package/adminWww/assets/{Config-Di_mkCPb.js → Config-J_9jPJSh.js} +1 -1
- package/adminWww/assets/{CustomModal-BTTKhEC8.js → CustomModal-_hsT1UfZ.js} +1 -1
- package/adminWww/assets/{CustomTab-D6Mn63bB.js → CustomTab-k0r6if9B.js} +1 -1
- package/adminWww/assets/{DefaultPropsProvider-Beyggw1o.js → DefaultPropsProvider-BrbE0teb.js} +2 -2
- package/adminWww/assets/{EasyMode-DKcbIjJ6.js → EasyMode-BR5t1u_s.js} +1 -1
- package/adminWww/assets/{Enums-uOeKEKzl.js → Enums-DyPrfI2O.js} +1 -1
- package/adminWww/assets/{Fields-TuYhaeX9.js → Fields-Vpif7eQH.js} +1 -1
- package/adminWww/assets/{Files-BhPaQLPw.js → Files-XKQDh_3j.js} +1 -1
- package/adminWww/assets/FilledInput-D-tz8rvg.js +2 -0
- package/adminWww/assets/{Hosts-BNvz1qdC.js → Hosts-Dt3S3r7E.js} +1 -1
- package/adminWww/assets/Instances-Da-mNkXP.js +2 -0
- package/adminWww/assets/{Intro-Dih9urjd.js → Intro-pr1AT7Gn.js} +1 -1
- package/adminWww/assets/{Logs-C8bVKj2s.js → Logs-CoAIXCkZ.js} +1 -1
- package/adminWww/assets/{Objects-CD7n6XMI.js → Objects-CwBnoFN-.js} +1 -1
- package/adminWww/assets/{State-Bs4eLVUn.js → State-XZNqqv8y.js} +1 -1
- package/adminWww/assets/{Tabs-C57_YqtR.js → Tabs-CFvfAcjP.js} +10 -10
- package/adminWww/assets/{Users-DMJv0VQ1.js → Users-y0PgSeFL.js} +1 -1
- package/adminWww/assets/_commonjsHelpers-D6-XlEtG.js +1 -0
- package/adminWww/assets/ace-B1YQ8uqS.js +980 -0
- package/adminWww/assets/blueGrey-B0oIowPK.js +29 -0
- package/adminWww/assets/{bootstrap-DF1rNJUh.js → bootstrap-FVlt-hkS.js} +90 -91
- package/adminWww/assets/{createSvgIcon-DHNqxcCi.js → createSvgIcon-DH-uXnd0.js} +1 -1
- package/adminWww/assets/{emotion-react.browser.esm-DHkeNZGw.js → emotion-react.browser.esm-DApPKwaj.js} +1 -1
- package/adminWww/assets/{emotion-styled.browser.esm-DkldMRyw.js → emotion-styled.browser.esm-Dc05hmeu.js} +1 -1
- package/adminWww/assets/{emotion-utils.browser.esm-CKteYtrd.js → emotion-utils.browser.esm-DOjH6Olm.js} +1 -1
- package/adminWww/assets/{geosearch.module-cgRkjHe4.js → geosearch.module-CWfRtxrN.js} +1 -1
- package/adminWww/assets/{iconBase-CxzgaDaB.js → iconBase-CgxZ5MMC.js} +1 -1
- package/adminWww/assets/{index-ChNtEgbM.js → index-BN8A2xkW.js} +1 -1
- package/adminWww/assets/{index-DGeySK-Q.js → index-BXSb0Ud9.js} +2 -2
- package/adminWww/assets/index-Bj8P5tgE.js +55 -0
- package/adminWww/assets/{index-C3WYIc6x.js → index-Bsv_DXxB.js} +1 -1
- package/adminWww/assets/{index-SuMq84bM.js → index-C1TmeS7j.js} +1 -1
- package/adminWww/assets/{index-BMTRswnc.js → index-CJvbfjSs.js} +1 -1
- package/adminWww/assets/index-Cm4u8yKm.js +7 -0
- package/adminWww/assets/index-Co3YA5NW.js +9 -0
- package/adminWww/assets/{index-DgvYPGcD.js → index-D7Rlw-5R.js} +1 -1
- package/adminWww/assets/{index-BmaLPlND.js → index-DiMYzxTU.js} +1 -1
- package/adminWww/assets/{index-CFcKrkeG.js → index-HOidq_rM.js} +1 -1
- package/adminWww/assets/{index-Dhk9onlg.js → index-gHyOgbGJ.js} +1 -1
- package/adminWww/assets/{iobroker_admin__loadShare__leaflet__loadShare__-FMqZHPyC.js → iobroker_admin__loadShare__leaflet__loadShare__-B1OZ7tj-.js} +1 -1
- package/adminWww/assets/{iobroker_admin__loadShare__prop_mf_2_types__loadShare__-C8Lvs8Es.js → iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BGyJCibC.js} +1 -1
- package/adminWww/assets/{iobroker_admin__loadShare__react__loadShare__-T96CJO0k.js → iobroker_admin__loadShare__react__loadShare__-DtlEM_52.js} +1 -1
- package/adminWww/assets/{leaflet-src-CnimXdd7.js → leaflet-src-A2ZHl6nF.js} +1 -1
- package/adminWww/assets/{sentry-ClQ-PGjf.js → sentry-AXxoSb7Q.js} +1 -1
- package/adminWww/assets/{zh-cn-DrUOm-Ho.js → zh-cn-49uPQVT0.js} +1 -1
- package/adminWww/index.html +1 -1
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/remoteEntry.js +2 -2
- package/build-backend/lib/utils.js +10 -10
- package/build-backend/lib/utils.js.map +1 -1
- package/build-backend/lib/web.js +7 -1
- package/build-backend/lib/web.js.map +1 -1
- package/build-backend/main.js +4 -1
- package/build-backend/main.js.map +1 -1
- package/io-package.json +17 -14
- package/package.json +10 -11
- package/adminWww/assets/FilledInput-Bfz0Aef-.js +0 -2
- package/adminWww/assets/Instances-L7eZoDyM.js +0 -2
- package/adminWww/assets/_commonjsHelpers-BosuxZz1.js +0 -1
- package/adminWww/assets/ace-BAuRYJjv.js +0 -978
- package/adminWww/assets/blueGrey-BKTirx-Z.js +0 -29
- package/adminWww/assets/index-Cmq0Omjs.js +0 -55
- package/adminWww/assets/index-lAM5Xnu_.js +0 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as s,B as A,F as S,J as B}from"./DefaultPropsProvider-Beyggw1o.js";import{i as I,R as P}from"./iobroker_admin__loadShare__react__loadShare__-T96CJO0k.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-DF1rNJUh.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-C8Lvs8Es.js";import"./_commonjsHelpers-BosuxZz1.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-BAuRYJjv.js";import"./FilledInput-Bfz0Aef-.js";import"./preload-helper-C1FmrZbK.js";import"./blueGrey-BKTirx-Z.js";import"./emotion-cache.browser.esm-B8BFze5o.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-FMqZHPyC.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,{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,{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,{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,{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.png"};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.png"&&(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.png",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])||"--"}
|
|
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-FVlt-hkS.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-B1YQ8uqS.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,{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,{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,{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,{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.png"};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.png"&&(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.png",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
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-Beyggw1o.js";import{i as I}from"./iobroker_admin__loadShare__react__loadShare__-T96CJO0k.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-DF1rNJUh.js";import{b as O}from"./index-CFcKrkeG.js";import{a as y}from"./blueGrey-BKTirx-Z.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-C8Lvs8Es.js";import"./_commonjsHelpers-BosuxZz1.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-BAuRYJjv.js";import"./FilledInput-Bfz0Aef-.js";import"./preload-helper-C1FmrZbK.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-FMqZHPyC.js";import"./extends-CF3RwP-h.js";import"./iconBase-CxzgaDaB.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.png"),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-FVlt-hkS.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-B1YQ8uqS.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.png"),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,4 +1,4 @@
|
|
|
1
|
-
import{j as y}from"./DefaultPropsProvider-Beyggw1o.js";import{i as at,R as vh}from"./iobroker_admin__loadShare__react__loadShare__-T96CJO0k.js";import{w as Wn,f as rn,J as gh,i as w,a as X,u as Gl,v as $x,D as mh,x as Yx,y as qt,z as ks,U as jt,B as Xx,M as Cd,R as yh,I as G,E as ty,K as Td,N as qx,O as Ad,P as Zx,b as Ca,Q as ey,q as Kx,V as Rs,W as Jx}from"./bootstrap-DF1rNJUh.js";import{l as Qx}from"./index-8HslT92O.js";import{a as tw,i as ew}from"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import{c as rw,d as iw,e as nw,f as Md}from"./index-CFcKrkeG.js";import{a as aw}from"./_commonjsHelpers-BosuxZz1.js";import{h as Ul}from"./zh-cn-DrUOm-Ho.js";import{C as ow}from"./CustomModal-BTTKhEC8.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-C8Lvs8Es.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-BAuRYJjv.js";import"./FilledInput-Bfz0Aef-.js";import"./preload-helper-C1FmrZbK.js";import"./blueGrey-BKTirx-Z.js";import"./emotion-cache.browser.esm-B8BFze5o.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-FMqZHPyC.js";import"./extends-CF3RwP-h.js";import"./iconBase-CxzgaDaB.js";const Ut={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden"},headingIcon:{marginRight:5,width:32,height:32},titleEnabled:{float:"right",fontSize:16,color:"#7ff57f",textTransform:"uppercase",fontWeight:"bold",paddingLeft:20},scrollDiv:{width:"100%",height:"100%",overflow:"auto"},enabledControl:{width:130,display:"inline-block",verticalAlign:"top"},customControls:{width:"calc(100% - 130px)",maxWidth:800,display:"inline-block",verticalAlign:"top",paddingTop:16},accordionOdd:{},accordionEven:{backgroundColor:"rgba(128, 128, 128, 0.1)"},accordionHeaderOdd:{backgroundColor:"rgba(128, 128, 128, 0.2)"},accordionHeaderEven:{backgroundColor:"rgba(128, 128, 128, 0.3)"},accordionHeaderEnabledOdd:{backgroundColor:"rgba(128, 255, 128, 0.2)"},accordionHeaderEnabledEven:{backgroundColor:"rgba(128, 255, 128, 0.2)"},enabledVisible:{display:"inline-block"},enabledInvisible:{display:"none"}},sw=".";class Ls extends at.Component{changedIds;scrollDivRef;jsonConfigs;refTemplate;customObj;commonConfig={};cb;cachedNewValues;constructor(t){super(t);let e;try{e=JSON.parse((window._localStorage||window.localStorage).getItem("App.customsExpanded")||"[]")}catch{e=[]}this.changedIds=[],this.state={loaded:!1,expanded:e,newValues:{},confirmed:!1,showConfirmation:!1,maxOids:0,systemConfig:this.props.systemConfig},this.scrollDivRef=at.createRef(),this.jsonConfigs={},this.refTemplate={},this.props.customsInstances.map(i=>this.refTemplate[i]=at.createRef()),this.customObj=this.props.objectIDs.length>1?{common:{custom:{}},native:{}}:rn.deepClone(this.props.objects[this.props.objectIDs[0]]||null),this.customObj&&this.loadAllCustoms().then(()=>{this.commonConfig=this.getCommonConfig(),this.setState({loaded:!0,newValues:{}})})}async componentDidMount(){this.state.systemConfig||this.setState({systemConfig:await this.props.socket.getCompactSystemConfig()}),this.props.registerSaveFunc&&this.props.registerSaveFunc(this.onSave)}componentWillUnmount(){this.props.registerSaveFunc&&this.props.registerSaveFunc()}async loadAllCustoms(){const t=[];for(const e of this.props.customsInstances){if(e==="_")continue;const i=e.replace(/\.\d+$/,"").replace("system.adapter.","");this.jsonConfigs[i]===void 0&&(this.jsonConfigs[i]=null,t.push(this.getCustomTemplate(i)))}await Promise.all(t),this.props.customsInstances.forEach(e=>{var n,a;const i=e.replace(/\.\d+$/,"").replace("system.adapter.","");this.jsonConfigs[i]&&(this.jsonConfigs[i].instanceObjs=this.jsonConfigs[i].instanceObjs||{},this.jsonConfigs[i].instanceObjs[e]={_id:e,common:JSON.parse(JSON.stringify((n=this.props.objects[`system.adapter.${e}`])==null?void 0:n.common)),native:JSON.parse(JSON.stringify((a=this.props.objects[`system.adapter.${e}`])==null?void 0:a.native)),type:"instance",instanceObjects:[],objects:[]})})}async getCustomTemplate(t){var i;const e=this.props.objects[`system.adapter.${t}`]?rn.deepClone(this.props.objects[`system.adapter.${t}`]):null;if(!e){console.error(`Cannot find adapter "${t}"`);return}if(rn.fixAdminUI(e),((i=e.common)==null?void 0:i.adminUI.custom)==="json")try{const n=await this.props.socket.fileExists(`${t}.admin`,"jsonCustom.json5");let a,o;n?o=await this.props.socket.readFile(`${t}.admin`,"jsonCustom.json5"):o=await this.props.socket.readFile(`${t}.admin`,"jsonCustom.json"),o.file!==void 0?a=o.file:a=o;let s;try{s=Qx.parse(a),this.jsonConfigs[t]=this.jsonConfigs[t]||{},this.jsonConfigs[t].json=s}catch(l){console.error(`Cannot parse jsonConfig of ${t}: ${l}`),window.alert(`Cannot parse jsonConfig of ${t}: ${l}`)}await gh.loadI18n(this.props.socket,s.i18n,t);return}catch(n){console.error(`Cannot load jsonConfig of ${t}: ${n}`),window.alert(`Cannot load jsonConfig of ${t}: ${n}`)}console.error(`Adapter ${t} is not yet supported by this version of admin`),window.alert(`Adapter ${t} is not yet supported by this version of admin`)}_executeCustom(t,e,i,n,a,o,s){if(s.includes(o))return;s.push(o);let l=[],u;if(t&&typeof t=="object"?(l=t.alsoDependsOn||[],typeof l=="string"&&(l=[l]),u=t.func):u=t,l.forEach(h=>{if(!a[h])console.error(`[JsonConfigComponent] attribute "${h}" does not exist!`);else if(!a[h].defaultFunc)console.error(`[JsonConfigComponent] attribute "${h}" is not required to be includes in "alsoDependsOn" while has static value!`);else{const c=this._executeCustom(a[h].defaultFunc,e,i,n,a,h,s);c!==void 0&&(e[h]=c)}}),!u)e[o]=a[o].default===void 0?null:a[o].default;else try{const h=new Function("data","originalData","_system","instanceObj","customObj","_socket",u.includes("return")?u:`return ${u}`);e[o]=h(e||this.props.data,this.props.originalData,this.props.systemConfig,n,i,this.props.socket)}catch(h){console.error(`Cannot execute ${t}: ${h}`),e[o]=!a[o]||a[o].default===void 0?null:a[o].default}return e[o]}static flattenItems(t,e={}){return t&&Object.keys(t).forEach(i=>{t[i].items?Ls.flattenItems(t[i].items,e):e[i]=t[i]}),e}getDefaultValues(t,e){const i={enabled:!1},n=t.split(".")[0];if(this.jsonConfigs[n]&&!this.jsonConfigs[n].disabled){const a=Ls.flattenItems(this.jsonConfigs[n].json.items);if(a){const o=[],s=Object.keys(a).filter(l=>a[l]);s.forEach(l=>{!a[l].defaultFunc&&a[l].default!==void 0&&(i[l]=a[l].default)}),s.forEach(l=>{a[l].defaultFunc&&this._executeCustom(a[l].defaultFunc,i,e,this.jsonConfigs[n].instanceObjs[t],a,l,o)})}}return i}getCommonConfig(){const t=this.props.objectIDs||[],e=this.props.objects,i={};return this.props.customsInstances.forEach(n=>{const a=n.split(".")[0];this.jsonConfigs[a]&&this.jsonConfigs[a].disabled||(i[n]={},t.forEach(o=>{var u;const s=e[o],l=(u=s==null?void 0:s.common)!=null&&u.custom&&s.common.custom[n]||null;if(l)Object.keys(l).forEach(h=>{h.startsWith("_")||(i[n][h]===void 0?i[n][h]=l[h]:i[n][h]!==l[h]&&(Array.isArray(i[n][h])||(i[n][h]=[i[n][h]]),i[n][h].includes(l[h])||i[n][h].push(l[h])))});else{const h=this.getDefaultValues(n,s);h.enabled=!1,Object.keys(h).forEach(c=>{c.startsWith("_")||(i[n][c]===void 0?i[n][c]=h[c]:i[n][c]!==h[c]&&(Array.isArray(i[n][c])||(i[n][c]=[i[n][c]]),i[n][c].includes(h[c])||i[n][c].push(h[c])))})}}),Object.keys(i[n]).forEach(o=>{Array.isArray(i[n][o])&&i[n][o].sort()}))}),i}isChanged(t){return t=t||this.state.newValues,Object.keys(t).find(e=>t[e]===null||t[e]&&Object.keys(t[e]).find(i=>!i.startsWith("_")))}combineNewAndOld(t,e=!1){const i={...this.commonConfig[t]||{},...this.state.newValues[t]||{}};return e&&Object.keys(i).forEach(n=>{n.startsWith("_")&&delete i[n]}),this.state.newValues[t]===null&&(i.enabled=!1),i}renderOneCustom(t,e,i,n){var f,d;const a=t.split(".")[0],o=`${sw}/adapter/${a}/${this.props.objects[`system.adapter.${a}`].common.icon}`,s=this.state.newValues[t]!==void 0&&(!this.state.newValues[t]||this.state.newValues[t].enabled!==void 0)?!!(this.state.newValues[t]&&this.state.newValues[t].enabled):this.state.newValues[t]===null?!1:this.commonConfig[t].enabled,l=Array.isArray(s)&&(!this.state.newValues[t]||this.state.newValues[t].enabled===void 0),u=(d=(f=this.jsonConfigs[a])==null?void 0:f.json)==null?void 0:d.disabled,h=this.combineNewAndOld(t);if(u&&this.jsonConfigs[a].json.hidden===!0||typeof this.jsonConfigs[a].json.hidden=="string"&&this._executeCustom(this.jsonConfigs[a].json.hidden,h,i,e,this.jsonConfigs[a].json.items,"enabled",[]))return null;let c=null;return u&&this.jsonConfigs[a].json.help&&(typeof this.jsonConfigs[a].json.help=="object"?c=this.jsonConfigs[a].json.help[this.props.lang]||this.jsonConfigs[a].json.help.en:c=this.props.t(this.jsonConfigs[a].json.help)),y.jsxs(w.Accordion,{id:`Accordion_${t}`,style:n%2?Ut.accordionOdd:Ut.accordionEven,expanded:this.state.expanded.includes(t),ref:this.refTemplate[t],onChange:()=>{const p=[...this.state.expanded],v=p.indexOf(t);v===-1?p.push(t):p.splice(v,1),(window._localStorage||window.localStorage).setItem("App.customsExpanded",JSON.stringify(p)),v===-1&&(window._localStorage||window.localStorage).setItem("App.customsLastExpanded",t),this.setState({expanded:p})},children:[y.jsxs(w.AccordionSummary,{expandIcon:y.jsx(X.ExpandMore,{}),"data-id":t,style:n%2?s?Ut.accordionHeaderEnabledOdd:Ut.accordionHeaderOdd:s?Ut.accordionHeaderEnabledEven:Ut.accordionHeaderEven,children:[y.jsx("img",{src:o,style:Ut.headingIcon,alt:""}),y.jsx(w.Typography,{style:Ut.heading,children:this.props.t("Settings %s",t)}),y.jsx("div",{className:"titleEnabled",style:{...Ut.titleEnabled,...s?Ut.enabledVisible:Ut.enabledInvisible},children:this.props.t("Enabled")})]}),y.jsxs(w.AccordionDetails,{children:[y.jsx("div",{style:Ut.enabledControl,children:y.jsx(w.FormControlLabel,{style:Ut.formControl,control:y.jsx(w.Checkbox,{indeterminate:l,checked:!!s,disabled:!!u,onChange:p=>{this.cachedNewValues=this.cachedNewValues||this.state.newValues;const v=rn.deepClone(this.cachedNewValues);v[t]=v[t]||{},l||p.target.checked?v[t].enabled=!0:s&&this.commonConfig[t].enabled?v[t]=null:delete v[t],this.cachedNewValues=v,this.setState({newValues:v,hasChanges:this.isChanged(v)},()=>{this.cachedNewValues=void 0,this.props.onChange&&this.props.onChange(!!this.state.hasChanges)})}}),label:this.props.t("Enabled")})}),y.jsxs("div",{style:Ut.customControls,children:[!u&&(s||l)&&this.state.systemConfig?y.jsx(gh,{instanceObj:e,customObj:i,custom:!0,adapterName:a,instance:parseInt((t==null?void 0:t.split(".").pop())??"0",10)||0,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,multiEdit:this.props.objectIDs.length>1,schema:this.jsonConfigs[a].json,data:h,isFloatComma:this.props.systemConfig.common.isFloatComma,dateFormat:this.props.systemConfig.common.dateFormat,onError:p=>this.setState({error:p},()=>this.props.onError&&this.props.onError(p)),onValueChange:(p,v)=>{var m;this.cachedNewValues=this.cachedNewValues||this.state.newValues,console.log(`${p} => ${v}`);const g=rn.deepClone(this.cachedNewValues);g[t]=g[t]||{},JSON.stringify(Gl.getValue((m=this.commonConfig)==null?void 0:m[t],p))===JSON.stringify(v)?(Gl.setValue(g[t],p,null),Object.keys(g[t]).length||delete g[t]):Gl.setValue(g[t],p,v),this.cachedNewValues=g,this.setState({newValues:g,hasChanges:this.isChanged(g)},()=>{this.cachedNewValues=void 0,this.props.onChange&&this.props.onChange(!!this.state.hasChanges)})}}):null,c]})]})]},t)}renderErrorMessage(){return!!this.state.error&&y.jsx($x,{title:this.props.t("Error"),text:this.state.error?"Error":"",onClose:()=>this.setState({error:!1})})}getObject(t,e,i){return t[i]?Promise.resolve(t[i]):this.props.socket.getObject(i).then(n=>(e[i]=rn.deepClone(n),t[i]=n,n))}saveOneState(t,e,i,n){if(i=i||{},n=n||{},t!=null&&t.length){const a=this.state.maxOids||t.length;this.state.maxOids===null&&this.setState({maxOids:t.length},()=>this.props.onProgress(!0)),this.setState({progress:Math.round((a-t.length)/a*50)});const o=t.shift();this.getObject(i,n,o).then(s=>{var u,h,c;if(!s){window.alert(`Invalid object ${o}`);return}(u=s.common)!=null&&u.custom&&Object.keys(s.common.custom).forEach(f=>{(!s.common.custom[f]||!s.common.custom[f].enabled)&&(s.common.custom[f]=null)});const l=Object.keys(this.state.newValues);for(let f=0;f<l.length;f++){const d=l[f],p=this.combineNewAndOld(d,!0);if(p.enabled===!1)(c=(h=s.common)==null?void 0:h.custom)!=null&&c[d]&&(s.common.custom[d]=null);else if(p.enabled){if(s.common=s.common||{},Array.isArray(p.enabled)&&(!s.common.custom||!s.common.custom[d]||!s.common.custom[d].enabled)){s.common.custom&&s.common.custom[d]&&(s.common.custom[d]=null);continue}if(s.common.custom=s.common.custom||{},!s.common.custom[d]||!s.common.custom[d].enabled){const g=this.getDefaultValues(d,s);s.common.custom[d]=JSON.parse(JSON.stringify(g||{})),Object.keys(s.common.custom[d]).forEach(m=>{m.startsWith("_")&&delete s.common.custom[d][m]})}const v=this.props.objectIDs.length>1;s.common.custom[d].enabled=!0,Object.keys(p).forEach(g=>{if(!g.startsWith("_")){if(Array.isArray(p[g])&&v)return;s.common.custom[d][g]=p[g]}})}}setTimeout(()=>this.saveOneState(t,e,i,n),0)})}else{const a=Object.keys(i);if(!a.length)this.setState({maxOids:0},()=>this.props.onProgress(!1)),e&&e();else{this.setState({progress:Math.round((this.state.maxOids-a.length)/this.state.maxOids*50)+50});const o=a.shift();if(JSON.stringify(i[o].common)!==JSON.stringify(n[o].common)){this.changedIds.includes(o)||this.changedIds.push(o),this.props.socket.setObject(o,i[o]).then(async()=>{delete i[o],delete n[o],this.props.objects[o]=await this.props.socket.getObject(o),setTimeout(()=>this.saveOneState(t,e,i,n),0)});return}delete i[o],delete n[o],setTimeout(()=>this.saveOneState(t,e,i,n),0)}}}renderConfirmationDialog(){return this.state.showConfirmation?y.jsx(mh,{text:this.props.t("The changes will be applied to %s states. Are you sure?",this.props.objectIDs.length.toString()),ok:this.props.t("Yes"),onClose:t=>{t?this.setState({showConfirmation:!1,confirmed:!0},()=>{const e=this.cb;this.cb=void 0,this.onSave(e)}):(this.cb=void 0,this.setState({showConfirmation:!1}))}}):null}onSave=t=>{this.props.objectIDs.length>10&&!this.state.confirmed?(this.cb=t,this.setState({showConfirmation:!0})):this.saveOneState([...this.props.objectIDs],()=>{this.cachedNewValues={},this.commonConfig=this.getCommonConfig(),this.setState({confirmed:!1,hasChanges:void 0,newValues:{}},()=>{this.props.reportChangedIds(this.changedIds),this.props.onChange(!1,!0),t&&setTimeout(()=>t(),100)})})};render(){if(this.customObj===null)return y.jsx("div",{style:{color:"#F55",fontSize:32},children:this.props.t("Object does not exist!")});if(!this.state.loaded)return y.jsx(w.LinearProgress,{});let t=0;return y.jsxs(w.Paper,{style:Ut.paper,children:[this.state.maxOids>1&&y.jsx(w.LinearProgress,{color:"secondary",variant:"determinate",value:this.state.progress}),y.jsx("div",{style:Ut.scrollDiv,ref:this.scrollDivRef,children:this.state.maxOids===0&&Object.values(this.jsonConfigs).map(e=>e?Object.keys(e.instanceObjs).map(i=>this.renderOneCustom(i,e.instanceObjs[i],this.customObj,t++)):null)}),this.renderErrorMessage(),this.renderConfirmationDialog()]})}}const lw=Wn()(Ls),{loadShare:uw}=ew,{initPromise:hw}=tw,cw=hw.then(r=>uw("date-fns/locale",{customShareInfo:{shareConfig:{singleton:!0,strictVersion:!1,requiredVersion:"*"}}})),fw=await cw.then(r=>r());var we=fw;const Os={en:we.enUS,fr:we.fr,ru:we.ru,de:we.de,es:we.es,br:we.ptBR,nl:we.nl,it:we.it,pt:we.pt,pl:we.pl,uk:we.uk,"zh-cn":we.zhCN},rt={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden"},tableDiv:r=>({height:`calc(100% - ${parseInt(r.mixins.toolbar.minHeight,10)+8}px)`,overflow:"hidden",width:"100%"}),container:{height:"100%"},table:r=>({minWidth:960,width:"100%","& td:nth-of-type(5)":{overflow:"hidden",whiteSpace:"nowrap"},"& tr:nth-child(even)":{backgroundColor:r.palette.mode==="dark"?"#383838":"#b2b2b2"}}),row:{userSelect:"none",position:"relative","&:hover":{opacity:.7},"& td":{position:"relative"}},updatedRow:{animation:"updated 1s"},rowInterpolated:{opacity:.5},selectHistoryControl:{width:130},selectRelativeTime:{marginLeft:10,width:200},notAliveInstance:{opacity:.5},customRange:r=>({color:r.palette.primary.main}),rowSelected:r=>({backgroundColor:r.palette.secondary.main,color:r.palette.secondary.contrastText,"& td":{color:r.palette.secondary.contrastText,backgroundColor:r.palette.secondary.main}}),rowFocused:r=>({position:"absolute",pointerEvents:"none",top:0,bottom:0,left:0,right:0,m:"3px",border:`1px dotted ${r.palette.action.active}`}),grow:{flexGrow:1},msInput:{width:50,pt:"10px",ml:"5px","& label":{mt:"15px"}},cellAckTrue:r=>({color:r.palette.mode==="dark"?"#66ff7f":"#04a821"}),cellAckFalse:{color:"#FF6666"},toolbarDate:{width:124,mt:"9px","& fieldset":{display:"none"},"& input":{padding:"8px 0 0 0"},"& .MuiInputAdornment-root":{ml:0,mt:"7px"}},toolbarTime:{width:84,mt:"9px","& fieldset":{display:"none"},"& input":{padding:"8px 0 0 0"},"& .MuiInputAdornment-root":{ml:0,mt:"7px"}},toolbarTimeGrid:{position:"relative",marginLeft:8,paddingLeft:8,paddingRight:8,paddingTop:4,paddingBottom:4,border:"1px dotted #AAAAAA",borderRadius:8,display:"flex"},toolbarTimeLabel:{position:"absolute",padding:8,fontSize:"0.8rem",left:2,top:-9},noLoadingProgress:{width:"100%",height:4},colValue:{},colAck:{},colFrom:{},colLastChange:{},colTs:{}};class Es extends at.Component{adminInstance;supportedFeaturesPromises;unit;timeTimer;readSupportedFeaturesTimeout;rangeValues;rangeRef;subscribes;localStorage;constructor(t){super(t),this.localStorage=window._localStorage||window.localStorage;let e=this.localStorage.getItem("App.relativeRange")||"absolute";const i=parseInt(this.localStorage.getItem("App.absoluteStart"),10)||0,n=parseInt(this.localStorage.getItem("App.absoluteEnd"),10)||0,a=this.localStorage.getItem("App.historySelected")||"",o=parseInt(this.localStorage.getItem("App.historyLastSelected"),10)||null,s=this.localStorage.getItem("App.historyLastSelectedColumn")||null;(!i||!n)&&(!e||e==="absolute")&&(e="30"),i&&n&&(e="absolute");let l;try{l=JSON.parse(a)}catch{l=[]}this.state={start:i,end:n,values:null,relativeRange:e,selected:l,lastSelected:o,lastSelectedColumn:s,historyInstance:"",updateOpened:!1,insertOpened:!1,historyInstances:null,lcVisible:!0,ackVisible:!0,fromVisible:!0,supportedFeatures:[],ampm:!1,edit:{}},this.adminInstance=parseInt(window.location.search.slice(1),10)||0,this.supportedFeaturesPromises={},this.unit=this.props.obj.common&&this.props.obj.common.unit?` ${this.props.obj.common.unit}`:"",this.timeTimer=void 0,this.subscribes=[],this.prepareData().then(()=>this.readHistoryRange()).then(()=>{e!=="absolute"?this.setRelativeInterval(this.state.relativeRange,!0):this.readHistory()})}readSupportedFeatures(t){return t=t||this.state.historyInstance,t?this.supportedFeaturesPromises[t]instanceof Promise?this.supportedFeaturesPromises[t]:(this.supportedFeaturesPromises[t]=new Promise(e=>{this.readSupportedFeaturesTimeout&&clearTimeout(this.readSupportedFeaturesTimeout),this.readSupportedFeaturesTimeout=setTimeout(()=>{this.readSupportedFeaturesTimeout=void 0,e([])},2e3),this.props.socket.sendTo(t,"features",null).then(i=>{this.readSupportedFeaturesTimeout?(clearTimeout(this.readSupportedFeaturesTimeout),this.readSupportedFeaturesTimeout=void 0,e(i?i.supportedFeatures||[]:[])):this.setState({supportedFeatures:i?i.supportedFeatures||[]:[]})})}),this.supportedFeaturesPromises[t]):Promise.resolve([])}async componentDidMount(){await this.props.socket.subscribeState(this.props.obj._id,this.onChange)}componentWillUnmount(){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0);for(let t=0;t<this.subscribes.length;t++)this.props.socket.unsubscribeState(this.subscribes[t],this.onChange);this.subscribes=[],this.props.socket.unsubscribeState(this.props.obj._id,this.onChange)}onChange=(t,e)=>{if(t===this.props.obj._id&&e&&this.state.values&&(!this.state.values.length||this.state.values[this.state.values.length-1].ts<e.ts)){const i=[...this.state.values,e];this.setState({values:i})}else if(t.startsWith("system.adapter.")&&t.endsWith(".alive")){const i=t.substring(15,t.length-6),n=this.state.historyInstances,a=n.findIndex(o=>o.id===i);if(a!==-1&&n[a].alive!==!!(e!=null&&e.val)){const o=JSON.parse(JSON.stringify(n));o[a].alive=!!(e!=null&&e.val),this.setState({historyInstances:o},()=>{o[a].alive&&this.state.historyInstance===i&&this.readHistoryRange().then(()=>this.readHistory())})}}};async prepareData(){var o;const t=await this.getHistoryInstances(),e=await this.props.socket.getCompactSystemConfig(),i=(o=e==null?void 0:e.common)==null?void 0:o.defaultHistory;let n=this.localStorage.getItem("App.historyInstance")||"";if((!n||!t.find(s=>s.id===n&&s.alive))&&(n=i),!n||!t.find(s=>s.id===n&&s.alive)){const s=t.find(l=>l.alive);s&&(n=s.id)}!n&&t.length&&(n=i);const a=await this.readSupportedFeatures(n);await new Promise(s=>{this.setState({ampm:(e.common.dateFormat||"").includes("/"),historyInstances:t,historyInstance:n,supportedFeatures:a},()=>s())})}getHistoryInstances(){const t=[],e=[];return this.props.customsInstances.forEach(i=>{const n=this.props.objects[`system.adapter.${i}`];if(n&&n.common&&n.common.getHistory){const a={id:i,alive:!1};t.push(a),e.push(`system.adapter.${i}.alive`)}}),e.length?this.props.socket.getForeignStates(e).then(async i=>{Object.keys(i).forEach(n=>{var o;const a=t.find(s=>n.endsWith(`${s.id}.alive`));a&&(a.alive=!!((o=i[n])!=null&&o.val))}),this.subscribes=e;for(let n=0;n<e.length;n++)await this.props.socket.subscribeState(e[n],this.onChange);return t}):Promise.resolve(t)}readHistory(t,e){var i;return t=t||this.state.start,e=e||this.state.end,!this.state.historyInstance||!((i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive))?null:(this.setState({loading:!0}),this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:t,end:e,from:!0,ack:!0,q:!0,addId:!1,aggregate:"none",returnNewestEntries:!0}).then(n=>{const a=[],o=this.rangeValues;let s=!1,l=!1,u=!1;if(o&&o.length&&(!n||!n.length||o[0].ts<n[0].ts)&&(a.push(o[0]),a.push({ts:o[0].ts+1,e:!0}),console.log(`add ${new Date(o[0].ts).toISOString()}: ${o[0].val}`),!l&&o[0].ack!==void 0&&(l=!0),!u&&o[0].from&&(u=!0)),n!=null&&n.length)for(let h=0;h<n.length;h++)n[h]&&(!a.length||a[a.length-1].ts<n[h].ts)?(a.push(n[h]),n[h].from&&(n[h].from.startsWith("system.adapter.")?n[h].from=n[h].from.substring(15):n[h].from.startsWith("system.host.")&&(n[h].from=n[h].from.substring(7))),!s&&n[h].lc&&(s=!0),!l&&n[h].ack!==void 0&&(l=!0),!u&&n[h].from&&(u=!0),console.log(`add value ${new Date(n[h].ts).toISOString()}: ${n[h].val}`)):a[a.length-1].ts===n[h].ts&&a[a.length-1].val!==n[h].ts&&console.error("Strange data!");else a.push({noDataForPeriod:!0});a.length||a.push({noData:!0}),this.setState({loading:!1,values:a,lcVisible:s,fromVisible:u,ackVisible:l})}))}readHistoryRange(){var i;const t=new Date,e=new Date(2e3,0,1);return!this.state.historyInstance||!((i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive))?Promise.resolve():(this.setState({loading:!0}),this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:e.getTime(),end:t.getTime(),limit:1,from:!1,ack:!1,q:!1,addId:!1,aggregate:"none"}).then(n=>{n.length?((n[0].val===null||n[0].ts===e.getTime())&&n.shift(),n.forEach(a=>a.i=!0),this.rangeValues=n,this.setState({loading:!1})):(this.rangeValues=[],this.setState({loading:!1}))}))}onToggleSelect(t,e,i){let n=[...this.state.selected];const a=n.indexOf(e);if(t.shiftKey&&this.state.lastSelected){let o=-1,s=-1;n=[];for(let l=0;l<this.state.values.length&&!(this.state.values[l].ts===e&&(o=l,s!==o&&n.push(this.state.values[l].ts),o!==-1&&s!==-1)||this.state.values[l].ts===this.state.lastSelected&&(s=l,s!==o&&n.push(this.state.values[l].ts),o!==-1&&s!==-1));l++)(o!==-1||s!==-1)&&n.push(this.state.values[l].ts)}else t.ctrlKey?(a!==-1?n.splice(a,1):n.push(e),n.sort()):n=[e];this.localStorage.setItem("App.historyLastSelected",e.toString()),this.localStorage.setItem("App.historyLastSelectedColumn",i),this.localStorage.setItem("App.historySelected",JSON.stringify(n)),this.setState({selected:n,lastSelected:e,lastSelectedColumn:i})}getTableRows(){const t=[];for(let e=this.state.values.length-1;e>=0;e--){const i=this.state.values[e],n=i.ts;if(i.e)t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...rt.rowInterpolated},hover:!0,children:[y.jsx(w.TableCell,{}),y.jsx(w.TableCell,{children:"..."}),this.state.ackVisible?y.jsx(w.TableCell,{}):null,this.state.fromVisible?y.jsx(w.TableCell,{}):null,this.state.lcVisible?y.jsx(w.TableCell,{}):null]},n));else if(i.noData||i.noDataForPeriod)t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...rt.rowNoData},hover:!0,children:[y.jsx(w.TableCell,{}),y.jsx(w.TableCell,{children:i.noData?this.props.t("No data in history"):this.props.t("No data in history for selected period")}),this.state.ackVisible?y.jsx(w.TableCell,{}):null,this.state.fromVisible?y.jsx(w.TableCell,{}):null,this.state.lcVisible?y.jsx(w.TableCell,{}):null]},i.noData?"nodata":""));else{const a=i.i,o=this.state.lastSelected===n;let s=i.val;this.props.isFloatComma&&this.props.obj.common.type==="number"&&s&&(s=s.toString().replace(".",",")),s===null&&(s="null"),s===void 0&&(s="_");const l=this.state.selected.includes(n);t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...a?rt.rowInterpolated:void 0,...l?rt.rowSelected:void 0},children:[y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"ts"),children:[`${Es.formatTimestamp(i.ts)}`,o&&this.state.lastSelectedColumn==="ts"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}),y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"val"),children:[s+this.unit,o&&this.state.lastSelectedColumn==="val"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}),this.state.ackVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"ack"),sx:i.ack?rt.cellAckTrue:rt.cellAckFalse,children:[i.ack?"true":"false",o&&this.state.lastSelectedColumn==="ack"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null,this.state.fromVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"from"),children:[i.from||"",o&&this.state.lastSelectedColumn==="from"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null,this.state.lcVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"lc"),children:[i.lc?`${new Date(i.lc).toLocaleDateString()} ${new Date(i.lc).toLocaleTimeString()}.${(i.ts%1e3).toString().padStart(3,"0")}`:"",o&&this.state.lastSelectedColumn==="lc"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null]},n.toString()+(i.val||"").toString()))}}return t}shiftTime(){const t=new Date,e=6e4-t.getSeconds()-(1e3-t.getMilliseconds());t.getMilliseconds()&&t.setMilliseconds(1e3),t.getSeconds()&&t.setSeconds(60);const i=t.getTime();let n;const a=this.state.relativeRange;if(a==="day")t.setHours(0),t.setMinutes(0),t.setSeconds(0),n=t.getTime();else if(a==="week"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else if(a==="2weeks"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(t.getDate()-7);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else a==="month"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),n=t.getTime()):a==="year"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),t.setMonth(0),n=t.getTime()):a==="12months"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setFullYear(t.getFullYear()-1),n=t.getTime()):n=i-parseInt(a,10)*6e4;this.setState({start:n,end:i},()=>this.readHistory()),this.timeTimer=setTimeout(()=>{this.timeTimer=void 0,this.shiftTime()},e||6e4)}setRelativeInterval(t,e){if(e||(this.localStorage.setItem("App.relativeRange",t.toString()),this.setState({relativeRange:t})),t==="absolute"){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0);return}this.localStorage.removeItem("App.absoluteStart"),this.localStorage.removeItem("App.absolute");const i=new Date;if(!this.timeTimer){const o=6e4-i.getSeconds()-(1e3-i.getMilliseconds());this.timeTimer=setTimeout(()=>{this.timeTimer=void 0,this.shiftTime()},o||6e4)}i.getMilliseconds()&&i.setMilliseconds(1e3),i.getSeconds()&&i.setSeconds(60);const n=i.getTime();let a;if(t==="day")i.setHours(0),i.setMinutes(0),i.setSeconds(0),a=i.getTime();else if(t==="week"){i.setHours(0),i.setMinutes(0),i.setSeconds(0);const o=i.getDay()||7;o!==1&&i.setHours(-24*(o-1)),a=i.getTime()}else if(t==="2weeks"){i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(i.getDate()-7);const o=i.getDay()||7;o!==1&&i.setHours(-24*(o-1)),a=i.getTime()}else t==="month"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(1),a=i.getTime()):t==="year"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(1),i.setMonth(0),a=i.getTime()):t==="12months"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setFullYear(i.getFullYear()-1),a=i.getTime()):(t=Number(t),a=n-t*6e4);this.setState({start:a,end:n},()=>this.readHistory())}renderTable(){var t;if(!this.state.historyInstance)return y.jsx("div",{style:{marginTop:20,fontSize:24},children:this.props.t("History instance not selected")});if(!((t=this.state.historyInstances)!=null&&t.find(e=>e.id===this.state.historyInstance&&e.alive)))return y.jsx("div",{style:{marginTop:20,fontSize:24},children:this.props.t("History instance not alive")});if(this.state.values){const e=[200,"auto"],i=[190,100];return this.state.ackVisible&&(e.push(50),i.push(50)),this.state.fromVisible&&(e.push(150),i.push(150)),this.state.lcVisible&&(e.push(200),i.push(190)),y.jsx(w.TableContainer,{style:rt.container,children:y.jsxs(Yx,{stickyHeader:!0,sx:rt.table,initialWidths:e,minWidths:i,dblTitle:this.props.t("ra_Double click to reset table layout"),children:[y.jsx(w.TableHead,{children:y.jsxs(w.TableRow,{children:[y.jsx(w.TableCell,{style:rt.colTs,children:this.props.t("Timestamp")}),y.jsx(w.TableCell,{style:rt.colValue,children:this.props.t("Value")}),this.state.ackVisible?y.jsx(w.TableCell,{style:rt.colAck,children:this.props.t("Ack")}):null,this.state.fromVisible?y.jsx(w.TableCell,{style:rt.colFrom,children:this.props.t("From")}):null,this.state.lcVisible?y.jsx(w.TableCell,{style:rt.colLastChange,children:this.props.t("lc")}):null]})}),y.jsx(w.TableBody,{children:this.getTableRows()})]})})}return y.jsx(w.LinearProgress,{})}renderDialogConfirm(){return y.jsxs(w.Dialog,{open:!!this.state.areYouSure,onClose:()=>this.setState({areYouSure:!1}),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[y.jsx(w.DialogTitle,{id:"alert-dialog-title"}),y.jsxs(w.DialogContent,{children:[y.jsx(w.DialogContentText,{id:"alert-dialog-description",children:this.props.t("Are you sure?")}),y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{value:this.state.suppressMessage,onChange:()=>this.setState({suppressMessage:!0})}),label:this.props.t("Suppress for 5 minutes")})]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({areYouSure:!1,suppressMessage:this.state.suppressMessage&&Date.now()},()=>this.onDelete()),color:"primary",autoFocus:!0,startIcon:y.jsx(X.Delete,{}),children:this.props.t("Delete")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({areYouSure:!1}),color:"secondary",startIcon:y.jsx(X.Close,{}),children:this.props.t("Cancel")})]})]})}onDelete(){const t=this.state.selected.map(e=>({state:{ts:e},id:this.props.obj._id}));this.props.socket.sendTo(this.state.historyInstance,"delete",t).then(()=>this.readHistory())}onUpdate(){let t=this.state.edit.val;this.props.obj.common&&(this.props.obj.common.type==="number"?typeof t!="number"&&(t=parseFloat(t.toString().replace(",","."))):this.props.obj.common.type==="boolean"&&(t=t==="true"||t==="TRUE"||t===!0||t==="1"||t===1));const e={val:t,ack:this.state.edit.ack,ts:this.state.selected[0],from:`system.adapter.admin.${this.adminInstance}`,q:this.state.edit.q};for(const[i,n]of Object.entries(e))n===void 0&&delete e[i];!this.state.lcVisible&&e.lc&&delete e.lc,this.props.socket.sendTo(this.state.historyInstance,"update",[{id:this.props.obj._id,state:e}]).then(()=>this.readHistory())}onInsert(){let t=this.state.edit.val;this.props.obj.common&&(this.props.obj.common.type==="number"?t=parseFloat(t.toString().replace(",",".")):this.props.obj.common.type==="boolean"&&(t=t==="true"||t==="TRUE"||t===!0||t==="1"||t===1));const e=this.state.edit.date;e.setHours(this.state.edit.time.getHours()),e.setMinutes(this.state.edit.time.getMinutes()),e.setSeconds(this.state.edit.time.getSeconds()),e.setMilliseconds(parseInt(this.state.edit.ms,10));const i={ts:e.getTime(),val:t,ack:this.state.edit.ack,from:`system.adapter.admin.${this.adminInstance}`,q:this.state.edit.q||0};!this.state.lcVisible&&i.lc&&delete i.lc;for(const[n,a]of Object.entries(i))a===void 0&&delete i[n];this.props.socket.sendTo(this.state.historyInstance,"insert",[{id:this.props.obj._id,state:i}]).then(()=>this.readHistory())}updateEdit(t,e){const i=JSON.parse(JSON.stringify(this.state.edit));i.time=new Date(i.time),i.date=new Date(i.date),i[t]=e,this.setState({edit:i})}renderEditDialog(){return y.jsxs(w.Dialog,{open:this.state.updateOpened||this.state.insertOpened,onClose:()=>this.setState({updateOpened:!1,insertOpened:!1}),"aria-labelledby":"edit-dialog-title","aria-describedby":"edit-dialog-description",children:[y.jsx(w.DialogTitle,{id:"edit-dialog-title",children:this.state.updateOpened?this.props.t("Update entry"):this.props.t("Insert entry")}),y.jsx(w.DialogContent,{children:y.jsxs("form",{noValidate:!0,autoComplete:"off",children:[typeof this.state.edit.val=="boolean"?y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.edit.val,onChange:t=>this.updateEdit("val",t.target.checked)}),label:this.props.t("Value")}):y.jsx(w.TextField,{variant:"standard",label:this.props.t("Value"),value:this.state.edit.val,onChange:t=>this.updateEdit("val",t.target.value)}),y.jsx("br",{}),y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.edit.ack,onChange:t=>this.updateEdit("ack",t.target.checked)}),label:this.props.t("Acknowledged")}),this.state.insertOpened?y.jsx(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:rt.toolbarTimeLabel,children:this.props.t("Time")}),y.jsx(qt.DatePicker,{sx:rt.toolbarDate,value:this.state.edit.date,onChange:t=>this.updateEdit("date",t)}),y.jsx(qt.TimePicker,{sx:rt.toolbarTime,ampm:this.state.ampm,views:["hours","minutes","seconds"],value:this.state.edit.time,onChange:t=>this.updateEdit("time",t)}),y.jsx(w.TextField,{variant:"standard",sx:rt.msInput,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{max:999,min:0}},value:this.state.edit.ms,onChange:t=>this.updateEdit("ms",t.target.value)})]})}):null]})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",disabled:this.state.edit.val==="",onClick:()=>{const t=this.state.updateOpened;this.setState({updateOpened:!1,insertOpened:!1},()=>t?this.onUpdate():this.onInsert())},color:"primary",autoFocus:!0,children:this.state.updateOpened?this.props.t("Update"):this.props.t("Add")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({updateOpened:!1,insertOpened:!1}),color:"grey",children:this.props.t("Cancel")})]})]})}setStartDate(t){const e=t.getTime();this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0),this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",e.toString()),this.localStorage.setItem("App.absoluteEnd",this.state.end.toString()),this.setState({start:e,relativeRange:"absolute"},()=>this.readHistory())}setEndDate(t){const e=t.getTime();this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",this.state.start.toString()),this.localStorage.setItem("App.absoluteEnd",e.toString()),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0),this.setState({end:e,relativeRange:"absolute"},()=>this.readHistory())}renderToolbar(){var t,e;return y.jsxs(w.Toolbar,{children:[y.jsxs(w.FormControl,{variant:"standard",style:rt.selectHistoryControl,children:[y.jsx(w.InputLabel,{children:this.props.t("History instance")}),y.jsx(w.Select,{variant:"standard",value:this.state.historyInstance||"",onChange:i=>{const n=i.target.value;this.localStorage.setItem("App.historyInstance",n),this.readSupportedFeatures(n).then(a=>this.setState({historyInstance:n,supportedFeatures:a},()=>this.readHistory()))},children:(t=this.state.historyInstances)==null?void 0:t.map(i=>y.jsx(w.MenuItem,{value:i.id,style:i.alive?void 0:rt.notAliveInstance,children:i.id},i.id))})]}),y.jsxs(w.FormControl,{variant:"standard",style:rt.selectRelativeTime,children:[y.jsx(w.InputLabel,{children:this.props.t("Relative")}),y.jsxs(w.Select,{variant:"standard",ref:this.rangeRef,value:this.state.relativeRange,onChange:i=>this.setRelativeInterval(i.target.value),children:[y.jsx(w.MenuItem,{value:"absolute",sx:rt.customRange,children:this.props.t("custom range")},"custom"),y.jsx(w.MenuItem,{value:10,children:this.props.t("last 10 minutes")},"1"),y.jsx(w.MenuItem,{value:30,children:this.props.t("last 30 minutes")},"2"),y.jsx(w.MenuItem,{value:60,children:this.props.t("last hour")},"3"),y.jsx(w.MenuItem,{value:"day",children:this.props.t("this day")},"4"),y.jsx(w.MenuItem,{value:24*60,children:this.props.t("last 24 hours")},"5"),y.jsx(w.MenuItem,{value:"week",children:this.props.t("this week")},"6"),y.jsx(w.MenuItem,{value:24*60*7,children:this.props.t("last week")},"7"),y.jsx(w.MenuItem,{value:"2weeks",children:this.props.t("this 2 weeks")},"8"),y.jsx(w.MenuItem,{value:24*60*14,children:this.props.t("last 2 weeks")},"9"),y.jsx(w.MenuItem,{value:"month",children:this.props.t("this month")},"10"),y.jsx(w.MenuItem,{value:30*24*60,children:this.props.t("last 30 days")},"11"),y.jsx(w.MenuItem,{value:"year",children:this.props.t("this year")},"12"),y.jsx(w.MenuItem,{value:"12months",children:this.props.t("last 12 months")},"13")]})]}),y.jsxs(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:[y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:{...rt.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("Start time")}),y.jsx(qt.DatePicker,{sx:rt.toolbarDate,disabled:this.state.relativeRange!=="absolute",value:new Date(this.state.start),onChange:i=>this.setStartDate(i)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.start),onChange:i=>this.setStartDate(i)})]}),y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:{...rt.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("End time")}),y.jsx(qt.DatePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarDate,value:new Date(this.state.end),onChange:i=>this.setEndDate(i)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.end),onChange:i=>this.setEndDate(i)})]})]}),y.jsx(w.Box,{component:"div",sx:rt.grow}),(e=this.state.values)!=null&&e.length?y.jsx(w.IconButton,{size:"large",onClick:()=>this.exportData(),title:this.props.t("Save data as csv"),children:y.jsx(rw,{})}):null,this.state.supportedFeatures.includes("insert")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",onClick:()=>{const i=new Date,n={ack:this.state.values[this.state.values.length-1].ack,val:this.state.values[this.state.values.length-1].val,date:new Date(i),ms:0,time:new Date(i),q:0};this.setState({edit:n,insertOpened:!0})},children:y.jsx(iw,{})}):null,this.state.supportedFeatures.includes("update")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",disabled:this.state.selected.length!==1,onClick:()=>{const i=JSON.parse(JSON.stringify(this.state.values.find(a=>a.ts===this.state.lastSelected))),n=new Date(i.ts);i.date=new Date(n),i.time=new Date(n),this.setState({edit:i,updateOpened:!0})},children:y.jsx(X.Edit,{})}):null,this.state.supportedFeatures.includes("delete")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",disabled:!this.state.selected.length,onClick:()=>{typeof this.state.suppressMessage=="number"&&Date.now()-this.state.suppressMessage<3e5?this.onDelete():this.setState({areYouSure:!0})},children:y.jsx(X.Delete,{})}):null]})}exportData(){let t=window.document.getElementById("export-file");t||(t=document.createElement("a"),t.setAttribute("id","export-file"),t.style.display="none",document.body.appendChild(t));const e=["timestamp;value;acknowledged;from;"];this.state.values.forEach(i=>!i.i&&!i.e&&e.push([Es.formatTimestamp(i.ts),i.val===null||i.val===void 0?"null":i.val.toString(),i.ack?"true":"false",i.from||""].join(";"))),t.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(e.join(`
|
|
1
|
+
import{j as y}from"./DefaultPropsProvider-BrbE0teb.js";import{i as at,R as vh}from"./iobroker_admin__loadShare__react__loadShare__-DtlEM_52.js";import{w as Wn,f as rn,J as gh,i as w,a as X,u as Gl,v as $x,D as mh,x as Yx,y as qt,z as ks,U as jt,B as Xx,M as Cd,R as yh,I as G,E as ty,K as Td,N as qx,O as Ad,P as Zx,b as Ca,Q as ey,q as Kx,V as Rs,W as Jx}from"./bootstrap-FVlt-hkS.js";import{l as Qx}from"./index-8HslT92O.js";import{a as tw,i as ew}from"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import{c as rw,d as iw,e as nw,f as Md}from"./index-HOidq_rM.js";import{a as aw}from"./_commonjsHelpers-D6-XlEtG.js";import{h as Ul}from"./zh-cn-49uPQVT0.js";import{C as ow}from"./CustomModal-_hsT1UfZ.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BGyJCibC.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-B1YQ8uqS.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";import"./iconBase-CgxZ5MMC.js";const Ut={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden"},headingIcon:{marginRight:5,width:32,height:32},titleEnabled:{float:"right",fontSize:16,color:"#7ff57f",textTransform:"uppercase",fontWeight:"bold",paddingLeft:20},scrollDiv:{width:"100%",height:"100%",overflow:"auto"},enabledControl:{width:130,display:"inline-block",verticalAlign:"top"},customControls:{width:"calc(100% - 130px)",maxWidth:800,display:"inline-block",verticalAlign:"top",paddingTop:16},accordionOdd:{},accordionEven:{backgroundColor:"rgba(128, 128, 128, 0.1)"},accordionHeaderOdd:{backgroundColor:"rgba(128, 128, 128, 0.2)"},accordionHeaderEven:{backgroundColor:"rgba(128, 128, 128, 0.3)"},accordionHeaderEnabledOdd:{backgroundColor:"rgba(128, 255, 128, 0.2)"},accordionHeaderEnabledEven:{backgroundColor:"rgba(128, 255, 128, 0.2)"},enabledVisible:{display:"inline-block"},enabledInvisible:{display:"none"}},sw=".";class Ls extends at.Component{changedIds;scrollDivRef;jsonConfigs;refTemplate;customObj;commonConfig={};cb;cachedNewValues;constructor(t){super(t);let e;try{e=JSON.parse((window._localStorage||window.localStorage).getItem("App.customsExpanded")||"[]")}catch{e=[]}this.changedIds=[],this.state={loaded:!1,expanded:e,newValues:{},confirmed:!1,showConfirmation:!1,maxOids:0,systemConfig:this.props.systemConfig},this.scrollDivRef=at.createRef(),this.jsonConfigs={},this.refTemplate={},this.props.customsInstances.map(i=>this.refTemplate[i]=at.createRef()),this.customObj=this.props.objectIDs.length>1?{common:{custom:{}},native:{}}:rn.deepClone(this.props.objects[this.props.objectIDs[0]]||null),this.customObj&&this.loadAllCustoms().then(()=>{this.commonConfig=this.getCommonConfig(),this.setState({loaded:!0,newValues:{}})})}async componentDidMount(){this.state.systemConfig||this.setState({systemConfig:await this.props.socket.getCompactSystemConfig()}),this.props.registerSaveFunc&&this.props.registerSaveFunc(this.onSave)}componentWillUnmount(){this.props.registerSaveFunc&&this.props.registerSaveFunc()}async loadAllCustoms(){const t=[];for(const e of this.props.customsInstances){if(e==="_")continue;const i=e.replace(/\.\d+$/,"").replace("system.adapter.","");this.jsonConfigs[i]===void 0&&(this.jsonConfigs[i]=null,t.push(this.getCustomTemplate(i)))}await Promise.all(t),this.props.customsInstances.forEach(e=>{var n,a;const i=e.replace(/\.\d+$/,"").replace("system.adapter.","");this.jsonConfigs[i]&&(this.jsonConfigs[i].instanceObjs=this.jsonConfigs[i].instanceObjs||{},this.jsonConfigs[i].instanceObjs[e]={_id:e,common:JSON.parse(JSON.stringify((n=this.props.objects[`system.adapter.${e}`])==null?void 0:n.common)),native:JSON.parse(JSON.stringify((a=this.props.objects[`system.adapter.${e}`])==null?void 0:a.native)),type:"instance",instanceObjects:[],objects:[]})})}async getCustomTemplate(t){var i;const e=this.props.objects[`system.adapter.${t}`]?rn.deepClone(this.props.objects[`system.adapter.${t}`]):null;if(!e){console.error(`Cannot find adapter "${t}"`);return}if(rn.fixAdminUI(e),((i=e.common)==null?void 0:i.adminUI.custom)==="json")try{const n=await this.props.socket.fileExists(`${t}.admin`,"jsonCustom.json5");let a,o;n?o=await this.props.socket.readFile(`${t}.admin`,"jsonCustom.json5"):o=await this.props.socket.readFile(`${t}.admin`,"jsonCustom.json"),o.file!==void 0?a=o.file:a=o;let s;try{s=Qx.parse(a),this.jsonConfigs[t]=this.jsonConfigs[t]||{},this.jsonConfigs[t].json=s}catch(l){console.error(`Cannot parse jsonConfig of ${t}: ${l}`),window.alert(`Cannot parse jsonConfig of ${t}: ${l}`)}await gh.loadI18n(this.props.socket,s.i18n,t);return}catch(n){console.error(`Cannot load jsonConfig of ${t}: ${n}`),window.alert(`Cannot load jsonConfig of ${t}: ${n}`)}console.error(`Adapter ${t} is not yet supported by this version of admin`),window.alert(`Adapter ${t} is not yet supported by this version of admin`)}_executeCustom(t,e,i,n,a,o,s){if(s.includes(o))return;s.push(o);let l=[],u;if(t&&typeof t=="object"?(l=t.alsoDependsOn||[],typeof l=="string"&&(l=[l]),u=t.func):u=t,l.forEach(h=>{if(!a[h])console.error(`[JsonConfigComponent] attribute "${h}" does not exist!`);else if(!a[h].defaultFunc)console.error(`[JsonConfigComponent] attribute "${h}" is not required to be includes in "alsoDependsOn" while has static value!`);else{const c=this._executeCustom(a[h].defaultFunc,e,i,n,a,h,s);c!==void 0&&(e[h]=c)}}),!u)e[o]=a[o].default===void 0?null:a[o].default;else try{const h=new Function("data","originalData","_system","instanceObj","customObj","_socket",u.includes("return")?u:`return ${u}`);e[o]=h(e||this.props.data,this.props.originalData,this.props.systemConfig,n,i,this.props.socket)}catch(h){console.error(`Cannot execute ${t}: ${h}`),e[o]=!a[o]||a[o].default===void 0?null:a[o].default}return e[o]}static flattenItems(t,e={}){return t&&Object.keys(t).forEach(i=>{t[i].items?Ls.flattenItems(t[i].items,e):e[i]=t[i]}),e}getDefaultValues(t,e){const i={enabled:!1},n=t.split(".")[0];if(this.jsonConfigs[n]&&!this.jsonConfigs[n].disabled){const a=Ls.flattenItems(this.jsonConfigs[n].json.items);if(a){const o=[],s=Object.keys(a).filter(l=>a[l]);s.forEach(l=>{!a[l].defaultFunc&&a[l].default!==void 0&&(i[l]=a[l].default)}),s.forEach(l=>{a[l].defaultFunc&&this._executeCustom(a[l].defaultFunc,i,e,this.jsonConfigs[n].instanceObjs[t],a,l,o)})}}return i}getCommonConfig(){const t=this.props.objectIDs||[],e=this.props.objects,i={};return this.props.customsInstances.forEach(n=>{const a=n.split(".")[0];this.jsonConfigs[a]&&this.jsonConfigs[a].disabled||(i[n]={},t.forEach(o=>{var u;const s=e[o],l=(u=s==null?void 0:s.common)!=null&&u.custom&&s.common.custom[n]||null;if(l)Object.keys(l).forEach(h=>{h.startsWith("_")||(i[n][h]===void 0?i[n][h]=l[h]:i[n][h]!==l[h]&&(Array.isArray(i[n][h])||(i[n][h]=[i[n][h]]),i[n][h].includes(l[h])||i[n][h].push(l[h])))});else{const h=this.getDefaultValues(n,s);h.enabled=!1,Object.keys(h).forEach(c=>{c.startsWith("_")||(i[n][c]===void 0?i[n][c]=h[c]:i[n][c]!==h[c]&&(Array.isArray(i[n][c])||(i[n][c]=[i[n][c]]),i[n][c].includes(h[c])||i[n][c].push(h[c])))})}}),Object.keys(i[n]).forEach(o=>{Array.isArray(i[n][o])&&i[n][o].sort()}))}),i}isChanged(t){return t=t||this.state.newValues,Object.keys(t).find(e=>t[e]===null||t[e]&&Object.keys(t[e]).find(i=>!i.startsWith("_")))}combineNewAndOld(t,e=!1){const i={...this.commonConfig[t]||{},...this.state.newValues[t]||{}};return e&&Object.keys(i).forEach(n=>{n.startsWith("_")&&delete i[n]}),this.state.newValues[t]===null&&(i.enabled=!1),i}renderOneCustom(t,e,i,n){var f,d;const a=t.split(".")[0],o=`${sw}/adapter/${a}/${this.props.objects[`system.adapter.${a}`].common.icon}`,s=this.state.newValues[t]!==void 0&&(!this.state.newValues[t]||this.state.newValues[t].enabled!==void 0)?!!(this.state.newValues[t]&&this.state.newValues[t].enabled):this.state.newValues[t]===null?!1:this.commonConfig[t].enabled,l=Array.isArray(s)&&(!this.state.newValues[t]||this.state.newValues[t].enabled===void 0),u=(d=(f=this.jsonConfigs[a])==null?void 0:f.json)==null?void 0:d.disabled,h=this.combineNewAndOld(t);if(u&&this.jsonConfigs[a].json.hidden===!0||typeof this.jsonConfigs[a].json.hidden=="string"&&this._executeCustom(this.jsonConfigs[a].json.hidden,h,i,e,this.jsonConfigs[a].json.items,"enabled",[]))return null;let c=null;return u&&this.jsonConfigs[a].json.help&&(typeof this.jsonConfigs[a].json.help=="object"?c=this.jsonConfigs[a].json.help[this.props.lang]||this.jsonConfigs[a].json.help.en:c=this.props.t(this.jsonConfigs[a].json.help)),y.jsxs(w.Accordion,{id:`Accordion_${t}`,style:n%2?Ut.accordionOdd:Ut.accordionEven,expanded:this.state.expanded.includes(t),ref:this.refTemplate[t],onChange:()=>{const p=[...this.state.expanded],v=p.indexOf(t);v===-1?p.push(t):p.splice(v,1),(window._localStorage||window.localStorage).setItem("App.customsExpanded",JSON.stringify(p)),v===-1&&(window._localStorage||window.localStorage).setItem("App.customsLastExpanded",t),this.setState({expanded:p})},children:[y.jsxs(w.AccordionSummary,{expandIcon:y.jsx(X.ExpandMore,{}),"data-id":t,style:n%2?s?Ut.accordionHeaderEnabledOdd:Ut.accordionHeaderOdd:s?Ut.accordionHeaderEnabledEven:Ut.accordionHeaderEven,children:[y.jsx("img",{src:o,style:Ut.headingIcon,alt:""}),y.jsx(w.Typography,{style:Ut.heading,children:this.props.t("Settings %s",t)}),y.jsx("div",{className:"titleEnabled",style:{...Ut.titleEnabled,...s?Ut.enabledVisible:Ut.enabledInvisible},children:this.props.t("Enabled")})]}),y.jsxs(w.AccordionDetails,{children:[y.jsx("div",{style:Ut.enabledControl,children:y.jsx(w.FormControlLabel,{style:Ut.formControl,control:y.jsx(w.Checkbox,{indeterminate:l,checked:!!s,disabled:!!u,onChange:p=>{this.cachedNewValues=this.cachedNewValues||this.state.newValues;const v=rn.deepClone(this.cachedNewValues);v[t]=v[t]||{},l||p.target.checked?v[t].enabled=!0:s&&this.commonConfig[t].enabled?v[t]=null:delete v[t],this.cachedNewValues=v,this.setState({newValues:v,hasChanges:this.isChanged(v)},()=>{this.cachedNewValues=void 0,this.props.onChange&&this.props.onChange(!!this.state.hasChanges)})}}),label:this.props.t("Enabled")})}),y.jsxs("div",{style:Ut.customControls,children:[!u&&(s||l)&&this.state.systemConfig?y.jsx(gh,{instanceObj:e,customObj:i,custom:!0,adapterName:a,instance:parseInt((t==null?void 0:t.split(".").pop())??"0",10)||0,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,multiEdit:this.props.objectIDs.length>1,schema:this.jsonConfigs[a].json,data:h,isFloatComma:this.props.systemConfig.common.isFloatComma,dateFormat:this.props.systemConfig.common.dateFormat,onError:p=>this.setState({error:p},()=>this.props.onError&&this.props.onError(p)),onValueChange:(p,v)=>{var m;this.cachedNewValues=this.cachedNewValues||this.state.newValues,console.log(`${p} => ${v}`);const g=rn.deepClone(this.cachedNewValues);g[t]=g[t]||{},JSON.stringify(Gl.getValue((m=this.commonConfig)==null?void 0:m[t],p))===JSON.stringify(v)?(Gl.setValue(g[t],p,null),Object.keys(g[t]).length||delete g[t]):Gl.setValue(g[t],p,v),this.cachedNewValues=g,this.setState({newValues:g,hasChanges:this.isChanged(g)},()=>{this.cachedNewValues=void 0,this.props.onChange&&this.props.onChange(!!this.state.hasChanges)})}}):null,c]})]})]},t)}renderErrorMessage(){return!!this.state.error&&y.jsx($x,{title:this.props.t("Error"),text:this.state.error?"Error":"",onClose:()=>this.setState({error:!1})})}getObject(t,e,i){return t[i]?Promise.resolve(t[i]):this.props.socket.getObject(i).then(n=>(e[i]=rn.deepClone(n),t[i]=n,n))}saveOneState(t,e,i,n){if(i=i||{},n=n||{},t!=null&&t.length){const a=this.state.maxOids||t.length;this.state.maxOids===null&&this.setState({maxOids:t.length},()=>this.props.onProgress(!0)),this.setState({progress:Math.round((a-t.length)/a*50)});const o=t.shift();this.getObject(i,n,o).then(s=>{var u,h,c;if(!s){window.alert(`Invalid object ${o}`);return}(u=s.common)!=null&&u.custom&&Object.keys(s.common.custom).forEach(f=>{(!s.common.custom[f]||!s.common.custom[f].enabled)&&(s.common.custom[f]=null)});const l=Object.keys(this.state.newValues);for(let f=0;f<l.length;f++){const d=l[f],p=this.combineNewAndOld(d,!0);if(p.enabled===!1)(c=(h=s.common)==null?void 0:h.custom)!=null&&c[d]&&(s.common.custom[d]=null);else if(p.enabled){if(s.common=s.common||{},Array.isArray(p.enabled)&&(!s.common.custom||!s.common.custom[d]||!s.common.custom[d].enabled)){s.common.custom&&s.common.custom[d]&&(s.common.custom[d]=null);continue}if(s.common.custom=s.common.custom||{},!s.common.custom[d]||!s.common.custom[d].enabled){const g=this.getDefaultValues(d,s);s.common.custom[d]=JSON.parse(JSON.stringify(g||{})),Object.keys(s.common.custom[d]).forEach(m=>{m.startsWith("_")&&delete s.common.custom[d][m]})}const v=this.props.objectIDs.length>1;s.common.custom[d].enabled=!0,Object.keys(p).forEach(g=>{if(!g.startsWith("_")){if(Array.isArray(p[g])&&v)return;s.common.custom[d][g]=p[g]}})}}setTimeout(()=>this.saveOneState(t,e,i,n),0)})}else{const a=Object.keys(i);if(!a.length)this.setState({maxOids:0},()=>this.props.onProgress(!1)),e&&e();else{this.setState({progress:Math.round((this.state.maxOids-a.length)/this.state.maxOids*50)+50});const o=a.shift();if(JSON.stringify(i[o].common)!==JSON.stringify(n[o].common)){this.changedIds.includes(o)||this.changedIds.push(o),this.props.socket.setObject(o,i[o]).then(async()=>{delete i[o],delete n[o],this.props.objects[o]=await this.props.socket.getObject(o),setTimeout(()=>this.saveOneState(t,e,i,n),0)});return}delete i[o],delete n[o],setTimeout(()=>this.saveOneState(t,e,i,n),0)}}}renderConfirmationDialog(){return this.state.showConfirmation?y.jsx(mh,{text:this.props.t("The changes will be applied to %s states. Are you sure?",this.props.objectIDs.length.toString()),ok:this.props.t("Yes"),onClose:t=>{t?this.setState({showConfirmation:!1,confirmed:!0},()=>{const e=this.cb;this.cb=void 0,this.onSave(e)}):(this.cb=void 0,this.setState({showConfirmation:!1}))}}):null}onSave=t=>{this.props.objectIDs.length>10&&!this.state.confirmed?(this.cb=t,this.setState({showConfirmation:!0})):this.saveOneState([...this.props.objectIDs],()=>{this.cachedNewValues={},this.commonConfig=this.getCommonConfig(),this.setState({confirmed:!1,hasChanges:void 0,newValues:{}},()=>{this.props.reportChangedIds(this.changedIds),this.props.onChange(!1,!0),t&&setTimeout(()=>t(),100)})})};render(){if(this.customObj===null)return y.jsx("div",{style:{color:"#F55",fontSize:32},children:this.props.t("Object does not exist!")});if(!this.state.loaded)return y.jsx(w.LinearProgress,{});let t=0;return y.jsxs(w.Paper,{style:Ut.paper,children:[this.state.maxOids>1&&y.jsx(w.LinearProgress,{color:"secondary",variant:"determinate",value:this.state.progress}),y.jsx("div",{style:Ut.scrollDiv,ref:this.scrollDivRef,children:this.state.maxOids===0&&Object.values(this.jsonConfigs).map(e=>e?Object.keys(e.instanceObjs).map(i=>this.renderOneCustom(i,e.instanceObjs[i],this.customObj,t++)):null)}),this.renderErrorMessage(),this.renderConfirmationDialog()]})}}const lw=Wn()(Ls),{loadShare:uw}=ew,{initPromise:hw}=tw,cw=hw.then(r=>uw("date-fns/locale",{customShareInfo:{shareConfig:{singleton:!0,strictVersion:!1,requiredVersion:"*"}}})),fw=await cw.then(r=>r());var we=fw;const Os={en:we.enUS,fr:we.fr,ru:we.ru,de:we.de,es:we.es,br:we.ptBR,nl:we.nl,it:we.it,pt:we.pt,pl:we.pl,uk:we.uk,"zh-cn":we.zhCN},rt={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden"},tableDiv:r=>({height:`calc(100% - ${parseInt(r.mixins.toolbar.minHeight,10)+8}px)`,overflow:"hidden",width:"100%"}),container:{height:"100%"},table:r=>({minWidth:960,width:"100%","& td:nth-of-type(5)":{overflow:"hidden",whiteSpace:"nowrap"},"& tr:nth-child(even)":{backgroundColor:r.palette.mode==="dark"?"#383838":"#b2b2b2"}}),row:{userSelect:"none",position:"relative","&:hover":{opacity:.7},"& td":{position:"relative"}},updatedRow:{animation:"updated 1s"},rowInterpolated:{opacity:.5},selectHistoryControl:{width:130},selectRelativeTime:{marginLeft:10,width:200},notAliveInstance:{opacity:.5},customRange:r=>({color:r.palette.primary.main}),rowSelected:r=>({backgroundColor:r.palette.secondary.main,color:r.palette.secondary.contrastText,"& td":{color:r.palette.secondary.contrastText,backgroundColor:r.palette.secondary.main}}),rowFocused:r=>({position:"absolute",pointerEvents:"none",top:0,bottom:0,left:0,right:0,m:"3px",border:`1px dotted ${r.palette.action.active}`}),grow:{flexGrow:1},msInput:{width:50,pt:"10px",ml:"5px","& label":{mt:"15px"}},cellAckTrue:r=>({color:r.palette.mode==="dark"?"#66ff7f":"#04a821"}),cellAckFalse:{color:"#FF6666"},toolbarDate:{width:124,mt:"9px","& fieldset":{display:"none"},"& input":{padding:"8px 0 0 0"},"& .MuiInputAdornment-root":{ml:0,mt:"7px"}},toolbarTime:{width:84,mt:"9px","& fieldset":{display:"none"},"& input":{padding:"8px 0 0 0"},"& .MuiInputAdornment-root":{ml:0,mt:"7px"}},toolbarTimeGrid:{position:"relative",marginLeft:8,paddingLeft:8,paddingRight:8,paddingTop:4,paddingBottom:4,border:"1px dotted #AAAAAA",borderRadius:8,display:"flex"},toolbarTimeLabel:{position:"absolute",padding:8,fontSize:"0.8rem",left:2,top:-9},noLoadingProgress:{width:"100%",height:4},colValue:{},colAck:{},colFrom:{},colLastChange:{},colTs:{}};class Es extends at.Component{adminInstance;supportedFeaturesPromises;unit;timeTimer;readSupportedFeaturesTimeout;rangeValues;rangeRef;subscribes;localStorage;constructor(t){super(t),this.localStorage=window._localStorage||window.localStorage;let e=this.localStorage.getItem("App.relativeRange")||"absolute";const i=parseInt(this.localStorage.getItem("App.absoluteStart"),10)||0,n=parseInt(this.localStorage.getItem("App.absoluteEnd"),10)||0,a=this.localStorage.getItem("App.historySelected")||"",o=parseInt(this.localStorage.getItem("App.historyLastSelected"),10)||null,s=this.localStorage.getItem("App.historyLastSelectedColumn")||null;(!i||!n)&&(!e||e==="absolute")&&(e="30"),i&&n&&(e="absolute");let l;try{l=JSON.parse(a)}catch{l=[]}this.state={start:i,end:n,values:null,relativeRange:e,selected:l,lastSelected:o,lastSelectedColumn:s,historyInstance:"",updateOpened:!1,insertOpened:!1,historyInstances:null,lcVisible:!0,ackVisible:!0,fromVisible:!0,supportedFeatures:[],ampm:!1,edit:{}},this.adminInstance=parseInt(window.location.search.slice(1),10)||0,this.supportedFeaturesPromises={},this.unit=this.props.obj.common&&this.props.obj.common.unit?` ${this.props.obj.common.unit}`:"",this.timeTimer=void 0,this.subscribes=[],this.prepareData().then(()=>this.readHistoryRange()).then(()=>{e!=="absolute"?this.setRelativeInterval(this.state.relativeRange,!0):this.readHistory()})}readSupportedFeatures(t){return t=t||this.state.historyInstance,t?this.supportedFeaturesPromises[t]instanceof Promise?this.supportedFeaturesPromises[t]:(this.supportedFeaturesPromises[t]=new Promise(e=>{this.readSupportedFeaturesTimeout&&clearTimeout(this.readSupportedFeaturesTimeout),this.readSupportedFeaturesTimeout=setTimeout(()=>{this.readSupportedFeaturesTimeout=void 0,e([])},2e3),this.props.socket.sendTo(t,"features",null).then(i=>{this.readSupportedFeaturesTimeout?(clearTimeout(this.readSupportedFeaturesTimeout),this.readSupportedFeaturesTimeout=void 0,e(i?i.supportedFeatures||[]:[])):this.setState({supportedFeatures:i?i.supportedFeatures||[]:[]})})}),this.supportedFeaturesPromises[t]):Promise.resolve([])}async componentDidMount(){await this.props.socket.subscribeState(this.props.obj._id,this.onChange)}componentWillUnmount(){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0);for(let t=0;t<this.subscribes.length;t++)this.props.socket.unsubscribeState(this.subscribes[t],this.onChange);this.subscribes=[],this.props.socket.unsubscribeState(this.props.obj._id,this.onChange)}onChange=(t,e)=>{if(t===this.props.obj._id&&e&&this.state.values&&(!this.state.values.length||this.state.values[this.state.values.length-1].ts<e.ts)){const i=[...this.state.values,e];this.setState({values:i})}else if(t.startsWith("system.adapter.")&&t.endsWith(".alive")){const i=t.substring(15,t.length-6),n=this.state.historyInstances,a=n.findIndex(o=>o.id===i);if(a!==-1&&n[a].alive!==!!(e!=null&&e.val)){const o=JSON.parse(JSON.stringify(n));o[a].alive=!!(e!=null&&e.val),this.setState({historyInstances:o},()=>{o[a].alive&&this.state.historyInstance===i&&this.readHistoryRange().then(()=>this.readHistory())})}}};async prepareData(){var o;const t=await this.getHistoryInstances(),e=await this.props.socket.getCompactSystemConfig(),i=(o=e==null?void 0:e.common)==null?void 0:o.defaultHistory;let n=this.localStorage.getItem("App.historyInstance")||"";if((!n||!t.find(s=>s.id===n&&s.alive))&&(n=i),!n||!t.find(s=>s.id===n&&s.alive)){const s=t.find(l=>l.alive);s&&(n=s.id)}!n&&t.length&&(n=i);const a=await this.readSupportedFeatures(n);await new Promise(s=>{this.setState({ampm:(e.common.dateFormat||"").includes("/"),historyInstances:t,historyInstance:n,supportedFeatures:a},()=>s())})}getHistoryInstances(){const t=[],e=[];return this.props.customsInstances.forEach(i=>{const n=this.props.objects[`system.adapter.${i}`];if(n&&n.common&&n.common.getHistory){const a={id:i,alive:!1};t.push(a),e.push(`system.adapter.${i}.alive`)}}),e.length?this.props.socket.getForeignStates(e).then(async i=>{Object.keys(i).forEach(n=>{var o;const a=t.find(s=>n.endsWith(`${s.id}.alive`));a&&(a.alive=!!((o=i[n])!=null&&o.val))}),this.subscribes=e;for(let n=0;n<e.length;n++)await this.props.socket.subscribeState(e[n],this.onChange);return t}):Promise.resolve(t)}readHistory(t,e){var i;return t=t||this.state.start,e=e||this.state.end,!this.state.historyInstance||!((i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive))?null:(this.setState({loading:!0}),this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:t,end:e,from:!0,ack:!0,q:!0,addId:!1,aggregate:"none",returnNewestEntries:!0}).then(n=>{const a=[],o=this.rangeValues;let s=!1,l=!1,u=!1;if(o&&o.length&&(!n||!n.length||o[0].ts<n[0].ts)&&(a.push(o[0]),a.push({ts:o[0].ts+1,e:!0}),console.log(`add ${new Date(o[0].ts).toISOString()}: ${o[0].val}`),!l&&o[0].ack!==void 0&&(l=!0),!u&&o[0].from&&(u=!0)),n!=null&&n.length)for(let h=0;h<n.length;h++)n[h]&&(!a.length||a[a.length-1].ts<n[h].ts)?(a.push(n[h]),n[h].from&&(n[h].from.startsWith("system.adapter.")?n[h].from=n[h].from.substring(15):n[h].from.startsWith("system.host.")&&(n[h].from=n[h].from.substring(7))),!s&&n[h].lc&&(s=!0),!l&&n[h].ack!==void 0&&(l=!0),!u&&n[h].from&&(u=!0),console.log(`add value ${new Date(n[h].ts).toISOString()}: ${n[h].val}`)):a[a.length-1].ts===n[h].ts&&a[a.length-1].val!==n[h].ts&&console.error("Strange data!");else a.push({noDataForPeriod:!0});a.length||a.push({noData:!0}),this.setState({loading:!1,values:a,lcVisible:s,fromVisible:u,ackVisible:l})}))}readHistoryRange(){var i;const t=new Date,e=new Date(2e3,0,1);return!this.state.historyInstance||!((i=this.state.historyInstances)!=null&&i.find(n=>n.id===this.state.historyInstance&&n.alive))?Promise.resolve():(this.setState({loading:!0}),this.props.socket.getHistory(this.props.obj._id,{instance:this.state.historyInstance,start:e.getTime(),end:t.getTime(),limit:1,from:!1,ack:!1,q:!1,addId:!1,aggregate:"none"}).then(n=>{n.length?((n[0].val===null||n[0].ts===e.getTime())&&n.shift(),n.forEach(a=>a.i=!0),this.rangeValues=n,this.setState({loading:!1})):(this.rangeValues=[],this.setState({loading:!1}))}))}onToggleSelect(t,e,i){let n=[...this.state.selected];const a=n.indexOf(e);if(t.shiftKey&&this.state.lastSelected){let o=-1,s=-1;n=[];for(let l=0;l<this.state.values.length&&!(this.state.values[l].ts===e&&(o=l,s!==o&&n.push(this.state.values[l].ts),o!==-1&&s!==-1)||this.state.values[l].ts===this.state.lastSelected&&(s=l,s!==o&&n.push(this.state.values[l].ts),o!==-1&&s!==-1));l++)(o!==-1||s!==-1)&&n.push(this.state.values[l].ts)}else t.ctrlKey?(a!==-1?n.splice(a,1):n.push(e),n.sort()):n=[e];this.localStorage.setItem("App.historyLastSelected",e.toString()),this.localStorage.setItem("App.historyLastSelectedColumn",i),this.localStorage.setItem("App.historySelected",JSON.stringify(n)),this.setState({selected:n,lastSelected:e,lastSelectedColumn:i})}getTableRows(){const t=[];for(let e=this.state.values.length-1;e>=0;e--){const i=this.state.values[e],n=i.ts;if(i.e)t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...rt.rowInterpolated},hover:!0,children:[y.jsx(w.TableCell,{}),y.jsx(w.TableCell,{children:"..."}),this.state.ackVisible?y.jsx(w.TableCell,{}):null,this.state.fromVisible?y.jsx(w.TableCell,{}):null,this.state.lcVisible?y.jsx(w.TableCell,{}):null]},n));else if(i.noData||i.noDataForPeriod)t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...rt.rowNoData},hover:!0,children:[y.jsx(w.TableCell,{}),y.jsx(w.TableCell,{children:i.noData?this.props.t("No data in history"):this.props.t("No data in history for selected period")}),this.state.ackVisible?y.jsx(w.TableCell,{}):null,this.state.fromVisible?y.jsx(w.TableCell,{}):null,this.state.lcVisible?y.jsx(w.TableCell,{}):null]},i.noData?"nodata":""));else{const a=i.i,o=this.state.lastSelected===n;let s=i.val;this.props.isFloatComma&&this.props.obj.common.type==="number"&&s&&(s=s.toString().replace(".",",")),s===null&&(s="null"),s===void 0&&(s="_");const l=this.state.selected.includes(n);t.push(y.jsxs(w.TableRow,{sx:{...rt.row,...rt.updatedRow,...a?rt.rowInterpolated:void 0,...l?rt.rowSelected:void 0},children:[y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"ts"),children:[`${Es.formatTimestamp(i.ts)}`,o&&this.state.lastSelectedColumn==="ts"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}),y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"val"),children:[s+this.unit,o&&this.state.lastSelectedColumn==="val"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}),this.state.ackVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"ack"),sx:i.ack?rt.cellAckTrue:rt.cellAckFalse,children:[i.ack?"true":"false",o&&this.state.lastSelectedColumn==="ack"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null,this.state.fromVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"from"),children:[i.from||"",o&&this.state.lastSelectedColumn==="from"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null,this.state.lcVisible?y.jsxs(w.TableCell,{onClick:u=>!a&&this.onToggleSelect(u,n,"lc"),children:[i.lc?`${new Date(i.lc).toLocaleDateString()} ${new Date(i.lc).toLocaleTimeString()}.${(i.ts%1e3).toString().padStart(3,"0")}`:"",o&&this.state.lastSelectedColumn==="lc"?y.jsx(w.Box,{component:"div",sx:rt.rowFocused}):""]}):null]},n.toString()+(i.val||"").toString()))}}return t}shiftTime(){const t=new Date,e=6e4-t.getSeconds()-(1e3-t.getMilliseconds());t.getMilliseconds()&&t.setMilliseconds(1e3),t.getSeconds()&&t.setSeconds(60);const i=t.getTime();let n;const a=this.state.relativeRange;if(a==="day")t.setHours(0),t.setMinutes(0),t.setSeconds(0),n=t.getTime();else if(a==="week"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else if(a==="2weeks"){t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(t.getDate()-7);const o=t.getDay()||7;o!==1&&t.setHours(-24*(o-1)),n=t.getTime()}else a==="month"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),n=t.getTime()):a==="year"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setDate(1),t.setMonth(0),n=t.getTime()):a==="12months"?(t.setHours(0),t.setMinutes(0),t.setSeconds(0),t.setFullYear(t.getFullYear()-1),n=t.getTime()):n=i-parseInt(a,10)*6e4;this.setState({start:n,end:i},()=>this.readHistory()),this.timeTimer=setTimeout(()=>{this.timeTimer=void 0,this.shiftTime()},e||6e4)}setRelativeInterval(t,e){if(e||(this.localStorage.setItem("App.relativeRange",t.toString()),this.setState({relativeRange:t})),t==="absolute"){this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0);return}this.localStorage.removeItem("App.absoluteStart"),this.localStorage.removeItem("App.absolute");const i=new Date;if(!this.timeTimer){const o=6e4-i.getSeconds()-(1e3-i.getMilliseconds());this.timeTimer=setTimeout(()=>{this.timeTimer=void 0,this.shiftTime()},o||6e4)}i.getMilliseconds()&&i.setMilliseconds(1e3),i.getSeconds()&&i.setSeconds(60);const n=i.getTime();let a;if(t==="day")i.setHours(0),i.setMinutes(0),i.setSeconds(0),a=i.getTime();else if(t==="week"){i.setHours(0),i.setMinutes(0),i.setSeconds(0);const o=i.getDay()||7;o!==1&&i.setHours(-24*(o-1)),a=i.getTime()}else if(t==="2weeks"){i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(i.getDate()-7);const o=i.getDay()||7;o!==1&&i.setHours(-24*(o-1)),a=i.getTime()}else t==="month"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(1),a=i.getTime()):t==="year"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setDate(1),i.setMonth(0),a=i.getTime()):t==="12months"?(i.setHours(0),i.setMinutes(0),i.setSeconds(0),i.setFullYear(i.getFullYear()-1),a=i.getTime()):(t=Number(t),a=n-t*6e4);this.setState({start:a,end:n},()=>this.readHistory())}renderTable(){var t;if(!this.state.historyInstance)return y.jsx("div",{style:{marginTop:20,fontSize:24},children:this.props.t("History instance not selected")});if(!((t=this.state.historyInstances)!=null&&t.find(e=>e.id===this.state.historyInstance&&e.alive)))return y.jsx("div",{style:{marginTop:20,fontSize:24},children:this.props.t("History instance not alive")});if(this.state.values){const e=[200,"auto"],i=[190,100];return this.state.ackVisible&&(e.push(50),i.push(50)),this.state.fromVisible&&(e.push(150),i.push(150)),this.state.lcVisible&&(e.push(200),i.push(190)),y.jsx(w.TableContainer,{style:rt.container,children:y.jsxs(Yx,{stickyHeader:!0,sx:rt.table,initialWidths:e,minWidths:i,dblTitle:this.props.t("ra_Double click to reset table layout"),children:[y.jsx(w.TableHead,{children:y.jsxs(w.TableRow,{children:[y.jsx(w.TableCell,{style:rt.colTs,children:this.props.t("Timestamp")}),y.jsx(w.TableCell,{style:rt.colValue,children:this.props.t("Value")}),this.state.ackVisible?y.jsx(w.TableCell,{style:rt.colAck,children:this.props.t("Ack")}):null,this.state.fromVisible?y.jsx(w.TableCell,{style:rt.colFrom,children:this.props.t("From")}):null,this.state.lcVisible?y.jsx(w.TableCell,{style:rt.colLastChange,children:this.props.t("lc")}):null]})}),y.jsx(w.TableBody,{children:this.getTableRows()})]})})}return y.jsx(w.LinearProgress,{})}renderDialogConfirm(){return y.jsxs(w.Dialog,{open:!!this.state.areYouSure,onClose:()=>this.setState({areYouSure:!1}),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[y.jsx(w.DialogTitle,{id:"alert-dialog-title"}),y.jsxs(w.DialogContent,{children:[y.jsx(w.DialogContentText,{id:"alert-dialog-description",children:this.props.t("Are you sure?")}),y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{value:this.state.suppressMessage,onChange:()=>this.setState({suppressMessage:!0})}),label:this.props.t("Suppress for 5 minutes")})]}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({areYouSure:!1,suppressMessage:this.state.suppressMessage&&Date.now()},()=>this.onDelete()),color:"primary",autoFocus:!0,startIcon:y.jsx(X.Delete,{}),children:this.props.t("Delete")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({areYouSure:!1}),color:"secondary",startIcon:y.jsx(X.Close,{}),children:this.props.t("Cancel")})]})]})}onDelete(){const t=this.state.selected.map(e=>({state:{ts:e},id:this.props.obj._id}));this.props.socket.sendTo(this.state.historyInstance,"delete",t).then(()=>this.readHistory())}onUpdate(){let t=this.state.edit.val;this.props.obj.common&&(this.props.obj.common.type==="number"?typeof t!="number"&&(t=parseFloat(t.toString().replace(",","."))):this.props.obj.common.type==="boolean"&&(t=t==="true"||t==="TRUE"||t===!0||t==="1"||t===1));const e={val:t,ack:this.state.edit.ack,ts:this.state.selected[0],from:`system.adapter.admin.${this.adminInstance}`,q:this.state.edit.q};for(const[i,n]of Object.entries(e))n===void 0&&delete e[i];!this.state.lcVisible&&e.lc&&delete e.lc,this.props.socket.sendTo(this.state.historyInstance,"update",[{id:this.props.obj._id,state:e}]).then(()=>this.readHistory())}onInsert(){let t=this.state.edit.val;this.props.obj.common&&(this.props.obj.common.type==="number"?t=parseFloat(t.toString().replace(",",".")):this.props.obj.common.type==="boolean"&&(t=t==="true"||t==="TRUE"||t===!0||t==="1"||t===1));const e=this.state.edit.date;e.setHours(this.state.edit.time.getHours()),e.setMinutes(this.state.edit.time.getMinutes()),e.setSeconds(this.state.edit.time.getSeconds()),e.setMilliseconds(parseInt(this.state.edit.ms,10));const i={ts:e.getTime(),val:t,ack:this.state.edit.ack,from:`system.adapter.admin.${this.adminInstance}`,q:this.state.edit.q||0};!this.state.lcVisible&&i.lc&&delete i.lc;for(const[n,a]of Object.entries(i))a===void 0&&delete i[n];this.props.socket.sendTo(this.state.historyInstance,"insert",[{id:this.props.obj._id,state:i}]).then(()=>this.readHistory())}updateEdit(t,e){const i=JSON.parse(JSON.stringify(this.state.edit));i.time=new Date(i.time),i.date=new Date(i.date),i[t]=e,this.setState({edit:i})}renderEditDialog(){return y.jsxs(w.Dialog,{open:this.state.updateOpened||this.state.insertOpened,onClose:()=>this.setState({updateOpened:!1,insertOpened:!1}),"aria-labelledby":"edit-dialog-title","aria-describedby":"edit-dialog-description",children:[y.jsx(w.DialogTitle,{id:"edit-dialog-title",children:this.state.updateOpened?this.props.t("Update entry"):this.props.t("Insert entry")}),y.jsx(w.DialogContent,{children:y.jsxs("form",{noValidate:!0,autoComplete:"off",children:[typeof this.state.edit.val=="boolean"?y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.edit.val,onChange:t=>this.updateEdit("val",t.target.checked)}),label:this.props.t("Value")}):y.jsx(w.TextField,{variant:"standard",label:this.props.t("Value"),value:this.state.edit.val,onChange:t=>this.updateEdit("val",t.target.value)}),y.jsx("br",{}),y.jsx(w.FormControlLabel,{control:y.jsx(w.Checkbox,{checked:this.state.edit.ack,onChange:t=>this.updateEdit("ack",t.target.checked)}),label:this.props.t("Acknowledged")}),this.state.insertOpened?y.jsx(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:rt.toolbarTimeLabel,children:this.props.t("Time")}),y.jsx(qt.DatePicker,{sx:rt.toolbarDate,value:this.state.edit.date,onChange:t=>this.updateEdit("date",t)}),y.jsx(qt.TimePicker,{sx:rt.toolbarTime,ampm:this.state.ampm,views:["hours","minutes","seconds"],value:this.state.edit.time,onChange:t=>this.updateEdit("time",t)}),y.jsx(w.TextField,{variant:"standard",sx:rt.msInput,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{max:999,min:0}},value:this.state.edit.ms,onChange:t=>this.updateEdit("ms",t.target.value)})]})}):null]})}),y.jsxs(w.DialogActions,{children:[y.jsx(w.Button,{variant:"contained",disabled:this.state.edit.val==="",onClick:()=>{const t=this.state.updateOpened;this.setState({updateOpened:!1,insertOpened:!1},()=>t?this.onUpdate():this.onInsert())},color:"primary",autoFocus:!0,children:this.state.updateOpened?this.props.t("Update"):this.props.t("Add")}),y.jsx(w.Button,{variant:"contained",onClick:()=>this.setState({updateOpened:!1,insertOpened:!1}),color:"grey",children:this.props.t("Cancel")})]})]})}setStartDate(t){const e=t.getTime();this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0),this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",e.toString()),this.localStorage.setItem("App.absoluteEnd",this.state.end.toString()),this.setState({start:e,relativeRange:"absolute"},()=>this.readHistory())}setEndDate(t){const e=t.getTime();this.localStorage.setItem("App.relativeRange","absolute"),this.localStorage.setItem("App.absoluteStart",this.state.start.toString()),this.localStorage.setItem("App.absoluteEnd",e.toString()),this.timeTimer&&(clearTimeout(this.timeTimer),this.timeTimer=void 0),this.setState({end:e,relativeRange:"absolute"},()=>this.readHistory())}renderToolbar(){var t,e;return y.jsxs(w.Toolbar,{children:[y.jsxs(w.FormControl,{variant:"standard",style:rt.selectHistoryControl,children:[y.jsx(w.InputLabel,{children:this.props.t("History instance")}),y.jsx(w.Select,{variant:"standard",value:this.state.historyInstance||"",onChange:i=>{const n=i.target.value;this.localStorage.setItem("App.historyInstance",n),this.readSupportedFeatures(n).then(a=>this.setState({historyInstance:n,supportedFeatures:a},()=>this.readHistory()))},children:(t=this.state.historyInstances)==null?void 0:t.map(i=>y.jsx(w.MenuItem,{value:i.id,style:i.alive?void 0:rt.notAliveInstance,children:i.id},i.id))})]}),y.jsxs(w.FormControl,{variant:"standard",style:rt.selectRelativeTime,children:[y.jsx(w.InputLabel,{children:this.props.t("Relative")}),y.jsxs(w.Select,{variant:"standard",ref:this.rangeRef,value:this.state.relativeRange,onChange:i=>this.setRelativeInterval(i.target.value),children:[y.jsx(w.MenuItem,{value:"absolute",sx:rt.customRange,children:this.props.t("custom range")},"custom"),y.jsx(w.MenuItem,{value:10,children:this.props.t("last 10 minutes")},"1"),y.jsx(w.MenuItem,{value:30,children:this.props.t("last 30 minutes")},"2"),y.jsx(w.MenuItem,{value:60,children:this.props.t("last hour")},"3"),y.jsx(w.MenuItem,{value:"day",children:this.props.t("this day")},"4"),y.jsx(w.MenuItem,{value:24*60,children:this.props.t("last 24 hours")},"5"),y.jsx(w.MenuItem,{value:"week",children:this.props.t("this week")},"6"),y.jsx(w.MenuItem,{value:24*60*7,children:this.props.t("last week")},"7"),y.jsx(w.MenuItem,{value:"2weeks",children:this.props.t("this 2 weeks")},"8"),y.jsx(w.MenuItem,{value:24*60*14,children:this.props.t("last 2 weeks")},"9"),y.jsx(w.MenuItem,{value:"month",children:this.props.t("this month")},"10"),y.jsx(w.MenuItem,{value:30*24*60,children:this.props.t("last 30 days")},"11"),y.jsx(w.MenuItem,{value:"year",children:this.props.t("this year")},"12"),y.jsx(w.MenuItem,{value:"12months",children:this.props.t("last 12 months")},"13")]})]}),y.jsxs(qt.LocalizationProvider,{dateAdapter:ks,adapterLocale:Os[this.props.lang],children:[y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:{...rt.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("Start time")}),y.jsx(qt.DatePicker,{sx:rt.toolbarDate,disabled:this.state.relativeRange!=="absolute",value:new Date(this.state.start),onChange:i=>this.setStartDate(i)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.start),onChange:i=>this.setStartDate(i)})]}),y.jsxs("div",{style:rt.toolbarTimeGrid,children:[y.jsx("div",{style:{...rt.toolbarTimeLabel,opacity:this.state.relativeRange!=="absolute"?.5:void 0},children:this.props.t("End time")}),y.jsx(qt.DatePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarDate,value:new Date(this.state.end),onChange:i=>this.setEndDate(i)}),y.jsx(qt.TimePicker,{disabled:this.state.relativeRange!=="absolute",sx:rt.toolbarTime,ampm:this.state.ampm,value:new Date(this.state.end),onChange:i=>this.setEndDate(i)})]})]}),y.jsx(w.Box,{component:"div",sx:rt.grow}),(e=this.state.values)!=null&&e.length?y.jsx(w.IconButton,{size:"large",onClick:()=>this.exportData(),title:this.props.t("Save data as csv"),children:y.jsx(rw,{})}):null,this.state.supportedFeatures.includes("insert")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",onClick:()=>{const i=new Date,n={ack:this.state.values[this.state.values.length-1].ack,val:this.state.values[this.state.values.length-1].val,date:new Date(i),ms:0,time:new Date(i),q:0};this.setState({edit:n,insertOpened:!0})},children:y.jsx(iw,{})}):null,this.state.supportedFeatures.includes("update")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",disabled:this.state.selected.length!==1,onClick:()=>{const i=JSON.parse(JSON.stringify(this.state.values.find(a=>a.ts===this.state.lastSelected))),n=new Date(i.ts);i.date=new Date(n),i.time=new Date(n),this.setState({edit:i,updateOpened:!0})},children:y.jsx(X.Edit,{})}):null,this.state.supportedFeatures.includes("delete")&&this.props.expertMode?y.jsx(w.IconButton,{size:"large",disabled:!this.state.selected.length,onClick:()=>{typeof this.state.suppressMessage=="number"&&Date.now()-this.state.suppressMessage<3e5?this.onDelete():this.setState({areYouSure:!0})},children:y.jsx(X.Delete,{})}):null]})}exportData(){let t=window.document.getElementById("export-file");t||(t=document.createElement("a"),t.setAttribute("id","export-file"),t.style.display="none",document.body.appendChild(t));const e=["timestamp;value;acknowledged;from;"];this.state.values.forEach(i=>!i.i&&!i.e&&e.push([Es.formatTimestamp(i.ts),i.val===null||i.val===void 0?"null":i.val.toString(),i.ack?"true":"false",i.from||""].join(";"))),t.setAttribute("href",`data:text/plain;charset=utf-8,${encodeURIComponent(e.join(`
|
|
2
2
|
`))}`),t.setAttribute("download",`${jt.getObjectName({[this.props.obj._id]:this.props.obj},this.props.obj._id,this.props.lang)}.csv`),t.click(),document.body.removeChild(t)}render(){return this.state.historyInstances?y.jsxs(w.Paper,{style:rt.paper,children:[this.state.loading?y.jsx(w.LinearProgress,{}):y.jsx("div",{style:rt.noLoadingProgress}),this.renderToolbar(),y.jsx(w.Box,{component:"div",sx:rt.tableDiv,children:this.renderTable()}),this.renderDialogConfirm(),this.renderEditDialog()]}):y.jsx(w.LinearProgress,{})}static formatTimestamp(t){return`${new Date(t).toLocaleDateString()} ${new Date(t).toLocaleTimeString()}.${(t%1e3).toString().padStart(3,"0")}`}}const dw=Wn()(Es);var ry={};/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,E as i,J as o}from"./DefaultPropsProvider-
|
|
1
|
+
import{j as e,E as i,J as o}from"./DefaultPropsProvider-BrbE0teb.js";import{i as r,a as _}from"./bootstrap-FVlt-hkS.js";const a={checkIcon:{color:i[700]},cancelIcon:{color:o[700]},wrapperContent:{display:"flex",flexFlow:"nowrap",alignItems:"inherit"}};function l(n){return e.jsxs(r.Grid2,{container:!0,style:a.wrapperContent,alignItems:"center",direction:"row",spacing:1,children:[e.jsx(r.Grid2,{children:n.state?e.jsx(_.CheckCircle,{style:a.checkIcon}):e.jsx(_.Cancel,{style:a.cancelIcon})}),e.jsx(r.Grid2,{children:e.jsx(r.Typography,{children:n.children})})]})}export{l as S};
|