142 lines
7.2 KiB
JavaScript
142 lines
7.2 KiB
JavaScript
"use strict";
|
|
exports.id = 6251;
|
|
exports.ids = [6251];
|
|
exports.modules = {
|
|
|
|
/***/ 6251:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "Z": () => (/* binding */ SuErrorLogsContent)
|
|
/* 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 _functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6729);
|
|
/* harmony import */ var _general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5264);
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Server props
|
|
*/ function SuErrorLogsContent(props) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ /** @type {[ errorLog: string | null, setErrorLog: React.Dispatch<React.SetStateAction<string | null>> ]} */ // @ts-ignore
|
|
const [errorLog, setErrorLog] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null);
|
|
const [loading, setLoading] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(false);
|
|
const [refresh, setRefresh] = react__WEBPACK_IMPORTED_MODULE_1___default().useState(0);
|
|
function fetchErrorLogs() {
|
|
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)("/api/admin/grabErrorLogs").then((res)=>{
|
|
if (typeof res.log === "string" && !res.log?.match(/./)) {
|
|
setErrorLog("No Logs Yet");
|
|
return;
|
|
} else {
|
|
setErrorLog("");
|
|
}
|
|
setErrorLog(res.log.replace(/\n|\r|\n\r|\\n/gm, "<br/>"));
|
|
});
|
|
}
|
|
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(()=>{
|
|
fetchErrorLogs();
|
|
if (refresh === 0) {
|
|
setInterval(()=>{
|
|
fetchErrorLogs();
|
|
}, 10000);
|
|
}
|
|
}, [
|
|
refresh
|
|
]);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), {
|
|
children: [
|
|
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
|
|
className: "w-full justify-between",
|
|
children: [
|
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("h2", {
|
|
className: "text-xl m-0",
|
|
children: "Error Logs"
|
|
}),
|
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("div", {
|
|
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("button", {
|
|
onClick: (e)=>{
|
|
if (window.confirm("Clear Error Logs?")) {
|
|
setLoading(true);
|
|
(0,_functions_frontend_fetchApi__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z)("/api/admin/clearErrorLogs", "post").then((res)=>{
|
|
console.log(res);
|
|
setRefresh((prev)=>prev + 1);
|
|
});
|
|
setTimeout(()=>{
|
|
setLoading(false);
|
|
}, 2000);
|
|
}
|
|
},
|
|
className: "outlined gray relative",
|
|
children: [
|
|
loading && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
|
width: "20px"
|
|
}),
|
|
"Clear Error Log"
|
|
]
|
|
})
|
|
})
|
|
]
|
|
}),
|
|
/*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("section", {
|
|
className: "paper",
|
|
children: [
|
|
errorLog && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("p", {
|
|
dangerouslySetInnerHTML: {
|
|
__html: errorLog ? errorLog : "No Log"
|
|
}
|
|
}),
|
|
!errorLog && /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_general_LoadingBlock__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
|
position: "relative",
|
|
width: "25px"
|
|
})
|
|
]
|
|
})
|
|
]
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
/***/ })
|
|
|
|
};
|
|
; |