SPRINT-12: added widget meta data

This commit is contained in:
Tim Chamberlain
2022-10-03 14:02:55 -05:00
parent 7415732c6c
commit bb85d362fb
14 changed files with 393 additions and 19 deletions

View File

@ -30,11 +30,13 @@ import com.kingsrook.qqq.backend.core.actions.ActionHelper;
import com.kingsrook.qqq.backend.core.exceptions.QException; import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.model.actions.metadata.MetaDataInput; import com.kingsrook.qqq.backend.core.model.actions.metadata.MetaDataInput;
import com.kingsrook.qqq.backend.core.model.actions.metadata.MetaDataOutput; import com.kingsrook.qqq.backend.core.model.actions.metadata.MetaDataOutput;
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.QWidgetMetaDataInterface;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.AppTreeNode; import com.kingsrook.qqq.backend.core.model.metadata.frontend.AppTreeNode;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendAppMetaData; import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendAppMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendProcessMetaData; import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendProcessMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendReportMetaData; import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendReportMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendTableMetaData; import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendTableMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendWidgetMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppChildMetaData; import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppChildMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData; import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData; import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
@ -94,6 +96,16 @@ public class MetaDataAction
} }
metaDataOutput.setReports(reports); metaDataOutput.setReports(reports);
//////////////////////////////////////
// map widgets to frontend metadata //
//////////////////////////////////////
Map<String, QFrontendWidgetMetaData> widgets = new LinkedHashMap<>();
for(Map.Entry<String, QWidgetMetaDataInterface> entry : metaDataInput.getInstance().getWidgets().entrySet())
{
widgets.put(entry.getKey(), new QFrontendWidgetMetaData(entry.getValue()));
}
metaDataOutput.setWidgets(widgets);
/////////////////////////////////// ///////////////////////////////////
// map apps to frontend metadata // // map apps to frontend metadata //
/////////////////////////////////// ///////////////////////////////////

View File

@ -31,6 +31,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendAppMetaDa
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendProcessMetaData; import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendProcessMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendReportMetaData; import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendReportMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendTableMetaData; import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendTableMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.frontend.QFrontendWidgetMetaData;
/******************************************************************************* /*******************************************************************************
@ -43,9 +44,9 @@ public class MetaDataOutput extends AbstractActionOutput
private Map<String, QFrontendProcessMetaData> processes; private Map<String, QFrontendProcessMetaData> processes;
private Map<String, QFrontendReportMetaData> reports; private Map<String, QFrontendReportMetaData> reports;
private Map<String, QFrontendAppMetaData> apps; private Map<String, QFrontendAppMetaData> apps;
private Map<String, QFrontendWidgetMetaData> widgets;
private List<AppTreeNode> appTree; private List<AppTreeNode> appTree;
private QBrandingMetaData branding; private QBrandingMetaData branding;
@ -160,6 +161,28 @@ public class MetaDataOutput extends AbstractActionOutput
/*******************************************************************************
** Getter for widgets
**
*******************************************************************************/
public Map<String, QFrontendWidgetMetaData> getWidgets()
{
return widgets;
}
/*******************************************************************************
** Setter for widgets
**
*******************************************************************************/
public void setWidgets(Map<String, QFrontendWidgetMetaData> widgets)
{
this.widgets = widgets;
}
/******************************************************************************* /*******************************************************************************
** Getter for branding ** Getter for branding
** **

View File

@ -69,7 +69,7 @@ public class ChartData implements QWidget
*******************************************************************************/ *******************************************************************************/
public String getType() public String getType()
{ {
return "barChart"; return WidgetType.CHART.getType();
} }

View File

@ -78,7 +78,7 @@ public class LineChartData implements QWidget
*******************************************************************************/ *******************************************************************************/
public String getType() public String getType()
{ {
return "lineChart"; return WidgetType.LINE_CHART.getType();
} }

View File

@ -56,7 +56,7 @@ public class LocationData implements QWidget
*******************************************************************************/ *******************************************************************************/
public String getType() public String getType()
{ {
return "location"; return WidgetType.LOCATION.getType();
} }

View File

@ -62,7 +62,7 @@ public class MultiStatisticsData implements QWidget
*******************************************************************************/ *******************************************************************************/
public String getType() public String getType()
{ {
return "multiStatistics"; return WidgetType.MULTI_STATISTICS.getType();
} }

