Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Added support for OR_DATA_POINTS_QUERY_LIMIT (#1533)

Martin Peeters173c52e82460
diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AbstractDatapointService.java b/manager/src/main/java/org/openremote/manager/datapoint/AbstractDatapointService.java
index 32b693185..781856794 100644
--- a/manager/src/main/java/org/openremote/manager/datapoint/AbstractDatapointService.java
+++ b/manager/src/main/java/org/openremote/manager/datapoint/AbstractDatapointService.java
@@ -20,6 +20,7 @@
package org.openremote.manager.datapoint;
import com.fasterxml.jackson.databind.JsonNode;
+import jakarta.persistence.Query;
import jakarta.persistence.TypedQuery;
import jakarta.validation.constraints.NotNull;
import org.hibernate.Session;
@@ -34,6 +35,7 @@ import org.openremote.model.attribute.Attribute;
import org.openremote.model.attribute.AttributeRef;
import org.openremote.model.datapoint.Datapoint;
import org.openremote.model.datapoint.DatapointPeriod;
+import org.openremote.model.datapoint.DatapointQueryTooLargeException;
import org.openremote.model.datapoint.ValueDatapoint;
import org.openremote.model.datapoint.query.AssetDatapointQuery;
import org.openremote.model.util.ValueUtil;
@@ -47,28 +49,28 @@ import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.time.temporal.ChronoUnit.DAYS;
+import static org.openremote.container.util.MapAccess.getInteger;
/**
* Base class for all classes that store and retrieve {@link org.openremote.model.datapoint.Datapoint}.
*/
public abstract class AbstractDatapointService<T extends Datapoint> implements ContainerService {
+ public static final String OR_DATA_POINTS_QUERY_LIMIT = "OR_DATA_POINTS_QUERY_LIMIT";
public static final int PRIORITY = AssetStorageService.PRIORITY + 100;
protected PersistenceService persistenceService;
protected AssetStorageService assetStorageService;
protected TimerService timerService;
protected ScheduledExecutorService scheduledExecutorService;
protected ScheduledFuture<?> dataPointsPurgeScheduledFuture;
+ protected int maxAmountOfQueryPoints;
@Override
public int getPriority() {
@@ -81,6 +83,7 @@ public abstract class AbstractDatapointService<T extends Datapoint> implements C
assetStorageService = container.getService(AssetStorageService.class);
timerService = container.getService(TimerService.class);
scheduledExecutorService = container.getScheduledExecutor();
+ maxAmountOfQueryPoints = getInteger(container.getConfig(), OR_DATA_POINTS_QUERY_LIMIT, 0);
}
@Override
@@ -189,8 +192,50 @@ public abstract class AbstractDatapointService<T extends Datapoint> implements C
AttributeRef attributeRef = new AttributeRef(assetId, attribute.getName());
Map<Integer, Object> parameters = datapointQuery.getSQLParameters(attributeRef);
- getLogger().finest("Querying datapoints for: " + attributeRef);
+ // Gather the query based on the AssetDatapointQuery type
+ String query;
+ try {
+ query = datapointQuery.getSQLQuery(getDatapointTableName(), attribute.getTypeClass());
+ } catch (IllegalStateException ise) {
+ getLogger().log(Level.WARNING, ise.getMessage());
+ throw ise;
+ }
+
+ // Verify the query is 'legal' and can be executed
+ try {
+ if(canQueryDatapoints(assetId, attribute, query, parameters)) {
+ getLogger().finest("Querying datapoints for: " + attributeRef);
+
+ return doQueryDatapoints(assetId, attribute, query, parameters);
+ }
+ return Collections.emptyList();
+ } catch (IllegalStateException | IllegalArgumentException | DatapointQueryTooLargeException ex) {
+ getLogger().log(Level.WARNING, ex.getMessage());
+ throw ex;
+ }
+ }
+
+ protected boolean canQueryDatapoints(String assetId, Attribute<?> attribute, String query, Map<Integer, Object> parameters) {
+
+ // If only a maximum amount of data points is allowed,
+ // use SQL COUNT() to verify if the query does not exceed the maximum.
+ if(maxAmountOfQueryPoints > 0) {
+ String countQueryStr = "SELECT COUNT(*) FROM (" + query + ") AS count_query";
+ int amount = persistenceService.doReturningTransaction(entityManager -> {
+ Query countQuery = entityManager.createNativeQuery(countQueryStr);
+ parameters.forEach(countQuery::setParameter);
+ return ((Number) countQuery.getSingleResult()).intValue();
+ });
+ if (amount > maxAmountOfQueryPoints) {
+ throw new DatapointQueryTooLargeException("Could not query data points for " + assetId + ". It exceeds the data limit of " + maxAmountOfQueryPoints + " data points.");
+ }
+ }
+
+ return true;
+ }
+
+ protected List<ValueDatapoint<?>> doQueryDatapoints(String assetId, Attribute<?> attribute, String query, Map<Integer, Object> parameters) {
return persistenceService.doReturningTransaction(entityManager ->
entityManager.unwrap(Session.class).doReturningWork(new AbstractReturningWork<>() {
@@ -201,21 +246,17 @@ public abstract class AbstractDatapointService<T extends Datapoint> implements C
boolean isNumber = Number.class.isAssignableFrom(attributeType);
boolean isBoolean = Boolean.class.isAssignableFrom(attributeType);
- String query;
- try {
- query = datapointQuery.getSQLQuery(getDatapointTableName(), attributeType);
- } catch (IllegalStateException ise) {
- getLogger().log(Level.WARNING, ise.getMessage());
- throw ise;
- }
try (PreparedStatement st = connection.prepareStatement(query)) {
if(!parameters.isEmpty()) {
+ int paramCount = st.getParameterMetaData().getParameterCount();
for(Map.Entry<Integer, Object> param : parameters.entrySet()) {
- if(param.getValue() instanceof String) {
- st.setString(param.getKey(), param.getValue().toString());
- } else {
- st.setObject(param.getKey(), param.getValue());
+ if(param.getKey() <= paramCount) {
+ if(param.getValue() instanceof String) {
+ st.setString(param.getKey(), param.getValue().toString());
+ } else {
+ st.setObject(param.getKey(), param.getValue());
+ }
}
}
}
diff --git a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java
index 8e29f88a4..be8a38b27 100644
--- a/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java
+++ b/manager/src/main/java/org/openremote/manager/datapoint/AssetDatapointResourceImpl.java
@@ -39,6 +39,7 @@ import org.openremote.model.attribute.Attribute;
import org.openremote.model.attribute.AttributeRef;
import org.openremote.model.datapoint.AssetDatapointResource;
import org.openremote.model.datapoint.DatapointPeriod;
+import org.openremote.model.datapoint.DatapointQueryTooLargeException;
import org.openremote.model.datapoint.ValueDatapoint;
import org.openremote.model.datapoint.query.AssetDatapointQuery;
import org.openremote.model.http.RequestParams;
@@ -133,8 +134,10 @@ public class AssetDatapointResourceImpl extends ManagerWebResource implements As
}
return assetDatapointService.getDatapoints(new AttributeRef(assetId, attributeName)).toArray(ValueDatapoint[]::new);
- } catch (IllegalStateException ex) {
+ } catch (IllegalStateException | IllegalArgumentException ex) {
throw new BadRequestException(ex);
+ } catch (DatapointQueryTooLargeException dqex) {
+ throw new WebApplicationException(Response.Status.REQUEST_ENTITY_TOO_LARGE);
} catch (UnsupportedOperationException ex) {
throw new NotSupportedException(ex);
}
diff --git a/manager/src/web/shared/locales/en/or.json b/manager/src/web/shared/locales/en/or.json
index 9548389c3..42d235382 100644
--- a/manager/src/web/shared/locales/en/or.json
+++ b/manager/src/web/shared/locales/en/or.json
@@ -198,6 +198,7 @@
"noAttributeConnected": "No attribute connected",
"noAttributesConnected": "No attributes connected",
"noAttributeDataTimeout": "Data request timed out",
+ "datapointRequestTooLarge": "Requested too much data",
"noDatapointsOrRuleStateAttributes": "No attributes with 'rule state', 'store data points', or 'agent link' configuration item found",
"copy": "Copy",
"paste": "Paste",
diff --git a/manager/src/web/shared/locales/nl/or.json b/manager/src/web/shared/locales/nl/or.json
index be789a91c..6192d93a3 100644
--- a/manager/src/web/shared/locales/nl/or.json
+++ b/manager/src/web/shared/locales/nl/or.json
@@ -198,6 +198,7 @@
"noAttributeConnected": "Geen atribuut verbonden",
"noAttributesConnected": "Geen attributen verbonden",
"noAttributeDataTimeout": "Dataverzoek verlopen",
+ "datapointRequestTooLarge": "Teveel data opgevraagd",
"noDatapointsOrRuleStateAttributes": "Geen attributen met 'rule state', 'store data points', of 'agent link' configuratie item gevonden",
"copy": "Kopiëren",
"paste": "Plakken",
diff --git a/model/src/main/java/org/openremote/model/datapoint/DatapointQueryTooLargeException.java b/model/src/main/java/org/openremote/model/datapoint/DatapointQueryTooLargeException.java
new file mode 100644
index 000000000..3f9658f3d
--- /dev/null
+++ b/model/src/main/java/org/openremote/model/datapoint/DatapointQueryTooLargeException.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2024, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.model.datapoint;
+
+public class DatapointQueryTooLargeException extends RuntimeException {
+
+ public DatapointQueryTooLargeException(String message) {
+ super(message);
+ }
+}
diff --git a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointAllQuery.java b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointAllQuery.java
index 3b0fe8aea..ceac7c5f7 100644
--- a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointAllQuery.java
+++ b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointAllQuery.java
@@ -22,12 +22,13 @@ public class AssetDatapointAllQuery extends AssetDatapointQuery {
public String getSQLQuery(String tableName, Class<?> attributeType) throws IllegalStateException {
boolean isNumber = Number.class.isAssignableFrom(attributeType);
boolean isBoolean = Boolean.class.isAssignableFrom(attributeType);
+ String conditionSuffix = " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? order by timestamp desc";
if (isNumber) {
- return "select timestamp as X, value::text::numeric as Y from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? order by timestamp desc";
+ return "select timestamp as X, cast(value as numeric) as Y from " + tableName + conditionSuffix;
} else if (isBoolean) {
- return "select timestamp as X, (case when VALUE::text::boolean is true then 1 else 0 end) as Y from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? order by timestamp desc";
+ return "select timestamp as X, (case when cast(cast(value as text) as boolean) is true then 1 else 0 end) as Y from " + tableName + conditionSuffix;
} else {
- return "select distinct timestamp as X, value as Y from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? order by timestamp desc";
+ return "select distinct timestamp as X, value as Y from " + tableName + conditionSuffix;
}
}
diff --git a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointIntervalQuery.java b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointIntervalQuery.java
index 7fc72416f..dc38a60c5 100644
--- a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointIntervalQuery.java
+++ b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointIntervalQuery.java
@@ -42,9 +42,9 @@ public class AssetDatapointIntervalQuery extends AssetDatapointQuery {
boolean isBoolean = Boolean.class.isAssignableFrom(attributeType);
String function = (gapFill ? "public.time_bucket_gapfill" : "public.time_bucket");
if (isNumber) {
- return "select " + function + "(?::interval, timestamp) AS x, " + this.formula.toString().toLowerCase() + "(value::text::numeric) FROM " + tableName + " WHERE ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? GROUP BY x ORDER by x ASC;";
+ return "select " + function + "(cast(? as interval), timestamp) AS x, " + this.formula.toString().toLowerCase() + "(cast(value as numeric)) FROM " + tableName + " WHERE ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? GROUP BY x ORDER by x ASC";
} else if (isBoolean) {
- return "select " + function + "(?::interval, timestamp) AS x, " + this.formula.toString().toLowerCase() + "(case when VALUE::text::boolean is true then 1 else 0 end) FROM " + tableName + " WHERE ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? GROUP BY x ORDER by x ASC;";
+ return "select " + function + "(cast(? as interval), timestamp) AS x, " + this.formula.toString().toLowerCase() + "(case when cast(cast(value as text) as boolean) is true then 1 else 0 end) FROM " + tableName + " WHERE ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ? GROUP BY x ORDER by x ASC";
} else {
throw new IllegalStateException("Query of type Interval requires either a number or a boolean attribute.");
}
diff --git a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointLTTBQuery.java b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointLTTBQuery.java
index 85188213c..fa7b391e2 100644
--- a/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointLTTBQuery.java
+++ b/model/src/main/java/org/openremote/model/datapoint/query/AssetDatapointLTTBQuery.java
@@ -28,9 +28,9 @@ public final class AssetDatapointLTTBQuery extends AssetDatapointQuery {
boolean isNumber = Number.class.isAssignableFrom(attributeType);
boolean isBoolean = Boolean.class.isAssignableFrom(attributeType);
if (isNumber) {
- return "select * from public.unnest((select public.lttb(timestamp::timestamptz, value::double precision, ?) from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ?))";
+ return "select * from public.unnest((select public.lttb(cast(timestamp as timestamptz), cast(value as double precision), ?) from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ?))";
} else if (isBoolean) {
- return "select * from public.unnest((select public.lttb(timestamp::timestamptz, (case when VALUE::text::boolean is true then 1 else 0 end), ?) from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ?))";
+ return "select * from public.unnest((select public.lttb(cast(timestamp as timestamptz), (case when cast(cast(value as text) as boolean) is true then 1 else 0 end), ?) from " + tableName + " where ENTITY_ID = ? and ATTRIBUTE_NAME = ? and TIMESTAMP >= ? and TIMESTAMP <= ?))";
} else {
throw new IllegalStateException("Query of type LTTB requires either a number or a boolean attribute.");
}
diff --git a/profile/deploy.yml b/profile/deploy.yml
index ae9e688d5..4cffee407 100644
--- a/profile/deploy.yml
+++ b/profile/deploy.yml
@@ -335,6 +335,9 @@ services:
# value by using the DATA_POINTS_MAX_AGE_DAYS AssetMeta item).
# OR_DATA_POINTS_MAX_AGE_DAYS: 30
+ # Configure the limit of data points that can be queried. Disabled by default.
+ # OR_DATA_POINTS_QUERY_LIMIT: 1000000
+
# App id for the API of OpenWeather: https://openweathermap.org
# OR_OPEN_WEATHER_API_APP_ID
diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointQueryTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointQueryTest.groovy
index 413aa9b3d..55dc82ada 100644
--- a/test/src/test/groovy/org/openremote/test/assets/AssetDatapointQueryTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/assets/AssetDatapointQueryTest.groovy
@@ -9,7 +9,9 @@ import org.openremote.model.attribute.Attribute
import org.openremote.model.attribute.AttributeRef
import org.openremote.model.attribute.MetaItem
import org.openremote.model.datapoint.AssetDatapoint
+import org.openremote.model.datapoint.DatapointQueryTooLargeException
import org.openremote.model.datapoint.ValueDatapoint
+import org.openremote.model.datapoint.query.AssetDatapointAllQuery
import org.openremote.model.datapoint.query.AssetDatapointIntervalQuery
import org.openremote.model.datapoint.query.AssetDatapointLTTBQuery
import org.openremote.model.geo.GeoJSONPoint
@@ -40,6 +42,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetDatapointService = container.getService(AssetDatapointService.class)
+ assetDatapointService.maxAmountOfQueryPoints = 1000
when: "requesting the first light asset in City realm"
@@ -168,6 +171,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetDatapointService = container.getService(AssetDatapointService.class)
+ assetDatapointService.maxAmountOfQueryPoints = 1000
when: "a thing asset is added to the building realm"
def thingId = UniqueIdentifierGenerator.generateId("TestThing")
@@ -229,6 +233,7 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
def assetStorageService = container.getService(AssetStorageService.class)
def assetDatapointService = container.getService(AssetDatapointService.class)
+ assetDatapointService.maxAmountOfQueryPoints = 1000
when: "requesting the first light asset in City realm"
@@ -309,4 +314,88 @@ class AssetDatapointQueryTest extends Specification implements ManagerContainerT
}}
}
+
+ def "All query should return the correct data when the maximum is respected"() {
+
+ given: "expected conditions"
+ def conditions = new PollingConditions(timeout: 10, delay: 0.2)
+
+ and: "the container is started"
+ def container = startContainer(defaultConfig(), defaultServices())
+ def keycloakTestSetup = container.getService(SetupService.class).getTaskOfType(KeycloakTestSetup.class)
+ def assetStorageService = container.getService(AssetStorageService.class)
+ def assetDatapointService = container.getService(AssetDatapointService.class)
+ assetDatapointService.maxAmountOfQueryPoints = 1000
+
+ when: "requesting the first light asset in City realm"
+ def asset = assetStorageService.find(
+ new AssetQuery()
+ .types(LightAsset.class)
+ .realm(new RealmPredicate(keycloakTestSetup.realmCity.name))
+ .names("Light 1")
+ )
+
+ then: "asset should exist and be correct"
+ def assetName = "Light 1"
+ def attributeName = "brightness"
+ def dateTime = LocalDateTime.now()
+ assert asset != null // light 1, 2 and 3
+ assert asset.name == assetName
+ assert asset.attributes.has(attributeName)
+
+ and: "no datapoints should exist"
+ conditions.eventually {
+ def datapoints = assetDatapointService.getDatapoints(new AttributeRef(asset.getId(), attributeName))
+ assert datapoints.isEmpty()
+ }
+
+
+ /* ------------------------- */
+
+ when: "datapoints are added to the asset"
+ assetDatapointService.upsertValues(asset.getId(), attributeName,
+ [
+ new ValueDatapoint<>(dateTime.minusMinutes(25).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 50d),
+ new ValueDatapoint<>(dateTime.minusMinutes(20).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 40d),
+ new ValueDatapoint<>(dateTime.minusMinutes(15).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 30d),
+ new ValueDatapoint<>(dateTime.minusMinutes(10).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 20d),
+ new ValueDatapoint<>(dateTime.minusMinutes(5).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(), 10d),
+ ]
+ )
+
+ then: "datapoints should exist"
+ def allDatapoints = new ArrayList<ValueDatapoint>()
+ conditions.eventually {
+ allDatapoints = assetDatapointService.getDatapoints(new AttributeRef(asset.getId(), attributeName))
+ assert allDatapoints.size() == 5
+ }
+
+ /* ------------------------- */
+
+ and: "requesting 5 datapoints should return 5 values"
+ def allDatapoints1 = assetDatapointService.queryDatapoints(
+ asset.getId(),
+ asset.getAttribute(attributeName).orElseThrow({ new RuntimeException("Missing attribute") }),
+ new AssetDatapointAllQuery(dateTime.minusMinutes(30), dateTime)
+ )
+ assert allDatapoints1.size() == 5
+
+ /* ------------------------- */
+
+ when: "the OR_DATA_POINTS_QUERY_LIMIT environment variable is updated to 2"
+ assetDatapointService.maxAmountOfQueryPoints = 2
+
+ and: "the same datapoints are being requested"
+ assetDatapointService.queryDatapoints(
+ asset.getId(),
+ asset.getAttribute(attributeName).orElseThrow({ new RuntimeException("Missing attribute") }),
+ new AssetDatapointAllQuery(dateTime.minusMinutes(30), dateTime)
+ )
+
+ then: "no points should be returned"
+ thrown(DatapointQueryTooLargeException)
+
+ cleanup: "Remove the limit on datapoint querying"
+ assetDatapointService.maxAmountOfQueryPoints = 0
+ }
}
diff --git a/ui/component/or-app/src/index.ts b/ui/component/or-app/src/index.ts
index 0b01efbe3..d5765f6c6 100644
--- a/ui/component/or-app/src/index.ts
+++ b/ui/component/or-app/src/index.ts
@@ -468,7 +468,7 @@ export class OrApp<S extends AppStateKeyed> extends LitElement {
setTimeout(() => {
if(!finished) { deferred.resolve(); } // resolve THIS timer if not done yet.
- }, this.appConfig?.offlineTimeout || 10000)
+ }, this.appConfig?.offlineTimeout || 20000)
this._offlineFallbackDeferred = deferred;
}
diff --git a/ui/component/or-attribute-card/src/index.ts b/ui/component/or-attribute-card/src/index.ts
index 9c56b0049..d7d63eaf3 100644
--- a/ui/component/or-attribute-card/src/index.ts
+++ b/ui/component/or-attribute-card/src/index.ts
@@ -765,9 +765,12 @@ export class OrAttributeCard extends LitElement {
this._loading = false;
if(isAxiosError(ex)) {
- if(ex.message.includes("timeout of 10000ms exceeded")) {
+ if(ex.message.includes("timeout")) {
this._error = "noAttributeDataTimeout";
return;
+ } else if(ex.response?.status === 413) {
+ this._error = "datapointRequestTooLarge";
+ return;
}
}
diff --git a/ui/component/or-attribute-history/src/index.ts b/ui/component/or-attribute-history/src/index.ts
index 587a7e71f..704529a48 100644
--- a/ui/component/or-attribute-history/src/index.ts
+++ b/ui/component/or-attribute-history/src/index.ts
@@ -785,9 +785,12 @@ export class OrAttributeHistory extends translate(i18next)(LitElement) {
this._loading = false;
if(isAxiosError(ex)) {
- if(ex.message.includes("timeout of 10000ms exceeded")) {
+ if(ex.message.includes("timeout")) {
this._error = "noAttributeDataTimeout";
return;
+ } else if(ex.response?.status === 413) {
+ this._error = "datapointRequestTooLarge";
+ return;
}
}
this._error = "errorOccurred";
diff --git a/ui/component/or-chart/src/index.ts b/ui/component/or-chart/src/index.ts
index 80657bac0..a7c19bd5e 100644
--- a/ui/component/or-chart/src/index.ts
+++ b/ui/component/or-chart/src/index.ts
@@ -1145,10 +1145,15 @@ export class OrChart extends translate(i18next)(LitElement) {
this._loading = false;
if(isAxiosError(ex)) {
- if(ex.message.includes("timeout of 10000ms exceeded")) {
+ if(ex.message.includes("timeout")) {
this._latestError = "noAttributeDataTimeout";
+ return;
+ } else if(ex.response?.status === 413) {
+ this._latestError = "datapointRequestTooLarge";
+ return;
}
}
+ this._latestError = "errorOccurred";
}
}