530 lines
19 KiB
JavaScript
530 lines
19 KiB
JavaScript
|
"use strict";
|
||
|
(() => {
|
||
|
var exports = {};
|
||
|
exports.id = 7775;
|
||
|
exports.ids = [7775];
|
||
|
exports.modules = {
|
||
|
|
||
|
/***/ 3667:
|
||
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||
|
|
||
|
// ESM COMPAT FLAG
|
||
|
__webpack_require__.r(__webpack_exports__);
|
||
|
|
||
|
// EXPORTS
|
||
|
__webpack_require__.d(__webpack_exports__, {
|
||
|
"default": () => (/* binding */ Console),
|
||
|
"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/general/LoadingBlock.jsx
|
||
|
var LoadingBlock = __webpack_require__(5264);
|
||
|
;// CONCATENATED MODULE: external "os"
|
||
|
const external_os_namespaceObject = require("os");
|
||
|
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
|
||
|
var fetchApi = __webpack_require__(6729);
|
||
|
;// CONCATENATED MODULE: ./components/su/SuEnvCard.jsx
|
||
|
// @ts-check
|
||
|
/**
|
||
|
* ==============================================================================
|
||
|
* Imports
|
||
|
* ==============================================================================
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
let isMouseInLogHistory = false;
|
||
|
/** @type {any} */ let timeout;
|
||
|
/**
|
||
|
* ==============================================================================
|
||
|
* Main Component { Functional }
|
||
|
* ==============================================================================
|
||
|
* @param {Object} props - Server props
|
||
|
* @param {any} props.envObject
|
||
|
* @param {string} props.envKey
|
||
|
*/ function SuEnvCard({ envObject , envKey }) {
|
||
|
/**
|
||
|
* Get Contexts
|
||
|
*
|
||
|
* @abstract { React.useContext }
|
||
|
*/ ////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
/**
|
||
|
* Javascript Variables
|
||
|
*
|
||
|
* @abstract Non hook variables and functions
|
||
|
*/ const [visible, setVisible] = external_react_default().useState(false);
|
||
|
const [loading, setLoading] = external_react_default().useState(false);
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
/**
|
||
|
* React Hooks
|
||
|
*
|
||
|
* @abstract { useState, useEffect, useRef, etc ... }
|
||
|
*/ const [value, setValue] = external_react_default().useState(envObject[envKey]);
|
||
|
const [focused, setFocused] = external_react_default().useState(false);
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
/**
|
||
|
* Function Return
|
||
|
*
|
||
|
* @description Main Function Return
|
||
|
*/ return /*#__PURE__*/ jsx_runtime_.jsx((external_react_default()).Fragment, {
|
||
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("form", {
|
||
|
className: "grid grid-cols-2 items-center gap2 w-full hover:bg-slate-100 py-2 px-4 relative",
|
||
|
onSubmit: (e)=>{
|
||
|
e.preventDefault();
|
||
|
if (!visible) return;
|
||
|
setLoading(true);
|
||
|
setTimeout(()=>{
|
||
|
setLoading(false);
|
||
|
}, 1000);
|
||
|
},
|
||
|
children: [
|
||
|
loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {
|
||
|
width: "20px"
|
||
|
}),
|
||
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
||
|
children: envKey
|
||
|
}),
|
||
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
||
|
children: [
|
||
|
/*#__PURE__*/ jsx_runtime_.jsx("input", {
|
||
|
type: visible ? "text" : "password",
|
||
|
onFocus: (e)=>{
|
||
|
if (e.target.type == "password") {
|
||
|
e.target.type = "text";
|
||
|
}
|
||
|
setFocused(true);
|
||
|
setVisible(true);
|
||
|
},
|
||
|
onBlur: (e)=>{
|
||
|
window.clearTimeout(timeout);
|
||
|
timeout = setTimeout(()=>{
|
||
|
if (e.target.type == "text") {
|
||
|
e.target.type = "password";
|
||
|
}
|
||
|
setFocused(false);
|
||
|
setVisible(false);
|
||
|
}, 2000);
|
||
|
},
|
||
|
value: value,
|
||
|
onChange: (e)=>{
|
||
|
setValue(e.target.value);
|
||
|
}
|
||
|
}),
|
||
|
focused ? /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
||
|
className: "button secondary",
|
||
|
onClick: (e)=>{
|
||
|
e.preventDefault();
|
||
|
if (!visible) return;
|
||
|
setLoading(true);
|
||
|
(0,fetchApi/* default */.Z)("/api/admin/updateEnv", {
|
||
|
method: "post",
|
||
|
body: {
|
||
|
key: envKey,
|
||
|
value: value
|
||
|
}
|
||
|
}).then((res)=>{
|
||
|
if (res.success) {
|
||
|
window.location.reload();
|
||
|
} else {
|
||
|
window.alert(res.error);
|
||
|
}
|
||
|
}).finally(()=>{
|
||
|
setTimeout(()=>{
|
||
|
setLoading(false);
|
||
|
}, 1000);
|
||
|
});
|
||
|
},
|
||
|
children: "Update"
|
||
|
}) : /*#__PURE__*/ jsx_runtime_.jsx("div", {
|
||
|
className: "button outlined",
|
||
|
onClick: (e)=>{
|
||
|
setVisible(!visible);
|
||
|
setFocused(true);
|
||
|
},
|
||
|
children: "Reveal"
|
||
|
})
|
||
|
]
|
||
|
})
|
||
|
]
|
||
|
})
|
||
|
});
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
} //////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
;// CONCATENATED MODULE: ./components/su/SuEnvContent.jsx
|
||
|
// @ts-check
|
||
|
/**
|
||
|
* ==============================================================================
|
||
|
* Imports
|
||
|
* ==============================================================================
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
let SuEnvContent_isMouseInLogHistory = false;
|
||
|
/**
|
||
|
* ==============================================================================
|
||
|
* Main Component { Functional }
|
||
|
* ==============================================================================
|
||
|
* @param {Object} props - Server props
|
||
|
* @param {{ envObject: any }} props.data
|
||
|
*/ function SuEnvContent({ data }) {
|
||
|
/**
|
||
|
* Get Contexts
|
||
|
*
|
||
|
* @abstract { React.useContext }
|
||
|
*/ ////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
/**
|
||
|
* Javascript Variables
|
||
|
*
|
||
|
* @abstract Non hook variables and functions
|
||
|
*/ const { envObject } = data;
|
||
|
const [env, setEnv] = external_react_default().useState(envObject);
|
||
|
const envKeys = Object.keys(env);
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
/**
|
||
|
* React Hooks
|
||
|
*
|
||
|
* @abstract { useState, useEffect, useRef, etc ... }
|
||
|
*/ ////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
/**
|
||
|
* Function Return
|
||
|
*
|
||
|
* @description 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__*/ jsx_runtime_.jsx("h2", {
|
||
|
className: "text-2xl m-0",
|
||
|
children: "Environment Variables"
|
||
|
}),
|
||
|
/*#__PURE__*/ jsx_runtime_.jsx("button", {
|
||
|
onClick: (e)=>{
|
||
|
const newEnvName = window.prompt("What is the new ENV name?");
|
||
|
const newEnvValue = window.prompt("ENV Value");
|
||
|
if (newEnvName && newEnvValue) {
|
||
|
setEnv((/** @type {any} */ prev)=>{
|
||
|
const newObject = {
|
||
|
...prev
|
||
|
};
|
||
|
newObject[newEnvName] = newEnvValue;
|
||
|
return newObject;
|
||
|
});
|
||
|
}
|
||
|
},
|
||
|
children: "Add Environment Variable"
|
||
|
})
|
||
|
]
|
||
|
}),
|
||
|
/*#__PURE__*/ jsx_runtime_.jsx("section", {
|
||
|
className: "paper",
|
||
|
children: envKeys.map((key, index)=>/*#__PURE__*/ jsx_runtime_.jsx(SuEnvCard, {
|
||
|
envObject: env,
|
||
|
envKey: key
|
||
|
}, index))
|
||
|
})
|
||
|
]
|
||
|
});
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
////////////////////////////////////////////////
|
||
|
} //////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
//////////////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
;// CONCATENATED MODULE: ./pages/su/envar.jsx
|
||
|
// @ts-check
|
||
|
/**
|
||
|
* ==============================================================================
|
||
|
* Imports
|
||
|
* ==============================================================================
|
||
|
*/
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
const fs = __webpack_require__(7147);
|
||
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||
|
* ==============================================================================
|
||
|
* Main Component { Functional }
|
||
|
* ==============================================================================
|
||
|
* @param {Object} props - Server props
|
||
|
* @param {import("@/package-shared/types").UserType} props.user
|
||
|
* @param {any} [props.data]
|
||
|
*/ function Console({ user , data }) {
|
||
|
/**
|
||
|
* Get Contexts
|
||
|
*
|
||
|
* @abstract { React.useContext }
|
||
|
*/ ////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* Javascript Variables
|
||
|
*
|
||
|
* @abstract Non hook variables and functions
|
||
|
*/ const pageTitle = "Console | Datasquirel";
|
||
|
const pageDescription = "Databases Console";
|
||
|
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 ... }
|
||
|
*/ ////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* Function Return
|
||
|
*
|
||
|
* @abstract Main Function Return
|
||
|
*/ return /*#__PURE__*/ jsx_runtime_.jsx(SuAdminLayout/* default */.Z, {
|
||
|
head: head,
|
||
|
user: user,
|
||
|
children: /*#__PURE__*/ jsx_runtime_.jsx(SuEnvContent, {
|
||
|
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
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
if (false) {}
|
||
|
/**
|
||
|
* Page/Site Data Data Fetching
|
||
|
*
|
||
|
* @description Fetch data on the server before returning
|
||
|
*/ const env = fs.readFileSync("./.env", "utf-8");
|
||
|
const envLines = env.split(/\n|\r/);
|
||
|
/** @type {any} */ const envObject = {};
|
||
|
envLines.forEach((line)=>{
|
||
|
if (!line.match(/=/)) return;
|
||
|
if (line.match(/^\#/)) return;
|
||
|
const envArray = line.split("=");
|
||
|
envObject[envArray[0]] = envArray[1];
|
||
|
});
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
/**
|
||
|
* Server props return
|
||
|
*
|
||
|
* @description Return data fetched on the server side
|
||
|
*/ return {
|
||
|
props: {
|
||
|
user: suAdminUser,
|
||
|
data: {
|
||
|
envObject
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
////////////////////////////////////////
|
||
|
}
|
||
|
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 9318:
|
||
|
/***/ ((module) => {
|
||
|
|
||
|
module.exports = require("@mui/icons-material/BackupTwoTone");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 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");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 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");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 415:
|
||
|
/***/ ((module) => {
|
||
|
|
||
|
module.exports = require("@mui/icons-material/TerminalTwoTone");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 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");
|
||
|
|
||
|
/***/ }),
|
||
|
|
||
|
/***/ 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))
|
||
|
var __webpack_exports__ = __webpack_require__.X(0, [4017,8313,5264,6729,5304,1503,5313], () => (__webpack_exec__(3667)));
|
||
|
module.exports = __webpack_exports__;
|
||
|
|
||
|
})();
|