dsql-admin/dsql-app/.local_dist/static/chunks/6460-1a5ce626ace242bf.js
Benjamin Toby a7dfd48284 Updates
2024-12-09 10:39:09 +01:00

1 line
27 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6460],{6919:(e,t,l)=>{l.d(t,{A:()=>c});var a=l(4848),s=l(6540),n=l(620),i=l(5896),d=l(3698);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})]})}},1627:(e,t,l)=>{l.d(t,{A:()=>x});var a=l(4848),s=l(6540),n=l(5143),i=l(3238),d=l(637),r=l(1301),c=l(620),o=l(4500),u=l(3698),m=l(2543),h=l.n(m);function p(e){let{database:t,table:l,setOpenPopover:n,dbSchemaData:i,query:d}=e,[r,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:r,setOpen:c,children:(0,a.jsx)(f,{database:t,table:l,dbSchemaData:i,query:d})})]})}function f(e){let{database:t,table:l,query:n,dbSchemaData:i}=e,[o,m]=s.useState(i),[p,f]=s.useState("Push"),[x,b]=s.useState(null==o?void 0:o[0]),[v,g]=s.useState(null==x?void 0:x.tables),[j,N]=s.useState(null==v?void 0:v[0]),[y,w]=s.useState(!1),[T,S]=s.useState(!1);return s.useEffect(()=>{h().isEqual(null==l?void 0:l.fields,null==j?void 0:j.fields)?S(!0):S(!1)},[j,b]),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:[y||!o&&(0,a.jsx)(c.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})]}),o&&(0,a.jsxs)("form",{onSubmit:e=>{!function(e){var t,l,a;let{e:s,setLoading:n,database:i,table:d,query:r}=e;s.preventDefault(),n(!0);let c=s.target,o=null===(t=c.paradigm)||void 0===t?void 0:t.value,m=null===(l=c.database)||void 0===l?void 0:l.value,h=null===(a=c.table)||void 0===a?void 0:a.value,p={paradigm:o,src:{db:i.db_slug,table:d.tableName},dst:{db:m,table:h},delegated:r.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:{...p}},!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:n})},className:"w-full stack gap-2 items-stretch",children:[(0,a.jsxs)("div",{className:"stack gap-2 my-2",children:[(0,a.jsx)(d.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"==p?(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)(r.A,{selectOptions:o.filter(e=>e.dbFullName!==t.db_full_name).map(e=>({title:e.dbName,payload:e.dbSlug})),name:"database",onChangeHandler:e=>{let t=o.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)(r.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"})]})]})}function x(e){let{database:t,table:l,dbSchemaData:d,query:r}=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)(p,{database:t,table:l,setOpenPopover:o,dbSchemaData:d,query:r}),(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,{})})})}},5098:(e,t,l)=>{let a;l.d(t,{A:()=>x});var s=l(4848),n=l(6540),i=l(7111),d=l(1041),r=l(1301),c=l(5414),o=l(3698),u=l(620);function m(e){var t,i,m,h;let{data:p}=e,{table:f,entries:x,activeEntries:b,setActiveEntries:v,confirmedDelegetedUser:g,database:j,targetField:N,searchTerm:y}=n.useContext(d.TableEntriesContext);l(4327),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===(h=y.current)||void 0===h?void 0:h.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 h=l(6919),p=l(1627),f=l(2276);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)(p.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)(f.A,{}),(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"})]})]})]})})}},7111:(e,t,l)=>{l.d(t,{A:()=>b});var a=l(4848),s=l(6540),n=l(8825),i=l(3698),d=l(7531),r=l(6604),c=l(620),o=l(8214),u=l(2543),m=l.n(u),h=l(1263),p=l(3238),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,h.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,h.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)(p.A,{})})})})}function b(e){var t,l,u,h,p;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===(h=S.priviledges)||void 0===h||h.match(/Edit Entries/i);let F=null==S?void 0:null===(p=S.priviledges)||void 0===p?void 0:p.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 M="".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(M))||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:M},t+1)}),(0,a.jsx)("button",{type:"submit",className:k?" pointer-events-none opacity-40":"",id:M,children:"Update Entry"})]}),!T&&(0,a.jsx)(r.A,{collapse:R,setCollapse:I})]})}},637:(e,t,l)=>{l.d(t,{A:()=>s});var a=l(4848);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(6540)},1301:(e,t,l)=>{l.d(t,{A:()=>n});var a=l(4848),s=l(2027);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(6540)},1041:(e,t,l)=>{let a;l.r(t),l.d(t,{TableEntriesContext:()=>w,__N_SSP:()=>y,default:()=>T});var s=l(4848),n=l(6540),i=l(1187),d=l(9862),r=l(4709),c=l(7121),o=l(5098),u=l(2378),m=l(8070),h=l(6836),p=l(620),f=l(3698);l(2543);var x=l(6919),b=l(1627);function v(e){var t,a,i;let{user:p,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(4327);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==p?void 0:p.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:p})]}),f.active_clone?(0,s.jsx)(u.A,{database:f,user:p}):(0,s.jsx)(s.Fragment,{}),f.remote_connected?(0,s.jsx)(h.p,{database:f}):(0,s.jsx)(s.Fragment,{}),(0,s.jsx)(m.A,{table:v,database:f,user:p}),(0,s.jsx)(o.A,{user:p,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)(p.A,{position:"relative",style:{backgroundColor:"transparent"},width:"20px"})})}var j=l(5897),N=l(5107),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"),h=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("title",{children:m}),(0,s.jsx)("meta",{name:"description",content:"All Entries in table"})]}),[p,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:h,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:p,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})]})})}}}]);