diff --git a/.eslintrc.json b/.eslintrc.json index bbc7b81..eecb6d5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,7 +5,8 @@ }, "extends": [ "plugin:react/recommended", - "airbnb" + "plugin:import/recommended", + "plugin:import/typescript" ], "globals": { "JSX": true @@ -27,7 +28,8 @@ }, "plugins": [ "react", - "@typescript-eslint" + "@typescript-eslint", + "import" ], "rules": { "brace-style": [ @@ -56,7 +58,26 @@ "devDependencies": true } ], - "import/order": "off", + "import/order": [ + "error", + { + "groups": [ + "builtin", // Built-in imports (come from NodeJS native) go first + "external", // <- External imports + "internal", // <- Absolute imports + ["sibling", "parent"], // <- Relative imports, the sibling and parent types they can be mingled together + "index", // <- index imports + "unknown" + ], + "newlines-between": "never", + "alphabetize": { + /* sort in ascending order. Options: ["ignore", "asc", "desc"] */ + "order": "asc", + /* ignore case. Options: [true, false] */ + "caseInsensitive": true + } + } + ], "jsx-one-expression-per-line": "off", "max-len": "off", "no-console": "off", @@ -82,10 +103,7 @@ ] } ], - "react/jsx-indent": [ - "error", - 3 - ], + "react/jsx-indent": "off", "react/jsx-indent-props": [ "error", 3 @@ -95,6 +113,15 @@ "quotes": [ "error", "double" + ], + "sort-imports": [ + "error", + { + "ignoreCase": false, + "ignoreDeclarationSort": true, + "ignoreMemberSort": true, + "allowSeparatedGroups": false + } ] }, "settings": { diff --git a/package.json b/package.json index 7145fd9..d278cb2 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@fullcalendar/interaction": "5.10.0", "@fullcalendar/react": "5.10.0", "@fullcalendar/timegrid": "5.10.0", - "@kingsrook/qqq-frontend-core": "1.0.13", + "@kingsrook/qqq-frontend-core": "1.0.14", "@mui/icons-material": "5.4.1", "@mui/material": "5.4.1", "@mui/styled-engine": "5.4.1", diff --git a/public/apple-icon.png b/public/apple-icon.png index 59c68b9..d594bc6 100644 Binary files a/public/apple-icon.png and b/public/apple-icon.png differ diff --git a/public/favicon.png b/public/favicon.png index 59c68b9..d594bc6 100644 Binary files a/public/favicon.png and b/public/favicon.png differ diff --git a/src/App.tsx b/src/App.tsx index 9508ad8..b4a564f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,56 +1,56 @@ -import React, { - JSXElementConstructor, Key, ReactElement, useEffect, useState, -} from "react"; - -// react-router components -import { - Navigate, Route, Routes, useLocation, -} from "react-router-dom"; +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ import {useAuth0} from "@auth0/auth0-react"; - -// @mui material components -import {LicenseInfo} from "@mui/x-license-pro"; -import {ThemeProvider} from "@mui/material/styles"; +import {QAppNodeType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QAppNodeType"; +import {QAppTreeNode} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QAppTreeNode"; +import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstance"; import CssBaseline from "@mui/material/CssBaseline"; import Icon from "@mui/material/Icon"; - -// Material Dashboard 2 PRO React TS components -import MDBox from "components/MDBox"; - -// Material Dashboard 2 PRO React TS exampless -import Sidenav from "examples/Sidenav"; -import Configurator from "examples/Configurator"; - -// Material Dashboard 2 PRO React TS themes -import theme from "assets/theme"; - -// Material Dashboard 2 PRO React TS Dark Mode themes -import themeDark from "assets/theme-dark"; - -// Material Dashboard 2 PRO React TS contexts -import {setMiniSidenav, setOpenConfigurator, useMaterialUIController} from "context"; - -// Images -import nfLogo from "assets/images/nutrifresh_one_icon_white.png"; -import {Md5} from "ts-md5/dist/md5"; +import {ThemeProvider} from "@mui/material/styles"; +import {LicenseInfo} from "@mui/x-license-pro"; +import React, {JSXElementConstructor, Key, ReactElement, useEffect, useState,} from "react"; import {useCookies} from "react-cookie"; -import EntityCreate from "./qqq/pages/entity-create"; -import EntityList from "./qqq/pages/entity-list"; -import EntityView from "./qqq/pages/entity-view"; -import EntityEdit from "./qqq/pages/entity-edit"; -import ProcessRun from "./qqq/pages/process-run"; +import {Navigate, Route, Routes, useLocation,} from "react-router-dom"; +import {Md5} from "ts-md5/dist/md5"; +import theme from "assets/theme"; +import themeDark from "assets/theme-dark"; +import MDBox from "components/MDBox"; +import {setMiniSidenav, setOpenConfigurator, useMaterialUIController} from "context"; +import Configurator from "examples/Configurator"; +import Sidenav from "examples/Sidenav"; import AppHome from "qqq/pages/app-home"; +import QProcessUtils from "qqq/utils/QProcessUtils"; import MDAvatar from "./components/MDAvatar"; -import ProfileOverview from "./layouts/pages/profile/profile-overview"; -import Settings from "./layouts/pages/account/settings"; import Analytics from "./layouts/dashboards/analytics"; import Sales from "./layouts/dashboards/sales"; +import Settings from "./layouts/pages/account/settings"; +import ProfileOverview from "./layouts/pages/profile/profile-overview"; +import Logo from "./qqq/images/logo.png"; +import EntityCreate from "./qqq/pages/entity-create"; +import EntityEdit from "./qqq/pages/entity-edit"; +import EntityList from "./qqq/pages/entity-list"; +import EntityView from "./qqq/pages/entity-view"; +import ProcessRun from "./qqq/pages/process-run"; import QClient from "./qqq/utils/QClient"; -import {QAppNodeType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QAppNodeType"; -import {QInstance} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QInstance"; -import QProcessUtils from "qqq/utils/QProcessUtils"; -import {QAppTreeNode} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QAppTreeNode"; /////////////////////////////////////////////////////////////////////////////////////////////// // define the parts of the nav that are static - before the qqq tables etc get dynamic added // @@ -436,7 +436,7 @@ export default function App() <> . + */ + import React, {useEffect} from "react"; -import {SESSION_ID_COOKIE_NAME} from "App"; import {useCookies} from "react-cookie"; +import {SESSION_ID_COOKIE_NAME} from "App"; interface Props { diff --git a/src/assets/images/favicon.png b/src/assets/images/favicon.png index 59c68b9..d594bc6 100644 Binary files a/src/assets/images/favicon.png and b/src/assets/images/favicon.png differ diff --git a/src/index.tsx b/src/index.tsx index 4f978af..52adb68 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,16 +1,35 @@ -import ReactDOM from "react-dom"; -import {BrowserRouter, useNavigate, useSearchParams} from "react-router-dom"; -import {Auth0Provider} from "@auth0/auth0-react"; -import App from "App"; +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ -// Material Dashboard 2 PRO React TS Context Provider +import {Auth0Provider} from "@auth0/auth0-react"; +import React from "react"; +import {render} from "react-dom"; +import {BrowserRouter, useNavigate, useSearchParams} from "react-router-dom"; +import App from "App"; import {MaterialUIControllerProvider} from "context"; import "./qqq/styles/qqq-override-styles.css"; -import ProtectedRoute from "qqq/auth0/protected-route"; -import React from "react"; import HandleAuthorizationError from "HandleAuthorizationError"; +import ProtectedRoute from "qqq/auth0/protected-route"; + -// Auth0 params from env const domain = process.env.REACT_APP_AUTH0_DOMAIN; const clientId = process.env.REACT_APP_AUTH0_CLIENT_ID; @@ -43,7 +62,7 @@ function Auth0ProviderWithRedirectCallback({children, ...props}) } } -ReactDOM.render( +render( . + */ -// misc components -import * as Yup from "yup"; -import { - Form, Formik, useFormik, useFormikContext, -} from "formik"; - -// qqq components -import DynamicFormUtils from "qqq/components/QDynamicForm/utils/DynamicFormUtils"; -import QDynamicForm from "qqq/components/QDynamicForm"; import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData"; - -// @material-ui core components +import {QSection} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QSection"; +import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData"; +import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord"; +import {Alert} from "@mui/material"; +import Avatar from "@mui/material/Avatar"; import Card from "@mui/material/Card"; import Grid from "@mui/material/Grid"; -import {Alert} from "@mui/material"; - -// Material Dashboard 2 PRO React TS components +import Icon from "@mui/material/Icon"; +import {Form, Formik} from "formik"; +import React, {useReducer, useState} from "react"; +import {useParams, useNavigate, useLocation} from "react-router-dom"; +import * as Yup from "yup"; +import colors from "assets/theme/base/colors"; import MDBox from "components/MDBox"; import MDTypography from "components/MDTypography"; -import QClient from "qqq/utils/QClient"; -import {QTableMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QTableMetaData"; import {QCancelButton, QSaveButton} from "qqq/components/QButtons"; -import {QRecord} from "@kingsrook/qqq-frontend-core/lib/model/QRecord"; -import Avatar from "@mui/material/Avatar"; -import Icon from "@mui/material/Icon"; +import QDynamicForm from "qqq/components/QDynamicForm"; +import DynamicFormUtils from "qqq/components/QDynamicForm/utils/DynamicFormUtils"; import QRecordSidebar from "qqq/components/QRecordSidebar"; +import QClient from "qqq/utils/QClient"; import QTableUtils from "qqq/utils/QTableUtils"; -import colors from "assets/theme/base/colors"; -import {QSection} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QSection"; interface Props { diff --git a/src/qqq/components/Footer/index.tsx b/src/qqq/components/Footer/index.tsx index e976520..6ebe4c7 100644 --- a/src/qqq/components/Footer/index.tsx +++ b/src/qqq/components/Footer/index.tsx @@ -19,28 +19,25 @@ * along with this program. If not, see . */ -// @mui material components import Link from "@mui/material/Link"; -import Icon from "@mui/material/Icon"; - -// Material Dashboard 2 PRO React TS components +import typography from "assets/theme/base/typography"; import MDBox from "components/MDBox"; import MDTypography from "components/MDTypography"; -// Material Dashboard 2 PRO React TS Base Styles -import typography from "assets/theme/base/typography"; // Declaring props types for Footer -interface Props { - company?: { - href: string; - name: string; - }; - links?: { - href: string; - name: string; - }[]; - [key: string]: any; +interface Props +{ + company?: { + href: string; + name: string; + }; + links?: { + href: string; + name: string; + }[]; + + [key: string]: any; } function Footer({company, links}: Props): JSX.Element @@ -85,9 +82,9 @@ function Footer({company, links}: Props): JSX.Element , -   +   {name} -  +   diff --git a/src/qqq/components/Navbar/index.tsx b/src/qqq/components/Navbar/index.tsx index 3b4ac40..9674fca 100644 --- a/src/qqq/components/Navbar/index.tsx +++ b/src/qqq/components/Navbar/index.tsx @@ -19,45 +19,19 @@ * along with this program. If not, see . */ -import {useState, useEffect} from "react"; - -// react-router components -import {useLocation} from "react-router-dom"; - -// @material-ui core components import AppBar from "@mui/material/AppBar"; -import Toolbar from "@mui/material/Toolbar"; +import Icon from "@mui/material/Icon"; import IconButton from "@mui/material/IconButton"; import Menu from "@mui/material/Menu"; -import Icon from "@mui/material/Icon"; - -// Material Dashboard 2 PRO React TS components +import Toolbar from "@mui/material/Toolbar"; +import {useState, useEffect} from "react"; +import {useLocation} from "react-router-dom"; +import MDBadge from "components/MDBadge"; import MDBox from "components/MDBox"; import MDInput from "components/MDInput"; -import MDBadge from "components/MDBadge"; - -// Material Dashboard 2 PRO React TS examples components +import {useMaterialUIController, setTransparentNavbar, setMiniSidenav, setOpenConfigurator,} from "context"; import NotificationItem from "examples/Items/NotificationItem"; - -// Custom styles for Navbar -import { - navbar, - navbarContainer, - navbarRow, - navbarIconButton, - navbarDesktopMenu, - navbarMobileMenu, -} from "qqq/components/Navbar/styles"; - -// Material Dashboard 2 PRO React context -import { - useMaterialUIController, - setTransparentNavbar, - setMiniSidenav, - setOpenConfigurator, -} from "context"; - -// qqq +import {navbar, navbarContainer, navbarRow, navbarIconButton, navbarDesktopMenu, navbarMobileMenu,} from "qqq/components/Navbar/styles"; import QBreadcrumbs, {routeToLabel} from "qqq/components/QBreadcrumbs"; // Declaring prop types for Navbar diff --git a/src/qqq/components/Navbar/styles.ts b/src/qqq/components/Navbar/styles.ts index 7fa3afc..999c130 100644 --- a/src/qqq/components/Navbar/styles.ts +++ b/src/qqq/components/Navbar/styles.ts @@ -19,7 +19,6 @@ * along with this program. If not, see . */ -// @mui material components import {Theme} from "@mui/material/styles"; function navbar(theme: Theme | any, ownerState: any) diff --git a/src/qqq/components/ProcessLinkCard/index.tsx b/src/qqq/components/ProcessLinkCard/index.tsx index 0be3bd4..c57936f 100644 --- a/src/qqq/components/ProcessLinkCard/index.tsx +++ b/src/qqq/components/ProcessLinkCard/index.tsx @@ -18,14 +18,11 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import {ReactNode} from "react"; -// @mui material components import Card from "@mui/material/Card"; import Divider from "@mui/material/Divider"; import Icon from "@mui/material/Icon"; - -// Material Dashboard 2 PRO React TS components +import {ReactNode} from "react"; import MDBox from "components/MDBox"; import MDTypography from "components/MDTypography"; diff --git a/src/qqq/components/QBreadcrumbs/index.tsx b/src/qqq/components/QBreadcrumbs/index.tsx index 248cfa1..94587e7 100644 --- a/src/qqq/components/QBreadcrumbs/index.tsx +++ b/src/qqq/components/QBreadcrumbs/index.tsx @@ -19,11 +19,10 @@ * along with this program. If not, see . */ -import {ReactNode} from "react"; - -import {Link} from "react-router-dom"; import {Breadcrumbs as MuiBreadcrumbs} from "@mui/material"; import Icon from "@mui/material/Icon"; +import {ReactNode} from "react"; +import {Link} from "react-router-dom"; import MDBox from "components/MDBox"; import MDTypography from "components/MDTypography"; diff --git a/src/qqq/components/QButtons/index.tsx b/src/qqq/components/QButtons/index.tsx index 6f54183..e02a180 100644 --- a/src/qqq/components/QButtons/index.tsx +++ b/src/qqq/components/QButtons/index.tsx @@ -19,12 +19,11 @@ * along with this program. If not, see . */ -import MDBox from "components/MDBox"; -import {Link} from "react-router-dom"; -import MDButton from "components/MDButton"; import Icon from "@mui/material/Icon"; import React from "react"; -import EntityForm from "qqq/components/EntityForm"; +import {Link} from "react-router-dom"; +import MDBox from "components/MDBox"; +import MDButton from "components/MDButton"; // eslint-disable import/prefer-default-export diff --git a/src/qqq/components/QDynamicForm/index.tsx b/src/qqq/components/QDynamicForm/index.tsx index 71c5d17..3516d30 100644 --- a/src/qqq/components/QDynamicForm/index.tsx +++ b/src/qqq/components/QDynamicForm/index.tsx @@ -19,23 +19,19 @@ * along with this program. If not, see . */ -// @mui material components import Grid from "@mui/material/Grid"; - -// Material Dashboard 2 PRO React TS components -import MDBox from "components/MDBox"; -import MDTypography from "components/MDTypography"; - -// NewUser page components import {useFormikContext} from "formik"; import React from "react"; +import MDBox from "components/MDBox"; +import MDTypography from "components/MDTypography"; import QDynamicFormField from "qqq/components/QDynamicFormField"; -interface Props { - formLabel?: string; - formData: any; - bulkEditMode?: boolean; - bulkEditSwitchChangeHandler?: any +interface Props +{ + formLabel?: string; + formData: any; + bulkEditMode?: boolean; + bulkEditSwitchChangeHandler?: any; } function QDynamicForm(props: Props): JSX.Element @@ -72,55 +68,55 @@ function QDynamicForm(props: Props): JSX.Element {formFields - && Object.keys(formFields).length > 0 - && Object.keys(formFields).map((fieldName: any) => - { - const field = formFields[fieldName]; - if (values[fieldName] === undefined) - { - values[fieldName] = ""; - } + && Object.keys(formFields).length > 0 + && Object.keys(formFields).map((fieldName: any) => + { + const field = formFields[fieldName]; + if (values[fieldName] === undefined) + { + values[fieldName] = ""; + } - if (field.type === "file") - { - return ( - - - + + ) => fileChanged(event, field)} + /> + + + {errors[fieldName] && You must select a file to proceed} + + + + + ); + } + + // todo? inputProps={{ autoComplete: "" }} + // todo? placeholder={password.placeholder} + return ( + + ) => fileChanged(event, field)} + displayFormat={field.displayFormat} + value={values[fieldName]} + error={errors[fieldName] && touched[fieldName]} + bulkEditMode={bulkEditMode} + bulkEditSwitchChangeHandler={bulkEditSwitchChanged} + success={`${values[fieldName]}` !== "" && !errors[fieldName] && touched[fieldName]} /> - - - {errors[fieldName] && You must select a file to proceed} - - - - - ); - } - - // todo? inputProps={{ autoComplete: "" }} - // todo? placeholder={password.placeholder} - return ( - - - - ); - })} + + ); + })} @@ -131,7 +127,8 @@ QDynamicForm.defaultProps = { formLabel: undefined, bulkEditMode: false, bulkEditSwitchChangeHandler: () => - {}, + { + }, }; export default QDynamicForm; diff --git a/src/qqq/components/QDynamicForm/utils/DynamicFormUtils.ts b/src/qqq/components/QDynamicForm/utils/DynamicFormUtils.ts index 812fd77..dbdead7 100644 --- a/src/qqq/components/QDynamicForm/utils/DynamicFormUtils.ts +++ b/src/qqq/components/QDynamicForm/utils/DynamicFormUtils.ts @@ -19,12 +19,9 @@ * along with this program. If not, see . */ -// misc imports -import * as Yup from "yup"; - -// qqq imports import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData"; import {QFieldType} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldType"; +import * as Yup from "yup"; /******************************************************************************* ** Meta-data to represent a single field in a table. diff --git a/src/qqq/components/QDynamicFormField/index.tsx b/src/qqq/components/QDynamicFormField/index.tsx index b521445..9540671 100644 --- a/src/qqq/components/QDynamicFormField/index.tsx +++ b/src/qqq/components/QDynamicFormField/index.tsx @@ -19,17 +19,14 @@ * along with this program. If not, see . */ -// formik components -import {ErrorMessage, Field} from "formik"; - -// Material Dashboard 2 PRO React TS components -import MDBox from "components/MDBox"; -import MDTypography from "components/MDTypography"; -import MDInput from "components/MDInput"; -import React, {useState} from "react"; +import {InputAdornment} from "@mui/material"; import Grid from "@mui/material/Grid"; import Switch from "@mui/material/Switch"; -import {InputAdornment} from "@mui/material"; +import {ErrorMessage, Field} from "formik"; +import React, {useState} from "react"; +import MDBox from "components/MDBox"; +import MDInput from "components/MDInput"; +import MDTypography from "components/MDTypography"; // Declaring props types for FormField interface Props diff --git a/src/qqq/components/QRecordSidebar/index.tsx b/src/qqq/components/QRecordSidebar/index.tsx index 85c5b04..d146825 100644 --- a/src/qqq/components/QRecordSidebar/index.tsx +++ b/src/qqq/components/QRecordSidebar/index.tsx @@ -19,16 +19,15 @@ * along with this program. If not, see . */ -import React, {ReactNode} from "react"; - -import {Link} from "react-router-dom"; +import {QSection} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QSection"; import {Breadcrumbs as MuiBreadcrumbs} from "@mui/material"; +import Card from "@mui/material/Card"; import Icon from "@mui/material/Icon"; +import {Theme} from "@mui/material/styles"; +import React, {ReactNode} from "react"; +import {Link} from "react-router-dom"; import MDBox from "components/MDBox"; import MDTypography from "components/MDTypography"; -import Card from "@mui/material/Card"; -import {Theme} from "@mui/material/styles"; -import {QSection} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QSection"; interface Props { tableSections: QSection[]; diff --git a/src/qqq/components/Widgets/BarChart.tsx b/src/qqq/components/Widgets/BarChart.tsx new file mode 100644 index 0000000..d18972d --- /dev/null +++ b/src/qqq/components/Widgets/BarChart.tsx @@ -0,0 +1,99 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import Card from "@mui/material/Card"; +import Divider from "@mui/material/Divider"; +import Icon from "@mui/material/Icon"; +import {useMemo, ReactNode} from "react"; +import {Bar} from "react-chartjs-2"; +import MDBox from "components/MDBox"; +import MDTypography from "components/MDTypography"; +import configs from "qqq/components/Widgets/Configs/BarChartConfig"; + +// Declaring props types for ReportsBarChart +interface Props { + color?: "primary" | "secondary" | "info" | "success" | "warning" | "error" | "dark"; + title: string; + description?: string | ReactNode; + date: string; + chart: { + labels: string[]; + datasets: { + label: string; + data: number[]; + }; + }; + [key: string]: any; +} + +function ReportsBarChart({color, title, description, date, chart}: Props): JSX.Element +{ + const {data, options} = configs(chart.labels || [], chart.datasets || {}); + + return ( + + + {useMemo( + () => ( + + + + ), + [chart, color] + )} + + + {title} + + + {description} + + + + + schedule + + + {date} + + + + + + ); +} + +// Setting default values for the props of ReportsBarChart +ReportsBarChart.defaultProps = { + color: "dark", + description: "", +}; + +export default ReportsBarChart; diff --git a/src/qqq/components/Widgets/Configs/BarChartConfig.ts b/src/qqq/components/Widgets/Configs/BarChartConfig.ts new file mode 100644 index 0000000..6478675 --- /dev/null +++ b/src/qqq/components/Widgets/Configs/BarChartConfig.ts @@ -0,0 +1,104 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +function configs(labels: any, datasets: any) +{ + return { + data: { + labels, + datasets: [ + { + label: datasets.label, + tension: 0.4, + borderWidth: 0, + borderRadius: 4, + borderSkipped: false, + backgroundColor: "rgba(255, 255, 255, 0.8)", + data: datasets.data, + maxBarThickness: 6, + }, + ], + }, + options: { + responsive: true, + maintainAspectRatio: false, + plugins: { + legend: { + display: false, + }, + }, + interaction: { + intersect: false, + mode: "index", + }, + scales: { + y: { + grid: { + drawBorder: false, + display: true, + drawOnChartArea: true, + drawTicks: false, + borderDash: [5, 5], + color: "rgba(255, 255, 255, .2)", + }, + ticks: { + suggestedMin: 0, + suggestedMax: 500, + beginAtZero: true, + padding: 10, + font: { + size: 14, + weight: 300, + family: "Roboto", + style: "normal", + lineHeight: 2, + }, + color: "#fff", + }, + }, + x: { + grid: { + drawBorder: false, + display: true, + drawOnChartArea: true, + drawTicks: false, + borderDash: [5, 5], + color: "rgba(255, 255, 255, .2)", + }, + ticks: { + display: true, + color: "#f8f9fa", + padding: 10, + font: { + size: 14, + weight: 300, + family: "Roboto", + style: "normal", + lineHeight: 2, + }, + }, + }, + }, + }, + }; +} + +export default configs; diff --git a/src/qqq/components/Widgets/Configs/PieChartConfigs.ts b/src/qqq/components/Widgets/Configs/PieChartConfigs.ts new file mode 100644 index 0000000..eed60ec --- /dev/null +++ b/src/qqq/components/Widgets/Configs/PieChartConfigs.ts @@ -0,0 +1,100 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import colors from "assets/theme/base/colors"; + +const {gradients, dark} = colors; + +function configs(labels: any, datasets: any) +{ + const backgroundColors = []; + + if (datasets.backgroundColors) + { + datasets.backgroundColors.forEach((color: string) => + gradients[color] + ? backgroundColors.push(gradients[color].state) + : backgroundColors.push(dark.main) + ); + } + else + { + backgroundColors.push(dark.main); + } + + return { + data: { + labels, + datasets: [ + { + label: datasets.label, + weight: 9, + cutout: 0, + tension: 0.9, + pointRadius: 2, + borderWidth: 2, + backgroundColor: backgroundColors, + fill: false, + data: datasets.data, + }, + ], + }, + options: { + responsive: true, + maintainAspectRatio: false, + plugins: { + legend: { + display: false, + }, + }, + interaction: { + intersect: false, + mode: "index", + }, + scales: { + y: { + grid: { + drawBorder: false, + display: false, + drawOnChartArea: false, + drawTicks: false, + }, + ticks: { + display: false, + }, + }, + x: { + grid: { + drawBorder: false, + display: false, + drawOnChartArea: false, + drawTicks: false, + }, + ticks: { + display: false, + }, + }, + }, + }, + }; +} + +export default configs; diff --git a/src/qqq/components/Widgets/PieChart.tsx b/src/qqq/components/Widgets/PieChart.tsx new file mode 100644 index 0000000..f7d55cd --- /dev/null +++ b/src/qqq/components/Widgets/PieChart.tsx @@ -0,0 +1,110 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import Card from "@mui/material/Card"; +import Icon from "@mui/material/Icon"; +import {useMemo, ReactNode} from "react"; +import {Pie} from "react-chartjs-2"; +import MDBox from "components/MDBox"; +import MDTypography from "components/MDTypography"; +import configs from "qqq/components/Widgets/Configs/PieChartConfigs" + +// Declaring props types for PieChart +interface Props +{ + icon?: { + color?: "primary" | "secondary" | "info" | "success" | "warning" | "error" | "light" | "dark"; + component: ReactNode; + }; + title?: string; + description?: string | ReactNode; + height?: string | number; + chart: { + labels: string[]; + datasets: { + label: string; + backgroundColors: string[]; + data: number[]; + }; + }; + + [key: string]: any; +} + +function PieChart({icon, title, description, height, chart}: Props): JSX.Element +{ + const {data, options} = configs(chart.labels || [], chart.datasets || {}); + + const renderChart = ( + + {title || description ? ( + + {icon.component && ( + + {icon.component} + + )} + + {title && {title}} + + + {description} + + + + + ) : null} + {useMemo( + () => ( + + + + ), + [chart, height] + )} + + ); + + return title || description ? {renderChart} : renderChart; +} + +// Declaring default props for PieChart +PieChart.defaultProps = { + icon: {color: "info", component: ""}, + title: "", + description: "", + height: "19.125rem", +}; + +export default PieChart; diff --git a/src/qqq/components/Widgets/QuickSightChart.tsx b/src/qqq/components/Widgets/QuickSightChart.tsx new file mode 100644 index 0000000..845e356 --- /dev/null +++ b/src/qqq/components/Widgets/QuickSightChart.tsx @@ -0,0 +1,57 @@ +/* + * QQQ - Low-code Application Framework for Engineers. + * Copyright (C) 2021-2022. Kingsrook, LLC + * 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States + * contact@kingsrook.com + * https://github.com/Kingsrook/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import Card from "@mui/material/Card"; +import React from "react"; +import MDBox from "components/MDBox"; +import MDTypography from "components/MDTypography"; + +interface Props +{ + label: string; + url: string; +} + +interface IframeProps +{ + iframe: string; +} + +function Iframe({iframe}: IframeProps) +{ + return (
); +} + +function QuickSightChart({label, url}: Props): JSX.Element +{ + const iframe = `