dsql-admin/dsql-app/.local_dist/static/chunks/6460-44a9fb82157e2b3e.js
Benjamin Toby 8b7ea057d0 Updates
2024-12-06 14:24:26 +01:00

1 line
27 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6460],{76919:(e,t,l)=>{l.d(t,{A:()=>c});var a=l(74848),s=l(96540),n=l(620),i=l(95896),d=l(23698);function r(e){let{paradigm:t,payload:l,setLoading:a,table:s,database:n}=e;a(!0),(0,d.A)("/api/exportTableData",{method:"POST",body:{paradigm:t,dbName:n.db_slug,tableName:s.tableName,payload:l}},!0).then(e=>{if(e.success){if("export"==t){let t=new Blob([JSON.stringify(e.data||[],null,4)],{type:"application/json"}),l=URL.createObjectURL(t),a=document.createElement("a");a.href=l,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"==t&&(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:t,table:l}=e,[d,c]=s.useState(!1),[o,u]=s.useState(!0),m=s.useRef(null);return s.useRef(null),(0,a.jsxs)("div",{className:"relative",children:[d&&(0,a.jsx)(n.A,{width:"15px"}),(0,a.jsx)("div",{className:"button outlined gray",onClick:e=>{r({paradigm:"export",database:t,setLoading:c,table:l})},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?"))?r({paradigm:"import",payload:e.fileBase64,database:t,setLoading:c,table:l}):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})]})}},93644:(e,t,l)=>{l.d(t,{A:()=>r});var a=l(74848),s=l(96540),n=l(5143),i=l(23238),d=l(31942);function r(e){let{database:t,table:l,dbSchemaData:r,query:c}=e,[o,u]=s.useState(!1);return(0,a.jsx)(n.Popover,{isOpen:o,onClickOutside:()=>u(!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)(d.A,{database:t,table:l,setOpenPopover:u,dbSchemaData:r,query:c}),(0,a.jsx)("hr",{className:"m-0"})]}),containerClassName:"z-[1000]",children:(0,a.jsx)("button",{onClick:()=>{u(!o)},className:"outlined gray px-2 py-1.5",children:(0,a.jsx)(i.A,{})})})}},31942:(e,t,l)=>{l.d(t,{A:()=>m});var a=l(74848),s=l(60637),n=l(41301),i=l(620),d=l(44500),r=l(23698),c=l(2543),o=l.n(c),u=l(96540);function m(e){let{database:t,table:l,setOpenPopover:s,dbSchemaData:n,query:i}=e,[r,c]=u.useState(!1);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{className:"ghost p-3 justify-start",onClick:()=>{c(!0),setTimeout(()=>{s&&s(!1)},200)},children:"Sync Data"}),(0,a.jsx)(d.A,{open:r,setOpen:c,children:(0,a.jsx)(p,{database:t,table:l,dbSchemaData:n,query:i})})]})}function p(e){let{database:t,table:l,query:d,dbSchemaData:c}=e,[m,p]=u.useState(c),[h,f]=u.useState("Push"),[x,b]=u.useState(null==m?void 0:m[0]),[v,g]=u.useState(null==x?void 0:x.tables),[j,N]=u.useState(null==v?void 0:v[0]),[y,w]=u.useState(!1),[T,S]=u.useState(!1);return u.useEffect(()=>{o().isEqual(null==l?void 0:l.fields,null==j?void 0:j.fields)?S(!0):S(!1)},[j,b]),u.useEffect(()=>{d.delegated&&(0,r.A)("/api/get-authorized-databases").then(e=>{e.success&&e.payload&&p(e.payload)})},[]),(0,a.jsxs)("div",{className:"stack gap-2 relative w-full",children:[y||!m&&(0,a.jsx)(i.A,{width:"20px"}),(0,a.jsx)("h3",{className:"m-0 text-lg",children:"Sync Data with another table"}),T?(0,a.jsxs)("span",{className:"info green inline",children:["The selected table matches ",(0,a.jsx)("b",{children:l.tableFullName})," ","schema"]}):(0,a.jsxs)("span",{className:"info warning inline",children:["The selected table is not compatible with"," ",(0,a.jsx)("b",{children:l.tableFullName})]}),m&&(0,a.jsxs)("form",{onSubmit:e=>{!function(e){var t,l,a;let{e:s,setLoading:n,database:i,table:d,query:c}=e;s.preventDefault(),n(!0);let o=s.target,u=null===(t=o.paradigm)||void 0===t?void 0:t.value,m=null===(l=o.database)||void 0===l?void 0:l.value,p=null===(a=o.table)||void 0===a?void 0:a.value,h={paradigm:u,src:{db:i.db_slug,table:d.tableName},dst:{db:m,table:p},delegated:c.delegated};if(!window.confirm("Pull"==u?"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,r.A)("/api/sync-table-data",{method:"POST",body:{...h}},!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:t,setLoading:w,table:l,query:d})},className:"w-full stack gap-2 items-stretch",children:[(0,a.jsxs)("div",{className:"stack gap-2 my-2",children:[(0,a.jsx)(s.A,{radioValues:[{title:"Push",payload:"Push",default:!0},{title:"Pull",payload:"Pull"}],name:"paradigm",smallText:!0,flexRow:!0,onChangeHandler:e=>{f(e.target.value)}}),(0,a.jsx)("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Push"==h?(0,a.jsxs)(a.Fragment,{children:["Sync data from the current table(",(0,a.jsx)("b",{children:l.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:l.tableFullName}),")"]})})]}),(0,a.jsx)(n.A,{selectOptions:m.filter(e=>e.dbFullName!==t.db_full_name).map(e=>({title:e.dbName,payload:e.dbSlug})),name:"database",onChangeHandler:e=>{let t=m.find(t=>t.dbSlug==e.target.value);if(t){var l;b(t),g(t.tables),N(null===(l=t.tables)||void 0===l?void 0:l[0])}}}),(0,a.jsx)(n.A,{selectOptions:v.map(e=>({title:e.tableFullName,payload:e.tableName})),name:"table",onChangeHandler:e=>{let t=v.find(t=>t.tableName===e.target.value);t&&N(t)}}),(0,a.jsx)("button",{className:T?"":"disabled",children:"Sync"})]})]})}},55098:(e,t,l)=>{let a;l.d(t,{A:()=>x});var s=l(74848),n=l(96540),i=l(47111),d=l(31041),r=l(41301),c=l(25414),o=l(23698),u=l(620);function m(e){var t,i,m,p;let{data:h}=e,{table:f,entries:x,activeEntries:b,setActiveEntries:v,confirmedDelegetedUser:g,database:j,targetField:N,searchTerm:y}=n.useContext(d.TableEntriesContext);l(94327),null==g||g.delegated,null==g||null===(t=g.priviledges)||void 0===t||t.match(/Edit Tables/i),null==g||null===(i=g.priviledges)||void 0===i||i.match(/Delete Tables/i),null==g||null===(m=g.priviledges)||void 0===m||m.match(/Create Tables/i);let[w,T]=n.useState(!1),S=n.useRef();n.useEffect(()=>{S.current&&S.current.focus()},[]);let[E,A]=n.useState(null);function _(e){var t,l;if(T(!0),b&&v(null),!(null==e?void 0:e.toString().match(/./))){setTimeout(()=>{v&&v(x||[]),T(!1)},500);return}window.clearTimeout(a);let s=null==f?void 0:f.fields.filter(e=>e.fieldName===(null==N?void 0:N.current)),n=s&&s[0]&&(null===(l=s[0].dataType)||void 0===l?void 0:l.match(/int/i))||(null==N?void 0:null===(t=N.current)||void 0===t?void 0:t.match(/^id$/))?"equal":"like";a=setTimeout(()=>{T(!1),(0,o.A)("/api/queryEntriesSearchTerm?db=".concat(null==j?void 0:j.db_full_name,"&table=").concat(null==f?void 0:f.tableName,"&field=").concat(null==N?void 0:N.current,"&term=").concat(e,"&operator=").concat(n)).then(e=>{"number"==typeof e.count&&A(e.count),e.success&&v&&v(e.result),T(!1)})},500)}return(0,s.jsxs)("div",{className:"w-full flex-col items-stretch",children:[(0,s.jsxs)("form",{onSubmit:e=>{e.preventDefault(),(null==y?void 0:y.current)&&_(y.current)},className:"flex flex-row items-stretch gap-4 w-full",children:[(0,s.jsx)("div",{className:"max-w-xs",children:(0,s.jsx)(r.A,{required:!0,selectOptions:f?f.fields.map(e=>({title:e.fieldName||"",payload:e.fieldName||""})):[],name:"database_tables",onChangeHandler:e=>{N&&(N.current=e.target.value)},title:"Select Field",defaultValue:null==N?void 0:N.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 t;let l=e.target;(null===(t=l.value)||void 0===t?void 0:t.match(/./))&&y?y.current=l.value:y&&(y.current=null),_(l.value)},elementRef:S,id:"entries-search-input"})}),w&&(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==y?void 0:null===(p=y.current)||void 0===p?void 0:p.match(/./))&&(0,s.jsx)("div",{className:"py-4",children:(0,s.jsxs)("span",{className:"text-lg",children:["number"==typeof E?E>0?(0,s.jsxs)("b",{children:[E," "]}):(0,s.jsx)(s.Fragment,{children:"No "}):"... ","Search result",E&&1!==E?"s":""," for"," ",(0,s.jsxs)("b",{children:['"',y.current,'"']})]})})]})}var p=l(35381),h=l(76919),f=l(93644);function x(e){var t,l,a,d,r;let{user:c,entries:o,database:x,table:b,setTargetEntry:v,dbSchemaData:g,richTextEditors:j,jsonTextEditors:N,dataTypes:y,title:w,confirmedDelegetedUser:T,query:S,search:E,entriesCount:A}=e;null==T||T.delegated,null==T||null===(t=T.priviledges)||void 0===t||t.match(/Edit Tables/i),null==T||null===(l=T.priviledges)||void 0===l||l.match(/Delete Tables/i),null==T||null===(a=T.priviledges)||void 0===a||a.match(/Create Tables/i),null==T||null===(d=T.priviledges)||void 0===d||d.match(/Edit Entries/i),null==T||null===(r=T.priviledges)||void 0===r||r.match(/Delete Entries/i);let{active_clone:_,active_clone_parent_db:C,remote_connected:F}=x;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(x.db_slug,"/tables/").concat(b.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:x,table:b}),(0,s.jsx)(f.A,{database:x,table:b,dbSchemaData:g,query:S})]})]}),E&&(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:x,table:b,dbSchemaData:g,richTextEditors:j,dataTypes:y,entry:e,query:S,confirmedDelegetedUser:T,jsonTextEditors:N})},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(x.db_slug,"/tables/").concat(b.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,{className:"opacity-20 my-4",sx:{fontSize:80}}),(0,s.jsx)("span",{className:"text-center",children:"Add an Entry to this Table"})]}),A&&A>10?(0,s.jsx)("a",{href:"/admin/".concat(null==c?void 0:c.id,"/databases/").concat(x.db_slug,"/tables/").concat(b.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(x.db_slug,"/tables/").concat(b.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"})]})]})]})})}l(31942)},47111:(e,t,l)=>{l.d(t,{A:()=>b});var a=l(74848),s=l(96540),n=l(58825),i=l(23698),d=l(17531),r=l(66604),c=l(620),o=l(52507),u=l(2543),m=l.n(u),p=l(41263),h=l(23238),f=l(5143);function x(e){let{user:t,table:l,entry:n,url:i,query:d}=e,[r,c]=s.useState(!1),o=s.useRef(null);return(0,a.jsx)("div",{className:"relative z-[1000]",children:(0,a.jsx)(f.Popover,{isOpen:r,onClickOutside:()=>c(!1),containerClassName:"z-[1000]",positions:["bottom"],align:"end",content:(0,a.jsx)("div",{className:"bg-white dark:bg-slate-900 rounded shadow-md cancel-link",children:(0,a.jsxs)("div",{className:"flex-col min-w-[200px] items-stretch gap-0",children:[(0,a.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(n)).then(()=>{window.alert("Post Copied"),c(!1)})},children:"Copy Object"}),(0,a.jsx)("hr",{className:"m-0"}),(0,a.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{let e=(0,p.A)({paradigm:"JavaScript",table:l,query:d,user:t});navigator.clipboard.writeText(e||"").then(()=>{window.alert("JavaScript Type Definition Copied"),c(!1)})},children:"Copy JS Type Definition"}),(0,a.jsx)("hr",{className:"m-0"}),(0,a.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{let e=(0,p.A)({paradigm:"TypeScript",table:l,query:d,user:t});navigator.clipboard.writeText(e||"").then(()=>{window.alert("TypeScript Type Definition Copied"),c(!1)})},children:"Copy TS Type Definition"}),(0,a.jsx)("hr",{className:"m-0"}),(0,a.jsx)("a",{href:i,className:"button plain-text justify-start py-3",children:(0,a.jsx)("span",{children:"View Entry"})})]})}),children:(0,a.jsx)("button",{onClick:()=>{c(!r)},ref:o,className:"ghost p-2",children:(0,a.jsx)(h.A,{})})})})}function b(e){var t,l,u,p,h;let{user:f,database:b,table:v,dbSchemaData:g,richTextEditors:j,jsonTextEditors:N,dataTypes:y,entry:w,entryPage:T,confirmedDelegetedUser:S,query:E}=e,A=v.fields.filter(e=>e.fieldName&&!e.fieldName.match(n.A)),_=v.fields.find(e=>"uuid"===e.fieldName),C=null==S?void 0:S.delegated;null==S||null===(t=S.priviledges)||void 0===t||t.match(/Edit Tables/i),null==S||null===(l=S.priviledges)||void 0===l||l.match(/Delete Tables/i),null==S||null===(u=S.priviledges)||void 0===u||u.match(/Create Tables/i),null==S||null===(p=S.priviledges)||void 0===p||p.match(/Edit Entries/i);let F=null==S?void 0:null===(h=S.priviledges)||void 0===h?void 0:h.match(/Delete Entries/i);_&&A.unshift({dataType:"UUID",fieldName:"uuid",defaultField:!0}),A.unshift({dataType:"BIGINT",fieldName:"id",defaultField:!0}),A.push({dataType:"VARCHAR(250)",fieldName:"date_created",defaultField:!0}),A.push({dataType:"BIGINT",fieldName:"date_created_code",defaultField:!0}),A.push({dataType:"TIMESTAMP",fieldName:"date_created_timestamp",defaultField:!0}),A.push({dataType:"VARCHAR(250)",fieldName:"date_updated",defaultField:!0}),A.push({dataType:"BIGINT",fieldName:"date_updated_code",defaultField:!0}),A.push({dataType:"TIMESTAMP",fieldName:"date_updated_timestamp",defaultField:!0});let[k,D]=s.useState(!1),[R,I]=s.useState(!0),[O,P]=s.useState(w),[U,q]=s.useState(!1);s.useRef(null);let L=s.useRef([]),[H,B]=s.useState("/admin/".concat(null==f?void 0:f.id,"/databases/").concat(b.db_slug,"/tables/").concat(v.tableName,"/entries/").concat(O.id));s.useEffect(()=>{(null==S?void 0:S.dbUserId)&&Number(f.id)!==Number(S.dbUserId)&&B("/admin/".concat(null==f?void 0:f.id,"/databases/").concat(b.db_slug,"/tables/").concat(v.tableName,"/entries/").concat(O.id)+window.location.search)},[]);let z="".concat(b.db_slug,"-").concat(v.tableName,"-").concat(O.id,"-submit-button");return(0,a.jsxs)("div",{className:"card col w-full overflow-hidden",children:[(0,a.jsx)("a",{href:H,onClick:e=>{let t=e.target;(t.closest(".cancel-link")||t.closest(".MuiPopover-root"))&&e.preventDefault()},className:"w-full",children:(0,a.jsxs)("div",{className:"w-full bg-slate-700 text-white py-2 px-4 rounded justify-between flex-wrap hover:bg-slate-800 cursor-pointer relative z-[1000] ",onClick:e=>{let t=e.target;t.closest(".cancel-link")||t.closest(".MuiPopover-root")||(e.ctrlKey?window.open(H,"__blank"):window.location.href=H)},children:[(0,a.jsxs)("span",{children:["Entry #",O.id]}),(0,a.jsxs)("div",{className:"flex-wrap cancel-link",children:[(!C||C&&F)&&(0,a.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer"+(k?" pointer-events-none opacity-40":""),onClick:e=>{window.confirm("Delete Entry #".concat(O.id,"?"))&&(D(!0),(0,i.A)("/api/deleteTableEntry"+window.location.search,{method:"post",body:{dbFullName:b.db_full_name,tableName:v.tableName,entryId:O.id,dbSlug:b.db_slug,dbId:b.id,delegated:null==E?void 0:E.delegated,confirmedDelegetedUser:S}},!0).then(e=>{e.success?(0,d.A)().then(()=>{window.location.reload()}):(window.alert(e.msg),setTimeout(()=>{D(!1)},500))}))},children:"Delete Entry"}),!T&&(0,a.jsxs)(s.Fragment,{children:[(0,a.jsx)("span",{className:"opacity-20",children:"|"}),(0,a.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer",onClick:e=>{R?I(!1):I(!0)},children:R?(0,a.jsx)("span",{children:"Expand"}):(0,a.jsx)("span",{children:"Collapse"})})]}),(0,a.jsx)("span",{className:"opacity-20",children:"|"}),(0,a.jsx)("div",{className:"button ghost px-0",onClick:e=>{let t=m().cloneDeep(w);delete t.date_created,delete t.date_created_code,delete t.date_created_timestamp,delete t.date_updated,delete t.date_updated_code,delete t.date_updated_timestamp,delete t.id,delete t.uuid,localStorage.setItem("duplicate_entry",JSON.stringify(t)),window.location.href="/admin/".concat(null==f?void 0:f.id,"/databases/").concat(b.db_slug,"/tables/").concat(v.tableName,"/entries/add-entry?duplicate=true&id=").concat(w.id)},children:(0,a.jsx)("span",{className:"text-slate-300",children:"Duplicate"})}),(0,a.jsx)("span",{className:"opacity-20",children:"|"}),(0,a.jsx)(x,{table:v,user:f,entry:w,query:E,url:H})]})]})}),(0,a.jsxs)("form",{className:"w-full flex flex-col items-stretch gap-8 minimal-scrollbars relative",style:T?{}:{maxHeight:R?"300px":"none",paddingTop:"10px",paddingBottom:"10px",overflow:"hidden"},onSubmit:e=>{e.preventDefault(),D(!0);let t={},l=e.target;A.forEach(e=>{var a;if(!e.fieldName||!l[e.fieldName])return;let s="string"!=typeof l[e.fieldName].value,n="number"!=typeof l[e.fieldName].value;(s||n||l[e.fieldName].value)&&(null!==(a=l[e.fieldName])&&void 0!==a&&a.dataset.default||(t[e.fieldName]=l[e.fieldName].value))}),L.current[0]&&L.current.forEach(e=>{var l;(null==e?void 0:e.fieldName)&&(null==e?void 0:null===(l=e.ref)||void 0===l?void 0:l.current)&&(t[e.fieldName]=e.ref.current.getContent())}),N.current[0]&&N.current.forEach(e=>{var l;(null==e?void 0:e.fieldName)&&(null==e?void 0:null===(l=e.ref)||void 0===l?void 0:l.current)&&(t[e.fieldName]=e.ref.current.getValue())}),(0,i.A)("/api/updateTableEntry",{method:"post",body:{dbFullName:b.db_full_name,dbSlug:b.db_slug,dbId:b.id,tableName:v.tableName,entryId:O.id,payload:t,tableSchema:v,delegated:null==E?void 0:E.delegated,confirmedDelegetedUser:S}},!0).then(e=>{e.success?(0,i.A)("/api/refreshEntry?table=".concat(v.tableName,"&db=").concat(b.db_full_name,"&id=").concat(O.id,"&schema=").concat(JSON.stringify(v))).then(e=>{e.success&&(P(e.entry),setTimeout(()=>{D(!1)},500))}):(window.alert(e.msg+"\n"+(e.err||"")),setTimeout(()=>{D(!1)},500))})},onKeyUp:e=>{if(e.ctrlKey&&"Enter"==e.key){var t;window.confirm("Update this Form?")&&(null===(t=document.getElementById(z))||void 0===t||t.click())}},children:[k&&(0,a.jsx)(c.A,{}),(R&&!T?A.slice(0,3):A).map((e,t)=>{let l=y.filter(t=>{var l;return t.name===(null===(l=e.dataType)||void 0===l?void 0:l.replace(/\d|\(|\)/g,""))});return(0,a.jsx)(o.A,{fieldObject:e,dataTypeSchema:l[0],richTextEditors:j,currentRichTextEditorForms:L,entry:O,query:E,entryPage:T,confirmedDelegetedUser:S,jsonTextEditors:N,formButtonId:z},t+1)}),(0,a.jsx)("button",{type:"submit",className:k?" pointer-events-none opacity-40":"",id:z,children:"Update Entry"})]}),!T&&(0,a.jsx)(r.A,{collapse:R,setCollapse:I})]})}},60637:(e,t,l)=>{l.d(t,{A:()=>s});var a=l(74848);function s(e){let{radioValues:t,name:l,onChangeHandler:s,setAlert:n,flexRow:i,labelColor:d,baseText:r,smallText:c,className:o}=e;try{return(0,a.jsx)("div",{className:"flex items-start gap-4 flex-wrap "+(i?"":" flex-col ")+(o||""),children:t.map((e,t)=>{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"+(r?" w-5 h-5":c?" w-4 h-4":" w-6 h-6"),type:"radio",defaultChecked:!!e.default,name:l,id:l+"_"+m,onChange:t=>{n&&n(null),e.onChangeHandler?e.onChangeHandler(t):s&&s(t)},value:"string"==typeof m?m:void 0}),u||(0,a.jsx)("label",{htmlFor:l+"_"+m,className:"text-lg m-0 "+(d||"text-slate-800")+(r?" text-base":c?" text-sm":" text-lg"),children:o})]},t+1)})})}catch(e){return console.log("ERROR in FormRadio =>",e),(0,a.jsx)("div",{children:"Form Radio Error"})}}l(96540)},41301:(e,t,l)=>{l.d(t,{A:()=>n});var a=l(74848),s=l(62027);function n(e){let{selectOptions:t,name:l,onChangeHandler:n,required:i,setAlert:d,title:r,defaultValue:c,info:o,id:u}=e;try{function m(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),l=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!l.classList.contains("hidden")){l.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&l.classList.contains("hidden"))){if(!t){l.classList.add("hidden");return}if(l.classList.contains("hidden")){l.classList.remove("hidden");return}l.classList.add("hidden")}}return(0,a.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(o?" pr-8":""),children:[r&&(0,a.jsxs)("label",{htmlFor:l,children:[r,i?"":" (optional)"]}),(0,a.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,a.jsx)("select",{name:l,id:u||l,className:"w-full bg-white",required:i,onChange:e=>{d&&d(null),e.target.classList.remove("warning"),n&&n(e)},defaultValue:c||void 0,children:t.map((e,t)=>{let{payload:l,title:s}=e;return(0,a.jsx)("option",{value:l,selected:!!e.default,children:s},t+1)})}),(0,a.jsx)(s.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),o&&(0,a.jsxs)("div",{className:"info-wrapper absolute -right-10 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",style:{top:"50%",transform:"translate(0,-50%)"},onMouseEnter:m,onMouseLeave:m,onClick:m,children:[(0,a.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,a.jsx)("div",{className:"info-dropdown absolute top-9 right-0 bg-white w-52 md:w-96 p-2 sm:p-6 shadow-xl rounded hidden text-center border border-slate-300 border-solid",children:(0,a.jsx)("span",{children:o})}),(0,a.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,a.jsx)("div",{children:"Form Select Error"})}}l(96540)},31041:(e,t,l)=>{let a;l.r(t),l.d(t,{TableEntriesContext:()=>w,__N_SSP:()=>y,default:()=>T});var s=l(74848),n=l(96540),i=l(51187),d=l(99862),r=l(4709),c=l(77121),o=l(55098),u=l(12378),m=l(98070),p=l(36836),h=l(620),f=l(23698);l(2543);var x=l(76919),b=l(93644);function v(e){var t,a,i;let{user:h,database:f,table:v,dbSchemaData:j,setTargetEntry:N,richTextEditors:y,jsonTextEditors:T,query:S,confirmedDelegetedUser:E,activeEntries:A,entriesCount:_,setActiveEntries:C}=n.useContext(w),F=l(94327);return null==E||E.delegated,null==E||null===(t=E.priviledges)||void 0===t||t.match(/Edit Tables/i),null==E||null===(a=E.priviledges)||void 0===a||a.match(/Delete Tables/i),null==E||null===(i=E.priviledges)||void 0===i||i.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)(d.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:[v.tableFullName,(0,s.jsx)("div",{className:"absolute -top-5 -right-4",children:(0,s.jsx)(c.A,{slugText:v.tableName,justIcon:!0})})]})," ","Table"]})})]}),(0,s.jsxs)("div",{className:"w-full sm:w-auto",children:[(0,s.jsxs)("a",{href:"/admin/".concat(null==h?void 0:h.id,"/databases/").concat(f.db_slug,"/tables/").concat(v.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)(x.A,{database:f,table:v}),(0,s.jsx)(b.A,{database:f,table:v,dbSchemaData:j,query:S})]})]}),(0,s.jsx)(r.A,{confirmedDelegetedUser:null==S?void 0:S.delegated,user:h})]}),f.active_clone?(0,s.jsx)(u.A,{database:f,user:h}):(0,s.jsx)(s.Fragment,{}),f.remote_connected?(0,s.jsx)(p.p,{database:f}):(0,s.jsx)(s.Fragment,{}),(0,s.jsx)(m.A,{table:v,database:f,user:h}),(0,s.jsx)(o.A,{user:h,entries:A,database:f,table:v,setTargetEntry:N,dbSchemaData:j,richTextEditors:y,dataTypes:F,query:S,confirmedDelegetedUser:E,jsonTextEditors:T,search:!0}),_>20&&(0,s.jsx)(g,{activeEntries:A,setActiveEntries:C,database:f,table:v,entriesCount:_})]})}function g(e){let{activeEntries:t,setActiveEntries:l,database:i,table:d,entriesCount:r}=e,c=n.useContext(w),o=n.useRef(),u=n.useRef(1),m=20*Number(u.current);return(n.useEffect(()=>{function e(e,t){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"),t=document.getElementById("entries-search-field-select"),s={tableName:d.tableName,dbName:i.db_slug,page:u.current,tableSchema:d,search:e?e.value:void 0,searchField:t?t.value:void 0,delegated:!!c.query.delegated};(0,f.A)("/api/infiniteScroll",{method:"POST",body:s},!0).then(e=>{e.success&&(e.page&&(u.current=e.page),window.clearTimeout(a),a=setTimeout(()=>{var t,a;(null===(t=e.data)||void 0===t?void 0:t[0])&&(null===(a=e.data)||void 0===a?void 0:a[0])&&l(t=>t?[...t,...e.data]:null)},500))}).catch(e=>{console.log("Infinite Scroll Error =>",e)}).finally(()=>{console.log("Infinite Scroll Done. Page",u.current)})}}let t={rootMargin:"0px 0px 0px 0px"};setTimeout(()=>{requestAnimationFrame(()=>{let l=new IntersectionObserver(e,t);o.current&&l.observe(o.current)})},1e3)},[]),m>=r)?(0,s.jsx)(n.Fragment,{}):(0,s.jsx)("div",{className:"w-full flex items-center justify-center",ref:o,children:(0,s.jsx)(h.A,{position:"relative",style:{backgroundColor:"transparent"},width:"20px"})})}var j=l(85897),N=l(55107),y=!0;let w=n.createContext({});function T(e){let{user:t,database:l,table:a,dbSchemaData:d,entries:r,query:c,confirmedDelegetedUser:o,entriesCount:u}=e,m="".concat(a.tableFullName," Table Entries | Datasquirel"),p=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("title",{children:m}),(0,s.jsx)("meta",{name:"description",content:"All Entries in table"})]}),[h,f]=n.useState(null),[x,b]=n.useState(r),g=n.useRef("title"),y=n.useRef(null),T=n.useRef([]),S=n.useRef([]);return(0,s.jsx)(i.A,{head:p,user:t,extraHeaderContent:(0,s.jsx)(j.A,{database:l,query:c,confirmedDelegetedUser:o,user:t}),children:(0,s.jsxs)(w.Provider,{value:{user:t,database:l,table:a,dbSchemaData:d,entries:r,targetEntry:h,setTargetEntry:f,richTextEditors:T,jsonTextEditors:S,query:c,confirmedDelegetedUser:o,activeEntries:x,setActiveEntries:b,targetField:g,searchTerm:y,entriesCount:u},children:[(0,s.jsx)(v,{}),(0,s.jsx)(N.A,{snug:!0})]})})}}}]);