dsql-admin/dsql-app/.local_dist/static/chunks/9035-b11038b244e852f0.js
2024-11-05 12:12:42 +01:00

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-databases").then((function(e){e.success&&e.payload&&p(e.payload)}))}),[]),(0,l.jsxs)("div",{className:"stack gap-2 relative w-full",children:[D||!h&&(0,l.jsx)(r.Z,{width:"20px"}),(0,l.jsx)("h3",{className:"m-0 text-lg",children:"Sync Data with another table"}),q?(0,l.jsxs)("span",{className:"info green inline",children:["The selected table matches ",(0,l.jsx)("b",{children:a.tableFullName})," ","schema"]}):(0,l.jsxs)("span",{className:"info warning inline",children:["The selected table is not compatible with"," ",(0,l.jsx)("b",{children:a.tableFullName})]}),h&&(0,l.jsxs)("form",{onSubmit:function(e){!function(e){var t,a,n,l=e.e,i=e.setLoading,s=e.database,r=e.table,d=e.query;l.preventDefault(),i(!0);var u=l.target,m=null===(t=u.paradigm)||void 0===t?void 0:t.value,f=null===(a=u.database)||void 0===a?void 0:a.value,v=null===(n=u.table)||void 0===n?void 0:n.value,h={paradigm:m,src:{db:s.db_slug,table:r.tableName},dst:{db:f,table:v},delegated:d.delegated},p="Pull"==m?"NOTE: This operation will override the current database entries. Continue?":"NOTE: This operation will override the selected database entries. Continue?";window.confirm(p)?(0,o.Z)("/api/sync-table-data",{method:"POST",body:(0,c.Z)({},h)},!0).then((function(e){e.success?(window.alert("Data Sync Successful"),window.location.reload()):e.msg&&window.alert("ERROR: "+e.msg)})).finally((function(){setTimeout((function(){i(!1)}),1e3)})):setTimeout((function(){i(!1)}),1e3)}({e:e,database:t,setLoading:F,table:a,query:d})},className:"w-full stack gap-2 items-stretch",children:[(0,l.jsxs)("div",{className:"stack gap-2 my-2",children:[(0,l.jsx)(i.Z,{radioValues:[{title:"Push",payload:"Push",default:!0},{title:"Pull",payload:"Pull"}],name:"paradigm",smallText:!0,flexRow:!0,onChangeHandler:function(e){g(e.target.value)}}),(0,l.jsx)("span",{className:"text-xs text-slate-500 dark:text-slate-400",children:"Push"==x?(0,l.jsxs)(l.Fragment,{children:["Sync data from the current table(",(0,l.jsx)("b",{children:a.tableFullName}),") to the selected table below"]}):(0,l.jsxs)(l.Fragment,{children:["Sync data from the selected table below to the current table(",(0,l.jsx)("b",{children:a.tableFullName}),")"]})})]}),(0,l.jsx)(s.Z,{selectOptions:h.filter((function(e){return e.dbFullName!==t.db_full_name})).map((function(e){return{title:e.dbName,payload:e.dbSlug}})),name:"database",onChangeHandler:function(e){var t,a=h.find((function(t){return t.dbSlug==e.target.value}));a&&(N(a),E(a.tables),_(null===(t=a.tables)||void 0===t?void 0:t[0]))}}),(0,l.jsx)(s.Z,{selectOptions:T.map((function(e){return{title:e.tableFullName,payload:e.tableName}})),name:"table",onChangeHandler:function(e){var t=T.find((function(t){return t.tableName===e.target.value}));t&&_(t)}}),(0,l.jsx)("button",{className:q?"":"disabled",children:"Sync"})]})]})}},6122:function(e,t,a){a.d(t,{Z:function(){return b}});var n,l=a(85893),i=a(67294),s=a(51985),r=a(828),d=a(37722),o=a(44114),c=a(27901),u=a(86729),m=a(95264);function f(e){e.data;var t,s,f,v,h=function(e){if(Z(!0),g&&j(null),null===e||void 0===e?void 0:e.toString().match(/./)){window.clearTimeout(n);var t=null===b||void 0===b?void 0:b.fields.filter((function(e){return e.fieldName===(null===w||void 0===w?void 0:w.current)})),a=function(){var e,a;if(t&&t[0]&&(null===(a=t[0].dataType)||void 0===a?void 0:a.match(/int/i)))return"equal";return(null===w||void 0===w||null===(e=w.current)||void 0===e?void 0:e.match(/^id$/))?"equal":"like"}();n=setTimeout((function(){Z(!1),(0,u.Z)("/api/queryEntriesSearchTerm?db=".concat(null===N||void 0===N?void 0:N.db_full_name,"&table=").concat(null===b||void 0===b?void 0:b.tableName,"&field=").concat(null===w||void 0===w?void 0:w.current,"&term=").concat(e,"&operator=").concat(a)).then((function(e){"number"==typeof e.count&&F(e.count),e.success&&j&&j(e.result),Z(!1)}))}),500)}else setTimeout((function(){j&&j(x||[]),Z(!1)}),500)},p=i.useContext(d.TableEntriesContext),b=p.table,x=p.entries,g=p.activeEntries,j=p.setActiveEntries,y=p.confirmedDelegetedUser,N=p.database,w=p.targetField,T=p.searchTerm,E=(a(89594),null===y||void 0===y||y.delegated,null===y||void 0===y||null===(t=y.priviledges)||void 0===t||t.match(/Edit Tables/i),null===y||void 0===y||null===(s=y.priviledges)||void 0===s||s.match(/Delete Tables/i),null===y||void 0===y||null===(f=y.priviledges)||void 0===f||f.match(/Create Tables/i),(0,r.Z)(i.useState(!1),2)),S=E[0],Z=E[1],_=i.useRef();i.useEffect((function(){_.current&&_.current.focus()}),[]);var C=(0,r.Z)(i.useState(null),2),D=C[0],F=C[1];return(0,l.jsxs)("div",{className:"w-full flex-col items-stretch",children:[(0,l.jsxs)("form",{onSubmit:function(e){e.preventDefault(),(null===T||void 0===T?void 0:T.current)&&h(T.current)},className:"flex flex-row items-stretch gap-4 w-full",children:[(0,l.jsx)("div",{className:"max-w-xs",children:(0,l.jsx)(o.Z,{required:!0,selectOptions:b?b.fields.map((function(e){return{title:e.fieldName||"",payload:e.fieldName||""}})):[],name:"database_tables",onChangeHandler:function(e){w&&(w.current=e.target.value)},title:"Select Field",defaultValue:null===w||void 0===w?void 0:w.current,id:"entries-search-field-select"})}),(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(c.Z,{title:"Search Term",placeholder:"Enter search term that corresponds with the selected field type ...",onInputHandler:function(e){var t,a=e.target;(null===(t=a.value)||void 0===t?void 0:t.match(/./))&&T?T.current=a.value:T&&(T.current=null),h(a.value)},elementRef:_,id:"entries-search-input"})}),S&&(0,l.jsx)("div",{className:"relative items-center justify-center",children:(0,l.jsx)("div",{className:"relative mt-5 w-6",children:(0,l.jsx)(m.Z,{width:"20px"})})})]}),(null===T||void 0===T||null===(v=T.current)||void 0===v?void 0:v.match(/./))&&(0,l.jsx)("div",{className:"py-4",children:(0,l.jsxs)("span",{className:"text-lg",children:["number"==typeof D?D>0?(0,l.jsxs)("b",{children:[D," "]}):(0,l.jsx)(l.Fragment,{children:"No "}):"... ","Search result",D&&1!==D?"s":""," for"," ",(0,l.jsxs)("b",{children:['"',T.current,'"']})]})})]})}var v=a(30073),h=a(82943),p=a(13684);a(40436);function b(e){var t,a,n,r,d,o=e.user,c=e.entries,u=e.database,b=e.table,x=(e.setTargetEntry,e.dbSchemaData),g=e.richTextEditors,j=e.jsonTextEditors,y=e.dataTypes,N=e.title,w=e.confirmedDelegetedUser,T=e.query,E=e.search,S=e.entriesCount;null===w||void 0===w||w.delegated,null===w||void 0===w||null===(t=w.priviledges)||void 0===t||t.match(/Edit Tables/i),null===w||void 0===w||null===(a=w.priviledges)||void 0===a||a.match(/Delete Tables/i),null===w||void 0===w||null===(n=w.priviledges)||void 0===n||n.match(/Create Tables/i),null===w||void 0===w||null===(r=w.priviledges)||void 0===r||r.match(/Edit Entries/i),null===w||void 0===w||null===(d=w.priviledges)||void 0===d||d.match(/Delete Entries/i),u.active_clone,u.active_clone_parent_db,u.remote_connected;return(0,l.jsx)(i.Fragment,{children:(0,l.jsxs)("section",{className:"paper gray gray-bg",children:[N&&(0,l.jsxs)("div",{className:"justify-between w-full flex-wrap px-4 sm:px-0 pt-4 sm:pt-0",children:[(0,l.jsx)("h2",{className:"text-xl m-0",children:N}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("a",{className:"button flex gap-2 items-center",href:"/admin/".concat(null===o||void 0===o?void 0:o.id,"/databases/").concat(u.db_slug,"/tables/").concat(b.tableName,"/entries/add-entry"),children:[(0,l.jsx)("span",{className:"symbol",children:"+"}),(0,l.jsx)("span",{children:"Add New Entry"})]}),(0,l.jsx)(h.Z,{database:u,table:b}),(0,l.jsx)(p.Z,{database:u,table:b,dbSchemaData:x,query:T})]})]}),E&&(0,l.jsx)(f,{}),(0,l.jsxs)("div",{className:"w-full flex-col gap-6",children:[(null===c||void 0===c?void 0:c[0])&&c.map((function(e){return(0,l.jsx)(i.Fragment,{children:(0,l.jsx)(s.Z,{user:o,database:u,table:b,dbSchemaData:x,richTextEditors:g,dataTypes:y,entry:e,query:T,confirmedDelegetedUser:w,jsonTextEditors:j})},e.id)})),!c&&(0,l.jsx)("div",{className:"w-full h-[300px]",children:(0,l.jsx)(m.Z,{position:"relative"})}),c&&!(null===c||void 0===c?void 0:c[0])&&(0,l.jsxs)("a",{href:"/admin/".concat(null===o||void 0===o?void 0:o.id,"/databases/").concat(u.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,l.jsx)("span",{className:"text-slate-400 text-center",children:"No Entries Added Yet."}),(0,l.jsx)(v.Z,{className:"opacity-20 my-4",sx:{fontSize:80}}),(0,l.jsx)("span",{className:"text-center",children:"Add an Entry to this Table"})]}),S&&S>10?(0,l.jsx)("a",{href:"/admin/".concat(null===o||void 0===o?void 0:o.id,"/databases/").concat(u.db_slug,"/tables/").concat(b.tableName,"/entries"),className:"button outlined gray w-full -mb-4",children:(0,l.jsx)("span",{children:"See All Entries"})}):null,(null===c||void 0===c?void 0:c[0])&&N&&(0,l.jsxs)("a",{className:"button flex gap-2 items-center w-full justify-center mt-2 more-padding",href:"/admin/".concat(null===o||void 0===o?void 0:o.id,"/databases/").concat(u.db_slug,"/tables/").concat(b.tableName,"/entries/add-entry"),style:{borderStyle:"dotted",borderWidth:"2px"},children:[(0,l.jsx)("span",{className:"symbol",children:"+"}),(0,l.jsx)("span",{children:"Add New Entry"})]})]})]})})}},51985:function(e,t,a){a.d(t,{Z:function(){return x}});var n=a(828),l=a(85893),i=a(67294),s=a(33907),r=a(86729),d=a(81069),o=a(36169),c=a(95264),u=a(54559),m=a(96486),f=a.n(m),v=a(95753),h=a(9404),p=a(82106);function b(e){var t=e.user,a=e.table,s=e.entry,r=e.url,d=e.query,o=(0,n.Z)(i.useState(!1),2),c=o[0],u=o[1],m=i.useRef(null);return(0,l.jsx)("div",{className:"relative z-[1000]",children:(0,l.jsx)(p.Popover,{isOpen:c,onClickOutside:function(){return u(!1)},containerClassName:"z-[1000]",positions:["bottom"],align:"end",content:(0,l.jsx)("div",{className:"bg-white dark:bg-slate-900 rounded shadow-md cancel-link",children:(0,l.jsxs)("div",{className:"flex-col min-w-[200px] items-stretch gap-0",children:[(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:function(){navigator.clipboard.writeText(JSON.stringify(s)).then((function(){window.alert("Post Copied"),u(!1)}))},children:"Copy Object"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:function(){var e=(0,v.Z)({paradigm:"JavaScript",table:a,query:d,user:t});navigator.clipboard.writeText(e||"").then((function(){window.alert("JavaScript Type Definition Copied"),u(!1)}))},children:"Copy JS Type Definition"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:function(){var e=(0,v.Z)({paradigm:"TypeScript",table:a,query:d,user:t});navigator.clipboard.writeText(e||"").then((function(){window.alert("TypeScript Type Definition Copied"),u(!1)}))},children:"Copy TS Type Definition"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("a",{href:r,className:"button plain-text justify-start py-3",children:(0,l.jsx)("span",{children:"View Entry"})})]})}),children:(0,l.jsx)("button",{onClick:function(){u(!c)},ref:m,className:"ghost p-2",children:(0,l.jsx)(h.Z,{})})})})}function x(e){var t,a,m,v,h,p=e.user,x=e.database,g=e.table,j=(e.dbSchemaData,e.richTextEditors),y=e.jsonTextEditors,N=e.dataTypes,w=e.entry,T=e.entryPage,E=e.confirmedDelegetedUser,S=e.query,Z=g.fields.filter((function(e){return e.fieldName&&!e.fieldName.match(s.Z)})),_=g.fields.find((function(e){return"uuid"===e.fieldName})),C=null===E||void 0===E?void 0:E.delegated,D=(null===E||void 0===E||null===(t=E.priviledges)||void 0===t||t.match(/Edit Tables/i),null===E||void 0===E||null===(a=E.priviledges)||void 0===a||a.match(/Delete Tables/i),null===E||void 0===E||null===(m=E.priviledges)||void 0===m||m.match(/Create Tables/i),null===E||void 0===E||null===(v=E.priviledges)||void 0===v||v.match(/Edit Entries/i),null===E||void 0===E||null===(h=E.priviledges)||void 0===h?void 0:h.match(/Delete Entries/i));_&&Z.unshift({dataType:"UUID",fieldName:"uuid",defaultField:!0}),Z.unshift({dataType:"BIGINT",fieldName:"id",defaultField:!0}),Z.push({dataType:"VARCHAR(250)",fieldName:"date_created",defaultField:!0}),Z.push({dataType:"BIGINT",fieldName:"date_created_code",defaultField:!0}),Z.push({dataType:"TIMESTAMP",fieldName:"date_created_timestamp",defaultField:!0}),Z.push({dataType:"VARCHAR(250)",fieldName:"date_updated",defaultField:!0}),Z.push({dataType:"BIGINT",fieldName:"date_updated_code",defaultField:!0}),Z.push({dataType:"TIMESTAMP",fieldName:"date_updated_timestamp",defaultField:!0});var F=(0,n.Z)(i.useState(!1),2),k=F[0],q=F[1],R=(0,n.Z)(i.useState(!0),2),I=R[0],O=R[1],P=(0,n.Z)(i.useState(w),2),U=P[0],A=P[1],L=(0,n.Z)(i.useState(!1),2),H=(L[0],L[1],i.useRef(null),i.useRef([])),B=(0,n.Z)(i.useState("/admin/".concat(null===p||void 0===p?void 0:p.id,"/databases/").concat(x.db_slug,"/tables/").concat(g.tableName,"/entries/").concat(U.id)),2),z=B[0],M=B[1];i.useEffect((function(){(null===E||void 0===E?void 0:E.dbUserId)&&Number(p.id)!==Number(E.dbUserId)&&M("/admin/".concat(null===p||void 0===p?void 0:p.id,"/databases/").concat(x.db_slug,"/tables/").concat(g.tableName,"/entries/").concat(U.id)+window.location.search)}),[]);var V="".concat(x.db_slug,"-").concat(g.tableName,"-").concat(U.id,"-submit-button");return(0,l.jsxs)("div",{className:"card col w-full overflow-hidden",children:[(0,l.jsx)("a",{href:z,onClick:function(e){var t=e.target;(t.closest(".cancel-link")||t.closest(".MuiPopover-root"))&&e.preventDefault()},className:"w-full",children:(0,l.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:function(e){var t=e.target;t.closest(".cancel-link")||t.closest(".MuiPopover-root")||(e.ctrlKey?window.open(z,"__blank"):window.location.href=z)},children:[(0,l.jsxs)("span",{children:["Entry #",U.id]}),(0,l.jsxs)("div",{className:"flex-wrap cancel-link",children:[(!C||C&&D)&&(0,l.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer"+(k?" pointer-events-none opacity-40":""),onClick:function(e){window.confirm("Delete Entry #".concat(U.id,"?"))&&(q(!0),(0,r.Z)("/api/deleteTableEntry"+window.location.search,{method:"post",body:{dbFullName:x.db_full_name,tableName:g.tableName,entryId:U.id,dbSlug:x.db_slug,dbId:x.id,delegated:null===S||void 0===S?void 0:S.delegated,confirmedDelegetedUser:E}},!0).then((function(e){e.success?(0,d.Z)().then((function(){window.location.reload()})):(window.alert(e.msg),setTimeout((function(){q(!1)}),500))})))},children:"Delete Entry"}),!T&&(0,l.jsxs)(i.Fragment,{children:[(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer",onClick:function(e){O(!I)},children:I?(0,l.jsx)("span",{children:"Expand"}):(0,l.jsx)("span",{children:"Collapse"})})]}),(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)("div",{className:"button ghost px-0",onClick:function(e){var t=f().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===p||void 0===p?void 0:p.id,"/databases/").concat(x.db_slug,"/tables/").concat(g.tableName,"/entries/add-entry?duplicate=true&id=").concat(w.id)},children:(0,l.jsx)("span",{className:"text-slate-300",children:"Duplicate"})}),(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)(b,{table:g,user:p,entry:w,query:S,url:z})]})]})}),(0,l.jsxs)("form",{className:"w-full flex flex-col items-stretch gap-8 minimal-scrollbars relative",style:T?{}:{maxHeight:I?"300px":"none",paddingTop:"10px",paddingBottom:"10px",overflow:"hidden"},onSubmit:function(e){e.preventDefault(),q(!0);var t={},a=e.target;Z.forEach((function(e){var n;if(e.fieldName&&a[e.fieldName]){var l="string"!==typeof a[e.fieldName].value,i="number"!==typeof a[e.fieldName].value;(l||i||a[e.fieldName].value)&&((null===(n=a[e.fieldName])||void 0===n?void 0:n.dataset.default)||(t[e.fieldName]=a[e.fieldName].value))}})),H.current[0]&&H.current.forEach((function(e){var a;(null===e||void 0===e?void 0:e.fieldName)&&(null===e||void 0===e||null===(a=e.ref)||void 0===a?void 0:a.current)&&(t[e.fieldName]=e.ref.current.getContent())})),y.current[0]&&y.current.forEach((function(e){var a;(null===e||void 0===e?void 0:e.fieldName)&&(null===e||void 0===e||null===(a=e.ref)||void 0===a?void 0:a.current)&&(t[e.fieldName]=e.ref.current.getValue())})),(0,r.Z)("/api/updateTableEntry",{method:"post",body:{dbFullName:x.db_full_name,dbSlug:x.db_slug,dbId:x.id,tableName:g.tableName,entryId:U.id,payload:t,tableSchema:g,delegated:null===S||void 0===S?void 0:S.delegated,confirmedDelegetedUser:E}},!0).then((function(e){e.success?(0,r.Z)("/api/refreshEntry?table=".concat(g.tableName,"&db=").concat(x.db_full_name,"&id=").concat(U.id,"&schema=").concat(JSON.stringify(g))).then((function(e){e.success&&(A(e.entry),setTimeout((function(){q(!1)}),500))})):(window.alert(e.msg+"\n"+(e.err||"")),setTimeout((function(){q(!1)}),500))}))},onKeyUp:function(e){if(e.ctrlKey&&"Enter"==e.key){var t;if(!window.confirm("Update this Form?"))return;null===(t=document.getElementById(V))||void 0===t||t.click()}},children:[k&&(0,l.jsx)(c.Z,{}),(I&&!T?Z.slice(0,3):Z).map((function(e,t){var a=N.filter((function(t){var a;return t.name===(null===(a=e.dataType)||void 0===a?void 0:a.replace(/\d|\(|\)/g,""))}));return(0,l.jsx)(u.Z,{fieldObject:e,dataTypeSchema:a[0],richTextEditors:j,currentRichTextEditorForms:H,entry:U,query:S,entryPage:T,confirmedDelegetedUser:E,jsonTextEditors:y,formButtonId:V},t+1)})),(0,l.jsx)("button",{type:"submit",className:k?" pointer-events-none opacity-40":"",id:V,children:"Update Entry"})]}),!T&&(0,l.jsx)(o.Z,{collapse:I,setCollapse:O})]})}},22348:function(e,t,a){a.d(t,{Z:function(){return l}});var n=a(85893);a(67294);function l(e){var t=e.radioValues,a=e.name,l=e.onChangeHandler,i=e.setAlert,s=e.flexRow,r=e.labelColor,d=e.baseText,o=e.smallText,c=e.className;try{return(0,n.jsx)("div",{className:"flex items-start gap-4 flex-wrap "+(s?"":" flex-col ")+(c||""),children:t.map((function(e,t){var s=e.payload,c=e.title,u=e.jsx,m=!1===s?s:s||(c||null);return(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{className:"m-0"+(d?" w-5 h-5":o?" w-4 h-4":" w-6 h-6"),type:"radio",defaultChecked:!!e.default,name:a,id:a+"_"+m,onChange:function(t){i&&i(null),e.onChangeHandler?e.onChangeHandler(t):l&&l(t)},value:"string"==typeof m?m:void 0}),u||(0,n.jsx)("label",{htmlFor:a+"_"+m,className:"text-lg m-0 "+(r||"text-slate-800")+(d?" text-base":o?" text-sm":" text-lg"),children:c})]},t+1)}))})}catch(u){return console.log("ERROR in FormRadio =>",u),(0,n.jsx)("div",{children:"Form Radio Error"})}}},44114:function(e,t,a){a.d(t,{Z:function(){return i}});var n=a(85893),l=a(8971);a(67294);function i(e){var t=e.selectOptions,a=e.name,i=e.onChangeHandler,s=e.required,r=e.setAlert,d=e.title,o=e.defaultValue,c=e.info,u=e.id;try{var m=function(e){if(!(e.type.match(/enter/i)&&window.innerWidth<1200)){var t=e.target.closest(".info-wrapper"),a=t.querySelector(".info-dropdown");!e.type.match(/leave/i)||a.classList.contains("hidden")?e.type.match(/leave/i)&&a.classList.contains("hidden")||(t&&a.classList.contains("hidden")?a.classList.remove("hidden"):a.classList.add("hidden")):a.classList.add("hidden")}};return(0,n.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(c?" pr-8":""),children:[d&&(0,n.jsxs)("label",{htmlFor:a,children:[d,s?"":" (optional)"]}),(0,n.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,n.jsx)("select",{name:a,id:u||a,className:"w-full bg-white",required:s,onChange:function(e){r&&r(null),e.target.classList.remove("warning"),i&&i(e)},defaultValue:o||void 0,children:t.map((function(e,t){var a=e.payload,l=e.title;return(0,n.jsx)("option",{value:a,selected:!!e.default,children:l},t+1)}))}),(0,n.jsx)(l.Z,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),c&&(0,n.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,n.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,n.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,n.jsx)("span",{children:c})}),(0,n.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(f){return console.log("ERROR in FormSelect =>",f),(0,n.jsx)("div",{children:"Form Select Error"})}}},37722:function(e,t,a){a.r(t),a.d(t,{TableEntriesContext:function(){return S},__N_SSP:function(){return E},default:function(){return Z}});var n,l=a(828),i=a(85893),s=a(67294),r=a(54858),d=a(29815),o=a(61781),c=a(424),u=a(79230),m=a(6122),f=a(94986),v=a(88515),h=a(58264),p=a(95264),b=a(86729),x=(a(96486),a(82943)),g=a(13684);function j(e){var t,n,l,r=s.useContext(S),d=r.user,p=r.database,b=r.table,j=r.dbSchemaData,N=r.setTargetEntry,w=r.richTextEditors,T=r.jsonTextEditors,E=r.query,Z=r.confirmedDelegetedUser,_=r.activeEntries,C=r.entriesCount,D=r.setActiveEntries,F=a(89594);null===Z||void 0===Z||Z.delegated,null===Z||void 0===Z||null===(t=Z.priviledges)||void 0===t||t.match(/Edit Tables/i),null===Z||void 0===Z||null===(n=Z.priviledges)||void 0===n||n.match(/Delete Tables/i),null===Z||void 0===Z||null===(l=Z.priviledges)||void 0===l||l.match(/Create Tables/i);return(0,i.jsxs)(s.Fragment,{children:[(0,i.jsxs)("div",{className:"flex-col items-start gap-0 w-full relative z-50",children:[(0,i.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,i.jsxs)("div",{className:"flex-wrap",children:[(0,i.jsx)(o.Z,{}),(0,i.jsx)("h1",{className:"text-3xl m-0",children:(0,i.jsxs)("span",{className:"flex items-center flex-wrap gap-2",children:["All Entries In"," ",(0,i.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:[b.tableFullName,(0,i.jsx)("div",{className:"absolute -top-5 -right-4",children:(0,i.jsx)(u.Z,{slugText:b.tableName,justIcon:!0})})]})," ","Table"]})})]}),(0,i.jsxs)("div",{className:"w-full sm:w-auto",children:[(0,i.jsxs)("a",{href:"/admin/".concat(null===d||void 0===d?void 0:d.id,"/databases/").concat(p.db_slug,"/tables/").concat(b.tableName,"/entries/add-entry"),className:"button flex items-center gap-2 w-full sm:w-auto justify-center",children:[(0,i.jsx)("span",{className:"symbol",children:"+"}),(0,i.jsx)("span",{children:"Add New Entry"})]}),(0,i.jsx)(x.Z,{database:p,table:b}),(0,i.jsx)(g.Z,{database:p,table:b,dbSchemaData:j,query:E})]})]}),(0,i.jsx)(c.Z,{confirmedDelegetedUser:null===E||void 0===E?void 0:E.delegated,user:d})]}),p.active_clone?(0,i.jsx)(f.Z,{database:p,user:d}):(0,i.jsx)(i.Fragment,{}),p.remote_connected?(0,i.jsx)(h.w,{database:p}):(0,i.jsx)(i.Fragment,{}),(0,i.jsx)(v.Z,{table:b,database:p,user:d}),(0,i.jsx)(m.Z,{user:d,entries:_,database:p,table:b,setTargetEntry:N,dbSchemaData:j,richTextEditors:w,dataTypes:F,query:E,confirmedDelegetedUser:Z,jsonTextEditors:T,search:!0}),C>20&&(0,i.jsx)(y,{activeEntries:_,setActiveEntries:D,database:p,table:b,entriesCount:C})]})}function y(e){e.activeEntries;var t=e.setActiveEntries,a=e.database,l=e.table,r=e.entriesCount,o=s.useContext(S),c=s.useRef(),u=s.useRef(1),m=20*Number(u.current),f=Boolean(m>=r);return s.useEffect((function(){var e=function(e,i){var s;if(null===e||void 0===e||null===(s=e[0])||void 0===s?void 0:s.isIntersecting){var r=document.getElementById("entries-search-input"),c=document.getElementById("entries-search-field-select"),m={tableName:l.tableName,dbName:a.db_slug,page:u.current,tableSchema:l,search:r?r.value:void 0,searchField:c?c.value:void 0,delegated:Boolean(o.query.delegated)};(0,b.Z)("/api/infiniteScroll",{method:"POST",body:m},!0).then((function(e){e.success&&(e.page&&(u.current=e.page),window.clearTimeout(n),n=setTimeout((function(){var a,n;(null===(a=e.data)||void 0===a?void 0:a[0])&&(null===(n=e.data)||void 0===n?void 0:n[0])&&t((function(t){return t?(0,d.Z)(t).concat((0,d.Z)(e.data)):null}))}),500))})).catch((function(e){console.log("Infinite Scroll Error =>",e)})).finally((function(){console.log("Infinite Scroll Done. Page",u.current)}))}},i={rootMargin:"0px 0px 0px 0px"};setTimeout((function(){requestAnimationFrame((function(){var t=new IntersectionObserver(e,i);c.current&&t.observe(c.current)}))}),1e3)}),[]),f?(0,i.jsx)(s.Fragment,{}):(0,i.jsx)("div",{className:"w-full flex items-center justify-center",ref:c,children:(0,i.jsx)(p.Z,{position:"relative",style:{backgroundColor:"transparent"},width:"20px"})})}var N=a(4423),w=a(4514),T={},E=!0,S=s.createContext(T);function Z(e){var t=e.user,a=e.database,n=e.table,d=e.dbSchemaData,o=e.entries,c=e.query,u=e.confirmedDelegetedUser,m=e.entriesCount,f="".concat(n.tableFullName," Table Entries | Datasquirel"),v=(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("title",{children:f}),(0,i.jsx)("meta",{name:"description",content:"All Entries in table"})]}),h=(0,l.Z)(s.useState(null),2),p=h[0],b=h[1],x=(0,l.Z)(s.useState(o),2),g=x[0],y=x[1],T=s.useRef("title"),E=s.useRef(null),Z=s.useRef([]),_=s.useRef([]);return(0,i.jsx)(r.Z,{head:v,user:t,extraHeaderContent:(0,i.jsx)(N.Z,{database:a,query:c,confirmedDelegetedUser:u,user:t}),children:(0,i.jsxs)(S.Provider,{value:{user:t,database:a,table:n,dbSchemaData:d,entries:o,targetEntry:p,setTargetEntry:b,richTextEditors:Z,jsonTextEditors:_,query:c,confirmedDelegetedUser:u,activeEntries:g,setActiveEntries:y,targetField:T,searchTerm:E,entriesCount:m},children:[(0,i.jsx)(j,{}),(0,i.jsx)(w.Z,{snug:!0})]})})}}}]);