View File

@ -53,7 +53,7 @@ public class QuickSightChart implements QWidget
*******************************************************************************/ *******************************************************************************/
public String getType() public String getType()
{ {
return "quickSightChart"; return WidgetType.QUICK_SIGHT_CHART.getType();
} }

View File

@ -59,7 +59,7 @@ public class RawHTML implements QWidget
*******************************************************************************/ *******************************************************************************/
public String getType() public String getType()
{ {
return "html"; return WidgetType.HTML.getType();
} }

View File

@ -55,7 +55,7 @@ public class StepperData implements QWidget
*******************************************************************************/ *******************************************************************************/
public String getType() public String getType()
{ {
return "stepper"; return WidgetType.STEPPER.getType();
} }

View File

@ -0,0 +1,64 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.kingsrook.qqq.backend.core.model.dashboard.widgets;
/*******************************************************************************
** Possible values for widget type
*******************************************************************************/
public enum WidgetType
{
CHART("chart"),
HTML("html"),
LINE_CHART("lineChart"),
LOCATION("location"),
MULTI_STATISTICS("multiStatistics"),
QUICK_SIGHT_CHART("quickSightChart"),
STATISTICS("statistics"),
STEPPER("stepper"),
TABLE("table");
private final String type;
/*******************************************************************************
**
*******************************************************************************/
WidgetType(String type)
{
this.type = type;
}
/*******************************************************************************
** Getter for type
**
*******************************************************************************/
public String getType()
{
return type;
}
}

View File

@ -31,8 +31,11 @@ import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
*******************************************************************************/ *******************************************************************************/
public class QWidgetMetaData implements QWidgetMetaDataInterface public class QWidgetMetaData implements QWidgetMetaDataInterface
{ {
private String id;
protected String name; protected String name;
protected String icon;
protected String label;
protected String type;
protected Integer gridColumns;
protected QCodeReference codeReference; protected QCodeReference codeReference;
@ -71,6 +74,74 @@ public class QWidgetMetaData implements QWidgetMetaDataInterface
/*******************************************************************************
** Getter for icon
**
*******************************************************************************/
public String getIcon()
{
return icon;
}
/*******************************************************************************
** Setter for icon
**
*******************************************************************************/
public void setIcon(String icon)
{
this.icon = icon;
}
/*******************************************************************************
** Fluent setter for icon
**
*******************************************************************************/
public QWidgetMetaData withIcon(String icon)
{
this.icon = icon;
return (this);
}
/*******************************************************************************
** Getter for label
**
*******************************************************************************/
public String getLabel()
{
return label;
}
/*******************************************************************************
** Setter for label
**
*******************************************************************************/
public void setLabel(String label)
{
this.label = label;
}
/*******************************************************************************
** Fluent setter for label
**
*******************************************************************************/
public QWidgetMetaData withLabel(String label)
{
this.label = label;
return (this);
}
/******************************************************************************* /*******************************************************************************
** Getter for codeReference ** Getter for codeReference
** **
@ -106,34 +177,68 @@ public class QWidgetMetaData implements QWidgetMetaDataInterface
/******************************************************************************* /*******************************************************************************
** Getter for id ** Getter for type
** **
*******************************************************************************/ *******************************************************************************/
public String getId() public String getType()
{ {
return id; return type;
} }
/******************************************************************************* /*******************************************************************************
** Setter for id ** Setter for type
** **
*******************************************************************************/ *******************************************************************************/
public void setId(String id) public void setType(String type)
{ {
this.id = id; this.type = type;
} }
/******************************************************************************* /*******************************************************************************
** Fluent setter for id ** Fluent setter for type
** **
*******************************************************************************/ *******************************************************************************/
public QWidgetMetaData withId(String id) public QWidgetMetaData withType(String type)
{ {
this.id = id; this.type = type;
return (this);
}
/*******************************************************************************
** Getter for gridColumns
**
*******************************************************************************/
public Integer getGridColumns()
{
return gridColumns;
}
/*******************************************************************************
** Setter for gridColumns
**
*******************************************************************************/
public void setGridColumns(Integer gridColumns)
{
this.gridColumns = gridColumns;
}
/*******************************************************************************
** Fluent setter for gridColumns
**
*******************************************************************************/
public QWidgetMetaData withGridColumns(Integer gridColumns)
{
this.gridColumns = gridColumns;
return (this); return (this);
} }

View File

@ -46,6 +46,51 @@ public interface QWidgetMetaDataInterface
*******************************************************************************/ *******************************************************************************/
QWidgetMetaDataInterface withName(String name); QWidgetMetaDataInterface withName(String name);
/*******************************************************************************
** Getter for label
*******************************************************************************/
String getLabel();
/*******************************************************************************
** Setter for label
*******************************************************************************/
void setLabel(String label);
/*******************************************************************************
** Fluent setter for label
*******************************************************************************/
QWidgetMetaDataInterface withLabel(String label);
/*******************************************************************************
** Getter for type
*******************************************************************************/
String getType();
/*******************************************************************************
** Setter for type
*******************************************************************************/
void setType(String type);
/*******************************************************************************
** Fluent setter for type
*******************************************************************************/
QWidgetMetaDataInterface withType(String type);
/*******************************************************************************
** Getter for gridColumns
*******************************************************************************/
Integer getGridColumns();
/*******************************************************************************
** Setter for gridColumns
*******************************************************************************/
void setGridColumns(Integer gridColumns);
/*******************************************************************************
** Fluent setter for gridColumns
*******************************************************************************/
QWidgetMetaDataInterface withGridColumns(Integer gridColumns);
/******************************************************************************* /*******************************************************************************
** Getter for codeReference ** Getter for codeReference
*******************************************************************************/ *******************************************************************************/
@ -61,4 +106,13 @@ public interface QWidgetMetaDataInterface
*******************************************************************************/ *******************************************************************************/
QWidgetMetaDataInterface withCodeReference(QCodeReference codeReference); QWidgetMetaDataInterface withCodeReference(QCodeReference codeReference);
/*******************************************************************************
** Getter for type
*******************************************************************************/
String getIcon();
/*******************************************************************************
** Setter for type
*******************************************************************************/
void setIcon(String type);
} }

