mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
QQQ-32: added booleans, cleaned up error handling, fixed infinite loop on unauthorized login, removed all the login buttons, removed redundant qClient functions
This commit is contained in:
@ -21,6 +21,7 @@ import {Alert} from "@mui/material";
|
||||
import MDBox from "components/MDBox";
|
||||
import MDTypography from "components/MDTypography";
|
||||
import MDButton from "../../../components/MDButton";
|
||||
import QClient from "qqq/utils/QClient";
|
||||
|
||||
// Declaring props types for EntityForm
|
||||
interface Props
|
||||
@ -30,7 +31,7 @@ interface Props
|
||||
|
||||
function EntityForm({id}: Props): JSX.Element
|
||||
{
|
||||
const qController = new QController("");
|
||||
const qController = QClient.getInstance();
|
||||
const {tableName} = useParams();
|
||||
|
||||
const [validations, setValidations] = useState({});
|
||||
|
@ -38,7 +38,6 @@ import {
|
||||
} from "context";
|
||||
|
||||
// qqq
|
||||
import AuthenticationButton from "qqq/components/buttons/AuthenticationButton";
|
||||
|
||||
// Declaring prop types for Navbar
|
||||
interface Props
|
||||
@ -159,14 +158,6 @@ function Navbar({absolute, light, isMini}: Props): JSX.Element
|
||||
<MDInput label="Search here" />
|
||||
</MDBox>
|
||||
<MDBox color={light ? "white" : "inherit"}>
|
||||
<AuthenticationButton />
|
||||
{ /*
|
||||
<Link to="/authentication/sign-in/basic">
|
||||
<IconButton sx={navbarIconButton} size="small" disableRipple>
|
||||
<Icon sx={iconsStyle}>account_circle</Icon>
|
||||
</IconButton>
|
||||
</Link>
|
||||
*/ }
|
||||
<IconButton
|
||||
size="small"
|
||||
disableRipple
|
||||
|
@ -66,6 +66,9 @@ class DynamicFormUtils
|
||||
case QFieldType.BLOB:
|
||||
fieldType = "file";
|
||||
break;
|
||||
case QFieldType.BOOLEAN:
|
||||
fieldType = "checkbox";
|
||||
break;
|
||||
case QFieldType.TEXT:
|
||||
case QFieldType.HTML:
|
||||
case QFieldType.STRING:
|
||||
|
@ -87,6 +87,7 @@ function EntityList({table}: Props): JSX.Element
|
||||
const columnVisibilityLocalStorageKey = `${COLUMN_VISIBILITY_LOCAL_STORAGE_KEY_ROOT}.${tableName}`;
|
||||
let defaultSort = [] as GridSortItem[];
|
||||
let defaultVisibility = {};
|
||||
const qController = QClient.getInstance();
|
||||
|
||||
if (localStorage.getItem(sortLocalStorageKey))
|
||||
{
|
||||
@ -193,7 +194,7 @@ function EntityList({table}: Props): JSX.Element
|
||||
{
|
||||
(async () =>
|
||||
{
|
||||
const newTableMetaData = await QClient.loadTableMetaData(tableName);
|
||||
const newTableMetaData = await qController.loadTableMetaData(tableName);
|
||||
setTableMetaData(newTableMetaData);
|
||||
if (columnSortModel.length === 0)
|
||||
{
|
||||
@ -206,14 +207,14 @@ function EntityList({table}: Props): JSX.Element
|
||||
|
||||
const qFilter = buildQFilter();
|
||||
|
||||
const count = await QClient.count(tableName, qFilter);
|
||||
const count = await qController.count(tableName, qFilter);
|
||||
setTotalRecords(count);
|
||||
setButtonText(`new ${newTableMetaData.label}`);
|
||||
setTableLabel(newTableMetaData.label);
|
||||
|
||||
const columns = [] as GridColDef[];
|
||||
|
||||
const results = await QClient.query(
|
||||
const results = await qController.query(
|
||||
tableName,
|
||||
qFilter,
|
||||
rowsPerPage,
|
||||
@ -362,7 +363,7 @@ function EntityList({table}: Props): JSX.Element
|
||||
setTableState(tableName);
|
||||
setFilterModel(null);
|
||||
setFiltersMenu(null);
|
||||
const metaData = await QClient.loadMetaData();
|
||||
const metaData = await qController.loadMetaData();
|
||||
|
||||
setTableProcesses(QProcessUtils.getProcessesForTable(metaData, tableName));
|
||||
|
||||
|
@ -38,8 +38,9 @@ import Icon from "@mui/material/Icon";
|
||||
import MDAlert from "components/MDAlert";
|
||||
import MDButton from "../../../../../components/MDButton";
|
||||
import QProcessUtils from "../../../../utils/QProcessUtils";
|
||||
import QClient from "qqq/utils/QClient";
|
||||
|
||||
const qController = new QController("");
|
||||
const qController = QClient.getInstance();
|
||||
|
||||
// Declaring props types for ViewForm
|
||||
interface Props
|
||||
|
@ -19,9 +19,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {QFieldMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QFieldMetaData";
|
||||
import {QController} from "@kingsrook/qqq-frontend-core/lib/controllers/QController";
|
||||
import {QQueryFilter} from "@kingsrook/qqq-frontend-core/lib/model/query/QQueryFilter";
|
||||
import {QException} from "@kingsrook/qqq-frontend-core/lib/exceptions/QException";
|
||||
import {useAuth0} from "@auth0/auth0-react";
|
||||
|
||||
/*******************************************************************************
|
||||
** client wrapper of qqq backend
|
||||
@ -31,40 +31,25 @@ class QClient
|
||||
{
|
||||
private static qController: QController;
|
||||
|
||||
private static handleException(exception: QException)
|
||||
{
|
||||
console.log(`Caught Exception: ${JSON.stringify(exception)}`);
|
||||
const {logout} = useAuth0();
|
||||
if (exception.status === "401")
|
||||
{
|
||||
logout();
|
||||
}
|
||||
}
|
||||
|
||||
public static getInstance()
|
||||
{
|
||||
if (this.qController == null)
|
||||
{
|
||||
this.qController = new QController("");
|
||||
this.qController = new QController("", this.handleException);
|
||||
}
|
||||
|
||||
return this.qController;
|
||||
}
|
||||
|
||||
public static loadTableMetaData(tableName: string)
|
||||
{
|
||||
return this.getInstance().loadTableMetaData(tableName);
|
||||
}
|
||||
|
||||
public static loadMetaData()
|
||||
{
|
||||
return this.getInstance().loadMetaData();
|
||||
}
|
||||
|
||||
public static query(tableName: string, filter: QQueryFilter, limit: number, skip: number)
|
||||
{
|
||||
return this.getInstance()
|
||||
.query(tableName, filter, limit, skip)
|
||||
.catch((error) =>
|
||||
{
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
public static count(tableName: string, filter: QQueryFilter)
|
||||
{
|
||||
return this.getInstance().count(tableName, filter);
|
||||
}
|
||||
}
|
||||
|
||||
export default QClient;
|
||||
|
Reference in New Issue
Block a user