2024-11-05 11:12:42 +00:00
"use strict" ;
exports . id = 9035 ;
exports . ids = [ 9035 , 2348 ] ;
exports . modules = {
/***/ 2943 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
"Z" : ( ) => ( /* binding */ ImportExportEntries )
} ) ;
// EXTERNAL MODULE: external "react/jsx-runtime"
var jsx _runtime _ = _ _webpack _require _ _ ( 997 ) ;
// EXTERNAL MODULE: external "react"
var external _react _ = _ _webpack _require _ _ ( 6689 ) ;
var external _react _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _react _ ) ;
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
var LoadingBlock = _ _webpack _require _ _ ( 5264 ) ;
// EXTERNAL MODULE: ./functions/frontend/inputFileToBase64.js
2024-11-06 11:13:31 +00:00
var inputFileToBase64 = _ _webpack _require _ _ ( 8345 ) ;
2024-11-05 11:12:42 +00:00
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
var fetchApi = _ _webpack _require _ _ ( 6729 ) ;
; // CONCATENATED MODULE: ./components/admin/databases/functions/import-export-handler.js
// @ts-check
/ * *
* Import ot Export Table Data
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } param0
* @ param { "import" | "export" } param0 . paradigm
* @ param { any } [ param0 . payload ]
* @ param { any } param0 . setLoading
* @ param { DSQL _TableSchemaType } param0 . table
* @ param { DSQL _MYSQL _user _databases _Type } param0 . database
* / f u n c t i o n i m p o r t E x p o r t H a n d l e r ( { p a r a d i g m , p a y l o a d , s e t L o a d i n g , t a b l e , d a t a b a s e , } ) {
setLoading ( true ) ;
if ( paradigm === "import" ) { }
( 0 , fetchApi /* default */ . Z ) ( "/api/exportTableData" , {
method : "POST" ,
body : {
paradigm ,
dbName : database . db _slug ,
tableName : table . tableName ,
payload : payload
}
} , true ) . then ( ( res ) => {
if ( res . success ) {
if ( paradigm == "export" ) {
const data = res . data ;
const jsonString = JSON . stringify ( data || [ ] , null , 4 ) ;
const blob = new Blob ( [
jsonString
] , {
type : "application/json"
} ) ;
const url = URL . createObjectURL ( blob ) ;
const a = document . createElement ( "a" ) ;
a . href = url ;
a . style . display = "none" ;
a . download = ` ${ database . db _slug } - ${ table . tableName } - ${ Date . now ( ) } .json ` ;
document . body . appendChild ( a ) ;
a . click ( ) ;
document . body . removeChild ( a ) ;
} else if ( paradigm == "import" ) {
window . alert ( "Data Imported Successfully" ) ;
window . location . reload ( ) ;
}
} else if ( res . msg ) {
window . alert ( res . msg ) ;
}
} ) . catch ( ( error ) => {
console . log ( error ) ;
} ) . finally ( ( ) => {
setLoading ( false ) ;
} ) ;
}
; // CONCATENATED MODULE: ./components/admin/databases/ImportExportEntries.jsx
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* # Import Export Entries
* === === === === === === === === === === === === === === === === ===
* @ param { object } props
* @ param { DSQL _MYSQL _user _databases _Type } props . database
* @ param { DSQL _TableSchemaType } props . table
* @ returns
* / f u n c t i o n I m p o r t E x p o r t E n t r i e s ( { d a t a b a s e , t a b l e } ) {
const [ loading , setLoading ] = external _react _default ( ) . useState ( false ) ;
const [ inputReady , setInputReady ] = external _react _default ( ) . useState ( true ) ;
/** @type {React.RefObject<HTMLInputElement>} */ const fileRef = external _react _default ( ) . useRef ( null ) ;
/** @type {React.RefObject<HTMLFormElement>} */ const formRef = external _react _default ( ) . useRef ( null ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
function resetForm ( ) {
setInputReady ( false ) ;
setTimeout ( ( ) => {
setInputReady ( true ) ;
} , 200 ) ;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "relative" ,
children : [
loading && /*#__PURE__*/ jsx _runtime _ . jsx ( LoadingBlock /* default */ . Z , {
width : "15px"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "button outlined gray" ,
onClick : ( e ) => {
importExportHandler ( {
paradigm : "export" ,
database ,
setLoading ,
table
} ) ;
} ,
children : "Export"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "button outlined gray" ,
onClick : ( e ) => {
fileRef . current ? . addEventListener ( "change" , ( e ) => {
setLoading ( true ) ;
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e . target ;
if ( ! inputEl . files ? . [ 0 ] ) {
window . alert ( "No FIles selected" ) ;
setLoading ( false ) ;
return ;
}
( 0 , inputFileToBase64 /* default */ . Z ) ( {
inputFile : inputEl . files [ 0 ]
} ) . then ( ( fileObject ) => {
if ( window . confirm ( ` Use this file ' ${ fileObject . fileName } ' as your import file? ` ) ) {
importExportHandler ( {
paradigm : "import" ,
payload : fileObject . fileBase64 ,
database ,
setLoading ,
table
} ) ;
resetForm ( ) ;
} else {
setLoading ( false ) ;
resetForm ( ) ;
}
} ) ;
} ) ;
fileRef . current ? . click ( ) ;
} ,
children : "Import"
} ) ,
inputReady && /*#__PURE__*/ jsx _runtime _ . jsx ( "input" , {
type : "file" ,
name : "json_file_input" ,
id : "json_file_input" ,
accept : ".json" ,
className : "hidden" ,
ref : fileRef
} )
]
} ) ;
}
/***/ } ) ,
/***/ 3684 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ "Z" : ( ) => ( /* binding */ MoreTableOptions )
/* harmony export */ } ) ;
/* harmony import */ var react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 997 ) ;
/* harmony import */ var react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 6689 ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ ) ;
/* harmony import */ var react _tiny _popover _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _ ( 7076 ) ;
/* harmony import */ var react _tiny _popover _ _WEBPACK _IMPORTED _MODULE _2 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _tiny _popover _ _WEBPACK _IMPORTED _MODULE _2 _ _ ) ;
/* harmony import */ var lucide _react _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _ ( 2423 ) ;
/* harmony import */ var lucide _react _ _WEBPACK _IMPORTED _MODULE _3 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( lucide _react _ _WEBPACK _IMPORTED _MODULE _3 _ _ ) ;
/* harmony import */ var _SyncDataButton _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _ ( 436 ) ;
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* # Import Export Entries
* === === === === === === === === === === === === === === === === ===
* @ param { object } props
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } props . table
* @ param { import ( "@/package-shared/types" ) . DSQL _DatabaseSchemaType [ ] } props . dbSchemaData
* @ param { any } props . query
* @ returns
* / f u n c t i o n M o r e T a b l e O p t i o n s ( { d a t a b a s e , t a b l e , d b S c h e m a D a t a , q u e r y , } ) {
const [ open , setOpen ] = react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . useState ( false ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( react _tiny _popover _ _WEBPACK _IMPORTED _MODULE _2 _ _ . Popover , {
isOpen : open ,
onClickOutside : ( ) => setOpen ( false ) ,
positions : [
"bottom"
] ,
align : "end" ,
content : /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "stack items-stretch bg-white rounded shadow-md gap-0 min-w-[200px]" ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _SyncDataButton _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* ["default"] */ . Z , {
database ,
table ,
setOpenPopover : setOpen ,
dbSchemaData ,
query
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "m-0"
} )
]
} ) ,
containerClassName : "z-[1000]" ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "button" , {
onClick : ( ) => {
setOpen ( ! open ) ;
} ,
className : "outlined gray px-2 py-1.5" ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( lucide _react _ _WEBPACK _IMPORTED _MODULE _3 _ _ . Ellipsis , { } )
} )
} ) ;
}
/***/ } ) ,
/***/ 436 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
"Z" : ( ) => ( /* binding */ SyncDataButton )
} ) ;
// UNUSED EXPORTS: SyncDataModalContent
// EXTERNAL MODULE: external "react/jsx-runtime"
var jsx _runtime _ = _ _webpack _require _ _ ( 997 ) ;
// EXTERNAL MODULE: ./components/form/FormRadios.jsx
var FormRadios = _ _webpack _require _ _ ( 2348 ) ;
// EXTERNAL MODULE: ./components/form/FormSelect.jsx
var FormSelect = _ _webpack _require _ _ ( 4114 ) ;
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
var LoadingBlock = _ _webpack _require _ _ ( 5264 ) ;
// EXTERNAL MODULE: ./components/general/Modal.jsx
var Modal = _ _webpack _require _ _ ( 9471 ) ;
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
var fetchApi = _ _webpack _require _ _ ( 6729 ) ;
; // CONCATENATED MODULE: ./functions/frontend/syncTableDataFormHandler.js
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Auth user on client side
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { object } params
* @ param { React . FormEvent < HTMLFormElement > } params . e
* @ param { React . Dispatch < React . SetStateAction < boolean >> } params . setLoading
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } params . database
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } params . table
* @ param { any } params . query
*
* @ requires search - field name attribute
* / f u n c t i o n s y n c T a b l e D a t a F o r m H a n d l e r ( { e , s e t L o a d i n g , d a t a b a s e , t a b l e , q u e r y , } ) {
e . preventDefault ( ) ;
setLoading ( true ) ;
/** @type {HTMLFormElement} */ // @ts-ignore
const formEl = e . target ;
const paradigm = formEl [ "paradigm" ] ? . value ;
const dstDbName = formEl [ "database" ] ? . value ;
const dstTableName = formEl [ "table" ] ? . value ;
/** @type {import("@/pages/api/sync-table-data").SyncTableBody} */ const fetchObject = {
paradigm : paradigm ,
src : {
db : database . db _slug ,
table : table . tableName
} ,
dst : {
db : dstDbName ,
table : dstTableName
} ,
delegated : query . delegated
} ;
const alertMsg = paradigm == "Pull" ? "NOTE: This operation will override the current database entries. Continue?" : "NOTE: This operation will override the selected database entries. Continue?" ;
if ( ! window . confirm ( alertMsg ) ) {
setTimeout ( ( ) => {
setLoading ( false ) ;
} , 1000 ) ;
return ;
}
( 0 , fetchApi /* default */ . Z ) ( "/api/sync-table-data" , {
method : "POST" ,
body : {
... fetchObject
}
} , true ) . then ( ( res ) => {
if ( res . success ) {
window . alert ( "Data Sync Successful" ) ;
window . location . reload ( ) ;
} else {
if ( res . msg ) window . alert ( "ERROR: " + res . msg ) ;
}
} ) . finally ( ( ) => {
setTimeout ( ( ) => {
setLoading ( false ) ;
} , 1000 ) ;
} ) ;
} ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
// EXTERNAL MODULE: external "lodash"
var external _lodash _ = _ _webpack _require _ _ ( 6517 ) ;
var external _lodash _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _lodash _ ) ;
// EXTERNAL MODULE: external "react"
var external _react _ = _ _webpack _require _ _ ( 6689 ) ;
var external _react _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _react _ ) ;
; // CONCATENATED MODULE: ./components/admin/databases/SyncDataButton.jsx
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* @ param { object } props
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } props . table
* @ param { import ( "@/package-shared/types" ) . DSQL _DatabaseSchemaType [ ] } props . dbSchemaData
* @ param { React . Dispatch < React . SetStateAction < boolean >> } [ props . setOpenPopover ]
* @ param { any } props . query
* / f u n c t i o n S y n c D a t a B u t t o n ( { d a t a b a s e , t a b l e , s e t O p e n P o p o v e r , d b S c h e m a D a t a , q u e r y , } ) {
const [ open , setOpen ] = external _react _default ( ) . useState ( false ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
return /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( jsx _runtime _ . Fragment , {
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "button" , {
className : "ghost p-3 justify-start" ,
onClick : ( ) => {
setOpen ( true ) ;
setTimeout ( ( ) => {
if ( setOpenPopover ) setOpenPopover ( false ) ;
} , 200 ) ;
} ,
children : "Sync Data"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( Modal /* default */ . Z , {
open : open ,
setOpen : setOpen ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( SyncDataModalContent , {
database ,
table ,
dbSchemaData ,
query
} )
} )
]
} ) ;
}
/ * *
* @ param { object } props
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } props . table
* @ param { import ( "@/package-shared/types" ) . DSQL _DatabaseSchemaType [ ] } props . dbSchemaData
* @ param { any } props . query
* / f u n c t i o n S y n c D a t a M o d a l C o n t e n t ( { d a t a b a s e , t a b l e , q u e r y , d b S c h e m a D a t a : i n i t i a l S c h e m a , } ) {
/** @type {[ state: import("@/package-shared/types").DSQL_DatabaseSchemaType[], dispatch: React.Dispatch<React.SetStateAction<import("@/package-shared/types").DSQL_DatabaseSchemaType[]>> ]} */ // @ts-ignore
const [ dbSchemaData , setDbSchemaData ] = external _react _default ( ) . useState ( initialSchema ) ;
const [ paradigm , setParadigm ] = external _react _default ( ) . useState ( "Push" ) ;
const [ targetDb , setTargetDb ] = external _react _default ( ) . useState ( dbSchemaData ? . [ 0 ] ) ;
const [ tables , setTables ] = external _react _default ( ) . useState ( targetDb ? . tables ) ;
const [ targetTable , setTargetTable ] = external _react _default ( ) . useState ( tables ? . [ 0 ] ) ;
const [ loading , setLoading ] = external _react _default ( ) . useState ( false ) ;
const [ isCompatible , setIsCompatible ] = external _react _default ( ) . useState ( false ) ;
external _react _default ( ) . useEffect ( ( ) => {
const isEqual = external _lodash _default ( ) . isEqual ( table ? . fields , targetTable ? . fields ) ;
if ( isEqual ) {
setIsCompatible ( true ) ;
} else {
setIsCompatible ( false ) ;
}
} , [
targetTable ,
setTargetDb
] ) ;
external _react _default ( ) . useEffect ( ( ) => {
if ( query . delegated ) {
( 0 , fetchApi /* default */ . Z ) ( "/api/get-authorized-databases" ) . then ( ( res ) => {
if ( res . success && res . payload ) {
setDbSchemaData ( res . payload ) ;
}
} ) ;
}
} , [ ] ) ;
return /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "stack gap-2 relative w-full" ,
children : [
loading || ! dbSchemaData && /*#__PURE__*/ jsx _runtime _ . jsx ( LoadingBlock /* default */ . Z , {
width : "20px"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "h3" , {
className : "m-0 text-lg" ,
children : "Sync Data with another table"
} ) ,
! isCompatible ? /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "span" , {
className : "info warning inline" ,
children : [
"The selected table is not compatible with" ,
" " ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "b" , {
children : table . tableFullName
} )
]
} ) : /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "span" , {
className : "info green inline" ,
children : [
"The selected table matches " ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "b" , {
children : table . tableFullName
} ) ,
" " ,
"schema"
]
} ) ,
dbSchemaData && /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "form" , {
onSubmit : ( e ) => {
syncTableDataFormHandler ( {
e ,
database ,
setLoading ,
table ,
query
} ) ;
} ,
className : "w-full stack gap-2 items-stretch" ,
children : [
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "stack gap-2 my-2" ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( FormRadios /* default */ . Z , {
radioValues : [
{
title : "Push" ,
payload : "Push" ,
default : true
} ,
{
title : "Pull" ,
payload : "Pull"
} ,
] ,
name : "paradigm" ,
smallText : true ,
flexRow : true ,
onChangeHandler : ( e ) => {
setParadigm ( e . target . value ) ;
}
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "text-xs text-slate-500 dark:text-slate-400" ,
children : paradigm == "Push" ? /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( jsx _runtime _ . Fragment , {
children : [
"Sync data from the current table(" ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "b" , {
children : table . tableFullName
} ) ,
") to the selected table below"
]
} ) : /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( jsx _runtime _ . Fragment , {
children : [
"Sync data from the selected table below to the current table(" ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "b" , {
children : table . tableFullName
} ) ,
")"
]
} )
} )
]
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( FormSelect /* default */ . Z , {
selectOptions : dbSchemaData . filter ( ( dbObj ) => dbObj . dbFullName !== database . db _full _name ) . map ( ( dbObj ) => ( {
title : dbObj . dbName ,
payload : dbObj . dbSlug
} ) ) ,
name : "database" ,
onChangeHandler : ( e ) => {
const targetDatabase = dbSchemaData . find ( ( db ) => db . dbSlug == e . target . value ) ;
if ( targetDatabase ) {
setTargetDb ( targetDatabase ) ;
setTables ( targetDatabase . tables ) ;
setTargetTable ( targetDatabase . tables ? . [ 0 ] ) ;
}
}
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( FormSelect /* default */ . Z , {
selectOptions : tables . map ( ( tbl ) => ( {
title : tbl . tableFullName ,
payload : tbl . tableName
} ) ) ,
name : "table" ,
onChangeHandler : ( e ) => {
const findTable = tables . find ( ( tb ) => tb . tableName === e . target . value ) ;
if ( findTable ) setTargetTable ( findTable ) ;
}
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "button" , {
className : isCompatible ? "" : "disabled" ,
children : "Sync"
} )
]
} )
]
} ) ;
}
/***/ } ) ,
/***/ 6122 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
"Z" : ( ) => ( /* binding */ TableEntriesList )
} ) ;
// EXTERNAL MODULE: external "react/jsx-runtime"
var jsx _runtime _ = _ _webpack _require _ _ ( 997 ) ;
// EXTERNAL MODULE: external "react"
var external _react _ = _ _webpack _require _ _ ( 6689 ) ;
var external _react _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _react _ ) ;
// EXTERNAL MODULE: ./components/admin/databases/UpdateEntryForm.jsx + 1 modules
var UpdateEntryForm = _ _webpack _require _ _ ( 1985 ) ;
// EXTERNAL MODULE: ./pages/admin/[user_id]/databases/[single]/tables/[single_table]/entries/index.jsx + 1 modules
var _single _table _entries = _ _webpack _require _ _ ( 7722 ) ;
// EXTERNAL MODULE: ./components/form/FormSelect.jsx
var FormSelect = _ _webpack _require _ _ ( 4114 ) ;
// EXTERNAL MODULE: ./components/form/FormInput.jsx + 2 modules
var FormInput = _ _webpack _require _ _ ( 7901 ) ;
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
var fetchApi = _ _webpack _require _ _ ( 6729 ) ;
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
var LoadingBlock = _ _webpack _require _ _ ( 5264 ) ;
; // CONCATENATED MODULE: ./components/admin/databases/SearchEntriesSection.jsx
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** @type {any} */ let timeout ;
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* @ param { any } [ props . data ]
* / f u n c t i o n S e a r c h E n t r i e s S e c t i o n ( { d a t a } ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / c o n s t { t a b l e , e n t r i e s , a c t i v e E n t r i e s , s e t A c t i v e E n t r i e s , c o n f i r m e d D e l e g e t e d U s e r , d a t a b a s e , t a r g e t F i e l d , s e a r c h T e r m , } = e x t e r n a l _ r e a c t _ d e f a u l t ( ) . u s e C o n t e x t ( _ s i n g l e _ t a b l e _ e n t r i e s . T a b l e E n t r i e s C o n t e x t ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / c o n s t d a t a T y p e s = _ _ w e b p a c k _ r e q u i r e _ _ ( 9 5 9 4 ) ;
const isDelegated = confirmedDelegetedUser ? . delegated ;
const isTableEditable = confirmedDelegetedUser ? . priviledges ? . match ( /Edit Tables/i ) ;
const isTableDeletable = confirmedDelegetedUser ? . priviledges ? . match ( /Delete Tables/i ) ;
const isTableCreatable = confirmedDelegetedUser ? . priviledges ? . match ( /Create Tables/i ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / c o n s t [ l o a d i n g , s e t L o a d i n g ] = e x t e r n a l _ r e a c t _ d e f a u l t ( ) . u s e S t a t e ( f a l s e ) ;
/** @type {React.MutableRefObject<HTMLElement | undefined>} */ const searchInputRef = external _react _default ( ) . useRef ( ) ;
external _react _default ( ) . useEffect ( ( ) => {
if ( searchInputRef . current ) searchInputRef . current . focus ( ) ;
} , [ ] ) ;
const [ count , setCount ] = external _react _default ( ) . useState ( null ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
function search ( /** @type {string} */ term ) {
setLoading ( true ) ;
if ( activeEntries ) setActiveEntries ( null ) ;
if ( ! term ? . toString ( ) . match ( /./ ) ) {
setTimeout ( ( ) => {
if ( setActiveEntries ) setActiveEntries ( entries || [ ] ) ;
setLoading ( false ) ;
} , 500 ) ;
return ;
}
window . clearTimeout ( timeout ) ;
const targetFieldObject = table ? . fields . filter ( ( fld ) => fld . fieldName === targetField ? . current ) ;
const operator = ( ( ) => {
if ( targetFieldObject && targetFieldObject [ 0 ] ) {
if ( targetFieldObject [ 0 ] . dataType ? . match ( /int/i ) ) return "equal" ;
}
if ( targetField ? . current ? . match ( /^id$/ ) ) return "equal" ;
return "like" ;
} ) ( ) ;
timeout = setTimeout ( ( ) => {
setLoading ( false ) ;
( 0 , fetchApi /* default */ . Z ) ( ` /api/queryEntriesSearchTerm?db= ${ database ? . db _full _name } &table= ${ table ? . tableName } &field= ${ targetField ? . current } &term= ${ term } &operator= ${ operator } ` ) . then ( ( res ) => {
if ( typeof res . count == "number" ) {
setCount ( res . count ) ;
}
if ( res . success && setActiveEntries ) {
setActiveEntries ( res . result ) ;
}
setLoading ( false ) ;
} ) ;
} , 500 ) ;
}
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / ( 0 , j s x _ r u n t i m e _ . j s x s ) ( " d i v " , {
className : "w-full flex-col items-stretch" ,
children : [
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "form" , {
onSubmit : ( e ) => {
e . preventDefault ( ) ;
if ( searchTerm ? . current ) search ( searchTerm . current ) ;
} ,
className : "flex flex-row items-stretch gap-4 w-full" ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "max-w-xs" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( FormSelect /* default */ . Z , {
required : true ,
selectOptions : table ? table . fields . map ( ( fieldObject ) => {
return {
title : fieldObject . fieldName || "" ,
payload : fieldObject . fieldName || ""
} ;
} ) : [ ] ,
name : "database_tables" ,
onChangeHandler : ( e ) => {
if ( targetField ) targetField . current = e . target . value ;
// setTimeout(() => {
// search(searchTerm);
// }, 500);
} ,
title : "Select Field" ,
defaultValue : targetField ? . current ,
id : "entries-search-field-select"
} )
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "grow" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( FormInput /* default */ . Z , {
title : "Search Term" ,
placeholder : "Enter search term that corresponds with the selected field type ..." ,
onInputHandler : ( e ) => {
/** @type {HTMLInputElement} */ // @ts-ignore
const inputEl = e . target ;
if ( inputEl . value ? . match ( /./ ) && searchTerm ) {
searchTerm . current = inputEl . value ;
} else if ( searchTerm ) {
searchTerm . current = null ;
}
search ( inputEl . value ) ;
} ,
elementRef : searchInputRef ,
id : "entries-search-input"
} )
} ) ,
loading && /*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "relative items-center justify-center" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "relative mt-5 w-6" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( LoadingBlock /* default */ . Z , {
width : "20px"
} )
} )
} )
]
} ) ,
searchTerm ? . current ? . match ( /./ ) && /*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "py-4" ,
children : /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "span" , {
className : "text-lg" ,
children : [
typeof count == "number" ? count > 0 ? /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "b" , {
children : [
count ,
" "
]
} ) : /*#__PURE__*/ jsx _runtime _ . jsx ( jsx _runtime _ . Fragment , {
children : "No "
} ) : "... " ,
"Search result" ,
! count || count === 1 ? "" : "s" ,
" for" ,
" " ,
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "b" , {
children : [
'"' ,
searchTerm . current ,
'"'
]
} )
]
} )
} )
]
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
// EXTERNAL MODULE: external "@mui/icons-material/LibraryAddTwoTone"
var LibraryAddTwoTone _ = _ _webpack _require _ _ ( 9438 ) ;
var LibraryAddTwoTone _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( LibraryAddTwoTone _ ) ;
// EXTERNAL MODULE: ./components/admin/databases/ImportExportEntries.jsx + 1 modules
var ImportExportEntries = _ _webpack _require _ _ ( 2943 ) ;
// EXTERNAL MODULE: ./components/admin/databases/MoreTableOptions.jsx
var MoreTableOptions = _ _webpack _require _ _ ( 3684 ) ;
// EXTERNAL MODULE: ./components/admin/databases/SyncDataButton.jsx + 1 modules
var SyncDataButton = _ _webpack _require _ _ ( 436 ) ;
; // CONCATENATED MODULE: ./components/admin/databases/TableEntriesList.jsx
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* @ param { import ( "@/package-shared/types" ) . UserType } props . user
* @ param { any [ ] | null } props . entries
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } props . table
* @ param { React . Dispatch < React . SetStateAction < any >> } [ props . setTargetEntry ]
* @ param { import ( "@/package-shared/types" ) . DSQL _DatabaseSchemaType [ ] } props . dbSchemaData
* @ param { React . MutableRefObject < import ( "@/package-shared/types" ) . RichTextEditorsRefArray [ ] > } props . richTextEditors
* @ param { React . MutableRefObject < import ( "@/package-shared/types" ) . JSONTextEditorsRefArray [ ] > } props . jsonTextEditors
* @ param { any [ ] } props . dataTypes
* @ param { string } [ props . title ]
* @ param { any } [ props . confirmedDelegetedUser ]
* @ param { any } [ props . query ]
* @ param { any } [ props . search ]
* @ param { number } [ props . entriesCount ]
* / f u n c t i o n T a b l e E n t r i e s L i s t ( { u s e r , e n t r i e s , d a t a b a s e , t a b l e , s e t T a r g e t E n t r y , d b S c h e m a D a t a , r i c h T e x t E d i t o r s , j s o n T e x t E d i t o r s , d a t a T y p e s , t i t l e , c o n f i r m e d D e l e g e t e d U s e r , q u e r y , s e a r c h , e n t r i e s C o u n t , } ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / c o n s t i s D e l e g a t e d = c o n f i r m e d D e l e g e t e d U s e r ? . d e l e g a t e d ;
const isTableEditable = confirmedDelegetedUser ? . priviledges ? . match ( /Edit Tables/i ) ;
const isTableDeletable = confirmedDelegetedUser ? . priviledges ? . match ( /Delete Tables/i ) ;
const isTableCreatable = confirmedDelegetedUser ? . priviledges ? . match ( /Create Tables/i ) ;
const areEntriesEditable = confirmedDelegetedUser ? . priviledges ? . match ( /Edit Entries/i ) ;
const areEntriesDeletable = confirmedDelegetedUser ? . priviledges ? . match ( /Delete Entries/i ) ;
const { active _clone , active _clone _parent _db , remote _connected } = database ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / j s x _ r u n t i m e _ . j s x ( ( e x t e r n a l _ r e a c t _ d e f a u l t ( ) ) . F r a g m e n t , {
children : /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "section" , {
className : "paper gray gray-bg" ,
children : [
title && /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "justify-between w-full flex-wrap px-4 sm:px-0 pt-4 sm:pt-0" ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "h2" , {
className : "text-xl m-0" ,
children : title
} ) ,
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
children : [
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "a" , {
className : "button flex gap-2 items-center" ,
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /tables/ ${ table . tableName } /entries/add-entry ` ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "symbol" ,
children : "+"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
children : "Add New Entry"
} )
]
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( ImportExportEntries /* default */ . Z , {
database ,
table
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( MoreTableOptions /* default */ . Z , {
database ,
table ,
dbSchemaData ,
query
} )
]
} )
]
} ) ,
search && /*#__PURE__*/ jsx _runtime _ . jsx ( SearchEntriesSection , { } ) ,
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "w-full flex-col gap-6" ,
children : [
entries ? . [ 0 ] && entries . map ( ( entry ) => {
return /*#__PURE__*/ jsx _runtime _ . jsx ( ( external _react _default ( ) ) . Fragment , {
children : /*#__PURE__*/ jsx _runtime _ . jsx ( UpdateEntryForm /* default */ . Z , {
user : user ,
database : database ,
table : table ,
dbSchemaData : dbSchemaData ,
richTextEditors : richTextEditors ,
dataTypes : dataTypes ,
entry : entry ,
query : query ,
confirmedDelegetedUser : confirmedDelegetedUser ,
jsonTextEditors : jsonTextEditors
} )
} , entry . id ) ;
} ) ,
! entries && /*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "w-full h-[300px]" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( LoadingBlock /* default */ . Z , {
position : "relative"
} )
} ) ,
entries && ! entries ? . [ 0 ] && /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /tables/ ${ table . 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 : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "text-slate-400 text-center" ,
children : "No Entries Added Yet."
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( ( LibraryAddTwoTone _default ( ) ) , {
className : "opacity-20 my-4" ,
sx : {
fontSize : 80
}
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "text-center" ,
children : "Add an Entry to this Table"
} )
]
} ) ,
entriesCount && entriesCount > 10 ? /*#__PURE__*/ jsx _runtime _ . jsx ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /tables/ ${ table . tableName } /entries ` ,
className : "button outlined gray w-full -mb-4" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
children : "See All Entries"
} )
} ) : null ,
entries ? . [ 0 ] && title && /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "a" , {
className : "button flex gap-2 items-center w-full justify-center mt-2 more-padding" ,
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /tables/ ${ table . tableName } /entries/add-entry ` ,
style : {
borderStyle : "dotted" ,
borderWidth : "2px"
} ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "symbol" ,
children : "+"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
children : "Add New Entry"
} )
]
} )
]
} )
]
} )
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ } ) ,
/***/ 1985 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
"Z" : ( ) => ( /* binding */ UpdateEntryForm )
} ) ;
// EXTERNAL MODULE: external "react/jsx-runtime"
var jsx _runtime _ = _ _webpack _require _ _ ( 997 ) ;
// EXTERNAL MODULE: external "react"
var external _react _ = _ _webpack _require _ _ ( 6689 ) ;
var external _react _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _react _ ) ;
// EXTERNAL MODULE: ./functions/frontend/defaultFieldsRegexp.js
var defaultFieldsRegexp = _ _webpack _require _ _ ( 3907 ) ;
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
var fetchApi = _ _webpack _require _ _ ( 6729 ) ;
// EXTERNAL MODULE: ./functions/frontend/updateDiskUsage.js
var updateDiskUsage = _ _webpack _require _ _ ( 1069 ) ;
// EXTERNAL MODULE: ./components/general/ExpandBlock.jsx
var ExpandBlock = _ _webpack _require _ _ ( 6169 ) ;
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
var LoadingBlock = _ _webpack _require _ _ ( 5264 ) ;
// EXTERNAL MODULE: ./components/admin/databases/TableEntryField.jsx + 11 modules
var TableEntryField = _ _webpack _require _ _ ( 4559 ) ;
// EXTERNAL MODULE: external "@mui/material"
var material _ = _ _webpack _require _ _ ( 5692 ) ;
// EXTERNAL MODULE: external "@mui/icons-material/MoreHoriz"
var MoreHoriz _ = _ _webpack _require _ _ ( 5453 ) ;
// EXTERNAL MODULE: external "lodash"
var external _lodash _ = _ _webpack _require _ _ ( 6517 ) ;
var external _lodash _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _lodash _ ) ;
// EXTERNAL MODULE: external "lucide-react"
var external _lucide _react _ = _ _webpack _require _ _ ( 2423 ) ;
// EXTERNAL MODULE: ./components/admin/databases/functions/generateTypeDefinition.js
var generateTypeDefinition = _ _webpack _require _ _ ( 5753 ) ;
// EXTERNAL MODULE: external "react-tiny-popover"
var external _react _tiny _popover _ = _ _webpack _require _ _ ( 7076 ) ;
; // CONCATENATED MODULE: ./components/admin/databases/UpdateEntryMoreOptions.jsx
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* @ param { import ( "@/package-shared/types" ) . UserType } props . user
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } props . table
* @ param { any } [ props . entry ]
* @ param { string } [ props . url ]
* @ param { any } [ props . query ]
* / f u n c t i o n U p d a t e E n t r y M o r e O p t i o n s ( { u s e r , t a b l e , e n t r y , u r l , q u e r y , } ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / c o n s t [ o p e n M o r e , s e t O p e n M o r e ] = e x t e r n a l _ r e a c t _ d e f a u l t ( ) . u s e S t a t e ( f a l s e ) ;
const openMoreButtonRef = external _react _default ( ) . useRef ( null ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / j s x _ r u n t i m e _ . j s x ( " d i v " , {
className : "relative z-[1000]" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( external _react _tiny _popover _ . Popover , {
isOpen : openMore ,
onClickOutside : ( ) => setOpenMore ( false ) ,
containerClassName : "z-[1000]" ,
positions : [
"bottom"
] ,
align : "end" ,
content : /*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "bg-white dark:bg-slate-900 rounded shadow-md cancel-link" ,
children : /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "flex-col min-w-[200px] items-stretch gap-0" ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "button" , {
className : "plain-text justify-start py-3" ,
onClick : ( ) => {
navigator . clipboard . writeText ( JSON . stringify ( entry ) ) . then ( ( ) => {
window . alert ( "Post Copied" ) ;
setOpenMore ( false ) ;
} ) ;
} ,
children : "Copy Object"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "hr" , {
className : "m-0"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "button" , {
className : "plain-text justify-start py-3" ,
onClick : ( ) => {
const txt = ( 0 , generateTypeDefinition /* default */ . Z ) ( {
paradigm : "JavaScript" ,
table ,
query ,
user
} ) ;
navigator . clipboard . writeText ( txt || "" ) . then ( ( ) => {
window . alert ( "JavaScript Type Definition Copied" ) ;
setOpenMore ( false ) ;
} ) ;
} ,
children : "Copy JS Type Definition"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "hr" , {
className : "m-0"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "button" , {
className : "plain-text justify-start py-3" ,
onClick : ( ) => {
const txt = ( 0 , generateTypeDefinition /* default */ . Z ) ( {
paradigm : "TypeScript" ,
table ,
query ,
user
} ) ;
navigator . clipboard . writeText ( txt || "" ) . then ( ( ) => {
window . alert ( "TypeScript Type Definition Copied" ) ;
setOpenMore ( false ) ;
} ) ;
} ,
children : "Copy TS Type Definition"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "hr" , {
className : "m-0"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "a" , {
href : url ,
className : "button plain-text justify-start py-3" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
children : "View Entry"
} )
} )
]
} )
} ) ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( "button" , {
onClick : ( ) => {
setOpenMore ( ! openMore ) ;
} ,
ref : openMoreButtonRef ,
className : "ghost p-2" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( external _lucide _react _ . Ellipsis , { } )
} )
} )
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
; // CONCATENATED MODULE: ./components/admin/databases/UpdateEntryForm.jsx
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* @ param { import ( "@/package-shared/types" ) . UserType } props . user
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } props . table
* @ param { import ( "@/package-shared/types" ) . DSQL _DatabaseSchemaType [ ] } [ props . dbSchemaData ]
* @ param { React . MutableRefObject < any [ ] > } props . richTextEditors
* @ param { React . MutableRefObject < any [ ] > } props . jsonTextEditors
* @ param { any [ ] } props . dataTypes
* @ param { any } [ props . entry ]
* @ param { boolean } [ props . entryPage ]
* @ param { any } [ props . confirmedDelegetedUser ]
* @ param { any } [ props . query ]
* / f u n c t i o n U p d a t e E n t r y F o r m ( { u s e r , d a t a b a s e , t a b l e , d b S c h e m a D a t a , r i c h T e x t E d i t o r s , j s o n T e x t E d i t o r s , d a t a T y p e s , e n t r y , e n t r y P a g e , c o n f i r m e d D e l e g e t e d U s e r , q u e r y , } ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / const filteredFields = table.fields.filter((field)=>field.fieldName && !field.fieldName.match(defaultFieldsRegexp/ * default * / . Z ) ) ;
const isUUID = table . fields . find ( ( field ) => field . fieldName === "uuid" ) ;
const isDelegated = confirmedDelegetedUser ? . delegated ;
const isTableEditable = confirmedDelegetedUser ? . priviledges ? . match ( /Edit Tables/i ) ;
const isTableDeletable = confirmedDelegetedUser ? . priviledges ? . match ( /Delete Tables/i ) ;
const isTableCreatable = confirmedDelegetedUser ? . priviledges ? . match ( /Create Tables/i ) ;
const areEntriesEditable = confirmedDelegetedUser ? . priviledges ? . match ( /Edit Entries/i ) ;
const areEntriesDeletable = confirmedDelegetedUser ? . priviledges ? . match ( /Delete Entries/i ) ;
////////////////////////////////////////
if ( isUUID ) {
filteredFields . unshift ( {
dataType : "UUID" ,
fieldName : "uuid" ,
defaultField : true
} ) ;
}
filteredFields . unshift ( {
dataType : "BIGINT" ,
fieldName : "id" ,
defaultField : true
} ) ;
filteredFields . push ( {
dataType : "VARCHAR(250)" ,
fieldName : "date_created" ,
defaultField : true
} ) ;
filteredFields . push ( {
dataType : "BIGINT" ,
fieldName : "date_created_code" ,
defaultField : true
} ) ;
filteredFields . push ( {
dataType : "TIMESTAMP" ,
fieldName : "date_created_timestamp" ,
defaultField : true
} ) ;
filteredFields . push ( {
dataType : "VARCHAR(250)" ,
fieldName : "date_updated" ,
defaultField : true
} ) ;
filteredFields . push ( {
dataType : "BIGINT" ,
fieldName : "date_updated_code" ,
defaultField : true
} ) ;
filteredFields . push ( {
dataType : "TIMESTAMP" ,
fieldName : "date_updated_timestamp" ,
defaultField : true
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / c o n s t [ l o a d i n g , s e t L o a d i n g ] = e x t e r n a l _ r e a c t _ d e f a u l t ( ) . u s e S t a t e ( f a l s e ) ;
const [ collapse , setCollapse ] = external _react _default ( ) . useState ( true ) ;
const [ activeEntry , setActiveEntry ] = external _react _default ( ) . useState ( entry ) ;
const [ openMore , setOpenMore ] = external _react _default ( ) . useState ( false ) ;
const openMoreButtonRef = external _react _default ( ) . useRef ( null ) ;
/** @type {React.MutableRefObject<import("@/package-shared/types").RichTextEditorsRefArray[]>} */ const currentRichTextEditorForms = external _react _default ( ) . useRef ( [ ] ) ;
const [ url , setUrl ] = external _react _default ( ) . useState ( ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /tables/ ${ table . tableName } /entries/ ${ activeEntry . id } ` ) ;
external _react _default ( ) . useEffect ( ( ) => {
if ( confirmedDelegetedUser ? . dbUserId && Number ( user . id ) !== Number ( confirmedDelegetedUser . dbUserId ) ) {
setUrl ( ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /tables/ ${ table . tableName } /entries/ ${ activeEntry . id } ` + window . location . search ) ;
}
} , [ ] ) ;
const formButtonId = ` ${ database . db _slug } - ${ table . tableName } - ${ activeEntry . id } -submit-button ` ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / ( 0 , j s x _ r u n t i m e _ . j s x s ) ( " d i v " , {
className : "card col w-full overflow-hidden" ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "a" , {
href : url ,
onClick : ( e ) => {
/** @type {HTMLElement} */ // @ts-ignore
const targetEl = e . target ;
if ( targetEl . closest ( ".cancel-link" ) || targetEl . closest ( ".MuiPopover-root" ) ) {
e . preventDefault ( ) ;
}
} ,
className : "w-full" ,
children : /*#__PURE__*/ ( 0 , jsx _runtime _ . 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 ) => {
/** @type {HTMLDivElement} */ // @ts-ignore
const divEl = e . target ;
if ( divEl . closest ( ".cancel-link" ) || divEl . closest ( ".MuiPopover-root" ) ) return ;
if ( e . ctrlKey ) {
window . open ( url , "__blank" ) ;
} else {
window . location . href = url ;
}
} ,
children : [
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "span" , {
children : [
"Entry #" ,
activeEntry . id
]
} ) ,
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "flex-wrap cancel-link" ,
children : [
( ! isDelegated || isDelegated && areEntriesDeletable ) && /*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "text-slate-300 hover:text-fuchsia-200 cursor-pointer" + ( loading ? " pointer-events-none opacity-40" : "" ) ,
onClick : ( e ) => {
if ( window . confirm ( ` Delete Entry # ${ activeEntry . id } ? ` ) ) {
setLoading ( true ) ;
( 0 , fetchApi /* default */ . Z ) ( "/api/deleteTableEntry" + window . location . search , {
method : "post" ,
body : {
dbFullName : database . db _full _name ,
tableName : table . tableName ,
entryId : activeEntry . id ,
dbSlug : database . db _slug ,
dbId : database . id ,
delegated : query ? . delegated ,
confirmedDelegetedUser
}
} , true ) . then ( ( res ) => {
if ( res . success ) {
( 0 , updateDiskUsage /* default */ . Z ) ( ) . then ( ( ) => {
window . location . reload ( ) ;
} ) ;
} else {
window . alert ( res . msg ) ;
setTimeout ( ( ) => {
setLoading ( false ) ;
} , 500 ) ;
}
} ) ;
}
} ,
children : "Delete Entry"
} ) ,
! entryPage && /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( ( external _react _default ( ) ) . Fragment , {
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "opacity-20" ,
children : "|"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "text-slate-300 hover:text-fuchsia-200 cursor-pointer" ,
onClick : ( e ) => {
if ( collapse ) {
setCollapse ( false ) ;
} else {
setCollapse ( true ) ;
}
} ,
children : collapse ? /*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
children : "Expand"
} ) : /*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
children : "Collapse"
} )
} )
]
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "opacity-20" ,
children : "|"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "button ghost px-0" ,
onClick : ( e ) => {
let duplicateEntry = external _lodash _default ( ) . cloneDeep ( entry ) ;
delete duplicateEntry [ "date_created" ] ;
delete duplicateEntry [ "date_created_code" ] ;
delete duplicateEntry [ "date_created_timestamp" ] ;
delete duplicateEntry [ "date_updated" ] ;
delete duplicateEntry [ "date_updated_code" ] ;
delete duplicateEntry [ "date_updated_timestamp" ] ;
delete duplicateEntry [ "id" ] ;
delete duplicateEntry [ "uuid" ] ;
localStorage . setItem ( "duplicate_entry" , JSON . stringify ( duplicateEntry ) ) ;
window . location . href = ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /tables/ ${ table . tableName } /entries/add-entry?duplicate=true&id= ${ entry . id } ` ;
} ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "text-slate-300" ,
children : "Duplicate"
} )
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "opacity-20" ,
children : "|"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( UpdateEntryMoreOptions , {
table ,
user ,
entry ,
query ,
url
} )
]
} )
]
} )
} ) ,
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "form" , {
className : "w-full flex flex-col items-stretch gap-8 minimal-scrollbars relative" ,
style : ! entryPage ? {
maxHeight : collapse ? "300px" : "none" ,
paddingTop : "10px" ,
paddingBottom : "10px" ,
overflow : "hidden"
} : { } ,
onSubmit : ( e ) => {
e . preventDefault ( ) ;
setLoading ( true ) ;
/** @type {any} */ let payload = { } ;
/** @type {HTMLFormElement} */ // @ts-ignore
const formEl = e . target ;
filteredFields . forEach ( ( field ) => {
if ( ! field . fieldName ) return ;
if ( ! formEl [ field . fieldName ] ) return ;
const isString = typeof formEl [ field . fieldName ] . value !== "string" ;
const isNumber = typeof formEl [ field . fieldName ] . value !== "number" ;
if ( ! isString && ! isNumber && ! formEl [ field . fieldName ] . value ) return ;
if ( formEl [ field . fieldName ] ? . dataset . default ) return ;
payload [ field . fieldName ] = formEl [ field . fieldName ] . value ;
} ) ;
if ( currentRichTextEditorForms . current [ 0 ] ) {
currentRichTextEditorForms . current . forEach ( ( /** @type {any} */ richTextObject ) => {
if ( ! richTextObject ? . fieldName || ! richTextObject ? . ref ? . current ) return ;
payload [ richTextObject . fieldName ] = richTextObject . ref . current . getContent ( ) ;
} ) ;
}
if ( jsonTextEditors . current [ 0 ] ) {
jsonTextEditors . current . forEach ( ( jsonEditor ) => {
if ( ! jsonEditor ? . fieldName || ! jsonEditor ? . ref ? . current ) return ;
payload [ jsonEditor . fieldName ] = jsonEditor . ref . current . getValue ( ) ;
} ) ;
}
( 0 , fetchApi /* default */ . Z ) ( "/api/updateTableEntry" , {
method : "post" ,
body : {
dbFullName : database . db _full _name ,
dbSlug : database . db _slug ,
dbId : database . id ,
tableName : table . tableName ,
entryId : activeEntry . id ,
payload : payload ,
tableSchema : table ,
delegated : query ? . delegated ,
confirmedDelegetedUser
}
} , true ) . then ( ( res ) => {
if ( res . success ) {
( 0 , fetchApi /* default */ . Z ) ( ` /api/refreshEntry?table= ${ table . tableName } &db= ${ database . db _full _name } &id= ${ activeEntry . id } &schema= ${ JSON . stringify ( table ) } ` ) . then ( ( _res ) => {
if ( _res . success ) {
setActiveEntry ( _res . entry ) ;
setTimeout ( ( ) => {
setLoading ( false ) ;
} , 500 ) ;
}
} ) ;
} else {
window . alert ( res . msg + "\n" + ( res . err || "" ) ) ;
setTimeout ( ( ) => {
setLoading ( false ) ;
} , 500 ) ;
}
} ) ;
} ,
onKeyUp : ( e ) => {
if ( e . ctrlKey && e . key == "Enter" ) {
const confirm = window . confirm ( "Update this Form?" ) ;
if ( ! confirm ) return ;
document . getElementById ( formButtonId ) ? . click ( ) ;
}
} ,
children : [
loading && /*#__PURE__*/ jsx _runtime _ . jsx ( LoadingBlock /* default */ . Z , { } ) ,
( collapse && ! entryPage ? filteredFields . slice ( 0 , 3 ) : filteredFields ) . map ( ( field , index ) => {
let dataTypeSchema = dataTypes . filter ( ( type ) => type . name === field . dataType ? . replace ( /\d|\(|\)/g , "" ) ) ;
return /*#__PURE__*/ jsx _runtime _ . jsx ( TableEntryField /* default */ . Z , {
fieldObject : field ,
dataTypeSchema : dataTypeSchema [ 0 ] ,
richTextEditors : richTextEditors ,
currentRichTextEditorForms : currentRichTextEditorForms ,
entry : activeEntry ,
query : query ,
entryPage : entryPage ,
confirmedDelegetedUser : confirmedDelegetedUser ,
jsonTextEditors : jsonTextEditors ,
formButtonId : formButtonId
} , index + 1 ) ;
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "button" , {
type : "submit" ,
className : "" + ( loading ? " pointer-events-none opacity-40" : "" ) ,
id : formButtonId ,
children : "Update Entry"
} )
]
} ) ,
! entryPage && /*#__PURE__*/ jsx _runtime _ . jsx ( ExpandBlock /* default */ . Z , {
collapse : collapse ,
setCollapse : setCollapse
} )
]
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ } ) ,
/***/ 2348 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ "Z" : ( ) => ( /* binding */ FormRadios )
/* harmony export */ } ) ;
/* harmony import */ var react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 997 ) ;
/* harmony import */ var react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 6689 ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ ) ;
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* @ param { {
* title : string ,
* payload : string | boolean ,
* default ? : boolean ,
* jsx ? : React . ReactNode ,
* onChangeHandler ? : ( e : any ) => void ,
* } [ ] } props . radioValues - array of objects
* @ param { string } props . name - form radios collective name
* @ param { ( e : any ) => void } [ props . onChangeHandler ] - when radios change
* @ param { React . Dispatch < React . SetStateAction < any >> } [ props . setAlert ] - set an external alert dispatch
* @ param { boolean } [ props . flexRow ] - if the radio and label are stacked on each other or side - by - side
* @ param { string } [ props . labelColor ] - Label color using tailwind syntax
* @ param { boolean } [ props . baseText ] - Font size regular
* @ param { boolean } [ props . smallText ] - Font size smaller
* @ param { string } [ props . className ] - Additional class names for the wrapper
* / f u n c t i o n F o r m R a d i o s ( { r a d i o V a l u e s , n a m e , o n C h a n g e H a n d l e r , s e t A l e r t , f l e x R o w , l a b e l C o l o r , b a s e T e x t , s m a l l T e x t , c l a s s N a m e , } ) {
try {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / r e a c t _ j s x _ r u n t i m e _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 0 _ _ . j s x ( " d i v " , {
className : "flex items-start gap-4 flex-wrap " + ( flexRow ? "" : " flex-col " ) + ( className ? className : "" ) ,
children : radioValues . map ( ( value , index ) => {
const { payload , title , jsx } = value ;
const radioPayload = payload === false ? payload : payload ? payload : title ? title : null ;
return /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "flex items-center gap-2" ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "input" , {
className : "m-0" + ( baseText ? " w-5 h-5" : smallText ? " w-4 h-4" : " w-6 h-6" ) ,
type : "radio" ,
defaultChecked : value . default ? true : false ,
name : name ,
id : name + "_" + radioPayload ,
onChange : ( e ) => {
if ( setAlert ) setAlert ( null ) ;
if ( value . onChangeHandler ) {
value . onChangeHandler ( e ) ;
} else if ( onChangeHandler ) {
onChangeHandler ( e ) ;
}
} ,
value : typeof radioPayload == "string" ? radioPayload : undefined
} ) ,
jsx ? jsx : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "label" , {
htmlFor : name + "_" + radioPayload ,
className : "text-lg m-0 " + ( labelColor ? labelColor : "text-slate-800" ) + ( baseText ? " text-base" : smallText ? " text-sm" : " text-lg" ) ,
children : title
} )
]
} , index + 1 ) ;
} )
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch ( error ) {
console . log ( "ERROR in FormRadio =>" , error ) ;
return /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "div" , {
children : "Form Radio Error"
} ) ;
}
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
/***/ } ) ,
/***/ 7722 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
"TableEntriesContext" : ( ) => ( /* binding */ TableEntriesContext ) ,
"default" : ( ) => ( /* binding */ TableEntries ) ,
"getServerSideProps" : ( ) => ( /* binding */ getServerSideProps )
} ) ;
// EXTERNAL MODULE: external "react/jsx-runtime"
var jsx _runtime _ = _ _webpack _require _ _ ( 997 ) ;
// EXTERNAL MODULE: external "react"
var external _react _ = _ _webpack _require _ _ ( 6689 ) ;
var external _react _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _react _ ) ;
// EXTERNAL MODULE: ./functions/backend/userAuth.js
var userAuth = _ _webpack _require _ _ ( 370 ) ;
var userAuth _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( userAuth ) ;
// EXTERNAL MODULE: ./layouts/AdminLayout.jsx + 2 modules
var AdminLayout = _ _webpack _require _ _ ( 4858 ) ;
// EXTERNAL MODULE: ./components/general/BackButton.jsx
var BackButton = _ _webpack _require _ _ ( 1781 ) ;
// EXTERNAL MODULE: ./components/general/Breadcrumbs.jsx
var Breadcrumbs = _ _webpack _require _ _ ( 424 ) ;
// EXTERNAL MODULE: ./components/general/CopySlug.jsx
var CopySlug = _ _webpack _require _ _ ( 9230 ) ;
// EXTERNAL MODULE: ./components/admin/databases/TableEntriesList.jsx + 1 modules
var TableEntriesList = _ _webpack _require _ _ ( 6122 ) ;
// EXTERNAL MODULE: ./components/general/ActiveCloneDbBanner.jsx
var ActiveCloneDbBanner = _ _webpack _require _ _ ( 4986 ) ;
// EXTERNAL MODULE: ./components/general/ActiveCloneTableBanner.jsx
var ActiveCloneTableBanner = _ _webpack _require _ _ ( 8515 ) ;
// EXTERNAL MODULE: ./components/admin/databases/DatabasesTablesList.jsx
var DatabasesTablesList = _ _webpack _require _ _ ( 8264 ) ;
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
var LoadingBlock = _ _webpack _require _ _ ( 5264 ) ;
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
var fetchApi = _ _webpack _require _ _ ( 6729 ) ;
// EXTERNAL MODULE: external "lodash"
var external _lodash _ = _ _webpack _require _ _ ( 6517 ) ;
// EXTERNAL MODULE: ./components/admin/databases/ImportExportEntries.jsx + 1 modules
var ImportExportEntries = _ _webpack _require _ _ ( 2943 ) ;
// EXTERNAL MODULE: ./components/admin/databases/MoreTableOptions.jsx
var MoreTableOptions = _ _webpack _require _ _ ( 3684 ) ;
; // CONCATENATED MODULE: ./components/admin/databases/TableEntriesContent.jsx
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ const BATCH _NO = 20 ;
/** @type {any} */ let refreshTimeout ;
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* / f u n c t i o n T a b l e E n t r i e s C o n t e n t ( p r o p s ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / c o n s t { u s e r , d a t a b a s e , t a b l e , d b S c h e m a D a t a , s e t T a r g e t E n t r y , r i c h T e x t E d i t o r s , j s o n T e x t E d i t o r s , q u e r y , c o n f i r m e d D e l e g e t e d U s e r , a c t i v e E n t r i e s , e n t r i e s C o u n t , s e t A c t i v e E n t r i e s , } = e x t e r n a l _ r e a c t _ d e f a u l t ( ) . u s e C o n t e x t ( T a b l e E n t r i e s C o n t e x t ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / c o n s t d a t a T y p e s = _ _ w e b p a c k _ r e q u i r e _ _ ( 9 5 9 4 ) ;
const isDelegated = confirmedDelegetedUser ? . delegated ;
const isTableEditable = confirmedDelegetedUser ? . priviledges ? . match ( /Edit Tables/i ) ;
const isTableDeletable = confirmedDelegetedUser ? . priviledges ? . match ( /Delete Tables/i ) ;
const isTableCreatable = confirmedDelegetedUser ? . priviledges ? . match ( /Create Tables/i ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / ( 0 , j s x _ r u n t i m e _ . j s x s ) ( ( e x t e r n a l _ r e a c t _ d e f a u l t ( ) ) . F r a g m e n t , {
children : [
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "flex-col items-start gap-0 w-full relative z-50" ,
children : [
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "w-full justify-between flex-wrap" ,
children : [
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "flex-wrap" ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( BackButton /* default */ . Z , { } ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "h1" , {
className : "text-3xl m-0" ,
children : /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "span" , {
className : "flex items-center flex-wrap gap-2" ,
children : [
"All Entries In" ,
" " ,
/*#__PURE__*/ ( 0 , jsx _runtime _ . 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 : [
table . tableFullName ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "absolute -top-5 -right-4" ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( CopySlug /* default */ . Z , {
slugText : table . tableName ,
justIcon : true
} )
} )
]
} ) ,
" " ,
"Table"
]
} )
} )
]
} ) ,
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "div" , {
className : "w-full sm:w-auto" ,
children : [
/*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /tables/ ${ table . tableName } /entries/add-entry ` ,
className : "button flex items-center gap-2 w-full sm:w-auto justify-center" ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
className : "symbol" ,
children : "+"
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "span" , {
children : "Add New Entry"
} )
]
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( ImportExportEntries /* default */ . Z , {
database ,
table
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( MoreTableOptions /* default */ . Z , {
database ,
table ,
dbSchemaData ,
query
} )
]
} )
]
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( Breadcrumbs /* default */ . Z , {
confirmedDelegetedUser : query ? . delegated ,
user : user
} )
]
} ) ,
database . active _clone ? /*#__PURE__*/ jsx _runtime _ . jsx ( ActiveCloneDbBanner /* default */ . Z , {
database : database ,
user : user
} ) : /*#__PURE__*/ jsx _runtime _ . jsx ( jsx _runtime _ . Fragment , { } ) ,
database . remote _connected ? /*#__PURE__*/ jsx _runtime _ . jsx ( DatabasesTablesList /* ConnectedDatabaseBanner */ . w , {
database : database
} ) : /*#__PURE__*/ jsx _runtime _ . jsx ( jsx _runtime _ . Fragment , { } ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( ActiveCloneTableBanner /* default */ . Z , {
table : table ,
database : database ,
user : user
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( TableEntriesList /* default */ . Z , {
user : user ,
entries : activeEntries ,
database : database ,
table : table ,
setTargetEntry : setTargetEntry ,
dbSchemaData : dbSchemaData ,
richTextEditors : richTextEditors ,
dataTypes : dataTypes ,
query : query ,
confirmedDelegetedUser : confirmedDelegetedUser ,
jsonTextEditors : jsonTextEditors ,
search : true
} ) ,
entriesCount > BATCH _NO && /*#__PURE__*/ jsx _runtime _ . jsx ( InfiniteScroll , {
activeEntries ,
setActiveEntries ,
database ,
table ,
entriesCount
} )
]
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
*
* @ param { object } props
* @ param { any [ ] | null } props . activeEntries
* @ param { React . Dispatch < React . SetStateAction < any [ ] | null >> } props . setActiveEntries
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } props . table
* @ param { number } props . entriesCount
* @ returns
* / f u n c t i o n I n f i n i t e S c r o l l ( { a c t i v e E n t r i e s , s e t A c t i v e E n t r i e s , d a t a b a s e , t a b l e , e n t r i e s C o u n t , } ) {
const context = external _react _default ( ) . useContext ( TableEntriesContext ) ;
/** @type {React.RefObject<HTMLDivElement>} */ // @ts-ignore
const infiniteScrollRef = external _react _default ( ) . useRef ( ) ;
const pageRef = external _react _default ( ) . useRef ( 1 ) ;
const totalEntriesDisplayed = BATCH _NO * Number ( pageRef . current ) ;
const exhausted = Boolean ( totalEntriesDisplayed >= entriesCount ) ;
external _react _default ( ) . useEffect ( ( ) => {
/** @type {IntersectionObserverCallback} */ function ISObserverCb ( entries , observer ) {
if ( entries ? . [ 0 ] ? . isIntersecting ) {
/** @type {HTMLInputElement | null} */ // @ts-ignore
const searchInput = document . getElementById ( "entries-search-input" ) ;
/** @type {HTMLInputElement | null} */ // @ts-ignore
const searchField = document . getElementById ( "entries-search-field-select" ) ;
/** @type {import("@/pages/api/infiniteScroll").InfiniteScrollBodyObject} */ const fetchObject = {
tableName : table . tableName ,
dbName : database . db _slug ,
page : pageRef . current ,
tableSchema : table ,
search : searchInput ? searchInput . value : undefined ,
searchField : searchField ? searchField . value : undefined ,
delegated : Boolean ( context . query . delegated )
} ;
( 0 , fetchApi /* default */ . Z ) ( "/api/infiniteScroll" , {
method : "POST" ,
body : fetchObject
} , true ) . then ( ( /** @type {import("@/pages/api/infiniteScroll").InfiniteScrollAPIRes} */ res ) => {
if ( ! res . success ) {
return ;
}
if ( res . page ) {
pageRef . current = res . page ;
}
window . clearTimeout ( refreshTimeout ) ;
refreshTimeout = setTimeout ( ( ) => {
if ( ! res . data ? . [ 0 ] ) return ;
if ( res . data ? . [ 0 ] ) {
setActiveEntries ( ( prev ) => {
if ( ! prev ) {
return null ;
}
return [
... prev ,
// @ts-ignore
... res . data ,
] ;
} ) ;
}
} , 500 ) ;
} ) . catch ( ( err ) => {
console . log ( "Infinite Scroll Error =>" , err ) ;
} ) . finally ( ( ) => {
console . log ( "Infinite Scroll Done. Page" , pageRef . current ) ;
} ) ;
}
}
/** @type {IntersectionObserverInit} */ const ISObserverOptions = {
rootMargin : "0px 0px 0px 0px"
} ;
setTimeout ( ( ) => {
requestAnimationFrame ( ( ) => {
const infiniteScrollObserver = new IntersectionObserver ( ISObserverCb , ISObserverOptions ) ;
if ( infiniteScrollRef . current ) infiniteScrollObserver . observe ( infiniteScrollRef . current ) ;
} ) ;
} , 1000 ) ;
} , [ ] ) ;
if ( exhausted ) {
return /*#__PURE__*/ jsx _runtime _ . jsx ( ( external _react _default ( ) ) . Fragment , { } ) ;
}
return /*#__PURE__*/ jsx _runtime _ . jsx ( "div" , {
className : "w-full flex items-center justify-center" ,
ref : infiniteScrollRef ,
children : /*#__PURE__*/ jsx _runtime _ . jsx ( LoadingBlock /* default */ . Z , {
position : "relative" ,
style : {
backgroundColor : "transparent"
} ,
width : "20px"
} )
} ) ;
}
// EXTERNAL MODULE: ./components/general/ExtraContentDatabase.jsx
var ExtraContentDatabase = _ _webpack _require _ _ ( 4941 ) ;
// EXTERNAL MODULE: ./package-shared/functions/backend/varDatabaseDbHandler.js
var varDatabaseDbHandler = _ _webpack _require _ _ ( 1206 ) ;
var varDatabaseDbHandler _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( varDatabaseDbHandler ) ;
// EXTERNAL MODULE: ./functions/backend/grabDelegatedUserFromCookie.js
var grabDelegatedUserFromCookie = _ _webpack _require _ _ ( 5116 ) ;
var grabDelegatedUserFromCookie _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( grabDelegatedUserFromCookie ) ;
// EXTERNAL MODULE: ./functions/backend/serverError.js
var serverError = _ _webpack _require _ _ ( 2317 ) ;
var serverError _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( serverError ) ;
// EXTERNAL MODULE: ./package-shared/utils/backend/global-db/DB_HANDLER.js
var DB _HANDLER = _ _webpack _require _ _ ( 9395 ) ;
var DB _HANDLER _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( DB _HANDLER ) ;
// EXTERNAL MODULE: ./layouts/components/GeneralLayout/ScrollToTopButton.jsx
var ScrollToTopButton = _ _webpack _require _ _ ( 9360 ) ;
; // CONCATENATED MODULE: ./pages/admin/[user_id]/databases/[single]/tables/[single_table]/entries/index.jsx
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
const fs = _ _webpack _require _ _ ( 7147 ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ****************************************************************************** */ /** @type {import("@/package-shared/types").TableEntriesContextType} */ // @ts-ignore
const init = { } ;
const TableEntriesContext = /*#__PURE__*/ external _react _default ( ) . createContext ( init ) ;
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* @ param { import ( "@/package-shared/types" ) . UserType } props . user
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { import ( "@/package-shared/types" ) . DSQL _TableSchemaType } props . table
* @ param { import ( "@/package-shared/types" ) . DSQL _DatabaseSchemaType [ ] } props . dbSchemaData
* @ param { any [ ] } props . entries
* @ param { any } props . query
* @ param { any } props . confirmedDelegetedUser
* @ param { number } props . entriesCount
* / f u n c t i o n T a b l e E n t r i e s ( { u s e r , d a t a b a s e , t a b l e , d b S c h e m a D a t a , e n t r i e s , q u e r y , c o n f i r m e d D e l e g e t e d U s e r , e n t r i e s C o u n t , } ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / c o n s t p a g e T i t l e = ` $ { t a b l e . t a b l e F u l l N a m e } T a b l e E n t r i e s | D a t a s q u i r e l ` ;
const pageDescription = "All Entries in table" ;
let head = /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( jsx _runtime _ . Fragment , {
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( "title" , {
children : pageTitle
} ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( "meta" , {
name : "description" ,
content : pageDescription
} )
]
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / c o n s t [ t a r g e t E n t r y , s e t T a r g e t E n t r y ] = e x t e r n a l _ r e a c t _ d e f a u l t ( ) . u s e S t a t e ( n u l l ) ;
/** @type {[ state: any[] | null, dispatch: React.Dispatch<React.SetStateAction<any[] | null>> ]} */ // @ts-ignore
const [ activeEntries , setActiveEntries ] = external _react _default ( ) . useState ( entries ) ;
const targetField = external _react _default ( ) . useRef ( "title" ) ;
const searchTerm = external _react _default ( ) . useRef ( null ) ;
/** @type {React.MutableRefObject<any[]>} */ const richTextEditors = external _react _default ( ) . useRef ( [ ] ) ;
/** @type {React.MutableRefObject<any[]>} */ const jsonTextEditors = external _react _default ( ) . useRef ( [ ] ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / jsx_runtime_.jsx(AdminLayout/ * default * / . Z , {
head : head ,
user : user ,
extraHeaderContent : /*#__PURE__*/ jsx _runtime _ . jsx ( ExtraContentDatabase /* default */ . Z , {
database : database ,
query : query ,
confirmedDelegetedUser : confirmedDelegetedUser ,
user : user
} ) ,
children : /*#__PURE__*/ ( 0 , jsx _runtime _ . jsxs ) ( TableEntriesContext . Provider , {
value : {
user ,
database ,
table ,
dbSchemaData ,
entries ,
targetEntry ,
setTargetEntry ,
richTextEditors ,
jsonTextEditors ,
query ,
confirmedDelegetedUser ,
activeEntries ,
setActiveEntries ,
targetField ,
searchTerm ,
entriesCount
} ,
children : [
/*#__PURE__*/ jsx _runtime _ . jsx ( TableEntriesContent , { } ) ,
/*#__PURE__*/ jsx _runtime _ . jsx ( ScrollToTopButton /* default */ . Z , {
snug : true
} )
]
} )
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Server Side Props or Static Props
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ type { import ( "next" ) . GetServerSideProps }
* / a s y n c f u n c t i o n g e t S e r v e r S i d e P r o p s ( { r e q , r e s , q u e r y } ) {
/ * *
* User Auth
*
* @ description User Auth
* / c o n s t u s e r = a w a i t u s e r A u t h _ d e f a u l t ( ) ( r e q , r e s ) ;
if ( ! user ? . logged _in _status ) {
return {
redirect : {
destination : "/login" ,
permanent : false
}
} ;
}
try {
/ * *
* Check delegated user token
*
* @ description Check delegated user token
* / / * * @ type { string } * / / / @ ts - ignore
const slug = query . single ;
const dbUserData = await grabDelegatedUserFromCookie _default ( ) ( {
request : req ,
user : user ,
databaseSlug : slug ,
query
} ) ;
const dbUserDataObj = dbUserData ;
if ( ! dbUserDataObj ) {
throw new Error ( "No Db Object Found!" ) ;
}
const { dbUserId } = dbUserDataObj ;
/ * *
* Page / Site Data Data Fetching
*
* @ description Fetch data on the server before returning
* / c o n s t d a t a b a s e = a w a i t D B _ H A N D L E R _ d e f a u l t ( ) ( ` S E L E C T * F R O M u s e r _ d a t a b a s e s W H E R E u s e r _ i d = ' $ { d b U s e r I d } ' A N D d b _ s l u g = ' $ { q u e r y . s i n g l e } ' ` ) ;
if ( ! database || ! database [ 0 ] ) {
return {
redirect : {
destination : ` /admin/ ${ user ? . id } /databases ` ,
permanent : false
}
} ;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Confirm delegated User
*
* @ description Confirm delegated User
* / l e t c o n f i r m e d D e l e g e t e d U s e r = d b U s e r D a t a ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Page / Site Data Data Fetching
*
* @ description Fetch data on the server before returning
2024-11-05 14:18:40 +00:00
* / / * * @ type { import ( "@/package-shared/types" ) . DSQL _DatabaseSchemaType [ ] } * / c o n s t d b S c h e m a D a t a = J S O N . p a r s e ( f s . r e a d F i l e S y n c ( ` $ { p r o c e s s . e n v . D S Q L _ U S E R _ D B _ S C H E M A _ P A T H } / u s e r - $ { d b U s e r I d } / m a i n . j s o n ` , " u t f - 8 " ) ) ;
2024-11-05 11:12:42 +00:00
const tables = dbSchemaData . filter ( ( db ) => db . dbFullName === database [ 0 ] . db _full _name ) [ 0 ] ? . tables ;
const targetTable = tables . filter ( ( table ) => table . tableName === query . single _table ) [ 0 ] ;
const tableEntries = await varDatabaseDbHandler _default ( ) ( {
database : database [ 0 ] . db _full _name ,
queryString : ` SELECT * FROM \` ${ targetTable . tableName } \` ORDER BY id DESC LIMIT 20 ` ,
tableSchema : targetTable
} ) ;
const tableEntriesCount = await varDatabaseDbHandler _default ( ) ( {
database : database [ 0 ] . db _full _name ,
queryString : ` SELECT COUNT(id) AS count FROM ${ targetTable . tableName } ` ,
tableSchema : targetTable
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Server props return
*
* @ description Return data fetched on the server side
* / r e t u r n {
props : {
user : user ,
database : database [ 0 ] ,
table : targetTable ,
dbSchemaData : dbSchemaData ,
entries : tableEntries ,
query ,
confirmedDelegetedUser ,
entriesCount : tableEntriesCount ? . [ 0 ] ? . count || 0
}
} ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch ( /** @type {any} */ error ) {
serverError _default ( ) ( {
component : "[single_table]/entries-page-component/getServerSideProps/catch-error" ,
message : error . message ,
user : user
} ) ;
return {
// redirect: {
// destination: "/login",
// permanent: false
// },
props : {
user : user ,
database : null ,
table : null ,
entries : [ ]
}
} ;
}
}
/***/ } )
} ;
;