View File

@ -31,7 +31,6 @@ import java.util.Collection;
*******************************************************************************/ *******************************************************************************/
public class QuickSightChartMetaData extends QWidgetMetaData implements QWidgetMetaDataInterface public class QuickSightChartMetaData extends QWidgetMetaData implements QWidgetMetaDataInterface
{ {
private String label;
private String accessKey; private String accessKey;
private String secretKey; private String secretKey;
private String dashboardId; private String dashboardId;

View File

@ -0,0 +1,117 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/
package com.kingsrook.qqq.backend.core.model.metadata.frontend;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.QWidgetMetaDataInterface;
/*******************************************************************************
* Version of QWidgetMetaData that's meant for transmitting to a frontend.
* e.g., it excludes backend-only details (when/if we have them)
*
*******************************************************************************/
@JsonInclude(Include.NON_NULL)
public class QFrontendWidgetMetaData
{
private final String name;
private final String label;
private final String type;
private final String icon;
private final Integer gridColumns;
//////////////////////////////////////////////////////////////////////////////////
// do not add setters. take values from the source-object in the constructor!! //
//////////////////////////////////////////////////////////////////////////////////
/*******************************************************************************
**
*******************************************************************************/
public QFrontendWidgetMetaData(QWidgetMetaDataInterface widgetMetaData)
{
this.name = widgetMetaData.getName();
this.label = widgetMetaData.getLabel();
this.type = widgetMetaData.getType();
this.icon = widgetMetaData.getIcon();
this.gridColumns = widgetMetaData.getGridColumns();
}
/*******************************************************************************
** Getter for name
**
*******************************************************************************/
public String getName()
{
return name;
}
/*******************************************************************************
** Getter for label
**
*******************************************************************************/
public String getLabel()
{
return label;
}
/*******************************************************************************
** Getter for type
**
*******************************************************************************/
public String getType()
{
return type;
}
/*******************************************************************************
** Getter for gridColumns
**
*******************************************************************************/
public Integer getGridColumns()
{
return gridColumns;
}
/*******************************************************************************
** Getter for icon
**
*******************************************************************************/
public String getIcon()
{
return icon;
}
}