dsql-admin/dsql-app/.local_dist/server/chunks/8842.js

1 line
26 KiB
JavaScript
Raw Normal View History

2024-12-06 13:24:26 +00:00
"use strict";exports.id=8842,exports.ids=[8842],exports.modules={30469:(e,t,a)=>{a.d(t,{A:()=>o});var s=a(8732),l=a(82015),i=a.n(l),r=a(32415),n=a(83147),d=a(63715);function c({paradigm:e,payload:t,setLoading:a,table:s,database:l}){a(!0),(0,d.A)("/api/exportTableData",{method:"POST",body:{paradigm:e,dbName:l.db_slug,tableName:s.tableName,payload:t}},!0).then(t=>{if(t.success){if("export"==e){let e=new Blob([JSON.stringify(t.data||[],null,4)],{type:"application/json"}),a=URL.createObjectURL(e),i=document.createElement("a");i.href=a,i.style.display="none",i.download=`${l.db_slug}-${s.tableName}-${Date.now()}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i)}else"import"==e&&(window.alert("Data Imported Successfully"),window.location.reload())}else t.msg&&window.alert(t.msg)}).catch(e=>{console.log(e)}).finally(()=>{a(!1)})}function o({database:e,table:t}){let[a,l]=i().useState(!1),[d,o]=i().useState(!0),u=i().useRef(null);return i().useRef(null),(0,s.jsxs)("div",{className:"relative",children:[a&&(0,s.jsx)(r.A,{width:"15px"}),(0,s.jsx)("div",{className:"button outlined gray",onClick:a=>{c({paradigm:"export",database:e,setLoading:l,table:t})},children:"Export"}),(0,s.jsx)("div",{className:"button outlined gray",onClick:a=>{u.current?.addEventListener("change",a=>{l(!0);let s=a.target;if(!s.files?.[0]){window.alert("No FIles selected"),l(!1);return}n.A({inputFile:s.files[0]}).then(a=>{window.confirm(`Use this file '${a.fileName}' as your import file?`)?c({paradigm:"import",payload:a.fileBase64,database:e,setLoading:l,table:t}):l(!1),o(!1),setTimeout(()=>{o(!0)},200)})}),u.current?.click()},children:"Import"}),d&&(0,s.jsx)("input",{type:"file",name:"json_file_input",id:"json_file_input",accept:".json",className:"hidden",ref:u})]})}},56775:(e,t,a)=>{a.d(t,{A:()=>c});var s=a(8732),l=a(82015),i=a.n(l),r=a(41836),n=a(95939),d=a(20173);function c({database:e,table:t,dbSchemaData:a,query:l}){let[c,o]=i().useState(!1);return(0,s.jsx)(r.Popover,{isOpen:c,onClickOutside:()=>o(!1),positions:["bottom"],align:"end",content:(0,s.jsxs)("div",{className:"stack items-stretch bg-white rounded shadow-md gap-0 min-w-[200px]",children:[(0,s.jsx)(d.A,{database:e,table:t,setOpenPopover:o,dbSchemaData:a,query:l}),(0,s.jsx)("hr",{className:"m-0"})]}),containerClassName:"z-[1000]",children:(0,s.jsx)("button",{onClick:()=>{o(!c)},className:"outlined gray px-2 py-1.5",children:(0,s.jsx)(n.A,{})})})}},87663:(e,t,a)=>{a.a(e,async(e,s)=>{try{let p;a.d(t,{A:()=>h});var l=a(8732),i=a(82015),r=a.n(i),n=a(98842),d=a(51548),c=a(13737),o=a(63715),u=a(32415),m=e([n]);function h({data:e}){let{table:t,entries:s,activeEntries:i,setActiveEntries:m,confirmedDelegetedUser:h,database:x,targetField:f,searchTerm:b}=r().useContext(n.TableEntriesContext);a(94327),h?.delegated,h?.priviledges?.match(/Edit Tables/i),h?.priviledges?.match(/Delete Tables/i),h?.priviledges?.match(/Create Tables/i);let[g,j]=r().useState(!1),y=r().useRef(),[N,v]=r().useState(null);function w(e){if(j(!0),i&&m(null),!e?.toString().match(/./)){setTimeout(()=>{m&&m(s||[]),j(!1)},500);return}window.clearTimeout(p);let a=t?.fields.filter(e=>e.fieldName===f?.current),l=a&&a[0]&&a[0].dataType?.match(/int/i)||f?.current?.match(/^id$/)?"equal":"like";p=setTimeout(()=>{j(!1),(0,o.A)(`/api/queryEntriesSearchTerm?db=${x?.db_full_name}&table=${t?.tableName}&field=${f?.current}&term=${e}&operator=${l}`).then(e=>{"number"==typeof e.count&&v(e.count),e.success&&m&&m(e.result),j(!1)})},500)}return(0,l.jsxs)("div",{className:"w-full flex-col items-stretch",children:[(0,l.jsxs)("form",{onSubmit:e=>{e.preventDefault(),b?.current&&w(b.current)},className:"flex flex-row items-stretch gap-4 w-full",children:[(0,l.jsx)("div",{className:"max-w-xs",children:(0,l.jsx)(d.A,{required:!0,selectOptions:t?t.fields.map(e=>({title:e.fieldName||"",payload:e.fieldName||""})):[],name:"database_tables",onChangeHandler:e=>{f&&(f.current=e.target.value)},title:"Select Field",defaultValue:f?.current,id:"entries-search-field-select"})}),(0,l.jsx)("div",{className:"grow",children:(0,l.jsx)(c.A,{title:"Search Term",p