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

2 lines
18 KiB
JavaScript
Raw Normal View History

2024-12-06 13:24:26 +00:00
"use strict";exports.id=5421,exports.ids=[5421],exports.modules={77802:(e,a,t)=>{t.d(a,{A:()=>F});var l=t(8732),s=t(82015),i=t.n(s);function d({tableFields:e,setTableFields:a,setRefresh:t,setPageRefresh:l,refreshFieldsListRef:s}){let i=e.findIndex(e=>"date_created"===e.fieldName);e.splice(i,0,{newTempField:!0}),a(e),s?.current&&s.current(e=>e+1)}t(80255);var r=t(39897),n=t(32415),c=t(64030),o=t(27825),m=t.n(o);function u({tableFields:e,setTableFields:a,refreshFieldsListRef:t,order:l,field:s,e:i}){let d=m().cloneDeep(e),r=d.findIndex(e=>e.fieldName===s.fieldName);if(r<0)return;let n=d[r];if("up"===l&&r&&r<=1){console.log("Min Reached =>",r);return}if("down"===l&&r&&r>=d.length-7){console.log("Max Reached =>",r);return}try{let e;let a=i.target.closest(".table-field-wrapper"),t=a.previousElementSibling,s=a.nextElementSibling,d=window.DSQL.Flip,r=d.getState(a);"up"===l?(e=d.getState(t),a.parentNode?.insertBefore(a,t)):s?.nextElementSibling&&(e=d.getState(s),a.parentNode?.insertBefore(a,s.nextElementSibling)),d.from(r,{duration:.3,ease:"power1.inOut"}),d.from(e,{duration:.3,ease:"power1.inOut"})}catch(e){console.log("Error =>",e.message)}if(!r){console.log("No target Field Index =>",r);return}d.splice(r,1),"up"===l?d.splice(r-1,0,n):d.splice(r+1,0,n),setTimeout(()=>{a([...d]),t.current&&t.current(e=>e+1)},500)}var p=t(64417),x=t(12097),h=t(63715);function f({field:e,setTargetField:a,fieldIndex:t,tableFields:s,setTableFields:d,refreshFieldsListRef:r,database:n,currentTable:o,user:m,isDelegated:u,setLoading:p}){let[f,g]=i().useState(e),[w,y]=i().useState(!1);return(0,l.jsxs)("div",{className:"flex-col w-full table-field-wrapper"+(w?" shadow-2xl shadow-slate-700/40 relative z-50":""),children:[(0,l.jsxs)("div",{className:"card no-hover items-center w-full py-4"+(w?" rounded-t":" rounded")+(f.fieldName?.match(c.A)?" text-slate-400 pointer-events-none border-slate-200 border":" light-gray"),children:[(0,l.jsx)("span",{className:"font-bold"+(f.fieldName?.match(c.A)?" dark:text-slate-500":" dark:text-white"),children:f.fieldName}),(0,l.jsx)("span",{className:"text-xs py-1 px-2 bg-slate-100 dark:bg-slate-700 dark:text-slate-200 rounded ",children:f.dataType}),f?.foreignKey&&(0,l.jsxs)("div",{className:"text-xs bg-primary text-white px-2 py-0.5 rounded-full",children:[(0,l.jsx)("span",{children:"Foreign Key: "}),(0,l.jsxs)("span",{children:[f.foreignKey.destinationTableName," ("," ",(0,l.jsx)("b",{children:f.foreignKey.destinationTableColumnName})," ",")"]})]}),f.fieldName?.match(c.A)&&(0,l.jsx)("span",{className:"text-slate-300 text-sm font-semibold ml-0 md:ml-auto",children:"Default Field"}),!(!u&&!f.fieldName?.match(c.A)&&f.dataType?.match(/INT/))||f.foreignKey||n?.active_clone?.toString()?.match(/1/)?!u&&!f.fieldName?.match(c.A)&&f.dataType?.match(/INT/)&&!n?.active_clone?.toString()?.match(/1/)?(0,l.jsx)("div",{className:"ml-0 md:ml-auto flex-wrap",children:(0,l.jsx)("div",{className:"button py-1 text-xs light-gray",onClick:a=>{window.confirm("Delete this foreign Key?")&&(delete e.foreignKey,p(!0),(0,h.A)("/api/updateClonedTableForeignKeys",{method:"post",body:{tableData:o,database:n.db_full_name,dbSlug:n.db_slug,delegated:!!window.location?.search?.match(/delegated=true/i)}},!0).then(e=>{e.success?window.location.reload():window.alert("Update Failed, Please Try again.")}))},style:{color:"var(--slate-500)"},children:"Delete Foreign Key"})}):(0,l.jsx)(i().Fragment,{}):(0,l.jsx)("div",{className:"ml-0 md:ml-auto flex-wrap",children:(0,l.jsx)("div",{className:"button outlined py-1 text-xs gray",onClick:e=>{w?y(!1):y(!0)},style:{color:"var(--slate-500)"},children:"Add Foreign Key"})})]}),w&&!u&&(0,l.jsx)("div",{className:"card col w-full -mt-5 pt-0 no-hover",children:(0,l.jsx)(x.A,{targetField:e,setFieldData:g,tableFields:s,setTableFields:d,database:n,currentTable:o,user:m,setActiveEdit:y,activeClonedTable:!0})})]})}var g=t(65388),w=t(84896);function y({fieldIndex:e,setTableFields:a,database:s,user:d,isNewField:r,setLiteralValue:n,tempFieldData:c,setTempFieldData:o,dataTypeValue:m,setDataTypeValue:u,dataType:p,setDataType:x,dataType
* @typedef {object} ${s}`),r.forEach(e=>{let a=e.nullValue?"?":e.fieldName?.match(l.A)?"?":"";n.push(` ${e.fieldName}${a}: ${d(e.dataType||"")};`),c.push(` * @property {${d(e.dataType||"")}${a}} ${e.fieldName}`)}),n.push("}"),c.push(" */"),e?.match(/javascript/i)&&(i=c.join("\n")),e?.match(/typescript/i)&&(i=n.join("\n"))}catch(e){console.log(e.message),i=null}return i}},39897:(e,a,t)=>{t.d(a,{A:()=>s});var l=t(8732);function s({collapse:e,setCollapse:a}){return(0,l.jsxs)("div",{className:"collapse-block"+(e?" -mt-16 -mb-6 pt-10":" mt-0 mb-0 p-0"),onClick:t=>{e?a(!1):a(!0)},children:[(0,l.jsx)("span",{children:e?"Expand":"Collapse"}),(0,l.jsx)("img",{src:"/images/down-arrow-dark.svg",alt:"Down Arrow",width:16,className:"dark:hidden opacity-30 "+(e?"":"rotate-180")}),(0,l.jsx)("img",{src:"/images/down-arrow-white.svg",alt:"Down Arrow",width:16,className:"opacity-30 hidden dark:flex "+(e?"":"rotate-180")})]})}t(82015)},64030:(e,a,t)=>{t.d(a,{A:()=>l});let l=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/},93342:(e,a,t)=>{t.d(a,{A:()=>d});let l=t(22373),s=t(29021),i=t(33873);function d({userId:e}){try{let a=i.resolve(process.cwd(),`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${e}/main.json`);return JSON.parse(s.readFileSync(a,"utf-8"))}catch(e){return l({component:"grabUserSchemaData",message:e.message}),null}}}};