iobroker.admin 7.6.13 → 7.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +2 -1
  2. package/adminWww/assets/{AdapterUpdateDialog-B8g_ZuhP.js → AdapterUpdateDialog-B6VPfFAv.js} +1 -1
  3. package/adminWww/assets/{Adapters-XtPWdL3s.js → Adapters-BUS-m5sC.js} +1 -1
  4. package/adminWww/assets/{Config-Dhj9WMpz.js → Config-JGWRs4Md.js} +1 -1
  5. package/adminWww/assets/{CustomModal-4eTuDNla.js → CustomModal-DTJBMSYG.js} +1 -1
  6. package/adminWww/assets/{CustomTab-CSgGzXlh.js → CustomTab-zV14j14y.js} +1 -1
  7. package/adminWww/assets/{EasyMode-Bwx_UimW.js → EasyMode-Ddluonyq.js} +1 -1
  8. package/adminWww/assets/{Enums-B-PrqYys.js → Enums-B9Vu_bT7.js} +1 -1
  9. package/adminWww/assets/{Fields-CYjxm_8L.js → Fields-DFmrkQbX.js} +1 -1
  10. package/adminWww/assets/{Files-CsBMd5VX.js → Files-Dna7TJ1l.js} +1 -1
  11. package/adminWww/assets/{Hosts-D7aAXH9U.js → Hosts-Crda8GGz.js} +1 -1
  12. package/adminWww/assets/{Instances-Bj8CqStT.js → Instances-C6ivUbdr.js} +2 -2
  13. package/adminWww/assets/{Intro-sAT0x17e.js → Intro-BKq04_0O.js} +1 -1
  14. package/adminWww/assets/{Logs-Bb16bYuu.js → Logs-C1D65jm_.js} +1 -1
  15. package/adminWww/assets/{Objects-C7k5tHdx.js → Objects-DrIz44vD.js} +1 -1
  16. package/adminWww/assets/{State-DPLzxZ6D.js → State-C03R1qSx.js} +1 -1
  17. package/adminWww/assets/{Users-BQ3pWAxq.js → Users-CpmGZkwf.js} +1 -1
  18. package/adminWww/assets/{bootstrap-BNkcLa73.js → bootstrap-DlPDCLBt.js} +6 -6
  19. package/adminWww/assets/{index-C6O1p4S2.js → index-DjASwRZE.js} +2 -2
  20. package/adminWww/assets/{sentry-9i5rBs6L.js → sentry-BjvSHsab.js} +1 -1
  21. package/adminWww/assets/{zh-cn-CULr7ytT.js → zh-cn-C_xZjEmq.js} +1 -1
  22. package/adminWww/index.html +1 -1
  23. package/adminWww/mf-manifest.json +1 -1
  24. package/adminWww/remoteEntry.js +2 -2
  25. package/io-package.json +2 -2
  26. package/package.json +4 -4
