PageSourceSearch

https://sab2up.ru/assets/EmailSettings-CzmqM4h7.js

js sab2up.ru collected 2026-10-07 03:02:52 UTC 16,665 bytes, 6 lines download raw bytes

1import{r as f,U as F,u as O,E as Y,d as p,j as e,h as B,n as q}from"./index-CXOeVRoW.js";const G=[{value:"support",label:"Поддержка",icon:"fa-headset",bg:"#fff3e0",color:"#f2722c"},{value:"sales",label:"Продажи",icon:"fa-chart-line",bg:"#e8f5e9",color:"#388e3c"},{value:"cloud",label:"Облачные услуги",icon:"fa-cloud",bg:"#e3f2fd",color:"#1976d2"},{value:"noreply",label:"No-reply (уведомления)",icon:"fa-bell-slash",bg:"#f3e5f5",color:"#7b1fa2"}],E=[{value:"personal",label:"Личный",icon:"fa-user",bg:"#e3f2fd",color:"#1976d2"},{value:"work",label:"Рабочий",icon:"fa-briefcase",bg:"#e8f5e9",color:"#388e3c"},{value:"gmail",label:"Gmail",icon:"fa-envelope",bg:"#fce4ec",color:"#c62828"},{value:"yandex",label:"Яндекс",icon:"fa-envelope",bg:"#fff3e0",color:"#e65100"},{value:"mail",label:"Mail.ru",icon:"fa-envelope",bg:"#f3e5f5",color:"#6a1b9a"},{value:"other",label:"Другой",icon:"fa-at",bg:"#f5f5f5",color:"#616161"}],J=[...G,...E];function T(m){return J.find(u=>u.value===m)||E[0]}function K(m){return m._isSystem?"/api/email/mailboxes":"/api/email/my/mailboxes"}function V(){var C;const{user:m}=f.useContext(F),u=O(),c=Y(),g=(m==null?void 0:m.isServiceAdmin)===!0,y=f.useRef(null),[w,R]=f.useState([]),[W,N]=f.useState(!0),[z,k]=f.useState(null),[h,b]=f.useState(null),[j,M]=f.useState({}),[o,x]=f.useState(null),A=f.useCallback(async(s,i)=>{i.stopPropagation(),x({mb:s,users:[],loading:!0,allUsers:[],search:"",error:null});try{const[{data:a},{data:t}]=await Promise.all([p.get(`/api/email/mailboxes/${s.id}/access`,{withCredentials:!0}),p.get("/api/bitrix/users",{params:{isActive:!0,isExtranet:!1},withCredentials:!0}).then(l=>({data:l.data.users||l.data}))]);x(l=>l?{...l,users:a,allUsers:t,loading:!1}:null)}catch(a){x(t=>{var l,n;return t?{...t,loading:!1,error:((n=(l=a.response)==null?void 0:l.data)==null?void 0:n.error)||a.message}:null})}},[]),I=f.useCallback(async s=>{var a,t,l;if(!o)return;const i=o.mb.id;try{await p.delete(`/api/email/mailboxes/${i}/access/${s}`,{withCredentials:!0}),x(n=>n?{...n,users:n.users.filter(r=>r.id!==s)}:null)}catch(n){(l=window.showToast)==null||l.call(window,((t=(a=n.response)==null?void 0:a.data)==null?void 0:t.error)||"Ошибка","danger")}},[o]),$=f.useCallback(async s=>{var a,t,l;if(!o)return;const i=o.mb.id;try{if(await p.post(`/api/email/mailboxes/${i}/access`,{userId:s},{withCredentials:!0}),!o.users.find(r=>r.id===s)){const r=o.allUsers.find(d=>d.id===s);if(r){const d=`${r.name||""} ${r.lastName||""}`.trim(),v={id:r.id,name:d,email:r.email||"",photoUrl:r.photoUrl||null};x(S=>S?{...S,users:[...S.users,{...v,grantedAt:new Date().toISOString()}],search:""}:null)}else x(d=>d?{...d,search:""}:null)}}catch(n){(l=window.showToast)==null||l.call(window,((t=(a=n.response)==null?void 0:a.data)==null?void 0:t.error)||"Ошибка","danger")}},[o]),L=async()=>{var s,i;N(!0),k(null);try{let t=(await p.get("/api/email/my/mailboxes",{withCredentials:!0})).data.map(l=>({...l,_isSystem:!1}));if(g)try{t=[...(await p.get("/api/email/mailboxes",{withCredentials:!0})).data.map(n=>({...n,_isSystem:!0})),...t]}catch{}R(t)}catch(a){k(((i=(s=a.response)==null?void 0:s.data)==null?void 0:i.error)||a.message)}finally{N(!1)}};f.useEffect(()=>{L()},[]);const P=(s,i)=>i!=null&&i.bodyTpl?i.bodyTpl.replace(/\{\{subject\}\}/g,"Тестовая тема письма").replace(/\{\{header\}\}/g,"Заголовок письма").replace(/\{\{content\}\}/g,"<p>Пример содержимого письма.</p>").replace(/\{\{signature\}\}/g,i.signature||"").replace(/\{\{year\}\}/g,new Date().getFullYear()).replace(/\{\{mailboxName\}\}/g,(s==null?void 0:s.name)||""):'<p style="color:#aaa;padding:20px">Шаблон не настроен</p>',U=async(s,i)=>{i.stopPropagation(),clearTimeout(y.current);const a=i.currentTarget.getBoundingClientRect(),t=680,l=520;let n=a.right-t,r=a.bottom+8;if(n<16&&(n=16),n+t>window.innerWidth-16&&(n=window.innerWidth-t-16),r+l>window.innerHeight-16&&(r=a.top-l-8),r<16&&(r=16),b({mb:s,x:n,y:r}),!j[s.id])try{const{data:d}=await p.get(`${K(s)}/${s.id}/template`,{withCredentials:!0});M(v=>({...v,[s.id]:d}))}catch{}},_=()=>{y.current=setTimeout(()=>b(null),250)},H=()=>clearTimeout(y.current),D=()=>{y.current=setTimeout(()=>b(null),250)};return W?e.jsx("div",{className:"d-flex justify-content-center align-items-center",style:{minHeight:200},children:e.jsx("div",{className:"spinner-border text-primary",role:"status"})}
1):e.jsxs("div",{className:"container-fluid py-4 email-settings-root",children:[c&&e.jsx("style",{children:`
2                    @media (max-width: 991.98px) {
3                        .email-settings-root .btn { width: auto; margin-bottom: 0; }
4                    }
5                `}),e.jsxs("div",{className:`d-flex mb-4 ${c?"flex-column gap-3":"align-items-center"}`,children:[e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center me-3",style:{width:44,height:44,borderRadius:12,background:"linear-gradient(135deg, #f2722c, #e05a1a)",color:"#fff",fontSize:20,flexShrink:0},children:e.jsx("i",{className:"fas fa-envelope"})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("h4",{className:"mb-0 fw-bold",children:"Почтовые ящики"}),e.jsx("div",{className:"text-muted",style:{fontSize:13},children:g?"Системные и личные почтовые ящики":"Мои почтовые ящики"})]})]}),e.jsxs("div",{className:`d-flex gap-2 ${c?"":"ms-auto"}`,children:[c&&e.jsxs("button",{className:"btn btn-outline-secondary",onClick:()=>u("/my/email"),children:[e.jsx("i",{className:"fas fa-arrow-left me-1"}),"К почте"]}),e.jsxs("button",{className:`btn btn-primary ${c?"flex-grow-1":""}`,onClick:()=>u("/my/settings/email/new"),children:[e.jsx("i",{className:"fas fa-plus me-2"}),"Добавить ящик"]}),!c&&e.jsxs("button",{className:"btn btn-outline-secondary",onClick:()=>u("/my/email"),children:[e.jsx("i",{className:"fas fa-arrow-left me-1"}),"К почте"]})]})]}),z&&e.jsx("div",{className:"alert alert-danger",children:z}),w.length===0?e.jsx("div",{className:"card border-0 shadow-sm",style:{borderRadius:12},children:e.jsxs("div",{className:"card-body text-center py-5 text-muted",children:[e.jsx("i",{className:"fas fa-inbox fa-3x mb-3 d-block",style:{color:"#ddd"}}),e.jsx("div",{className:"fw-semibold mb-1",children:"Ящики не добавлены"}),e.jsx("div",{style:{fontSize:13},children:"Нажмите «Добавить ящик» чтобы начать"})]})}):e.jsx("div",{className:"d-flex flex-column gap-2",children:w.map(s=>{const i=T(s.type);return e.jsxs("div",{onClick:()=>u("/my/settings/email/"+s.id,{state:{isSystem:s._isSystem}}),style:{display:"flex",alignItems:"center",gap:14,background:"#fff",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.07)",padding:"11px 18px",cursor:"pointer",transition:"box-shadow 0.15s"},onMouseEnter:a=>a.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.13)",onMouseLeave:a=>a.currentTarget.style.boxShadow="0 1px 4px rgba(0,0,0,0.07)",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center flex-shrink-0",style:{width:34,height:34,borderRadius:8,fontSize:15,background:s.color?s.color+"22":i.bg,color:s.color||i.color,boxShadow:s.color?`0 0 0 2px ${s.color}55`:"none"},children:e.jsx("i",{className:`fas ${i.icon}`})}),e.jsxs("div",{style:{flex:c?"1 1 auto":"0 0 220px",minWidth:0},children:[e.jsx("div",{style:{fontWeight:600,fontSize:14,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.name}),c&&s.fromEmail&&e.jsx("div",{style:{fontSize:11,color:"#aaa",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.fromEmail}),e.jsxs("div",{style:{display:"flex",gap:5,marginTop:3,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:10,fontWeight:500,padding:"1px 8px",borderRadius:20,background:i.bg,color:i.color},children:i.label}),g&&e.jsx("span",{style:{fontSize:10,fontWeight:500,padding:"1px 8px",borderRadius:20,background:s._isSystem?"#fff3e0":"#e8f5e9",color:s._isSystem?"#e65100":"#2e7d32"},children:s._isSystem?"системный":"личный"}),!s.isActive&&e.jsx("span",{style:{fontSize:10,fontWeight:500,padding:"1px 8px",borderRadius:20,background:"#f0f0f0",color:"#999"},children:"отключён"}),s.moderationEnabled&&e.jsxs("span",{title:"Исходящие письма идут на подтверждение",style:{fontSize:10,fontWeight:500,padding:"1px 8px",borderRadius:20,background:"#fff8e1",color:"#b7791f"},children:[e.jsx("i",{className:"fas fa-user-shield me-1",style:{fontSize:9}}),"модерация"]}
5)]})]}),!c&&e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,color:"#555",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.fromName}),e.jsx("div",{style:{fontSize:11,color:"#aaa",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.fromEmail})]}),!c&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{flex:"0 0 180px",minWidth:0},children:[e.jsxs("div",{style:{fontSize:11,color:"#888"},children:[e.jsx("i",{className:"fas fa-paper-plane me-1",style:{fontSize:10,opacity:.6}}),"SMTP: ",s.host]}),e.jsxs("div",{style:{fontSize:11,color:"#bbb"},children:["порт ",s.port," · ",s.secure?"SSL":"STARTTLS"]})]}),e.jsx("div",{style:{flex:"0 0 160px",minWidth:0},children:s.imapEnabled?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{fontSize:11,color:"#888"},children:[e.jsx("i",{className:"fas fa-inbox me-1",style:{fontSize:10,opacity:.6}}),"IMAP: ",s.imapHost]}),e.jsx("div",{style:{fontSize:11,color:s.imapLastSync?"#4caf50":"#bbb"},children:s.imapLastSync?`✓ ${B(new Date(s.imapLastSync),{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}`:"не синхронизировано"})]}):e.jsx("div",{style:{fontSize:11,color:"#ddd"},children:"IMAP не настроен"})}),e.jsx("div",{style:{flexShrink:0},onClick:a=>a.stopPropagation(),onMouseEnter:a=>U(s,a),onMouseLeave:_,children:e.jsxs("span",{style:{fontSize:12,color:"#1976d2",cursor:"default",display:"flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:20,background:"#e3f2fd",userSelect:"none"},children:[e.jsx("i",{className:"fas fa-eye",style:{fontSize:11}}),"шаблон"]})}),g&&s._isSystem&&e.jsx("div",{style:{flexShrink:0},onClick:a=>A(s,a),children:e.jsxs("span",{style:{fontSize:12,color:"#555",cursor:"pointer",display:"flex",alignItems:"center",gap:4,padding:"4px 10px",borderRadius:20,background:"#f5f5f5",userSelect:"none"},children:[e.jsx("i",{className:"fas fa-users",style:{fontSize:11}}),"доступ"]})})]}),e.jsx("i",{className:"fas fa-chevron-right flex-shrink-0",style:{fontSize:11,color:"#ccc"}})]},s.id)})}),o&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:1e4,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>x(null),children:e.jsxs("div",{style:{background:"#fff",borderRadius:14,padding:c?18:28,width:c?"94vw":480,maxWidth:"94vw",maxHeight:"80vh",display:"flex",flexDirection:"column",boxShadow:"0 8px 40px rgba(0,0,0,0.18)"},onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"d-flex align-items-center mb-3",children:[e.jsx("i",{className:"fas fa-users me-2",style:{color:"#f2722c",fontSize:18}}),e.jsxs("div",{children:[e.jsx("div",{className:"fw-bold",style:{fontSize:15},children:"Доступ к ящику"}),e.jsxs("div",{style:{fontSize:12,color:"#888"},children:[o.mb.name," · ",o.mb.fromEmail]})]}),e.jsx("button",{className:"btn-close ms-auto",onClick:()=>x(null)})]}),o.loading?e.jsx("div",{className:"d-flex justify-content-center py-4",children:e.jsx("span",{className:"spinner-border text-primary"})}):o.error?e.jsxs("div",{className:"alert alert-danger py-2",style:{fontSize:13},children:[e.jsx("i",{className:"fas fa-exclamation-circle me-2"}),o.error]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{style:{fontSize:12,color:"#666",fontWeight:600,marginBottom:6,display:"block"},children:"Добавить пользователя"}),e.jsx("div",{className:"d-flex gap-2",children:e.jsx("input",{className:"form-control form-control-sm",placeholder:"Поиск по имени или email...",value:o.search||"",onChange:s=>x(i=>i?{...i,search:s.target.value}:null)})}),((C=o.search)==null?void 0:C.trim())&&(()=>{const s=o.search.toLowerCase(),i=new Set(o.users.map(t=>t.id)),a=(o.allUsers||[]).filter(t=>{const l=`${t.name||""} ${t.lastName||""}`.trim().toLowerCase(),n=(t.email||"").toLowerCase();return!i.has(t.id)&&(l.includes(s)||n.includes(s))}).slice(0,8);return a.length?e.jsx("div",{style:{border:"1px solid #e0e0e0",borderRadius:8,marginTop:4,maxHeight:180,overflowY:"auto"},children:a.map(t=>{const l=t.id,n=`${t.name||""} ${t.lastName||""}
5`.trim(),r=t.email||"";return e.jsxs("div",{style:{padding:"7px 12px",cursor:"pointer",display:"flex",alignItems:"center",gap:10,borderBottom:"1px solid #f5f5f5"},onMouseEnter:d=>d.currentTarget.style.background="#f9f9f9",onMouseLeave:d=>d.currentTarget.style.background="",onClick:()=>$(l),children:[e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",overflow:"hidden",background:"#e3f2fd",color:"#1976d2",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:600,flexShrink:0},children:t.photoUrl?e.jsx("img",{src:t.photoUrl,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(n.charAt(0)||"?").toUpperCase()}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{className:"text-truncate",style:{fontSize:13,fontWeight:500},children:n}),r&&e.jsx("div",{className:"text-truncate",style:{fontSize:11,color:"#aaa"},children:r})]}),e.jsx("i",{className:"fas fa-plus ms-auto",style:{fontSize:11,color:"#4caf50"}})]},l)})}):e.jsx("div",{style:{fontSize:12,color:"#aaa",padding:"6px 2px"},children:"Не найдено"})})()]}),e.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[e.jsxs("div",{style:{fontSize:12,color:"#666",fontWeight:600,marginBottom:8},children:["Пользователи с доступом (",o.users.length,")"]}),o.users.length===0?e.jsx("div",{style:{fontSize:13,color:"#aaa",textAlign:"center",padding:"16px 0"},children:"Нет пользователей с явным доступом"}):e.jsx("div",{className:"d-flex flex-column gap-1",children:o.users.map(s=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"6px 10px",borderRadius:8,background:"#fafafa"},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",overflow:"hidden",background:"#e8f5e9",color:"#388e3c",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:600,flexShrink:0},children:s.photoUrl?e.jsx("img",{src:s.photoUrl,alt:"",style:{width:"100%",height:"100%",objectFit:"cover"}}):(s.name||"?").charAt(0).toUpperCase()}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:s.name}),s.email&&e.jsx("div",{style:{fontSize:11,color:"#aaa"},children:s.email})]}),e.jsx("div",{style:{fontSize:11,color:"#bbb"},children:q(new Date(s.grantedAt))}),e.jsx("button",{className:"btn btn-sm",style:{padding:"2px 8px",fontSize:11,color:"#e53935",background:"none",border:"none"},onClick:()=>I(s.id),title:"Отозвать доступ",children:e.jsx("i",{className:"fas fa-times"})})]},s.id))})]})]})]})}),h&&e.jsxs("div",{style:{position:"fixed",top:h.y,left:h.x,width:680,zIndex:9999,background:"#fff",borderRadius:10,boxShadow:"0 8px 32px rgba(0,0,0,0.18)",border:"1px solid #e0e0e0",overflow:"hidden",pointerEvents:"auto"},onMouseEnter:H,onMouseLeave:D,children:[e.jsxs("div",{style:{padding:"8px 14px",borderBottom:"1px solid #f0f0f0",fontSize:12,color:"#666",display:"flex",alignItems:"center",gap:6},children:[(()=>{const s=T(h.mb.type);return e.jsx("div",{style:{width:20,height:20,borderRadius:5,background:s.bg,color:s.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11},children:e.jsx("i",{className:`fas ${s.icon}`})})})(),e.jsx("span",{className:"fw-semibold",children:h.mb.name}),e.jsx("span",{style:{color:"#aaa"},children:"· предпросмотр шаблона"})]}),j[h.mb.id]?e.jsx("iframe",{title:"tpl-preview",srcDoc:P(h.mb,j[h.mb.id]),style:{width:"100%",height:480,border:"none",display:"block"},sandbox:"allow-same-origin"}):e.jsx("div",{style:{height:480,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("span",{className:"spinner-border text-primary"})})]})]})}export{V as default};
6//# sourceMappingURL=EmailSettings-CzmqM4h7.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.