Skip to content

armgit / core

Public Imported from GitHub
0

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

Fixed wrong index in or-select when empty option should be shown. Fixed deprecation of ST_Distance_Sphere Fixed deletion in JsonRulesBuilder when DELETE is requested when no value is present

Michael Rademaker607922297f9e
diff --git a/container/src/main/java/org/openremote/container/security/basic/PasswordStorage.java b/container/src/main/java/org/openremote/container/security/basic/PasswordStorage.java
index 25398e775..3df312e87 100644
--- a/container/src/main/java/org/openremote/container/security/basic/PasswordStorage.java
+++ b/container/src/main/java/org/openremote/container/security/basic/PasswordStorage.java
@@ -31,11 +31,11 @@ import com.google.common.cache.LoadingCache;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
-import javax.xml.bind.DatatypeConverter;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
+import java.util.Base64;
import java.util.concurrent.ExecutionException;
import java.util.logging.Logger;
@@ -277,13 +277,12 @@ public class PasswordStorage {
}
}
- private static byte[] fromBase64(String hex)
- throws IllegalArgumentException {
- return DatatypeConverter.parseBase64Binary(hex);
+ private static byte[] fromBase64(String hex) {
+ return Base64.getDecoder().decode(hex);
}
private static String toBase64(byte[] array) {
- return DatatypeConverter.printBase64Binary(array);
+ return Base64.getEncoder().encodeToString(array);
}
}
\ No newline at end of file
diff --git a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
index 2aeead926..2d3d6df19 100644
--- a/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
+++ b/manager/src/main/java/org/openremote/manager/asset/AssetStorageService.java
@@ -1422,7 +1422,7 @@ public class AssetStorageService extends RouteBuilder implements ContainerServic
} else if (attributePredicate.value instanceof GeofencePredicate) {
if (attributePredicate.value instanceof RadialGeofencePredicate) {
RadialGeofencePredicate location = (RadialGeofencePredicate) attributePredicate.value;
- attributeBuilder.append("ST_Distance_Sphere(ST_MakePoint(")
+ attributeBuilder.append("ST_DistanceSphere(ST_MakePoint(")
.append("(AX")
.append(joinCounter)
.append(".VALUE #>> '{value,coordinates,0}')::numeric")
diff --git a/manager/src/main/java/org/openremote/manager/rules/JsonRulesBuilder.java b/manager/src/main/java/org/openremote/manager/rules/JsonRulesBuilder.java
index c90789aea..6617c506d 100644
--- a/manager/src/main/java/org/openremote/manager/rules/JsonRulesBuilder.java
+++ b/manager/src/main/java/org/openremote/manager/rules/JsonRulesBuilder.java
@@ -768,10 +768,12 @@ public class JsonRulesBuilder extends RulesBuilder {
}
break;
case DELETE:
- if (valueType.equals(ValueType.ARRAY)) {
- ((ArrayValue) value).remove(attributeUpdateAction.index);
- } else {
- ((ObjectValue) value).remove(attributeUpdateAction.key);
+ if(value != null) {
+ if (valueType.equals(ValueType.ARRAY)) {
+ ((ArrayValue) value).remove(attributeUpdateAction.index);
+ } else {
+ ((ObjectValue) value).remove(attributeUpdateAction.key);
+ }
}
break;
case CLEAR:
diff --git a/ui/component/or-select/src/index.ts b/ui/component/or-select/src/index.ts
index cf7ea3def..135061a59 100644
--- a/ui/component/or-select/src/index.ts
+++ b/ui/component/or-select/src/index.ts
@@ -50,7 +50,7 @@ export class OrSelect extends LitElement {
public autoSize?: boolean = true;
@property({type: Boolean, attribute: true})
- public noEmpty?: boolean = false;
+ public showEmptyOption?: boolean = true;
@property({type: Array})
public options!: string[] | [string, string][];
@@ -93,7 +93,7 @@ export class OrSelect extends LitElement {
if (_changedProperties.has("options") || _changedProperties.has("value")) {
let val = this.value;
- if (this.options.length === 1 || (this.noEmpty && !val)) {
+ if (this.options.length === 1 || (!this.showEmptyOption && !val)) {
const opt = this.options[0];
const firstValue = Array.isArray(opt) ? opt[0] : opt;
if (this.value !== firstValue) {
@@ -102,13 +102,17 @@ export class OrSelect extends LitElement {
}
let index: number;
- if (this.options.length === 1 || (this.noEmpty && !val)) {
+ if (this.options.length === 1 || (!this.showEmptyOption && !val)) {
index = 0;
} else {
index = this.options.findIndex((opt: string | [string, string]) => {
const value = Array.isArray(opt) ? opt[0] : opt;
return value == val;
});
+
+ if(this.showEmptyOption) {
+ index = index + 1;
+ }
}
const indexChanged = this._select.selectedIndex != index;
@@ -129,7 +133,7 @@ export class OrSelect extends LitElement {
return html`
<div class="mdc-select">
<select id="or-select" ?required="${this.required}" @change="${this.onChange}" ?disabled="${this.readonly || isSingular}">
- ${!this.noEmpty && !isSingular ? html`<option value=""></option>` : ``};
+ ${this.showEmptyOption && !isSingular ? html`<option value=""></option>` : ``}
${this.options.length > 0 && Array.isArray(this.options[0]) ?
(this.options as [string, string][]).map((option: [string, string]) => {
return html`<option style="color: ${this._optColor || optionColorVar};" value="${option[0]}">${option[1]}</option>`;