diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/dashboard/widgets/USMapWidgetRenderer.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/dashboard/widgets/USMapWidgetRenderer.java new file mode 100644 index 00000000..7db99301 --- /dev/null +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/actions/dashboard/widgets/USMapWidgetRenderer.java @@ -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 . + */ + +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 generateMapMarkerList() throws QException + { + return (List.of(new USMapWidgetData.MapMarker("maryville", new BigDecimal("38.725278"), new BigDecimal("-89.957778")))); + } + +} diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/ChartData.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/ChartData.java index 78303cba..14cd564c 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/ChartData.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/ChartData.java @@ -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); + } + + + /******************************************************************************* ** *******************************************************************************/ diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/PieChartData.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/PieChartData.java new file mode 100644 index 00000000..14369572 --- /dev/null +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/PieChartData.java @@ -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 . + */ + +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 labels, List 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(); + } +} diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/QWidgetData.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/QWidgetData.java index 1fbc0ea1..cccd3242 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/QWidgetData.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/QWidgetData.java @@ -32,6 +32,8 @@ import java.util.Map; *******************************************************************************/ public abstract class QWidgetData { + + private String label; private List dropdownNameList; private List 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); } + } diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/TableData.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/TableData.java index c16a8f2c..1cd3f334 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/TableData.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/TableData.java @@ -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 columns, List> rows, List> dropdownOptions) + public TableData(String label, List columns, List> rows, List> 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(); } diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/USMapWidgetData.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/USMapWidgetData.java new file mode 100644 index 00000000..215a1d15 --- /dev/null +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/USMapWidgetData.java @@ -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 . + */ + +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 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 getMapMarkerList() + { + return mapMarkerList; + } + + + + /******************************************************************************* + ** Setter for mapMarkerList + ** + *******************************************************************************/ + public void setMapMarkerList(List mapMarkerList) + { + this.mapMarkerList = mapMarkerList; + } + + + + /******************************************************************************* + ** Fluent setter for mapMarkerList + ** + *******************************************************************************/ + public USMapWidgetData withMapMarkerList(List 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); + } + + } +} diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/WidgetType.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/WidgetType.java index ebe1fb96..4a3f8d38 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/WidgetType.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/dashboard/widgets/WidgetType.java @@ -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; diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/dashboard/QWidgetMetaData.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/dashboard/QWidgetMetaData.java index eb137257..6f50d022 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/dashboard/QWidgetMetaData.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/dashboard/QWidgetMetaData.java @@ -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); + } + } diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/dashboard/QWidgetMetaDataInterface.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/dashboard/QWidgetMetaDataInterface.java index a6d1df1f..335a4480 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/dashboard/QWidgetMetaDataInterface.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/dashboard/QWidgetMetaDataInterface.java @@ -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 *******************************************************************************/ diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/frontend/QFrontendWidgetMetaData.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/frontend/QFrontendWidgetMetaData.java index 7cad796e..0374a25e 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/frontend/QFrontendWidgetMetaData.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/frontend/QFrontendWidgetMetaData.java @@ -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 **