@@ -1 +1 @@
1
- import{j as t}from"./DefaultPropsProvider-BrbE0teb.js";import{X as P,Y as O,U as h,i,a as d,b as w,Z as F,f as b,_ as E,$ as N,a0 as W,a1 as z,h as B,T as R}from"./bootstrap-BNkcLa73.js";import{i as j}from"./iobroker_admin__loadShare__react__loadShare__-DtlEM_52.js";import{I as y,a as S,b as $}from"./Fields-CYjxm_8L.js";import A from"./user1-BHHH0LIq.js";import M from"./user2-BN56rMPt.js";import L from"./user3-Mx6XZSLK.js";import H from"./user4-DpEs_YiD.js";import Y from"./user5-CVfrnlXE.js";import q from"./user6-C7HkYnq4.js";import V from"./user7-VAQcubFn.js";import X from"./user8-CwACr_jq.js";import Z from"./user9-Dk4Mlhcc.js";import J from"./user10-Dvmqf8l1.js";import K from"./user11-C8ly5pY7.js";import Q from"./user12-CHtaF3qG.js";import ee from"./group1-DBYxcyxq.js";import te from"./group2-BUQSell7.js";import se from"./group3-B0AdMrOp.js";import oe from"./group4-TeCgDok7.js";import ie from"./group5-CJ_-VPxg.js";import re from"./group6-JW-nEhw_.js";import ne from"./group7-CWpVuR4T.js";import le from"./group8-CRGBxCwd.js";import ae from"./group9-BXRQchYG.js";import ce from"./group10-BIcZMfE3.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BGyJCibC.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-j1VT51C2.js";import"./FilledInput-D-tz8rvg.js";import"./preload-helper-C1FmrZbK.js";import"./blueGrey-B0oIowPK.js";import"./emotion-cache.browser.esm-B8BFze5o.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-B1OZ7tj-.js";import"./extends-CF3RwP-h.js";const k=e=>{const s=e.isDragging?0:1,o=h.getInvertedColor(e.user.common.color,e.themeType,!0),r={cursor:"grab",opacity:s,overflow:"hidden",color:o};return e.user.common.color&&(r.backgroundColor=e.user.common.color),t.jsx(i.Card,{style:r,sx:e.styles.userGroupCard2,children:t.jsxs("div",{style:e.styles.userCardContent,children:[t.jsxs("div",{style:e.styles.right,children:[t.jsx(i.Checkbox,{checked:e.user.common.enabled,style:{color:o},disabled:e.user.common.dontDelete,onChange:()=>{e.socket.extendObject(e.user._id,{common:{enabled:!e.user.common.enabled}}).then(()=>e.updateData())}}),t.jsx(i.IconButton,{size:"small",onClick:()=>e.showUserEditDialog(e.user,!1),children:t.jsx(d.Edit,{style:{color:o}})}),t.jsx(i.IconButton,{size:"small",onClick:()=>e.showUserDeleteDialog(e.user),disabled:e.user.common.dontDelete,children:t.jsx(d.Delete,{style:e.user.common.dontDelete?null:{color:o}})})]}),t.jsxs(i.CardContent,{children:[t.jsxs(i.Typography,{gutterBottom:!0,component:"div",style:e.styles.userGroupTitle,children:[e.user.common.icon?t.jsx(w,{style:e.styles.icon,src:e.user.common.icon}):t.jsx(d.Person,{style:e.styles.icon}),t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx("span",{style:e.styles.userGroupUserName,children:e.getText(e.user.common.name)}),t.jsxs("span",{style:e.styles.userGroupUserID,children:["[",e.user._id,"]"]})]}),t.jsx("span",{children:e.user.common.desc?t.jsx("div",{style:e.styles.description,children:e.getText(e.user.common.desc)}):null})]})]}),e.groups.find(n=>n.common.members&&n.common.members.includes(e.user._id))?t.jsxs("div",{children:[e.t("In groups"),":"]}):null,t.jsx("div",{children:e.groups.map(n=>{var m,p;if(!n.common.members||!n.common.members.includes(e.user._id))return null;const a=n&&((m=n.common)!=null&&m.color)?h.getInvertedColor(n.common.color,e.themeType,!0):o;return t.jsxs(i.Card,{variant:"outlined",sx:e.styles.userGroupMember,style:{color:a,borderColor:`${a}80`,background:((p=n.common)==null?void 0:p.color)||"inherit"},children:[n.common.icon?t.jsx(w,{style:e.styles.icon,src:n.common.icon}):t.jsx(d.Group,{style:e.styles.icon}),e.getText(n.common.name),t.jsx(i.IconButton,{size:"small",onClick:()=>e.removeUserFromGroup(e.user._id,n._id),children:t.jsx(d.Clear,{style:{color:a}})})]},n._id)})})]})]})})},de=e=>{const s=j.useRef(),[{isDragging:o},r,n]=P({type:"user",item:()=>{var a;return{userId:e.user._id,preview:t.jsx("div",{style:{width:(a=s.current)==null?void 0:a.offsetWidth},children:t.jsx(k,{...e})})}},end:(a,m)=>{const p=m.getDropResult();a&&p&&e.addUserToGroup(a.userId,p.groupId)},collect:a=>({isDragging:a.isDragging(),handlerId:a.getHandlerId()})});return j.useEffect(()=>{n(O(),{captureDraggingState:!0})},[n]),t.jsx("div",{ref:r,children:t.jsx("div",{ref:s,children:t.jsx(k,{isDragging:o,...e})})})};function he(e,s){return s.group.common.members?!s.group.common.members.includes(e.getItem().userId):!0}const me=e=>{var D;const[{CanDrop:s,isOver:o},r]=F(()=>({accept:"user",drop:()=>({groupId:e.group._id}),canDrop:(g,c)=>he(c,e),collect:g=>({isOver:g.isOver(),CanDrop:g.canDrop()})}),[e.group.common.members]);let n=.7,a;s&&o?(n=s?1:.125,a=e.styles.userGroupCardSecondary):s&&(n=s?.75:.25);const p=h.getInvertedColor(e.group.common.color,e.themeType,!0),x={opacity:n,overflow:"hidden",color:p};return e.group.common.color&&(x.backgroundColor=e.group.common.color),t.jsxs(i.Card,{style:x,ref:r,sx:h.getStyle(e.theme,e.styles.userGroupCard2,a),children:[t.jsxs("div",{style:e.styles.right,children:[t.jsx(i.IconButton,{size:"small",onClick:()=>e.showGroupEditDialog(e.group,!1),children:t.jsx(d.Edit,{style:{color:p}})}),t.jsx(i.IconButton,{size:"small",onClick:()=>e.showGroupDeleteDialog(e.group),disabled:e.group.common.dontDelete,children:t.jsx(d.Delete,{style:e.group.common.dontDelete?null:{color:p}})})]}),t.jsxs(i.CardContent,{children:[t.jsxs(i.Typography,{gutterBottom:!0,component:"div",style:e.styles.userGroupTitle,children:[e.group.common.icon?t.jsx(w,{style:e.styles.icon,src:e.group.common.icon}):t.jsx(d.Group,{style:e.styles.icon}),t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx("span",{style:e.styles.userGroupUserName,children:e.getText(e.group.common.name)}),t.jsxs("span",{children:["[",e.group._id,"]"]})]}),e.group.common.desc?t.jsx("div",{style:e.styles.description,children:e.getText(e.group.common.desc)}):null]})]}),(D=e.group.common.members)!=null&&D.length?t.jsxs("div",{children:[e.t("Group members"),":"]}):null,t.jsx("div",{children:(e.group.common.members||[]).map((g,c)=>{var G,T;const l=e.users.find(I=>I._id===g),f=l&&((G=l.common)!=null&&G.color)?h.getInvertedColor(l.common.color,e.themeType,!0):p;return l?t.jsxs(i.Card,{variant:"outlined",sx:e.styles.userGroupMember,style:{color:f,borderColor:`${f}40`,background:((T=l.common)==null?void 0:T.color)||"inherit"},children:[l.common.icon?t.jsx(w,{style:e.styles.icon,src:l.common.icon}):t.jsx(d.Person,{style:e.styles.icon}),e.getText(l.common.name),t.jsx(i.IconButton,{size:"small",onClick:()=>e.removeUserFromGroup(g,e.group._id),children:t.jsx(d.Clear,{style:{color:f}})})]},c):null})})]})]})},_=[A,M,L,H,Y,q,V,X,Z,J,K,Q],pe={contentRoot:{padding:"16px 24px"}};class ue extends j.Component{constructor(s){super(s),this.state={originalId:s.user._id,passwordRepeat:s.user.common.password}}componentDidMount(){if(this.props.isNew){const s=_[Math.round(Math.random()*(_.length-1))];s&&h.getSvg(s).then(o=>{const r=h.clone(this.props.user);r.common.icon=o,this.props.onChange(r)})}}render(){const s=this.props.users.find(c=>c._id===this.props.user._id),o=this.props.user._id!==this.state.originalId,r=c=>c.split(".").pop(),n=c=>c.replace(h.FORBIDDEN_CHARS,"_").replace(/\s/g,"_").replace(/\./g,"_").replace(/,/g,"_").replace(/__/g,"_").replace(/__/g,"_").toLowerCase(),a=(c,l)=>{const f=c.split(".");return f[f.length-1]=l,f.join(".")},m=this.props.getText(this.props.user.common.desc),p=this.props.getText(this.props.user.common.name),x=b.checkPassword(this.props.user.common.password),D=b.checkPassword(this.props.user.common.password,this.state.passwordRepeat);let g=this.props.user._id!=="system.user."&&!x&&!D;return(this.props.isNew&&s||s&&o)&&(g=!1),t.jsxs(i.Dialog,{fullWidth:this.props.innerWidth<500,open:!0,onClose:(c,l)=>{l!=="backdropClick"&&l!=="escapeKeyDown"&&this.props.onClose()},children:[t.jsx(i.DialogTitle,{style:{...this.props.styles.dialogTitle,padding:12},children:this.props.t("User parameters")}),t.jsx(i.DialogContent,{sx:{"&.MuiDialogContent-root":{...this.props.innerWidth<500?this.props.styles.narrowContent:void 0,...pe.contentRoot}},children:t.jsxs(i.Grid2,{container:!0,spacing:this.props.innerWidth<500?1:4,style:this.props.styles.dialog,children:[t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Name",t:this.props.t,value:p,onChange:c=>{const l=h.clone(this.props.user);!this.props.user.common.dontDelete&&n(this.props.getText(l.common.name))===r(l._id)&&(l._id=a(l._id,n(c))),l.common.name=c,this.props.onChange(l)},autoComplete:"new-password",icon:d.TextFields,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"ID edit",t:this.props.t,disabled:this.props.user.common.dontDelete,value:this.props.user._id.split(".")[this.props.user._id.split(".").length-1],onChange:c=>{const l=h.clone(this.props.user);l._id=a(l._id,n(c)),this.props.onChange(l)},icon:d.LocalOffer,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"ID preview",t:this.props.t,disabled:!0,value:this.props.user._id,icon:d.Pageview,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Description",t:this.props.t,value:m,onChange:c=>{const l=h.clone(this.props.user);l.common.desc=c,this.props.onChange(l)},icon:d.Description,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Password",t:this.props.t,value:this.props.user.common.password,error:x?this.props.t(x):void 0,onChange:c=>{const l=h.clone(this.props.user);l.common.password=c,this.props.onChange(l)},type:"password",autoComplete:"new-password",icon:d.VpnKey,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Password repeat",t:this.props.t,value:this.state.passwordRepeat,error:D?this.props.t(D):void 0,onChange:c=>this.setState({passwordRepeat:c}),type:"password",autoComplete:"new-password",icon:d.VpnKey,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(E,{icons:_,label:"Icon",value:this.props.user.common.icon,onChange:c=>{const l=h.clone(this.props.user);l.common.icon=c,this.props.onChange(l)},previewStyle:this.props.styles.iconPreview,icon:d.Image})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(S,{label:"Color",t:this.props.t,value:this.props.user.common.color,previewStyle:this.props.styles.iconPreview,onChange:c=>{const l=h.clone(this.props.user);l.common.color=c,this.props.onChange(l)},icon:d.ColorLens,style:this.props.styles.colorPicker,styles:this.props.styles})})]})}),t.jsxs(i.DialogActions,{style:this.props.styles.dialogActions,children:[t.jsx(i.Button,{variant:"contained",color:"primary",autoFocus:!0,onClick:()=>this.props.saveData(this.props.isNew?null:this.state.originalId),disabled:!g,startIcon:t.jsx(d.Check,{}),children:this.props.t("Save")}),t.jsx(i.Button,{variant:"contained",color:"grey",onClick:this.props.onClose,startIcon:t.jsx(d.Close,{}),children:this.props.t("Cancel")})]})]})}}const v=[ee,te,se,oe,ie,re,ne,le,ae,ce];function ge(e){const s=(r,n)=>Object.values(r).map((a,m)=>{const p=Object.keys(r)[m];return n(a,p)});let o=e.group.common.acl;return o=o||{},o.object=o.object||{read:!0,list:!0,write:!0,delete:!1,create:void 0},o.object={read:!0,list:!0,write:!0,delete:!1,...o.object},o.state=o.state||{read:!0,list:!0,write:!0,delete:!1,create:void 0},o.state={read:!0,list:!0,write:!0,delete:!1,...o.state},o.users=o.users||{write:!1,delete:!1,create:!1,list:void 0,read:void 0},o.users={write:!1,delete:!1,create:!1,...o.users},o.other=o.other||{http:!1,execute:!1,sendto:!0},o.other={http:!1,execute:!1,sendto:!0,...o.other},o.file=o.file||{read:!0,list:!0,write:!1,delete:!1,create:!1},o.file={read:!0,list:!0,write:!1,delete:!1,create:!1,...o.file},t.jsx(i.Grid2,{container:!0,spacing:e.innerWidth<500?1:4,style:e.styles.dialog,children:s(e.group.common.acl||{},(r,n)=>t.jsxs(i.Grid2,{size:{xs:12,md:12},children:[t.jsx(i.Box,{component:"h2",sx:e.styles.permHeaders,children:e.t(`group_acl_${n}`)}),s(r,(a,m)=>t.jsx(i.FormControlLabel,{control:t.jsx(i.Checkbox,{disabled:e.group._id==="system.group.administrator",checked:a,onChange:p=>{const x=h.clone(e.group);x.common.acl[n][m]=p.target.checked,e.onChange(x)}}),label:e.t(`group_acl_${m}`),labelPlacement:"top"},m))]},n))},"PermissionsTab")}const xe={contentRoot:{padding:"16px 24px"}};class fe extends j.Component{constructor(s){super(s),this.state={tab:0,originalId:s.group._id}}componentDidMount(){if(this.props.isNew){const s=v[Math.round(Math.random()*(v.length-1))];s&&h.getSvg(s).then(o=>{const r=h.clone(this.props.group);r.common.icon=o,this.props.onChange(r)})}}render(){const s=this.props.groups.find(c=>c._id===this.props.group._id),o=this.props.group._id!==this.state.originalId;let r=this.props.group._id!=="system.group."&&this.props.group.common.password===this.props.group.common.passwordRepeat;const n=c=>c.split(".").pop(),a=c=>c.replace(h.FORBIDDEN_CHARS,"_").replace(/\s/g,"_").replace(/\./g,"_").toLowerCase(),m=(c,l)=>{const f=c.split(".");return f[f.length-1]=l,f.join(".")};this.props.isNew?s&&(r=!1):s&&o&&(r=!1);const p=this.props.getText(this.props.group.common.desc),x=this.props.getText(this.props.group.common.name),g=[t.jsxs(i.Grid2,{container:!0,spacing:this.props.innerWidth<500?1:4,style:this.props.styles.dialog,children:[t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Name",t:this.props.t,value:x,onChange:c=>{const l=h.clone(this.props.group);!this.props.group.common.dontDelete&&a(this.props.getText(l.common.name))===n(l._id)&&(l._id=m(l._id,a(c))),l.common.name=c,this.props.onChange(l)},autoComplete:"off",icon:d.TextFields,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"ID edit",t:this.props.t,disabled:this.props.group.common.dontDelete,value:this.props.group._id.split(".")[this.props.group._id.split(".").length-1],onChange:c=>{const l=h.clone(this.props.group);l._id=m(l._id,a(c)),this.props.onChange(l)},icon:d.LocalOffer,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"ID preview",t:this.props.t,disabled:!0,value:this.props.group._id,icon:d.Pageview,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Description",t:this.props.t,value:p,onChange:c=>{const l=h.clone(this.props.group);l.common.desc=c,this.props.onChange(l)},icon:d.Description,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(E,{label:"Icon",icons:v,value:this.props.group.common.icon,onChange:c=>{const l=h.clone(this.props.group);l.common.icon=c,this.props.onChange(l)},previewStyle:this.props.styles.iconPreview,icon:d.Image})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(S,{label:"Color",t:this.props.t,value:this.props.group.common.color,previewStyle:this.props.styles.iconPreview,onChange:c=>{const l=h.clone(this.props.group);l.common.color=c,this.props.onChange(l)},icon:d.ColorLens,style:this.props.styles.colorPicker,styles:this.props.styles})})]}),ge(this.props)][this.state.tab];return t.jsxs(i.Dialog,{open:!0,onClose:(c,l)=>{l!=="backdropClick"&&l!=="escapeKeyDown"&&this.props.onClose()},fullWidth:this.props.innerWidth<500,children:[t.jsx(i.DialogTitle,{style:this.props.styles.dialogTitle,children:t.jsxs(i.Tabs,{variant:"fullWidth",value:this.state.tab,onChange:(c,l)=>this.setState({tab:l}),children:[t.jsx(i.Tab,{label:this.props.t("Main"),value:0}),t.jsx(i.Tab,{label:this.props.t("Permissions"),value:1})]})}),t.jsx(i.DialogContent,{sx:{"&.MuiDialogContent-root":{...this.props.innerWidth<500?this.props.styles.narrowContent:void 0,...xe.contentRoot}},children:g}),t.jsxs(i.DialogActions,{style:this.props.styles.dialogActions,children:[t.jsx(i.Button,{variant:"contained",color:"primary",autoFocus:!0,onClick:()=>this.props.saveData(this.props.isNew?null:this.state.originalId),disabled:!r,startIcon:t.jsx(d.Check,{}),children:this.props.t("Save")}),t.jsx(i.Button,{variant:"contained",color:"grey",onClick:this.props.onClose,startIcon:t.jsx(d.Close,{}),children:this.props.t("Cancel")})]})]})}}function ye(e){return t.jsxs(i.Dialog,{open:!0,onClose:e.onClose,children:[t.jsx(i.DialogTitle,{children:e.t("Please confirm")}),t.jsx(i.DialogContent,{children:t.jsx(i.DialogContentText,{children:e.t("Do you want to delete user %s?",e.getText(e.user.common.name))})}),t.jsxs(i.DialogActions,{children:[t.jsx(i.Button,{variant:"contained",color:"primary",onClick:()=>e.deleteUser(e.user._id),startIcon:t.jsx(d.Delete,{}),children:e.t("Delete")}),t.jsx(i.Button,{variant:"contained",color:"grey",autoFocus:!0,onClick:e.onClose,startIcon:t.jsx(d.Close,{}),children:e.t("Cancel")})]})]})}function De(e){return t.jsxs(i.Dialog,{open:!0,onClose:e.onClose,children:[t.jsx(i.DialogTitle,{children:e.t("Please confirm")}),t.jsx(i.DialogContent,{children:t.jsx(i.DialogContentText,{children:e.t("Do you want to delete group %s?",e.getText(e.group.common.name))})}),t.jsxs(i.DialogActions,{style:e.styles.dialogActions,children:[t.jsx(i.Button,{variant:"contained",color:"primary",onClick:()=>e.deleteGroup(e.group._id),startIcon:t.jsx(d.Delete,{}),children:e.t("Delete")}),t.jsx(i.Button,{variant:"contained",color:"grey",autoFocus:!0,onClick:e.onClose,startIcon:t.jsx(d.Close,{}),children:e.t("Cancel")})]})]})}const U="***********",Ce="0 1px 1px 0 rgba(0, 0, 0, .4),0 6px 6px 0 rgba(0, 0, 0, .2)",u={mainGridCont:{height:"calc(100% - 55px)",overflowY:"auto"},childGridCont:{display:"flex",flexDirection:"column"},childGridContWide:{height:"100%"},canDrop:e=>({backgroundColor:e.palette.background.default}),headContainer:{margin:10},blocksContainer:{overflowY:"auto",overflowX:"hidden"},userGroupCard2:e=>({border:"1px solid #FFF",borderColor:e.palette.divider,m:"10px",minHeight:150,backgroundColor:e.palette.background.default,color:e.palette.text.primary,transition:"all 200ms ease-out",opacity:1,overflow:"hidden","&:hover":{overflowY:"auto",boxShadow:Ce}}),userGroupCardSecondary:e=>({color:e.palette.text.primary,backgroundColor:e.palette.success.light}),permHeaders:e=>({backgroundColor:e.palette.mode==="dark"?e.palette.background.default:e.palette.primary.main,p:"4px",borderRadius:"2px",color:"#EEE"}),userCardContent:{height:"100%",opacity:1},userGroupTitle:{display:"inline-flex",alignItems:"center"},userGroupUserName:{fontWeight:900,padding:5},userGroupUserID:{opacity:.7,padding:5},description:{fontSize:10,fontStyle:"italic",marginLeft:5,opacity:.7},userGroupMember:e=>({display:"inline-flex",m:"4px",p:"4px",backgroundColor:"#00000010",border:"1px solid #FFF",borderColor:e.palette.text.primary,color:e.palette.text.primary,alignItems:"center"}),icon:{height:32,width:32,marginRight:5,backgroundSize:"cover",backgroundPosition:"center"},right:{float:"right"},left:{float:"left",marginRight:10},dialog:{},flex:{display:"flex"},formControl:{display:"flex",padding:24,flexGrow:1e3},formContainer:{display:"flex",justifyContent:"center",alignItems:"center"},formIcon:{margin:10,opacity:.6},descriptionPanel:e=>({width:"100%",backgroundColor:"transparent",mb:"20px",mt:"20px",ml:"20px",opacity:.75,border:"none",display:"flex",alignItems:"center","& a":{pl:"3px",color:e.palette.mode==="dark"?"#EEE":"#111"}}),dialogTitle:{borderBottom:"1px solid #00000020",padding:0,width:"100%"},dialogActions:{borderTop:"1px solid #00000020",width:"100%"},dialogPaper:{overflowY:"initial",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"calc(100% - 100px)",height:"calc(100% - 100px)",maxWidth:800,maxHeight:"100%"},dialogPaperMini:{maxHeight:300},colorPicker:{},iconPreview:{height:40,width:40},mainDescription:{fontSize:"200%"},deleteDialog:{padding:20},narrowContent:{padding:"8px 8px 8px 8px"}},je=()=>{const e=$();return e.display?t.jsx("div",{style:e.style,children:e.item.preview}):null},we={_id:"system.user.",type:"user",common:{name:"",password:"",enabled:!0,color:"",desc:""},native:{},enums:{}},_e={_id:void 0,native:{},type:"group",common:{name:"",desc:"",members:[],dontDelete:void 0,acl:{object:{list:!1,read:!1,write:!1,delete:!1,create:void 0},state:{list:!1,read:!1,write:!1,create:!1,delete:!1},users:{list:!1,read:!1,write:!1,create:!1,delete:!1},other:{execute:!1,http:!1,sendto:!1},file:{list:!1,read:!1,write:!1,create:!1,delete:!1}},icon:"",color:""}};class C extends j.Component{constructor(s){super(s),this.state={users:null,groups:null,userEditDialog:!1,userEditDialogNew:null,groupEditDialog:!1,groupEditDialogNew:null,userDeleteDialog:!1,groupDeleteDialog:!1,innerWidth:0}}componentDidMount(){this.setState({innerWidth:window.innerWidth},()=>this.updateData())}componentDidUpdate(){window.innerWidth!==this.state.innerWidth&&setTimeout(()=>this.setState({innerWidth:window.innerWidth}),100)}getText=s=>s&&(typeof s=="object"?s[this.props.lang]||s.en||"":s||"")||"";showUserEditDialog=(s,o)=>{s=h.clone(s),s.common.password=s.common.password?U:"",this.setState({userEditDialog:s,userEditDialogNew:o})};showGroupEditDialog=(s,o)=>{s=h.clone(s),this.setState({groupEditDialog:s,groupEditDialogNew:o})};updateData=()=>{let s;return this.props.socket.getForeignObjects("system.user.*","user").then(o=>(s=Object.values(o).sort((r,n)=>r._id>n._id?1:-1),s.forEach(r=>{r.common&&r.common.description&&(r.common.desc||(r.common.desc=r.common.description),delete r.common.description)}),this.props.socket.getForeignObjects("system.group.*","group"))).then(o=>{const r=Object.values(o).sort((n,a)=>n._id>a._id?1:-1);r.forEach(n=>{n.common&&n.common.description&&(n.common.desc||(n.common.desc=n.common.description),delete n.common.description)}),this.setState({groups:r,users:s})})};changeUserFormData=s=>this.setState({userEditDialog:s});changeGroupFormData=s=>this.setState({groupEditDialog:s});saveUser=async s=>{const o=h.clone(this.state.userEditDialog),r=this.state.users.find(a=>a._id===o._id),n=o.common.password&&o.common.password!==U?o.common.password:"";if(r?o.common.password=r.common.password:o.common.password="",await this.props.socket.setObject(o._id,o),typeof this.state.userEditDialog=="object"&&s&&s!==this.state.userEditDialog._id)try{await this.props.socket.delObject(s);for(let a=0;a<this.state.groups.length;a++){const m=this.state.groups[a];if(m.common.members.includes(s)){const p=h.clone(m);p.common.members[p.common.members.indexOf(s)]=o._id,await this.props.socket.setObject(p._id,p)}}}catch(a){window.alert(`Cannot delete user: ${a}`)}if(n)try{await this.props.socket.changePassword(o._id,n)}catch(a){window.alert(`Cannot change password: ${a}`)}this.setState({userEditDialog:!1},()=>this.updateData())};saveGroup=async s=>{if(typeof this.state.groupEditDialog=="object"){if(await this.props.socket.setObject(this.state.groupEditDialog._id,this.state.groupEditDialog),s&&s!==this.state.groupEditDialog._id)try{await this.props.socket.delObject(s)}catch(o){window.alert(`Cannot delete user: ${o}`)}this.setState({groupEditDialog:!1},()=>this.updateData())}};showUserDeleteDialog=s=>this.setState({userDeleteDialog:s});showGroupDeleteDialog=s=>this.setState({groupDeleteDialog:s});deleteUser=s=>{this.props.socket.delObject(s).then(()=>Promise.all(this.state.groups.map(o=>{if(o.common.members.includes(s)){const r=h.clone(o);return r.common.members.splice(r.common.members.indexOf(s),1),this.props.socket.setObject(r._id,r)}return Promise.resolve(null)}))).catch(o=>window.alert(`Cannot delete user: ${o}`)).then(()=>{this.setState({userDeleteDialog:!1},()=>this.updateData())})};deleteGroup=s=>this.props.socket.delObject(s).then(()=>this.setState({groupDeleteDialog:!1},()=>this.updateData())).catch(o=>window.alert(`Cannot delete user: ${o}`));addUserToGroup=(s,o)=>{const r=this.state.groups.find(a=>a._id===o),n=r.common.members;n.includes(s)||(n.push(s),this.props.socket.setObject(r._id,r).then(()=>this.updateData()).catch(a=>window.alert(`Cannot delete user: ${a}`)))};removeUserFromGroup=(s,o)=>{const r=this.state.groups.find(a=>a._id===o),n=r.common.members;n.includes(s)&&(n.splice(n.indexOf(s),1),this.props.socket.setObject(r._id,r).then(()=>this.updateData()))};static _isUniqueName(s,o,r){return!s.find(n=>n._id===`system.user.${o.toLowerCase()}_${r}`||n.common.name===`${o} ${r}`)}static findNewUniqueName(s,o,r){let n=1;for(;!C._isUniqueName(o,r,n);)n++;return{_id:`system.${s?"group":"user"}.${r.toLowerCase()}_${n}`,name:`${r} ${n}`}}render(){return!this.state.users||!this.state.groups?t.jsx(i.LinearProgress,{}):t.jsxs(N,{backend:b.isTouchDevice()?W:z,children:[t.jsx(je,{}),t.jsx(i.Box,{component:"div",sx:u.descriptionPanel,children:this.props.t("You can drag users to groups.")}),t.jsxs(i.Grid2,{container:!0,spacing:2,style:u.mainGridCont,children:[t.jsxs(i.Grid2,{size:{xs:12,md:6},style:{...u.childGridCont,...this.state.innerWidth>600?u.childGridContWide:void 0},children:[t.jsxs("div",{style:u.headContainer,children:[t.jsx(i.Fab,{size:"small",style:u.right,onClick:()=>{const{_id:s,name:o}=C.findNewUniqueName(!0,this.state.groups,this.props.t("Group")),r=h.clone(_e);r._id=s,r.common.name=o,this.showGroupEditDialog(r,!0)},children:t.jsx(d.GroupAdd,{})}),t.jsx(i.Typography,{gutterBottom:!0,variant:"h4",component:"h4",children:this.props.t("Groups")})]}),t.jsx("div",{style:u.blocksContainer,children:this.state.groups.sort((s,o)=>{var a,m;const r=(this.getText((a=s==null?void 0:s.common)==null?void 0:a.name)||s._id).toLowerCase(),n=(this.getText((m=o==null?void 0:o.common)==null?void 0:m.name)||o._id).toLowerCase();return r>n?1:r<n?-1:0}).map(s=>t.jsx(me,{themeType:this.props.themeType,group:s,users:this.state.users,showGroupEditDialog:this.showGroupEditDialog,showGroupDeleteDialog:this.showGroupDeleteDialog,removeUserFromGroup:this.removeUserFromGroup,getText:this.getText,styles:u,...this.props},s._id))})]}),t.jsxs(i.Grid2,{size:{xs:12,md:6},style:{...u.childGridCont,...this.state.innerWidth>600?u.childGridContWide:void 0},children:[t.jsxs("div",{style:u.headContainer,children:[t.jsx(i.Fab,{size:"small",style:u.right,onClick:()=>{const{_id:s,name:o}=C.findNewUniqueName(!1,this.state.users,this.props.t("User")),r=h.clone(we);r._id=s,r.common.name=o,this.showUserEditDialog(r,!0)},children:t.jsx(d.PersonAdd,{})}),t.jsx(i.Typography,{gutterBottom:!0,variant:"h4",component:"h4",children:this.props.t("Users")})]}),t.jsx("div",{style:u.blocksContainer,children:this.state.users.sort((s,o)=>{var a,m;const r=(this.getText((a=s==null?void 0:s.common)==null?void 0:a.name)||s._id).toLowerCase(),n=(this.getText((m=o==null?void 0:o.common)==null?void 0:m.name)||o._id).toLowerCase();return r>n?1:r<n?-1:0}).map(s=>t.jsx(de,{themeType:this.props.themeType,user:s,groups:this.state.groups,showUserEditDialog:this.showUserEditDialog,showUserDeleteDialog:this.showUserDeleteDialog,updateData:this.updateData,addUserToGroup:this.addUserToGroup,removeUserFromGroup:this.removeUserFromGroup,getText:this.getText,styles:u,...this.props},s._id))})]})]}),this.state.userEditDialog?t.jsx(ue,{onClose:()=>this.setState({userEditDialog:!1}),users:this.state.users,user:this.state.userEditDialog,isNew:this.state.userEditDialogNew,t:this.props.t,getText:this.getText,styles:u,onChange:this.changeUserFormData,saveData:this.saveUser,innerWidth:this.state.innerWidth}):null,this.state.groupEditDialog?t.jsx(fe,{onClose:()=>this.setState({groupEditDialog:!1}),groups:this.state.groups,group:this.state.groupEditDialog,isNew:this.state.groupEditDialogNew,t:this.props.t,getText:this.getText,styles:u,onChange:this.changeGroupFormData,innerWidth:this.state.innerWidth,saveData:this.saveGroup}):null,this.state.userDeleteDialog?t.jsx(ye,{getText:this.getText,onClose:()=>this.setState({userDeleteDialog:!1}),user:this.state.userDeleteDialog,t:this.props.t,deleteUser:this.deleteUser}):null,this.state.groupDeleteDialog?t.jsx(De,{getText:this.getText,onClose:()=>this.setState({groupDeleteDialog:!1}),group:this.state.groupDeleteDialog,t:this.props.t,styles:u,deleteGroup:this.deleteGroup}):null]})}}function at(e){return t.jsx(B,{children:t.jsx(R,{style:{display:"flex",flexDirection:"column",overflow:"auto"},children:t.jsx(C,{t:e.t,lang:e.lang,socket:e.socket,ready:e.ready,expertMode:e.expertMode,themeType:e.themeType,theme:e.theme})})})}export{at as default};
1
+ import{j as t}from"./DefaultPropsProvider-BrbE0teb.js";import{X as P,Y as O,U as h,i,a as d,b as w,Z as F,f as b,_ as E,$ as N,a0 as W,a1 as z,h as B,T as R}from"./bootstrap-DlPDCLBt.js";import{i as j}from"./iobroker_admin__loadShare__react__loadShare__-DtlEM_52.js";import{I as y,a as S,b as $}from"./Fields-DFmrkQbX.js";import A from"./user1-BHHH0LIq.js";import M from"./user2-BN56rMPt.js";import L from"./user3-Mx6XZSLK.js";import H from"./user4-DpEs_YiD.js";import Y from"./user5-CVfrnlXE.js";import q from"./user6-C7HkYnq4.js";import V from"./user7-VAQcubFn.js";import X from"./user8-CwACr_jq.js";import Z from"./user9-Dk4Mlhcc.js";import J from"./user10-Dvmqf8l1.js";import K from"./user11-C8ly5pY7.js";import Q from"./user12-CHtaF3qG.js";import ee from"./group1-DBYxcyxq.js";import te from"./group2-BUQSell7.js";import se from"./group3-B0AdMrOp.js";import oe from"./group4-TeCgDok7.js";import ie from"./group5-CJ_-VPxg.js";import re from"./group6-JW-nEhw_.js";import ne from"./group7-CWpVuR4T.js";import le from"./group8-CRGBxCwd.js";import ae from"./group9-BXRQchYG.js";import ce from"./group10-BIcZMfE3.js";import"./iobroker_admin__loadShare__prop_mf_2_types__loadShare__-BGyJCibC.js";import"./_commonjsHelpers-D6-XlEtG.js";import"./iobroker_admin__mf_v__runtimeInit__mf_v__-VDoBF19b.js";import"./emotion-serialize.esm-BUa21YfQ.js";import"./iobroker_admin__loadShare___mf_0_emotion_mf_1_react__loadShare__-gw2iqPBS.js";import"./ace-j1VT51C2.js";import"./FilledInput-D-tz8rvg.js";import"./preload-helper-C1FmrZbK.js";import"./blueGrey-B0oIowPK.js";import"./emotion-cache.browser.esm-B8BFze5o.js";import"./iobroker_admin__loadShare__leaflet__loadShare__-B1OZ7tj-.js";import"./extends-CF3RwP-h.js";const k=e=>{const s=e.isDragging?0:1,o=h.getInvertedColor(e.user.common.color,e.themeType,!0),r={cursor:"grab",opacity:s,overflow:"hidden",color:o};return e.user.common.color&&(r.backgroundColor=e.user.common.color),t.jsx(i.Card,{style:r,sx:e.styles.userGroupCard2,children:t.jsxs("div",{style:e.styles.userCardContent,children:[t.jsxs("div",{style:e.styles.right,children:[t.jsx(i.Checkbox,{checked:e.user.common.enabled,style:{color:o},disabled:e.user.common.dontDelete,onChange:()=>{e.socket.extendObject(e.user._id,{common:{enabled:!e.user.common.enabled}}).then(()=>e.updateData())}}),t.jsx(i.IconButton,{size:"small",onClick:()=>e.showUserEditDialog(e.user,!1),children:t.jsx(d.Edit,{style:{color:o}})}),t.jsx(i.IconButton,{size:"small",onClick:()=>e.showUserDeleteDialog(e.user),disabled:e.user.common.dontDelete,children:t.jsx(d.Delete,{style:e.user.common.dontDelete?null:{color:o}})})]}),t.jsxs(i.CardContent,{children:[t.jsxs(i.Typography,{gutterBottom:!0,component:"div",style:e.styles.userGroupTitle,children:[e.user.common.icon?t.jsx(w,{style:e.styles.icon,src:e.user.common.icon}):t.jsx(d.Person,{style:e.styles.icon}),t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx("span",{style:e.styles.userGroupUserName,children:e.getText(e.user.common.name)}),t.jsxs("span",{style:e.styles.userGroupUserID,children:["[",e.user._id,"]"]})]}),t.jsx("span",{children:e.user.common.desc?t.jsx("div",{style:e.styles.description,children:e.getText(e.user.common.desc)}):null})]})]}),e.groups.find(n=>n.common.members&&n.common.members.includes(e.user._id))?t.jsxs("div",{children:[e.t("In groups"),":"]}):null,t.jsx("div",{children:e.groups.map(n=>{var m,p;if(!n.common.members||!n.common.members.includes(e.user._id))return null;const a=n&&((m=n.common)!=null&&m.color)?h.getInvertedColor(n.common.color,e.themeType,!0):o;return t.jsxs(i.Card,{variant:"outlined",sx:e.styles.userGroupMember,style:{color:a,borderColor:`${a}80`,background:((p=n.common)==null?void 0:p.color)||"inherit"},children:[n.common.icon?t.jsx(w,{style:e.styles.icon,src:n.common.icon}):t.jsx(d.Group,{style:e.styles.icon}),e.getText(n.common.name),t.jsx(i.IconButton,{size:"small",onClick:()=>e.removeUserFromGroup(e.user._id,n._id),children:t.jsx(d.Clear,{style:{color:a}})})]},n._id)})})]})]})})},de=e=>{const s=j.useRef(),[{isDragging:o},r,n]=P({type:"user",item:()=>{var a;return{userId:e.user._id,preview:t.jsx("div",{style:{width:(a=s.current)==null?void 0:a.offsetWidth},children:t.jsx(k,{...e})})}},end:(a,m)=>{const p=m.getDropResult();a&&p&&e.addUserToGroup(a.userId,p.groupId)},collect:a=>({isDragging:a.isDragging(),handlerId:a.getHandlerId()})});return j.useEffect(()=>{n(O(),{captureDraggingState:!0})},[n]),t.jsx("div",{ref:r,children:t.jsx("div",{ref:s,children:t.jsx(k,{isDragging:o,...e})})})};function he(e,s){return s.group.common.members?!s.group.common.members.includes(e.getItem().userId):!0}const me=e=>{var D;const[{CanDrop:s,isOver:o},r]=F(()=>({accept:"user",drop:()=>({groupId:e.group._id}),canDrop:(g,c)=>he(c,e),collect:g=>({isOver:g.isOver(),CanDrop:g.canDrop()})}),[e.group.common.members]);let n=.7,a;s&&o?(n=s?1:.125,a=e.styles.userGroupCardSecondary):s&&(n=s?.75:.25);const p=h.getInvertedColor(e.group.common.color,e.themeType,!0),x={opacity:n,overflow:"hidden",color:p};return e.group.common.color&&(x.backgroundColor=e.group.common.color),t.jsxs(i.Card,{style:x,ref:r,sx:h.getStyle(e.theme,e.styles.userGroupCard2,a),children:[t.jsxs("div",{style:e.styles.right,children:[t.jsx(i.IconButton,{size:"small",onClick:()=>e.showGroupEditDialog(e.group,!1),children:t.jsx(d.Edit,{style:{color:p}})}),t.jsx(i.IconButton,{size:"small",onClick:()=>e.showGroupDeleteDialog(e.group),disabled:e.group.common.dontDelete,children:t.jsx(d.Delete,{style:e.group.common.dontDelete?null:{color:p}})})]}),t.jsxs(i.CardContent,{children:[t.jsxs(i.Typography,{gutterBottom:!0,component:"div",style:e.styles.userGroupTitle,children:[e.group.common.icon?t.jsx(w,{style:e.styles.icon,src:e.group.common.icon}):t.jsx(d.Group,{style:e.styles.icon}),t.jsxs("div",{children:[t.jsxs("div",{children:[t.jsx("span",{style:e.styles.userGroupUserName,children:e.getText(e.group.common.name)}),t.jsxs("span",{children:["[",e.group._id,"]"]})]}),e.group.common.desc?t.jsx("div",{style:e.styles.description,children:e.getText(e.group.common.desc)}):null]})]}),(D=e.group.common.members)!=null&&D.length?t.jsxs("div",{children:[e.t("Group members"),":"]}):null,t.jsx("div",{children:(e.group.common.members||[]).map((g,c)=>{var G,T;const l=e.users.find(I=>I._id===g),f=l&&((G=l.common)!=null&&G.color)?h.getInvertedColor(l.common.color,e.themeType,!0):p;return l?t.jsxs(i.Card,{variant:"outlined",sx:e.styles.userGroupMember,style:{color:f,borderColor:`${f}40`,background:((T=l.common)==null?void 0:T.color)||"inherit"},children:[l.common.icon?t.jsx(w,{style:e.styles.icon,src:l.common.icon}):t.jsx(d.Person,{style:e.styles.icon}),e.getText(l.common.name),t.jsx(i.IconButton,{size:"small",onClick:()=>e.removeUserFromGroup(g,e.group._id),children:t.jsx(d.Clear,{style:{color:f}})})]},c):null})})]})]})},_=[A,M,L,H,Y,q,V,X,Z,J,K,Q],pe={contentRoot:{padding:"16px 24px"}};class ue extends j.Component{constructor(s){super(s),this.state={originalId:s.user._id,passwordRepeat:s.user.common.password}}componentDidMount(){if(this.props.isNew){const s=_[Math.round(Math.random()*(_.length-1))];s&&h.getSvg(s).then(o=>{const r=h.clone(this.props.user);r.common.icon=o,this.props.onChange(r)})}}render(){const s=this.props.users.find(c=>c._id===this.props.user._id),o=this.props.user._id!==this.state.originalId,r=c=>c.split(".").pop(),n=c=>c.replace(h.FORBIDDEN_CHARS,"_").replace(/\s/g,"_").replace(/\./g,"_").replace(/,/g,"_").replace(/__/g,"_").replace(/__/g,"_").toLowerCase(),a=(c,l)=>{const f=c.split(".");return f[f.length-1]=l,f.join(".")},m=this.props.getText(this.props.user.common.desc),p=this.props.getText(this.props.user.common.name),x=b.checkPassword(this.props.user.common.password),D=b.checkPassword(this.props.user.common.password,this.state.passwordRepeat);let g=this.props.user._id!=="system.user."&&!x&&!D;return(this.props.isNew&&s||s&&o)&&(g=!1),t.jsxs(i.Dialog,{fullWidth:this.props.innerWidth<500,open:!0,onClose:(c,l)=>{l!=="backdropClick"&&l!=="escapeKeyDown"&&this.props.onClose()},children:[t.jsx(i.DialogTitle,{style:{...this.props.styles.dialogTitle,padding:12},children:this.props.t("User parameters")}),t.jsx(i.DialogContent,{sx:{"&.MuiDialogContent-root":{...this.props.innerWidth<500?this.props.styles.narrowContent:void 0,...pe.contentRoot}},children:t.jsxs(i.Grid2,{container:!0,spacing:this.props.innerWidth<500?1:4,style:this.props.styles.dialog,children:[t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Name",t:this.props.t,value:p,onChange:c=>{const l=h.clone(this.props.user);!this.props.user.common.dontDelete&&n(this.props.getText(l.common.name))===r(l._id)&&(l._id=a(l._id,n(c))),l.common.name=c,this.props.onChange(l)},autoComplete:"new-password",icon:d.TextFields,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"ID edit",t:this.props.t,disabled:this.props.user.common.dontDelete,value:this.props.user._id.split(".")[this.props.user._id.split(".").length-1],onChange:c=>{const l=h.clone(this.props.user);l._id=a(l._id,n(c)),this.props.onChange(l)},icon:d.LocalOffer,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"ID preview",t:this.props.t,disabled:!0,value:this.props.user._id,icon:d.Pageview,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Description",t:this.props.t,value:m,onChange:c=>{const l=h.clone(this.props.user);l.common.desc=c,this.props.onChange(l)},icon:d.Description,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Password",t:this.props.t,value:this.props.user.common.password,error:x?this.props.t(x):void 0,onChange:c=>{const l=h.clone(this.props.user);l.common.password=c,this.props.onChange(l)},type:"password",autoComplete:"new-password",icon:d.VpnKey,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Password repeat",t:this.props.t,value:this.state.passwordRepeat,error:D?this.props.t(D):void 0,onChange:c=>this.setState({passwordRepeat:c}),type:"password",autoComplete:"new-password",icon:d.VpnKey,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(E,{icons:_,label:"Icon",value:this.props.user.common.icon,onChange:c=>{const l=h.clone(this.props.user);l.common.icon=c,this.props.onChange(l)},previewStyle:this.props.styles.iconPreview,icon:d.Image})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(S,{label:"Color",t:this.props.t,value:this.props.user.common.color,previewStyle:this.props.styles.iconPreview,onChange:c=>{const l=h.clone(this.props.user);l.common.color=c,this.props.onChange(l)},icon:d.ColorLens,style:this.props.styles.colorPicker,styles:this.props.styles})})]})}),t.jsxs(i.DialogActions,{style:this.props.styles.dialogActions,children:[t.jsx(i.Button,{variant:"contained",color:"primary",autoFocus:!0,onClick:()=>this.props.saveData(this.props.isNew?null:this.state.originalId),disabled:!g,startIcon:t.jsx(d.Check,{}),children:this.props.t("Save")}),t.jsx(i.Button,{variant:"contained",color:"grey",onClick:this.props.onClose,startIcon:t.jsx(d.Close,{}),children:this.props.t("Cancel")})]})]})}}const v=[ee,te,se,oe,ie,re,ne,le,ae,ce];function ge(e){const s=(r,n)=>Object.values(r).map((a,m)=>{const p=Object.keys(r)[m];return n(a,p)});let o=e.group.common.acl;return o=o||{},o.object=o.object||{read:!0,list:!0,write:!0,delete:!1,create:void 0},o.object={read:!0,list:!0,write:!0,delete:!1,...o.object},o.state=o.state||{read:!0,list:!0,write:!0,delete:!1,create:void 0},o.state={read:!0,list:!0,write:!0,delete:!1,...o.state},o.users=o.users||{write:!1,delete:!1,create:!1,list:void 0,read:void 0},o.users={write:!1,delete:!1,create:!1,...o.users},o.other=o.other||{http:!1,execute:!1,sendto:!0},o.other={http:!1,execute:!1,sendto:!0,...o.other},o.file=o.file||{read:!0,list:!0,write:!1,delete:!1,create:!1},o.file={read:!0,list:!0,write:!1,delete:!1,create:!1,...o.file},t.jsx(i.Grid2,{container:!0,spacing:e.innerWidth<500?1:4,style:e.styles.dialog,children:s(e.group.common.acl||{},(r,n)=>t.jsxs(i.Grid2,{size:{xs:12,md:12},children:[t.jsx(i.Box,{component:"h2",sx:e.styles.permHeaders,children:e.t(`group_acl_${n}`)}),s(r,(a,m)=>t.jsx(i.FormControlLabel,{control:t.jsx(i.Checkbox,{disabled:e.group._id==="system.group.administrator",checked:a,onChange:p=>{const x=h.clone(e.group);x.common.acl[n][m]=p.target.checked,e.onChange(x)}}),label:e.t(`group_acl_${m}`),labelPlacement:"top"},m))]},n))},"PermissionsTab")}const xe={contentRoot:{padding:"16px 24px"}};class fe extends j.Component{constructor(s){super(s),this.state={tab:0,originalId:s.group._id}}componentDidMount(){if(this.props.isNew){const s=v[Math.round(Math.random()*(v.length-1))];s&&h.getSvg(s).then(o=>{const r=h.clone(this.props.group);r.common.icon=o,this.props.onChange(r)})}}render(){const s=this.props.groups.find(c=>c._id===this.props.group._id),o=this.props.group._id!==this.state.originalId;let r=this.props.group._id!=="system.group."&&this.props.group.common.password===this.props.group.common.passwordRepeat;const n=c=>c.split(".").pop(),a=c=>c.replace(h.FORBIDDEN_CHARS,"_").replace(/\s/g,"_").replace(/\./g,"_").toLowerCase(),m=(c,l)=>{const f=c.split(".");return f[f.length-1]=l,f.join(".")};this.props.isNew?s&&(r=!1):s&&o&&(r=!1);const p=this.props.getText(this.props.group.common.desc),x=this.props.getText(this.props.group.common.name),g=[t.jsxs(i.Grid2,{container:!0,spacing:this.props.innerWidth<500?1:4,style:this.props.styles.dialog,children:[t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Name",t:this.props.t,value:x,onChange:c=>{const l=h.clone(this.props.group);!this.props.group.common.dontDelete&&a(this.props.getText(l.common.name))===n(l._id)&&(l._id=m(l._id,a(c))),l.common.name=c,this.props.onChange(l)},autoComplete:"off",icon:d.TextFields,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"ID edit",t:this.props.t,disabled:this.props.group.common.dontDelete,value:this.props.group._id.split(".")[this.props.group._id.split(".").length-1],onChange:c=>{const l=h.clone(this.props.group);l._id=m(l._id,a(c)),this.props.onChange(l)},icon:d.LocalOffer,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"ID preview",t:this.props.t,disabled:!0,value:this.props.group._id,icon:d.Pageview,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(y,{label:"Description",t:this.props.t,value:p,onChange:c=>{const l=h.clone(this.props.group);l.common.desc=c,this.props.onChange(l)},icon:d.Description,styles:this.props.styles})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(E,{label:"Icon",icons:v,value:this.props.group.common.icon,onChange:c=>{const l=h.clone(this.props.group);l.common.icon=c,this.props.onChange(l)},previewStyle:this.props.styles.iconPreview,icon:d.Image})}),t.jsx(i.Grid2,{size:{xs:12,md:6},children:t.jsx(S,{label:"Color",t:this.props.t,value:this.props.group.common.color,previewStyle:this.props.styles.iconPreview,onChange:c=>{const l=h.clone(this.props.group);l.common.color=c,this.props.onChange(l)},icon:d.ColorLens,style:this.props.styles.colorPicker,styles:this.props.styles})})]}),ge(this.props)][this.state.tab];return t.jsxs(i.Dialog,{open:!0,onClose:(c,l)=>{l!=="backdropClick"&&l!=="escapeKeyDown"&&this.props.onClose()},fullWidth:this.props.innerWidth<500,children:[t.jsx(i.DialogTitle,{style:this.props.styles.dialogTitle,children:t.jsxs(i.Tabs,{variant:"fullWidth",value:this.state.tab,onChange:(c,l)=>this.setState({tab:l}),children:[t.jsx(i.Tab,{label:this.props.t("Main"),value:0}),t.jsx(i.Tab,{label:this.props.t("Permissions"),value:1})]})}),t.jsx(i.DialogContent,{sx:{"&.MuiDialogContent-root":{...this.props.innerWidth<500?this.props.styles.narrowContent:void 0,...xe.contentRoot}},children:g}),t.jsxs(i.DialogActions,{style:this.props.styles.dialogActions,children:[t.jsx(i.Button,{variant:"contained",color:"primary",autoFocus:!0,onClick:()=>this.props.saveData(this.props.isNew?null:this.state.originalId),disabled:!r,startIcon:t.jsx(d.Check,{}),children:this.props.t("Save")}),t.jsx(i.Button,{variant:"contained",color:"grey",onClick:this.props.onClose,startIcon:t.jsx(d.Close,{}),children:this.props.t("Cancel")})]})]})}}function ye(e){return t.jsxs(i.Dialog,{open:!0,onClose:e.onClose,children:[t.jsx(i.DialogTitle,{children:e.t("Please confirm")}),t.jsx(i.DialogContent,{children:t.jsx(i.DialogContentText,{children:e.t("Do you want to delete user %s?",e.getText(e.user.common.name))})}),t.jsxs(i.DialogActions,{children:[t.jsx(i.Button,{variant:"contained",color:"primary",onClick:()=>e.deleteUser(e.user._id),startIcon:t.jsx(d.Delete,{}),children:e.t("Delete")}),t.jsx(i.Button,{variant:"contained",color:"grey",autoFocus:!0,onClick:e.onClose,startIcon:t.jsx(d.Close,{}),children:e.t("Cancel")})]})]})}function De(e){return t.jsxs(i.Dialog,{open:!0,onClose:e.onClose,children:[t.jsx(i.DialogTitle,{children:e.t("Please confirm")}),t.jsx(i.DialogContent,{children:t.jsx(i.DialogContentText,{children:e.t("Do you want to delete group %s?",e.getText(e.group.common.name))})}),t.jsxs(i.DialogActions,{style:e.styles.dialogActions,children:[t.jsx(i.Button,{variant:"contained",color:"primary",onClick:()=>e.deleteGroup(e.group._id),startIcon:t.jsx(d.Delete,{}),children:e.t("Delete")}),t.jsx(i.Button,{variant:"contained",color:"grey",autoFocus:!0,onClick:e.onClose,startIcon:t.jsx(d.Close,{}),children:e.t("Cancel")})]})]})}const U="***********",Ce="0 1px 1px 0 rgba(0, 0, 0, .4),0 6px 6px 0 rgba(0, 0, 0, .2)",u={mainGridCont:{height:"calc(100% - 55px)",overflowY:"auto"},childGridCont:{display:"flex",flexDirection:"column"},childGridContWide:{height:"100%"},canDrop:e=>({backgroundColor:e.palette.background.default}),headContainer:{margin:10},blocksContainer:{overflowY:"auto",overflowX:"hidden"},userGroupCard2:e=>({border:"1px solid #FFF",borderColor:e.palette.divider,m:"10px",minHeight:150,backgroundColor:e.palette.background.default,color:e.palette.text.primary,transition:"all 200ms ease-out",opacity:1,overflow:"hidden","&:hover":{overflowY:"auto",boxShadow:Ce}}),userGroupCardSecondary:e=>({color:e.palette.text.primary,backgroundColor:e.palette.success.light}),permHeaders:e=>({backgroundColor:e.palette.mode==="dark"?e.palette.background.default:e.palette.primary.main,p:"4px",borderRadius:"2px",color:"#EEE"}),userCardContent:{height:"100%",opacity:1},userGroupTitle:{display:"inline-flex",alignItems:"center"},userGroupUserName:{fontWeight:900,padding:5},userGroupUserID:{opacity:.7,padding:5},description:{fontSize:10,fontStyle:"italic",marginLeft:5,opacity:.7},userGroupMember:e=>({display:"inline-flex",m:"4px",p:"4px",backgroundColor:"#00000010",border:"1px solid #FFF",borderColor:e.palette.text.primary,color:e.palette.text.primary,alignItems:"center"}),icon:{height:32,width:32,marginRight:5,backgroundSize:"cover",backgroundPosition:"center"},right:{float:"right"},left:{float:"left",marginRight:10},dialog:{},flex:{display:"flex"},formControl:{display:"flex",padding:24,flexGrow:1e3},formContainer:{display:"flex",justifyContent:"center",alignItems:"center"},formIcon:{margin:10,opacity:.6},descriptionPanel:e=>({width:"100%",backgroundColor:"transparent",mb:"20px",mt:"20px",ml:"20px",opacity:.75,border:"none",display:"flex",alignItems:"center","& a":{pl:"3px",color:e.palette.mode==="dark"?"#EEE":"#111"}}),dialogTitle:{borderBottom:"1px solid #00000020",padding:0,width:"100%"},dialogActions:{borderTop:"1px solid #00000020",width:"100%"},dialogPaper:{overflowY:"initial",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",width:"calc(100% - 100px)",height:"calc(100% - 100px)",maxWidth:800,maxHeight:"100%"},dialogPaperMini:{maxHeight:300},colorPicker:{},iconPreview:{height:40,width:40},mainDescription:{fontSize:"200%"},deleteDialog:{padding:20},narrowContent:{padding:"8px 8px 8px 8px"}},je=()=>{const e=$();return e.display?t.jsx("div",{style:e.style,children:e.item.preview}):null},we={_id:"system.user.",type:"user",common:{name:"",password:"",enabled:!0,color:"",desc:""},native:{},enums:{}},_e={_id:void 0,native:{},type:"group",common:{name:"",desc:"",members:[],dontDelete:void 0,acl:{object:{list:!1,read:!1,write:!1,delete:!1,create:void 0},state:{list:!1,read:!1,write:!1,create:!1,delete:!1},users:{list:!1,read:!1,write:!1,create:!1,delete:!1},other:{execute:!1,http:!1,sendto:!1},file:{list:!1,read:!1,write:!1,create:!1,delete:!1}},icon:"",color:""}};class C extends j.Component{constructor(s){super(s),this.state={users:null,groups:null,userEditDialog:!1,userEditDialogNew:null,groupEditDialog:!1,groupEditDialogNew:null,userDeleteDialog:!1,groupDeleteDialog:!1,innerWidth:0}}componentDidMount(){this.setState({innerWidth:window.innerWidth},()=>this.updateData())}componentDidUpdate(){window.innerWidth!==this.state.innerWidth&&setTimeout(()=>this.setState({innerWidth:window.innerWidth}),100)}getText=s=>s&&(typeof s=="object"?s[this.props.lang]||s.en||"":s||"")||"";showUserEditDialog=(s,o)=>{s=h.clone(s),s.common.password=s.common.password?U:"",this.setState({userEditDialog:s,userEditDialogNew:o})};showGroupEditDialog=(s,o)=>{s=h.clone(s),this.setState({groupEditDialog:s,groupEditDialogNew:o})};updateData=()=>{let s;return this.props.socket.getForeignObjects("system.user.*","user").then(o=>(s=Object.values(o).sort((r,n)=>r._id>n._id?1:-1),s.forEach(r=>{r.common&&r.common.description&&(r.common.desc||(r.common.desc=r.common.description),delete r.common.description)}),this.props.socket.getForeignObjects("system.group.*","group"))).then(o=>{const r=Object.values(o).sort((n,a)=>n._id>a._id?1:-1);r.forEach(n=>{n.common&&n.common.description&&(n.common.desc||(n.common.desc=n.common.description),delete n.common.description)}),this.setState({groups:r,users:s})})};changeUserFormData=s=>this.setState({userEditDialog:s});changeGroupFormData=s=>this.setState({groupEditDialog:s});saveUser=async s=>{const o=h.clone(this.state.userEditDialog),r=this.state.users.find(a=>a._id===o._id),n=o.common.password&&o.common.password!==U?o.common.password:"";if(r?o.common.password=r.common.password:o.common.password="",await this.props.socket.setObject(o._id,o),typeof this.state.userEditDialog=="object"&&s&&s!==this.state.userEditDialog._id)try{await this.props.socket.delObject(s);for(let a=0;a<this.state.groups.length;a++){const m=this.state.groups[a];if(m.common.members.includes(s)){const p=h.clone(m);p.common.members[p.common.members.indexOf(s)]=o._id,await this.props.socket.setObject(p._id,p)}}}catch(a){window.alert(`Cannot delete user: ${a}`)}if(n)try{await this.props.socket.changePassword(o._id,n)}catch(a){window.alert(`Cannot change password: ${a}`)}this.setState({userEditDialog:!1},()=>this.updateData())};saveGroup=async s=>{if(typeof this.state.groupEditDialog=="object"){if(await this.props.socket.setObject(this.state.groupEditDialog._id,this.state.groupEditDialog),s&&s!==this.state.groupEditDialog._id)try{await this.props.socket.delObject(s)}catch(o){window.alert(`Cannot delete user: ${o}`)}this.setState({groupEditDialog:!1},()=>this.updateData())}};showUserDeleteDialog=s=>this.setState({userDeleteDialog:s});showGroupDeleteDialog=s=>this.setState({groupDeleteDialog:s});deleteUser=s=>{this.props.socket.delObject(s).then(()=>Promise.all(this.state.groups.map(o=>{if(o.common.members.includes(s)){const r=h.clone(o);return r.common.members.splice(r.common.members.indexOf(s),1),this.props.socket.setObject(r._id,r)}return Promise.resolve(null)}))).catch(o=>window.alert(`Cannot delete user: ${o}`)).then(()=>{this.setState({userDeleteDialog:!1},()=>this.updateData())})};deleteGroup=s=>this.props.socket.delObject(s).then(()=>this.setState({groupDeleteDialog:!1},()=>this.updateData())).catch(o=>window.alert(`Cannot delete user: ${o}`));addUserToGroup=(s,o)=>{const r=this.state.groups.find(a=>a._id===o),n=r.common.members;n.includes(s)||(n.push(s),this.props.socket.setObject(r._id,r).then(()=>this.updateData()).catch(a=>window.alert(`Cannot delete user: ${a}`)))};removeUserFromGroup=(s,o)=>{const r=this.state.groups.find(a=>a._id===o),n=r.common.members;n.includes(s)&&(n.splice(n.indexOf(s),1),this.props.socket.setObject(r._id,r).then(()=>this.updateData()))};static _isUniqueName(s,o,r){return!s.find(n=>n._id===`system.user.${o.toLowerCase()}_${r}`||n.common.name===`${o} ${r}`)}static findNewUniqueName(s,o,r){let n=1;for(;!C._isUniqueName(o,r,n);)n++;return{_id:`system.${s?"group":"user"}.${r.toLowerCase()}_${n}`,name:`${r} ${n}`}}render(){return!this.state.users||!this.state.groups?t.jsx(i.LinearProgress,{}):t.jsxs(N,{backend:b.isTouchDevice()?W:z,children:[t.jsx(je,{}),t.jsx(i.Box,{component:"div",sx:u.descriptionPanel,children:this.props.t("You can drag users to groups.")}),t.jsxs(i.Grid2,{container:!0,spacing:2,style:u.mainGridCont,children:[t.jsxs(i.Grid2,{size:{xs:12,md:6},style:{...u.childGridCont,...this.state.innerWidth>600?u.childGridContWide:void 0},children:[t.jsxs("div",{style:u.headContainer,children:[t.jsx(i.Fab,{size:"small",style:u.right,onClick:()=>{const{_id:s,name:o}=C.findNewUniqueName(!0,this.state.groups,this.props.t("Group")),r=h.clone(_e);r._id=s,r.common.name=o,this.showGroupEditDialog(r,!0)},children:t.jsx(d.GroupAdd,{})}),t.jsx(i.Typography,{gutterBottom:!0,variant:"h4",component:"h4",children:this.props.t("Groups")})]}),t.jsx("div",{style:u.blocksContainer,children:this.state.groups.sort((s,o)=>{var a,m;const r=(this.getText((a=s==null?void 0:s.common)==null?void 0:a.name)||s._id).toLowerCase(),n=(this.getText((m=o==null?void 0:o.common)==null?void 0:m.name)||o._id).toLowerCase();return r>n?1:r<n?-1:0}).map(s=>t.jsx(me,{themeType:this.props.themeType,group:s,users:this.state.users,showGroupEditDialog:this.showGroupEditDialog,showGroupDeleteDialog:this.showGroupDeleteDialog,removeUserFromGroup:this.removeUserFromGroup,getText:this.getText,styles:u,...this.props},s._id))})]}),t.jsxs(i.Grid2,{size:{xs:12,md:6},style:{...u.childGridCont,...this.state.innerWidth>600?u.childGridContWide:void 0},children:[t.jsxs("div",{style:u.headContainer,children:[t.jsx(i.Fab,{size:"small",style:u.right,onClick:()=>{const{_id:s,name:o}=C.findNewUniqueName(!1,this.state.users,this.props.t("User")),r=h.clone(we);r._id=s,r.common.name=o,this.showUserEditDialog(r,!0)},children:t.jsx(d.PersonAdd,{})}),t.jsx(i.Typography,{gutterBottom:!0,variant:"h4",component:"h4",children:this.props.t("Users")})]}),t.jsx("div",{style:u.blocksContainer,children:this.state.users.sort((s,o)=>{var a,m;const r=(this.getText((a=s==null?void 0:s.common)==null?void 0:a.name)||s._id).toLowerCase(),n=(this.getText((m=o==null?void 0:o.common)==null?void 0:m.name)||o._id).toLowerCase();return r>n?1:r<n?-1:0}).map(s=>t.jsx(de,{themeType:this.props.themeType,user:s,groups:this.state.groups,showUserEditDialog:this.showUserEditDialog,showUserDeleteDialog:this.showUserDeleteDialog,updateData:this.updateData,addUserToGroup:this.addUserToGroup,removeUserFromGroup:this.removeUserFromGroup,getText:this.getText,styles:u,...this.props},s._id))})]})]}),this.state.userEditDialog?t.jsx(ue,{onClose:()=>this.setState({userEditDialog:!1}),users:this.state.users,user:this.state.userEditDialog,isNew:this.state.userEditDialogNew,t:this.props.t,getText:this.getText,styles:u,onChange:this.changeUserFormData,saveData:this.saveUser,innerWidth:this.state.innerWidth}):null,this.state.groupEditDialog?t.jsx(fe,{onClose:()=>this.setState({groupEditDialog:!1}),groups:this.state.groups,group:this.state.groupEditDialog,isNew:this.state.groupEditDialogNew,t:this.props.t,getText:this.getText,styles:u,onChange:this.changeGroupFormData,innerWidth:this.state.innerWidth,saveData:this.saveGroup}):null,this.state.userDeleteDialog?t.jsx(ye,{getText:this.getText,onClose:()=>this.setState({userDeleteDialog:!1}),user:this.state.userDeleteDialog,t:this.props.t,deleteUser:this.deleteUser}):null,this.state.groupDeleteDialog?t.jsx(De,{getText:this.getText,onClose:()=>this.setState({groupDeleteDialog:!1}),group:this.state.groupDeleteDialog,t:this.props.t,styles:u,deleteGroup:this.deleteGroup}):null]})}}function at(e){return t.jsx(B,{children:t.jsx(R,{style:{display:"flex",flexDirection:"column",overflow:"auto"},children:t.jsx(C,{t:e.t,lang:e.lang,socket:e.socket,ready:e.ready,expertMode:e.expertMode,themeType:e.themeType,theme:e.theme})})})}export{at as default};