import{j as a,d as k,a as B,nE as z,b as P,r as f,nF as b,I as _,mn as y,R as l,nG as A,nH as I,f as M,z as Y,nI as C,M as G,B as H,a2 as N,T as v,bA as R,nJ as U}from"./index-e79f7aad.js";import{c as L}from"./index.esm-05058101.js";import{D as W,a as $}from"./DialogContent-6a297cef.js";import{D as q}from"./DialogTitle-62595023.js";import{T as J}from"./TextField-21e22d39.js";import{D as K}from"./DialogActions-edd1d02f.js";import{C as Q}from"./CircularProgress-8c35778c.js";import{T as X}from"./index-a65810f4.js";import{T as Z,t as D}from"./TableRow-0ea91e40.js";import{d as aa,P as ea}from"./Select-8a61e5a6.js";import{C as ta}from"./CardContent-f9f46bc4.js";import{D as sa}from"./Divider-d5c2dff6.js";import{G as oa}from"./Grid2-7786e458.js";import"./isMuiElement-db2b7d4c.js";import"./useMediaQuery-9155ba05.js";import"./TableContainer-00013c19.js";import"./TableHead-1f8b658d.js";import"./TablePagination-6f9f31d4.js";import"./KeyboardArrowRight-4ee9435c.js";import"./LastPage-1ca2417e.js";import"./Toolbar-d2cd5725.js";import"./MenuItem-c14df0e9.js";import"./dividerClasses-691b251c.js";import"./listItemTextClasses-d3a968ad.js";import"./listItemIconClasses-03011ebf.js";import"./index-e5978b8b.js";const ra=aa(a.jsx("path",{d:"M19 9h-4V3H9v6H5l7 7zm-8 2V5h2v6h1.17L12 13.17 9.83 11zm-6 7h14v2H5z"}),"DownloadOutlined"),na=({open:t})=>{const r=k(),{backupDatabase:{backupData:n,dataBaseId:u,verifyPwdloading:c},system:{userAccessList:h}}=B(s=>({backupDatabase:z(s),system:P(s)})),d=s=>{r(b({key:s.target.name,value:s.target.value}))},o=()=>{const s={password:n.password};r(A({obj:s,dataBaseId:u}))},p=()=>{r(I(!1))};return f.useEffect(()=>{r(b({key:"password",value:n.password}))},[n.password,r]),a.jsxs(W,{open:t,onClose:p,maxWidth:"sm",fullWidth:!0,children:[a.jsxs(q,{children:["Verify Password",a.jsx(_,{onClick:p,style:{position:"absolute",right:8,top:8},children:a.jsx(L,{})})]}),a.jsx($,{children:a.jsx(y,{container:!0,spacing:2,children:a.jsx(y,{item:!0,xs:12,children:a.jsx(J,{fullWidth:!0,label:"Password",name:"password",type:"password",variant:"outlined",placeholder:"Enter Password",value:n.password||"",onChange:d,required:!0})})})}),a.jsxs(K,{children:[a.jsx(l,{onClick:p,color:"secondary",variant:"outlined",children:"Cancel"}),a.jsx(l,{onClick:o,color:"primary",variant:"contained",disabled:c,endIcon:c?a.jsx(Q,{size:20}):null,children:"Verify"})]})]})};M(Z)(({theme:t})=>({[`&.${D.head}`]:{backgroundColor:t.palette.grey[100],color:t.palette.primary},[`&.${D.body}`]:{fontSize:14}}));const Fa=()=>{const t=k(),r=Y(),[n,u]=f.useState(null),c=!!n,h=c?"simple-popover":void 0,{backupDatabase:{backUpDataBaselist:d,backUpDataBaseParams:o,loading:p,listCount:s},system:{userAccessList:i}}=B(e=>({backupDatabase:z(e),system:P(e)}));f.useEffect(()=>{t(C({page:1,search:"",page_size:10}))},[]);const S=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Created On",width:100},{title:"Database File",width:100}];function T(e,m,g,x,V){return{index:e,code:m,name:g,createdon:x,databasefile:V}}const w=d==null?void 0:d.map((e,m)=>{const g=(o.page-1)*o.page_size+(m+1),x=a.jsx(l,{variant:"contained",color:"primary",size:"small",startIcon:a.jsx(ra,{}),onClick:()=>t(I({model:!0,Id:e==null?void 0:e.id})),disabled:!(i!=null&&i.includes("System.export_backup")),children:"Download"});return T(g,e==null?void 0:e.code,e==null?void 0:e.name,G(e==null?void 0:e.createdon).format("DD-MM-YYYY, h:mm:ss a"),x)}),E=e=>{u(e.currentTarget)},j=()=>{u(null)},F=(e,m)=>{t(C({...o,search:"",page:m+1}))},O=e=>{t(C({...o,search:"",page:1,page_size:parseInt(e.target.value)}))};return a.jsx(a.Fragment,{children:a.jsxs(H,{children:[a.jsxs(N,{children:[a.jsxs(ta,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs(v,{variant:"h4",sx:{display:"flex",alignItems:"center",gap:2,cursor:"pointer"},onClick:()=>{r("/pages/settings",{relative:"path"})},children:[a.jsx(R,{}),"Database Backup"]}),(i==null?void 0:i.indexOf("System.add_backup"))!==-1&&a.jsxs(a.Fragment,{children:[a.jsx(l,{"aria-describedby":h,variant:"contained",onClick:E,color:"primary",style:{marginBottom:"15px"},size:"large",children:"Create Database Backup"}),a.jsx(ea,{id:h,open:c,anchorEl:n,onClose:j,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:a.jsxs("div",{style:{padding:"15px"},children:[a.jsx(v,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to Create Database Backup?"}),a.jsx(l,{variant:"contained",type:"submit",color:"primary",onClick:()=>{t(U())},autoFocus:!0,children:"Yes"}),a.jsx(l,{variant:"outlined",size:"small",onClick:j,style:{marginLeft:"20px"},children:"No"})]})})]})]}),a.jsx(sa,{})]}),a.jsx(oa,{size:{xs:12},sx:{mt:3},children:a.jsx(X,{count:s,columns:S,rows:w,loading:p,page:o.page,pageSize:o.page_size,handleChangePage:F,handleChangeRowsPerPage:O})}),a.jsx(na,{open:!1})]})})};export{Fa as default};
