mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
SPRINT-12: added widget meta data
This commit is contained in:
@ -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.model.actions.metadata.MetaDataInput;
|
||||
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.QFrontendAppMetaData;
|
||||
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.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.QAppMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||
@ -94,6 +96,16 @@ public class MetaDataAction
|
||||
}
|
||||
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 //
|
||||
///////////////////////////////////
|
||||
|
@ -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.QFrontendReportMetaData;
|
||||
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, QFrontendReportMetaData> reports;
|
||||
private Map<String, QFrontendAppMetaData> apps;
|
||||
private Map<String, QFrontendWidgetMetaData> widgets;
|
||||
|
||||
private List<AppTreeNode> appTree;
|
||||
|
||||
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
|
||||
**
|
||||
|
@ -69,7 +69,7 @@ public class ChartData implements QWidget
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return "barChart";
|
||||
return WidgetType.CHART.getType();
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class LineChartData implements QWidget
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return "lineChart";
|
||||
return WidgetType.LINE_CHART.getType();
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class LocationData implements QWidget
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return "location";
|
||||
return WidgetType.LOCATION.getType();
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class MultiStatisticsData implements QWidget
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return "multiStatistics";
|
||||
return WidgetType.MULTI_STATISTICS.getType();
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class QuickSightChart implements QWidget
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return "quickSightChart";
|
||||
return WidgetType.QUICK_SIGHT_CHART.getType();
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class RawHTML implements QWidget
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return "html";
|
||||
return WidgetType.HTML.getType();
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class StepperData implements QWidget
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return "stepper";
|
||||
return WidgetType.STEPPER.getType();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -31,8 +31,11 @@ import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||
*******************************************************************************/
|
||||
public class QWidgetMetaData implements QWidgetMetaDataInterface
|
||||
{
|
||||
private String id;
|
||||
protected String name;
|
||||
protected String icon;
|
||||
protected String label;
|
||||
protected String type;
|
||||
protected Integer gridColumns;
|
||||
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
|
||||
**
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,51 @@ public interface QWidgetMetaDataInterface
|
||||
*******************************************************************************/
|
||||
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
|
||||
*******************************************************************************/
|
||||
@ -61,4 +106,13 @@ public interface QWidgetMetaDataInterface
|
||||
*******************************************************************************/
|
||||
QWidgetMetaDataInterface withCodeReference(QCodeReference codeReference);
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for type
|
||||
*******************************************************************************/
|
||||
String getIcon();
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for type
|
||||
*******************************************************************************/
|
||||
void setIcon(String type);
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import java.util.Collection;
|
||||
*******************************************************************************/
|
||||
public class QuickSightChartMetaData extends QWidgetMetaData implements QWidgetMetaDataInterface
|
||||
{
|
||||
private String label;
|
||||
private String accessKey;
|
||||
private String secretKey;
|
||||
private String dashboardId;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user