1 line
29 KiB
JavaScript
1 line
29 KiB
JavaScript
|
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9035],{82943:function(e,t,a){a.d(t,{Z:function(){return c}});var n=a(828),l=a(85893),i=a(67294),s=a(95264),r=a(53314),d=a(86729);function o(e){var t=e.paradigm,a=e.payload,n=e.setLoading,l=e.table,i=e.database;n(!0),(0,d.Z)("/api/exportTableData",{method:"POST",body:{paradigm:t,dbName:i.db_slug,tableName:l.tableName,payload:a}},!0).then((function(e){if(e.success)if("export"==t){var a=e.data,n=JSON.stringify(a||[],null,4),s=new Blob([n],{type:"application/json"}),r=URL.createObjectURL(s),d=document.createElement("a");d.href=r,d.style.display="none",d.download="".concat(i.db_slug,"-").concat(l.tableName,"-").concat(Date.now(),".json"),document.body.appendChild(d),d.click(),document.body.removeChild(d)}else"import"==t&&(window.alert("Data Imported Successfully"),window.location.reload());else e.msg&&window.alert(e.msg)})).catch((function(e){console.log(e)})).finally((function(){n(!1)}))}function c(e){var t=e.database,a=e.table,d=function(){h(!1),setTimeout((function(){h(!0)}),200)},c=(0,n.Z)(i.useState(!1),2),u=c[0],m=c[1],f=(0,n.Z)(i.useState(!0),2),v=f[0],h=f[1],p=i.useRef(null);i.useRef(null);return(0,l.jsxs)("div",{className:"relative",children:[u&&(0,l.jsx)(s.Z,{width:"15px"}),(0,l.jsx)("div",{className:"button outlined gray",onClick:function(e){o({paradigm:"export",database:t,setLoading:m,table:a})},children:"Export"}),(0,l.jsx)("div",{className:"button outlined gray",onClick:function(e){var n,l;null===(n=p.current)||void 0===n||n.addEventListener("change",(function(e){var n;m(!0);var l=e.target;if(!(null===(n=l.files)||void 0===n?void 0:n[0]))return window.alert("No FIles selected"),void m(!1);(0,r.Z)({inputFile:l.files[0]}).then((function(e){window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))?(o({paradigm:"import",payload:e.fileBase64,database:t,setLoading:m,table:a}),d()):(m(!1),d())}))})),null===(l=p.current)||void 0===l||l.click()},children:"Import"}),v&&(0,l.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:p})]})}},13684:function(e,t,a){a.d(t,{Z:function(){return o}});var n=a(828),l=a(85893),i=a(67294),s=a(82106),r=a(9404),d=a(40436);function o(e){var t=e.database,a=e.table,o=e.dbSchemaData,c=e.query,u=(0,n.Z)(i.useState(!1),2),m=u[0],f=u[1];return(0,l.jsx)(s.Popover,{isOpen:m,onClickOutside:function(){return f(!1)},positions:["bottom"],align:"end",content:(0,l.jsxs)("div",{className:"stack items-stretch bg-white rounded shadow-md gap-0 min-w-[200px]",children:[(0,l.jsx)(d.Z,{database:t,table:a,setOpenPopover:f,dbSchemaData:o,query:c}),(0,l.jsx)("hr",{className:"m-0"})]}),containerClassName:"z-[1000]",children:(0,l.jsx)("button",{onClick:function(){f(!m)},className:"outlined gray px-2 py-1.5",children:(0,l.jsx)(r.Z,{})})})}},40436:function(e,t,a){a.d(t,{Z:function(){return v}});var n=a(828),l=a(85893),i=a(22348),s=a(44114),r=a(95264),d=a(59471),o=a(86729),c=a(26042);var u=a(96486),m=a.n(u),f=a(67294);function v(e){var t=e.database,a=e.table,i=e.setOpenPopover,s=e.dbSchemaData,r=e.query,o=(0,n.Z)(f.useState(!1),2),c=o[0],u=o[1];return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("button",{className:"ghost p-3 justify-start",onClick:function(){u(!0),setTimeout((function(){i&&i(!1)}),200)},children:"Sync Data"}),(0,l.jsx)(d.Z,{open:c,setOpen:u,children:(0,l.jsx)(h,{database:t,table:a,dbSchemaData:s,query:r})})]})}function h(e){var t=e.database,a=e.table,d=e.query,u=e.dbSchemaData,v=(0,n.Z)(f.useState(u),2),h=v[0],p=v[1],b=(0,n.Z)(f.useState("Push"),2),x=b[0],g=b[1],j=(0,n.Z)(f.useState(null===h||void 0===h?void 0:h[0]),2),y=j[0],N=j[1],w=(0,n.Z)(f.useState(null===y||void 0===y?void 0:y.tables),2),T=w[0],E=w[1],S=(0,n.Z)(f.useState(null===T||void 0===T?void 0:T[0]),2),Z=S[0],_=S[1],C=(0,n.Z)(f.useState(!1),2),D=C[0],F=C[1],k=(0,n.Z)(f.useState(!1),2),q=k[0],R=k[1];return f.useEffect((function(){var e=m().isEqual(null===a||void 0===a?void 0:a.fields,null===Z||void 0===Z?void 0:Z.fields);R(!!e)}),[Z,N]),f.useEffect((function(){d.delegated&&(0,o.Z)("/api/get-authorized
|