iobroker.admin 7.4.1 → 7.4.2

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.
Files changed (29) hide show
  1. package/README.md +5 -5
  2. package/admin/i18n/de/translations.json +1 -1
  3. package/adminWww/asset-manifest.json +13 -13
  4. package/adminWww/index.html +1 -1
  5. package/adminWww/static/js/288.7aa5c1cd.chunk.js +2 -0
  6. package/adminWww/static/js/288.7aa5c1cd.chunk.js.map +1 -0
  7. package/adminWww/static/js/4720.4d2f2008.chunk.js +2 -0
  8. package/adminWww/static/js/4720.4d2f2008.chunk.js.map +1 -0
  9. package/adminWww/static/js/6853.d4463ea5.chunk.js +2 -0
  10. package/adminWww/static/js/6853.d4463ea5.chunk.js.map +1 -0
  11. package/adminWww/static/js/{7137.59c61794.chunk.js → 7137.3d55bb2a.chunk.js} +2 -2
  12. package/adminWww/static/js/7137.3d55bb2a.chunk.js.map +1 -0
  13. package/adminWww/static/js/7424.25b03f3d.chunk.js +2 -0
  14. package/adminWww/static/js/7424.25b03f3d.chunk.js.map +1 -0
  15. package/adminWww/static/js/main.d9df93d8.js +2 -0
  16. package/adminWww/static/js/main.d9df93d8.js.map +1 -0
  17. package/io-package.json +222 -37
  18. package/package.json +4 -4
  19. package/adminWww/static/js/288.8fd137b7.chunk.js +0 -2
  20. package/adminWww/static/js/288.8fd137b7.chunk.js.map +0 -1
  21. package/adminWww/static/js/4720.f547d551.chunk.js +0 -2
  22. package/adminWww/static/js/4720.f547d551.chunk.js.map +0 -1
  23. package/adminWww/static/js/591.675e66af.chunk.js +0 -2
  24. package/adminWww/static/js/591.675e66af.chunk.js.map +0 -1
  25. package/adminWww/static/js/6853.be661c6e.chunk.js +0 -2
  26. package/adminWww/static/js/6853.be661c6e.chunk.js.map +0 -1
  27. package/adminWww/static/js/7137.59c61794.chunk.js.map +0 -1
  28. package/adminWww/static/js/main.d185596b.js +0 -2
  29. package/adminWww/static/js/main.d185596b.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";(self.webpackChunksrc_rx=self.webpackChunksrc_rx||[]).push([[4720],{84720:(e,t,s)=>{s.r(t),s.d(t,{default:()=>R});var o=s(29183),i=s(89303),n=s(32075),r=s(16904),l=s(79159);function a(e){const{tooltip:t,label:s,disabled:o,Icon:n,onClick:r}=e,a=!!s&&(0,l.jsx)(i.Typography,{variant:"button",style:{marginLeft:4},children:s});return t?(0,l.jsx)(i.Tooltip,{title:t,slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,l.jsx)("span",{children:(0,l.jsxs)(i.IconButton,{onClick:r,disabled:o,size:"small",children:[n,a]})})}):(0,l.jsxs)(i.IconButton,{onClick:r,disabled:o,size:"small",children:[n,a]})}function c(e,t){const s=e.split(" ").map((e=>e.trim())).filter((e=>"fa-solid"!==e));return s.includes("fa-trash-can")||s.includes("fa-trash")?(0,l.jsx)(n.Delete,{style:{color:t}}):s.includes("fa-pen")?(0,l.jsx)(n.Edit,{style:{color:t}}):s.includes("fa-redo-alt")?(0,l.jsx)(n.Refresh,{style:{color:t}}):s.includes("fa-plus")?(0,l.jsx)(n.Add,{style:{color:t}}):s.includes("fa-qrcode")||s.includes("qrcode")?(0,l.jsx)(n.QrCode,{style:{color:t}}):s.includes("fa-wifi")?(0,l.jsx)(n.Wifi,{style:{color:t}}):s.includes("fa-wifi-slash")?(0,l.jsx)(n.WifiOff,{style:{color:t}}):s.includes("fa-bluetooth")?(0,l.jsx)(n.Bluetooth,{style:{color:t}}):s.includes("fa-bluetooth-slash")?(0,l.jsx)(n.BluetoothDisabled,{style:{color:t}}):s.includes("fa-eye")?(0,l.jsx)(n.Visibility,{style:{color:t}}):s.includes("fa-search")?(0,l.jsx)(n.Search,{style:{color:t}}):s.includes("fa-unlink")?(0,l.jsx)(n.LinkOff,{style:{color:t}}):s.includes("fa-link")?(0,l.jsx)(n.Link,{style:{color:t}}):s.includes("fa-search-location")?(0,l.jsx)(n.NotListedLocation,{style:{color:t}}):s.includes("fa-play")?(0,l.jsx)(n.PlayArrow,{style:{color:t}}):s.includes("fa-stop")?(0,l.jsx)(n.Stop,{style:{color:t}}):s.includes("fa-pause")?(0,l.jsx)(n.Pause,{style:{color:t}}):(0,l.jsx)(n.QuestionMark,{style:{color:t}})}function d(e,t,s){return"edit"===e||"rename"===e||"edit"===t||"rename"===t?(0,l.jsx)(n.Edit,{style:{color:s}}):"delete"===e||"delete"===t?(0,l.jsx)(n.Delete,{style:{color:s}}):"refresh"===e||"refresh"===t?(0,l.jsx)(n.Refresh,{style:{color:s}}):"newDevice"===e||"new"===e||"add"===e||"newDevice"===t||"new"===t||"add"===t?(0,l.jsx)(n.Add,{style:{color:s}}):"discover"===e||"search"===e||"discover"===t||"search"===t?(0,l.jsx)(n.Search,{style:{color:s}}):"unpairDevice"===e||"unpair"===e||"unpairDevice"===t||"unpair"===t?(0,l.jsx)(n.LinkOff,{style:{color:s}}):"pairDevice"===e||"pair"===e||"pairDevice"===t||"pair"===t?(0,l.jsx)(n.Link,{style:{color:s}}):"identify"===e||"identify"===t?(0,l.jsx)(n.NotListedLocation,{style:{color:s}}):"play"===e||"play"===t?(0,l.jsx)(n.PlayArrow,{style:{color:s}}):"stop"===e||"stop"===t?(0,l.jsx)(n.Stop,{style:{color:s}}):"pause"===e||"pause"===t?(0,l.jsx)(n.Pause,{style:{color:s}}):"forward"===e||"next"===e||"forward"===t||"next"===t?(0,l.jsx)(n.FastForward,{style:{color:s}}):"rewind"===e||"previous"===e||"rewind"===t||"previous"===t?(0,l.jsx)(n.FastRewind,{style:{color:s}}):"lamp"===e||"light"===e||"lamp"===t||"light"===t?(0,l.jsx)(n.Lightbulb,{style:{color:s}}):"backlight"===e||"backlight"===t?(0,l.jsx)(n.Fluorescent,{style:{color:s}}):"dimmer"===e||"dimmer"===t?(0,l.jsx)(n.WbIncandescent,{style:{color:s}}):"socket"===e||"socket"===t?(0,l.jsx)(n.Power,{style:{color:s}}):"settings"===e||"settings"===t?(0,l.jsx)(n.Settings,{style:{color:s}}):"users"===e||"group"===e||"users"===t||"group"===t?(0,l.jsx)(n.Group,{style:{color:s}}):"user"===e||"user"===t?(0,l.jsx)(n.Person,{style:{color:s}}):"qrcode"===e||"qrcode"===t?(0,l.jsx)(n.QrCode,{style:{color:s}}):"identify"===e||"identify"===t?(0,l.jsx)(n.WifiFind,{style:{color:s}}):"info"===e||"info"===t?(0,l.jsx)(n.Info,{style:{color:s}}):"lines"===e||"lines"===t?(0,l.jsx)(n.Article,{style:{color:s}}):(0,l.jsx)(n.QuestionMark,{style:{color:s}})}function p(e,t,s){var o,i,n,a;if(!e)return null;let p=s&&e.colorOn||e.color||(e.state?"primary":"inherit");return t&&("primary"===p?p=t.primary:"secondary"===p&&(p=t.secondary)),null!==(o=e.icon)&&void 0!==o&&o.startsWith("fa-")||null!==(i=e.icon)&&void 0!==i&&i.startsWith("fas")?c(e.icon,p):s&&null!==(n=e.iconOn)&&void 0!==n&&n.startsWith("data:image")?(0,l.jsx)(r.Icon,{src:e.iconOn,style:{color:p}}):null!==(a=e.icon)&&void 0!==a&&a.startsWith("data:image")?(0,l.jsx)(r.Icon,{src:e.icon,style:{color:p}}):d(e.id,e.icon,p)}function h(e){var t,s,o;return e?null!==(t=e.icon)&&void 0!==t&&t.startsWith("fa-")||null!==(s=e.icon)&&void 0!==s&&s.startsWith("fas")?c(e.icon,e.color):null!==(o=e.icon)&&void 0!==o&&o.startsWith("data:image")?(0,l.jsx)(r.Icon,{src:e.icon,style:{color:e.color}}):d(e.id,e.icon,e.color):null}let u;function v(e,t){return u=u||r.I18n.getLanguage(),"object"===typeof e?e[u]||e.en:t?e:r.I18n.t(e)}function m(e){var t;const{deviceId:s,action:o,refresh:i,deviceHandler:n,disabled:r}=e,c=h(o),d=v(null!==(t=o.description)&&void 0!==t?t:"")||(c?null:o.id);return(0,l.jsx)(a,{tooltip:d||void 0,disabled:r||o.disabled,Icon:c,onClick:n(s,o,i)})}class x extends o.Component{constructor(e){var t,s;super(e),this.stateHandler=async(e,t)=>{if(e===this.props.control.stateId&&t){const e=await this.props.controlStateHandler(this.props.deviceId,this.props.control)();null!==e&&void 0!==e&&e.ts&&(!this.state.ts||e.ts>this.state.ts)&&this.setState({value:e.val,ts:e.ts})}},this.state={value:null===(t=e.control.state)||void 0===t?void 0:t.val,ts:null===(s=e.control.state)||void 0===s?void 0:s.ts}}async componentDidMount(){if(this.props.control.stateId){const e=this.props.socket.subscribeState(this.props.control.stateId,this.stateHandler);e instanceof Promise&&await e}}componentWillUnmount(){this.props.control.stateId&&this.props.socket.unsubscribeState(this.props.control.stateId,this.stateHandler)}static getDerivedStateFromProps(e,t){var s,o;return null!==(s=e.control.state)&&void 0!==s&&s.ts&&(!t.ts||(null===(o=e.control.state)||void 0===o?void 0:o.ts)>t.ts)?{value:e.control.state.val,ts:e.control.state.ts}:null}async sendControl(e,t,s){const o=await this.props.controlHandler(e,t,s)();null!==o&&void 0!==o&&o.ts&&(!this.state.ts||(null===o||void 0===o?void 0:o.ts)>this.state.ts)&&this.setState({value:o.val,ts:o.ts})}renderButton(){var e;const t=v(null!==(e=this.props.control.description)&&void 0!==e?e:""),s=p(this.props.control,this.props.colors,this.state.value);return this.props.control.label?(0,l.jsx)(i.Button,{disabled:this.props.disabled,title:t,onClick:()=>this.sendControl(this.props.deviceId,this.props.control,!0),startIcon:s,children:v(this.props.control.label)}):(0,l.jsx)(i.Fab,{size:"small",disabled:this.props.disabled,title:t,onClick:()=>this.sendControl(this.props.deviceId,this.props.control,!0),children:s})}renderSwitch(){var e;const t=v(null!==(e=this.props.control.description)&&void 0!==e?e:"");return(0,l.jsx)(i.Switch,{disabled:this.props.disabled,title:t,checked:!!this.state.value,onChange:e=>this.sendControl(this.props.deviceId,this.props.control,e.target.checked)})}getColor(){let e;return this.state.value?e=this.props.control.colorOn||"primary":"switch"===this.props.control.type&&(e=this.props.control.color),"primary"===e?this.props.colors.primary:"secondary"===e?this.props.colors.secondary:e}renderSelect(){return null}renderSlider(){return null}renderColor(){return null}renderIcon(){var e;const t=v(null!==(e=this.props.control.description)&&void 0!==e?e:""),s=p(this.props.control,this.props.colors,this.state.value),o=this.getColor(),n=o===this.props.colors.primary||o===this.props.colors.secondary?{}:{color:o},r=o===this.props.colors.primary?"primary":o===this.props.colors.secondary?"secondary":void 0;return this.props.control.label?(0,l.jsx)(i.Button,{disabled:this.props.disabled,title:t,color:r,style:n,onClick:()=>this.sendControl(this.props.deviceId,this.props.control,!this.state.value),startIcon:s,children:v(this.props.control.label)}):(n.width=34,n.height=34,n.minHeight=34,(0,l.jsx)(i.Fab,{disabled:this.props.disabled,size:"small",title:t,color:r,style:n,onClick:()=>this.sendControl(this.props.deviceId,this.props.control,!this.state.value),children:s}))}render(){return"button"===this.props.control.type?this.renderButton():"icon"===this.props.control.type?this.renderIcon():"switch"===this.props.control.type?this.renderSwitch():(0,l.jsx)("div",{style:{color:"red"},children:this.props.control.type})}}const f={tooltip:{pointerEvents:"none"}};function g(e){if(!e.status)return null;let t;t="string"===typeof e.status?{connection:e.status}:e.status;const s={fill:"#00ac00"},o={fill:"#ff0000"},r={fill:"#ff9900"};let a=null;return"number"===typeof t.battery&&(a=t.battery>=96&&t.battery<=100?(0,l.jsx)(n.BatteryFull,{style:s}):t.battery>=90&&t.battery<=95?(0,l.jsx)(n.Battery90,{style:s}):t.battery>=80&&t.battery<=89?(0,l.jsx)(n.Battery80,{style:s}):t.battery>=60&&t.battery<=79?(0,l.jsx)(n.Battery60,{style:s}):t.battery>=50&&t.battery<=59?(0,l.jsx)(n.Battery50,{style:s}):t.battery>=30&&t.battery<=49?(0,l.jsx)(n.Battery30,{style:s}):t.battery>=20&&t.battery<=29?(0,l.jsx)(n.Battery20,{style:o}):(0,l.jsx)(n.BatteryAlert,{style:o})),(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:["connected"===t.connection&&(0,l.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,l.jsx)(i.Tooltip,{title:v("connectedIconTooltip"),slotProps:{popper:{sx:f.tooltip}},children:(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:(0,l.jsx)(n.Link,{style:s})})})}),"disconnected"===t.connection&&(0,l.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,l.jsx)(i.Tooltip,{title:v("disconnectedIconTooltip"),slotProps:{popper:{sx:f.tooltip}},children:(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:(0,l.jsx)(n.LinkOff,{style:o})})})}),t.rssi&&(0,l.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,l.jsx)(i.Tooltip,{title:"RSSI",slotProps:{popper:{sx:f.tooltip}},children:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[(0,l.jsx)(n.NetworkCheck,{}),(0,l.jsx)("p",{style:{fontSize:"small",margin:0},children:t.rssi})]})})}),"number"===typeof t.battery&&(0,l.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,l.jsx)(i.Tooltip,{title:v("batteryTooltip"),slotProps:{popper:{sx:f.tooltip}},children:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[a,(0,l.jsxs)("p",{style:{fontSize:"small",margin:0},children:[t.battery,"%"]})]})})}),"string"===typeof t.battery&&(0,l.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,l.jsx)(i.Tooltip,{title:v("batteryTooltip"),slotProps:{popper:{sx:f.tooltip}},children:(0,l.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:["charging"===t.battery?(0,l.jsx)(n.BatteryCharging50,{}):(0,l.jsx)(n.BatteryFull,{}),"charging"!==t.battery?t.battery.includes("V")||t.battery.includes("mV")?(0,l.jsx)("p",{style:{fontSize:"small",margin:0},children:t.battery}):(0,l.jsxs)("p",{style:{fontSize:"small",margin:0},children:[(0,l.jsx)("span",{style:{marginRight:4},children:t.battery}),"mV"]}):null]})})}),"boolean"===typeof t.battery&&(0,l.jsx)("div",{style:{display:"flex",alignItems:"center"},children:(0,l.jsx)(i.Tooltip,{title:v("batteryTooltip"),slotProps:{popper:{sx:f.tooltip}},children:(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:t.battery?(0,l.jsx)(n.BatteryFull,{style:s}):(0,l.jsx)(n.BatteryAlert,{style:o})})})}),t.warning&&(0,l.jsx)("div",{style:{display:"flex",alignItems:"center"},children:"string"===typeof t.warning||"object"===typeof t.warning?(0,l.jsx)(i.Tooltip,{title:v(t.warning),slotProps:{popper:{sx:f.tooltip}},children:(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:(0,l.jsx)(n.Warning,{style:r})})}):(0,l.jsx)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:(0,l.jsx)(n.Warning,{style:r})})})]})}var y=s(4531);function I(e){var t,s;const{instanceId:i,socket:n,schema:r,data:a,onChange:c}=e,[d,p]=(0,o.useState)(!1);if(void 0===r)return null;const[h,u]=i.split(".",2);return(0,l.jsxs)(l.Fragment,{children:[d&&(0,l.jsx)("div",{children:d}),(0,l.jsx)(y.JsonConfigComponent,{socket:n,adapterName:h,instance:parseInt(u,10),schema:r,data:a,onError:p,onChange:e=>c(e),embedded:!0,themeName:e.themeName,themeType:e.themeType,theme:e.theme,isFloatComma:void 0===e.isFloatComma?!(null===(t=e.socket.systemConfig)||void 0===t||!t.common.isFloatComma):e.isFloatComma,dateFormat:void 0===e.dateFormat?null===(s=e.socket.systemConfig)||void 0===s?void 0:s.common.dateFormat:e.dateFormat})]})}const T=function(e){const{socket:t,manufacturer:s,model:o,deviceId:i,onImageSelect:n,uploadImagesToInstance:r}=e;return(0,l.jsx)("div",{children:(0,l.jsx)("input",{style:{opacity:0,position:"absolute",width:"45px",height:"45px",zIndex:3},type:"file",accept:"image/*",onChange:e=>{const l=e.target.files;if(!l||0===l.length)return;const a=l[0];if(a){const e=new FileReader;e.onload=e=>{if(!e.target||!e.target.result)return;const l=new Image;l.src=e.target.result,l.onload=async()=>{let e=l.width,a=l.height;e>a?e>50&&(a*=50/e,e=50):a>50&&(e*=50/a,a=50);const c=document.createElement("canvas"),d=c.getContext("2d");if(d){c.width=e,c.height=a,d.drawImage(l,0,0,e,a);const p=c.toDataURL("image/webp"),h=`${s?`${s}_`:""}${o||i}`,u=p.replace(/^data:image\/webp;base64,/,""),v=await t.writeFile64(r,h,u);console.log(`saveImage response: ${JSON.stringify(v)}`),n&&n(p)}}},e.readAsDataURL(a)}}})})};function j(e){return(0,l.jsx)("svg",{viewBox:"0 0 24 24",width:"24",height:"24",style:e.style,className:e.className,children:(0,l.jsx)("path",{fill:"currentColor",d:"M21.9,21.9l-8.49-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1,0.9,2,2,2h13.17l2.31,2.31L21.9,21.9z M5,18 l3.5-4.5l2.5,3.01L12.17,15l3,3H5z M21,18.17L5.83,3H19c1.1,0,2,0.9,2,2V18.17z"})})}function b(e){return"object"===typeof e?e[r.I18n.getLanguage()]||e.en:e}class C extends o.Component{constructor(e){super(e),this.refresh=()=>{this.setState({details:null}),this.loadDetails().catch(console.error)},this.copyToClipboard=()=>{const e=this.props.device.id;r.Utils.copyToClipboard(e),alert(`${v("copied")} ${e} ${v("toClipboard")}!`)},this.state={open:!1,details:null,data:{},icon:e.device.icon,showControlDialog:!1}}async fetchIcon(){if(!this.props.device.icon){const e=r.I18n.getLanguage(),t=this.props.device.manufacturer&&"object"===typeof this.props.device.manufacturer?this.props.device.manufacturer[e]||this.props.device.manufacturer.en:this.props.device.manufacturer,s=`${t?`${t}_`:""}${(this.props.device.model&&"object"===typeof this.props.device.model?this.props.device.model[e]||this.props.device.model.en:this.props.device.model)||this.props.device.id}`;try{const e=await this.props.socket.readFile(this.props.instanceId.replace("system.adapter.",""),`${s}.webp`,!0);e?this.setState({icon:`data:image/${e.mimeType},${e.file}`}):this.setState({icon:""})}catch{this.state.icon&&this.setState({icon:""})}}}componentDidMount(){this.fetchIcon().catch((e=>console.error(e)))}async loadDetails(){console.log(`Loading device details for ${this.props.device.id}... from ${this.props.instanceId}`);const e=await this.props.socket.sendTo(this.props.instanceId,"dm:deviceDetails",this.props.device.id);console.log(`Got device details for ${this.props.device.id}:`,e),this.setState({details:e,data:(null===e||void 0===e?void 0:e.data)||{}})}renderDialog(){return this.state.open&&this.state.details?(0,l.jsxs)(i.Dialog,{open:!0,maxWidth:"md",onClose:()=>this.setState({open:!1}),children:[(0,l.jsx)(i.DialogContent,{children:(0,l.jsx)(I,{instanceId:this.props.instanceId,socket:this.props.socket,schema:this.state.details.schema,data:this.state.data,onChange:e=>this.setState({data:e}),themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat})}),(0,l.jsx)(i.DialogActions,{children:(0,l.jsx)(i.Button,{disabled:!this.props.alive,variant:"contained",color:"primary",onClick:()=>this.setState({open:!1}),autoFocus:!0,children:v("closeButtonText")})})]}):null}renderControlDialog(){var e;if(!this.state.showControlDialog||!this.props.alive)return null;const t={primary:"#111",secondary:"#888"};return(0,l.jsxs)(i.Dialog,{open:!0,onClose:()=>this.setState({showControlDialog:!1}),children:[(0,l.jsxs)(i.DialogTitle,{children:[this.props.title,(0,l.jsx)(i.IconButton,{style:{position:"absolute",top:5,right:5,zIndex:10},onClick:()=>this.setState({showControlDialog:!1}),children:(0,l.jsx)(n.Close,{})})]}),(0,l.jsx)(i.DialogContent,{style:{display:"flex",flexDirection:"column"},children:null===(e=this.props.device.controls)||void 0===e?void 0:e.map((e=>(0,l.jsx)(x,{disabled:!1,control:e,socket:this.props.socket,colors:t,deviceId:this.props.device.id,controlHandler:this.props.controlHandler,controlStateHandler:this.props.controlStateHandler},e.id)))})]})}renderControls(){var e,t,s;const o={primary:"#111",secondary:"#888"},r=null===(e=this.props.device.controls)||void 0===e?void 0:e[0];return 1!==(null===(t=this.props.device.controls)||void 0===t?void 0:t.length)||!r||"icon"!==r.type&&"switch"!==r.type||r.label?null!==(s=this.props.device.controls)&&void 0!==s&&s.length?(0,l.jsx)(i.Fab,{size:"small",disabled:!this.props.alive,onClick:()=>this.setState({showControlDialog:!0}),children:(0,l.jsx)(n.VideogameAsset,{})}):null:(0,l.jsx)(x,{disabled:!this.props.alive,control:r,colors:o,socket:this.props.socket,deviceId:this.props.device.id,controlHandler:this.props.controlHandler,controlStateHandler:this.props.controlStateHandler})}renderActions(){var e;return null!==(e=this.props.device.actions)&&void 0!==e&&e.length?this.props.device.actions.map((e=>(0,l.jsx)(m,{disabled:!this.props.alive,deviceId:this.props.device.id,action:e,deviceHandler:this.props.deviceHandler,refresh:this.refresh},e.id))):null}renderSmall(){const e=this.props.device.hasDetails,t=this.props.device.status?Array.isArray(this.props.device.status)?this.props.device.status:[this.props.device.status]:[],s=this.state.icon?(0,l.jsx)(r.IconDeviceType,{src:this.state.icon}):(0,l.jsx)(j,{});return(0,l.jsxs)(i.Card,{sx:{maxWidth:345,minWidth:200},children:[(0,l.jsx)(i.CardHeader,{sx:e=>({backgroundColor:"primary"===this.props.device.color?e.palette.primary.main:"secondary"===e.palette.secondary.main?e.palette.secondary.main:this.props.device.color||e.palette.secondary.main,color:this.props.device.color&&"primary"!==this.props.device.color&&"secondary"!==this.props.device.color?r.Utils.invertColor(this.props.device.color,!0):e.palette.secondary.contrastText,maxWidth:345}),avatar:(0,l.jsxs)("div",{children:[this.props.uploadImagesToInstance?(0,l.jsx)(T,{uploadImagesToInstance:this.props.uploadImagesToInstance,deviceId:this.props.device.id,manufacturer:b(this.props.device.manufacturer),model:b(this.props.device.model),onImageSelect:e=>{e&&this.setState({icon:e})},socket:this.props.socket}):null,s]}),action:e?(0,l.jsx)(i.IconButton,{"aria-label":"settings",onClick:()=>{this.state.open||(this.loadDetails().catch(console.error),this.setState({open:!0}))},children:(0,l.jsx)(n.MoreVert,{})}):null,title:this.props.title,subheader:this.props.device.manufacturer?(0,l.jsxs)("span",{children:[(0,l.jsxs)("b",{style:{marginRight:4},children:[v("manufacturer"),":"]}),b(this.props.device.manufacturer)]}):null}),(0,l.jsxs)(i.CardContent,{style:{position:"relative"},children:[null!==t&&void 0!==t&&t.length?(0,l.jsx)("div",{style:{display:"flex",position:"absolute",top:-11,background:"#88888880",padding:"0 8px",borderRadius:5,width:"calc(100% - 46px)"},children:t.map(((e,t)=>(0,l.jsx)(g,{status:e},t)))}):null,(0,l.jsx)("div",{children:(0,l.jsxs)(i.Typography,{variant:"body1",children:[(0,l.jsxs)("div",{onClick:this.copyToClipboard,style:{textOverflow:"ellipsis",overflow:"hidden"},children:[(0,l.jsx)("b",{children:"ID:"}),(0,l.jsx)("span",{style:{marginLeft:4},children:this.props.device.id.replace(/.*\.\d\./,"")})]}),this.props.device.manufacturer?(0,l.jsxs)("div",{children:[(0,l.jsxs)("b",{style:{marginRight:4},children:[v("manufacturer"),":"]}),b(this.props.device.manufacturer)]}):null,this.props.device.model?(0,l.jsxs)("div",{children:[(0,l.jsxs)("b",{style:{marginRight:4},children:[v("model"),":"]}),b(this.props.device.model)]}):null]})})]}),(0,l.jsxs)(i.CardActions,{disableSpacing:!0,children:[this.renderActions(),(0,l.jsx)("div",{style:{flexGrow:1}}),this.renderControls()]}),this.renderDialog(),this.renderControlDialog()]})}renderBig(){var e,t,s,o,a;const c={zIndex:2,maxWidth:"100%",maxHeight:"100%",color:"#FFF"},d=this.props.device.status?Array.isArray(this.props.device.status)?this.props.device.status:[this.props.device.status]:[],p=this.state.icon?(0,l.jsx)(r.IconDeviceType,{src:this.state.icon,style:c}):(0,l.jsx)(j,{style:c}),h=(null===(e=this.state.details)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.name)||this.props.title||"";return(0,l.jsxs)(i.Paper,{style:{width:300,minHeight:280,margin:10,overflow:"hidden",display:"inline-block"},children:[(0,l.jsxs)(i.Box,{sx:e=>({backgroundColor:e.palette.secondary.main}),style:{display:"flex",alignItems:"center",gap:8,paddingLeft:8,paddingRight:8,position:"relative",minHeight:60,color:"#000"},children:[(0,l.jsxs)("div",{style:{height:45,width:45,justifyContent:"center",display:"flex",alignItems:"center"},children:[this.props.uploadImagesToInstance?(0,l.jsx)(T,{uploadImagesToInstance:this.props.uploadImagesToInstance,deviceId:this.props.device.id,manufacturer:b(this.props.device.manufacturer),model:b(this.props.device.model),onImageSelect:e=>{e&&this.setState({icon:e})},socket:this.props.socket}):null,p]}),(0,l.jsx)(i.Box,{style:{fontSize:16,fontWeight:"bold",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:h.length>20?h:void 0,sx:e=>({color:e.palette.secondary.contrastText}),children:(null===(s=this.state.details)||void 0===s||null===(o=s.data)||void 0===o?void 0:o.name)||this.props.title}),this.props.device.hasDetails?(0,l.jsx)(i.Fab,{disabled:!this.props.alive,size:"small",style:{right:20,bottom:-20,position:"absolute"},onClick:()=>{this.state.open||(this.loadDetails().catch(console.error),this.setState({open:!0}))},color:"primary",children:(0,l.jsx)(n.MoreVert,{})}):null]}),(0,l.jsx)("div",{style:{padding:"15px 15px 0 15px",height:41},children:d.map(((e,t)=>(0,l.jsx)(g,{status:e},t)))}),(0,l.jsxs)("div",{style:{height:"calc(100% - 116px)"},children:[(0,l.jsxs)(i.Typography,{variant:"body1",style:{padding:"20px 16px 0 16px",height:133},children:[(0,l.jsxs)("div",{onClick:this.copyToClipboard,children:[(0,l.jsx)("b",{style:{marginRight:4},children:"ID:"}),this.props.device.id.replace(/.*\.\d\./,"")]}),this.props.device.manufacturer?(0,l.jsxs)("div",{children:[(0,l.jsxs)("b",{style:{marginRight:4},children:[v("manufacturer"),":"]}),b(this.props.device.manufacturer)]}):null,this.props.device.model?(0,l.jsxs)("div",{children:[(0,l.jsxs)("b",{style:{marginRight:4},children:[v("model"),":"]}),b(this.props.device.model)]}):null]}),!(null===(a=this.props.device.actions)||void 0===a||!a.length)&&(0,l.jsxs)("div",{style:{flex:1,position:"relative",display:"flex",gap:8,paddingBottom:5,height:34,paddingLeft:10,paddingRight:10},children:[this.renderActions(),(0,l.jsx)("div",{style:{flexGrow:1}}),this.renderControls()]})]}),this.renderDialog(),this.renderControlDialog()]},this.props.id)}render(){return this.props.smallCards?this.renderSmall():this.renderBig()}}const w=C;class B extends o.Component{constructor(e){super(e),this.responseTimeout=null,this.instanceHandler=void 0,this.deviceHandler=void 0,this.controlHandler=void 0,this.controlStateHandler=void 0,this.sendActionToInstance=(e,t,s)=>{(async()=>{this.setState({showSpinner:!0}),this.responseTimeout=setTimeout((()=>{this.setState({showSpinner:!1}),window.alert(r.I18n.t("ra_No response from the backend"))}),5e3);const o=await this.props.socket.sendTo(this.props.selectedInstance,e,t);this.responseTimeout&&(clearTimeout(this.responseTimeout),this.responseTimeout=null);const i=o.type;switch(console.log(`Response: ${o.type}`),i){case"message":console.log(`Message received: ${o.message}`),o.message&&this.setState({message:{message:o.message,handleClose:()=>this.setState({message:null},(()=>this.sendActionToInstance("dm:actionProgress",{origin:o.origin},s)))},showSpinner:!1});break;case"confirm":console.log(`Confirm received: ${o.confirm}`),o.confirm&&this.setState({confirm:{message:o.confirm,handleClose:e=>this.setState({confirm:null},(()=>this.sendActionToInstance("dm:actionProgress",{origin:o.origin,confirm:e},s)))},showSpinner:!1});break;case"form":if(console.log("Form received"),o.form){const e=o.form.data,t={};e&&Object.keys(e).forEach((s=>{void 0!==e[s]&&(t[s]=e[s])})),o.form.data=JSON.parse(JSON.stringify(t)),this.setState({form:{...o.form,changed:!1,originalData:JSON.stringify(t),handleClose:e=>this.setState({form:null},(()=>{console.log(`Form ${JSON.stringify(e)}`),this.sendActionToInstance("dm:actionProgress",{origin:o.origin,data:e},s)}))},showSpinner:!1})}break;case"progress":if(o.progress)if(this.state.progress){const e={...this.state.progress,...o.progress};this.setState({progress:e,showSpinner:!1})}else this.setState({progress:o.progress,showSpinner:!1});this.sendActionToInstance("dm:actionProgress",{origin:o.origin},s);break;case"result":console.log("Response content",o.result),o.result.refresh&&(!0===o.result.refresh?(console.log("Refreshing all"),this.loadData()):"instance"===o.result.refresh?console.log(`Refreshing instance infos: ${this.props.selectedInstance}`):"device"===o.result.refresh?s?(console.log(`Refreshing device infos: ${this.props.selectedInstance}`),s()):console.log('No refresh function provided to refresh "device"'):console.log("Not refreshing anything")),o.result.error?(console.error(`Error: ${o.result.error.message}`),this.setState({showToast:o.result.error.message,showSpinner:!1})):this.setState({showSpinner:!1});break;default:console.log(`Unknown response type: ${i}`),this.setState({showSpinner:!1})}})().catch(console.error)},this.sendControlToInstance=async(e,t)=>{const s=await this.props.socket.sendTo(this.props.selectedInstance,e,t),o=s.type;if(console.log(`Response: ${s.type}`),"result"===s.type){if(console.log("Response content",s.result),s.result.error)console.error(`Error: ${s.result.error.message}`),this.setState({showToast:s.result.error.message});else if(void 0!==s.result.state)return s.result.state}else console.warn("Unexpected response type",o);return null},this.state={showSpinner:!1,showToast:null,message:null,confirm:null,form:null,progress:null,showConfirmation:null,showInput:null,inputValue:null},this.instanceHandler=e=>()=>{e.confirmation?this.setState({showConfirmation:e}):e.inputBefore?this.setState({showInput:e}):this.sendActionToInstance("dm:instanceAction",{actionId:e.id})},this.deviceHandler=(e,t,s)=>()=>{t.confirmation?this.setState({showConfirmation:{...t,deviceId:e,refresh:s}}):t.inputBefore?this.setState({showInput:{...t,deviceId:e,refresh:s},inputValue:t.inputBefore.defaultValue||""}):this.sendActionToInstance("dm:deviceAction",{deviceId:e,actionId:t.id},s)},this.controlHandler=(e,t,s)=>()=>this.sendControlToInstance("dm:deviceControl",{deviceId:e,controlId:t.id,state:s}),this.controlStateHandler=(e,t)=>()=>this.sendControlToInstance("dm:deviceControlState",{deviceId:e,controlId:t.id}),this.props.registerHandler&&this.props.registerHandler((()=>this.loadData()))}componentWillUnmount(){this.responseTimeout&&(clearTimeout(this.responseTimeout),this.responseTimeout=null)}loadData(){console.error("loadData not implemented")}loadDevices(){return this.props.socket.sendTo(this.props.selectedInstance,"dm:listDevices")}loadInstanceInfos(){return this.props.socket.sendTo(this.props.selectedInstance,"dm:instanceInfo")}renderMessageDialog(){var e;return this.state.message?(0,l.jsxs)(i.Dialog,{open:!0,onClose:()=>{var e;return null===(e=this.state.message)||void 0===e?void 0:e.handleClose()},hideBackdrop:!0,"aria-describedby":"message-dialog-description",children:[(0,l.jsx)(i.DialogContent,{children:(0,l.jsx)(i.DialogContentText,{id:"message-dialog-description",children:null===(e=this.state.message)||void 0===e?void 0:e.message})}),(0,l.jsx)(i.DialogActions,{children:(0,l.jsx)(i.Button,{color:"primary",onClick:()=>{var e;return null===(e=this.state.message)||void 0===e?void 0:e.handleClose()},variant:"contained",autoFocus:!0,children:v("okButtonText")})})]}):null}renderConfirmDialog(){var e;return this.state.confirm?(0,l.jsxs)(i.Dialog,{open:!0,onClose:()=>{var e;return null===(e=this.state.confirm)||void 0===e?void 0:e.handleClose()},hideBackdrop:!0,"aria-describedby":"confirm-dialog-description",children:[(0,l.jsx)(i.DialogContent,{children:(0,l.jsx)(i.DialogContentText,{id:"confirm-dialog-description",children:v(null===(e=this.state.confirm)||void 0===e?void 0:e.message)})}),(0,l.jsxs)(i.DialogActions,{children:[(0,l.jsx)(i.Button,{variant:"contained",color:"primary",onClick:()=>{var e;return null===(e=this.state.confirm)||void 0===e?void 0:e.handleClose(!0)},autoFocus:!0,children:v("yesButtonText")}),(0,l.jsx)(i.Button,{variant:"contained",color:"grey",onClick:()=>{var e;return null===(e=this.state.confirm)||void 0===e?void 0:e.handleClose(!1)},autoFocus:!0,children:v("noButtonText")})]})]}):null}renderSnackbar(){return(0,l.jsx)(i.Snackbar,{open:!!this.state.showToast,autoHideDuration:6e3,onClose:()=>this.setState({showToast:null}),message:this.state.showToast})}getOkButton(e){var t,s,o,n,a,c,d;return"string"===typeof e&&(e=void 0),(0,l.jsx)(i.Button,{disabled:!(null!==(t=this.state.form)&&void 0!==t&&t.changed),variant:(null===(s=e)||void 0===s?void 0:s.variant)||"contained",color:(null===(o=e)||void 0===o?void 0:o.color)||"primary",onClick:()=>{var e,t;return(null===(e=this.state.form)||void 0===e?void 0:e.handleClose)&&this.state.form.handleClose(null===(t=this.state.form)||void 0===t?void 0:t.data)},startIcon:null!==(n=e)&&void 0!==n&&n.icon?(0,l.jsx)(r.Icon,{src:null===(a=e)||void 0===a?void 0:a.icon}):void 0,children:v((null===(c=e)||void 0===c?void 0:c.label)||"okButtonText",null===(d=e)||void 0===d?void 0:d.noTranslation)},"apply")}getCancelButton(e){var t,s,o,n,a,c;return"string"===typeof e&&(e=void 0),(0,l.jsx)(i.Button,{variant:(null===(t=e)||void 0===t?void 0:t.variant)||"contained",color:(null===(s=e)||void 0===s?void 0:s.color)||"grey",onClick:()=>{var e;return(null===(e=this.state.form)||void 0===e?void 0:e.handleClose)&&this.state.form.handleClose()},startIcon:null!==(o=e)&&void 0!==o&&o.icon?(0,l.jsx)(r.Icon,{src:null===(n=e)||void 0===n?void 0:n.icon}):void 0,children:v((null===(a=e)||void 0===a?void 0:a.label)||"cancelButtonText",null===(c=e)||void 0===c?void 0:c.noTranslation)},"cancel")}renderFormDialog(){var e,t,s;if(!this.state.form||!this.state.form.schema)return null;let o;return this.state.form.buttons?(o=[],this.state.form.buttons.forEach((e=>{"apply"===e||"apply"===e.type?o.push(this.getOkButton(e)):o.push(this.getCancelButton(e))}))):o=[this.getOkButton(),this.getCancelButton()],(0,l.jsxs)(i.Dialog,{open:!0,onClose:()=>{var e;return(null===(e=this.state.form)||void 0===e?void 0:e.handleClose)&&this.state.form.handleClose()},hideBackdrop:!0,maxWidth:this.state.form.maxWidth||"md",children:[null!==(e=this.state.form)&&void 0!==e&&e.title?(0,l.jsx)(i.DialogTitle,{children:v((null===(t=this.state.form)||void 0===t?void 0:t.label)||(null===(s=this.state.form)||void 0===s?void 0:s.title),this.state.form.noTranslation)}):null,(0,l.jsx)(i.DialogContent,{children:(0,l.jsx)(I,{instanceId:this.props.selectedInstance,schema:this.state.form.schema,data:this.state.form.data||{},socket:this.props.socket,onChange:e=>{console.log("handleFormChange",{data:e});const t={...this.state.form};t&&(t.data=e,t.changed=JSON.stringify(e)!==t.originalData,this.setState({form:t}))},themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat})}),(0,l.jsx)(i.DialogActions,{children:o})]})}renderProgressDialog(){var e,t;return null!==(e=this.state.progress)&&void 0!==e&&e.open?(0,l.jsx)(i.Dialog,{open:!0,onClose:()=>{},hideBackdrop:!0,children:(0,l.jsx)(i.LinearProgress,{variant:"determinate",value:(null===(t=this.state.progress)||void 0===t?void 0:t.progress)||0})}):null}renderContent(){return null}renderSpinner(){return this.state.showSpinner?(0,l.jsx)(i.Backdrop,{style:{zIndex:1e3},open:!0,children:(0,l.jsx)(i.CircularProgress,{})}):null}renderConfirmationDialog(){return this.state.showConfirmation?(0,l.jsxs)(i.Dialog,{open:!0,onClose:()=>this.setState({showConfirmation:null}),children:[(0,l.jsx)(i.DialogTitle,{children:v(!0===this.state.showConfirmation.confirmation?v("areYouSureText"):v(this.state.showConfirmation.confirmation))}),(0,l.jsxs)(i.DialogActions,{children:[(0,l.jsx)(i.Button,{variant:"contained",color:"primary",onClick:()=>{if(!this.state.showConfirmation)return;const e=this.state.showConfirmation;this.setState({showConfirmation:null},(()=>{e.deviceId?this.sendActionToInstance("dm:deviceAction",{actionId:e.id,deviceId:e.deviceId},e.refresh):this.sendActionToInstance("dm:instanceAction",{actionId:e.id})}))},autoFocus:!0,startIcon:(0,l.jsx)(n.Check,{}),children:v("yesButtonText")}),(0,l.jsx)(i.Button,{variant:"contained",color:"grey",onClick:()=>this.setState({showConfirmation:null}),startIcon:(0,l.jsx)(n.Close,{}),children:v("cancelButtonText")})]})]}):null}onShowInputOk(){if(!this.state.showInput)return;const e=this.state.showInput;this.setState({showInput:null},(()=>{var t,s,o,i;e.deviceId?this.sendActionToInstance("dm:deviceAction",{actionId:e.id,deviceId:e.deviceId,value:"checkbox"===(null===(t=e.inputBefore)||void 0===t?void 0:t.type)?!!this.state.inputValue:"number"===(null===(s=e.inputBefore)||void 0===s?void 0:s.type)?parseFloat(this.state.inputValue)||0:this.state.inputValue},e.refresh):this.sendActionToInstance("dm:instanceAction",{actionId:e.id,value:"checkbox"===(null===(o=e.inputBefore)||void 0===o?void 0:o.type)?!!this.state.inputValue:"number"===(null===(i=e.inputBefore)||void 0===i?void 0:i.type)?parseFloat(this.state.inputValue)||0:this.state.inputValue})}))}renderInputDialog(){var e;if(!this.state.showInput||!this.state.showInput.inputBefore)return null;let t=!1;return this.state.showInput.inputBefore.allowEmptyValue||"checkbox"===this.state.showInput.inputBefore.type||(t="number"===this.state.showInput.inputBefore.type||"slider"===this.state.showInput.inputBefore.type?""===this.state.inputValue||null===this.state.inputValue||!window.isFinite(this.state.inputValue):!this.state.inputValue),(0,l.jsxs)(i.Dialog,{open:!0,onClose:()=>this.setState({showInput:null}),children:[(0,l.jsx)(i.DialogTitle,{children:v("pleaseEnterValueText")}),(0,l.jsxs)(i.DialogContent,{children:["text"!==this.state.showInput.inputBefore.type&&"number"!==this.state.showInput.inputBefore.type&&this.state.showInput.inputBefore.type?null:(0,l.jsx)(i.TextField,{autoFocus:!0,margin:"dense",label:v(this.state.showInput.inputBefore.label),slotProps:{htmlInput:"number"===this.state.showInput.inputBefore.type?{min:this.state.showInput.inputBefore.min,max:this.state.showInput.inputBefore.max,step:this.state.showInput.inputBefore.step}:void 0,input:{endAdornment:this.state.inputValue?(0,l.jsx)(i.InputAdornment,{position:"end",children:(0,l.jsx)(i.IconButton,{size:"small",onClick:()=>this.setState({inputValue:""}),children:(0,l.jsx)(n.Close,{})})}):null}},type:"number"===this.state.showInput.inputBefore.type?"number":"text",fullWidth:!0,value:this.state.inputValue,onChange:e=>this.setState({inputValue:e.target.value}),onKeyUp:e=>{"Enter"===e.key&&this.onShowInputOk()}}),"checkbox"===this.state.showInput.inputBefore.type?(0,l.jsx)(i.FormControlLabel,{control:(0,l.jsx)(i.Checkbox,{checked:!!this.state.inputValue,autoFocus:!0,onChange:e=>this.setState({inputValue:e.target.checked})}),label:v(this.state.showInput.inputBefore.label)}):null,"select"===this.state.showInput.inputBefore.type?(0,l.jsxs)(i.FormControl,{fullWidth:!0,children:[(0,l.jsx)(i.InputLabel,{children:v(this.state.showInput.inputBefore.label)}),(0,l.jsx)(i.Select,{variant:"standard",value:this.state.inputValue,onChange:e=>this.setState({inputValue:e.target.value}),children:null===(e=this.state.showInput.inputBefore.options)||void 0===e?void 0:e.map((e=>(0,l.jsx)(i.MenuItem,{value:e.value,children:v(e.label)},e.value)))})]}):null,"slider"===this.state.showInput.inputBefore.type?(0,l.jsxs)(i.Box,{sx:{width:"100%"},children:[(0,l.jsx)(i.Typography,{gutterBottom:!0,children:v(this.state.showInput.inputBefore.label)}),(0,l.jsxs)(i.Grid2,{container:!0,spacing:2,alignItems:"center",children:[(0,l.jsx)(i.Grid2,{children:(0,l.jsx)(i.Slider,{value:"number"===typeof this.state.inputValue?this.state.inputValue:0,onChange:(e,t)=>this.setState({inputValue:t})})}),(0,l.jsx)(i.Grid2,{children:(0,l.jsx)(i.Input,{value:this.state.inputValue,size:"small",onChange:e=>this.setState({inputValue:""===e.target.value?0:Number(e.target.value)}),onBlur:()=>{var e,t;if(!this.state.showInput)return;const s=void 0===(null===(e=this.state.showInput.inputBefore)||void 0===e?void 0:e.min)?0:this.state.showInput.inputBefore.min,o=void 0===(null===(t=this.state.showInput.inputBefore)||void 0===t?void 0:t.max)?100:this.state.showInput.inputBefore.max;this.state.inputValue<s?this.setState({inputValue:s}):this.state.inputValue>o&&this.setState({inputValue:o})},inputProps:{step:this.state.showInput.inputBefore.step,min:void 0===this.state.showInput.inputBefore.min?0:this.state.showInput.inputBefore.min,max:void 0===this.state.showInput.inputBefore.max?100:this.state.showInput.inputBefore.max,type:"number"}})})]})]}):null]}),(0,l.jsxs)(i.DialogActions,{children:[(0,l.jsx)(i.Button,{variant:"contained",disabled:t,color:"primary",onClick:()=>this.onShowInputOk(),startIcon:(0,l.jsx)(n.Check,{}),children:v("yesButtonText")}),(0,l.jsx)(i.Button,{variant:"contained",color:"grey",onClick:()=>this.setState({showInput:null}),startIcon:(0,l.jsx)(n.Close,{}),children:v("cancelButtonText")})]})]})}render(){return(0,l.jsxs)(l.Fragment,{children:[this.renderSnackbar(),this.renderContent(),this.renderConfirmDialog(),this.renderMessageDialog(),this.renderFormDialog(),this.renderProgressDialog(),this.renderConfirmationDialog(),this.renderInputDialog(),this.renderSpinner()]})}}const S=B;function k(e){const{action:t,instanceHandler:s}=e,o=v(null!==t&&void 0!==t&&t.description?t.description:""),i=v(null!==t&&void 0!==t&&t.title?t.title:""),n=h(t);return(0,l.jsx)(a,{tooltip:o,label:i,disabled:t.disabled,Icon:n,onClick:s(t)})}const D=JSON.parse('{"allDevicesFilteredOut":"Alle Ger\xe4te herausgefiltert","batteryTooltip":"Batterie","cancelButtonText":"Abbrechen","closeButtonText":"Schlie\xdfen","connectedIconTooltip":"Verbunden","copied":"Kopiert","disconnectedIconTooltip":"Getrennt","filterLabelText":"Nach Name filtern","instanceLabelText":"Instanz","instanceNotAlive":"Instanz ist nicht aktiv","manufacturer":"Hersteller","model":"Modell","noButtonText":"Nein","noDevicesFoundText":"Keine Ger\xe4te gefunden","noInstanceSelectedText":"Bitte Instanz ausw\xe4hlen","okButtonText":"OK","pleaseEnterValueText":"Bitte eingeben","refreshInstanceList":"Instanzliste aktualisieren","refreshTooltip":"Aktualisieren","toClipboard":"in die Zwischenablage kopiert","yesButtonText":"Ja"}'),F=JSON.parse('{"allDevicesFilteredOut":"All devices filtered out","batteryTooltip":"Battery","cancelButtonText":"Cancel","closeButtonText":"Close","connectedIconTooltip":"Connected","copied":"Copied","disconnectedIconTooltip":"Disconnected","filterLabelText":"Filter by name","instanceLabelText":"Instance","instanceNotAlive":"Instance is not alive","manufacturer":"Manufacturer","model":"Model","noButtonText":"No","noDevicesFoundText":"No devices found","noInstanceSelectedText":"Please select instance","okButtonText":"OK","pleaseEnterValueText":"Please enter","refreshInstanceList":"Refresh instance list","refreshTooltip":"Refresh","toClipboard":"to clipboard","yesButtonText":"Yes"}'),L=JSON.parse('{"allDevicesFilteredOut":"\u0412\u0441\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u044b","batteryTooltip":"\u0411\u0430\u0442\u0430\u0440\u0435\u044f","cancelButtonText":"\u041e\u0442\u043c\u0435\u043d\u0430","closeButtonText":"\u0417\u0430\u043a\u0440\u044b\u0442\u044c","connectedIconTooltip":"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e","copied":"\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043e","disconnectedIconTooltip":"\u041e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u043e","filterLabelText":"\u0424\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0438\u043c\u0435\u043d\u0438","instanceLabelText":"\u0415\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440","instanceNotAlive":"\u042d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043d\u0435 \u0436\u0438\u0432","manufacturer":"\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c","model":"\u041c\u043e\u0434\u0435\u043b\u044c","noButtonText":"\u041d\u0435\u0442","noDevicesFoundText":"\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b","noInstanceSelectedText":"\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440","okButtonText":"\u0425\u041e\u0420\u041e\u0428\u041e","pleaseEnterValueText":"\u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430 \u0432\u0445\u043e\u0434\u0438\u0442\u0435","refreshInstanceList":"\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432","refreshTooltip":"\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c","toClipboard":"\u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0435\u043d\u0430","yesButtonText":"\u0414\u0430"}'),A=JSON.parse('{"allDevicesFilteredOut":"Todos os dispositivos foram filtrados","batteryTooltip":"Bateria","cancelButtonText":"Cancelar","closeButtonText":"Fechar","connectedIconTooltip":"Conectado","copied":"Copiado","disconnectedIconTooltip":"Desconectado","filterLabelText":"Filtrar por nome","instanceLabelText":"Inst\xe2ncia","instanceNotAlive":"A inst\xe2ncia n\xe3o est\xe1 ativa","manufacturer":"Fabricante","model":"Modelo","noButtonText":"N\xe3o","noDevicesFoundText":"Nenhum dispositivo encontrado","noInstanceSelectedText":"Selecione a inst\xe2ncia","okButtonText":"OK","pleaseEnterValueText":"Por favor, insira","refreshInstanceList":"Atualizar lista de inst\xe2ncias","refreshTooltip":"Atualizar","toClipboard":"para a \xe1rea de transfer\xeancia","yesButtonText":"Sim"}'),N=JSON.parse('{"allDevicesFilteredOut":"Alle apparaten zijn eruit gefilterd","batteryTooltip":"Batterij","cancelButtonText":"Annuleren","closeButtonText":"Dichtbij","connectedIconTooltip":"Verbonden","copied":"Gekopieerd","disconnectedIconTooltip":"Losgekoppeld","filterLabelText":"Filter op naam","instanceLabelText":"Voorbeeld","instanceNotAlive":"Instantie leeft niet","manufacturer":"Fabrikant","model":"Model","noButtonText":"Nee","noDevicesFoundText":"Geen apparaten gevonden","noInstanceSelectedText":"Selecteer een exemplaar","okButtonText":"OK","pleaseEnterValueText":"Kom binnen alstublieft","refreshInstanceList":"Ververs de exemplaarlijst","refreshTooltip":"Vernieuwen","toClipboard":"naar klembord","yesButtonText":"Ja"}'),O=JSON.parse('{"allDevicesFilteredOut":"Tous les appareils filtr\xe9s","batteryTooltip":"Batterie","cancelButtonText":"Annuler","closeButtonText":"Fermer","connectedIconTooltip":"Connect\xe9","copied":"Copi\xe9","disconnectedIconTooltip":"D\xe9branch\xe9","filterLabelText":"Filtrer par nom","instanceLabelText":"Exemple","instanceNotAlive":"L\'instance n\'est pas vivante","manufacturer":"Fabricant","model":"Mod\xe8le","noButtonText":"Non","noDevicesFoundText":"Aucun p\xe9riph\xe9rique trouv\xe9","noInstanceSelectedText":"Veuillez s\xe9lectionner une instance","okButtonText":"D\'ACCORD","pleaseEnterValueText":"Entrez s\'il vous plait","refreshInstanceList":"Actualiser la liste des instances","refreshTooltip":"Rafra\xeechir","toClipboard":"au presse-papiers","yesButtonText":"Oui"}'),V=JSON.parse('{"allDevicesFilteredOut":"Tutti i dispositivi sono stati filtrati","batteryTooltip":"Batteria","cancelButtonText":"Annulla","closeButtonText":"Vicino","connectedIconTooltip":"Connesso","copied":"Copiato","disconnectedIconTooltip":"Disconnesso","filterLabelText":"Filtra per nome","instanceLabelText":"Esempio","instanceNotAlive":"L\'istanza non \xe8 viva","manufacturer":"Produttore","model":"Modello","noButtonText":"NO","noDevicesFoundText":"Nessun dispositivo trovato","noInstanceSelectedText":"Seleziona l\'istanza","okButtonText":"OK","pleaseEnterValueText":"Prego entra","refreshInstanceList":"Aggiorna l\'elenco delle istanze","refreshTooltip":"ricaricare","toClipboard":"negli appunti","yesButtonText":"S\xcc"}'),z=JSON.parse('{"allDevicesFilteredOut":"Todos los dispositivos filtrados","batteryTooltip":"Bater\xeda","cancelButtonText":"Cancelar","closeButtonText":"Cerca","connectedIconTooltip":"Conectado","copied":"copiado","disconnectedIconTooltip":"Desconectado","filterLabelText":"Filtrar por nombre","instanceLabelText":"Instancia","instanceNotAlive":"La instancia no est\xe1 viva.","manufacturer":"Fabricante","model":"Modelo","noButtonText":"No","noDevicesFoundText":"No se encontraron dispositivos","noInstanceSelectedText":"Por favor seleccione instancia","okButtonText":"DE ACUERDO","pleaseEnterValueText":"Por favor escribe","refreshInstanceList":"Actualizar lista de instancias","refreshTooltip":"Actualizar","toClipboard":"al portapapeles","yesButtonText":"S\xed"}'),H=JSON.parse('{"allDevicesFilteredOut":"Wszystkie urz\u0105dzenia zosta\u0142y odfiltrowane","batteryTooltip":"Bateria","cancelButtonText":"Anulowa\u0107","closeButtonText":"Zamkn\u0105\u0107","connectedIconTooltip":"Po\u0142\u0105czono","copied":"Skopiowano","disconnectedIconTooltip":"Bez\u0142adny","filterLabelText":"Filtruj wed\u0142ug nazwy","instanceLabelText":"Instancja","instanceNotAlive":"Instancja nie \u017cyje","manufacturer":"Producent","model":"Model","noButtonText":"NIE","noDevicesFoundText":"Nie znaleziono urz\u0105dze\u0144","noInstanceSelectedText":"Wybierz instancj\u0119","okButtonText":"OK","pleaseEnterValueText":"Podaj","refreshInstanceList":"Od\u015bwie\u017c list\u0119 instancji","refreshTooltip":"Od\u015bwie\u017ca\u0107","toClipboard":"do schowka","yesButtonText":"Tak"}'),P=JSON.parse('{"allDevicesFilteredOut":"\u0423\u0441\u0456 \u043f\u0440\u0438\u0441\u0442\u0440\u043e\u0457 \u0432\u0456\u0434\u0444\u0456\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043e","batteryTooltip":"\u0411\u0430\u0442\u0430\u0440\u0435\u044f","cancelButtonText":"\u0421\u043a\u0430\u0441\u0443\u0432\u0430\u0442\u0438","closeButtonText":"\u0417\u0430\u043a\u0440\u0438\u0442\u0438","connectedIconTooltip":"\u041f\u0456\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e","copied":"\u0421\u043a\u043e\u043f\u0456\u0439\u043e\u0432\u0430\u043d\u043e","disconnectedIconTooltip":"\u0412\u0456\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043e","filterLabelText":"\u0424\u0456\u043b\u044c\u0442\u0440\u0443\u0432\u0430\u0442\u0438 \u0437\u0430 \u043d\u0430\u0437\u0432\u043e\u044e","instanceLabelText":"\u0415\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440","instanceNotAlive":"\u041f\u0440\u0438\u043c\u0456\u0440\u043d\u0438\u043a \u043d\u0435 \u0436\u0438\u0432\u0438\u0439","manufacturer":"\u0412\u0438\u0440\u043e\u0431\u043d\u0438\u043a","model":"\u041c\u043e\u0434\u0435\u043b\u044c","noButtonText":"\u041d\u0435\u043c\u0430\u0454","noDevicesFoundText":"\u041f\u0440\u0438\u0441\u0442\u0440\u043e\u0457\u0432 \u043d\u0435 \u0437\u043d\u0430\u0439\u0434\u0435\u043d\u043e","noInstanceSelectedText":"\u0412\u0438\u0431\u0435\u0440\u0456\u0442\u044c \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440","okButtonText":"\u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0443","pleaseEnterValueText":"\u0411\u0443\u0434\u044c \u043b\u0430\u0441\u043a\u0430 \u0432\u0432\u0435\u0434\u0456\u0442\u044c","refreshInstanceList":"\u041e\u043d\u043e\u0432\u0438\u0442\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0456\u0432","refreshTooltip":"\u041e\u043d\u043e\u0432\u0438\u0442\u0438","toClipboard":"\u0432 \u0431\u0443\u0444\u0435\u0440 \u043e\u0431\u043c\u0456\u043d\u0443","yesButtonText":"\u0422\u0430\u043a"}'),E=JSON.parse('{"allDevicesFilteredOut":"\u6240\u6709\u8bbe\u5907\u5747\u88ab\u8fc7\u6ee4\u6389","batteryTooltip":"\u7535\u6c60","cancelButtonText":"\u53d6\u6d88","closeButtonText":"\u5173\u95ed","connectedIconTooltip":"\u5df2\u8fde\u63a5","copied":"\u5df2\u590d\u5236","disconnectedIconTooltip":"\u5df2\u65ad\u5f00\u8fde\u63a5","filterLabelText":"\u6309\u540d\u79f0\u8fc7\u6ee4","instanceLabelText":"\u5b9e\u4f8b","instanceNotAlive":"\u5b9e\u4f8b\u4e0d\u5b58\u5728","manufacturer":"\u5236\u9020\u5546","model":"\u578b\u53f7","noButtonText":"\u4e0d","noDevicesFoundText":"\u672a\u627e\u5230\u8bbe\u5907","noInstanceSelectedText":"\u8bf7\u9009\u62e9\u5b9e\u4f8b","okButtonText":"\u597d\u7684","pleaseEnterValueText":"\u8bf7\u8f93\u5165","refreshInstanceList":"\u5237\u65b0\u5b9e\u4f8b\u5217\u8868","refreshTooltip":"\u5237\u65b0","toClipboard":"\u5230\u526a\u8d34\u677f","yesButtonText":"\u662f\u7684"}');class $ extends S{constructor(e){super(e),this.lastPropsFilter=void 0,this.lastInstance=void 0,this.lastTriggerLoad=0,this.filterTimeout=void 0,this.language=void 0,this.aliveHandler=(e,t)=>{if(e===`system.adapter.${this.props.selectedInstance}.alive`){const e=!(null===t||void 0===t||!t.val);e!==this.state.alive&&this.setState({alive:e},(()=>{e&&this.componentDidMount().catch(console.error)}))}},$.i18nInitialized||($.i18nInitialized=!0,r.I18n.extendTranslations({en:F,de:D,ru:L,pt:A,nl:N,fr:O,it:V,es:z,pl:H,uk:P,"zh-cn":E})),Object.assign(this.state,{devices:[],filteredDevices:[],filter:"",instanceInfo:null,loading:null,alive:null,groupKey:""}),this.lastPropsFilter=this.props.filter,this.lastInstance=this.props.selectedInstance,this.lastTriggerLoad=this.props.triggerLoad||0,this.filterTimeout=null,this.language=r.I18n.getLanguage()}async componentDidMount(){let e=!1;if(null===this.state.alive){try{const t=await this.props.socket.getState(`system.adapter.${this.props.selectedInstance}.alive`);null!==t&&void 0!==t&&t.val&&(e=!0)}catch(t){console.error(t)}if(this.setState({alive:e},(()=>this.props.socket.subscribeState(`system.adapter.${this.props.selectedInstance}.alive`,this.aliveHandler))),!e)return}else e=this.state.alive;if(!this.props.embedded&&e)try{const e=await this.loadInstanceInfos();this.setState({instanceInfo:e})}catch(t){console.error(t)}e&&this.loadData()}componentWillUnmount(){this.props.socket.unsubscribeState(`system.adapter.${this.props.selectedInstance}.alive`,this.aliveHandler)}loadData(){this.setState({loading:!0},(async()=>{console.log(`Loading devices for ${this.props.selectedInstance}...`);let e=[];try{e=await this.loadDevices(),e&&Array.isArray(e)||(console.error(`Message returned from sendTo() doesn't look like one from DeviceManagement, did you accidentally handle the message in your adapter? ${JSON.stringify(e)}`),e=[])}catch(t){console.error(t),e=[]}this.setState({devices:e,loading:!1},(()=>this.applyFilter()))}))}getText(e){return"object"===typeof e?e[this.language]||e.en:e}applyFilter(){const e=this.props.embedded?this.props.filter:this.state.filter;if(e){const t=this.state.devices.filter((t=>this.getText(t.name).toLowerCase().includes(e.toLowerCase())));this.setState({filteredDevices:t})}else this.setState({filteredDevices:this.state.devices})}handleFilterChange(e){this.setState({filter:e},(()=>{this.filterTimeout&&clearTimeout(this.filterTimeout),this.filterTimeout=setTimeout((()=>{this.filterTimeout=null,this.applyFilter()}),250)}))}renderGroups(e){return null!==e&&void 0!==e&&e.length?(0,l.jsx)(i.Select,{style:{minWidth:120,marginRight:8,marginTop:12.5},variant:"standard",value:this.state.groupKey||"_",renderValue:t=>{"_"===t&&(t="");const s=e.find((e=>e.value===t));return(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(null===s||void 0===s?void 0:s.icon)||(0,l.jsx)("div",{style:{width:24}}),(null===s||void 0===s?void 0:s.name)||t]})},onChange:e=>this.setState({groupKey:"_"===e.target.value?"":e.target.value}),children:e.map((e=>(0,l.jsxs)(i.MenuItem,{value:e.value||"_",style:{display:"flex",alignItems:"center",gap:8},children:[e.icon||(0,l.jsx)("div",{style:{width:24}}),e.name]},e.value||"_")))}):null}renderContent(){var e,t;const s={padding:25};(this.props.triggerLoad||0)!==this.lastTriggerLoad&&(this.lastTriggerLoad=this.props.triggerLoad||0,setTimeout((()=>this.loadData()),50)),this.props.embedded&&this.lastPropsFilter!==this.props.filter&&(this.lastPropsFilter=this.props.filter,setTimeout((()=>this.applyFilter()),50)),this.props.embedded&&this.lastInstance!==this.props.selectedInstance&&(this.lastInstance=this.props.selectedInstance,setTimeout((()=>this.loadData()),50));const o=[];let a;if(this.props.embedded||this.state.alive)if(!this.state.devices.length&&this.props.selectedInstance)a=[(0,l.jsx)("div",{style:s,children:(0,l.jsx)("span",{children:v("noDevicesFoundText")})},"notFound")];else if(this.state.devices.length&&!this.state.filteredDevices.length)a=[(0,l.jsx)("div",{style:s,children:(0,l.jsx)("span",{children:v("allDevicesFilteredOut")})},"filtered")];else{let e=this.state.filteredDevices;if(!this.props.embedded&&e.find((e=>e.group))){o.push({name:r.I18n.t("All"),value:"",count:e.length,icon:(0,l.jsx)(n.FilterAltOff,{})}),e.forEach((e=>{if(e.group){const t=o.find((t=>{var s;return t.value===(null===(s=e.group)||void 0===s?void 0:s.key)}));if(t)t.count++;else{const t=e.group.icon?(0,l.jsx)(r.IconDeviceType,{src:e.group.icon}):null;o.push({name:this.getText(e.group.name||e.group.key),value:e.group.key,count:1,icon:t})}}}));const t=e.filter((e=>!e.group));t.length&&o.push({name:r.I18n.t("Unknown"),value:"?",count:t.length,icon:(0,l.jsx)(n.QuestionMark,{})}),this.state.groupKey&&(e="?"===this.state.groupKey?e.filter((e=>{var t;return!(null!==(t=e.group)&&void 0!==t&&t.key)})):e.filter((e=>{var t;return(null===(t=e.group)||void 0===t?void 0:t.key)===this.state.groupKey})),e.length||(a=[(0,l.jsx)("div",{style:s,children:(0,l.jsx)("span",{children:v("allDevicesFilteredOut")})},"filtered")]))}e.length&&(a=e.map((e=>(0,l.jsx)(w,{alive:!!this.state.alive,id:e.id,title:this.getText(e.name),device:e,instanceId:this.props.selectedInstance,uploadImagesToInstance:this.props.uploadImagesToInstance,deviceHandler:this.deviceHandler,controlHandler:this.controlHandler,controlStateHandler:this.controlStateHandler,socket:this.props.socket,themeName:this.props.themeName,themeType:this.props.themeType,theme:this.props.theme,isFloatComma:this.props.isFloatComma,dateFormat:this.props.dateFormat},e.id))))}else a=[(0,l.jsx)("div",{style:s,children:(0,l.jsx)("span",{children:v("instanceNotAlive")})},"notAlive")];return this.props.embedded?(0,l.jsxs)(l.Fragment,{children:[this.state.loading?(0,l.jsx)(i.LinearProgress,{style:{width:"100%"}}):null,a]}):(0,l.jsxs)("div",{style:{width:"100%",height:"100%",overflow:"hidden"},children:[(0,l.jsxs)(i.Toolbar,{variant:"dense",style:{backgroundColor:"#777",display:"flex"},children:[this.props.title,this.props.selectedInstance?(0,l.jsx)(i.Tooltip,{title:v("refreshTooltip"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:(0,l.jsx)("span",{children:(0,l.jsx)(i.IconButton,{onClick:()=>this.loadData(),disabled:!this.state.alive,size:"small",children:(0,l.jsx)(n.Refresh,{})})})}):null,this.state.alive&&null!==(e=this.state.instanceInfo)&&void 0!==e&&null!==(t=e.actions)&&void 0!==t&&t.length?(0,l.jsx)("div",{style:{marginLeft:20},children:this.state.instanceInfo.actions.map((e=>(0,l.jsx)(k,{action:e,instanceHandler:this.instanceHandler},e.id)))}):null,(0,l.jsx)("div",{style:{flexGrow:1}}),this.renderGroups(o),this.state.alive?(0,l.jsx)(i.TextField,{variant:"standard",style:{width:200},size:"small",label:v("filterLabelText"),onChange:e=>this.handleFilterChange(e.target.value),value:this.state.filter,autoComplete:"off",slotProps:{input:{autoComplete:"new-password",endAdornment:this.state.filter?(0,l.jsx)(i.InputAdornment,{position:"end",children:(0,l.jsx)(i.IconButton,{onClick:()=>this.handleFilterChange(""),edge:"end",children:(0,l.jsx)(n.Clear,{})})}):null},htmlInput:{autoComplete:"off"}}}):null]}),(0,l.jsxs)("div",{style:{width:"100%",height:"calc(100% - 56px)",marginTop:8,overflow:"auto",...this.props.style},children:[this.state.loading?(0,l.jsx)(i.LinearProgress,{style:{width:"100%"}}):null,a]})]})}}$.i18nInitialized=!1;const R=$}}]);
2
+ //# sourceMappingURL=4720.4d2f2008.chunk.js.map