mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
SPRINT-17: updated some widgets to look less broken when data is 'not available now', checkpoint commit on 'real dashboards'
This commit is contained in:
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.actions.dashboard.widgets;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.widgets.RenderWidgetOutput;
|
||||
import com.kingsrook.qqq.backend.core.model.dashboard.widgets.USMapWidgetData;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Generic widget for display a map of the us
|
||||
*******************************************************************************/
|
||||
public class USMapWidgetRenderer extends AbstractWidgetRenderer
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Override
|
||||
public RenderWidgetOutput render(RenderWidgetInput input) throws QException
|
||||
{
|
||||
return (new RenderWidgetOutput(
|
||||
new USMapWidgetData()
|
||||
.withHeight("250px")
|
||||
.withMapMarkerList(generateMapMarkerList())
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
protected List<USMapWidgetData.MapMarker> generateMapMarkerList() throws QException
|
||||
{
|
||||
return (List.of(new USMapWidgetData.MapMarker("maryville", new BigDecimal("38.725278"), new BigDecimal("-89.957778"))));
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.core.model.dashboard.widgets;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -325,6 +326,22 @@ public class ChartData extends QWidgetData
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for single dataset
|
||||
**
|
||||
*******************************************************************************/
|
||||
public Dataset getDataset()
|
||||
{
|
||||
if(CollectionUtils.nullSafeHasContents(getDatasets()))
|
||||
{
|
||||
return (getDatasets().get(0));
|
||||
|
||||
}
|
||||
return (null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Model containing datastructure expected by frontend pie chart widget
|
||||
**
|
||||
*******************************************************************************/
|
||||
public class PieChartData extends ChartData
|
||||
{
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public PieChartData()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public PieChartData(String label, String description, String seriesLabel, List<String> labels, List<Number> data)
|
||||
{
|
||||
setLabel(label);
|
||||
setDescription(description);
|
||||
setChartData(new ChartData.Data()
|
||||
.withLabels(labels)
|
||||
.withDatasets(List.of(
|
||||
new ChartData.Data.Dataset()
|
||||
.withLabel(seriesLabel)
|
||||
.withData(data)
|
||||
))
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for type
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return WidgetType.PIE_CHART.getType();
|
||||
}
|
||||
}
|
@ -32,6 +32,8 @@ import java.util.Map;
|
||||
*******************************************************************************/
|
||||
public abstract class QWidgetData
|
||||
{
|
||||
|
||||
private String label;
|
||||
private List<String> dropdownNameList;
|
||||
private List<String> dropdownLabelList;
|
||||
|
||||
@ -52,6 +54,40 @@ public abstract class QWidgetData
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for label
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getLabel()
|
||||
{
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for label
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for label
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QWidgetData withLabel(String label)
|
||||
{
|
||||
this.label = label;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for dropdownLabelList
|
||||
**
|
||||
@ -185,4 +221,5 @@ public abstract class QWidgetData
|
||||
this.dropdownNeedsSelectedText = dropdownNeedsSelectedText;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import java.util.Map;
|
||||
*******************************************************************************/
|
||||
public class TableData extends QWidgetData
|
||||
{
|
||||
private String title;
|
||||
private String linkText;
|
||||
private String linkURL;
|
||||
private String noRowsFoundHTML;
|
||||
@ -45,9 +44,9 @@ public class TableData extends QWidgetData
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public TableData(String title, List<Column> columns, List<Map<String, Object>> rows, List<Map<String, String>> dropdownOptions)
|
||||
public TableData(String label, List<Column> columns, List<Map<String, Object>> rows, List<Map<String, String>> dropdownOptions)
|
||||
{
|
||||
setTitle(title);
|
||||
setLabel(label);
|
||||
setColumns(columns);
|
||||
setRows(rows);
|
||||
setDropdownOptions(dropdownOptions);
|
||||
@ -61,41 +60,7 @@ public class TableData extends QWidgetData
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return "table";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for title
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getTitle()
|
||||
{
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for title
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for title
|
||||
**
|
||||
*******************************************************************************/
|
||||
public TableData withTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
return (this);
|
||||
return WidgetType.TABLE.getType();
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,263 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Model containing datastructure expected by frontend USA map
|
||||
**
|
||||
*******************************************************************************/
|
||||
public class USMapWidgetData extends QWidgetData
|
||||
{
|
||||
private String height;
|
||||
private List<MapMarker> mapMarkerList;
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public USMapWidgetData()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for type
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getType()
|
||||
{
|
||||
return WidgetType.USA_MAP.getType();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for height
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for height
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setHeight(String height)
|
||||
{
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for height
|
||||
**
|
||||
*******************************************************************************/
|
||||
public USMapWidgetData withHeight(String height)
|
||||
{
|
||||
this.height = height;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for mapMarkerList
|
||||
**
|
||||
*******************************************************************************/
|
||||
public List<MapMarker> getMapMarkerList()
|
||||
{
|
||||
return mapMarkerList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for mapMarkerList
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setMapMarkerList(List<MapMarker> mapMarkerList)
|
||||
{
|
||||
this.mapMarkerList = mapMarkerList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for mapMarkerList
|
||||
**
|
||||
*******************************************************************************/
|
||||
public USMapWidgetData withMapMarkerList(List<MapMarker> mapMarkerList)
|
||||
{
|
||||
this.mapMarkerList = mapMarkerList;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static class MapMarker
|
||||
{
|
||||
private String name;
|
||||
private BigDecimal latitude;
|
||||
private BigDecimal longitude;
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** default constructor
|
||||
**
|
||||
*******************************************************************************/
|
||||
public MapMarker()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** useful constructor
|
||||
**
|
||||
*******************************************************************************/
|
||||
public MapMarker(String name, BigDecimal latitude, BigDecimal longitude)
|
||||
{
|
||||
this.name = name;
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for name
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for name
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for name
|
||||
**
|
||||
*******************************************************************************/
|
||||
public MapMarker withName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for latitude
|
||||
**
|
||||
*******************************************************************************/
|
||||
public BigDecimal getLatitude()
|
||||
{
|
||||
return latitude;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for latitude
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setLatitude(BigDecimal latitude)
|
||||
{
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for latitude
|
||||
**
|
||||
*******************************************************************************/
|
||||
public MapMarker withLatitude(BigDecimal latitude)
|
||||
{
|
||||
this.latitude = latitude;
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for longitude
|
||||
**
|
||||
*******************************************************************************/
|
||||
public BigDecimal getLongitude()
|
||||
{
|
||||
return longitude;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for longitude
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setLongitude(BigDecimal longitude)
|
||||
{
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for longitude
|
||||
**
|
||||
*******************************************************************************/
|
||||
public MapMarker withLongitude(BigDecimal longitude)
|
||||
{
|
||||
this.longitude = longitude;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -31,19 +31,23 @@ public enum WidgetType
|
||||
CHART("chart"),
|
||||
CHILD_RECORD_LIST("childRecordList"),
|
||||
DIVIDER("divider"),
|
||||
FIELD_VALUE_LIST("fieldValueList"),
|
||||
GENERIC("generic"),
|
||||
HORIZONTAL_BAR_CHART("horizontalBarChart"),
|
||||
HTML("html"),
|
||||
LINE_CHART("lineChart"),
|
||||
SMALL_LINE_CHART("smallLineChart"),
|
||||
LOCATION("location"),
|
||||
MULTI_STATISTICS("multiStatistics"),
|
||||
PARENT_WIDGET("parentWidget"),
|
||||
PIE_CHART("pieChart"),
|
||||
PROCESS("process"),
|
||||
QUICK_SIGHT_CHART("quickSightChart"),
|
||||
STATISTICS("statistics"),
|
||||
SIMPLE_STATISTICS("simpleStatistics"),
|
||||
STEPPER("stepper"),
|
||||
TABLE("table"),
|
||||
FIELD_VALUE_LIST("fieldValueList");
|
||||
USA_MAP("usaMap");
|
||||
|
||||
|
||||
private final String type;
|
||||
|
@ -40,6 +40,7 @@ public class QWidgetMetaData implements QWidgetMetaDataInterface
|
||||
protected String icon;
|
||||
protected String label;
|
||||
protected String type;
|
||||
protected boolean isCard;
|
||||
protected Integer gridColumns;
|
||||
protected QCodeReference codeReference;
|
||||
|
||||
@ -352,4 +353,38 @@ public class QWidgetMetaData implements QWidgetMetaDataInterface
|
||||
return (this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for isCard
|
||||
**
|
||||
*******************************************************************************/
|
||||
public boolean getIsCard()
|
||||
{
|
||||
return isCard;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for isCard
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void setIsCard(boolean isCard)
|
||||
{
|
||||
this.isCard = isCard;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Fluent setter for isCard
|
||||
**
|
||||
*******************************************************************************/
|
||||
public QWidgetMetaData withIsCard(boolean isCard)
|
||||
{
|
||||
this.isCard = isCard;
|
||||
return (this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -109,15 +109,25 @@ public interface QWidgetMetaDataInterface
|
||||
QWidgetMetaDataInterface withCodeReference(QCodeReference codeReference);
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for type
|
||||
** Getter for icon
|
||||
*******************************************************************************/
|
||||
String getIcon();
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for type
|
||||
** Setter for icon
|
||||
*******************************************************************************/
|
||||
void setIcon(String type);
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for isCard
|
||||
*******************************************************************************/
|
||||
boolean getIsCard();
|
||||
|
||||
/*******************************************************************************
|
||||
** Setter for type
|
||||
*******************************************************************************/
|
||||
void setIsCard(boolean isCard);
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for defaultValues
|
||||
*******************************************************************************/
|
||||
|
@ -40,6 +40,7 @@ public class QFrontendWidgetMetaData
|
||||
private final String type;
|
||||
private final String icon;
|
||||
private final Integer gridColumns;
|
||||
private final boolean isCard;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
// do not add setters. take values from the source-object in the constructor!! //
|
||||
@ -57,6 +58,7 @@ public class QFrontendWidgetMetaData
|
||||
this.type = widgetMetaData.getType();
|
||||
this.icon = widgetMetaData.getIcon();
|
||||
this.gridColumns = widgetMetaData.getGridColumns();
|
||||
this.isCard = widgetMetaData.getIsCard();
|
||||
}
|
||||
|
||||
|
||||
@ -105,6 +107,17 @@ public class QFrontendWidgetMetaData
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for isCard
|
||||
**
|
||||
*******************************************************************************/
|
||||
public boolean getIsCard()
|
||||
{
|
||||
return isCard;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for icon
|
||||
**
|
||||
|
Reference in New Issue
Block a user