"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["views/admin/reseller/resourceUsage"],{2034:(e,t,a)=>{a.r(t),a.d(t,{default:()=>h});var s=a(270),r=a(271),o=a(89),n=a(496),i=a(620),l=a(531),u=a(2035),c=a(698),d=a(597),m=a(811),p=a.n(m);const y=o.Locale.getTranslate("admin.components.lists.resourceusage"),g=n.gql`
    mutation SendResourceUsageByMail($input: SendResourceUsageReportByEmailInput!) {
        sendResourceUsageReportByEmail(input: $input) {
            __typename
        }
    }
`,h=(0,d.withSimplePageLayout)((()=>{const[e,t]=(0,s.useState)(""),{queryResult:{data:a},listProps:o,listInput:n}=(0,c.useGraphQlList)({key:"ResourceUsagePage",query:p(),extractList:e=>e.viewer.client.resourceUsage}),[d]=(0,i.useMutation)(g,{variables:{input:{email:e,filters:n}},onCompleted:()=>{(0,l.addToast)({intent:"success",message:(0,s.jsx)(y,{content:"reportWasSent",params:{email:e}})})},onError:({graphQLErrors:e})=>{e.forEach((({extensions:e,message:t})=>{"validate"===e?.category?["email","filters"].forEach((t=>{Object.values(e.messages[t]??{}).forEach((e=>{(0,l.addToast)({intent:"danger",message:e})}))})):(0,l.addToast)({intent:"danger",message:t})}))}});(0,s.useEffect)((()=>{t(a.viewer.client.email)}),[]);const m=(0,s.useMemo)((()=>[{key:"clientName",width:"300px"},{key:"domainName",width:"400px"},{key:"diskUsage",width:"70px",renderFunc:e=>(0,u.formatByteSize)(+e.diskUsage)},{key:"traffic",width:"120px",renderFunc:e=>`${(0,u.formatByteSize)(+e.traffic)}/Month`},{key:"subDomainsCount"},{key:"webUsersCount"},{key:"databasesCount"},{key:"mailBoxesCount"},{key:"autoRepliesCount"},{key:"mailForwardingsCount"},{key:"mailListsCount"}].map((({key:e,width:t,renderFunc:a})=>({key:e,width:t,title:(0,s.jsx)(y,{content:e}),sortable:!0,render:a||(t=>t[e])})))),[]),h=(0,s.jsxs)(r.Toolbar,{children:[(0,s.jsxs)(r.ToolbarGroup,{title:"",children:[(0,s.jsx)(r.Input,{"data-cy":"email",value:e,onChange:({target:e})=>t(e.value)}),(0,s.jsx)(r.Button,{"data-type":"send-to-email","data-cy":"send-by-email",icon:"mail",onClick:d,tooltip:(0,s.jsx)(y,{content:"sendByEmail"}),children:(0,s.jsx)(y,{content:"buttonSendByEmail"})})]}),(0,s.jsx)(r.ToolbarExpander,{}),(0,s.jsx)(r.ToolbarGroup,{title:"",children:(0,s.jsx)(r.ToolbarGroup,{groupable:!1,title:"",children:(0,s.jsx)(c.GraphQlList.SearchBar,{name:"domainName"})})})]});return(0,s.jsx)(c.GraphQlList,{rowKey:"id",filtered:!!n.searchFilters?.domainName,columns:m,toolbar:h,emptyView:(0,s.jsx)(r.ListEmptyView,{title:(0,s.jsx)(y,{content:"noResults"})}),...o})}),(({data:e})=>{const[,t]=atob(e.viewer.client.id).split(":");return{breadcrumbs:[{title:o.Locale.getSection("admin.controllers.reseller.tools").lmsg("title"),href:`/admin/reseller/tools/id/${t}?context=reseller-tools`},{title:o.Locale.getSection("admin.controllers.reseller.tools").lmsg("resourceUsageByDomains"),href:"/cp/resource-usage"}],helpContext:"client.domain-summary-report"}}))},2033:(e,t,a)=>{a.r(t),a.d(t,{default:()=>s.default});var s=a(2034)},2035:(e,t,a)=>{a.r(t),a.d(t,{formatByteSize:()=>r});const s=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],r=e=>{if(!e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**t).toFixed(2)} ${s[t]}`}}}]);
//# sourceMappingURL=resourceUsage.js.map?249c1412a1d8624a7628