2024-11-05 11:12:42 +00:00
|
|
|
"use strict";
|
|
|
|
(() => {
|
|
|
|
var exports = {};
|
|
|
|
exports.id = 4916;
|
|
|
|
exports.ids = [4916];
|
|
|
|
exports.modules = {
|
|
|
|
|
|
|
|
/***/ 8858:
|
|
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
|
|
|
|
// ESM COMPAT FLAG
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
// EXPORTS
|
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
|
|
"default": () => (/* binding */ UsersPage),
|
|
|
|
"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/suAdminUserAuth.js
|
|
|
|
var suAdminUserAuth = __webpack_require__(1503);
|
|
|
|
var suAdminUserAuth_default = /*#__PURE__*/__webpack_require__.n(suAdminUserAuth);
|
|
|
|
// EXTERNAL MODULE: ./layouts/SuAdminLayout.jsx + 2 modules
|
|
|
|
var SuAdminLayout = __webpack_require__(8282);
|
|
|
|
// EXTERNAL MODULE: ./components/su/components/UserCard.jsx
|
|
|
|
var UserCard = __webpack_require__(1336);
|
|
|
|
// EXTERNAL MODULE: ./components/general/BackButton.jsx
|
|
|
|
var BackButton = __webpack_require__(1781);
|
|
|
|
// 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 "@mui/icons-material/StyleTwoTone"
|
|
|
|
var StyleTwoTone_ = __webpack_require__(723);
|
|
|
|
var StyleTwoTone_default = /*#__PURE__*/__webpack_require__.n(StyleTwoTone_);
|
|
|
|
;// CONCATENATED MODULE: ./components/su/components/UserBackups.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {object} props - Server props
|
|
|
|
* @param {import("@/package-shared/types").UserType} props.user
|
|
|
|
* @param {number} props.refresh
|
|
|
|
* @param {React.Dispatch<React.SetStateAction<number>>} props.setRefresh
|
|
|
|
*/ function UserBackups({ user , refresh , setRefresh }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ const [loading, setLoading] = external_react_default().useState(false);
|
|
|
|
/** @type {[ backups: string[], setBackups: React.Dispatch<React.SetStateAction<string[]>> ]} */ // @ts-ignore
|
|
|
|
const [backups, setBackups] = external_react_default().useState([]);
|
|
|
|
external_react_default().useEffect(()=>{
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/getUserBackups", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
user
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
|
|
|
setBackups(res.backups);
|
|
|
|
});
|
|
|
|
}, [
|
|
|
|
refresh
|
|
|
|
]);
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @description Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("section", {
|
|
|
|
className: "paper",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("h2", {
|
|
|
|
className: "text-xl m-0",
|
|
|
|
children: "User Backups"
|
|
|
|
}),
|
|
|
|
!backups && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {
|
|
|
|
width: "20px",
|
|
|
|
position: "relative"
|
|
|
|
}),
|
|
|
|
backups && !backups[0] && /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
children: "This user has no backups"
|
|
|
|
}),
|
|
|
|
backups && backups[0] && backups.sort((a, b)=>{
|
|
|
|
if (parseInt(a) > parseInt(b)) return -1;
|
|
|
|
return 1;
|
|
|
|
}).map((backup, index)=>{
|
|
|
|
const backupDate = new Date(parseInt(backup));
|
|
|
|
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("a", {
|
|
|
|
href: `/su/users/${user.id}/${backup}`,
|
|
|
|
className: "card w-full items-center",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx((StyleTwoTone_default()), {
|
|
|
|
color: "inherit",
|
|
|
|
className: "opacity-40 text-slate-500"
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("b", {
|
|
|
|
children: "Backup:"
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
children: backupDate.toString()
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}, backup);
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
} //////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./components/general/CodeBlock.jsx
|
|
|
|
var CodeBlock = __webpack_require__(1095);
|
|
|
|
// EXTERNAL MODULE: external "@mui/icons-material/FolderCopyTwoTone"
|
|
|
|
var FolderCopyTwoTone_ = __webpack_require__(8398);
|
|
|
|
var FolderCopyTwoTone_default = /*#__PURE__*/__webpack_require__.n(FolderCopyTwoTone_);
|
|
|
|
;// CONCATENATED MODULE: external "@mui/icons-material/InsertDriveFileTwoTone"
|
|
|
|
const InsertDriveFileTwoTone_namespaceObject = require("@mui/icons-material/InsertDriveFileTwoTone");
|
|
|
|
var InsertDriveFileTwoTone_default = /*#__PURE__*/__webpack_require__.n(InsertDriveFileTwoTone_namespaceObject);
|
|
|
|
;// CONCATENATED MODULE: external "@mui/icons-material/KeyboardArrowDownRounded"
|
|
|
|
const KeyboardArrowDownRounded_namespaceObject = require("@mui/icons-material/KeyboardArrowDownRounded");
|
|
|
|
var KeyboardArrowDownRounded_default = /*#__PURE__*/__webpack_require__.n(KeyboardArrowDownRounded_namespaceObject);
|
|
|
|
;// CONCATENATED MODULE: ./components/su/components/UserSingleFile.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {object} props - Server props
|
|
|
|
* @param {object} props.user
|
|
|
|
* @param {import("@/package-shared/types").UserFileObject2} props.file
|
|
|
|
* @param {import("@/package-shared/types").UserFileObject} props.activeFile
|
|
|
|
* @param {React.Dispatch<React.SetStateAction<import("@/package-shared/types").UserFileObject>>} props.setActiveFile
|
|
|
|
*/ function UserSingleFile({ user , file , activeFile , setActiveFile , }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @description Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("button", {
|
|
|
|
className: "justify-start gap-4" + (activeFile?.path === `${file.root}/${file.name}` ? " dark" : " light-gray"),
|
|
|
|
onClick: (e)=>{
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/grabFile", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
user,
|
|
|
|
type: "file",
|
|
|
|
path: `${file.root}/${file.name}`
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
|
|
|
if (res.success) {
|
|
|
|
try {
|
|
|
|
setActiveFile({
|
|
|
|
title: file.name,
|
|
|
|
path: `${file.root}/${file.name}`,
|
|
|
|
data: JSON.stringify(JSON.parse(res.data), null, 4)
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
setActiveFile({
|
|
|
|
title: file.name,
|
|
|
|
path: `${file.root}/${file.name}`,
|
|
|
|
data: res.data
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx((InsertDriveFileTwoTone_default()), {
|
|
|
|
fontSize: "small",
|
|
|
|
className: "text-slate-400"
|
|
|
|
}),
|
|
|
|
file.name
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
} //////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./components/su/components/UserFolder.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {object} props - Server props
|
|
|
|
* @param {object} props.user
|
|
|
|
* @param {import("@/package-shared/types").UserFileObject2} props.file
|
|
|
|
* @param {import("@/package-shared/types").UserFileObject} props.activeFile
|
|
|
|
* @param {React.Dispatch<React.SetStateAction<import("@/package-shared/types").UserFileObject>>} props.setActiveFile
|
|
|
|
*/ function UserFolder({ user , file , activeFile , setActiveFile }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ const [files, setFiles] = external_react_default().useState(null);
|
|
|
|
const [loading, setLoading] = external_react_default().useState(false);
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @description Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "flex-col w-full items-start relative",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx((FolderCopyTwoTone_default()), {
|
|
|
|
fontSize: "small",
|
|
|
|
className: "text-slate-400"
|
|
|
|
}),
|
|
|
|
file.name,
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx((KeyboardArrowDownRounded_default()), {
|
|
|
|
className: "ml-auto absolute right-2"
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
file.content && /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "flex-col w-full pl-4 items-start ml-2",
|
|
|
|
style: {
|
|
|
|
borderLeft: "1px solid var(--slate-200)"
|
|
|
|
},
|
|
|
|
children: file.content.map((nest, index)=>{
|
|
|
|
if (nest?.type?.match(/file/i)) {
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx(UserSingleFile, {
|
|
|
|
user: user,
|
|
|
|
file: nest,
|
|
|
|
activeFile: activeFile,
|
|
|
|
setActiveFile: setActiveFile
|
|
|
|
}, index);
|
|
|
|
} else {
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx(UserFolder, {
|
|
|
|
user: user,
|
|
|
|
file: nest,
|
|
|
|
activeFile: activeFile,
|
|
|
|
setActiveFile: setActiveFile
|
|
|
|
}, index);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
} //////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./components/su/components/UserFiles.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {object} props - Server props
|
|
|
|
* @param {import("@/package-shared/types").UserType} props.user
|
|
|
|
* @param {any[]} props.rootFilesArray
|
|
|
|
*/ function UserFiles({ user , rootFilesArray }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ /** @type {[ activeFile: import("@/package-shared/types").UserFileObject, setActiveFile: React.Dispatch<React.SetStateAction<import("@/package-shared/types").UserFileObject>> ]} */ // @ts-ignore
|
|
|
|
const [activeFile, setActiveFile] = external_react_default().useState(null);
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @description Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("section", {
|
|
|
|
className: "paper",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("h3", {
|
|
|
|
className: "text-lg m-0",
|
|
|
|
children: "User Files"
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "w-full items-start max-w-7xl",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "flex-col items-stretch w-[40%]",
|
|
|
|
children: rootFilesArray.map((/** @type {import("@/package-shared/types").UserFileObject2} */ file, index)=>{
|
|
|
|
if (file?.type?.match(/file/)) {
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx(UserSingleFile, {
|
|
|
|
user: user,
|
|
|
|
file: file,
|
|
|
|
activeFile: activeFile,
|
|
|
|
setActiveFile: setActiveFile
|
|
|
|
}, index);
|
|
|
|
} else {
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx(UserFolder, {
|
|
|
|
user: user,
|
|
|
|
file: file,
|
|
|
|
activeFile: activeFile,
|
|
|
|
setActiveFile: setActiveFile
|
|
|
|
}, index);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "grow flex-col items-start justify-start w-[60%] h-full -mt-4",
|
|
|
|
children: activeFile && /*#__PURE__*/ jsx_runtime_.jsx(CodeBlock/* default */.Z, {
|
|
|
|
content: activeFile.data || "",
|
|
|
|
language: "javascript"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
} //////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./components/general/Breadcrumbs.jsx
|
|
|
|
var Breadcrumbs = __webpack_require__(424);
|
|
|
|
// EXTERNAL MODULE: external "@mui/material/styles"
|
|
|
|
var styles_ = __webpack_require__(8442);
|
|
|
|
// EXTERNAL MODULE: external "@mui/material/Table"
|
|
|
|
var Table_ = __webpack_require__(9181);
|
|
|
|
var Table_default = /*#__PURE__*/__webpack_require__.n(Table_);
|
|
|
|
// EXTERNAL MODULE: external "@mui/material/TableBody"
|
|
|
|
var TableBody_ = __webpack_require__(8823);
|
|
|
|
var TableBody_default = /*#__PURE__*/__webpack_require__.n(TableBody_);
|
|
|
|
// EXTERNAL MODULE: external "@mui/material/TableCell"
|
|
|
|
var TableCell_ = __webpack_require__(5612);
|
|
|
|
var TableCell_default = /*#__PURE__*/__webpack_require__.n(TableCell_);
|
|
|
|
// EXTERNAL MODULE: external "@mui/material/TableContainer"
|
|
|
|
var TableContainer_ = __webpack_require__(443);
|
|
|
|
var TableContainer_default = /*#__PURE__*/__webpack_require__.n(TableContainer_);
|
|
|
|
// EXTERNAL MODULE: external "@mui/material/TableHead"
|
|
|
|
var TableHead_ = __webpack_require__(5953);
|
|
|
|
var TableHead_default = /*#__PURE__*/__webpack_require__.n(TableHead_);
|
|
|
|
// EXTERNAL MODULE: external "@mui/material/TableRow"
|
|
|
|
var TableRow_ = __webpack_require__(4848);
|
|
|
|
var TableRow_default = /*#__PURE__*/__webpack_require__.n(TableRow_);
|
|
|
|
// EXTERNAL MODULE: external "@mui/material/Paper"
|
|
|
|
var Paper_ = __webpack_require__(1168);
|
|
|
|
var Paper_default = /*#__PURE__*/__webpack_require__.n(Paper_);
|
|
|
|
;// CONCATENATED MODULE: ./components/su/components/UserDbShellQueryResult.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ const StyledTableCell = (0,styles_.styled)((TableCell_default()))(({ theme })=>({
|
|
|
|
[`&.${TableCell_.tableCellClasses.head}`]: {
|
|
|
|
backgroundColor: "var(--slate-800)",
|
|
|
|
color: "white"
|
|
|
|
},
|
|
|
|
[`&.${TableCell_.tableCellClasses.body}`]: {
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
/** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {Object} props - Server props
|
|
|
|
* @param {any} props.data
|
|
|
|
* @param {import("@/package-shared/types").UserType} [props.user]
|
|
|
|
*/ function UserDbShellQueryResult({ data , user }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
try {
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ const headers = Object.keys(data[0]);
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @abstract Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
className: "p-4 bg-slate-200 rounded-md overflow-hidden w-full max-w-6xl",
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx((TableContainer_default()), {
|
|
|
|
component: (Paper_default()),
|
|
|
|
sx: {
|
|
|
|
width: "100%"
|
|
|
|
},
|
|
|
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)((Table_default()), {
|
|
|
|
sx: {
|
|
|
|
minWidth: 650
|
|
|
|
},
|
|
|
|
"aria-label": "simple table",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx((TableHead_default()), {
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx((TableRow_default()), {
|
|
|
|
children: headers && headers[0] && headers.map((header, index)=>{
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx(StyledTableCell, {
|
|
|
|
align: "left",
|
|
|
|
children: header
|
|
|
|
}, index + 1);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx((TableBody_default()), {
|
|
|
|
children: data && data[0] && data.map((/** @type {any} */ dataObject, /** @type {Number} */ index)=>{
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx((TableRow_default()), {
|
|
|
|
sx: {
|
|
|
|
"&:last-child td, &:last-child th": {
|
|
|
|
border: 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
children: headers.map((header, _index)=>{
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx(StyledTableCell, {
|
|
|
|
align: "left",
|
|
|
|
children: dataObject[header]
|
|
|
|
}, _index + 1);
|
|
|
|
})
|
|
|
|
}, index + 1);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
} catch (error) {
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
children: "No results"
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./components/form/FormSelect.jsx
|
|
|
|
var FormSelect = __webpack_require__(4114);
|
|
|
|
;// CONCATENATED MODULE: ./components/su/components/UserDbShell.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {Object} props - Server props
|
|
|
|
* @param {import("@/package-shared/types").UserType} props.user
|
|
|
|
* @param {string[]} props.databases
|
|
|
|
*/ function UserDbShell({ user , databases }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
try {
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ /** @type {React.MutableRefObject<HTMLDivElement | undefined>} */ const sqlEditorRef = external_react_default().useRef();
|
|
|
|
/** @type {React.MutableRefObject<AceAjax.Editor | undefined>} */ const editorRef = external_react_default().useRef();
|
|
|
|
const dbRef = external_react_default().useRef(databases[0]);
|
|
|
|
const [loading, setLoading] = external_react_default().useState(false);
|
|
|
|
const [data, setData] = external_react_default().useState(false);
|
|
|
|
const [refresh, setRefresh] = external_react_default().useState(0);
|
|
|
|
const [targetDb, setTargetDb] = external_react_default().useState(databases[0]);
|
|
|
|
function runQuery() {
|
|
|
|
setLoading(true);
|
|
|
|
const query = editorRef.current ? editorRef.current.getValue() : null;
|
|
|
|
if (!query?.match(/./)) return;
|
|
|
|
const formattedQuery = query.replace(/^--.*/gm, "").replace(/\n|\r|\n\r/gm, "").replace(/ {2,}/g, " ");
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/runUserDbQuery", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
database: dbRef.current,
|
|
|
|
query: formattedQuery
|
|
|
|
}
|
|
|
|
}, true).then((res)=>{
|
|
|
|
if (res.success) {
|
|
|
|
setData(res.result);
|
|
|
|
} else if (res.msg) {
|
|
|
|
window.alert(res.msg);
|
|
|
|
}
|
|
|
|
setTimeout(()=>{
|
|
|
|
setLoading(false);
|
|
|
|
}, 500);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
external_react_default().useEffect(()=>{
|
|
|
|
if (!ace?.edit) {
|
|
|
|
setTimeout(()=>{
|
|
|
|
setRefresh((prev)=>prev + 1);
|
|
|
|
}, 1000);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const editor = ace.edit("ace-editor-wrapper");
|
|
|
|
editor.setOptions({
|
|
|
|
mode: "ace/mode/mysql",
|
|
|
|
theme: "ace/theme/twilight",
|
|
|
|
value: `SELECT * FROM table_name`,
|
|
|
|
placeholder: "Type an SQL query",
|
|
|
|
enableBasicAutocompletion: true,
|
|
|
|
enableLiveAutocompletion: true
|
|
|
|
});
|
|
|
|
editor.commands.addCommand({
|
|
|
|
name: "myCommand",
|
|
|
|
bindKey: {
|
|
|
|
win: "Ctrl-Enter",
|
|
|
|
mac: "Command-Enter"
|
|
|
|
},
|
|
|
|
exec: function(editor) {
|
|
|
|
runQuery();
|
|
|
|
},
|
|
|
|
readOnly: true
|
|
|
|
});
|
|
|
|
editorRef.current = editor;
|
|
|
|
}, [
|
|
|
|
refresh
|
|
|
|
]);
|
|
|
|
/** @type {[dbTables: string[], setDbTables: React.Dispatch<React.SetStateAction<string[]>> ]} */ // @ts-ignore
|
|
|
|
const [dbTables, setDbTables] = external_react_default().useState([]);
|
|
|
|
external_react_default().useEffect(()=>{
|
|
|
|
(0,fetchApi/* default */.Z)(`/api/admin/getTablesForUserDatabase?database=${targetDb}`).then((res)=>{
|
|
|
|
if (res.success) {
|
|
|
|
setDbTables(res.tables);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, [
|
|
|
|
targetDb,
|
|
|
|
refresh
|
|
|
|
]);
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @abstract Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "paper w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("h3", {
|
|
|
|
className: "text-lg m-0",
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
children: "Database Shell"
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(FormSelect/* default */.Z, {
|
|
|
|
selectOptions: databases.map((db)=>{
|
|
|
|
return {
|
|
|
|
payload: db,
|
|
|
|
title: db?.replace(new RegExp(`datasquirel_user_${user.id}_`), "")
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
name: "select-database",
|
|
|
|
onChangeHandler: (e)=>{
|
|
|
|
setTargetDb(e.target.value);
|
|
|
|
dbRef.current = e.target.value;
|
|
|
|
},
|
|
|
|
title: "Databases"
|
|
|
|
}),
|
|
|
|
targetDb && dbTables && /*#__PURE__*/ jsx_runtime_.jsx(FormSelect/* default */.Z, {
|
|
|
|
selectOptions: dbTables.map((table)=>{
|
|
|
|
return {
|
|
|
|
payload: table,
|
|
|
|
title: table
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
name: "select-database-table",
|
|
|
|
title: "Tables"
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "w-full flex-col relative",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
// @ts-ignore
|
|
|
|
ref: sqlEditorRef,
|
|
|
|
id: "ace-editor-wrapper",
|
|
|
|
style: {
|
|
|
|
height: "100px"
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("button", {
|
|
|
|
className: "absolute right-4 bottom-4" + (loading ? " pointer-events-none opacity-70" : ""),
|
|
|
|
onClick: (e)=>{
|
|
|
|
runQuery();
|
|
|
|
},
|
|
|
|
children: [
|
|
|
|
loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {
|
|
|
|
position: "relative",
|
|
|
|
width: "15px",
|
|
|
|
borderWidth: "3px",
|
|
|
|
style: {
|
|
|
|
backgroundColor: "transparent"
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
loading ? "Running Query ..." : "Run Query"
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
data && !loading && /*#__PURE__*/ jsx_runtime_.jsx(UserDbShellQueryResult, {
|
|
|
|
data: data,
|
|
|
|
user: user
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
return /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx("section", {
|
|
|
|
className: "card",
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx("h2", {
|
|
|
|
className: "text-xl m-0",
|
|
|
|
children: "Shell not available at this time"
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./components/su/components/UserData.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {object} props - Server props
|
|
|
|
* @param {import("@/package-shared/types").UserType} props.user
|
|
|
|
* @param {number} props.refresh
|
|
|
|
* @param {React.Dispatch<React.SetStateAction<number>>} [props.setRefresh]
|
|
|
|
*/ function UserData({ user , refresh , setRefresh }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ ////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ const [loading, setLoading] = external_react_default().useState(false);
|
|
|
|
const [userData, setUserData] = external_react_default().useState(null);
|
|
|
|
const [userDbs, setUserDbs] = external_react_default().useState(null);
|
|
|
|
external_react_default().useEffect(()=>{
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/getUserData", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
user
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
|
|
|
console.log(res);
|
|
|
|
if (res.success) {
|
|
|
|
setUserData(res.data);
|
|
|
|
setUserDbs(res.databases);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, [
|
|
|
|
refresh
|
|
|
|
]);
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @description Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "paper w-full",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("h2", {
|
|
|
|
className: "text-xl m-0",
|
|
|
|
children: "User Data"
|
|
|
|
}),
|
|
|
|
userData && /*#__PURE__*/ jsx_runtime_.jsx(UserFiles, {
|
|
|
|
user: user,
|
|
|
|
rootFilesArray: userData
|
|
|
|
}),
|
|
|
|
userDbs && /*#__PURE__*/ jsx_runtime_.jsx(UserDbShell, {
|
|
|
|
user: user,
|
|
|
|
databases: userDbs
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
} //////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
;// CONCATENATED MODULE: ./components/su/SuSingleUserContent.jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {Object} props - Server props
|
|
|
|
* @param {any} props.data
|
|
|
|
*/ function SuSingleUserContent({ data }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ const user = data.user;
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ const [refresh, setRefresh] = external_react_default().useState(0);
|
|
|
|
const [addBackupLoading, setAddBackupLoading] = external_react_default().useState(false);
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @abstract Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
className: "w-full justify-between",
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(BackButton/* default */.Z, {}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("h1", {
|
|
|
|
className: "text-3xl m-0",
|
|
|
|
children: [
|
|
|
|
user.first_name,
|
|
|
|
" ",
|
|
|
|
user.last_name
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
|
|
className: "info w-auto gray font-normal",
|
|
|
|
children: user.email
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
|
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("button", {
|
|
|
|
onClick: (e)=>{
|
|
|
|
if (window.confirm(`Create a new backup for ${user.first_name}?`)) {
|
|
|
|
setAddBackupLoading(true);
|
|
|
|
(0,fetchApi/* default */.Z)("/api/admin/addUserBackup", {
|
|
|
|
method: "post",
|
|
|
|
body: {
|
|
|
|
user
|
|
|
|
}
|
|
|
|
}).then((res)=>{
|
|
|
|
console.log(res);
|
|
|
|
if (res.success) {
|
|
|
|
setRefresh((prev)=>prev + 1);
|
|
|
|
}
|
|
|
|
setTimeout(()=>{
|
|
|
|
setAddBackupLoading(false);
|
|
|
|
}, 1000);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
className: "relative",
|
|
|
|
children: [
|
|
|
|
addBackupLoading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {
|
|
|
|
width: "20px"
|
|
|
|
}),
|
|
|
|
"Backup User"
|
|
|
|
]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
]
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(UserCard/* default */.Z, {
|
|
|
|
userObject: user,
|
|
|
|
userPage: true
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(UserBackups, {
|
|
|
|
user: user,
|
|
|
|
refresh: refresh,
|
|
|
|
setRefresh: setRefresh
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx(UserData, {
|
|
|
|
user: user,
|
|
|
|
refresh: refresh,
|
|
|
|
setRefresh: setRefresh
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
;// CONCATENATED MODULE: ./pages/su/users/[single].jsx
|
|
|
|
// @ts-check
|
|
|
|
/**
|
|
|
|
* ==============================================================================
|
|
|
|
* Imports
|
|
|
|
* ==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Main Component { Functional }
|
|
|
|
* ==============================================================================
|
|
|
|
* @param {Object} props - Server props
|
|
|
|
* @param {import("@/package-shared/types").UserType} props.user
|
|
|
|
* @param {any} props.data
|
|
|
|
*/ function UsersPage({ user , data }) {
|
|
|
|
/**
|
|
|
|
* Get Contexts
|
|
|
|
*
|
|
|
|
* @abstract { React.useContext }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Javascript Variables
|
|
|
|
*
|
|
|
|
* @abstract Non hook variables and functions
|
|
|
|
*/ const pageTitle = "User Dashboard | Datasquirel";
|
|
|
|
const pageDescription = "Welcome to your data app";
|
|
|
|
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
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
|
|
|
|
children: [
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("script", {
|
|
|
|
src: "https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ace.min.js",
|
|
|
|
integrity: "sha512-q6CTB0jS+VuJnSct82rVcWlI06LGzNjaG3CWenHWVUncRvc4UQMFkA3a5Ip880xr+lBx38FcHDclOxPdSg+sBw==",
|
|
|
|
crossOrigin: "anonymous",
|
|
|
|
referrerPolicy: "no-referrer"
|
|
|
|
}),
|
|
|
|
/*#__PURE__*/ jsx_runtime_.jsx("script", {
|
|
|
|
src: "https://cdnjs.cloudflare.com/ajax/libs/ace/1.22.0/ext-language_tools.min.js",
|
|
|
|
integrity: "sha512-6g6cvocV7eT/J8L44lL8gJKqq9onqQeYGgJO0DmrsYFcCfRl6wYkYA/KHS768r4QVTB4JxsCcMQ9gIezxpTCZw==",
|
|
|
|
crossOrigin: "anonymous",
|
|
|
|
referrerPolicy: "no-referrer"
|
|
|
|
})
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* React Hooks
|
|
|
|
*
|
|
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
|
|
*/ ////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Function Return
|
|
|
|
*
|
|
|
|
* @abstract Main Function Return
|
|
|
|
*/ return /*#__PURE__*/ jsx_runtime_.jsx(SuAdminLayout/* default */.Z, {
|
|
|
|
head: head,
|
|
|
|
user: user,
|
|
|
|
children: /*#__PURE__*/ jsx_runtime_.jsx(SuSingleUserContent, {
|
|
|
|
data: data
|
|
|
|
})
|
|
|
|
});
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
}
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
|
|
* ==============================================================================
|
|
|
|
* Server Side Props or Static Props
|
|
|
|
* ==============================================================================
|
|
|
|
* @type {import("next").GetServerSideProps}
|
|
|
|
*/ async function getServerSideProps({ req , res , query }) {
|
|
|
|
/**
|
|
|
|
* User Auth
|
|
|
|
*
|
|
|
|
* @description User Auth
|
|
|
|
*/ const suAdminUser = await suAdminUserAuth_default()(req);
|
|
|
|
if (!suAdminUser?.logged_in_status) {
|
|
|
|
return {
|
|
|
|
redirect: {
|
|
|
|
destination: `/su/login`,
|
|
|
|
permanent: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Page/Site Data Data Fetching
|
|
|
|
*
|
|
|
|
* @description Fetch data on the server before returning
|
|
|
|
*/ const user = await DB_HANDLER_default()(`SELECT * FROM users WHERE id='${query.single}'`);
|
|
|
|
if (!user?.[0]) return {
|
|
|
|
redirect: {
|
|
|
|
destination: "/su/users",
|
|
|
|
permanent: false
|
|
|
|
}
|
|
|
|
};
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
/**
|
|
|
|
* Server props return
|
|
|
|
*
|
|
|
|
* @description Return data fetched on the server side
|
|
|
|
*/ return {
|
|
|
|
props: {
|
|
|
|
user: suAdminUser,
|
|
|
|
data: {
|
|
|
|
user: user?.[0] || {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 3257:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/ArrowBackIosRounded");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 9318:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/BackupTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6843:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/ContentCopy");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 386:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/CottageTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6817:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/DocumentScannerTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6094:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/ErrorTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 8398:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/FolderCopyTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6547:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/LockPersonTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 5557:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/MenuBookTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 8245:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/PeopleAltTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 723:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/StyleTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 415:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/icons-material/TerminalTwoTone");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 1168:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/Paper");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 9174:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/Snackbar");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 9181:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/Table");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 8823:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/TableBody");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 5612:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/TableCell");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 443:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/TableContainer");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 5953:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/TableHead");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 4848:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/TableRow");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 8442:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("@mui/material/styles");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 2423:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("lucide-react");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 968:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("next/head");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6689:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("react");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 997:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("react/jsx-runtime");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 2261:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("serverless-mysql");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 4300:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("buffer");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 6113:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("crypto");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 7147:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("fs");
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 3685:
|
|
|
|
/***/ ((module) => {
|
|
|
|
|
|
|
|
module.exports = require("http");
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
|
|
};
|
|
|
|
;
|
|
|
|
|
|
|
|
// load runtime
|
|
|
|
var __webpack_require__ = require("../../../webpack-runtime.js");
|
|
|
|
__webpack_require__.C(exports);
|
|
|
|
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
|
2024-11-05 14:18:40 +00:00
|
|
|
var __webpack_exports__ = __webpack_require__.X(0, [4017,8313,5264,6729,4480,424,1781,4114,1503,5313,1336,2434], () => (__webpack_exec__(8858)));
|
2024-11-05 11:12:42 +00:00
|
|
|
module.exports = __webpack_exports__;
|
|
|
|
|
|
|
|
})();
|