1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9788],{54559:function(e,t,a){a.d(t,{Z:function(){return w}});var l=a(85893),i=a(67294);var d=a(828),r=a(95264),n=a(63845),o=a(90918),s=a(20745);function c(e){var t=e.editor,a=e.rootElement;return(0,l.jsx)("div",{className:"embed-popup-form-content-wrapper text-sm mt-2 flex-wrap bg-white p-10 rounded max-w-2xl w-full",children:(0,l.jsxs)("form",{onSubmit:function(e){e.preventDefault();var l=e.target["embed-text-area"].value;if(!(null===l||void 0===l?void 0:l.match(/./)))return alert("Please Enter HTML Text to continue.");t.insertContent(l),document.body.removeChild(a)},className:"w-full flex flex-col items-stretch gap-2",children:[(0,l.jsx)("h3",{className:"m-0 text-center text-lg",children:"Enter HTML code"}),(0,l.jsx)("textarea",{name:"embed-text-area",id:"embed-text-area",cols:30,rows:10,placeholder:"Paste Code here ..."}),(0,l.jsx)("button",{type:"submit",children:"Embed"})]})})}function u(e){var t=e.editor;navigator.clipboard.writeText((null===t||void 0===t?void 0:t.getContent())||"").then((function(){alert("Html Copied to Clipboard!")}))}var m=a(41352),f=a(52652),p=a.n(f);function x(e){var t=e.editor,a=e.rootElement,r=t.getContent(),n=i.useRef(),o=i.useRef(),s=(0,d.Z)(i.useState(null),2),c=s[0],u=s[1];return i.useEffect((function(){try{if(!(null===ace||void 0===ace?void 0:ace.edit)||!n.current)return void console.log("Ace Editor not found!");var e=ace.edit(n.current);e.setOptions({mode:"ace/mode/html",value:p()(r)}),u(e);try{ace.require("ace/ext/beautify").beautify(e.session)}catch(t){}}catch(a){console.log("JSON Editor ERROR =>",a.message)}}),[]),(0,l.jsxs)("div",{onKeyUp:function(e){var t;e.ctrlKey&&"Enter"==e.key&&(null===(t=o.current)||void 0===t||t.click())},children:[(0,l.jsx)("div",{className:"embed-popup-form-content-wrapper relative flex flex-col items-center justify-center",children:(0,l.jsxs)("div",{className:"max-w-[1200px] rounded-md overflow-hidden bg-white w-[90vw] items-start justify-start relative",children:[(0,l.jsx)("div",{ref:n,className:"w-full h-[80vh] text-[18px]"}),(0,l.jsx)("button",{className:"absolute bottom-4 right-4",onClick:function(e){if(c){var l=c.getValue();t.setContent(l),setTimeout((function(){document.body.removeChild(a)}),200)}},ref:o,children:"Save"})]})}),(0,l.jsx)("button",{className:"absolute top-4 right-8 rounded-full white",onClick:function(){try{document.body.removeChild(a)}catch(e){}},style:{width:"40px",height:"40px",padding:"0",zIndex:"12039800000"},children:(0,l.jsx)(m.Z,{})})]})}function h(e){var t=e.editor,a=document.createElement("div");(a.style.position="fixed",a.style.width="100vw",a.style.height="100vh",a.style.zIndex="123000000000000000",a.style.backgroundColor="rgba(0,0,0,0.8)",a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="center",a.style.top="0",a.style.left="0",document.body.append(a),a.onclick=function(e){e.target.closest(".embed-popup-form-content-wrapper")||document.body.removeChild(a)},t)&&s.createRoot(a).render((0,l.jsx)(x,{editor:t,rootElement:a}))}function v(e){var t=e.editor,a=document.createElement("div");(a.style.position="fixed",a.style.width="100vw",a.style.height="100vh",a.style.zIndex="123000000000000000",a.style.backgroundColor="rgba(0,0,0,0.8)",a.style.display="flex",a.style.alignItems="center",a.style.justifyContent="center",a.style.top="0",a.style.left="0",document.body.append(a),a.onclick=function(e){e.target.closest(".embed-popup-form-content-wrapper")?console.log("Still In Form"):document.body.removeChild(a)},t)&&s.createRoot(a).render((0,l.jsx)(c,{editor:t,rootElement:a}))}function y(e){var t=e.fieldObject,a=(e.dataTypeSchema,e.richTextEditors),s=e.entry,c=e.currentRichTextEditorForms,m=e.entryPage,f=e.formButtonId,p=(0,d.Z)(i.useState(!1),2),x=p[0],y=p[1],b=i.useRef(),g=i.useRef();return i.useEffect((function(){y(!0)}),[]),i.useEffect((function(){x&&(a.current.push({fieldName:t.fieldName||"",ref:g}),c.current.push({fieldName:t.fieldName||"",ref:g}))}),[x]),(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full rich-text-editor-wrapper",children:[(0,l.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:t.fieldName,children:[t.encrypted&&(0,l.jsx)(n.Z,{fontSize:"small",className:"opacity-50"}),(0,l.jsx)("span",{children:t.fieldName})]}),(0,l.jsxs)("div",{ref:b,id:t.fieldName,className:"w-full p-0 sm:p-4 flex-col items-stretch bg-slate-100 relative dark:bg-slate-700 border border-solid border-slate-300 dark:border-slate-300/20",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},children:[!x&&(0,l.jsx)(r.Z,{}),x&&(0,l.jsx)(i.Fragment,{children:(0,l.jsx)(o.M,{tinymceScriptSrc:"/tinymce/tinymce.min.js",onInit:function(e,t){g.current=t},initialValue:t.defaultValue||(s&&t.fieldName&&s[t.fieldName]?s[t.fieldName]:""),init:{height:m?400:300,width:"100%",convert_urls:!1,menubar:!1,plugins:["advlist","lists","link","image","charmap","anchor","searchreplace","visualblocks","code","fullscreen","insertdatetime","media","table","preview","help","wordcount"],toolbar:"undo redo | blocks | bold italic forecolor | link image | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat help | editCode embedCode copyCode",placeholder:"Type something ...",document_base_url:"/",content_css:t.cssFiles||void 0,setup:function(e){!function(e){var t=e.editor,a=e.formButtonId;t.addShortcut("meta+13","Save Entry.",(function(){var e;window.confirm("Update this Form?")&&a&&(null===(e=document.getElementById(a))||void 0===e||e.click())})),t.addShortcut("meta+shift+e","Edit Code.",(function(){h({editor:t})})),t.addShortcut("meta+shift+d","Embed Code.",(function(){v({editor:t})})),t.addShortcut("meta+shift+c","Copy Code.",(function(){u({editor:t})})),t.ui.registry.addButton("editCode",{icon:"edit-block",onAction:function(e){return h({editor:t})},tooltip:"Edit HTML Code"}),t.ui.registry.addButton("embedCode",{icon:"sourcecode",onAction:function(e){return v({editor:t})},tooltip:"Embed Code"}),t.ui.registry.addButton("copyCode",{icon:"copy",onAction:function(e){return u({editor:t})},tooltip:"Copy HTML"})}({editor:e,formButtonId:f})}}})})]})]})}var b=a(86729);a(63764);var g=a(31571),j=a(31325);function N(e){var t=e.fieldObject,a=e.typeFinal,i=e.isExpanded,d=e.setHeight,r=e.COLLAPSED_HEIGHT,o=e.EXPANDED_HEIGHT;return(0,l.jsxs)("div",{className:"gap-2 w-full",children:[(0,l.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:t.fieldName,children:[t.encrypted&&(0,l.jsx)(n.Z,{fontSize:"small",className:"opacity-50"}),(0,l.jsx)("span",{children:t.fieldName})]}),(0,l.jsx)("div",{className:"px-4 py-1 bg-secondary text-white rounded-full text-sm font-bold -mt-2",children:(0,l.jsx)("span",{children:a})}),(0,l.jsxs)("div",{className:"ml-auto cursor-pointer gap-1 text-slate-400 hover:text-slate-800 -mt-2 items-center flex",onClick:function(e){d(i?r:o)},children:[(0,l.jsx)("span",{className:"font-semibold text-sm",children:i?"Collapse":"Expand"}),i?(0,l.jsx)(g.Z,{size:18,className:"mt-[-1px]"}):(0,l.jsx)(j.Z,{size:18,className:"mt-[-1px]"})]})]})}function E(e){var t=e.fieldObject,a=(e.dataTypeSchema,e.entry),r=(e.entryPage,e.jsonTextEditors),n=e.type||"json";try{var o=(0,d.Z)(i.useState(0),2),s=o[0],c=o[1],u=(0,d.Z)(i.useState(300),2),m=u[0],f=u[1],p=300!==m,x=i.useRef(),h=i.useRef();return i.useEffect((function(){!function(e){var t=e.jsonEditorRef,a=e.fieldObject,l=e.setRefresh,i=e.typeFinal,d=e.entry,r=e.jsonTextEditors,n=e.editorRef;try{if(!(null===ace||void 0===ace?void 0:ace.edit)||!t.current||!a.fieldName)return console.log("Ace Editor not found!"),void setTimeout((function(){l((function(e){return e+1}))}),1e3);var o=ace.edit(t.current);o.setOptions({mode:"ace/mode/"+i,value:a.defaultValue?a.defaultValue:(null===d||void 0===d?void 0:d[a.fieldName])?function(){if("json"!==i)return d[a.fieldName];try{return JSON.stringify(JSON.parse(d[a.fieldName]),null,4)}catch(e){return d[a.fieldName]}}():"",placeholder:"json"==i?"{} ...":"",enableBasicAutocompletion:!0,enableLiveAutocompletion:!0}),r.current.push({fieldName:a.fieldName,ref:n}),n.current=o;try{ace.require("ace/ext/beautify").beautify(o.session)}catch(s){}}catch(c){console.log("JSON Editor ERROR =>",c.message)}}({editorRef:h,entry:a,fieldObject:t,jsonEditorRef:x,jsonTextEditors:r,setRefresh:c,typeFinal:n})}),[s]),(0,l.jsx)(i.Fragment,{children:(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full rich-text-editor-wrapper",children:[(0,l.jsx)(N,{fieldObject:t,isExpanded:p,setHeight:f,typeFinal:n,COLLAPSED_HEIGHT:300,EXPANDED_HEIGHT:600}),(0,l.jsx)(T,{height:m,jsonEditorRef:x})]})})}catch(v){return i.useEffect((function(){(0,b.Z)("/api/admin/clientError",{method:"post",body:{component:"DatabaseShellContent/catch-error-return",message:v.message}})}),[]),(0,l.jsx)(i.Fragment,{children:(0,l.jsx)("span",{children:"Editor Load Error"})})}}function T(e){var t=e.height,a=e.jsonEditorRef;return(0,l.jsx)("div",{className:"w-full p-0 sm:p-4 flex-col relative dark:bg-slate-700 border border-solid border-slate-300 dark:border-slate-300/20 overflow-hidden",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px",height:"".concat(t,"px")},children:(0,l.jsx)("div",{ref:a,className:"w-full text-[18px] h-full"})})}function w(e){var t,a,d,r,o,s,c,u,m,f=e.fieldObject,p=e.dataTypeSchema,x=e.richTextEditors,h=e.jsonTextEditors,v=e.entry,b=e.currentRichTextEditorForms,g=e.confirmedDelegetedUser,j=(e.query,e.entryPage),N=e.formButtonId,T=(null===g||void 0===g||g.delegated,null===g||void 0===g||null===(t=g.priviledges)||void 0===t||t.match(/Edit Tables/i),null===g||void 0===g||null===(a=g.priviledges)||void 0===a||a.match(/Delete Tables/i),null===g||void 0===g||null===(d=g.priviledges)||void 0===d||d.match(/Create Tables/i),null===g||void 0===g||null===(r=g.priviledges)||void 0===r||r.match(/Edit Entries/i),null===g||void 0===g||null===(o=g.priviledges)||void 0===o||o.match(/Delete Entries/i),i.useRef()),w=function(e){var t,a,i,d,r,n,o,s,c,u=e.fieldObject,m=e.dataTypeSchema,f=e.elementRef,p=e.entry;return u.defaultField?r=(0,l.jsx)("input",{ref:f,type:"text",name:"def_field_"+u.fieldName,id:"def_field_"+u.fieldName,placeholder:u.fieldName,defaultValue:p&&p[u.fieldName||""]?p[u.fieldName||""]:u.defaultValue?u.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},readOnly:!0,"data-default":"true"}):((null===(t=u.dataType)||void 0===t?void 0:t.match(/varchar/i))&&(r=(0,l.jsx)("textarea",{ref:f,name:u.fieldName,id:u.fieldName,placeholder:u.fieldName,required:!!u.notNullValue,maxLength:(null===(o=null===(n=u.dataType)||void 0===n?void 0:n.match(/\d+/))||void 0===o?void 0:o[0])?parseInt((null===(c=null===(s=u.dataType)||void 0===s?void 0:s.match(/\d+/))||void 0===c?void 0:c[0])||""):void 0,defaultValue:p&&p[u.fieldName||""]?p[u.fieldName||""]:u.defaultValue?u.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},onChange:function(e){var t;(null===(t=u.fieldName)||void 0===t?void 0:t.match(/^title$/))&&function(e){var t=e.target.closest("form");if(t){var a=null===t||void 0===t?void 0:t.querySelector("#slug");a&&(a.value=e.target.value.toLowerCase().replace(/ /g,"-").replace(/[^a-z\-0-9]/g,""))}}(e)}})),(null===(a=u.dataType)||void 0===a?void 0:a.match(/int$/i))&&(r=(0,l.jsx)("input",{ref:f,type:"number",name:u.fieldName,id:u.fieldName,placeholder:u.fieldName,required:!!u.notNullValue,max:m.maxValue,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:p&&p[u.fieldName||""]?p[u.fieldName||""]:u.defaultValue?u.defaultValue:"",onChange:function(e){}})),(null===(i=u.dataType)||void 0===i?void 0:i.match(/text$/i))&&(r=(0,l.jsx)("textarea",{ref:f,name:u.fieldName,id:u.fieldName,placeholder:u.fieldName,required:!!u.notNullValue,defaultValue:p&&p[u.fieldName||""]?p[u.fieldName||""]:u.defaultValue?u.defaultValue:"",style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},rows:10,onChange:function(e){}})),(null===(d=u.fieldName)||void 0===d?void 0:d.match(/password|^pass$|^key$/i))&&(r=(0,l.jsxs)("div",{className:"w-full relative",children:[(0,l.jsx)("input",{ref:f,type:"password",name:u.fieldName,id:u.fieldName,placeholder:u.fieldName,required:!!u.notNullValue,max:m.maxValue,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:p&&p[u.fieldName]?p[u.fieldName]:u.defaultValue?u.defaultValue:"",onChange:function(e){}}),(0,l.jsx)("span",{className:"absolute right-4 cursor-pointer",onClick:function(e){var t=e.target.closest("div").querySelector("input");"password"===t.type?(t.type="text",e.target.innerText="Hide"):(t.type="password",e.target.innerText="Reveal")},children:"Reveal"})]})),r||(r=(0,l.jsx)("input",{ref:f,type:"text",name:u.fieldName,id:u.fieldName,style:{borderRadius:"0 5px 5px 5px",marginTop:"-1px"},defaultValue:p&&p[u.fieldName||""]?p[u.fieldName||""]:u.defaultValue?u.defaultValue:"",onChange:function(e){}})),r)}({fieldObject:f,dataTypeSchema:p,elementRef:T,entry:v});if((null===(s=f.dataType)||void 0===s?void 0:s.match(/text$/i))&&f.richText&&!f.plainText&&!(null===(c=f.fieldName)||void 0===c?void 0:c.match(/^pass|^key$/i))&&!f.encrypted||f.encrypted&&f.richText)return(0,l.jsx)(i.Fragment,{children:(0,l.jsx)(y,{fieldObject:f,dataTypeSchema:p,richTextEditors:x,currentRichTextEditorForms:b,entry:v,entryPage:j,formButtonId:N})});var C=f.json||f.yaml||f.html||f.css||f.javascript||f.shell;return(null===(u=f.dataType)||void 0===u?void 0:u.match(/text$/i))&&C&&!f.plainText&&!(null===(m=f.fieldName)||void 0===m?void 0:m.match(/^pass|^key$/i))&&!f.encrypted||f.encrypted&&C?(0,l.jsx)(E,{fieldObject:f,dataTypeSchema:p,entry:v,entryPage:j,jsonTextEditors:h,type:f.json?"json":f.yaml?"yaml":f.html?"html":f.css?"css":f.javascript?"javascript":f.shell?"shell":"json"}):(0,l.jsxs)("div",{className:"flex flex-col items-start gap-0 w-full"+(f.defaultField?" opacity-50":""),children:[(0,l.jsxs)("label",{className:"font-bold text-slate-700 dark:text-slate-300 text-base px-3 py-1 bg-slate-100 dark:bg-slate-700 rounded-t-md border border-solid border-slate-300 dark:border-slate-300/20 flex items-center gap-2",htmlFor:f.fieldName,children:[f.encrypted&&(0,l.jsx)(i.Fragment,{children:(0,l.jsx)(n.Z,{fontSize:"small",className:"opacity-50"})}),(0,l.jsx)("span",{children:f.fieldName}),f.defaultField&&(0,l.jsx)("span",{className:"bg-white dark:bg-slate-900 text-primary dark:text-slate-300 font-semibold text-xs px-2 py-0.5 rounded-xs",children:"Default Field"})]}),w]})}},88515:function(e,t,a){a.d(t,{Z:function(){return d}});var l=a(85893),i=a(67294);function d(e){var t=e.table,a=e.database,d=e.user,r=(e.activeDbClone,(null===t||void 0===t?void 0:t.childTableDbFullName)?t.childTableDbFullName.replace(new RegExp(/datasquirel_user_\d+_/),""):null),n=t.childTableDbFullName===a.db_full_name;return r?(0,l.jsxs)("span",{className:"info small green gap-1"+((null===a||void 0===a?void 0:a.active_clone)?" -mt-6":""),style:{fontWeight:"500"},children:["This Table is an active clone of"," ",(0,l.jsx)("a",{href:"/admin/".concat(null===d||void 0===d?void 0:d.id,"/databases/").concat(r,"/tables/").concat(t.childTableName),target:"_blank",className:"button gray outlined small-text",style:{display:"inline-block",fontSize:"12px",padding:"3px 7px"},children:(0,l.jsx)("b",{children:t.childTableName})})," ","in"," ",n?(0,l.jsxs)("span",{children:["this current database(",(0,l.jsx)("b",{children:a.db_name}),")."]}):(0,l.jsxs)(i.Fragment,{children:[(0,l.jsx)("a",{href:"/admin/".concat(null===d||void 0===d?void 0:d.id,"/databases/").concat(r),target:"_blank",className:"button gray outlined small-text",style:{display:"inline-block",fontSize:"12px",padding:"3px 7px"},children:(0,l.jsx)("b",{children:r})}),(0,l.jsx)("span",{children:"database."})]})," ",(null===a||void 0===a?void 0:a.active_clone)?"":"Only Foreign keys and Entries can be updated."]}):(0,l.jsx)(i.Fragment,{})}}}]); |