502 lines
25 KiB
JavaScript
502 lines
25 KiB
JavaScript
"use strict";
|
|
exports.id = 7926;
|
|
exports.ids = [7926];
|
|
exports.modules = {
|
|
|
|
/***/ 8124:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
"Z": () => (/* binding */ DashboardContent)
|
|
});
|
|
|
|
// 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: ./pages/admin/[user_id]/index.jsx
|
|
var _user_id_ = __webpack_require__(1457);
|
|
// EXTERNAL MODULE: ./components/general/Breadcrumbs.jsx
|
|
var Breadcrumbs = __webpack_require__(424);
|
|
// EXTERNAL MODULE: ./components/general/VerificationBanner.jsx
|
|
var VerificationBanner = __webpack_require__(7946);
|
|
// EXTERNAL MODULE: ./components/admin/databases/DatabasesContent.jsx
|
|
var DatabasesContent = __webpack_require__(8744);
|
|
// EXTERNAL MODULE: ./components/admin/databases/DatabasesList.jsx
|
|
var DatabasesList = __webpack_require__(6891);
|
|
;// CONCATENATED MODULE: ./components/admin/dashboard/DatabasesSummary.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Server props
|
|
*/ function DatabasesSummary(props) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ const { databases , setTargetDatabase , user } = external_react_default().useContext(_user_id_.DashboardContext);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* 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(DatabasesList/* default */.Z, {
|
|
databases: databases,
|
|
setTargetDatabase: setTargetDatabase,
|
|
title: "Recently added Databases",
|
|
more: true,
|
|
user: user
|
|
})
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
// EXTERNAL MODULE: ./components/admin/databases/DelegatedDatabasesSection.jsx
|
|
var DelegatedDatabasesSection = __webpack_require__(5592);
|
|
// EXTERNAL MODULE: external "lucide-react"
|
|
var external_lucide_react_ = __webpack_require__(2423);
|
|
;// CONCATENATED MODULE: ./components/general/MetricCard.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Server props
|
|
* @param {any} props.icon
|
|
* @param {string} props.metric
|
|
* @param {string | number} props.count
|
|
* @param {string} [props.url]
|
|
*/ function MetricCard({ icon , metric , count , url }) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)("a", {
|
|
href: url,
|
|
className: "card col w-full",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("div", {
|
|
className: "absolute top-4 right-4",
|
|
children: icon
|
|
}),
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "content-block",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
className: "metric text-slate-800 dark:text-white",
|
|
children: count
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx("span", {
|
|
className: "text-sm text-slate-600 dark:text-slate-400",
|
|
children: metric
|
|
})
|
|
]
|
|
})
|
|
]
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
;// CONCATENATED MODULE: ./components/admin/dashboard/Metrics.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Server props
|
|
*/ function Metrics(props) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ const { databases , setTargetDatabase , metrics , user } = external_react_default().useContext(_user_id_.DashboardContext);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ jsx_runtime_.jsx("section", {
|
|
className: "p-0",
|
|
children: /*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 w-full gap-6 items-stretch",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx(MetricCard, {
|
|
metric: "Databases Created",
|
|
count: metrics?.dbCount || 0,
|
|
icon: /*#__PURE__*/ jsx_runtime_.jsx(external_lucide_react_.Database, {
|
|
size: 20,
|
|
className: "text-secondary2"
|
|
}),
|
|
url: `/admin/${user?.id}/databases`
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx(MetricCard, {
|
|
metric: "Tables Created",
|
|
count: metrics?.tablesCount || 0,
|
|
icon: /*#__PURE__*/ jsx_runtime_.jsx(external_lucide_react_.Sheet, {
|
|
size: 20,
|
|
className: "text-primary"
|
|
})
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx(MetricCard, {
|
|
metric: "Media Added",
|
|
count: metrics?.mediaCount || 0,
|
|
icon: /*#__PURE__*/ jsx_runtime_.jsx(external_lucide_react_.Images, {
|
|
size: 20,
|
|
className: "text-slate-500"
|
|
}),
|
|
url: `/admin/${user?.id}/media`
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx(MetricCard, {
|
|
metric: "API Keys",
|
|
count: metrics?.apiKeysCount || 0,
|
|
icon: /*#__PURE__*/ jsx_runtime_.jsx(external_lucide_react_.Key, {
|
|
size: 20,
|
|
className: "text-slate-900 dark:text-white"
|
|
}),
|
|
url: `/admin/${user?.id}/api-keys`
|
|
})
|
|
]
|
|
})
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
;// CONCATENATED MODULE: ./components/admin/dashboard/DashboardContent.jsx
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Server props
|
|
*/ function DashboardContent(props) {
|
|
/**
|
|
* Get Contexts
|
|
*
|
|
* @abstract { React.useContext }
|
|
*/ const { databases , user } = external_react_default().useContext(_user_id_.DashboardContext);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Javascript Variables
|
|
*
|
|
* @abstract Non hook variables and functions
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ ////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
|
|
children: [
|
|
/*#__PURE__*/ (0,jsx_runtime_.jsxs)("div", {
|
|
className: "flex-col items-start gap-0",
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx("h1", {
|
|
className: "text-3xl m-0",
|
|
children: "Dashboard"
|
|
}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx(Breadcrumbs/* default */.Z, {
|
|
user: user
|
|
})
|
|
]
|
|
}),
|
|
user?.verification_status?.toString().match(/1/) ? /*#__PURE__*/ (0,jsx_runtime_.jsxs)((external_react_default()).Fragment, {
|
|
children: [
|
|
/*#__PURE__*/ jsx_runtime_.jsx(Metrics, {}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx(DatabasesSummary, {}),
|
|
/*#__PURE__*/ jsx_runtime_.jsx(DelegatedDatabasesSection/* default */.Z, {
|
|
user: user
|
|
})
|
|
]
|
|
}) : /*#__PURE__*/ jsx_runtime_.jsx(VerificationBanner/* default */.Z, {})
|
|
]
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
} /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1457:
|
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "DashboardContext": () => (/* binding */ DashboardContext),
|
|
/* harmony export */ "default": () => (/* binding */ Dashboard),
|
|
/* harmony export */ "getServerSideProps": () => (/* binding */ getServerSideProps)
|
|
/* 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 _layouts_AdminLayout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4858);
|
|
/* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(370);
|
|
/* harmony import */ var _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_3__);
|
|
/* harmony import */ var _components_admin_dashboard_DashboardContent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8124);
|
|
/* harmony import */ var _components_admin_databases_DeleteDatabaseConfirmationPopup__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5012);
|
|
/* harmony import */ var _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9395);
|
|
/* harmony import */ var _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6__);
|
|
// @ts-check
|
|
/**
|
|
* ==============================================================================
|
|
* Imports
|
|
* ==============================================================================
|
|
*/
|
|
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
/** ****************************************************************************** */ /** @type {import("@/package-shared/types").DashboardContextType} */ let DashboardContextObject = {};
|
|
const DashboardContext = /*#__PURE__*/ react__WEBPACK_IMPORTED_MODULE_1___default().createContext(DashboardContextObject);
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Main Component { Functional }
|
|
* ==============================================================================
|
|
* @param {Object} props - Server props
|
|
* @param {import("@/package-shared/types").UserType} props.user - Server props
|
|
* @param {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type[]} props.databases - Server props
|
|
* @param {import("@/package-shared/types").MetricsType} props.metrics - Server props
|
|
*/ function Dashboard({ user , databases , metrics }) {
|
|
/**
|
|
* 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,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {
|
|
children: [
|
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("title", {
|
|
children: pageTitle
|
|
}),
|
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx("meta", {
|
|
name: "description",
|
|
content: pageDescription
|
|
})
|
|
]
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* React Hooks
|
|
*
|
|
* @abstract { useState, useEffect, useRef, etc ... }
|
|
*/ /** @type {*} */ const targetDbState = react__WEBPACK_IMPORTED_MODULE_1___default().useState(null);
|
|
/** @type { [ targetDatabase: import("@/package-shared/types").DSQL_MYSQL_user_databases_Type | undefined, setTargetDatabase: React.Dispatch<React.SetStateAction<import("@/package-shared/types").DSQL_MYSQL_user_databases_Type>> ] } */ const [targetDatabase, setTargetDatabase] = targetDbState;
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Function Return
|
|
*
|
|
* @abstract Main Function Return
|
|
*/ return /*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_layouts_AdminLayout__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Z, {
|
|
head: head,
|
|
user: user,
|
|
children: /*#__PURE__*/ (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)(DashboardContext.Provider, {
|
|
value: {
|
|
user,
|
|
databases,
|
|
targetDatabase,
|
|
setTargetDatabase,
|
|
metrics
|
|
},
|
|
children: [
|
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_admin_dashboard_DashboardContent__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Z, {}),
|
|
/*#__PURE__*/ react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx(_components_admin_databases_DeleteDatabaseConfirmationPopup__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .Z, {
|
|
targetDatabase: targetDatabase
|
|
})
|
|
]
|
|
})
|
|
});
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
|
* ==============================================================================
|
|
* Server Side Props or Static Props
|
|
* ==============================================================================
|
|
* @type {import("next").GetServerSideProps}
|
|
*/ async function getServerSideProps({ req , res , query }) {
|
|
/**
|
|
* User Auth
|
|
*
|
|
* @description User Auth
|
|
*/ const user = await _functions_backend_userAuth__WEBPACK_IMPORTED_MODULE_3___default()(req, res);
|
|
if (!user?.logged_in_status) {
|
|
return {
|
|
redirect: {
|
|
destination: "/login",
|
|
permanent: false
|
|
}
|
|
};
|
|
}
|
|
/**
|
|
* Page/Site Data Data Fetching
|
|
*
|
|
* @description Fetch data on the server before returning
|
|
*/ /** @type {import("@/package-shared/types").DSQL_MYSQL_user_databases_Type[]} */ const databases = await _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6___default()(`SELECT * FROM user_databases WHERE user_id=? ORDER BY id DESC LIMIT 3`, [
|
|
user.id
|
|
]);
|
|
const metrics = await _package_shared_utils_backend_global_db_DB_HANDLER__WEBPACK_IMPORTED_MODULE_6___default()(`
|
|
SELECT (
|
|
SELECT COUNT(id) FROM user_databases WHERE user_id=?
|
|
) AS dbCount,
|
|
(
|
|
SELECT COUNT(id) FROM user_database_tables WHERE user_id=?
|
|
) AS tablesCount,
|
|
(
|
|
SELECT COUNT(id) FROM user_media WHERE user_id=?
|
|
) AS mediaCount,
|
|
(
|
|
SELECT COUNT(id) FROM api_keys WHERE user_id=?
|
|
) AS apiKeysCount
|
|
`, [
|
|
user.id,
|
|
user.id,
|
|
user.id,
|
|
user.id
|
|
]);
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
/**
|
|
* Server props return
|
|
*
|
|
* @description Return data fetched on the server side
|
|
*/ return {
|
|
props: {
|
|
user: user,
|
|
databases: databases,
|
|
metrics: metrics && metrics[0] ? metrics[0] : {}
|
|
}
|
|
};
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
////////////////////////////////////////
|
|
}
|
|
|
|
|
|
/***/ })
|
|
|
|
};
|
|
; |