2024-11-05 11:12:42 +00:00
"use strict" ;
exports . id = 4941 ;
exports . ids = [ 4941 ] ;
exports . modules = {
/***/ 9230 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ "Z" : ( ) => ( /* binding */ CopySlug )
/* 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 _mui _icons _material _CopyAllTwoTone _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _ ( 5050 ) ;
/* harmony import */ var _mui _icons _material _CopyAllTwoTone _ _WEBPACK _IMPORTED _MODULE _2 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _mui _icons _material _CopyAllTwoTone _ _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 _ _ ) ;
// @ts-check
/ * *
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { {
* slugText : string ,
* justIcon ? : boolean ,
* title ? : string ,
* outlined ? : boolean ,
* } } props - React component props including { children }
* / f u n c t i o n C o p y S l u g ( { s l u g T e x t , j u s t I c o n , t i t l e , o u t l i n e d } ) {
return /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "button small-text" + ( outlined ? " outlined gray bg-white" : " ghost light-gray" ) ,
onClick : ( e ) => {
navigator . clipboard . writeText ( slugText ) . then ( ( ) => {
alert ( ` Copied: " ${ slugText } " ` ) ;
} ) ;
} ,
style : outlined ? undefined : {
padding : 0
} ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( lucide _react _ _WEBPACK _IMPORTED _MODULE _3 _ _ . Copy , {
size : outlined ? 15 : 20
} ) ,
! justIcon && /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
className : "text-slate-500 dark:text-slate-300" ,
children : title ? title : "Copy Slug"
} )
]
} ) ;
}
/***/ } ) ,
/***/ 4941 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ "Z" : ( ) => ( /* binding */ ExtraContentDatabase )
/* 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 _CopySlug _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _ ( 9230 ) ;
/* harmony import */ var _mui _icons _material _CodeRounded _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _ ( 3849 ) ;
/* harmony import */ var _mui _icons _material _CodeRounded _ _WEBPACK _IMPORTED _MODULE _3 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _mui _icons _material _CodeRounded _ _WEBPACK _IMPORTED _MODULE _3 _ _ ) ;
/* harmony import */ var _DiskUsageComponent _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _ ( 6355 ) ;
/* harmony import */ var _functions _frontend _downloadApiStream _ _WEBPACK _IMPORTED _MODULE _10 _ _ = _ _webpack _require _ _ ( 7851 ) ;
/* harmony import */ var _mui _icons _material _SendToMobileTwoTone _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _ ( 6500 ) ;
/* harmony import */ var _mui _icons _material _SendToMobileTwoTone _ _WEBPACK _IMPORTED _MODULE _5 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _mui _icons _material _SendToMobileTwoTone _ _WEBPACK _IMPORTED _MODULE _5 _ _ ) ;
/* harmony import */ var _mui _icons _material _SummarizeTwoTone _ _WEBPACK _IMPORTED _MODULE _6 _ _ = _ _webpack _require _ _ ( 7428 ) ;
/* harmony import */ var _mui _icons _material _SummarizeTwoTone _ _WEBPACK _IMPORTED _MODULE _6 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _mui _icons _material _SummarizeTwoTone _ _WEBPACK _IMPORTED _MODULE _6 _ _ ) ;
/* harmony import */ var _mui _icons _material _TipsAndUpdatesTwoTone _ _WEBPACK _IMPORTED _MODULE _7 _ _ = _ _webpack _require _ _ ( 507 ) ;
/* harmony import */ var _mui _icons _material _TipsAndUpdatesTwoTone _ _WEBPACK _IMPORTED _MODULE _7 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _mui _icons _material _TipsAndUpdatesTwoTone _ _WEBPACK _IMPORTED _MODULE _7 _ _ ) ;
/* harmony import */ var _functions _frontend _fetchApi _ _WEBPACK _IMPORTED _MODULE _11 _ _ = _ _webpack _require _ _ ( 6729 ) ;
/* harmony import */ var _LoadingBlock _ _WEBPACK _IMPORTED _MODULE _8 _ _ = _ _webpack _require _ _ ( 5264 ) ;
/* harmony import */ var lucide _react _ _WEBPACK _IMPORTED _MODULE _9 _ _ = _ _webpack _require _ _ ( 2423 ) ;
/* harmony import */ var lucide _react _ _WEBPACK _IMPORTED _MODULE _9 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( lucide _react _ _WEBPACK _IMPORTED _MODULE _9 _ _ ) ;
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - Server props
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { any } [ props . query ]
* @ param { any } [ props . confirmedDelegetedUser ]
* @ param { import ( "@/package-shared/types" ) . UserType } props . user
* / f u n c t i o n E x t r a C o n t e n t D a t a b a s e ( { d a t a b a s e , 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 , u s e r , } ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / c o n s t { a c t i v e _ c l o n e , a c t i v e _ c l o n e _ p a r e n t _ d b } = d a t a b a s e ;
const isDelegated = confirmedDelegetedUser ? . delegated ;
const isTableEditable = confirmedDelegetedUser ? . priviledges ? . match ( /Edit Tables/i ) ;
const isTableDeletable = confirmedDelegetedUser ? . priviledges ? . match ( /Delete Tables/i ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / c o n s t [ l i n k s , s e t L i n k s ] = r e a c t _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 1 _ _ _ d e f a u l t ( ) . u s e S t a t e ( n u l l ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / ( 0 , 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 s ) ( " d i v " , {
className : "flex-wrap justify-center gap-4" ,
children : [
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "dropdown-wrapper gap-4" ,
children : [
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "relative" ,
children : [
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "w-8 h-8 relative" ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "img" , {
src : database . db _image ,
alt : "Database Image" ,
width : 20 ,
className : "w-full h-full rounded-full object-cover"
} ) ,
confirmedDelegetedUser ? . delegated && /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : " absolute -bottom-2 left-5 gap-1" ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "img" , {
src : confirmedDelegetedUser . rootUserImage ,
alt : "Root User Image" ,
className : "w-5 h-5 rounded-full object-cover border-2 border-white dark:border-slate-800 border-solid"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
className : "text-xs" ,
children : confirmedDelegetedUser . rootUserEmail
} )
]
} )
]
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
className : "font-semibold text-base" + ( confirmedDelegetedUser ? . delegated ? " -mt-3" : "" ) ,
children : database . db _name
} )
]
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( lucide _react _ _WEBPACK _IMPORTED _MODULE _9 _ _ . ChevronDown , {
size : 20
} ) ,
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "dropdown p-0" ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "m-0"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /edit-database ` ,
className : "button plain-text more-padding normal-weight" ,
children : "Edit Database"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "m-0"
} ) ,
! active _clone && /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . Fragment ) , {
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/add-database?duplicate= ${ database . db _full _name } ` ,
className : "button plain-text more-padding normal-weight" ,
children : "Duplicate Database"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "m-0"
} )
]
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /schema ` ,
className : "button plain-text more-padding normal-weight" ,
children : "Schema"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "m-0"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /users ` ,
className : "button plain-text more-padding normal-weight" ,
children : "Database Users"
} ) ,
! isDelegated && /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( NonDelegatedSection , {
database : database ,
user : user
} )
]
} )
]
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "vertical"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _CopySlug _ _WEBPACK _IMPORTED _MODULE _2 _ _ /* ["default"] */ . Z , {
slugText : database . db _slug ,
2024-11-06 06:52:57 +00:00
title : ` Db Slug `
} ) ,
true && /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "div" , {
className : "-mt-1 gap-1" ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _CopySlug _ _WEBPACK _IMPORTED _MODULE _2 _ _ /* ["default"] */ . Z , {
slugText : database . db _full _name ,
title : "Full DB Name"
} )
2024-11-05 11:12:42 +00:00
} ) ,
! isDelegated && /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . Fragment ) , {
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "vertical"
} ) ,
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /shell ` ,
className : "button ghost small-text" ,
style : {
height : "30px" ,
padding : 0
} ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( lucide _react _ _WEBPACK _IMPORTED _MODULE _9 _ _ . SquareTerminal , {
size : 20
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
className : "text-sm font-semibold" ,
children : "Shell"
} )
]
} )
]
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "vertical"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _DiskUsageComponent _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* ["default"] */ . Z , { } )
]
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* # # Buttons for Database Root Owner
* @ param { object } props
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* @ param { import ( "@/package-shared/types" ) . UserType } props . user
* / f u n c t i o n N o n D e l e g a t e d S e c t i o n ( { d a t a b a s e , u s e r } ) {
const [ loading , setLoading ] = react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . useState ( false ) ;
/** @type {React.RefObject<HTMLInputElement>} */ // @ts-ignore
const uploadSchemaButtonRef = react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . useRef ( ) ;
return /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . Fragment ) , {
children : [
loading && /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _LoadingBlock _ _WEBPACK _IMPORTED _MODULE _8 _ _ /* ["default"] */ . Z , {
width : "20px"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "m-0"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /shell ` ,
className : "button plain-text more-padding normal-weight" ,
children : "Shell"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "m-0"
} ) ,
database ? . remote _connected == 1 ? /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( DisconnectButton , {
database : database
} ) : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "a" , {
href : ` /admin/ ${ user ? . id } /databases/ ${ database . db _slug } /connect ` ,
className : "button plain-text more-padding normal-weight" ,
children : "Connect"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "hr" , {
className : "m-0"
} ) ,
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "button" , {
className : "button plain-text more-padding normal-weight w-full" ,
onClick : ( e ) => {
( 0 , _functions _frontend _downloadApiStream _ _WEBPACK _IMPORTED _MODULE _10 _ _ /* ["default"] */ . Z ) ( {
url : ` /api/exportDatabase?dbName= ${ database . db _full _name } ` ,
fileName : ` ${ database . db _full _name } .sql `
} ) ;
} ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( ( _mui _icons _material _SendToMobileTwoTone _ _WEBPACK _IMPORTED _MODULE _5 _ _ _default ( ) ) , {
fontSize : "small" ,
color : "action" ,
className : "opacity-50"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
children : "Export Database"
} )
]
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "input" , {
type : "file" ,
name : "upload-update-schema" ,
id : "" ,
ref : uploadSchemaButtonRef ,
className : "hidden"
} ) ,
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "button" , {
className : "button green outlined more-padding normal-weight w-full rounded-none -mb-[1px]" ,
onClick : ( e ) => {
if ( ! uploadSchemaButtonRef . current ) return ;
uploadSchemaButtonRef . current . addEventListener ( "change" , ( e ) => {
/ * *
* @ type { HTMLInputElement }
* / / / @ ts - ignore
const inputEl = e . target ;
const file = inputEl . files ? . [ 0 ] ;
if ( ! file ) {
alert ( "No File Selected" ) ;
return ;
}
var reader = new FileReader ( ) ;
reader . onload = function ( ev ) {
var fileContent = ev . target ? . result ;
if ( ! fileContent ) {
alert ( "Invalid File!" ) ;
}
try {
const fileContentString = fileContent ? . toString ( ) ;
if ( ! fileContentString ) {
throw new Error ( "Invalid File!" ) ;
}
const schemaObject = JSON . parse ( fileContentString ) ;
if ( window . confirm ( "Are you sure you want to use this schema file for the current database?" ) ) {
if ( window . confirm ( "Remember if any existing table doesn't exist in the new schema file that table and all its content will be erased forever. Continue?" ) ) {
setLoading ( true ) ;
( 0 , _functions _frontend _fetchApi _ _WEBPACK _IMPORTED _MODULE _11 _ _ /* ["default"] */ . Z ) ( "/api/user-schema/replace-database-schema" , {
method : "POST" ,
body : {
schema : schemaObject ,
dbId : database . id
}
} , true ) . then ( ( res ) => {
if ( res . success ) {
window . location . reload ( ) ;
}
} ) . finally ( ( ) => {
setLoading ( false ) ;
} ) ;
}
}
} catch ( /** @type {any} */ error ) {
alert ( "Invalid File. Please enter a valid JSON file" ) ;
}
} ;
reader . readAsText ( file ) ;
// if (window.confirm("Update?")) {
// console.log("Updating");
// }
} ) ;
uploadSchemaButtonRef . current ? . click ( ) ;
} ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( ( _mui _icons _material _TipsAndUpdatesTwoTone _ _WEBPACK _IMPORTED _MODULE _7 _ _ _default ( ) ) , {
fontSize : "small" ,
color : "action" ,
className : "opacity-50 text-inherit"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
children : "Update From Schema"
} )
]
} ) ,
/*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "button" , {
className : "button secondary outlined more-padding normal-weight w-full rounded-none" ,
onClick : ( e ) => {
( 0 , _functions _frontend _downloadApiStream _ _WEBPACK _IMPORTED _MODULE _10 _ _ /* ["default"] */ . Z ) ( {
url : ` /api/downloadDatabaseSchema?dbName= ${ database . db _full _name } ` ,
fileName : ` ${ database . db _full _name } .json `
} ) ;
// fetchApi(`/api/downloadDatabaseSchema?dbName=${database.db_full_name}`).then((res)=>{
// console.log(res);
// })
} ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( ( _mui _icons _material _SummarizeTwoTone _ _WEBPACK _IMPORTED _MODULE _6 _ _ _default ( ) ) , {
fontSize : "small" ,
color : "action" ,
className : "opacity-50 text-inherit"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
children : "Download Schema"
} )
]
} )
]
} ) ;
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* # # # Disconnect Remote Db Button
* @ param { object } props
* @ param { import ( "@/package-shared/types" ) . DSQL _MYSQL _user _databases _Type } props . database
* / f u n c t i o n D i s c o n n e c t B u t t o n ( { d a t a b a s e } ) {
return /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "button" , {
className : "button plain-text more-padding normal-weight w-full" ,
onClick : ( e ) => {
if ( ! window . confirm ( "Disconnect this Database from the remote host?" ) ) return ;
( 0 , _functions _frontend _fetchApi _ _WEBPACK _IMPORTED _MODULE _11 _ _ /* ["default"] */ . Z ) ( ` /api/connect/disconnect ` , {
method : "POST" ,
body : {
dbId : database . id
}
} , true ) . then ( ( res ) => {
if ( res . success ) {
window . location . reload ( ) ;
} else {
console . log ( res ) ;
alert ( res . msg || "Remote disconnection failed. Please try again." ) ;
}
} ) ;
} ,
children : "Disconnect"
} ) ;
}
/***/ } ) ,
/***/ 7851 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ "Z" : ( ) => ( /* binding */ downloadApiStream )
/* harmony export */ } ) ;
// @ts-check
/ * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Auth user on client side
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { {
* url : string ,
* fileName : string ,
* setLoading ? : React . Dispatch < React . SetStateAction < boolean >> ,
* } } params - params
*
* @ requires search - field name attribute
* / f u n c t i o n d o w n l o a d A p i S t r e a m ( { u r l , f i l e N a m e , s e t L o a d i n g } ) {
/ * *
* Check for user in local storage
*
* @ description Preventdefault , declare variables
* / i f ( s e t L o a d i n g ) s e t L o a d i n g ( t r u e ) ;
fetch ( url , {
method : "GET" ,
// @ts-ignore
headers : {
"x-csrf-auth" : localStorage . getItem ( "csrf" )
}
} ) . then ( ( res ) => {
return res . body ;
} ) . then ( ( body ) => {
const reader = body ? . getReader ( ) ;
if ( reader ) {
return new ReadableStream ( {
start ( controller ) {
return pump ( ) ;
/** @type {() => any} */ function pump ( ) {
return reader ? . read ( ) . then ( ( { done , value } ) => {
// When no more data needs to be consumed, close the stream
if ( done ) {
controller . close ( ) ;
return ;
}
// Enqueue the next data chunk into our target stream
controller . enqueue ( value ) ;
return pump ( ) ;
} ) ;
}
}
} ) ;
}
// console.log(body);
// const blob = new Blob([body.text], { type: "application/pdf" });
// const url = URL.createObjectURL(blob);
// const link = document.createElement("a");
// link.href = blob;
// link.download = `${database.db_full_name}.sql`;
// link.style.display = "none";
// document.body.appendChild(link);
// link.click();
// URL.revokeObjectURL(url);
// document.body.removeChild(link);
// setTimeout(() => {
// setLoading(false);
// }, 1000);
} ) . then ( ( stream ) => {
return new Response ( stream ) ;
} ) . then ( ( response ) => response . blob ( ) ) . then ( ( blob ) => URL . createObjectURL ( blob ) ) . then ( ( url ) => {
const link = document . createElement ( "a" ) ;
link . href = url ;
link . download = fileName ;
link . style . display = "none" ;
document . body . appendChild ( link ) ;
link . click ( ) ;
URL . revokeObjectURL ( url ) ;
document . body . removeChild ( link ) ;
setTimeout ( ( ) => {
if ( setLoading ) setLoading ( false ) ;
} , 1000 ) ;
} ) . catch ( ( error ) => {
console . log ( error ) ;
setTimeout ( ( ) => {
if ( setLoading ) setLoading ( false ) ;
} , 1000 ) ;
} ) ;
} ////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/***/ } )
} ;
;