mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 05:10:45 +00:00
- New Composite & Block widget constructs. - Option for a parent widget's label to be the app home page's label - Updates to table-widget handling of fixed footer (to expand and stay fixed) - Option for widgets to have CSV Data that can be exported differently from just the data "in" the widget. -- This included changing the default value for showExportButton from true to false
91 lines
3.4 KiB
TypeScript
91 lines
3.4 KiB
TypeScript
/*
|
|
* QQQ - Low-code Application Framework for Engineers.
|
|
* Copyright (C) 2021-2024. 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 <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
|
|
import {QWidgetMetaData} from "@kingsrook/qqq-frontend-core/lib/model/metaData/QWidgetMetaData";
|
|
import {Alert, Skeleton} from "@mui/material";
|
|
import React from "react";
|
|
import BigNumberBlock from "qqq/components/widgets/blocks/BigNumberBlock";
|
|
import {BlockData} from "qqq/components/widgets/blocks/BlockModels";
|
|
import DividerBlock from "qqq/components/widgets/blocks/DividerBlock";
|
|
import NumberIconBadgeBlock from "qqq/components/widgets/blocks/NumberIconBadgeBlock";
|
|
import ProgressBarBlock from "qqq/components/widgets/blocks/ProgressBarBlock";
|
|
import TableSubRowDetailRowBlock from "qqq/components/widgets/blocks/TableSubRowDetailRowBlock";
|
|
import TextBlock from "qqq/components/widgets/blocks/TextBlock";
|
|
import UpOrDownNumberBlock from "qqq/components/widgets/blocks/UpOrDownNumberBlock";
|
|
import CompositeWidget from "qqq/components/widgets/CompositeWidget";
|
|
|
|
|
|
interface WidgetBlockProps
|
|
{
|
|
widgetMetaData: QWidgetMetaData;
|
|
block: BlockData;
|
|
}
|
|
|
|
|
|
/*******************************************************************************
|
|
** Component to render a single Block in the widget framework!
|
|
*******************************************************************************/
|
|
export default function WidgetBlock({widgetMetaData, block}: WidgetBlockProps): JSX.Element
|
|
{
|
|
if(!block)
|
|
{
|
|
return (<Skeleton />);
|
|
}
|
|
|
|
if(!block.values)
|
|
{
|
|
block.values = {};
|
|
}
|
|
|
|
if(!block.styles)
|
|
{
|
|
block.styles = {};
|
|
}
|
|
|
|
if(block.blockTypeName == "COMPOSITE")
|
|
{
|
|
// @ts-ignore - special case for composite type block...
|
|
return (<CompositeWidget widgetMetaData={widgetMetaData} data={block} />);
|
|
}
|
|
|
|
switch(block.blockTypeName)
|
|
{
|
|
case "TEXT":
|
|
return (<TextBlock widgetMetaData={widgetMetaData} data={block} />);
|
|
case "NUMBER_ICON_BADGE":
|
|
return (<NumberIconBadgeBlock widgetMetaData={widgetMetaData} data={block} />);
|
|
case "UP_OR_DOWN_NUMBER":
|
|
return (<UpOrDownNumberBlock widgetMetaData={widgetMetaData} data={block} />);
|
|
case "TABLE_SUB_ROW_DETAIL_ROW":
|
|
return (<TableSubRowDetailRowBlock widgetMetaData={widgetMetaData} data={block} />);
|
|
case "PROGRESS_BAR":
|
|
return (<ProgressBarBlock widgetMetaData={widgetMetaData} data={block} />);
|
|
case "DIVIDER":
|
|
return (<DividerBlock widgetMetaData={widgetMetaData} data={block} />);
|
|
case "BIG_NUMBER":
|
|
return (<BigNumberBlock widgetMetaData={widgetMetaData} data={block} />);
|
|
default:
|
|
return (<Alert sx={{m: "0.5rem"}} color="warning">Unsupported block type: {block.blockTypeName}</Alert>)
|
|
}
|
|
|
|
}
|