dsql-admin/dsql-app/.local_dist/static/chunks/4403-dd72a46996d6c5f9.js
Benjamin Toby 885c11f674 Updates
2025-01-14 07:42:13 +01:00

1 line
21 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4403],{6206:(e,l,t)=>{t.d(l,{A:()=>c});var a=t(4848),s=t(6540),n=t(1710),i=t(3078),r=t(9020);function d(e){let{paradigm:l,payload:t,setLoading:a,table:s,database:n}=e;a(!0),(0,r.A)("/api/exportTableData",{method:"POST",body:{paradigm:l,dbName:n.db_slug,tableName:s.tableName,payload:t}},!0).then(e=>{if(e.success){if("export"==l){let l=new Blob([JSON.stringify(e.data||[],null,4)],{type:"application/json"}),t=URL.createObjectURL(l),a=document.createElement("a");a.href=t,a.style.display="none",a.download="".concat(n.db_slug,"-").concat(s.tableName,"-").concat(Date.now(),".json"),document.body.appendChild(a),a.click(),document.body.removeChild(a)}else"import"==l&&(window.alert("Data Imported Successfully"),window.location.reload())}else e.msg&&window.alert(e.msg)}).catch(e=>{console.log(e)}).finally(()=>{a(!1)})}function c(e){let{database:l,table:t}=e,[r,c]=s.useState(!1),[o,u]=s.useState(!0),m=s.useRef(null);return s.useRef(null),(0,a.jsxs)("div",{className:"relative",children:[r&&(0,a.jsx)(n.A,{width:"15px"}),(0,a.jsx)("div",{className:"button outlined gray",onClick:e=>{d({paradigm:"export",database:l,setLoading:c,table:t})},children:"Export"}),(0,a.jsx)("div",{className:"button outlined gray",onClick:e=>{var a,s;null===(a=m.current)||void 0===a||a.addEventListener("change",e=>{var a;c(!0);let s=e.target;if(!(null===(a=s.files)||void 0===a?void 0:a[0])){window.alert("No FIles selected"),c(!1);return}(0,i.A)({inputFile:s.files[0]}).then(e=>{window.confirm("Use this file '".concat(e.fileName,"' as your import file?"))?d({paradigm:"import",payload:e.fileBase64,database:l,setLoading:c,table:t}):c(!1),u(!1),setTimeout(()=>{u(!0)},200)})}),null===(s=m.current)||void 0===s||s.click()},children:"Import"}),o&&(0,a.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:m})]})}},3425:(e,l,t)=>{t.d(l,{A:()=>b});var a=t(4848),s=t(6540),n=t(5143),i=t(3238),r=t(1671),d=t(6959),c=t(1710),o=t(9878),u=t(9020),m=t(2543),h=t.n(m);function x(e){let{database:l,table:t,setOpenPopover:n,dbSchemaData:i,query:r}=e,[d,c]=s.useState(!1);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"ghost p-3 justify-start",onClick:()=>{c(!0),setTimeout(()=>{n&&n(!1)},200)},children:"Sync Data"}),(0,a.jsx)(o.A,{open:d,setOpen:c,children:(0,a.jsx)(p,{database:l,table:t,dbSchemaData:i,query:r})})]})}function p(e){let{database:l,table:t,query:n,dbSchemaData:i}=e,[o,m]=s.useState(i),[x,p]=s.useState("Push"),[b,v]=s.useState(null==o?void 0:o[0]),[f,y]=s.useState(null==b?void 0:b.tables),[g,j]=s.useState(null==f?void 0:f[0]),[N,w]=s.useState(!1),[k,A]=s.useState(!1);return s.useEffect(()=>{h().isEqual(null==t?void 0:t.fields,null==g?void 0:g.fields)?A(!0):A(!1)},[g,v]),s.useEffect(()=>{n.delegated&&(0,u.A)("/api/get-authorized-databases").then(e=>{e.success&&e.payload&&m(e.payload)})},[]),(0,a.jsxs)("div",{className:"stack gap-2 relative w-full",children:[N||!o&&(0,a.jsx)(c.A,{width:"20px"}),(0,a.jsx)("h3",{className:"m-0 text-lg",children:"Sync Data with another table"}),k?(0,a.jsxs)("span",{className:"info green inline",children:["The selected table matches ",(0,a.jsx)("b",{children:t.tableFullName})," ","schema"]}):(0,a.jsxs)("span",{className:"info warning inline",children:["The selected table is not compatible with"," ",(0,a.jsx)("b",{children:t.tableFullName})]}),o&&(0,a.jsxs)("form",{onSubmit:e=>{!function(e){var l,t,a;let{e:s,setLoading:n,database:i,table:r,query:d}=e;s.preventDefault(),n(!0);let c=s.target,o=null===(l=c.paradigm)||void 0===l?void 0:l.value,m=null===(t=c.database)||void 0===t?void 0:t.value,h=null===(a=c.table)||void 0===a?void 0:a.value,x={paradigm:o,src:{db:i.db_slug,table:r.tableName},dst:{db:m,table:h},delegated:d.delegated};if(!window.confirm("Pull"==o?"NOTE: This operation will override the current database entries. Continue?":"NOTE: This operation will override the selected database entries. Continue?")){setTimeout(()=>{n(!1)},1e3);return}(0,u.A)("/api/sync-table-data",{method:"POST",body:{...x}},!0).then(e=>{e.success?(window.alert("Data Sync Successful"),window.location.reload()):e.msg&&window.alert("ERROR: "+e.msg)}).finally(()=>{setTimeout(()=>{n(!1)},1e3)})}({e,database:l,setLoading:w,table:t,query:n})},className:"w-full stack gap-2 items-stretch",children:[(0,a.jsxs)("div",{className:"stack gap-2 my-2",children:[(0,a.jsx)(r.A,{radioValues:[{title:"Push",payload:"Push",default:!0},{title:"Pull",payload:"Pull"}],name:"paradigm",smallText:!0,flexRow:!0,onChangeHandler:e=>{p(e.target.value)}}),(0,a.jsx)("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Push"==x?(0,a.jsxs)(a.Fragment,{children:["Sync data from the current table(",(0,a.jsx)("b",{children:t.tableFullName}),") to the selected table below"]}):(0,a.jsxs)(a.Fragment,{children:["Sync data from the selected table below to the current table(",(0,a.jsx)("b",{children:t.tableFullName}),")"]})})]}),(0,a.jsx)(d.A,{selectOptions:o.filter(e=>e.dbFullName!==l.db_full_name).map(e=>({title:e.dbName,payload:e.dbSlug})),name:"database",onChangeHandler:e=>{let l=o.find(l=>l.dbSlug==e.target.value);if(l){var t;v(l),y(l.tables),j(null===(t=l.tables)||void 0===t?void 0:t[0])}}}),(0,a.jsx)(d.A,{selectOptions:f.map(e=>({title:e.tableFullName,payload:e.tableName})),name:"table",onChangeHandler:e=>{let l=f.find(l=>l.tableName===e.target.value);l&&j(l)}}),(0,a.jsx)("button",{className:k?"":"disabled",children:"Sync"})]})]})}function b(e){let{database:l,table:t,dbSchemaData:r,query:d}=e,[c,o]=s.useState(!1);return(0,a.jsx)(n.Popover,{isOpen:c,onClickOutside:()=>o(!1),positions:["bottom"],align:"end",content:(0,a.jsxs)("div",{className:"stack items-stretch bg-white rounded shadow-md gap-0 min-w-[200px]",children:[(0,a.jsx)(x,{database:l,table:t,setOpenPopover:o,dbSchemaData:r,query:d}),(0,a.jsx)("hr",{className:"m-0"})]}),containerClassName:"z-[1000]",children:(0,a.jsx)("button",{onClick:()=>{o(!c)},className:"outlined gray px-2 py-1.5",children:(0,a.jsx)(i.A,{})})})}},4639:(e,l,t)=>{let a;t.d(l,{A:()=>b});var s=t(4848),n=t(6540),i=t(8032),r=t(4279),d=t(6959),c=t(9268),o=t(9020),u=t(1710);function m(e){var l,t,i,m;let{data:h}=e,{table:x,entries:p,activeEntries:b,setActiveEntries:v,confirmedDelegetedUser:f,database:y,targetField:g,searchTerm:j}=n.useContext(r.TableEntriesContext);null==f||f.delegated,null==f||null===(l=f.priviledges)||void 0===l||l.match(/Edit Tables/i),null==f||null===(t=f.priviledges)||void 0===t||t.match(/Delete Tables/i),null==f||null===(i=f.priviledges)||void 0===i||i.match(/Create Tables/i);let[N,w]=n.useState(!1),k=n.useRef();n.useEffect(()=>{k.current&&k.current.focus()},[]);let[A,T]=n.useState(null);function S(e){var l,t;if(w(!0),b&&v(null),!(null==e?void 0:e.toString().match(/./))){setTimeout(()=>{v&&v(p||[]),w(!1)},500);return}window.clearTimeout(a);let s=null==x?void 0:x.fields.filter(e=>e.fieldName===(null==g?void 0:g.current)),n=s&&s[0]&&(null===(t=s[0].dataType)||void 0===t?void 0:t.match(/int/i))||(null==g?void 0:null===(l=g.current)||void 0===l?void 0:l.match(/^id$/))?"equal":"like";a=setTimeout(()=>{w(!1),(0,o.A)("/api/queryEntriesSearchTerm?db=".concat(null==y?void 0:y.db_full_name,"&table=").concat(null==x?void 0:x.tableName,"&field=").concat(null==g?void 0:g.current,"&term=").concat(e,"&operator=").concat(n)).then(e=>{"number"==typeof e.count&&T(e.count),e.success&&v&&v(e.result),w(!1)})},500)}return(0,s.jsxs)("div",{className:"w-full flex-col items-stretch",children:[(0,s.jsxs)("form",{onSubmit:e=>{e.preventDefault(),(null==j?void 0:j.current)&&S(j.current)},className:"flex flex-row items-stretch gap-4 w-full",children:[(0,s.jsx)("div",{className:"max-w-xs",children:(0,s.jsx)(d.A,{required:!0,selectOptions:x?x.fields.map(e=>({title:e.fieldName||"",payload:e.fieldName||""})):[],name:"database_tables",onChangeHandler:e=>{g&&(g.current=e.target.value)},title:"Select Field",defaultValue:null==g?void 0:g.current,id:"entries-search-field-select"})}),(0,s.jsx)("div",{className:"grow",children:(0,s.jsx)(c.A,{title:"Search Term",placeholder:"Enter search term that corresponds with the selected field type ...",onInputHandler:e=>{var l;let t=e.target;(null===(l=t.value)||void 0===l?void 0:l.match(/./))&&j?j.current=t.value:j&&(j.current=null),S(t.value)},elementRef:k,id:"entries-search-input"})}),N&&(0,s.jsx)("div",{className:"relative items-center justify-center",children:(0,s.jsx)("div",{className:"relative mt-5 w-6",children:(0,s.jsx)(u.A,{width:"20px"})})})]}),(null==j?void 0:null===(m=j.current)||void 0===m?void 0:m.match(/./))&&(0,s.jsx)("div",{className:"py-4",children:(0,s.jsxs)("span",{className:"text-lg",children:["number"==typeof A?A>0?(0,s.jsxs)("b",{children:[A," "]}):(0,s.jsx)(s.Fragment,{children:"No "}):"... ","Search result",A&&1!==A?"s":""," for"," ",(0,s.jsxs)("b",{children:['"',j.current,'"']})]})})]})}var h=t(6206),x=t(3425),p=t(2276);function b(e){var l,t,a,r,d;let{user:c,entries:o,database:b,table:v,setTargetEntry:f,dbSchemaData:y,richTextEditors:g,jsonTextEditors:j,dataTypes:N,title:w,confirmedDelegetedUser:k,query:A,search:T,entriesCount:S}=e;null==k||k.delegated,null==k||null===(l=k.priviledges)||void 0===l||l.match(/Edit Tables/i),null==k||null===(t=k.priviledges)||void 0===t||t.match(/Delete Tables/i),null==k||null===(a=k.priviledges)||void 0===a||a.match(/Create Tables/i),null==k||null===(r=k.priviledges)||void 0===r||r.match(/Edit Entries/i),null==k||null===(d=k.priviledges)||void 0===d||d.match(/Delete Entries/i);let{active_clone:E,active_clone_parent_db:_,remote_connected:F}=b;return(0,s.jsx)(n.Fragment,{children:(0,s.jsxs)("section",{className:"paper gray gray-bg",children:[w&&(0,s.jsxs)("div",{className:"justify-between w-full flex-wrap px-4 sm:px-0 pt-4 sm:pt-0",children:[(0,s.jsx)("h2",{className:"text-xl m-0",children:w}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("a",{className:"button flex gap-2 items-center",href:"/admin/".concat(null==c?void 0:c.id,"/databases/").concat(b.db_slug,"/tables/").concat(v.tableName,"/entries/add-entry"),children:[(0,s.jsx)("span",{className:"symbol",children:"+"}),(0,s.jsx)("span",{children:"Add New Entry"})]}),(0,s.jsx)(h.A,{database:b,table:v}),(0,s.jsx)(x.A,{database:b,table:v,dbSchemaData:y,query:A})]})]}),T&&(0,s.jsx)(m,{}),(0,s.jsxs)("div",{className:"w-full flex-col gap-6",children:[(null==o?void 0:o[0])&&o.map(e=>(0,s.jsx)(n.Fragment,{children:(0,s.jsx)(i.A,{user:c,database:b,table:v,dbSchemaData:y,richTextEditors:g,dataTypes:N,entry:e,query:A,confirmedDelegetedUser:k,jsonTextEditors:j})},e.id)),!o&&(0,s.jsx)("div",{className:"w-full h-[300px]",children:(0,s.jsx)(u.A,{position:"relative"})}),o&&!(null==o?void 0:o[0])&&(0,s.jsxs)("a",{href:"/admin/".concat(null==c?void 0:c.id,"/databases/").concat(b.db_slug,"/tables/").concat(v.tableName,"/entries/add-entry"),className:"border-dotted border-slate-200 border-2 p-4 w-full flex-col rounded flex items-center hover:border-primary/50 gap-2",children:[(0,s.jsx)("span",{className:"text-slate-400 text-center",children:"No Entries Added Yet."}),(0,s.jsx)(p.A,{}),(0,s.jsx)("span",{className:"text-center",children:"Add an Entry to this Table"})]}),S&&S>10?(0,s.jsx)("a",{href:"/admin/".concat(null==c?void 0:c.id,"/databases/").concat(b.db_slug,"/tables/").concat(v.tableName,"/entries"),className:"button outlined gray w-full -mb-4",children:(0,s.jsx)("span",{children:"See All Entries"})}):null,(null==o?void 0:o[0])&&w&&(0,s.jsxs)("a",{className:"button flex gap-2 items-center w-full justify-center mt-2 more-padding",href:"/admin/".concat(null==c?void 0:c.id,"/databases/").concat(b.db_slug,"/tables/").concat(v.tableName,"/entries/add-entry"),style:{borderStyle:"dotted",borderWidth:"2px"},children:[(0,s.jsx)("span",{className:"symbol",children:"+"}),(0,s.jsx)("span",{children:"Add New Entry"})]})]})]})})}},1671:(e,l,t)=>{t.d(l,{A:()=>s});var a=t(4848);function s(e){let{radioValues:l,name:t,onChangeHandler:s,setAlert:n,flexRow:i,labelColor:r,baseText:d,smallText:c,className:o}=e;try{return(0,a.jsx)("div",{className:"flex items-start gap-4 flex-wrap "+(i?"":" flex-col ")+(o||""),children:l.map((e,l)=>{let{payload:i,title:o,jsx:u}=e,m=!1===i?i:i||o||null;return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("input",{className:"m-0"+(d?" w-5 h-5":c?" w-4 h-4":" w-6 h-6"),type:"radio",defaultChecked:!!e.default,name:t,id:t+"_"+m,onChange:l=>{n&&n(null),e.onChangeHandler?e.onChangeHandler(l):s&&s(l)},value:"string"==typeof m?m:void 0}),u||(0,a.jsx)("label",{htmlFor:t+"_"+m,className:"text-lg m-0 "+(r||"text-slate-800")+(d?" text-base":c?" text-sm":" text-lg"),children:o})]},l+1)})})}catch(e){return console.log("ERROR in FormRadio =>",e),(0,a.jsx)("div",{children:"Form Radio Error"})}}t(6540)},7700:(e,l,t)=>{t.d(l,{A:()=>n});var a=t(4848),s=t(6540);function n(e){let{table:l,database:t,user:n,activeDbClone:i}=e,r=(null==l?void 0:l.childTableDbFullName)?l.childTableDbFullName.replace(new RegExp(/datasquirel_user_\d+_/),""):null,d=l.childTableDbFullName===t.db_full_name;return r?(0,a.jsxs)("span",{className:"info small green gap-1"+((null==t?void 0:t.active_clone)?" -mt-6":""),style:{fontWeight:"500"},children:["This Table is an active clone of"," ",(0,a.jsx)("a",{href:"/admin/".concat(null==n?void 0:n.id,"/databases/").concat(r,"/tables/").concat(l.childTableName),target:"_blank",className:"button gray outlined small-text",style:{display:"inline-block",fontSize:"12px",padding:"3px 7px"},children:(0,a.jsx)("b",{children:l.childTableName})})," ","in"," ",d?(0,a.jsxs)("span",{children:["this current database(",(0,a.jsx)("b",{children:t.db_name}),")."]}):(0,a.jsxs)(s.Fragment,{children:[(0,a.jsx)("a",{href:"/admin/".concat(null==n?void 0:n.id,"/databases/").concat(r),target:"_blank",className:"button gray outlined small-text",style:{display:"inline-block",fontSize:"12px",padding:"3px 7px"},children:(0,a.jsx)("b",{children:r})}),(0,a.jsx)("span",{children:"database."})]})," ",(null==t?void 0:t.active_clone)?"":"Only Foreign keys and Entries can be updated."]}):(0,a.jsx)(s.Fragment,{})}},8453:(e,l,t)=>{t.d(l,{A:()=>a});let a=(0,t(5737).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},7845:(e,l,t)=>{t.d(l,{A:()=>a});let a=(0,t(5737).A)("CopyPlus",[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},4769:(e,l,t)=>{t.d(l,{A:()=>a});let a=(0,t(5737).A)("FileCog",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2",key:"17k7jt"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}],["path",{d:"M6 10v1",key:"xs0f9j"}],["path",{d:"M6 17v1",key:"idyhc0"}],["path",{d:"M10 14H9",key:"m5fm2q"}],["path",{d:"M3 14H2",key:"19ot09"}],["path",{d:"m9 11-.88.88",key:"lhul2b"}],["path",{d:"M3.88 16.12 3 17",key:"169z9n"}],["path",{d:"m9 17-.88-.88",key:"5io96w"}],["path",{d:"M3.88 11.88 3 11",key:"1ynhy1"}]])},1333:(e,l,t)=>{t.d(l,{A:()=>a});let a=(0,t(5737).A)("FileX2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m8 12.5-5 5",key:"b853mi"}],["path",{d:"m3 12.5 5 5",key:"1qls4r"}]])},2276:(e,l,t)=>{t.d(l,{A:()=>a});let a=(0,t(5737).A)("Grid2x2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M12 3v18",key:"108xh3"}]])},2750:(e,l,t)=>{t.d(l,{A:()=>a});let a=(0,t(5737).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},8190:(e,l,t)=>{t.d(l,{A:()=>a});let a=(0,t(5737).A)("Sheet",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["line",{x1:"3",x2:"21",y1:"9",y2:"9",key:"1vqk6q"}],["line",{x1:"3",x2:"21",y1:"15",y2:"15",key:"o2sbyz"}],["line",{x1:"9",x2:"9",y1:"9",y2:"21",key:"1ib60c"}],["line",{x1:"15",x2:"15",y1:"9",y2:"21",key:"1n26ft"}]])},2836:(e,l,t)=>{t.d(l,{A:()=>a});let a=(0,t(5737).A)("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]])},4279:(e,l,t)=>{let a;t.r(l),t.d(l,{TableEntriesContext:()=>w,__N_SSP:()=>N,default:()=>k});var s=t(4848),n=t(6540),i=t(8181),r=t(5844),d=t(3647),c=t(5139),o=t(4639),u=t(8064),m=t(7700),h=t(2438),x=t(1710),p=t(9020),b=t(6206),v=t(3425);function f(){var e,l,a;let{user:i,database:x,table:p,dbSchemaData:f,setTargetEntry:g,richTextEditors:j,jsonTextEditors:N,query:k,confirmedDelegetedUser:A,activeEntries:T,entriesCount:S,setActiveEntries:E}=n.useContext(w),_=t(4327);return null==A||A.delegated,null==A||null===(e=A.priviledges)||void 0===e||e.match(/Edit Tables/i),null==A||null===(l=A.priviledges)||void 0===l||l.match(/Delete Tables/i),null==A||null===(a=A.priviledges)||void 0===a||a.match(/Create Tables/i),(0,s.jsxs)(n.Fragment,{children:[(0,s.jsxs)("div",{className:"flex-col items-start gap-0 w-full relative z-50",children:[(0,s.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,s.jsxs)("div",{className:"flex-wrap",children:[(0,s.jsx)(r.A,{}),(0,s.jsx)("h1",{className:"text-3xl m-0",children:(0,s.jsxs)("span",{className:"flex items-center flex-wrap gap-2",children:["All Entries In"," ",(0,s.jsxs)("span",{className:"bg-slate-100 dark:bg-slate-800 px-2 py-1 border border-solid border-slate-400 dark:border-slate-600 rounded relative",children:[p.tableFullName,(0,s.jsx)("div",{className:"absolute -top-5 -right-4",children:(0,s.jsx)(c.A,{slugText:p.tableName,justIcon:!0})})]})," ","Table"]})})]}),(0,s.jsxs)("div",{className:"w-full sm:w-auto",children:[(0,s.jsxs)("a",{href:"/admin/".concat(null==i?void 0:i.id,"/databases/").concat(x.db_slug,"/tables/").concat(p.tableName,"/entries/add-entry"),className:"button flex items-center gap-2 w-full sm:w-auto justify-center",children:[(0,s.jsx)("span",{className:"symbol",children:"+"}),(0,s.jsx)("span",{children:"Add New Entry"})]}),(0,s.jsx)(b.A,{database:x,table:p}),(0,s.jsx)(v.A,{database:x,table:p,dbSchemaData:f,query:k})]})]}),(0,s.jsx)(d.A,{confirmedDelegetedUser:null==k?void 0:k.delegated,user:i})]}),x.active_clone?(0,s.jsx)(u.A,{database:x,user:i}):(0,s.jsx)(s.Fragment,{}),x.remote_connected?(0,s.jsx)(h.p,{database:x}):(0,s.jsx)(s.Fragment,{}),(0,s.jsx)(m.A,{table:p,database:x,user:i}),(0,s.jsx)(o.A,{user:i,entries:T,database:x,table:p,setTargetEntry:g,dbSchemaData:f,richTextEditors:j,dataTypes:_,query:k,confirmedDelegetedUser:A,jsonTextEditors:N,search:!0}),S>20&&(0,s.jsx)(y,{activeEntries:T,setActiveEntries:E,database:x,table:p,entriesCount:S})]})}function y(e){let{activeEntries:l,setActiveEntries:t,database:i,table:r,entriesCount:d}=e,c=n.useContext(w),o=n.useRef(),u=n.useRef(1),m=20*Number(u.current);return(n.useEffect(()=>{let e=(e,l)=>{var s;if(null==e?void 0:null===(s=e[0])||void 0===s?void 0:s.isIntersecting){let e=document.getElementById("entries-search-input"),l=document.getElementById("entries-search-field-select"),s={tableName:r.tableName,dbName:i.db_slug,page:u.current,tableSchema:r,search:e?e.value:void 0,searchField:l?l.value:void 0,delegated:!!c.query.delegated};(0,p.A)("/api/infiniteScroll",{method:"POST",body:s},!0).then(e=>{e.success&&(e.page&&(u.current=e.page),window.clearTimeout(a),a=setTimeout(()=>{var l,a;(null===(l=e.data)||void 0===l?void 0:l[0])&&(null===(a=e.data)||void 0===a?void 0:a[0])&&t(l=>l?[...l,...e.data]:null)},500))}).catch(e=>{console.log("Infinite Scroll Error =>",e)}).finally(()=>{console.log("Infinite Scroll Done. Page",u.current)})}},l={rootMargin:"0px 0px 0px 0px"};setTimeout(()=>{requestAnimationFrame(()=>{let t=new IntersectionObserver(e,l);o.current&&t.observe(o.current)})},1e3)},[]),m>=d)?(0,s.jsx)(n.Fragment,{}):(0,s.jsx)("div",{className:"w-full flex items-center justify-center",ref:o,children:(0,s.jsx)(x.A,{position:"relative",style:{backgroundColor:"transparent"},width:"20px"})})}var g=t(5211),j=t(4477),N=!0;let w=n.createContext({});function k(e){let{user:l,database:t,table:a,dbSchemaData:r,entries:d,query:c,confirmedDelegetedUser:o,entriesCount:u}=e,m="".concat(a.tableFullName," Table Entries | Datasquirel"),h=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("title",{children:m}),(0,s.jsx)("meta",{name:"description",content:"All Entries in table"})]}),[x,p]=n.useState(null),[b,v]=n.useState(d),y=n.useRef("title"),N=n.useRef(null),k=n.useRef([]),A=n.useRef([]);return(0,s.jsx)(i.A,{head:h,user:l,extraHeaderContent:(0,s.jsx)(g.A,{database:t,query:c,confirmedDelegetedUser:o,user:l}),children:(0,s.jsxs)(w.Provider,{value:{user:l,database:t,table:a,dbSchemaData:r,entries:d,targetEntry:x,setTargetEntry:p,richTextEditors:k,jsonTextEditors:A,query:c,confirmedDelegetedUser:o,activeEntries:b,setActiveEntries:v,targetField:y,searchTerm:N,entriesCount:u},children:[(0,s.jsx)(f,{}),(0,s.jsx)(j.A,{snug:!0})]})})}}}]);