iobroker.eos-admin 7.9.66 → 7.9.67
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/adminWww/assets/AdapterUpdateDialog-BMg84Hpf-v67.js +2 -0
- package/adminWww/assets/Adapters-B5_jQ7DE-v67.js +9 -0
- package/adminWww/assets/Config-hHK2UzGP-v67.js +1 -0
- package/adminWww/assets/CustomTab-B0wqoazH-v67.js +1 -0
- package/adminWww/assets/DeviceManager-BFmQeYQ1-v67.js +1 -0
- package/adminWww/assets/EasyMode-B1d9Vdc4-v67.js +1 -0
- package/adminWww/assets/Enums-DbWYxKOo-v67.js +91 -0
- package/adminWww/assets/Fields-CX3rKuWb-v67.js +1 -0
- package/adminWww/assets/Files-Cd2HOzIE-v67.js +1 -0
- package/adminWww/assets/Hosts-Bg8QzW5i-v67.js +121 -0
- package/adminWww/assets/Instances-YdaGnS5a-v67.js +2 -0
- package/adminWww/assets/Intro-DkwRiz1n-v67.js +2 -0
- package/adminWww/assets/Logs-CsVPSLJH-v67.js +1 -0
- package/adminWww/assets/Objects-DPan0bzw-v67.js +878 -0
- package/adminWww/assets/Users-BgnBRgwU-v67.js +1 -0
- package/adminWww/assets/bootstrap-COulQZax-v61.js +1 -317
- package/adminWww/assets/bootstrap-COulQZax-v67.js +317 -0
- package/adminWww/assets/index-CQZugZ1z-v67.js +2 -0
- package/adminWww/css/eos-branding.css +42 -16
- package/adminWww/index.html +10 -10
- package/adminWww/js/eos-branding.js +90 -38
- package/io-package.json +4 -4
- package/package.json +1 -1
- package/tools/nexowatt-validate-package.cjs +24 -15
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import{j as e}from"./DefaultPropsProvider-BiXBMQYQ.js";import{i as T,a as $}from"./iobroker_admin__loadShare__react__loadShare__-LM7uyL45.js";import{i as o,a as y}from"./iobroker_admin__loadShare___mf_0_mui_mf_1_icons_mf_2_material__loadShare__-CJO5yP3h.js";import{i as h}from"./iobroker_admin__loadShare___mf_0_iobroker_mf_1_adapter_mf_2_react_mf_2_v5__loadShare__-LFZoiUTt.js";import{m as tt,n as pt,E as dt,b as z,s as ct,S as st}from"./bootstrap-COulQZax-v67.js";import{G as it}from"./iconBase-2IlPecPg.js";import{A as ut}from"./AdapterUpdateDialog-BMg84Hpf-v67.js";import{g as mt}from"./_commonjsHelpers-CE1G-McA.js";import{C as xt}from"./CustomModal-CqDLqryN.js";import{q as at,v as gt,g as ft}from"./createTheme-DFX8CY6F.js";import{a as yt}from"./amber-D7aVlNg3.js";import{b as bt}from"./blue-CagzI6CQ.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-g2X2zhAf.js";import"./emotion-serialize.esm-Q4o_CgeF.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-BywLg1Xe.js";import"./ace-DEUjyTIn.js";import"./iobroker_admin__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__-CpA7pnS5.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-CNUAG3AH.js";import"./ext-language_tools-ylAoucDh.js";import"./iobroker_admin__loadShare__react_mf_2_dropzone__loadShare__-CwjnV48g.js";import"./iobroker_admin__loadShare__react_mf_2_dom__loadShare__-CVeAXnkk.js";import"./preload-helper-BDBacUwf.js";import"./sdk-C-e-e2gd.js";import"./extends-CF3RwP-h.js";import"./assertThisInitialized-B0aQ9eG_.js";import"./useTheme-Bl-M1DYp.js";import"./index-DcK0RDrH.js";import"./ThemeProvider-BOFFjWAF.js";import"./emotion-cache.browser.esm-BgJfNZJN.js";import"./setYear-3ufv5yRD.js";import"./en-US-DBFJNIH6.js";import"./zh-cn-nUtvS7Wc.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./State-qCI8JACH.js";function vt(u){return it({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M16.293 9.293 12 13.586 7.707 9.293l-1.414 1.414L12 16.414l5.707-5.707z"},child:[]}]})(u)}function jt(u){return it({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"m6.293 13.293 1.414 1.414L12 10.414l4.293 4.293 1.414-1.414L12 7.586z"},child:[]}]})(u)}var et={exports:{}},Ct=et.exports;(function(u){(function(t){const s="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${s}\\.${s}\\.${s}\\.${s}$`,"i"),threeOctet:new RegExp(`^${s}\\.${s}\\.${s}$`,"i"),twoOctet:new RegExp(`^${s}\\.${s}$`,"i"),longValue:new RegExp(`^${s}$`,"i")},p=new RegExp("^0[0-7]+$","i"),b=new RegExp("^0x[a-f0-9]+$","i"),g="%[0-9a-z]{1,}",k="(?:[0-9a-f]+::?)+",F={zoneIndex:new RegExp(g,"i"),native:new RegExp(`^(::)?(${k})?([0-9a-f]+)?(::)?(${g})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${s}\\.${s}\\.${s}\\.${s}(${g})?)$`,"i"),transitional:new RegExp(`^((?:${k})|(?:::)(?:${k})?)${s}\\.${s}\\.${s}\\.${s}(${g})?$`,"i")};function H(n,i){if(n.indexOf("::")!==n.lastIndexOf("::"))return null;let l=0,a=-1,d=(n.match(F.zoneIndex)||[])[0],c,C;for(d&&(d=d.substring(1),n=n.replace(/%.+$/,""));(a=n.indexOf(":",a+1))>=0;)l++;if(n.substr(0,2)==="::"&&l--,n.substr(-2,2)==="::"&&l--,l>i)return null;for(C=i-l,c=":";C--;)c+="0:";return n=n.replace("::",c),n[0]===":"&&(n=n.slice(1)),n[n.length-1]===":"&&(n=n.slice(0,-1)),i=(function(){const M=n.split(":"),J=[];for(let N=0;N<M.length;N++)J.push(parseInt(M[N],16));return J})(),{parts:i,zoneId:d}}function D(n,i,l,a){if(n.length!==i.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let d=0,c;for(;a>0;){if(c=l-a,c<0&&(c=0),n[d]>>c!==i[d]>>c)return!1;a-=l,d+=1}return!0}function L(n){if(b.test(n))return parseInt(n,16);if(n[0]==="0"&&!isNaN(parseInt(n[1],10))){if(p.test(n))return parseInt(n,8);throw new Error(`ipaddr: cannot parse ${n} as octal`)}return parseInt(n,10)}function X(n,i){for(;n.length<i;)n=`0${n}`;return n}const m={};m.IPv4=(function(){function n(i){if(i.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let l,a;for(l=0;l<i.length;l++)if(a=i[l],!(0<=a&&a<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=i}return n.prototype.SpecialRanges={unspecified:[[new n([0,0,0,0]),8]],broadcast:[[new n([255,255,255,255]),32]],multicast:[[new n([224,0,0,0]),4]],linkLocal:[[new n([169,254,0,0]),16]],loopback:[[new n([127,0,0,0]),8]],carrierGradeNat:[[new n([100,64,0,0]),10]],private:[[new n([10,0,0,0]),8],[new n([172,16,0,0]),12],[new n([192,168,0,0]),16]],reserved:[[new n([192,0,0,0]),24],[new n([192,0,2,0]),24],[new n([192,88,99,0]),24],[new n([198,18,0,0]),15],[new n([198,51,100,0]),24],[new n([203,0,113,0]),24],[new n([240,0,0,0]),4]],as112:[[new n([192,175,48,0]),24],[new n([192,31,196,0]),24]],amt:[[new n([192,52,193,0]),24]]},n.prototype.kind=function(){return"ipv4"},n.prototype.match=function(i,l){let a;if(l===void 0&&(a=i,i=a[0],l=a[1]),i.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return D(this.octets,i.octets,8,l)},n.prototype.prefixLengthFromSubnetMask=function(){let i=0,l=!1;const a={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let d,c,C;for(d=3;d>=0;d-=1)if(c=this.octets[d],c in a){if(C=a[c],l&&C!==0)return null;C!==8&&(l=!0),i+=C}else return null;return 32-i},n.prototype.range=function(){return m.subnetMatch(this,this.SpecialRanges)},n.prototype.toByteArray=function(){return this.octets.slice(0)},n.prototype.toIPv4MappedAddress=function(){return m.IPv6.parse(`::ffff:${this.toString()}`)},n.prototype.toNormalizedString=function(){return this.toString()},n.prototype.toString=function(){return this.octets.join(".")},n})(),m.IPv4.broadcastAddressFromCIDR=function(n){try{const i=this.parseCIDR(n),l=i[0].toByteArray(),a=this.subnetMaskFromPrefixLength(i[1]).toByteArray(),d=[];let c=0;for(;c<4;)d.push(parseInt(l[c],10)|parseInt(a[c],10)^255),c++;return new this(d)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},m.IPv4.isIPv4=function(n){return this.parser(n)!==null},m.IPv4.isValid=function(n){try{return new this(this.parser(n)),!0}catch{return!1}},m.IPv4.isValidCIDR=function(n){try{return this.parseCIDR(n),!0}catch{return!1}},m.IPv4.isValidFourPartDecimal=function(n){return!!(m.IPv4.isValid(n)&&n.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},m.IPv4.isValidCIDRFourPartDecimal=function(n){const i=n.match(/^(.+)\/(\d+)$/);return!m.IPv4.isValidCIDR(n)||!i?!1:m.IPv4.isValidFourPartDecimal(i[1])},m.IPv4.networkAddressFromCIDR=function(n){let i,l,a,d,c;try{for(i=this.parseCIDR(n),a=i[0].toByteArray(),c=this.subnetMaskFromPrefixLength(i[1]).toByteArray(),d=[],l=0;l<4;)d.push(parseInt(a[l],10)&parseInt(c[l],10)),l++;return new this(d)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},m.IPv4.parse=function(n){const i=this.parser(n);if(i===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(i)},m.IPv4.parseCIDR=function(n){let i;if(i=n.match(/^(.+)\/(\d+)$/)){const l=parseInt(i[2]);if(l>=0&&l<=32){const a=[this.parse(i[1]),l];return Object.defineProperty(a,"toString",{value:function(){return this.join("/")}}),a}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},m.IPv4.parser=function(n){let i,l,a;if(i=n.match(r.fourOctet))return(function(){const d=i.slice(1,6),c=[];for(let C=0;C<d.length;C++)l=d[C],c.push(L(l));return c})();if(i=n.match(r.longValue)){if(a=L(i[1]),a>4294967295||a<0)throw new Error("ipaddr: address outside defined range");return(function(){const d=[];let c;for(c=0;c<=24;c+=8)d.push(a>>c&255);return d})().reverse()}else return(i=n.match(r.twoOctet))?(function(){const d=i.slice(1,4),c=[];if(a=L(d[1]),a>16777215||a<0)throw new Error("ipaddr: address outside defined range");return c.push(L(d[0])),c.push(a>>16&255),c.push(a>>8&255),c.push(a&255),c})():(i=n.match(r.threeOctet))?(function(){const d=i.slice(1,5),c=[];if(a=L(d[2]),a>65535||a<0)throw new Error("ipaddr: address outside defined range");return c.push(L(d[0])),c.push(L(d[1])),c.push(a>>8&255),c.push(a&255),c})():null},m.IPv4.subnetMaskFromPrefixLength=function(n){if(n=parseInt(n),n<0||n>32)throw new Error("ipaddr: invalid IPv4 prefix length");const i=[0,0,0,0];let l=0;const a=Math.floor(n/8);for(;l<a;)i[l]=255,l++;return a<4&&(i[a]=Math.pow(2,n%8)-1<<8-n%8),new this(i)},m.IPv6=(function(){function n(i,l){let a,d;if(i.length===16)for(this.parts=[],a=0;a<=14;a+=2)this.parts.push(i[a]<<8|i[a+1]);else if(i.length===8)this.parts=i;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(a=0;a<this.parts.length;a++)if(d=this.parts[a],!(0<=d&&d<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");l&&(this.zoneId=l)}return n.prototype.SpecialRanges={unspecified:[new n([0,0,0,0,0,0,0,0]),128],linkLocal:[new n([65152,0,0,0,0,0,0,0]),10],multicast:[new n([65280,0,0,0,0,0,0,0]),8],loopback:[new n([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new n([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new n([0,0,0,0,0,65535,0,0]),96],discard:[new n([256,0,0,0,0,0,0,0]),64],rfc6145:[new n([0,0,0,0,65535,0,0,0]),96],rfc6052:[new n([100,65435,0,0,0,0,0,0]),96],"6to4":[new n([8194,0,0,0,0,0,0,0]),16],teredo:[new n([8193,0,0,0,0,0,0,0]),32],benchmarking:[new n([8193,2,0,0,0,0,0,0]),48],amt:[new n([8193,3,0,0,0,0,0,0]),32],as112v6:[[new n([8193,4,274,0,0,0,0,0]),48],[new n([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new n([8193,16,0,0,0,0,0,0]),28],orchid2:[new n([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new n([8193,48,0,0,0,0,0,0]),28],reserved:[[new n([8193,0,0,0,0,0,0,0]),23],[new n([8193,3512,0,0,0,0,0,0]),32]]},n.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},n.prototype.kind=function(){return"ipv6"},n.prototype.match=function(i,l){let a;if(l===void 0&&(a=i,i=a[0],l=a[1]),i.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return D(this.parts,i.parts,16,l)},n.prototype.prefixLengthFromSubnetMask=function(){let i=0,l=!1;const a={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let d,c;for(let C=7;C>=0;C-=1)if(d=this.parts[C],d in a){if(c=a[d],l&&c!==0)return null;c!==16&&(l=!0),i+=c}else return null;return 128-i},n.prototype.range=function(){return m.subnetMatch(this,this.SpecialRanges)},n.prototype.toByteArray=function(){let i;const l=[],a=this.parts;for(let d=0;d<a.length;d++)i=a[d],l.push(i>>8),l.push(i&255);return l},n.prototype.toFixedLengthString=function(){const i=(function(){const a=[];for(let d=0;d<this.parts.length;d++)a.push(X(this.parts[d].toString(16),4));return a}).call(this).join(":");let l="";return this.zoneId&&(l=`%${this.zoneId}`),i+l},n.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const i=this.parts.slice(-2),l=i[0],a=i[1];return new m.IPv4([l>>8,l&255,a>>8,a&255])},n.prototype.toNormalizedString=function(){const i=(function(){const a=[];for(let d=0;d<this.parts.length;d++)a.push(this.parts[d].toString(16));return a}).call(this).join(":");let l="";return this.zoneId&&(l=`%${this.zoneId}`),i+l},n.prototype.toRFC5952String=function(){const i=/((^|:)(0(:|$)){2,})/g,l=this.toNormalizedString();let a=0,d=-1,c;for(;c=i.exec(l);)c[0].length>d&&(a=c.index,d=c[0].length);return d<0?l:`${l.substring(0,a)}::${l.substring(a+d)}`},n.prototype.toString=function(){return this.toRFC5952String()},n})(),m.IPv6.broadcastAddressFromCIDR=function(n){try{const i=this.parseCIDR(n),l=i[0].toByteArray(),a=this.subnetMaskFromPrefixLength(i[1]).toByteArray(),d=[];let c=0;for(;c<16;)d.push(parseInt(l[c],10)|parseInt(a[c],10)^255),c++;return new this(d)}catch(i){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${i})`)}},m.IPv6.isIPv6=function(n){return this.parser(n)!==null},m.IPv6.isValid=function(n){if(typeof n=="string"&&n.indexOf(":")===-1)return!1;try{const i=this.parser(n);return new this(i.parts,i.zoneId),!0}catch{return!1}},m.IPv6.isValidCIDR=function(n){if(typeof n=="string"&&n.indexOf(":")===-1)return!1;try{return this.parseCIDR(n),!0}catch{return!1}},m.IPv6.networkAddressFromCIDR=function(n){let i,l,a,d,c;try{for(i=this.parseCIDR(n),a=i[0].toByteArray(),c=this.subnetMaskFromPrefixLength(i[1]).toByteArray(),d=[],l=0;l<16;)d.push(parseInt(a[l],10)&parseInt(c[l],10)),l++;return new this(d)}catch(C){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${C})`)}},m.IPv6.parse=function(n){const i=this.parser(n);if(i.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(i.parts,i.zoneId)},m.IPv6.parseCIDR=function(n){let i,l,a;if((l=n.match(/^(.+)\/(\d+)$/))&&(i=parseInt(l[2]),i>=0&&i<=128))return a=[this.parse(l[1]),i],Object.defineProperty(a,"toString",{value:function(){return this.join("/")}}),a;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},m.IPv6.parser=function(n){let i,l,a,d,c,C;if(a=n.match(F.deprecatedTransitional))return this.parser(`::ffff:${a[1]}`);if(F.native.test(n))return H(n,8);if((a=n.match(F.transitional))&&(C=a[6]||"",i=a[1],a[1].endsWith("::")||(i=i.slice(0,-1)),i=H(i+C,6),i.parts)){for(c=[parseInt(a[2]),parseInt(a[3]),parseInt(a[4]),parseInt(a[5])],l=0;l<c.length;l++)if(d=c[l],!(0<=d&&d<=255))return null;return i.parts.push(c[0]<<8|c[1]),i.parts.push(c[2]<<8|c[3]),{parts:i.parts,zoneId:i.zoneId}}return null},m.IPv6.subnetMaskFromPrefixLength=function(n){if(n=parseInt(n),n<0||n>128)throw new Error("ipaddr: invalid IPv6 prefix length");const i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let l=0;const a=Math.floor(n/8);for(;l<a;)i[l]=255,l++;return a<16&&(i[a]=Math.pow(2,n%8)-1<<8-n%8),new this(i)},m.fromByteArray=function(n){const i=n.length;if(i===4)return new m.IPv4(n);if(i===16)return new m.IPv6(n);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},m.isValid=function(n){return m.IPv6.isValid(n)||m.IPv4.isValid(n)},m.isValidCIDR=function(n){return m.IPv6.isValidCIDR(n)||m.IPv4.isValidCIDR(n)},m.parse=function(n){if(m.IPv6.isValid(n))return m.IPv6.parse(n);if(m.IPv4.isValid(n))return m.IPv4.parse(n);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},m.parseCIDR=function(n){try{return m.IPv6.parseCIDR(n)}catch{try{return m.IPv4.parseCIDR(n)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},m.process=function(n){const i=this.parse(n);return i.kind()==="ipv6"&&i.isIPv4MappedAddress()?i.toIPv4Address():i},m.subnetMatch=function(n,i,l){let a,d,c,C;l==null&&(l="unicast");for(d in i)if(Object.prototype.hasOwnProperty.call(i,d)){for(c=i[d],c[0]&&!(c[0]instanceof Array)&&(c=[c]),a=0;a<c.length;a++)if(C=c[a],n.kind()===C[0].kind()&&n.match.apply(n,C))return d}return l},u.exports?u.exports=m:t.ipaddr=m})(Ct)})(et);var It=et.exports;const ot=mt(It);class St extends T.Component{updating=!1;textareaRef=$.createRef();link=`${window.location.protocol}//${window.location.host}/`;interval;startTimeout;constructor(t){super(t),this.state={response:null,error:null,starting:!0}}setUpdating(t){this.updating!==t&&(this.updating=t,this.props.onUpdating(t))}async findIpAddress(){var b,g,k,F;if((await this.props.socket.getObject(`system.adapter.${this.props.adminInstance}`)).common.host===this.props.hostId)return;const s=await this.props.socket.getObject(this.props.hostId),r=await this.props.socket.readBaseSettings(this.props.hostId);let p=(g=(b=r==null?void 0:r.config)==null?void 0:b.objects)==null?void 0:g.host;if(!(!p||p==="localhost")&&(p=ot.parse(Array.isArray(p)?p[0]:p).toString(),!!((F=(k=s==null?void 0:s.native)==null?void 0:k.hardware)!=null&&F.networkInterfaces)))for(const H of Object.values(s.native.hardware.networkInterfaces))H.find(D=>{try{const L=ot.parseCIDR(D.cidr).toString();D.internal===!1&&p.match(L)&&(this.link=`${window.location.protocol}//${D.family==="IPv6"?`[${D.address}]`:D.address}:${window.location.port}`)}catch{}return!1})}async componentDidMount(){try{await this.findIpAddress()}catch(t){console.error(`Cannot find ip address: ${t.message}`)}try{await this.props.socket.upgradeController(this.props.hostId,this.props.version,parseInt(this.props.adminInstance.split(".").pop(),10))}catch(t){console.error(`Cannot update controller: ${t.message}`),this.setState({error:h.I18n.t("Not updatable"),starting:!1}),this.setUpdating(!1);return}this.setUpdating(!0),this.interval=setInterval(()=>this.checkStatus(),1e3),this.startTimeout=setTimeout(()=>{this.startTimeout=null,this.setState({starting:!1})},1e4)}componentWillUnmount(){this.interval&&(clearInterval(this.interval),this.interval=null),this.startTimeout&&(clearTimeout(this.startTimeout),this.startTimeout=null)}async checkStatus(){console.log(`Request update status from: ${this.link}`);try{const s=await(await fetch(this.link)).text();console.log(`Received status: ${s}`);const r=JSON.parse(s);r!=null&&r.stderr&&(r.stderr=r.stderr.filter(p=>p.trim())),r&&!r.running&&r.success&&r.stdout?(r.stdout.push(""),r.stdout.push("---------------------------------------------------"),r.stdout.push(h.I18n.t("%s was successfully updated to %s","js-controller",this.props.version))):r!=null&&r.stdout&&(r.stdout.unshift(""),r.stdout.unshift("---------------------------------------------------"),r.stdout.unshift(h.I18n.t("updating %s to %s...","js-controller",this.props.version))),this.setState({response:r,error:null},()=>{r&&!r.running?(this.setUpdating(!1),this.interval&&(clearInterval(this.interval),this.interval=null)):r!=null&&r.running&&this.setUpdating(!0),this.textareaRef.current&&setTimeout(()=>this.textareaRef.current.scrollTop=this.textareaRef.current.scrollHeight,100)})}catch(t){this.state.starting||this.setState({error:t.toString()},()=>this.setUpdating(!1))}}render(){var t,s,r,p,b;return e.jsxs(o.Dialog,{onClose:(g,k)=>{k!=="escapeKeyDown"&&k!=="backdropClick"&&this.props.onClose()},open:!0,maxWidth:"lg",fullWidth:!0,children:[e.jsx(o.DialogTitle,{children:h.I18n.t("Updating %s...","js-controller")}),e.jsxs(o.DialogContent,{style:{height:400,padding:"0 20px",overflow:"hidden"},children:[(!this.state.response||this.state.response.running)&&!this.state.error?e.jsx(o.LinearProgress,{}):null,this.state.response||this.state.error?e.jsx("textarea",{ref:this.textareaRef,style:{width:"100%",height:"100%",resize:"none",background:this.props.themeType==="dark"?"#000":"#fff",color:this.props.themeType==="dark"?"#EEE":"#111",boxSizing:"border-box",fontFamily:"Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace",border:(t=this.state.response)!=null&&t.success?"2px solid green":this.state.error||this.state.response&&!this.state.response.running&&!this.state.response.success?"2px solid red":void 0},value:this.state.error?this.state.error:this.state.response.stderr&&this.state.response.stderr.length?this.state.response.stderr.join(`
|
|
2
|
+
`):this.state.response.stdout.join(`
|
|
3
|
+
`),readOnly:!0}):null]}),e.jsx(o.DialogActions,{children:e.jsx(o.Button,{id:"js-controller-updater-close",variant:"contained",disabled:this.state.starting||!this.state.error&&((s=this.state.response)==null?void 0:s.running),onClick:()=>{var g;(g=this.state.response)!=null&&g.success&&window.location.reload(),this.props.onClose()},color:(r=this.state.response)!=null&&r.success?"primary":"grey",startIcon:(p=this.state.response)!=null&&p.success?e.jsx(y.Refresh,{}):e.jsx(y.Close,{}),children:(b=this.state.response)!=null&&b.success?h.I18n.t("Reload"):h.I18n.t("Close")})})]})}}const x={root:{width:"100%",height:"auto",display:"flex",flexDirection:"column",overflow:"auto",padding:10},paper:{maxWidth:1e3},overflowHidden:{display:"flex",overflow:"hidden"},h2:u=>({p:"10px 7px",fontSize:25,fontWeight:300,borderRadius:"3px",background:"#4dabf5",color:u.palette.mode==="dark"?"black":"white"}),h22:u=>({p:0,m:0,fontSize:25,fontWeight:300,borderRadius:"3px",background:"#4dabf5",color:u.palette.mode==="dark"?"black":"white"}),standardText:{fontSize:15,margin:"10px 0","& > a":{textDecoration:"none",color:"#1e88e5"}},standardTextSmall:{fontSize:12,color:"black"},standardTextSmall2:{fontSize:12},pre:{whiteSpace:"pre-wrap",background:"#e4e3e3",padding:10,borderRadius:3,position:"relative"},copyButton:{color:"black",position:"absolute",right:10,top:4},accordionSummary:{background:"#4dabf5",borderRadius:"3px","& .MuiAccordionSummary-content":{m:0}},accordionDetails:{display:"flex",flexDirection:"column"},code:u=>({backgroundColor:u.palette.mode==="dark"?"#123456":"#93bbe7",p:"0 3px 0 3px"}),copyButtonSmall:{width:31,height:16}};function rt(u,t,s){const r=u.split(`
|
|
4
|
+
`),p=[];let b=!1;for(let g=0;g<r.length;g++){const k=r[g].toLowerCase();k.startsWith("##")&&(b=k.includes(t.toLowerCase())&&(!s||!k.includes(s.toLowerCase()))),b||p.push(r[g])}return p.join(`
|
|
5
|
+
`)}const wt=({socket:u,hostId:t,version:s,onClose:r})=>{const[p,b]=T.useState(null),[g,k]=T.useState(""),[F,H]=T.useState(""),D=m=>{h.Utils.copyToClipboard(m),window.alert(h.I18n.t("Copied"))};T.useEffect(()=>{(!t||typeof t!="string")&&console.error(`Invalid hostId: "${t}" with type ${typeof t}`),(!g||!F)&&t&&typeof t=="string"&&u.getHostInfoShort(t).then(m=>{m.location&&m.location!==g&&k(m.location),m.os&&m.os!==F&&H(m.os),fetch(`https://raw.githubusercontent.com/ioBroker/ioBroker.docs/master/admin/${h.I18n.getLanguage()}/controller-upgrade.md`).then(n=>n.text()).then(n=>{const i=m.os||F,l=(m.location||g).replace(/\\/g,"/");i==="win32"?n=rt(n,"linux","windows"):n=rt(n,"windows","linux"),n=n.replace(/cd \/opt\/iobroker/g,`cd ${l}`),n=n.replace(/cd C:\\iobroker/g,`cd ${l}`),n=n.replace(/x\.y\.z/g,s);const a=n.split("<!-- copy"),d=[];a.forEach(c=>{if(c.includes("-->")){const C=c.split("-->");let M=C[0];const J=C[1];let N=!1;M.startsWith(" small")&&(M=M.replace(/^ {2}small /,""),N=!0),M=M.replace(/^\n\r/,"").replace(/^\n/,""),N?d.push(e.jsx(o.IconButton,{onClick:()=>D(M),children:e.jsx(h.IconCopy,{})},`b${d.length}`)):d.push(e.jsx(o.Button,{variant:"contained",onClick:()=>D(M),startIcon:e.jsx(h.IconCopy,{}),children:h.I18n.t("Copy to clipboard")},`b${d.length}`)),d.push(J)}else d.push(c)}),b(d)})}).catch(m=>window.alert(`Cannot get information about host "${t}": ${m}`))},[g,F,u,s,t]);const L=()=>e.jsx(e.Fragment,{children:p.map((m,n)=>typeof m=="object"?m:e.jsx(pt,{components:{em:({...i})=>e.jsx(o.IconButton,{style:x.copyButtonSmall,onClick:()=>D(i.children[0].toString()),children:e.jsx(h.IconCopy,{})}),a:({children:i,...l})=>e.jsx("a",{style:{color:"inherit"},...l,children:i}),code:({children:i,ref:l,...a})=>e.jsx(o.Box,{component:"code",sx:x.code,ref:l,...a,children:i})},children:m},`t_${n}`))}),X=()=>e.jsxs(o.Card,{style:x.root,children:[e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("Due to the different hardware and platforms under which ioBroker runs, the js-controller has to be updated manually. Further details can be found in the appropriate section.")}),e.jsx(o.Box,{component:"h2",sx:x.h2,children:h.I18n.t("General information for all platforms")}),e.jsxs(o.Box,{component:"div",sx:x.standardText,children:[h.I18n.t("For an update from js-controller 1.x to 2.x please always read the information at")," ",e.jsx("a",{href:"https://forum.iobroker.net/topic/26759/js-controller-2-jetzt-f%C3%BCr-alle-im-stable",target:"_blank",rel:"noreferrer",children:"forum"}),"."]}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("Otherwise please update the slaves first with an update of master-slave systems and the master last!")}),F!=="win32"&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{component:"h2",sx:x.h2,children:h.I18n.t("Linux/macOS (new installer)")}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("This is the recommended option")}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("Please execute the following commands in an SSH shell (console):")}),e.jsxs("pre",{style:x.pre,children:[e.jsx(o.IconButton,{size:"small",onClick:()=>{window.alert(h.I18n.t("Copied")),D(`iob backup
|
|
6
|
+
iob stop
|
|
7
|
+
iob update
|
|
8
|
+
iob upgrade self
|
|
9
|
+
iob start`)},style:x.copyButton,children:e.jsx(h.IconCopy,{})}),e.jsx("div",{style:x.standardTextSmall,children:"iob backup"}),e.jsx("div",{style:x.standardTextSmall,children:"iob stop"}),e.jsx("div",{style:x.standardTextSmall,children:"iob update"}),e.jsx("div",{style:x.standardTextSmall,children:"iob fix"}),e.jsx("div",{style:x.standardTextSmall,children:"iob upgrade self"}),e.jsx("div",{style:x.standardTextSmall,children:"iob start"})]}),e.jsx("div",{style:x.standardTextSmall2,children:h.I18n.t("or reboot server, then ioBroker should restart and you can be sure that all old processes were finished.")}),e.jsx("div",{style:x.standardTextSmall2,children:h.I18n.t("If the upgrade command displays Access Rights / Permission errors, then please use the install fixer")}),e.jsxs("pre",{style:x.pre,children:[e.jsx(o.IconButton,{size:"small",onClick:()=>{window.alert(h.I18n.t("Copied")),D("curl -sL https://iobroker.net/fix.sh | bash -")},style:x.copyButton,children:e.jsx(h.IconCopy,{})}),e.jsx("div",{style:x.standardTextSmall,children:"curl -sL https://iobroker.net/fix.sh | bash -"})]}),e.jsx("div",{style:x.standardTextSmall2,children:h.I18n.t("to fix these issues and upgrade command run again.")}),e.jsx(o.Box,{component:"h2",sx:x.h2,children:h.I18n.t("Linux/macOS (manually installed)")}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t('A manual installation usually takes place under root as user and therefore a "sudo" is necessary before the commands.')}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("Please execute the following commands in an SSH shell (console):")}),e.jsxs("pre",{style:x.pre,children:[e.jsx(o.IconButton,{size:"small",onClick:()=>{window.alert(h.I18n.t("Copied")),D(`cd ${g||"/opt/iobroker"}
|
|
10
|
+
iob backup
|
|
11
|
+
iob stop
|
|
12
|
+
iob update
|
|
13
|
+
iob fix
|
|
14
|
+
iob upgrade self
|
|
15
|
+
iob start
|
|
16
|
+
`)},style:x.copyButton,children:e.jsx(h.IconCopy,{})}),e.jsxs("div",{style:x.standardTextSmall,children:["cd",g||"/opt/iobroker"]}),e.jsx("div",{style:x.standardTextSmall,children:"iob backup"}),e.jsx("div",{style:x.standardTextSmall,children:"iob stop"}),e.jsx("div",{style:x.standardTextSmall,children:"iob fix"}),e.jsx("div",{style:x.standardTextSmall,children:"iob update"}),e.jsx("div",{style:x.standardTextSmall,children:"iob upgrade self"}),e.jsx("div",{style:x.standardTextSmall,children:"iob start"})]}),e.jsx("div",{style:x.standardTextSmall2,children:h.I18n.t("or reboot server, then ioBroker should restart and you can be sure that all old processes were finished.")}),e.jsx("div",{style:x.standardTextSmall2,children:h.I18n.t('If the upgrade command displays permissions / permissions errors, fix them. Sometimes "sudo" is not enough and you have to run the installation as a real root (previously simply sudo su -).')})]}),F==="win32"&&e.jsxs(e.Fragment,{children:[e.jsx(o.Box,{component:"h2",sx:x.h2,children:h.I18n.t("Windows")}),e.jsxs(o.Box,{component:"div",sx:x.standardText,children:[h.I18n.t("For updating ioBroker on Windows, download the appropriate installer with the desired js-controller version from the download page "),e.jsx("a",{rel:"noreferrer",href:"https://www.iobroker.net/#en/download",target:"_blank",children:"https://www.iobroker.net/#en/download"}),h.I18n.t(" and make the update with it. With the Windows Installer, previously manually installed servers or installations from other operating systems can be migrated to Windows and updated.")]}),e.jsx(o.Box,{component:"h2",sx:x.h2,children:h.I18n.t("Windows (manually installed)")}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("A manual installation is done with administrator rights. Please start a cmd.exe command line window as an administrator (right-click on cmd.exe and execute as administrator) and execute the following commands:")}),e.jsxs("pre",{style:x.pre,children:[e.jsx(o.IconButton,{size:"small",onClick:()=>{window.alert(h.I18n.t("Copied")),D(`cd ${(g||"C:\\iobroker").replace(/\//g,"\\")}
|
|
17
|
+
iob backup
|
|
18
|
+
iob stop
|
|
19
|
+
iob status
|
|
20
|
+
iob update
|
|
21
|
+
iob upgrade self
|
|
22
|
+
`)},style:x.copyButton,children:e.jsx(h.IconCopy,{})}),e.jsxs("div",{style:x.standardTextSmall,children:["cd",(g||"C:\\iobroker").replace(/\//g,"\\")," ",g?null:h.I18n.t("(or where ioBroker was installed)")]}),e.jsx("div",{style:x.standardTextSmall,children:"iob backup"}),e.jsxs("div",{style:x.standardTextSmall,children:["iob stop",h.I18n.t("to stop the ioBroker service")]}),e.jsxs("div",{style:x.standardTextSmall,children:["iob status",h.I18n.t("to check if ioBroker has finished")]}),e.jsx("div",{style:x.standardTextSmall,children:"iob update"}),e.jsx("div",{style:x.standardTextSmall,children:"iob upgrade self"})]}),e.jsx("div",{style:x.standardTextSmall2,children:h.I18n.t("Start ioBroker service or reboot computer, then ioBroker should restart and you can be sure that all the old processes were finished.")})]}),e.jsxs(o.Accordion,{style:{paddingTop:14},children:[e.jsx(o.AccordionSummary,{sx:x.accordionSummary,expandIcon:e.jsx(y.ExpandMore,{}),children:e.jsx(o.Box,{component:"h2",sx:x.h22,children:h.I18n.t("Emergency Linux / macOS / Windows")})}),e.jsxs(o.AccordionDetails,{style:x.accordionDetails,children:[e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("(manual reinstallation, if somehow nothing works after the update)")}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t('On Windows first please call in the start menu under "ioBroker" the command line of the relevant ioBroker instance. The correct directory is then set automatically. On Linux or macOS please go to the ioBroker directory.')}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("Run npm install iobroker.js-controller there. A specific version can be installed using npm install iobroker.js-controller@x.y.z (replace x.y.z with the desired version).")}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("If there are problems with access rights when running on Linux the command has to be changed slightly:")}),e.jsx("div",{style:x.standardTextSmall2,children:h.I18n.t("For systems created with the new Linux installer:")}),e.jsxs("pre",{style:x.pre,children:[e.jsx(o.IconButton,{size:"small",onClick:()=>{window.alert(h.I18n.t("Copied")),D(`cd ${F==="win32"?(g||"C:\\iobroker").replace(/\//g,"\\"):g||"/opt/iobroker"}
|
|
23
|
+
sudo -u iobroker -H npm install iobroker.js-controller`)},style:x.copyButton,children:e.jsx(h.IconCopy,{})}),e.jsxs("div",{style:x.standardTextSmall,children:["cd",F==="win32"?(g||"C:\\iobroker").replace(/\//g,"\\"):g||"/opt/iobroker"]}),e.jsx("div",{style:x.standardTextSmall,children:"sudo -u iobroker -H npm install iobroker.js-controller"})]}),e.jsx("div",{style:x.standardTextSmall2,children:h.I18n.t("For systems installed manually under Linux, prefix sudo or run as root.")}),e.jsx(o.Box,{component:"div",sx:x.standardText,children:h.I18n.t("This way is only necessary in very few cases and please consult the forum beforehand!")})]})]})]});return e.jsxs(o.Dialog,{onClose:()=>r(),open:!0,sx:{"& .MuiDialog-paper":x.paper},children:[e.jsx(o.DialogTitle,{children:h.I18n.t("js-controller upgrade instructions")}),e.jsx(o.DialogContent,{style:p?null:x.overflowHidden,dividers:!0,children:p?L():X()}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{id:"js-controller-dialog-changelog",variant:"contained",onClick:()=>{window.open(tt,"_blank")},color:"grey",startIcon:e.jsx(y.Description,{}),children:h.I18n.t("Show whole changelog")}),e.jsx(o.Button,{id:"js-controller-dialog-ok",variant:"contained",onClick:()=>r(),color:"primary",startIcon:e.jsx(y.Close,{}),children:h.I18n.t("Ok")})]})]})},P={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:"calc(100% - 16px)",marginBottom:16,marginRight:8,marginLeft:8},RAM:{width:400,marginRight:8}};class kt extends T.Component{focusRef;constructor(t){super(t);const s=this.props.settings||{};this.state={memoryLimitMB:s.memoryLimitMB||0,hostname:s.hostname||"",statisticsInterval:s.statisticsInterval||15e3,checkDiskInterval:s.checkDiskInterval||3e5,instanceStartInterval:s.instanceStartInterval||2e3,compact:s.compact||!1,allowShellCommands:s.allowShellCommands||!1,memLimitWarn:s.memLimitWarn||100,memLimitError:s.memLimitError||50,noChmod:s.noChmod||!1},this.focusRef=T.createRef()}componentDidMount(){var t;(t=this.focusRef.current)==null||t.focus()}onChange(){this.props.onChange({memoryLimitMB:this.state.memoryLimitMB,hostname:this.state.hostname,statisticsInterval:this.state.statisticsInterval,checkDiskInterval:this.state.checkDiskInterval,noChmod:this.state.noChmod,instanceStartInterval:this.state.instanceStartInterval,compact:this.state.compact,allowShellCommands:this.state.allowShellCommands,memLimitWarn:this.state.memLimitWarn,memLimitError:this.state.memLimitError})}render(){return e.jsx(o.Paper,{style:P.paper,children:e.jsx(o.Grid2,{style:P.gridSettings,children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",label:this.props.t("Host name"),style:P.controlItem,value:this.state.hostname||this.props.currentHost.replace("system.host.",""),onChange:t=>this.setState({hostname:t.target.value},()=>this.onChange()),helperText:this.props.t("You can change the host name, but be aware, that all instances must be assigned anew")})}),e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",label:this.props.t("Check disk space interval"),style:P.controlItem,value:this.state.checkDiskInterval,type:"number",slotProps:{htmlInput:{min:1e3}},onChange:t=>this.setState({checkDiskInterval:parseInt(t.target.value,10)},()=>this.onChange()),helperText:this.props.t("How oft the disk will be checked. Do not set it to low, because it can affect system performance. Value is in ms")})}),e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",label:this.props.t("Instance statistics update interval"),style:P.controlItem,value:this.state.statisticsInterval,type:"number",slotProps:{htmlInput:{min:5e3}},onChange:t=>this.setState({statisticsInterval:parseInt(t.target.value,10)},()=>this.onChange()),helperText:this.props.t("How oft the instance statistics will be updated. Used RAM, CPU and so on. Value is in ms")})}),e.jsxs(o.Grid2,{style:P.controlItem,children:[e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.compact,onChange:t=>this.setState({compact:t.target.checked},()=>this.onChange())}),label:this.props.t("Compact mode")}),e.jsx("div",{children:this.props.t("When enabled adapter instances can run in one or few processes to save RAM usage.")})]}),e.jsxs(o.Grid2,{style:P.controlItem,children:[e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.allowShellCommands,onChange:t=>this.setState({allowShellCommands:t.target.checked},()=>this.onChange())}),label:this.props.t("Allow shell's commands")}),e.jsx("div",{children:this.props.t('Allow execution of sendToHost("shell", "cli command")')})]}),e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",label:this.props.t("Limit RAM size for controller"),style:P.controlItem,value:this.state.memoryLimitMB,type:"number",onChange:t=>this.setState({memoryLimitMB:parseInt(t.target.value,10)},()=>this.onChange()),helperText:this.props.t("MB")})}),e.jsx(o.Grid2,{children:e.jsxs(o.Grid2,{container:!0,direction:"row",style:P.controlItem,children:[e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",label:this.props.t("Show warning im log if RAM less than"),style:P.RAM,value:this.state.memLimitWarn,type:"number",onChange:t=>this.setState({memLimitWarn:parseInt(t.target.value,10)},()=>this.onChange()),helperText:this.props.t("MB")})}),e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",label:this.props.t("Show error in log if RAM less than"),style:P.RAM,value:this.state.memLimitError,type:"number",onChange:t=>this.setState({memLimitError:parseInt(t.target.value,10)},()=>this.onChange()),helperText:this.props.t("MB")})})]})})]})})})}}const E={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:"calc(100% - 16px)",marginBottom:16,marginRight:8,marginLeft:8}};class Tt extends T.Component{focusRef;constructor(t){super(t);const s=this.props.settings||{};this.state={enabled:s.enabled||!1,secure:s.secure||!0,password:""},s.password&&this.props.socket.decrypt(s.password).then(r=>this.setState({password:r})),this.focusRef=T.createRef()}componentDidMount(){var t;(t=this.focusRef.current)==null||t.focus()}onChange(){const t={enabled:this.state.enabled,secure:this.state.secure};this.state.password?this.props.socket.encrypt(this.state.password).then(s=>{t.password=s,this.props.onChange(t)}):this.props.onChange(t)}render(){return e.jsx(o.Paper,{style:E.paper,children:e.jsx("form",{style:E.form,noValidate:!0,autoComplete:"off",children:e.jsx(o.Grid2,{style:E.gridSettings,children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[e.jsxs(o.Grid2,{style:E.controlItem,children:[e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.enabled,onChange:t=>this.setState({enabled:t.target.checked},()=>this.onChange())}),label:this.props.t("Allow slave connections")}),e.jsx("div",{children:this.props.t("When activated this host can be discovered by other iobroker installations in your network to become the master of a multihost system.")})]}),e.jsxs(o.Grid2,{style:E.controlItem,children:[e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.secure,onChange:t=>this.setState({secure:t.target.checked},()=>this.onChange())}),label:this.props.t("With password")}),e.jsx("div",{children:this.props.t("Ask password by connection establishment")})]}),this.state.secure?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",label:this.props.t("Multi-host password"),style:E.controlItem,value:this.state.password,type:"password",slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({password:t.target.value},()=>this.onChange())})}):null]})})})})}}const I={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},dangerZone:{backgroundColor:"rgba(255, 165, 0, 0.05)",border:"2px solid rgba(255, 165, 0)",marginBottom:8},dangerZoneHeader:{background:"rgba(255, 165, 0)",color:"#FFF",paddingLeft:16,paddingTop:4,paddingBottom:4,marginTop:-1,marginLeft:-1},warning:u=>({p:1,fontSize:14,color:u.palette.mode==="dark"?"#ffa500":"#b17200"})},K=9001,Q={autoCompress:{sizeFactor:2,sizeFactorMinimumSize:25e3},throttleFS:{intervalMs:6e4,maxBufferedCommands:1e3}};class G extends T.Component{focusRef;constructor(t){super(t);const s=this.props.settings||{};s.options||={auth_pass:"",retry_max_delay:2e3,retry_max_count:19,db:0,family:0},s.backup||={disabled:!1,files:24,hours:48,period:120,path:""},s.jsonlOptions||=Q,s.jsonlOptions.autoCompress||=Q.autoCompress,s.jsonlOptions.throttleFS||=Q.throttleFS,this.state={type:s.type||"file",host:Array.isArray(s.host)?s.host.join(","):s.host||"127.0.0.1",port:s.port||K,connectTimeout:s.connectTimeout||2e3,writeFileInterval:s.writeFileInterval||5e3,dataDir:s.dataDir||"",options_auth_pass:s.options.auth_pass||s.pass||"",options_retry_max_delay:s.options.retry_max_delay||2e3,options_retry_max_count:s.options.retry_max_count||19,options_db:s.options.db||0,options_family:s.options.family||0,backup_disabled:s.backup.disabled||!1,backup_files:s.backup.files||24,backup_hours:s.backup.hours||48,backup_period:s.backup.period||120,backup_path:s.backup.path||"",jsonlOptions_autoCompress_sizeFactor:s.jsonlOptions.autoCompress.sizeFactor||2,jsonlOptions_autoCompress_sizeFactorMinimumSize:s.jsonlOptions.autoCompress.sizeFactorMinimumSize||25e3,jsonlOptions_throttleFS_intervalMs:s.jsonlOptions.throttleFS.intervalMs||6e4,jsonlOptions_throttleFS_maxBufferedCommands:s.jsonlOptions.throttleFS.maxBufferedCommands||100,textIP:G.calculateTextIP(Array.isArray(s.host)?s.host.join(","):s.host||"127.0.0.1"),IPs:["0.0.0.0","127.0.0.1"],loading:!0,showWarningDialog:!1,toConfirmType:"",originalDBType:s.type||"file",noFileCache:s.noFileCache||!1},this.focusRef=T.createRef()}static calculateTextIP(t,s){return Array.isArray(t)||!!t.match(/[^.\d]/)||t.includes(",")?!0:s?!s.includes(t):!1}componentDidMount(){this.props.socket.getIpAddresses(this.props.currentHost).then(t=>{const s=[...t];s.includes("0.0.0.0")||s.push("0.0.0.0"),s.includes("127.0.0.1")||s.push("127.0.0.1");const r=G.calculateTextIP(this.state.host,s);this.setState({IPs:s,loading:!1,textIP:r},()=>this.focusRef.current&&this.focusRef.current.focus())})}componentDidUpdate(t){if(t.settings!==this.props.settings){const s=this.props.settings||{},r=Array.isArray(s.host)?s.host.join(","):s.host||"127.0.0.1";if(r!==this.state.host){const p=G.calculateTextIP(r,this.state.IPs);this.setState({host:r,textIP:p})}}}onChange(){const t={type:this.state.type,host:this.state.host,port:parseInt(this.state.port,10),noFileCache:this.state.noFileCache,connectTimeout:parseInt(this.state.connectTimeout,10),writeFileInterval:parseInt(this.state.writeFileInterval,10),dataDir:this.state.dataDir,options:{auth_pass:this.state.options_auth_pass||null,retry_max_delay:parseInt(this.state.options_retry_max_delay,10),retry_max_count:parseInt(this.state.options_retry_max_count,10),db:parseInt(this.state.options_db,10),family:parseInt(this.state.options_family,10)},backup:{disabled:this.state.backup_disabled,files:parseInt(this.state.backup_files,10),hours:parseInt(this.state.backup_hours,10),period:parseInt(this.state.backup_period,10),path:this.state.backup_path},jsonlOptions:{autoCompress:{sizeFactor:parseInt(this.state.jsonlOptions_autoCompress_sizeFactor,10),sizeFactorMinimumSize:parseInt(this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,10)},throttleFS:{intervalMs:parseInt(this.state.jsonlOptions_throttleFS_intervalMs,10),maxBufferedCommands:parseInt(this.state.jsonlOptions_throttleFS_maxBufferedCommands,10)}}};t.jsonlOptions.autoCompress.sizeFactor<2&&(t.jsonlOptions.autoCompress.sizeFactor=2),t.jsonlOptions.autoCompress.sizeFactorMinimumSize<0&&(t.jsonlOptions.autoCompress.sizeFactorMinimumSize=0),t.jsonlOptions.throttleFS.intervalMs<0&&(t.jsonlOptions.throttleFS.intervalMs=0),t.jsonlOptions.throttleFS.maxBufferedCommands<0&&(t.jsonlOptions.throttleFS.maxBufferedCommands=0),this.props.onChange(t)}renderWarning(){return this.state.showWarningDialog?e.jsx(h.DialogConfirm,{title:this.props.t("Please confirm"),text:this.props.t("switch_db_note"),onClose:t=>{if(t){let s;this.state.toConfirmType==="redis"?s=6379:s=K,this.setState({type:this.state.toConfirmType||"file",showWarningDialog:!1,port:s},()=>this.onChange())}else this.setState({showWarningDialog:!1})}}):null}render(){return e.jsxs(o.Paper,{style:I.paper,children:[this.state.loading?e.jsx(o.LinearProgress,{}):null,this.renderWarning(),e.jsxs(o.Grid2,{style:{...I.gridSettings,...I.dangerZone},children:[e.jsx("h3",{style:I.dangerZoneHeader,title:this.props.t("Invalid settings in these fields could lead to dead host"),children:this.props.t("Danger zone")}),e.jsx(o.Box,{component:"p",sx:I.warning,children:this.props.t("base_settings_hint")}),e.jsxs(o.Grid2,{container:!0,direction:"column",children:[e.jsx(o.Grid2,{children:e.jsx(o.Tooltip,{title:this.props.t("switch_db_note"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:e.jsxs(o.FormControl,{style:I.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Type")}),e.jsxs(o.Select,{variant:"standard",value:this.state.type,onChange:t=>{if(t.target.value!==this.state.originalDBType)this.setState({toConfirmType:t.target.value,showWarningDialog:!0});else{let s;t.target.value==="redis"?s=6379:s=K,this.setState({type:t.target.value,port:s},()=>this.onChange())}},children:[e.jsx(o.MenuItem,{value:"jsonl",children:"JSON Lines"}),e.jsx(o.MenuItem,{value:"file",children:this.props.t("File")}),e.jsx(o.MenuItem,{value:"redis",children:"Redis"})]})]})})}),e.jsx(o.Grid2,{style:{paddingLeft:8},children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Switch,{checked:this.state.textIP,onChange:t=>this.setState({textIP:t.target.checked},()=>this.onChange())}),label:this.props.t("IP is domain or more than one address")})}),e.jsx(o.Grid2,{children:this.state.textIP?e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.host,type:"text",onChange:t=>this.setState({host:t.target.value},()=>this.onChange()),label:this.props.t("Bind IP address"),helperText:this.props.t("You can enter more than one address divided by comma")}):e.jsxs(o.FormControl,{style:I.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Bind IP address")}),e.jsx(o.Select,{variant:"standard",value:this.state.host,onChange:t=>this.setState({host:t.target.value},()=>this.onChange()),children:this.state.IPs.map(t=>e.jsx(o.MenuItem,{value:t,children:t==="0.0.0.0"?`0.0.0.0 [${this.props.t("All addresses")}]`:t},t))})]})}),e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.port,type:"number",slotProps:{htmlInput:{min:1,max:65535}},onChange:t=>this.setState({port:t.target.value},()=>this.onChange()),label:this.props.t("Port")})}),this.state.type==="file"||this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.dataDir,helperText:this.props.t("Optional. Always relative to iobroker.js-controller/"),onChange:t=>this.setState({dataDir:t.target.value},()=>this.onChange()),label:this.props.t("Directory path")})}):null,e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.options_auth_pass,type:"password",helperText:this.props.t("Optional"),slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({options_auth_pass:t.target.value},()=>this.onChange()),label:this.state.type==="redis"?this.props.t("Redis password"):this.props.t("Connection password")})})]})]}),e.jsx(o.Grid2,{style:I.gridSettings,children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[this.state.type==="file"||this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.connectTimeout,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({connectTimeout:t.target.value},()=>this.onChange()),label:this.props.t("Connect timeout")})}):null,this.state.type==="file"||this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{component:"fieldset",variant:"standard",style:I.controlItem,children:[e.jsx(o.FormGroup,{children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.noFileCache,onChange:t=>this.setState({noFileCache:t.target.checked},()=>this.onChange())}),label:this.props.t("No file cache")})}),e.jsx(o.FormHelperText,{children:this.props.t("Always read files from disk and do not cache them in RAM. Used for debugging.")})]})}):null,this.state.type==="file"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.writeFileInterval,helperText:this.props.t("How often the data from RAM will be saved on disk in ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({writeFileInterval:t.target.value},()=>this.onChange()),label:this.props.t("Store file interval")})}):null,this.state.type==="redis"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.options_retry_max_delay,type:"number",helperText:this.props.t("Maximum delay between connection attempts"),onChange:t=>this.setState({options_retry_max_delay:t.target.value},()=>this.onChange()),label:this.props.t("Retry maximum delay")})}):null,this.state.type==="redis"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.options_retry_max_count,type:"number",helperText:this.props.t("Maximum number of connection retries"),onChange:t=>this.setState({options_retry_max_count:t.target.value},()=>this.onChange()),label:this.props.t("Retry maximum count")})}):null,this.state.type==="redis"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.options_db,type:"number",helperText:this.props.t("Used for sentinels"),onChange:t=>this.setState({options_db:t.target.value},()=>this.onChange()),label:this.props.t("DB number")})}):null,this.state.type==="redis"?e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{style:I.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Family number")}),e.jsxs(o.Select,{variant:"standard",value:this.state.options_family,onChange:t=>this.setState({options_family:t.target.value},()=>this.onChange()),children:[e.jsx(o.MenuItem,{value:0,children:"auto"}),e.jsx(o.MenuItem,{value:4,children:"IPv4"}),e.jsx(o.MenuItem,{value:6,children:"IPv6"})]}),e.jsx(o.FormHelperText,{children:this.props.t("Used for sentinels")})]})}):null,this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactor,type:"number",slotProps:{htmlInput:{min:2}},helperText:this.props.t("The JSONL DB is append-only and will contain unnecessary entries after a while."),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactor:t.target.value},()=>this.onChange()),label:this.props.t("Auto-compress size factor")})}):null,this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("It will be compressed when the uncompressed size is >= size * sizeFactor AND >= sizeFactorMinimumSize"),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactorMinimumSize:t.target.value},()=>this.onChange()),label:this.props.t("Auto-compress size factor minimum size")})}):null,this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.jsonlOptions_throttleFS_intervalMs,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Write to the database file no more than every X milliseconds"),onChange:t=>this.setState({jsonlOptions_throttleFS_intervalMs:t.target.value},()=>this.onChange()),label:this.props.t("Minimal write interval")})}):null,this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.jsonlOptions_throttleFS_maxBufferedCommands,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Force writing after this many changes have been buffered. This reduces memory consumption and data loss in case of a crash"),onChange:t=>this.setState({jsonlOptions_throttleFS_maxBufferedCommands:t.target.value},()=>this.onChange()),label:this.props.t("Maximum changes before write")})}):null,this.state.type==="file"||this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{component:"fieldset",style:I.controlItem,variant:"standard",children:[e.jsx(o.FormGroup,{children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.backup_disabled,onChange:t=>this.setState({backup_disabled:t.target.checked},()=>this.onChange())}),label:this.props.t("No on-the-fly backup")})}),e.jsx(o.FormHelperText,{children:this.props.t("By every write the backup of object.json will be created.")})]})}):null,(this.state.type==="file"||this.state.type==="jsonl")&&!this.state.backup_disabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.backup_files,type:"number",helperText:this.props.t("Minimal number of backup files, after the deletion will be executed according to the backup time settings"),onChange:t=>this.setState({backup_files:t.target.value},()=>this.onChange()),label:this.props.t("Number of files")})}):null,(this.state.type==="file"||this.state.type==="jsonl")&&!this.state.backup_disabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.backup_hours,type:"number",helperText:this.props.t("All backups older than these hours will be deleted, but only if the number of files is greater than of the files number"),onChange:t=>this.setState({backup_hours:t.target.value},()=>this.onChange()),label:this.props.t("Backup hours")})}):null,(this.state.type==="file"||this.state.type==="jsonl")&&!this.state.backup_disabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.backup_period,type:"number",helperText:this.props.t("By default the backup is every 2 hours. Time is in minutes. To disable backup set the value to 0"),onChange:t=>this.setState({backup_period:t.target.value},()=>this.onChange()),label:this.props.t("How often")})}):null,(this.state.type==="file"||this.state.type==="jsonl")&&!this.state.backup_disabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:I.controlItem,value:this.state.backup_path,helperText:this.props.t("Absolute path to backup directory or empty to backup in data directory. Leave it empty for default storage place."),onChange:t=>this.setState({backup_path:t.target.value},()=>this.onChange()),label:this.props.t("Path")})}):null]})})]})}}const S={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},dangerZone:{backgroundColor:"rgba(255, 165, 0, 0.05)",border:"2px solid rgba(255, 165, 0)",marginBottom:8},dangerZoneHeader:{background:"rgba(255, 165, 0)",color:"#FFF",paddingLeft:16,paddingTop:4,paddingBottom:4,marginTop:-1,marginLeft:-1},warning:u=>({p:1,fontSize:14,color:u.palette.mode==="dark"?"#ffa500":"#b17200"})},Z=9e3,Y={autoCompress:{sizeFactor:2,sizeFactorMinimumSize:25e3},throttleFS:{intervalMs:6e4,maxBufferedCommands:1e3}};class U extends T.Component{focusRef;constructor(t){super(t);const s=this.props.settings||{};s.options||={auth_pass:"",retry_max_delay:2e3,retry_max_count:19,db:0,family:0},s.backup||={disabled:!1,files:24,hours:48,period:120,path:""},s.jsonlOptions||=Y,s.jsonlOptions.autoCompress||=Y.autoCompress,s.jsonlOptions.throttleFS||=Y.throttleFS,this.state={type:s.type||"file",host:Array.isArray(s.host)?s.host.join(","):s.host||"127.0.0.1",port:s.port||Z,connectTimeout:s.connectTimeout||2e3,writeFileInterval:s.writeFileInterval||5e3,dataDir:s.dataDir||"",options_auth_pass:s.options.auth_pass||s.pass||"",options_retry_max_delay:s.options.retry_max_delay||2e3,options_retry_max_count:s.options.retry_max_count||19,options_db:s.options.db||0,options_family:s.options.family||0,backup_disabled:s.backup.disabled||!1,backup_files:s.backup.files||24,backup_hours:s.backup.hours||48,backup_period:s.backup.period||120,backup_path:s.backup.path||"",jsonlOptions_autoCompress_sizeFactor:s.jsonlOptions.autoCompress.sizeFactor||2,jsonlOptions_autoCompress_sizeFactorMinimumSize:s.jsonlOptions.autoCompress.sizeFactorMinimumSize||25e3,jsonlOptions_throttleFS_intervalMs:s.jsonlOptions.throttleFS.intervalMs||6e4,jsonlOptions_throttleFS_maxBufferedCommands:s.jsonlOptions.throttleFS.maxBufferedCommands||100,textIP:U.calculateTextIP(Array.isArray(s.host)?s.host.join(","):s.host||"127.0.0.1"),IPs:["0.0.0.0","127.0.0.1"],loading:!0,showWarningDialog:!1,toConfirmType:"",originalDBType:s.type||"file",noFileCache:s.noFileCache||!1},this.focusRef=T.createRef()}static calculateTextIP(t,s){return Array.isArray(t)||!!t.match(/[^.\d]/)||t.includes(",")?!0:s?!s.includes(t):!1}componentDidMount(){this.props.socket.getIpAddresses(this.props.currentHost).then(t=>{const s=[...t];s.includes("0.0.0.0")||s.push("0.0.0.0"),s.includes("127.0.0.1")||s.push("127.0.0.1");const r=U.calculateTextIP(Array.isArray(this.state.host)?this.state.host[0]:this.state.host,s);this.setState({IPs:s,loading:!1,textIP:r},()=>this.focusRef.current&&this.focusRef.current.focus())})}componentDidUpdate(t){if(t.settings!==this.props.settings){const s=this.props.settings||{},r=Array.isArray(s.host)?s.host.join(","):s.host||"127.0.0.1";if(r!==this.state.host){const p=U.calculateTextIP(r,this.state.IPs);this.setState({host:r,textIP:p})}}}onChange(){const t={type:this.state.type,host:this.state.host,port:parseInt(this.state.port,10),noFileCache:this.state.noFileCache,connectTimeout:parseInt(this.state.connectTimeout,10),writeFileInterval:parseInt(this.state.writeFileInterval,10),dataDir:this.state.dataDir,options:{auth_pass:this.state.options_auth_pass||null,retry_max_delay:parseInt(this.state.options_retry_max_delay,10),retry_max_count:parseInt(this.state.options_retry_max_count,10),db:parseInt(this.state.options_db,10),family:parseInt(this.state.options_family,10)},backup:{disabled:this.state.backup_disabled,files:parseInt(this.state.backup_files,10),hours:parseInt(this.state.backup_hours,10),period:parseInt(this.state.backup_period,10),path:this.state.backup_path},jsonlOptions:{autoCompress:{sizeFactor:parseInt(this.state.jsonlOptions_autoCompress_sizeFactor,10),sizeFactorMinimumSize:parseInt(this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,10)},throttleFS:{intervalMs:parseInt(this.state.jsonlOptions_throttleFS_intervalMs,10),maxBufferedCommands:parseInt(this.state.jsonlOptions_throttleFS_maxBufferedCommands,10)}}};t.jsonlOptions.autoCompress.sizeFactor<2&&(t.jsonlOptions.autoCompress.sizeFactor=2),t.jsonlOptions.autoCompress.sizeFactorMinimumSize<0&&(t.jsonlOptions.autoCompress.sizeFactorMinimumSize=0),t.jsonlOptions.throttleFS.intervalMs<0&&(t.jsonlOptions.throttleFS.intervalMs=0),t.jsonlOptions.throttleFS.maxBufferedCommands<0&&(t.jsonlOptions.throttleFS.maxBufferedCommands=0),this.props.onChange(t)}renderWarning(){return this.state.showWarningDialog?e.jsx(h.DialogConfirm,{title:this.props.t("Please confirm"),text:this.props.t("switch_db_note"),onClose:t=>{if(t){let s;this.state.toConfirmType==="redis"?s=6379:s=Z,this.setState({type:this.state.toConfirmType||"file",showWarningDialog:!1,port:s},()=>this.onChange())}else this.setState({showWarningDialog:!1})}}):null}render(){return e.jsxs(o.Paper,{style:S.paper,children:[this.state.loading?e.jsx(o.LinearProgress,{}):null,this.renderWarning(),e.jsxs(o.Grid2,{style:{...S.gridSettings,...S.dangerZone},children:[e.jsx("h3",{style:S.dangerZoneHeader,title:this.props.t("Invalid settings in these fields could lead to dead host"),children:this.props.t("Danger zone")}),e.jsx(o.Box,{component:"p",sx:S.warning,children:this.props.t("base_settings_hint")}),e.jsxs(o.Grid2,{container:!0,direction:"column",children:[e.jsx(o.Grid2,{children:e.jsx(o.Tooltip,{title:this.props.t("switch_db_note"),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:e.jsxs(o.FormControl,{style:S.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Type")}),e.jsxs(o.Select,{variant:"standard",value:this.state.type,onChange:t=>{if(t.target.value!==this.state.originalDBType)this.setState({toConfirmType:t.target.value,showWarningDialog:!0});else{let s;t.target.value==="redis"?s=6379:s=Z,this.setState({type:t.target.value,port:s},()=>this.onChange())}},children:[e.jsx(o.MenuItem,{value:"jsonl",children:"JSON Lines"}),e.jsx(o.MenuItem,{value:"file",children:this.props.t("File")}),e.jsx(o.MenuItem,{value:"redis",children:"Redis"})]})]})})}),e.jsx(o.Grid2,{style:{paddingLeft:8},children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Switch,{checked:this.state.textIP,onChange:t=>this.setState({textIP:t.target.checked},()=>this.onChange())}),label:this.props.t("IP is domain or more than one address")})}),e.jsx(o.Grid2,{children:this.state.textIP?e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.host,type:"text",onChange:t=>this.setState({host:t.target.value},()=>this.onChange()),label:this.props.t("Bind IP address"),helperText:this.props.t("You can enter more than one address divided by comma")}):e.jsxs(o.FormControl,{style:S.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Bind IP address")}),e.jsx(o.Select,{variant:"standard",value:this.state.host,onChange:t=>this.setState({host:t.target.value},()=>this.onChange()),children:this.state.IPs.map(t=>e.jsx(o.MenuItem,{value:t,children:t==="0.0.0.0"?`0.0.0.0 [${this.props.t("All addresses")}]`:t},t))})]})}),e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.port,type:"number",slotProps:{htmlInput:{min:1,max:65535}},onChange:t=>this.setState({port:t.target.value},()=>this.onChange()),label:this.props.t("Port")})}),this.state.type==="file"||this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.dataDir,helperText:this.props.t("Optional. Always relative to iobroker.js-controller/"),onChange:t=>this.setState({dataDir:t.target.value},()=>this.onChange()),label:this.props.t("Directory path")})}):null,e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.options_auth_pass,type:"password",helperText:this.props.t("Optional"),slotProps:{input:{autoComplete:"new-password"},htmlInput:{autoComplete:"off"}},autoComplete:"off",onChange:t=>this.setState({options_auth_pass:t.target.value},()=>this.onChange()),label:this.state.type==="redis"?this.props.t("Redis password"):this.props.t("Connection password")})})]})]}),e.jsx(o.Grid2,{style:S.gridSettings,children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[this.state.type==="file"||this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.connectTimeout,helperText:this.props.t("ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({connectTimeout:t.target.value},()=>this.onChange()),label:this.props.t("Connect timeout")})}):null,this.state.type==="file"||this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{component:"fieldset",variant:"standard",style:S.controlItem,children:[e.jsx(o.FormGroup,{children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.noFileCache,onChange:t=>this.setState({noFileCache:t.target.checked},()=>this.onChange())}),label:this.props.t("No file cache")})}),e.jsx(o.FormHelperText,{children:this.props.t("Always read files from disk and do not cache them in RAM. Used for debugging.")})]})}):null,this.state.type==="file"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.writeFileInterval,helperText:this.props.t("How often the data from RAM will be saved on disk in ms"),type:"number",slotProps:{htmlInput:{min:200}},onChange:t=>this.setState({writeFileInterval:t.target.value},()=>this.onChange()),label:this.props.t("Store file interval")})}):null,this.state.type==="redis"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.options_retry_max_delay,type:"number",helperText:this.props.t("Maximum delay between connection attempts"),onChange:t=>this.setState({options_retry_max_delay:t.target.value},()=>this.onChange()),label:this.props.t("Retry maximum delay")})}):null,this.state.type==="redis"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.options_retry_max_count,type:"number",helperText:this.props.t("Maximum number of connection retries"),onChange:t=>this.setState({options_retry_max_count:t.target.value},()=>this.onChange()),label:this.props.t("Retry maximum count")})}):null,this.state.type==="redis"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.options_db,type:"number",helperText:this.props.t("Used for sentinels"),onChange:t=>this.setState({options_db:t.target.value},()=>this.onChange()),label:this.props.t("DB number")})}):null,this.state.type==="redis"?e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{style:S.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Family number")}),e.jsxs(o.Select,{variant:"standard",value:this.state.options_family,onChange:t=>this.setState({options_family:t.target.value},()=>this.onChange()),children:[e.jsx(o.MenuItem,{value:0,children:"auto"}),e.jsx(o.MenuItem,{value:4,children:"IPv4"}),e.jsx(o.MenuItem,{value:6,children:"IPv6"})]}),e.jsx(o.FormHelperText,{children:this.props.t("Used for sentinels")})]})}):null,this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactor,type:"number",slotProps:{htmlInput:{min:2}},helperText:this.props.t("The JSONL DB is append-only and will contain unnecessary entries after a while."),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactor:t.target.value},()=>this.onChange()),label:this.props.t("Auto-compress size factor")})}):null,this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.jsonlOptions_autoCompress_sizeFactorMinimumSize,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("It will be compressed when the uncompressed size is >= size * sizeFactor AND >= sizeFactorMinimumSize"),onChange:t=>this.setState({jsonlOptions_autoCompress_sizeFactorMinimumSize:t.target.value},()=>this.onChange()),label:this.props.t("Auto-compress size factor minimum size")})}):null,this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.jsonlOptions_throttleFS_intervalMs,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Write to the database file no more than every X milliseconds"),onChange:t=>this.setState({jsonlOptions_throttleFS_intervalMs:t.target.value},()=>this.onChange()),label:this.props.t("Minimal write interval")})}):null,this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.jsonlOptions_throttleFS_maxBufferedCommands,type:"number",slotProps:{htmlInput:{min:0}},helperText:this.props.t("Force writing after this many changes have been buffered. This reduces memory consumption and data loss in case of a crash"),onChange:t=>this.setState({jsonlOptions_throttleFS_maxBufferedCommands:t.target.value},()=>this.onChange()),label:this.props.t("Maximum changes before write")})}):null,this.state.type==="file"||this.state.type==="jsonl"?e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{component:"fieldset",style:S.controlItem,variant:"standard",children:[e.jsx(o.FormGroup,{children:e.jsx(o.FormControlLabel,{control:e.jsx(o.Checkbox,{checked:this.state.backup_disabled,onChange:t=>this.setState({backup_disabled:t.target.checked},()=>this.onChange())}),label:this.props.t("No on-the-fly backup")})}),e.jsx(o.FormHelperText,{children:this.props.t("By every write the backup of object.json will be created.")})]})}):null,(this.state.type==="file"||this.state.type==="jsonl")&&!this.state.backup_disabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.backup_files,type:"number",helperText:this.props.t("Minimal number of backup files, after the deletion will be executed according to the backup time settings"),onChange:t=>this.setState({backup_files:t.target.value},()=>this.onChange()),label:this.props.t("Number of files")})}):null,(this.state.type==="file"||this.state.type==="jsonl")&&!this.state.backup_disabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.backup_hours,type:"number",helperText:this.props.t("All backups older than these hours will be deleted, but only if the number of files is greater than of the files number"),onChange:t=>this.setState({backup_hours:t.target.value},()=>this.onChange()),label:this.props.t("Backup hours")})}):null,(this.state.type==="file"||this.state.type==="jsonl")&&!this.state.backup_disabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.backup_period,type:"number",helperText:this.props.t("By default the backup is every 2 hours. Time is in minutes. To disable backup set the value to 0"),onChange:t=>this.setState({backup_period:t.target.value},()=>this.onChange()),label:this.props.t("How often")})}):null,(this.state.type==="file"||this.state.type==="jsonl")&&!this.state.backup_disabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:S.controlItem,value:this.state.backup_path,helperText:this.props.t("Absolute path to backup directory or empty to backup in data directory. Leave it empty for default storage place."),onChange:t=>this.setState({backup_path:t.target.value},()=>this.onChange()),label:this.props.t("Path")})}):null]})})]})}}const nt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAbCAYAAADMIInqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAiPSURBVFhH7Zd7UFTXGcDPvXffy8IusMsbQUEgoyiKD4pBnoKgVkoRX1WpNia2QZ2MzFTS2MykmlqiMzWJqSUxJq1KG0VrE0GxqSgSNVEx4SEaAeXNLrDsLvve2+/cvQusgIHWf2jymzns+b5zLvd+3/nOd75DoGEsWJDLaWvrXsXhcH/S3a0ODArynqfRDLRptfo6qVRcRdOGww8fftbGTv+/YNAB/v4ZsSrVQJHBYAunaVb5BBwOMri58farVI9eR+iejVVPakj8x8dn6cKWlv5zev3YxmMsFiRQqYyv8fleb+XnH2CenexQ2JCqqroLRiMKYHWIzyctLi680ujo4Aa93nDfbDZ72WxIYB/FQUMsbG5+VNHf/6DRrpu8kFeu3EnRaKzhrIxEIq5ZLhdHqdUXMior31+mVJ5fFhKiiBCLqXp2CrJaETKbyTxWnNSQtbWP5w4Pe3d30cWWln9+w4oMdXV/bw8K8tgLZoNkYZpeb5zLDE5yIJ7n7EZI8jtWRl5eLl91dn4azYqDxMZu4ldWVrqxaQMgIAnWK1lhkODgDLHNRuVqNIYMiJQ5Wq0JnCocsFjM/w4PD/ikqurop+zUUYHnY8xmIs9mIxI7O7V4QSDajJc8PEQfZ2fHXyguPhPa2KiLwXNJklLZbDf+wTw4Cr3rkUg8j5dDSYYOOyslRI8Ccs6FJP6J+XZizpz1+bduPf49M8pA0zKZ8N3U1NlvyeWuTYcOFTwlLToTGZmdcu9e9xGj0RZkzxXOEARtE4nIE/v2bdmVl7e+nVUzyGTpHKGQ+BCMXgOOG5FgKQr/tf4xPNxPUFPT8QKWeDzqlsn0rzEjsSMe+fCnCdtcFsG6DfscC0fwUZvPsp9PS3rbSoSHZ/k+eKBshAzPY8cZeDwSGnELHHJ51qyg6tWrUz5/+eW1j9jhESxevDn9xo3Gs3q9lcOqxkQm456fPj1g+fXrRyGbIHTsWAm1e/f7x1tbNauYCU+BJFE/JGRX3P9OByQgH/hpE8+XIEGE2K5kGRDKX3HL+foAWV9/qk0q5f8BDGWH7JhMNqTVWiGEbTsrKx9+uHPne80KRfrNmTPXrC0uLmXWw8HBg8dcqqtbPhgynrbKZLwTQUGibIR0yWFhnoVwqpjsYxCavaalarX6JVZE+/Z9tKS1td/JeD6f6AkOdi9FyPBmYKC0xh4BCDmMnwi6m1pk7hx8PYPQoNzfdSYujQ2MJCowUHQQPuJFCD+uXTc6sAJwUlAfgHO2InQZZ0SoI9JWt7frTzATwJEyGf/V3t6Lg3kFM2/ez1Lv3HlcajbbHe3pKap9553tkTk5aVZPz7RLSqU+kRkAKIq+BnljRXd3mQrLOEKOHy/PraioP6zXWwYjbLwRgPukkEL86SKnrUCI3S87bdTZs1dFNTX1boOhLEheMotl7O3v4cHfq1JdKMB9L6/0k52duhzcFwhI4+bNSTEkSTiVzFwuhywqKr/a32+aimU4blFUlL9XWFiQ9dSpqna12sA4nsslLYsXh0WXl79XjeXhBAdnHmps7PkVK07IAc6A2YSwhDM1ZpOTAxyUlFwSFxS8PVWpHIi3Wul4CO2EgQGLjB1mgPygjYz0nvbllye7CGJRBU1Tz2M9GA4RIGTmPEl/vxEyOrPtAfzb62XvSzuh0GZ6kO1rVKrzMxjhCcLCVkY0NPTU0rT9s/87B1CwqrzXBJk7C6V5ew2jlrOZmUm62tqSr7u6yg7BKmeFhMgVvr4SOCmGIgJyhItAIEjCfZp2GIX3KI3gTjFqGzIeg/8XlrHhQ+swZYqc7Y3Ez0+uFQqdcvXEILg6QiTP8v5c/wY2nlGtWZO/A380Bq8evOQvhYW7Rpzvu3Yd4BQVlTX39hp8WRVyc+Nvg4rxMIcTV2GxEEwEgAt0kHb+bO+PDZfLRb6+fr9pbm6AjYkjwJ7lpFJBTV9f2agREBW1NqK6urUWEiHDhCKA5tynvGf+VH7y9l1GduDvv0KPUBx4wN7k8uRUdsgJcADl4pLcAAcezMMtjl6wYAOTyYODV5506Pn8BGtW1o6ZzEPjIDd3j6tYnNzjeJ7LjTfHxm6cxQ474eGRCrdQx/sX0zxe4lfs0KhgB0CjO+Kos6r8nMG7znBIqNDO2EPQ3uC2V7h8+Q6nFcjKeoW4cuXuL3U6UyirgqsxaZNIRJW47+rK+8SxPaAIIq9evf9qQsJWp6MyJeVFF6Ew7ixCMfdwEwhi6yIjV8iOHn29381NeJudBtuE5lRWfvvuxo17IlgVKir6G7VkyUtbIA9B1ToBbIgmKOkBzozkHI/9xY9ZrRPEwoUb5l+/3nwN7gODHwz3fo1C4XpDpdLcNJstkLH5cZAIfwQJkZ2BjzHBZaWyLJ4VIXSTIXTNz+E+Ab6E2uJqQIDk47t3v33o7i71s9l4+X19RmYco1AIz3R1lWbifkzMhqVffNH0mSO5YSQSnkUs5pbDTbSZz+c/DxXic8Pfj/muLTAemDdGR6974/btlgJ8yxsfliaFQpIABjSxCuyAGSYTfRNWib02Pw1zvUQijtdoLsLet+Pnl36ktVX7C/aTxsWzcABzCqxbt2TP3LlTdkC1ph6e6Z8EanlIfLxrYrEoebjxmL6+8m9cXbmLoAgC/ej/Az/v4SG4A9Vd4nDjMf7+XtvCwhR/5XDwJWskoIdj0Ou0XO7Cap4NTu7Ozv61d0tLx4aamuZZUqlrUm+vjhmXSPidXC5V7evrfnrTprTzW7fmMEfIaCQnbxHX1bWt7OnRZXh6ypLUah0SiwUDRqPxWmCg/Nz8+aGnjxz5rXNdOgyIxpj2dvULcNOLV6sHRJ6erkip7CkJDQ06tX37j+/n5xc1dnRomLnPIgImFVASB3h7L4PwGt8pMB5GLYS+T/zgAPb3e8sPDmB/Jw34voKPREf730DoP5pKhvU07RMQAAAAAElFTkSuQmCC",f={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"hidden",padding:8},gridSettings:u=>({height:`calc(100% - ${u.mixins.toolbar.minHeight}px)`,width:"100%",overflow:"auto"}),controlItem:{width:400,marginBottom:16,marginRight:8,marginLeft:8},delButton:{position:"absolute",top:2,right:48},addButton:{marginRight:8},buttonIcon:{height:24},headingIcon:{height:24,marginRight:8}};class Ft extends T.Component{focusRef;constructor(t){super(t);const s=this.props.settings||{};s.transport||={},Object.keys(s.transport).forEach(r=>{if(s.transport[r].type==="file"){const p=s.transport[r].maxSize,b=typeof p=="string"?p.includes("k")?.1:p.includes("g")?10:1:1;s.transport[r].maxSize=(parseInt(s.transport[r].maxSize,10)||0)*b,s.transport[r].level=s.transport[r].level||"",s.transport[r].maxFiles=s.transport[r].maxFiles||0}else s.transport[r].type==="syslog"?(s.transport[r].level=s.transport[r].level||"",s.transport[r].host=s.transport[r].host||"",s.transport[r].port=s.transport[r].port||0,s.transport[r].path=s.transport[r].path||"",s.transport[r].facility=s.transport[r].facility||"",s.transport[r].sysLogType=s.transport[r].sysLogType||"",s.transport[r].app_name=s.transport[r].app_name||"",s.transport[r].eol=s.transport[r].eol||""):s.transport[r].type==="http"?(s.transport[r].level=s.transport[r].level||"",s.transport[r].host=s.transport[r].host||"",s.transport[r].port=s.transport[r].port||0,s.transport[r].path=s.transport[r].path||"/",s.transport[r].auth=s.transport[r].auth||"None",s.transport[r].ssl=s.transport[r].ssl||!1):s.transport[r].type==="stream"?(s.transport[r].stream=s.transport[r].stream||"",s.transport[r].level=s.transport[r].level||"",s.transport[r].silent=s.transport[r].silent||!1,s.transport[r].eol=s.transport[r].eol||""):s.transport[r].type==="seq"&&(s.transport[r].level=s.transport[r].level||"",s.transport[r].serverUrl=s.transport[r].serverUrl||"",s.transport[r].apiKey=s.transport[r].apiKey||"",s.transport[r].eol=s.transport[r].eol||"")}),this.state={level:s.level||"info",maxDays:s.maxDays||7,noStdout:s.noStdout||!0,transport:s.transport||{},expanded:[]},this.focusRef=T.createRef()}componentDidMount(){var t;(t=this.focusRef.current)==null||t.focus()}onChange(){const t={level:this.state.level,maxDays:parseInt(this.state.maxDays,10),noStdout:this.state.noStdout,transport:{}};Object.keys(this.state.transport).forEach(s=>{t.transport[s]=JSON.parse(JSON.stringify(this.state.transport[s])),this.state.transport[s].type==="file"?(t.transport[s].maxSize=parseInt(t.transport[s].maxSize,10)||null,t.transport[s].maxSize&&(t.transport[s].maxSize=`${t.transport[s].maxSize.toString()}m`),t.transport[s].maxFiles=parseInt(t.transport[s].maxFiles,10)||null):this.state.transport[s].type==="syslog"?(t.transport[s].port||delete t.transport[s].port,t.transport[s].path||delete t.transport[s].path,t.transport[s].sysLogType||delete t.transport[s].sysLogType,t.transport[s].app_name||delete t.transport[s].app_name,t.transport[s].eol||delete t.transport[s].eol):this.state.transport[s].type==="http"?(t.transport[s].host=t.transport[s].host||"",t.transport[s].port=parseInt(t.transport[s].port,10)||80,t.transport[s].path=t.transport[s].path||"/",t.transport[s].auth=t.transport[s].auth||"",t.transport[s].ssl=t.transport[s].ssl||!1):this.state.transport[s].type==="stream"&&(t.transport[s].stream=t.transport[s].stream||"",t.transport[s].level=t.transport[s].level||"info",t.transport[s].silent=t.transport[s].silent||!1,t.transport[s].eol=t.transport[s].eol||"")}),this.props.onChange(t)}onDelete(t){const s=JSON.parse(JSON.stringify(this.state.transport));delete s[t],this.setState({transport:s},()=>this.onChange())}renderEnabled(t){return e.jsx(o.Grid2,{children:e.jsx(o.FormControlLabel,{style:f.controlItem,control:e.jsx(o.Checkbox,{checked:this.state.transport[t].enabled,onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].enabled=s.target.checked,this.setState({transport:r},()=>this.onChange())}}),label:this.props.t("Enabled")})})}renderLogLevel(t){return this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{style:f.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Level")}),e.jsxs(o.Select,{variant:"standard",value:this.state.transport[t].level||"_",renderValue:()=>this.state.transport[t].level||this.props.t("default"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].level=s.target.value==="_"?"":s.target.value,this.setState({transport:r},()=>this.onChange())},children:[e.jsx(o.MenuItem,{value:"_",children:this.props.t("default")}),e.jsx(o.MenuItem,{value:"silly",children:"silly"}),e.jsx(o.MenuItem,{value:"debug",children:"debug"}),e.jsx(o.MenuItem,{value:"info",children:"info"}),e.jsx(o.MenuItem,{value:"warn",children:"warn"}),e.jsx(o.MenuItem,{value:"error",children:"error"})]}),e.jsx(o.FormHelperText,{children:this.props.t("Level of messages that this transport should log (default: level set on parent logger)")})]})}):null}renderSyslog(t){return e.jsxs(o.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const s=[...this.state.expanded],r=s.indexOf(t);r===-1?s.push(t):s.splice(r,1),this.setState({expanded:s})},children:[e.jsxs(o.AccordionSummary,{expandIcon:e.jsx(y.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[e.jsx(y.Computer,{style:f.headingIcon}),e.jsx(o.Typography,{style:f.heading,children:t}),e.jsx(o.Fab,{size:"small",style:f.delButton,onClick:()=>this.onDelete(t),children:e.jsx(y.Delete,{})})]}),e.jsx(o.AccordionDetails,{children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].host,helperText:this.props.t("The host running syslogd, defaults to localhost"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].host=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].port,type:"number",helperText:this.props.t("The port on the host that syslog is running on, defaults to syslogd's default port(514/UDP)."),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].port=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Port")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{style:f.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Protocol")}),e.jsxs(o.Select,{variant:"standard",value:this.state.transport[t].protocol,onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].protocol=s.target.value,this.setState({transport:r},()=>this.onChange())},children:[e.jsx(o.MenuItem,{value:"udp4",children:"udp4"}),e.jsx(o.MenuItem,{value:"tcp4",children:"tcp4"}),e.jsx(o.MenuItem,{value:"unix",children:"unix"}),e.jsx(o.MenuItem,{value:"unix-connect",children:"unix-connect"})]})]})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].path,helperText:this.props.t("The path to the syslog dgram socket (i.e. /dev/log or /var/run/syslog for OS X)."),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].path=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Path")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].facility,helperText:this.props.t("Syslog facility to use (Default: local0)."),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].facility=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Facility")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].localhost,helperText:this.props.t("Host to indicate that log messages are coming from (Default: localhost)."),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].localhost=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Log name")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].sysLogType,helperText:this.props.t("The type of the syslog protocol to use (Default: BSD)."),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].sysLogType=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("SysLog Type")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].app_name,helperText:this.props.t("The name of the application (Default: process.title)."),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].app_name=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Application name")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].eol,helperText:this.props.t("The end of line character to be added to the end of the message (Default: Message without modifications)."),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].eol=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("End of line char")})}):null]})})]},t)}renderFile(t){return e.jsxs(o.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const s=[...this.state.expanded],r=s.indexOf(t);r===-1?s.push(t):s.splice(r,1),this.setState({expanded:s})},children:[e.jsxs(o.AccordionSummary,{style:{background:"rgba(128, 128, 128, 0.3)"},expandIcon:e.jsx(y.ExpandMore,{}),children:[e.jsx(y.InsertDriveFile,{style:f.headingIcon}),e.jsx(o.Typography,{style:f.heading,children:t}),e.jsx(o.Fab,{size:"small",style:f.delButton,onClick:()=>this.onDelete(t),children:e.jsx(y.Delete,{})})]}),e.jsx(o.AccordionDetails,{children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].filename,onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].filename=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].fileext,onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].fileext=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("File extension")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].maxSize,type:"number",helperText:this.props.t("MB"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].maxSize=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Maximal size of one file")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].maxFiles,type:"number",onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].maxFiles=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Maximal number of files")})}):null]})})]},t)}renderHttp(t){return e.jsxs(o.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const s=[...this.state.expanded],r=s.indexOf(t);r===-1?s.push(t):s.splice(r,1),this.setState({expanded:s})},children:[e.jsxs(o.AccordionSummary,{expandIcon:e.jsx(y.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[e.jsx(y.Language,{style:f.headingIcon}),e.jsx(o.Typography,{style:f.heading,children:t}),e.jsx(o.Fab,{size:"small",style:f.delButton,onClick:()=>this.onDelete(t),children:e.jsx(y.Delete,{})})]}),e.jsx(o.AccordionDetails,{children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].host,helperText:this.props.t("Remote host of the HTTP logging endpoint"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].host=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Host")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].port,type:"number",helperText:this.props.t("Remote port of the HTTP logging endpoint"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].port=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Port")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].path,helperText:this.props.t("Remote URI of the HTTP logging endpoint"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].path=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Path")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].auth,helperText:this.props.t("An object representing the username and password for HTTP Basic Auth"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].auth=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Auth")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.FormControlLabel,{style:f.controlItem,control:e.jsx(o.Checkbox,{checked:this.state.transport[t].ssl,onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].ssl=s.target.checked,this.setState({transport:r},()=>this.onChange())}}),label:this.props.t("SSL")})}):null]})})]},t)}renderStream(t){return e.jsxs(o.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const s=[...this.state.expanded],r=s.indexOf(t);r===-1?s.push(t):s.splice(r,1),this.setState({expanded:s})},children:[e.jsxs(o.AccordionSummary,{expandIcon:e.jsx(y.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[e.jsx(y.Send,{style:f.headingIcon}),e.jsx(o.Typography,{style:f.heading,children:t}),e.jsx(o.Fab,{size:"small",style:f.delButton,onClick:()=>this.onDelete(t),children:e.jsx(y.Delete,{})})]}),e.jsx(o.AccordionDetails,{children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].stream,helperText:this.props.t("any Node.js stream. If an objectMode stream is provided then the entire info object will be written. Otherwise info[MESSAGE] will be written"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].stream=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("File name")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.FormControlLabel,{style:f.controlItem,control:e.jsx(o.Checkbox,{checked:this.state.transport[t].silent,onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].silent=s.target.checked,this.setState({transport:r},()=>this.onChange())}}),label:this.props.t("Silent")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].eol,helperText:this.props.t("Line-ending character to use. (default: os.EOL).)"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].eol=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("EOL")})}):null]})})]},t)}renderSEQ(t){return e.jsxs(o.Accordion,{expanded:this.state.expanded.includes(t),onChange:()=>{const s=[...this.state.expanded],r=s.indexOf(t);r===-1?s.push(t):s.splice(r,1),this.setState({expanded:s})},children:[e.jsxs(o.AccordionSummary,{expandIcon:e.jsx(y.ExpandMore,{}),style:{position:"relative",background:"rgba(128, 128, 128, 0.3)"},children:[e.jsx("img",{style:f.headingIcon,src:nt,alt:"seq"}),e.jsx(o.Typography,{style:f.heading,children:t}),e.jsx(o.Fab,{size:"small",style:f.delButton,onClick:()=>this.onDelete(t),children:e.jsx(y.Delete,{})})]}),e.jsx(o.AccordionDetails,{children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[this.renderEnabled(t),this.renderLogLevel(t),this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].serverUrl,helperText:this.props.t("The http(s) URL including port of the seq server. If you use HTTPS a real certificate is needed; self signed certs are ot accepted."),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].serverUrl=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("Server URL")})}):null,this.state.transport[t].enabled?e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.transport[t].apiKey,helperText:this.props.t("The apiKey of the seq system"),onChange:s=>{const r=JSON.parse(JSON.stringify(this.state.transport));r[t].apiKey=s.target.value,this.setState({transport:r},()=>this.onChange())},label:this.props.t("API key")})}):null]})})]},t)}findFreeName(t){for(let s=1;;s++)if(!Object.keys(this.state.transport).find(r=>r===t+s))return t+s}add(t){if(t==="file"){const s=this.findFreeName(t),r=JSON.parse(JSON.stringify(this.state.transport));r[s]={type:t,enabled:!0,filename:"log/iobroker",fileext:".log",maxSize:0,maxFiles:0},this.setState({transport:r},()=>this.onChange())}else if(t==="syslog"){const s=this.findFreeName(t),r=JSON.parse(JSON.stringify(this.state.transport));r[s]={type:t,enabled:!0,host:"127.0.0.1",port:0,protocol:"udp4",path:"",facility:"",localhost:"iobroker",sysLogType:"",app_name:"",eol:""},this.setState({transport:r},()=>this.onChange())}else if(t==="http"){const s=this.findFreeName(t),r=JSON.parse(JSON.stringify(this.state.transport));r[s]={type:t,enabled:!0,host:"127.0.0.1",port:80,path:"/",auth:"None",ssl:!1},this.setState({transport:r},()=>this.onChange())}else if(t==="stream"){const s=this.findFreeName(t),r=JSON.parse(JSON.stringify(this.state.transport));r[s]={type:t,enabled:!0,stream:"/dev/null",level:"info",silent:!1,eol:""},this.setState({transport:r},()=>this.onChange())}else if(t==="seq"){const s=this.findFreeName(t),r=JSON.parse(JSON.stringify(this.state.transport));r[s]={type:t,enabled:!0,level:"info",serverUrl:"http://IP:PORT",apiKey:""},this.setState({transport:r},()=>this.onChange())}}render(){return e.jsxs(o.Paper,{style:f.paper,children:[e.jsx(o.Grid2,{sx:f.gridSettings,children:e.jsxs(o.Grid2,{container:!0,direction:"column",children:[e.jsx(o.Grid2,{children:e.jsxs(o.FormControl,{style:f.controlItem,variant:"standard",children:[e.jsx(o.InputLabel,{children:this.props.t("Level")}),e.jsxs(o.Select,{variant:"standard",value:this.state.level,onChange:t=>this.setState({level:t.target.value},()=>this.onChange()),children:[e.jsx(o.MenuItem,{value:"silly",children:"silly"}),e.jsx(o.MenuItem,{value:"debug",children:"debug"}),e.jsx(o.MenuItem,{value:"info",children:"info"}),e.jsx(o.MenuItem,{value:"warn",children:"warn"}),e.jsx(o.MenuItem,{value:"error",children:"error"})]})]})}),e.jsx(o.Grid2,{children:e.jsx(o.TextField,{variant:"standard",style:f.controlItem,value:this.state.maxDays,helperText:this.props.t("Every day one file"),type:"number",onChange:t=>this.setState({maxDays:t.target.value},()=>this.onChange()),label:this.props.t("Maximum number of days")})}),e.jsx(o.Grid2,{children:e.jsx(o.FormControlLabel,{style:f.controlItem,control:e.jsx(o.Checkbox,{checked:this.state.noStdout,onChange:t=>this.setState({noStdout:t.target.checked},()=>this.onChange())}),label:this.props.t("No stdout outputs")})}),Object.keys(this.state.transport).map(t=>{switch(this.state.transport[t].type){case"syslog":return this.renderSyslog(t);case"file":return this.renderFile(t);case"http":return this.renderHttp(t);case"stream":return this.renderStream(t);case"seq":return this.renderSEQ(t);default:return null}})]})}),e.jsxs(o.Toolbar,{children:[e.jsxs(o.Button,{color:"grey",style:f.addButton,variant:"contained",onClick:()=>this.add("file"),startIcon:e.jsx(y.Add,{}),children:[e.jsx(y.InsertDriveFile,{style:f.buttonIcon}),this.props.t("File log")]}),e.jsxs(o.Button,{color:"grey",style:f.addButton,variant:"contained",onClick:()=>this.add("syslog"),startIcon:e.jsx(y.Add,{}),children:[e.jsx(y.Computer,{style:f.buttonIcon}),this.props.t("Syslog")]}),e.jsxs(o.Button,{color:"grey",style:f.addButton,variant:"contained",onClick:()=>this.add("http"),startIcon:e.jsx(y.Add,{}),children:[e.jsx(y.Language,{style:f.buttonIcon}),this.props.t("HTTP log")]}),e.jsxs(o.Button,{color:"grey",style:f.addButton,variant:"contained",onClick:()=>this.add("stream"),startIcon:e.jsx(y.Add,{}),children:[e.jsx(y.Send,{style:f.buttonIcon}),this.props.t("Stream log")]}),e.jsxs(o.Button,{color:"grey",style:f.addButton,variant:"contained",onClick:()=>this.add("seq"),startIcon:e.jsx(y.Add,{}),children:[e.jsx("img",{src:nt,style:f.buttonIcon,alt:"seq"}),this.props.t("SEQ log")]})]})]})}}const V={paper:{height:"100%",maxHeight:"100%",maxWidth:"100%",overflow:"auto",padding:8},title:{width:"100%",height:32},divWithoutTitle:{width:"100%",height:"calc(100% - 32px)",border:"2px solid #00000000"},error:{border:"2px solid #FF0000"}};class _t extends T.Component{constructor(t){super(t),this.state={settings:JSON.stringify(this.props.settings||{},null,2),error:!1}}onChange(t){const s={settings:t};try{const r=JSON.parse(t);this.state.error&&(s.error=!1),this.setState(s,()=>this.props.onChange(r))}catch{s.error=!0,this.setState(s)}}render(){return e.jsxs(o.Paper,{style:V.paper,children:[e.jsx("div",{style:V.title,children:this.props.t("For future use")}),e.jsx("div",{style:{...V.divWithoutTitle,...this.state.error?V.error:void 0},children:e.jsx(dt,{themeType:this.props.themeType,value:this.state.settings,onChange:t=>this.onChange(t)})})]})}}const O={content:{height:500,overflow:"hidden"},tabPanel:u=>({width:"100%",height:`calc(100% - ${u.mixins.toolbar.minHeight}px)`,overflow:"auto"}),selected:u=>({color:u.palette.mode==="dark"?"#FFF !important":"#222 !important"})},q=["system","multihost","objects","states","log","plugins"];class Dt extends T.Component{originalSettings;constructor(t){super(t);const s=h.Router.getLocation(),r=s.tab==="tab-hosts"&&s.dialog==="base-settings"&&s.id===t.currentHost?q.indexOf(s.arg):-1;this.state={currentTab:r>=0?r:0,hasChanges:[],currentHost:this.props.currentHost,loading:!0,confirmExit:!1,showRestart:!1,system:null,multihostService:null,objects:null,states:null,log:null,plugins:null,dnsResolution:"ipv4first",dataDir:"",saving:!1}}isRouted(){const t=h.Router.getLocation();return t.tab==="tab-hosts"&&t.dialog==="base-settings"&&t.id===this.props.currentHost}async componentDidMount(){await this.getSettings(this.state.currentHost),this.isRouted()&&h.Router.getLocation().arg!==q[this.state.currentTab]&&h.Router.doNavigate(null,null,null,q[this.state.currentTab])}renderDialogConfirm(){return this.state.confirmExit?e.jsx(h.DialogConfirm,{text:this.props.t("Discard unsaved changes?"),onClose:t=>this.setState({confirmExit:!1},()=>t&&this.props.onClose())}):null}renderRestartDialog(){return this.state.showRestart?e.jsx(h.DialogConfirm,{title:this.props.t("Please confirm"),text:e.jsxs(e.Fragment,{children:[e.jsx("div",{children:this.props.t("Restart works only if controller started as system service.")}),e.jsx("div",{children:this.props.t("Would you like to restart the controller for your changes to take effect?")})]}),ok:this.props.t("Restart"),cancel:this.props.t("No restart"),onClose:t=>this.setState({showRestart:!1},()=>{t&&this.props.socket.restartController(this.props.currentHost).then(()=>setTimeout(()=>window.location.reload(),500)).catch(s=>window.alert(`Cannot restart: ${s}`)),this.props.onClose()})}):null}async getSettings(t){const r=await this.props.socket.readBaseSettings(t||this.state.currentHost);r!=null&&r.config&&(this.originalSettings=z.clone(r.config),this.setState({loading:!1,system:r.config.system,multihostService:r.config.multihostService,objects:r.config.objects,states:r.config.states,log:r.config.log,plugins:r.config.plugins,dnsResolution:r.config.dnsResolution||"ipv4first",dataDir:r.config.dataDir}))}onSave(t){const s={system:this.state.system,multihostService:this.state.multihostService,objects:this.state.objects,states:this.state.states,log:this.state.log,plugins:this.state.plugins},r={...this.originalSettings,...s};this.setState({saving:!0},()=>{this.props.socket.writeBaseSettings(t||this.state.currentHost,r).then(()=>{this.originalSettings=JSON.parse(JSON.stringify(s)),this.setState({hasChanges:[],showRestart:!0,saving:!1})}).catch(p=>{window.alert(`Cannot save settings: ${p}`),this.setState({saving:!1})})})}updateSettings(t,s){const r=[...this.state.hasChanges],p=JSON.stringify(this.originalSettings[t])!==JSON.stringify(s),b=r.indexOf(t);p&&b===-1?r.push(t):!p&&b!==-1&&r.splice(b,1),this.setState({[t]:s,hasChanges:r})}renderSystem(){const t="system";return e.jsx(kt,{settings:this.state[t],t:this.props.t,currentHost:this.props.currentHost,onChange:s=>this.updateSettings(t,s)})}renderMultihost(){const t="multihostService";return e.jsx(Tt,{settings:this.state[t],t:this.props.t,socket:this.props.socket,onChange:s=>this.updateSettings(t,s)})}renderObjects(){const t="objects";return e.jsx(G,{settings:this.state[t],t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:s=>this.updateSettings(t,s)})}renderStates(){const t="states";return e.jsx(U,{settings:this.state[t],t:this.props.t,socket:this.props.socket,currentHost:this.props.currentHost,onChange:s=>this.updateSettings(t,s)})}renderLog(){return e.jsx(Ft,{settings:this.state.log,t:this.props.t,onChange:s=>this.updateSettings("log",s)})}renderPlugins(){const t="plugins";return e.jsx(_t,{settings:this.state[t],t:this.props.t,themeType:this.props.themeType,onChange:s=>this.updateSettings(t,s)})}render(){return e.jsxs(o.Dialog,{style:O.dialog,open:!0,onClose:()=>!1,fullWidth:!0,maxWidth:"xl","aria-labelledby":"base-settings-dialog-title",children:[e.jsxs(o.DialogTitle,{id:"base-settings-dialog-title",children:[this.props.t("Host Base Settings"),": ",this.props.currentHostName||this.props.currentHost]}),e.jsxs(o.DialogContent,{style:O.content,children:[e.jsx(o.AppBar,{position:"static",children:e.jsxs(o.Tabs,{value:this.state.currentTab,onChange:(t,s)=>{this.setState({currentTab:s}),this.isRouted()&&h.Router.doNavigate(null,null,null,q[s])},"aria-label":"system tabs",indicatorColor:"secondary",children:[e.jsx(o.Tab,{label:this.props.t("System"),id:"system-tab","aria-controls":"simple-tabpanel-0",sx:{"&.Mui-selected":O.selected}}),e.jsx(o.Tab,{label:this.props.t("Multi-host"),id:"multihost-tab",sx:{"&.Mui-selected":O.selected},"aria-controls":"simple-tabpanel-1"}),e.jsx(o.Tab,{label:this.props.t("Objects"),id:"objects-tab","aria-controls":"simple-tabpanel-3",sx:{"&.Mui-selected":O.selected}}),e.jsx(o.Tab,{label:this.props.t("States"),id:"states-tab","aria-controls":"simple-tabpanel-4",sx:{"&.Mui-selected":O.selected}}),e.jsx(o.Tab,{label:this.props.t("Log"),id:"log-tab","aria-controls":"simple-tabpanel-5",sx:{"&.Mui-selected":O.selected}}),e.jsx(o.Tab,{label:this.props.t("Plugins"),id:"plugins-tab","aria-controls":"simple-tabpanel-6",sx:{"&.Mui-selected":O.selected}})]})}),this.state.loading?e.jsx(o.LinearProgress,{}):null,!this.state.loading&&this.state.currentTab===0?e.jsx(o.Box,{component:"div",sx:O.tabPanel,children:this.renderSystem()}):null,!this.state.loading&&this.state.currentTab===1?e.jsx(o.Box,{component:"div",sx:O.tabPanel,children:this.renderMultihost()}):null,!this.state.loading&&this.state.currentTab===2?e.jsx(o.Box,{component:"div",sx:O.tabPanel,children:this.renderObjects()}):null,!this.state.loading&&this.state.currentTab===3?e.jsx(o.Box,{component:"div",sx:O.tabPanel,children:this.renderStates()}):null,!this.state.loading&&this.state.currentTab===4?e.jsx(o.Box,{component:"div",sx:O.tabPanel,children:this.renderLog()}):null,!this.state.loading&&this.state.currentTab===5?e.jsx(o.Box,{component:"div",sx:O.tabPanel,children:this.renderPlugins()}):null,this.renderDialogConfirm(),this.renderRestartDialog()]}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{variant:"contained",disabled:!this.state.hasChanges.length||this.state.saving,onClick:()=>this.onSave(),color:"primary",startIcon:e.jsx(y.Check,{}),children:this.props.t("Save & Close")}),e.jsx(o.Button,{variant:"contained",color:"grey",disabled:this.state.saving,onClick:()=>this.state.hasChanges.length?this.setState({confirmExit:!0}):this.props.onClose(),startIcon:e.jsx(y.Close,{}),children:this.state.hasChanges.length?this.props.t("Cancel"):this.props.t("Close")})]})]})}}const B={error:{border:"2px solid #FF0000"},id:{fontStyle:"italic"},dialog:{height:"calc(100% - 64px)"},button:{marginTop:20,marginLeft:8},funcDivEdit:{width:"100%"},funcEditName:{display:"inline-block",width:85},funcEdit:{width:400},marginTop:{marginTop:20},commonTabWrapper:{flexFlow:"wrap",display:"flex"},commonWrapper:{width:500,minWidth:300},flexDrop:{width:"100%",maxWidth:500,margin:"auto",display:"flex"},marginBlock:{marginTop:20},buttonAdd:{minWidth:150},textField:{width:"100%"},flex:{display:"flex"},close:{width:"20px",height:"20px",opacity:"0.9",cursor:"pointer",position:"relative",top:20,transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:"9px",content:'""',height:"20px",width:"3px",backgroundColor:"#ff4f4f",transform:"rotate(-45deg)"}},color:{width:70},buttonRemoveWrapper:{position:"absolute",zIndex:222,right:0},tabsPadding:{padding:"0px 24px"}};class Ot extends T.Component{originalObj;constructor(t){super(t),this.state={text:JSON.stringify(this.props.obj,null,2),error:!1,changed:!1},this.originalObj=JSON.stringify(this.props.obj,null,2)}prepareObject(t){t=t||this.state.text;try{const s=JSON.parse(t);return s._id=this.props.obj._id,s}catch{return null}}onChange(t){const s={text:t},r=this.prepareObject(t);r?(s.changed=this.originalObj!==JSON.stringify(r,null,2),this.state.error&&(s.error=!1)):s.error=!0,this.setState(s)}onUpdate(){try{const t=JSON.parse(this.state.text);t._id=this.props.obj._id,this.props.onClose(t)}catch{}}setCommonItem(t,s,r){t.common[s]=r,this.onChange(JSON.stringify(t,null,2))}removeCommonItem(t,s){delete t.common.common[s],this.onChange(JSON.stringify(t,null,2))}buttonAddKey(t,s){const{t:r}=this.props;return e.jsx("div",{style:B.marginBlock,children:e.jsx(o.Button,{style:B.buttonAdd,variant:"contained",color:"secondary",onClick:s,startIcon:e.jsx(y.Add,{}),children:r(`Add ${t}`)})})}buttonRemoveKey(t,s){const{t:r}=this.props;return e.jsx(o.Tooltip,{title:r(`Remove ${t}`),slotProps:{popper:{sx:{pointerEvents:"none"}}},children:e.jsx(o.Box,{component:"div",sx:B.close,onClick:s})})}renderCommonEdit(){try{const t=JSON.parse(this.state.text),s=!1,{t:r}=this.props;return e.jsxs("div",{style:B.commonTabWrapper,children:[e.jsxs("div",{style:B.commonWrapper,children:[typeof t.common.title<"u"?e.jsx(o.TextField,{variant:"standard",disabled:s,label:r("title"),style:{...B.marginBlock,...B.textField},fullWidth:!0,value:t.common.title,onChange:p=>this.setCommonItem(t,"title",p.target.value),slotProps:{input:{endAdornment:t.common.title?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(t,"title",""),children:e.jsx(y.Close,{})})}):null}}}):this.buttonAddKey("title",()=>this.setCommonItem(t,"title","")),typeof t.common.color<"u"?e.jsxs("div",{style:B.flex,children:[e.jsx(o.TextField,{variant:"standard",disabled:s,style:{...B.marginBlock,...B.color},label:r("Color"),type:"color",value:t.common.color,onChange:p=>this.setCommonItem(t,"color",p.target.value),slotProps:{input:{endAdornment:t.common.color?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{tabIndex:-1,size:"small",onClick:()=>this.setCommonItem(t,"color",""),children:e.jsx(y.Close,{})})}):null}}}),this.buttonRemoveKey("color",()=>this.removeCommonItem(t,"color"))]}):this.buttonAddKey("color",()=>this.setCommonItem(t,"color",""))]}),typeof t.common.icon<"u"?e.jsxs("div",{style:B.flexDrop,children:[e.jsx(h.UploadImage,{disabled:s,crop:!0,maxSize:256*1024,icon:t.common.icon,removeIconFunc:()=>this.setCommonItem(t,"icon",""),onChange:p=>this.setCommonItem(t,"icon",p)}),this.buttonRemoveKey("icon",()=>this.removeCommonItem(t,"icon"))]}):e.jsx("div",{style:B.flexDrop,children:this.buttonAddKey("icon",()=>this.setCommonItem(t,"icon",""))})]})}catch{return e.jsx("div",{children:this.props.t("Cannot parse JSON!")})}}render(){return e.jsxs(o.Dialog,{sx:{"& .MuiDialog-paper":B.dialog},open:!0,maxWidth:"lg",fullWidth:!0,fullScreen:!1,onClose:()=>this.props.onClose(),"aria-labelledby":"edit-value-dialog-title","aria-describedby":"edit-value-dialog-description",children:[e.jsxs(o.DialogTitle,{id:"edit-value-dialog-title",children:[this.props.t("Edit host settings"),":",e.jsx("span",{style:B.id,children:this.props.obj._id})]}),e.jsx(o.DialogContent,{children:this.renderCommonEdit()}),e.jsxs(o.DialogActions,{children:[e.jsx(o.Button,{variant:"contained",disabled:this.state.error||!this.state.changed,onClick:()=>this.onUpdate(),color:"primary",startIcon:e.jsx(y.Check,{}),children:this.props.t("Write")}),e.jsx(o.Button,{variant:"contained",onClick:()=>this.props.onClose(),color:"grey",startIcon:e.jsx(y.Close,{}),children:this.props.t("Cancel")})]})]})}}const lt="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)",ht="0 8px 17px 0 rgba(0, 0, 0, .2),0 6px 20px 0 rgba(0, 0, 0, .19)",Bt=`
|
|
24
|
+
@keyframes newValueAnimationHostDark {
|
|
25
|
+
0% {
|
|
26
|
+
color: #00f900;
|
|
27
|
+
}
|
|
28
|
+
80% {
|
|
29
|
+
color: #008000;
|
|
30
|
+
}
|
|
31
|
+
100% {
|
|
32
|
+
color: #fff;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
@keyframes newValueAnimationHostLight {
|
|
36
|
+
0% {
|
|
37
|
+
color: #00f900;
|
|
38
|
+
}
|
|
39
|
+
80% {
|
|
40
|
+
color: #008000;
|
|
41
|
+
}
|
|
42
|
+
100% {
|
|
43
|
+
color: #fff;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
.newValueHost-dark {
|
|
47
|
+
animation: newValueAnimationHostDark 2s ease-in-out;
|
|
48
|
+
}
|
|
49
|
+
.newValueHost-light {
|
|
50
|
+
animation: newValueAnimationHostLight 2s ease-in-out;
|
|
51
|
+
}
|
|
52
|
+
@keyframes colors {
|
|
53
|
+
0% {
|
|
54
|
+
left: -51px;
|
|
55
|
+
}
|
|
56
|
+
100% {
|
|
57
|
+
left: 101%;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
@keyframes warning {
|
|
61
|
+
0% {
|
|
62
|
+
opacity: 1;
|
|
63
|
+
}
|
|
64
|
+
100% {
|
|
65
|
+
opacity: 0.7;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
@keyframes red {
|
|
69
|
+
0% {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
100% {
|
|
73
|
+
opacity: 0.8;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
@keyframes onBlink-keys-dark {
|
|
77
|
+
0% {
|
|
78
|
+
color: #264d72;
|
|
79
|
+
}
|
|
80
|
+
80% {
|
|
81
|
+
color: #3679be;
|
|
82
|
+
}
|
|
83
|
+
100% {
|
|
84
|
+
color: #fff;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
@keyframes onBlink-keys-light {
|
|
88
|
+
0% {
|
|
89
|
+
color: #3679be;
|
|
90
|
+
}
|
|
91
|
+
80% {
|
|
92
|
+
color: #264d72;
|
|
93
|
+
}
|
|
94
|
+
100% {
|
|
95
|
+
color: #000;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
.onBlick-light {
|
|
99
|
+
animation: onBlink-keys-light 2s ease-in-out;
|
|
100
|
+
animation-iteration-count: 2;
|
|
101
|
+
font-size: 12px;
|
|
102
|
+
margin-left: 4px;
|
|
103
|
+
}
|
|
104
|
+
.onBlick-dark {
|
|
105
|
+
animation: onBlink-keys-dark 2s ease-in-out;
|
|
106
|
+
animation-iteration-count: 2;
|
|
107
|
+
font-size: 12px;
|
|
108
|
+
margin-left: 4px;
|
|
109
|
+
}
|
|
110
|
+
@keyframes height {
|
|
111
|
+
0% {
|
|
112
|
+
height: 0;
|
|
113
|
+
},
|
|
114
|
+
100% {
|
|
115
|
+
height: 160px;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`,_={img:{width:45,height:45,margin:"auto 0",position:"relative","&:after":{content:'""',position:"absolute",zIndex:2,top:0,left:0,width:"100%",height:"100%",background:'url("img/no-image.svg") 100% 100% no-repeat',backgroundSize:"cover",backgroundColor:"#fff"}},collapseOff:{height:0},footerBlock:u=>({background:u.palette.background.default,p:"10px",display:"flex",justifyContent:"space-between"}),hidden:{display:"none"},emptyButton:{width:48},greenText:u=>({color:u.palette.success.dark}),wrapperAvailable:{display:"flex",alignItems:"center"},buttonUpdate:{border:`1px solid ${at[700]}`,padding:"2px 7px",borderRadius:"5px",display:"flex",alignItems:"center",cursor:"pointer",transition:"background 0.5s","&:hover":{background:"#00800026"}},buttonUpdateIcon:{height:20,width:20,marginRight:10},debug:{backgroundColor:ft[700]},info:{backgroundColor:bt[700]},warn:{backgroundColor:yt[700]},error:{backgroundColor:gt[700]},smallAvatar:{width:24,height:24},formControl:{display:"flex"},baseSettingsButton:{transform:"rotate(45deg)"},tooltip:{pointerEvents:"none"}},Lt=["silly","debug","info","warn","error"];function W(u,t){const s=u.className.split(" "),r=s.indexOf(t);r!==-1&&(s.splice(r,1),u.className=s.join(" ")),s.push(t),setTimeout(p=>u.className=p,100,s.join(" "))}function Pt(u){return u==="debug"?e.jsx(y.BugReport,{}):u==="info"?e.jsx(y.Info,{}):u==="warn"?e.jsx(y.Warning,{}):u==="error"?e.jsx(y.Error,{}):null}class A extends T.Component{static formatInfo={Uptime:z.formatSeconds,"System uptime":z.formatSeconds,RAM:z.formatRam,Speed:z.formatSpeed,"Disk size":z.formatBytes,"Disk free":z.formatBytes,time:t=>new Date(t).toLocaleString()};refEvents=$.createRef();refWarning=$.createRef();refCpu=$.createRef();refMem=$.createRef();refUptime=$.createRef();outputCache="-";inputCache="-";cpuCache="- %";memCache="- %";uptimeCache="-";diskFreeCache=1;diskSizeCache=1;diskWarningCache=1;constructor(t){super(t),this.state={logLevel:"",logLevelSelect:"",hostNotifications:{notifications:null,warning:0,other:0},openDialogLogLevel:!1,hostUpdateDialog:!1,updateAvailable:!1,instructionDialog:!1,updateDialog:!1,baseSettingsDialog:!1,editDialog:!1,changeLog:null}}static getDerivedStateFromProps(t,s){const r=h.Router.getLocation(),p=r.tab==="tab-hosts"&&r.id===t.hostId,b=p&&r.dialog==="settings",g=p&&r.dialog==="base-settings";return b!==s.editDialog||g!==s.baseSettingsDialog?{editDialog:b,baseSettingsDialog:g}:null}async getInitialDiskStates(){const t=await this.props.socket.getState(`${this.props.hostId}.diskWarning`);this.diskWarningCache=(t==null?void 0:t.val)??this.diskWarningCache;const s=await this.props.socket.getState(`${this.props.hostId}.diskFree`);this.diskFreeCache=(s==null?void 0:s.val)??this.diskFreeCache;const r=await this.props.socket.getState(`${this.props.hostId}.diskSize`);this.diskSizeCache=(r==null?void 0:r.val)??this.diskSizeCache}notificationHandler=t=>t&&t[this.props.hostId]&&this.setState({hostNotifications:{notifications:t[this.props.hostId],...A.calculateWarning(t[this.props.hostId])}});readChangeLog(){this.state.changeLog||fetch(tt.replace("github.com","raw.githubusercontent.com").replace("/blob/","/")).then(t=>t.text()).then(t=>this.setState({changeLog:t})).catch(t=>console.error(`Cannot read changelog: ${t}`))}componentDidMount(){this.props.hostsWorker.registerNotificationHandler(this.notificationHandler),this.props.hostsWorker.getNotifications(this.props.hostId).then(t=>this.notificationHandler(t)),this.props.socket.subscribeState(`${this.props.hostId}.inputCount`,this.eventsInputFunc),this.props.socket.subscribeState(`${this.props.hostId}.outputCount`,this.eventsOutputFunc),this.props.socket.subscribeState(`${this.props.hostId}.cpu`,this.cpuFunc),this.props.socket.subscribeState(`${this.props.hostId}.mem`,this.memFunc),this.props.socket.subscribeState(`${this.props.hostId}.uptime`,this.uptimeFunc),this.getInitialDiskStates().finally(async()=>{await this.props.socket.subscribeState(`${this.props.hostId}.diskFree`,this.warningFunc),await this.props.socket.subscribeState(`${this.props.hostId}.diskSize`,this.warningFunc),await this.props.socket.subscribeState(`${this.props.hostId}.diskWarning`,this.warningFunc)}),this.props.socket.subscribeState(`${this.props.hostId}.logLevel`,this.logLevelFunc)}componentWillUnmount(){this.props.hostsWorker.unregisterNotificationHandler(this.notificationHandler),this.props.socket.unsubscribeState(`${this.props.hostId}.inputCount`,this.eventsInputFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.outputCount`,this.eventsOutputFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.cpu`,this.cpuFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.mem`,this.memFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.uptime`,this.uptimeFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskFree`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskSize`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.diskWarning`,this.warningFunc),this.props.socket.unsubscribeState(`${this.props.hostId}.logLevel`,this.logLevelFunc)}eventsInputFunc=(t,s)=>{this.inputCache=s&&s.val!==null?`⇥${s.val}`:"-",this.refEvents.current&&(this.refEvents.current.innerHTML=`${this.inputCache} / ${this.outputCache}`,W(this.refEvents.current,`newValueHost-${this.props.themeType||"light"}`))};eventsOutputFunc=(t,s)=>{this.outputCache=s&&s.val!==null?`↦${s.val}`:"-",this.refEvents.current&&(this.refEvents.current.innerHTML=`${this.inputCache} / ${this.outputCache}`,W(this.refEvents.current,`newValueHost-${this.props.themeType||"light"}`))};warningFunc=(t,s)=>{t.endsWith("diskFree")?this.diskFreeCache=(s==null?void 0:s.val)||0:t.endsWith("diskSize")?this.diskSizeCache=(s==null?void 0:s.val)||0:t.endsWith("diskWarning")&&(this.diskWarningCache=(s==null?void 0:s.val)||0);const r=this.diskFreeCache/this.diskSizeCache*100<=this.diskWarningCache;this.refWarning.current&&(r?(this.refWarning.current.setAttribute("title",this.props.t("Warning: Free space on disk is low")),this.refWarning.current.classList.add("warning")):(this.refWarning.current.removeAttribute("title"),this.refWarning.current.classList.remove("warning")))};cpuFunc=(t,s)=>{this.cpuCache=this.formatValue(s,"%"),this.refCpu.current&&(this.refCpu.current.innerHTML=this.cpuCache,W(this.refCpu.current,`newValueHost-${this.props.themeType||"light"}`))};memFunc=(t,s)=>{this.memCache=this.formatValue(s,"%"),this.refMem.current&&(this.refMem.current.innerHTML=this.memCache,W(this.refMem.current,`newValueHost-${this.props.themeType||"light"}`))};uptimeFunc=(t,s)=>{if(s!=null&&s.val){const r=Math.floor(s.val/86400),p=Math.floor(s.val%(3600*24)/3600);this.uptimeCache=r?`${r}d${p}h`:`${p}h`}this.refUptime.current&&(this.refUptime.current.innerHTML=this.uptimeCache,W(this.refUptime.current,`newValueHost-${this.props.themeType||"light"}`))};static calculateWarning(t){const s={warning:0,other:0};if(!t)return s;const{result:r}=t;if(!r||!r.system)return s;if(Object.keys(r.system.categories).length){const p=r.system.categories;for(const b of Object.values(p))Object.keys(b.instances).forEach(()=>b.severity==="alert"?s.warning++:s.other++)}return s}formatValue(t,s){return!t||t.val===null||t.val===void 0?`-${s?` ${s}`:""}`:this.props.systemConfig.common.isFloatComma?t.val.toString().replace(".",",")+(s?` ${s}`:""):t.val+(s?` ${s}`:"")}logLevelFunc=(t,s)=>{s&&this.setState({logLevel:s.val,logLevelSelect:s.val})};renderDialogLogLevel(){return this.state.openDialogLogLevel?e.jsxs(xt,{theme:this.props.theme,title:this.props.t("Edit log level rule for %s",this.props.host.common.name),onApply:()=>{this.props.socket.setState(`${this.props.hostId}.logLevel`,this.state.logLevelSelect).catch(t=>window.alert(`Cannot set log level: ${t}`)),this.setState({openDialogLogLevel:!1})},onClose:()=>this.setState({openDialogLogLevel:!1,logLevelSelect:this.state.logLevel}),children:[e.jsxs(o.FormControl,{style:{..._.formControl,marginTop:8},variant:"outlined",children:[e.jsx(o.InputLabel,{children:this.props.t("log level")}),e.jsx(o.Select,{variant:"standard",value:this.state.logLevelSelect,fullWidth:!0,onChange:t=>this.setState({logLevelSelect:t.target.value}),children:Lt.map(t=>e.jsx(o.MenuItem,{value:t,children:this.props.t(t)},t))})]}),e.jsxs(o.FormControl,{style:_.formControl,variant:"outlined",children:[e.jsx(o.FormHelperText,{children:this.props.t("Log level will be reset to the saved level after the restart of the controller")}),e.jsxs(o.FormHelperText,{children:[this.props.t("You can set the log level permanently in the base host settings"),e.jsx(y.Build,{style:_.baseSettingsButton})]})]})]}):null}onCopy(){const t=[];if(this.refCpu.current&&t.push(`CPU: ${this.refCpu.current.innerHTML}`),this.refMem.current&&t.push(`RAM: ${this.refMem.current.innerHTML}`),this.refUptime.current&&t.push(`${this.props.t("Uptime")}: ${this.refUptime.current.innerHTML}`),t.push(`${this.props.t("Available")}: ${this.props.available}`),t.push(`${this.props.t("Installed")}: ${this.props.host.common.installedVersion}`),this.refEvents.current&&t.push(`${this.props.t("Events")}: ${this.refEvents.current.innerHTML}`),this.props.hostData&&typeof this.props.hostData=="object"){const s=this.props.hostData;Object.keys(s).map(r=>t.push(`${this.props.t(r)}: ${A.formatInfo[r]?A.formatInfo[r](s[r],this.props.t):s[r]||"--"}`))}h.Utils.copyToClipboard(t.join(`
|
|
119
|
+
`)),window.alert(this.props.t("Copied"))}renderUpdateButton(t,s){return t?e.jsx(o.Tooltip,{title:this.props.t("Update"),slotProps:{popper:{sx:_.tooltip}},children:e.jsxs(o.Box,{component:"div",onClick:r=>(r.stopPropagation(),this.openHostUpdateDialog()),sx:_.buttonUpdate,children:[e.jsx(o.IconButton,{style:_.buttonUpdateIcon,size:"small",children:e.jsx(y.Refresh,{})}),e.jsx("span",{style:{color:at[700]},children:this.props.available})]})}):e.jsx("span",{style:s,children:this.props.available})}renderHostBaseEdit(){return this.props.expertMode?e.jsx(o.Tooltip,{title:this.props.t("Host Base Settings"),slotProps:{popper:{sx:_.tooltip}},children:e.jsx("div",{children:e.jsx(o.IconButton,{size:"large",disabled:!this.props.alive,onClick:t=>{t.stopPropagation(),h.Router.doNavigate("tab-hosts","base-settings",this.props.hostId)},children:e.jsx(y.Build,{style:_.baseSettingsButton})})})}):null}renderExtendButton(t){return e.jsx(o.Tooltip,{title:this.props.t(t?"collapse":"Expand"),slotProps:{popper:{sx:_.tooltip}},children:e.jsx("div",{children:e.jsx(o.IconButton,{size:"large",children:t?e.jsx(jt,{}):e.jsx(vt,{})})})})}renderRestartButton(){return e.jsx(o.Tooltip,{title:this.props.t("Restart host"),slotProps:{popper:{sx:_.tooltip}},children:e.jsx("div",{children:e.jsx(o.IconButton,{size:"large",disabled:!this.props.alive,onClick:t=>{t.stopPropagation(),this.props.socket.restartController(this.props.hostId).catch(s=>window.alert(`Cannot restart: ${s}`))},children:e.jsx(y.Cached,{})})})})}renderEditButton(){return e.jsx(o.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),h.Router.doNavigate("tab-hosts","settings",this.props.hostId)},children:e.jsx(y.Edit,{})})}renderRemoveButton(){return!this.props.alive&&!this.props.isCurrentHost?e.jsx(o.Tooltip,{title:this.props.alive||this.props.isCurrentHost?this.props.t("You cannot delete host, when it is alive"):this.props.t("Remove"),slotProps:{popper:{sx:_.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),this.props.executeCommandRemove()},children:e.jsx(y.Delete,{})})}):e.jsx("div",{style:_.emptyButton})}renderCopyButton(t){return e.jsx(o.Tooltip,{title:this.props.t("Copy"),slotProps:{popper:{sx:_.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.onCopy(),style:t,children:e.jsx(h.IconCopy,{})})})}renderLogLevel(){return e.jsx(o.Tooltip,{title:`${this.props.t("loglevel")} ${this.state.logLevel}`,slotProps:{popper:{sx:_.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:t=>{t.stopPropagation(),this.setState({openDialogLogLevel:!0})},children:e.jsx(o.Avatar,{style:{..._.smallAvatar,..._[this.state.logLevel]},children:Pt(this.state.logLevel)})})})}renderNotificationsBadge(t,s){return e.jsx(o.Badge,{sx:s?{right:-3,top:13,padding:"0 4px",cursor:"pointer"}:{cursor:"pointer"},title:this.props.t("Hosts notifications"),badgeContent:this.state.hostNotifications.warning+this.state.hostNotifications.other,style:_.badge,color:this.state.hostNotifications.warning>0?"error":"secondary",onClick:r=>{r.stopPropagation(),this.props.showAdaptersWarning({[this.props.hostId]:this.state.hostNotifications.notifications},this.props.hostId)},children:t})}async openHostUpdateDialog(){const t=await this.props.socket.checkFeatureSupported("CONTROLLER_UI_UPGRADE");this.setState({hostUpdateDialog:!0,updateAvailable:t}),this.readChangeLog()}renderHostUpdateDialog(){return this.state.hostUpdateDialog?e.jsx(ut,{adapter:this.props.host.common.name,adapterObject:this.props.jsControllerInfo,t:this.props.t,textUpdate:this.state.updateAvailable?this.props.t("Start update"):this.props.t("Show instructions"),textInstruction:this.props.t("Show whole changelog"),rightDependencies:!0,news:this.getNews(),toggleTranslation:this.props.toggleTranslation,noTranslation:this.props.noTranslation,onUpdate:()=>{this.state.updateAvailable?this.setState({hostUpdateDialog:!1,updateDialog:!0}):this.setState({hostUpdateDialog:!1,instructionDialog:!0})},theme:this.props.theme,installedVersion:this.props.host.common.installedVersion,onInstruction:()=>{window.open(tt,"_blank")},onClose:()=>this.setState({hostUpdateDialog:!1})}):null}renderUpdateDialog(){return this.state.updateAvailable&&this.state.updateDialog?e.jsx(St,{socket:this.props.socket,hostId:this.props.hostId,version:this.props.jsControllerInfo.version,onClose:()=>this.setState({updateDialog:!1}),adminInstance:this.props.adminInstance,onUpdating:t=>this.props.onUpdating(t),themeType:this.props.themeType}):this.state.instructionDialog?e.jsx(wt,{socket:this.props.socket,hostId:this.props.hostId,version:this.props.jsControllerInfo.version,onClose:()=>this.setState({instructionDialog:!1})}):null}static extractNews(t,s){const r=t.split(`
|
|
120
|
+
`);let p="",b=!1;for(let g=0;g<r.length;g++)if(r[g].startsWith("## ")){if(b)break;r[g].startsWith(`## ${s}`)&&(b=!0)}else b&&(p+=`${r[g].replace(/^\*\s*/,"").replace(/^\(\w+\)\s*/,"")}
|
|
121
|
+
`);return p}getNews(t){const s=this.props.jsControllerInfo,r=this.props.host.common.installedVersion,p=[];return r&&(s!=null&&s.news)&&Object.keys(s.news).forEach(b=>{try{if(ct.gt(b,r)||t){let g=!1,k=this.props.noTranslation?s.news[b].en:s.news[b][this.props.lang]||s.news[b].en;if(s.news[b].en==="see CHANGELOG.md"&&this.state.changeLog){const F=A.extractNews(this.state.changeLog,b);F&&(k=F,g=!0)}p.push({version:b,news:k,downloaded:g})}}catch{console.warn(`Cannot compare "${b}" and "${r}"`)}}),p}baseSettingsSettingsDialog(){return this.state.baseSettingsDialog?e.jsx(Dt,{currentHost:this.props.hostId,themeType:this.props.themeType,currentHostName:this.props.host.common.name,onClose:()=>h.Router.doNavigate("tab-hosts"),socket:this.props.socket,t:this.props.t},"base"):null}renderEditObjectDialog(){return this.state.editDialog?e.jsx(Ot,{obj:this.props.host,t:this.props.t,onClose:t=>{h.Router.doNavigate("tab-hosts"),t&&this.props.socket.setObject(t._id,t).then(()=>this.forceUpdate()).catch(s=>alert(`Cannot write object: ${s}`))}}):null}renderDialogs(){return e.jsxs(e.Fragment,{children:[this.renderDialogLogLevel(),this.renderHostUpdateDialog(),this.renderUpdateDialog(),this.renderEditObjectDialog(),this.baseSettingsSettingsDialog()]})}}const j={..._,root:u=>({position:"relative",m:"10px",width:300,minHeight:200,background:u.palette.background.default,boxShadow:lt,display:"flex",flexDirection:"column",transition:"box-shadow 0.5s","&:hover":{boxShadow:ht},"& .warning":{backgroundColor:"#de0000 !important","&:before":{position:"absolute",right:0,top:-5,content:'"⚠"',fontSize:25,height:"30px",width:"30px",color:"black"},animation:"$warning 2.5s ease-in-out infinite alternate"}}),imageBlock:{minHeight:60,display:"flex",padding:"0 10px 0 10px",position:"relative",justifyContent:"space-between",transition:"background 0.5s"},fab:{position:"absolute",bottom:-20,width:40,height:40,right:20},collapse:{height:"100%",position:"absolute",width:"100%",zIndex:3,marginTop:"auto",bottom:0,transition:"height 0.3s",justifyContent:"space-between",display:"flex",flexDirection:"column"},collapseOff:{height:0},close:{width:20,height:20,opacity:.9,cursor:"pointer",position:"relative",ml:"auto",mb:"10px",transition:"all 0.6s ease","&:hover":{transform:"rotate(90deg)"},"&:before":{position:"absolute",left:9,content:'""',height:20,width:3,backgroundColor:"#ff4f4f",transform:"rotate(45deg)"},"&:after":{position:"absolute",left:9,content:'""',height:20,width:3,backgroundColor:"#ff4f4f",transform:"rotate(-45deg)"}},onOffLine:{alignSelf:"center",width:"100%",height:4},adapter:u=>({width:"100%",fontWeight:"bold",fontSize:16,verticalAlign:"middle",pl:1,pt:2,color:u.palette.mode==="dark"?"#333":"#555"}),cardContentInfo:u=>({overflow:"auto",paddingTop:0,backgroundColor:u.palette.background.paper,color:u.palette.mode==="dark"?"#EEE":"#111"}),cardContentH5:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between",paddingBottom:"10px !important"},marginTop10:{marginTop:10},displayFlex:{display:"flex"},enableButton:{display:"flex",justifyContent:"space-between",alignItems:"center"},instanceStateNotAlive1:{backgroundColor:"rgba(192, 192, 192, 0.4)"},green:{background:"#00ce00",position:"relative"},red:{background:"#da0000"},dotLine:{width:50,height:"100%",background:"linear-gradient(90deg, rgba(0,206,0,0.7497373949579832) 0%, rgba(31,255,1,1) 50%, rgba(0,206,0,0.7805497198879552) 100%)",zIndex:2,position:"absolute",left:-11},cardContentDiv:{position:"sticky",right:0,top:0,paddingTop:10},curdContentFlexCenter:{display:"flex",alignItems:"center",ml:"4px"},ul:{paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:8},value:{marginLeft:5},label:{fontWeight:"bold"}};class At extends A{getHostDescriptionAll(){return this.props.hostData?typeof this.props.hostData=="string"?this.props.hostData:!this.props.hostData||typeof this.props.hostData!="object"?e.jsx("ul",{style:j.ul,children:e.jsx(o.Skeleton,{})},"ul"):e.jsx("ul",{style:j.ul,children:Object.keys(this.props.hostData).map(t=>e.jsx("li",{children:e.jsxs("span",{style:j.black,children:[e.jsxs("span",{style:j.label,children:[this.props.t(t),": "]}),e.jsx("span",{style:j.value,children:A.formatInfo[t]?A.formatInfo[t](this.props.hostData[t],this.props.t):this.props.hostData[t]||"--"})]})},t))},"ul"):e.jsx(o.Skeleton,{})}render(){const t=(this.props.isCurrentHost||this.props.alive)&&z.updateAvailable(this.props.host.common.installedVersion,this.props.available),s=this.getHostDescriptionAll();return e.jsxs(o.Card,{sx:h.Utils.getStyle(this.props.theme,j.root,this.props.hidden&&j.hidden),children:[this.renderDialogs(),this.state.openCollapse&&e.jsxs("div",{style:{...j.collapse,...this.state.openCollapse?void 0:j.collapseOff},children:[e.jsxs(o.CardContent,{sx:j.cardContentInfo,children:[e.jsx("div",{style:j.cardContentDiv,onClick:()=>this.setState({openCollapse:!1}),children:e.jsx(o.Box,{component:"div",sx:j.close,onClick:()=>this.setState({openCollapse:!1})})}),s]}),e.jsx(o.Box,{component:"div",sx:j.footerBlock})]}),e.jsx("div",{style:{...j.onOffLine,...this.props.alive?j.green:j.red},children:this.props.alive&&e.jsx("div",{style:j.dotLine})}),e.jsxs("div",{ref:this.refWarning,style:{...j.imageBlock,...this.props.alive?void 0:j.instanceStateNotAlive1,background:this.props.host.common.color||"inherit"},children:[e.jsx(o.CardMedia,{sx:j.img,component:"img",image:this.props.host.common.icon||"img/no-image.svg"}),e.jsx(o.Box,{component:"div",style:h.Utils.getStyle(this.props.theme,j.adapter,{color:this.props.host.common.color&&h.Utils.invertColor(this.props.host.common.color,!0)||"inherit"}),children:this.renderNotificationsBadge(this.props.host.common.name,!0)}),this.state.openCollapse?null:e.jsx(o.Fab,{disabled:typeof s=="string",onClick:()=>this.setState({openCollapse:!0}),style:j.fab,color:"primary","aria-label":"add",title:this.props.t("Click for more"),children:e.jsx(y.MoreVert,{})})]}),e.jsxs(o.CardContent,{style:j.cardContentH5,children:[e.jsx(o.Typography,{variant:"body2",color:"textSecondary",component:"div",children:e.jsxs("div",{style:j.displayFlex,children:[e.jsx("span",{style:j.label,children:"CPU:"}),e.jsx("div",{ref:this.refCpu,style:j.value,children:"- %"})]})}),e.jsx(o.Typography,{variant:"body2",color:"textSecondary",component:"div",children:e.jsxs("div",{style:j.displayFlex,children:[e.jsx("span",{style:j.label,children:"RAM:"}),e.jsx("div",{ref:this.refMem,style:j.value,children:"- %"})]})}),e.jsx(o.Typography,{variant:"body2",color:"textSecondary",component:"div",children:e.jsxs("div",{style:j.displayFlex,children:[e.jsxs("span",{style:j.label,children:[this.props.t("Uptime"),":"]}),e.jsx("div",{ref:this.refUptime,style:j.value,children:"-d -h"})]})}),e.jsxs(o.Typography,{variant:"body2",color:"textSecondary",component:"div",style:j.wrapperAvailable,children:[e.jsxs("span",{style:j.label,children:[this.props.t("Available")," js-controller:"]}),e.jsx(o.Box,{component:"div",sx:{...t?j.greenText:void 0,...j.curdContentFlexCenter},children:this.renderUpdateButton(t)})]}),e.jsxs(o.Typography,{variant:"body2",color:"textSecondary",component:"p",children:[e.jsxs("span",{style:j.label,children:[this.props.t("Installed")," js-controller:"]}),e.jsx("span",{style:j.value,children:this.props.host.common.installedVersion})]}),e.jsx(o.Typography,{variant:"body2",color:"textSecondary",component:"div",children:e.jsxs("div",{style:j.displayFlex,children:[e.jsxs("span",{style:j.label,children:[this.props.t("Events"),":"]}),e.jsx("div",{ref:this.refEvents,style:j.value,children:"- / -"})]})}),e.jsx("div",{style:j.marginTop10,children:e.jsxs(o.Typography,{component:"span",style:j.enableButton,children:[this.renderEditButton(),this.renderHostBaseEdit(),this.renderRestartButton(),this.props.expertMode&&this.state.logLevel&&this.renderLogLevel(),this.renderRemoveButton(),this.renderCopyButton()]})})]})]},this.props.hostId)}}const v={..._,root:u=>({position:"relative",m:"7px",background:u.palette.background.default,boxShadow:lt,overflow:"hidden",transition:"box-shadow 0.5s,height 0.3s","&:hover":{boxShadow:ht}}),imageBlock:{marginRight:6,minHeight:60,width:"100%",maxWidth:300,display:"flex",padding:"0 10px 0 10px",position:"relative",justifyContent:"space-between",transition:"background 0.5s",alignItems:"baseline"},collapse:{height:215,backgroundColor:"rgba(128, 128, 128, 0.1)",width:"100%",zIndex:3,marginTop:"auto",bottom:0,transition:"height 0.3s",justifyContent:"space-between",display:"flex",flexDirection:"column"},collapseOn:{animation:"height 1s"},onOff:{alignSelf:"center",width:4,height:"100%"},host:u=>({width:"100%",fontWeight:"bold",fontSize:16,paddingLeft:"8px",alignSelf:"center",color:u.palette.mode==="dark"?"#ddd":"#222",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}),cardContentH5:{height:"100%",display:"flex",width:"100%",justifyContent:"space-between",padding:"10px !important",alignItems:"center"},marginTop10:{marginLeft:"auto",display:"flex"},enableButton:{display:"flex",justifyContent:"space-between"},green:{background:"#00ce00",position:"relative",overflow:"hidden"},dotLine:{width:10,height:20,background:"linear-gradient( rgba(0,206,0,0.7497373949579832) 0%, rgba(31,255,1,1) 50%, rgba(0,206,0,0.7805497198879552) 100%)",zIndex:2,position:"absolute",top:-21},red:{background:"#da0000"},flex:{flex:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},cardContentInfo:{overflow:"auto",paddingTop:0,justifyContent:"center",display:"flex",height:"100%",position:"relative"},cursorNoDrop:{cursor:"no-drop !important"},wrapperFlex:{display:"flex",cursor:"pointer","& .warning":{backgroundColor:"#de0000 !important","&:before":{position:"absolute",right:0,top:-5,content:'"⚠"',fontSize:25,height:"30px",width:"30px",color:"black"},animation:"$warning 2.5s ease-in-out infinite alternate"},"@media screen and (max-width: 500px)":{flexDirection:"column"}},wrapperColor:{position:"relative",overflow:"hidden"},hidden1100:{"@media screen and (max-width: 1100px)":{display:"none !important"}},hidden800:{"@media screen and (max-width: 800px)":{display:"none !important"}},hidden600:{"@media screen and (max-width: 600px)":{display:"none !important"}},curdContentFlexCenter:{display:"flex",alignItems:"center"},wrapperInfo:{display:"flex",flexFlow:"wrap",width:"100%",justifyContent:"space-around"},wrapperBlockItem:{display:"flex",flexFlow:"nowrap",whiteSpace:"nowrap",margin:10},bold:{fontWeight:"bold"},nowrap:{display:"flex",flexFlow:"nowrap",flex:1,whiteSpace:"nowrap",marginRight:5},cell:{}};class Mt extends A{renderValue(t){return typeof this.props.hostData!="object"?null:e.jsxs("div",{style:v.wrapperBlockItem,children:[e.jsxs("span",{style:{...v.bold,...v.nowrap},children:[this.props.t(t),": "]}),A.formatInfo[t]?A.formatInfo[t](this.props.hostData[t],this.props.t):this.props.hostData[t]||"--"]},t)}getHostDescriptionAll(){return this.props.hostData?typeof this.props.hostData=="string"?this.props.hostData:e.jsxs("div",{style:v.wrapperInfo,children:[e.jsx("div",{style:v.marginRight,children:this.props.hostData&&typeof this.props.hostData=="object"?Object.keys(this.props.hostData).map((t,s)=>s<=5&&this.renderValue(t)):e.jsx(o.Skeleton,{})}),e.jsx("div",{style:v.marginRight,children:this.props.hostData&&typeof this.props.hostData=="object"?Object.keys(this.props.hostData).map((t,s)=>s>5&&s<12&&this.renderValue(t)):e.jsx(o.Skeleton,{})}),e.jsx("div",{style:v.marginRight,children:this.props.hostData&&typeof this.props.hostData=="object"?Object.keys(this.props.hostData).map((t,s)=>s>=12&&this.renderValue(t)):e.jsx(o.Skeleton,{})})]}):e.jsx(o.Skeleton,{})}render(){const t=(this.props.isCurrentHost||this.props.alive)&&z.updateAvailable(this.props.host.common.installedVersion,this.props.available),s=this.getHostDescriptionAll();return e.jsxs(o.Box,{component:"div",sx:h.Utils.getStyle(this.props.theme,v.root,this.props.hidden&&v.hidden,{border:`2px solid ${this.props.host.common.color||"inherit"}`,borderRadius:"5px"}),children:[this.renderDialogs(),e.jsxs(o.Box,{component:"div",sx:{...v.wrapperFlex,...this.props.alive?void 0:v.cursorNoDrop},onClick:this.state.openDialogLogLevel?null:()=>this.setState({openCollapse:!this.state.openCollapse}),children:[e.jsxs("div",{style:v.wrapperColor,children:[e.jsx("div",{style:{...v.onOff,...this.props.alive?v.green:v.red}}),this.props.alive&&e.jsx("div",{style:v.dotLine})]}),e.jsxs("div",{ref:this.refWarning,style:{...v.imageBlock,background:this.props.host.common.color||"inherit"},children:[this.renderNotificationsBadge(e.jsx(o.CardMedia,{sx:v.img,component:"img",image:this.props.host.common.icon||"img/no-image.svg"}),!0),e.jsx("div",{style:h.Utils.getStyle(this.props.theme,v.host,{color:this.props.host.common.color&&h.Utils.invertColor(this.props.host.common.color,!0)||"inherit"}),children:this.props.host.common.name})]}),e.jsxs(o.CardContent,{sx:{"&.MuiCardContent-root":v.cardContentH5},children:[e.jsx(o.Typography,{sx:{...v.flex,...v.hidden800,...v.cell},variant:"body2",color:"textSecondary",component:"div",children:e.jsx("div",{ref:this.refCpu,children:"- %"})}),e.jsx(o.Typography,{sx:{...v.flex,...v.hidden800,...v.cell},variant:"body2",color:"textSecondary",component:"div",children:e.jsx("div",{ref:this.refMem,children:"- %"})}),e.jsx(o.Typography,{sx:{...v.flex,...v.hidden800,...v.cell},variant:"body2",color:"textSecondary",component:"div",children:e.jsx("div",{ref:this.refUptime,children:"-/-"})}),e.jsx(o.Typography,{sx:{...v.flex,...v.hidden1100},variant:"body2",color:"textSecondary",component:"p",children:this.props.host.common.installedVersion}),e.jsx(o.Typography,{sx:{...v.flex,...v.hidden1100,...v.cell},variant:"body2",color:"textSecondary",component:"div",children:e.jsx(o.Box,{component:"div",sx:{...t?v.greenText:void 0,...v.curdContentFlexCenter},children:this.renderUpdateButton(t)})}),e.jsx(o.Typography,{sx:{...v.flex,...v.hidden600,...v.cell},variant:"body2",color:"textSecondary",component:"div",children:e.jsx("div",{ref:this.refEvents,children:"- / -"})}),e.jsx("div",{style:v.marginTop10,children:e.jsxs(o.Typography,{component:"span",style:v.enableButton,children:[this.renderEditButton(),this.renderHostBaseEdit(),this.renderRestartButton(),this.props.expertMode&&this.state.logLevel?this.renderLogLevel():e.jsx("div",{style:v.emptyButton}),this.renderRemoveButton(),this.renderExtendButton(this.state.openCollapse)]})})]})]}),typeof s=="object"&&e.jsxs("div",{style:{...v.collapse,...this.state.openCollapse?v.collapseOn:v.collapseOff},onClick:r=>r.stopPropagation(),children:[e.jsxs(o.CardContent,{style:v.cardContentInfo,children:[s,this.renderCopyButton({height:44,width:44})]}),e.jsx(o.Box,{component:"div",sx:v.footerBlock})]})]},this.props.hostId)}}const w={grow:{flexGrow:1},cards:{display:"flex",flexFlow:"wrap",justifyContent:"center"},tabHeaderWrapper:{height:30,display:"flex",margin:7},tabHeaderFirstItem:{width:306,paddingLeft:30,fontSize:14,fontWeight:600,alignSelf:"center"},tabHeaderItem:{flex:1,fontSize:14,fontWeight:600,alignSelf:"center"},tabHeaderItemButton:{fontSize:14,fontWeight:600,alignSelf:"center"},tabFlex:{display:"flex",flex:1,padding:"0 10px"},hidden1100:{"@media screen and (max-width: 1100px)":{display:"none !important"}},hidden800:{"@media screen and (max-width: 800px)":{display:"none !important"}},hidden600:{"@media screen and (max-width: 600px)":{display:"none !important"}},jsController:{fontSize:12,opacity:.4,display:"block",whiteSpace:"nowrap"},tooltip:{pointerEvents:"none"}},R={};function Rt(u){var t;if((t=u.dockerInformation)!=null&&t.isDocker){let s=u.dockerInformation.isOfficial?"official image":"unofficial image";u.dockerInformation.isOfficial&&(s+=` - ${u.dockerInformation.officialVersion}`),u.Platform=`${u.Platform} (${s})`}delete u.dockerInformation}class ye extends T.Component{constructor(t){super(t),this.state={viewMode:(window._localStorage||window.localStorage).getItem("Hosts.viewMode")==="true",alive:{},hosts:[],repository:{},hostsData:{},filterText:(window._localStorage||window.localStorage).getItem("Hosts.filterText")||"",showSlowConnectionWarning:!1,readTimeoutMs:st.getReadTimeoutMs()}}t=(t,s,r)=>(s!==void 0&&r!==void 0&&!R[`${t} ${s} ${r}`]?R[`${t} ${s} ${r}`]=this.props.t(t,s,r):s!==void 0&&!R[`${t} ${s}`]?R[`${t} ${s}`]=this.props.t(t,s):R[t]||(R[t]=this.props.t(t)),s!==void 0&&r!==void 0?R[`${t} ${s} ${r}`]:s!==void 0?R[`${t} ${s}`]:R[t]);componentDidMount(){this.readInfo().then(()=>{this.props.hostsWorker.registerHandler(this.updateHosts),this.props.hostsWorker.registerAliveHandler(this.updateHostsAlive)})}componentWillUnmount(){this.props.hostsWorker.unregisterHandler(this.updateHosts),this.props.hostsWorker.unregisterAliveHandler(this.updateHostsAlive)}getHostsData(t,s){const r=[];for(let p=0;p<t.length;p++)if(s[t[p]._id]){const b=this.props.socket.getHostInfo(t[p]._id,null,this.state.readTimeoutMs).catch(g=>(console.error(`Cannot get getHostInfo: ${g}`),g.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0}),{id:t[p]._id,data:g.toString()})).then(g=>(Rt(g),{id:t[p]._id,data:g}));r.push(b)}else r.push(Promise.resolve({id:t[p]._id,data:"offline"}));return Promise.all(r).then(p=>{const b={};return p.forEach(g=>b[g.id]=g.data),b})}async readInfo(){try{const t=await this.props.socket.getHosts(!0),s=await this.props.socket.getRepository(this.props.currentHost,{update:!1},!1,this.state.readTimeoutMs),r=JSON.parse(JSON.stringify(this.state.alive));for(let g=0;g<t.length;g++){const k=await this.props.socket.getState(`${t[g]._id}.alive`);r[t[g]._id]=k?!!k.val:!1}const p=await this.getHostsData(t,r),b={alive:r,hosts:t,hostsData:p,repository:s};this.state.filterText&&t.length<=2&&(b.filterText=""),this.setState(b)}catch(t){window.alert(`Cannot getRepository: ${t}`),t.toString().includes("timeout")&&this.setState({showSlowConnectionWarning:!0})}}updateHosts=t=>{const s=JSON.parse(JSON.stringify(this.state.hosts)),r=JSON.parse(JSON.stringify(this.state.alive));Promise.all(t.map(async p=>{const b=s.findIndex(g=>g._id===p.id);if(b!==-1)p.obj?s[b]=p.obj:s.splice(b,1);else{const g=await this.props.socket.getState(`${p.id}.alive`);r[p.id]=!!(g!=null&&g.val),s.push(p.obj)}})).then(()=>{const p={hosts:s,alive:r};this.state.filterText&&s.length<=2&&(p.filterText=""),this.setState(p)})};updateHostsAlive=t=>{const s=JSON.parse(JSON.stringify(this.state.alive));let r=!1;t.forEach(p=>{p.type==="deleted"?s[p.id]!==void 0&&(delete s[p.id],r=!0):!!s[p.id]!=!!p.alive&&(s[p.id]=p.alive,r=!0)}),r&&this.setState({alive:s})};getPanelsOrRows(){const t=this.renderHosts().filter(s=>s);return t.length?t:this.t("All items are filtered out")}renderSlowConnectionWarning(){return this.state.showSlowConnectionWarning?e.jsx(st,{readTimeoutMs:this.state.readTimeoutMs,t:this.t,onClose:async t=>{this.setState({showSlowConnectionWarning:!1}),t&&(this.setState({readTimeoutMs:t}),await this.readInfo())}}):null}renderHosts(){return this.state.hosts.map(t=>{var r;if(this.state.filterText&&!t.common.name.toLowerCase().includes(this.state.filterText.toLowerCase()))return null;const s=this.state.viewMode?At:Mt;return e.jsx(s,{adminInstance:this.props.adminInstance,alive:this.state.alive[t._id],available:((r=this.state.repository["js-controller"])==null?void 0:r.version)||"-",executeCommandRemove:()=>this.props.executeCommand(`host remove ${t.common.name}`),expertMode:this.props.expertMode,host:t,hostData:this.state.hostsData[t._id],hostId:t._id,hostsWorker:this.props.hostsWorker,isCurrentHost:this.props.currentHost===t._id,jsControllerInfo:this.state.repository["js-controller"],lang:this.props.lang,noTranslation:this.props.noTranslation,onUpdating:this.props.onUpdating,showAdaptersWarning:this.props.showAdaptersWarning,socket:this.props.socket,systemConfig:this.props.systemConfig,t:this.t,theme:this.props.theme,themeType:this.props.themeType,toggleTranslation:this.props.toggleTranslation},t._id)})}renderTableHeader(){const t=window.innerWidth<100?10:window.innerWidth<1200?12:14;return e.jsxs("div",{style:w.tabHeaderWrapper,children:[e.jsx("div",{style:w.tabHeaderFirstItem,children:this.t("Name:")}),e.jsxs("div",{style:w.tabFlex,children:[e.jsx(o.Box,{component:"div",sx:h.Utils.getStyle(this.props.theme,w.tabHeaderItem,w.hidden800,{fontSize:t}),children:"CPU"}),e.jsx(o.Box,{component:"div",sx:h.Utils.getStyle(this.props.theme,w.tabHeaderItem,w.hidden800,{fontSize:t}),children:"RAM"}),e.jsx(o.Box,{component:"div",sx:h.Utils.getStyle(this.props.theme,w.tabHeaderItem,w.hidden800,{fontSize:t}),children:this.t("Uptime")}),e.jsxs(o.Box,{component:"div",sx:h.Utils.getStyle(this.props.theme,w.tabHeaderItem,w.hidden1100,{fontSize:t}),children:[this.t("Installed"),e.jsx("div",{style:w.jsController,children:"js-controller"})]}),e.jsxs(o.Box,{component:"div",sx:h.Utils.getStyle(this.props.theme,w.tabHeaderItem,w.hidden1100,{fontSize:t}),children:[this.t("Available"),e.jsx("div",{style:w.jsController,children:"js-controller"})]}),e.jsx(o.Box,{component:"div",sx:h.Utils.getStyle(this.props.theme,w.tabHeaderItem,w.hidden600,{fontSize:t}),children:this.t("Events")}),e.jsx("div",{style:{...w.tabHeaderItemButton,width:this.props.expertMode?292:244}})]})]})}render(){return this.state.hosts.length?e.jsxs(h.TabContainer,{children:[e.jsx("style",{children:Bt}),this.renderSlowConnectionWarning(),e.jsxs(h.TabHeader,{children:[e.jsx(o.Tooltip,{title:this.t("Show / hide List"),slotProps:{popper:{sx:w.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",this.state.viewMode?"false":"true"),this.setState({viewMode:!this.state.viewMode})},children:this.state.viewMode?e.jsx(y.ViewModule,{}):e.jsx(y.ViewList,{})})}),e.jsx(o.Tooltip,{title:this.t("Reload"),slotProps:{popper:{sx:w.tooltip}},children:e.jsx(o.IconButton,{size:"large",onClick:()=>this.forceUpdate(),children:e.jsx(y.Refresh,{})})}),e.jsx("div",{style:w.grow}),this.state.hosts.length>2?e.jsx(o.TextField,{variant:"standard",label:this.t("Filter"),style:{margin:"5px 0"},value:this.state.filterText,onChange:t=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",t.target.value),this.setState({filterText:t.target.value})},slotProps:{input:{endAdornment:this.state.filterText?e.jsx(o.InputAdornment,{position:"end",children:e.jsx(o.IconButton,{tabIndex:-1,size:"small",onClick:()=>{(window._localStorage||window.localStorage).setItem("Hosts.viewMode",""),this.setState({filterText:""})},children:e.jsx(y.Close,{})})}):null}}}):null,e.jsx("div",{style:w.grow})]}),e.jsxs(h.TabContent,{overflow:"auto",children:[h.Utils.isStableRepository(this.props.systemConfig.common.activeRepo)||String(this.props.systemConfig.common.activeRepo||"").toLowerCase()==="nexowatt"?null:e.jsx(o.Box,{sx:{marginX:2,width:"calc(100% - 32px)",alignSelf:"center"},children:e.jsx(h.InfoBox,{type:"warning",children:this.t('Active repo is "%s"',this.props.systemConfig.common.activeRepo)})}),e.jsxs("div",{style:this.state.viewMode?w.cards:void 0,children:[!this.state.viewMode&&this.renderTableHeader(),this.getPanelsOrRows()]})]})]}):e.jsx(o.LinearProgress,{})}}export{ye as default};
|