348 lines
16 KiB
JavaScript
348 lines
16 KiB
JavaScript
"use strict";
|
|
exports.id = 2435;
|
|
exports.ids = [2435];
|
|
exports.modules = {
|
|
|
|
/***/ 2435:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
"Z": () => (/* binding */ SuDocsPageListContent)
|
|
});
|
|
|
|
// 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: external "@mui/icons-material/ArticleTwoTone"
|
|
var ArticleTwoTone_ = __webpack_require__(1891);
|
|
var ArticleTwoTone_default = /*#__PURE__*/__webpack_require__.n(ArticleTwoTone_);
|
|
// EXTERNAL MODULE: ./functions/frontend/fetchApi.js
|
|
var fetchApi = __webpack_require__(6729);
|
|
// EXTERNAL MODULE: ./components/general/LoadingBlock.jsx
|
|
var LoadingBlock = __webpack_require__(5264);
|
|
// EXTERNAL MODULE: external "@mui/icons-material/AccountTreeTwoTone"
|
|
var AccountTreeTwoTone_ = __webpack_require__(4118);
|
|
var AccountTreeTwoTone_default = /*#__PURE__*/__webpack_require__.n(AccountTreeTwoTone_);
|
|
;// CONCATENATED MODULE: ./components/su/components/PageCard.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
/**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {object} props - Server props
|
|
* @param {import("@/package-shared/types").MYSQL_docs_pages_table_def} props.docPageObject
|
|
*/ function PageCard({ docPageObject }) {
|
|
/**
|
|
* 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 {[ childPages: import("@/package-shared/types").MYSQL_docs_pages_table_def[], setChildPages: React.Dispatch<React.SetStateAction<import("@/package-shared/types").MYSQL_docs_pages_table_def[]>> ]} */ // @ts-ignore
|
|
const [childPages, setChildPages] = external_react_default().useState([]);
|
|
external_react_default().useEffect(()=>{
|
|
(0,fetchApi/* default */.Z)("/api/admin/docs/get-child-pages", {
|
|
method: "post",
|
|
body: {
|
|
pageId: docPageObject.id
|
|
}
|
|
}).then((res)=>{
|
|
if (res.success) {
|
|
setChildPages(res.result);
|
|
}
|
|
});
|
|
}, []);
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @description Main Function Return
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "card col relative cursor-pointer",
|
|
onClick: (e)=>{
|
|
// @ts-ignore
|
|
if (e.target?.closest(".cancel-link")) {
|
|
e.preventDefault();
|
|
} else {
|
|
window.location.pathname = `/su/docs/pages/${docPageObject.id}`;
|
|
}
|
|
},
|
|
children: [
|
|
loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {
|
|
width: "20px"
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "w-full items-start",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx((ArticleTwoTone_default()), {
|
|
color: "inherit",
|
|
className: "opacity-40 text-gray-600"
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "flex-col items-start gap-0 relative z-10",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
className: "title",
|
|
children: docPageObject.title
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
className: "-my-3",
|
|
dangerouslySetInnerHTML: {
|
|
__html: docPageObject.description || ""
|
|
}
|
|
})
|
|
]
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "ml-auto cancel-link",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("button", {
|
|
onClick: ()=>{
|
|
window.location.href = `/su/docs/edit-page?id=${docPageObject.id}`;
|
|
},
|
|
className: "outlined small-text light-gray",
|
|
children: "Edit Page"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("button", {
|
|
onClick: ()=>{
|
|
if (window.confirm("Delete this page?")) {
|
|
setLoading(true);
|
|
(0,fetchApi/* default */.Z)("/api/admin/docs/delete-page", {
|
|
method: "post",
|
|
body: docPageObject
|
|
}).then((res)=>{
|
|
if (res.success) {
|
|
window.location.reload();
|
|
} else {}
|
|
setTimeout(()=>{
|
|
setLoading(false);
|
|
}, 1000);
|
|
});
|
|
}
|
|
},
|
|
className: "outlined small-text light-gray",
|
|
children: "Delete Page"
|
|
})
|
|
]
|
|
})
|
|
]
|
|
}),
|
|
childPages && /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "-mt-[40px] pt-[40px] ml-[10px] pl-[20px] border-0 border-l border-slate-200 border-solid w-full flex-col items-start cancel-link",
|
|
children: [
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx((AccountTreeTwoTone_default()), {
|
|
className: "opacity-20",
|
|
fontSize: "small"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
className: "text-slate-300 font-semibold",
|
|
children: "Children Pages"
|
|
})
|
|
]
|
|
}),
|
|
childPages.map((childPage, index)=>{
|
|
return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "card w-full",
|
|
onClick: ()=>{
|
|
window.location.pathname = `/su/docs/pages/${childPage.id}`;
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx((ArticleTwoTone_default()), {
|
|
color: "inherit",
|
|
className: "opacity-40 text-gray-500"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
children: childPage.title
|
|
})
|
|
]
|
|
}, index);
|
|
})
|
|
]
|
|
})
|
|
]
|
|
});
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
////////////////////////////////////////////////
|
|
} //////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// EXTERNAL MODULE: ./components/general/ui/ButtonGroup.jsx
|
|
var ButtonGroup = __webpack_require__(5449);
|
|
;// CONCATENATED MODULE: ./components/su/docs/SuDocsPageListContent.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* Super User Page List Component
|
|
* ==============================================================================
|
|
* @param {Object} props - Server props
|
|
* @param {any} props.data
|
|
*/ function SuDocsPageListContent({ data }) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ const { env } = data;
|
|
/** @type {import("@/package-shared/types").MYSQL_docs_pages_table_def[]} */ const docPages = data.docPages;
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ const [loading, setLoading] = external_react_default().useState(false);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* ## Persist Function
|
|
* @param {boolean} pull
|
|
*/ function persist(pull) {
|
|
if (window.confirm(pull ? "Update Docs DB from JSON file?" : "Update docs json file?")) {
|
|
setLoading(true);
|
|
(0,fetchApi/* default */.Z)("/api/admin/docs/persist", {
|
|
method: "post",
|
|
body: {
|
|
pull
|
|
}
|
|
}).then((res)=>{
|
|
if (res.success) {
|
|
window.alert(pull ? "Docs database table Updated Sucessfully!" : "JSON data written Successfully!");
|
|
} else {
|
|
window.alert("Operation failed!");
|
|
}
|
|
setTimeout(()=>{
|
|
setLoading(false);
|
|
}, 1000);
|
|
}).catch((err)=>{
|
|
setTimeout(()=>{
|
|
setLoading(false);
|
|
}, 1000);
|
|
});
|
|
}
|
|
}
|
|
////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
|
|
children: [
|
|
loading && /*#__PURE__*/ jsx_runtime_.jsx(LoadingBlock/* default */.Z, {}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("section", {
|
|
className: "items-start justify-start p-6",
|
|
children: [
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "flex items-center justify-between w-full mb-6",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("h2", {
|
|
className: "text-xl m-0",
|
|
children: "Documentation Pages"
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("a", {
|
|
href: `/su/docs/create-page`,
|
|
className: "button",
|
|
children: "Create Page"
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)(ButtonGroup/* default */.Z, {
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("button", {
|
|
className: "outlined gray",
|
|
onClick: ()=>{
|
|
persist(false);
|
|
},
|
|
children: "Push"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("button", {
|
|
className: "outlined gray",
|
|
onClick: ()=>{
|
|
persist(true);
|
|
},
|
|
children: "Pull"
|
|
})
|
|
]
|
|
})
|
|
]
|
|
})
|
|
]
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
className: "paper flex-col items-stretch gap-10 w-full",
|
|
children: docPages.map((docPageObject, index)=>/*#__PURE__*/ jsx_runtime_.jsx(PageCard, {
|
|
docPageObject: docPageObject
|
|
}, index))
|
|
})
|
|
]
|
|
})
|
|
]
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
/***/ })
|
|
|
|
};
|
|
; |