From 71f94358c4744060482695dae7a49cd0c2415238 Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Thu, 7 May 2020 10:49:44 +0300 Subject: [PATCH 1/5] Fix typos and added break statement --- application/src/main/resources/thingsboard.yml | 4 ++-- .../server/common/transport/adaptor/JsonConverter.java | 1 + .../rule/engine/metadata/TbAbstractGetAttributesNode.java | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index 03e461015f..2156447005 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -240,11 +240,11 @@ sql: ttl: ts: enabled: "${SQL_TTL_TS_ENABLED:true}" - execution_interval_ms: "${SQL_TTL_TS_EXECUTION_INTERVAL:86400000}" # Number of miliseconds. The current value corresponds to one day + execution_interval_ms: "${SQL_TTL_TS_EXECUTION_INTERVAL:86400000}" # Number of milliseconds. The current value corresponds to one day ts_key_value_ttl: "${SQL_TTL_TS_TS_KEY_VALUE_TTL:0}" # Number of seconds events: enabled: "${SQL_TTL_EVENTS_ENABLED:true}" - execution_interval_ms: "${SQL_TTL_EVENTS_EXECUTION_INTERVAL:86400000}" # Number of miliseconds. The current value corresponds to one day + execution_interval_ms: "${SQL_TTL_EVENTS_EXECUTION_INTERVAL:86400000}" # Number of milliseconds. The current value corresponds to one day events_ttl: "${SQL_TTL_EVENTS_EVENTS_TTL:0}" # Number of seconds debug_events_ttl: "${SQL_TTL_EVENTS_DEBUG_EVENTS_TTL:604800}" # Number of seconds. The current value corresponds to one week diff --git a/common/transport/transport-api/src/main/java/org/thingsboard/server/common/transport/adaptor/JsonConverter.java b/common/transport/transport-api/src/main/java/org/thingsboard/server/common/transport/adaptor/JsonConverter.java index 56e2c87d6e..8375b84ffa 100644 --- a/common/transport/transport-api/src/main/java/org/thingsboard/server/common/transport/adaptor/JsonConverter.java +++ b/common/transport/transport-api/src/main/java/org/thingsboard/server/common/transport/adaptor/JsonConverter.java @@ -391,6 +391,7 @@ public class JsonConverter { break; case JSON_V: result.add(de.getKv().getKey(), JSON_PARSER.parse(de.getKv().getJsonV())); + break; default: throw new IllegalArgumentException("Unsupported data type: " + de.getKv().getType()); } diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbAbstractGetAttributesNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbAbstractGetAttributesNode.java index 8aa15a4f38..9c46cbbc1d 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbAbstractGetAttributesNode.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbAbstractGetAttributesNode.java @@ -177,6 +177,7 @@ public abstract class TbAbstractGetAttributesNode Date: Thu, 7 May 2020 11:09:12 +0300 Subject: [PATCH 2/5] Fix tests --- .../org/thingsboard/server/dao/NoSqlDaoServiceTestSuite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dao/src/test/java/org/thingsboard/server/dao/NoSqlDaoServiceTestSuite.java b/dao/src/test/java/org/thingsboard/server/dao/NoSqlDaoServiceTestSuite.java index 48af5c4eb8..824f5887e2 100644 --- a/dao/src/test/java/org/thingsboard/server/dao/NoSqlDaoServiceTestSuite.java +++ b/dao/src/test/java/org/thingsboard/server/dao/NoSqlDaoServiceTestSuite.java @@ -32,7 +32,7 @@ public class NoSqlDaoServiceTestSuite { @ClassRule public static CustomSqlUnit sqlUnit = new CustomSqlUnit( Arrays.asList("sql/schema-entities-hsql.sql", "sql/schema-entities-idx.sql", "sql/system-data.sql", "sql/system-test.sql"), - "sql/drop-all-tables.sql", + "sql/hsql/drop-all-tables.sql", "nosql-test.properties" ); From 65015bfd732c3702abd7b8273c189b11d0cc99b3 Mon Sep 17 00:00:00 2001 From: Vladyslav Date: Thu, 7 May 2020 11:09:56 +0300 Subject: [PATCH 3/5] [3.0] Improvement image map (#2740) * Fixed not correct center image map Fixed update position marker for image map * Add support IE and clear code * Fix not correct update image for datasource * Update marker position --- .../components/widget/lib/maps/leaflet-map.ts | 3 +-- .../components/widget/lib/maps/maps-utils.ts | 12 +++++++++++- .../components/widget/lib/maps/markers.ts | 4 ++-- .../widget/lib/maps/providers/image-map.ts | 19 +++++++++++-------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts index 93477c1782..f4b264cabc 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts @@ -40,7 +40,6 @@ export default abstract class LeafletMap { markers: Map = new Map(); polylines: Map = new Map(); polygons: Map = new Map(); - dragMode = false; map: L.Map; map$: BehaviorSubject = new BehaviorSubject(null); ready$: Observable = this.map$.pipe(filter(map => !!map)); @@ -238,7 +237,7 @@ export default abstract class LeafletMap { convertToCustomFormat(position: L.LatLng): object { return { - [this.options.latKeyName]: position.lat % 180, + [this.options.latKeyName]: position.lat % 90, [this.options.lngKeyName]: position.lng % 180 } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts index fd92306349..742e024a09 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/maps-utils.ts @@ -75,7 +75,7 @@ const imageAspectMap = {}; function imageLoader(imageUrl: string): Observable { return new Observable((observer: Observer) => { - const image = new Image(); + const image = document.createElement('img'); // support IE image.style.position = 'absolute'; image.style.left = '-99999px'; image.style.top = '-99999px'; @@ -236,3 +236,13 @@ export function safeExecute(func: (...args: any[]) => any, params = []) { } return res; } + +export function calculateNewPointCoordinate(coordinate: number, imageSize: number): number { + let pointCoordinate = coordinate / imageSize; + if (pointCoordinate < 0) { + pointCoordinate = 0; + } else if (pointCoordinate > 1) { + pointCoordinate = 1; + } + return pointCoordinate; +} diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts index 38618efe2f..2e3927fdc4 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/markers.ts @@ -29,8 +29,8 @@ export class Marker { data: FormattedData; dataSources: FormattedData[]; - constructor(location: L.LatLngExpression, public settings: MarkerSettings, - data?: FormattedData, dataSources?, onDragendListener?) { + constructor(location: L.LatLngExpression, public settings: MarkerSettings, + data?: FormattedData, dataSources?, onDragendListener?) { this.setDataSources(data, dataSources); this.leafletMarker = L.marker(location, { draggable: settings.draggableMarker diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts index fc4bbc6fcd..fce2fb3644 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/providers/image-map.ts @@ -19,7 +19,7 @@ import LeafletMap from '../leaflet-map'; import { UnitedMapSettings } from '../map-models'; import { Observable } from 'rxjs'; import { map, filter, switchMap } from 'rxjs/operators'; -import { aspectCache, parseFunction } from '@home/components/widget/lib/maps/maps-utils'; +import { aspectCache, calculateNewPointCoordinate, parseFunction } from '@home/components/widget/lib/maps/maps-utils'; const maxZoom = 4;// ? @@ -79,9 +79,10 @@ export class ImageMap extends LeafletMap { if (lastCenterPos) { lastCenterPos.x *= w; lastCenterPos.y *= h; - /* this.ctx.$scope.$injector.get('$mdUtil').nextTick(() => { - this.map.panTo(center, { animate: false }); - });*/ + const center = this.pointToLatLng(lastCenterPos.x, lastCenterPos.y); + setTimeout(() => { + this.map.panTo(center, { animate: false }); + }, 0); } } @@ -97,7 +98,7 @@ export class ImageMap extends LeafletMap { width *= maxZoom; const prevWidth = this.width; const prevHeight = this.height; - if (this.width !== width) { + if (this.width !== width || updateImage) { this.width = width; this.height = width / this.aspect; if (!this.map) { @@ -108,6 +109,7 @@ export class ImageMap extends LeafletMap { lastCenterPos.y /= prevHeight; this.updateBounds(updateImage, lastCenterPos); this.map.invalidateSize(true); + // TODO: need add update marker position } } } @@ -133,7 +135,7 @@ export class ImageMap extends LeafletMap { convertPosition(expression): L.LatLng { if (isNaN(expression[this.options.xPosKeyName]) || isNaN(expression[this.options.yPosKeyName])) return null; - Object.assign(expression, this.posFunction(expression[this.options.xPosKeyName], expression[this.options.yPosKeyName])) + Object.assign(expression, this.posFunction(expression[this.options.xPosKeyName], expression[this.options.yPosKeyName])); return this.pointToLatLng( expression.x * this.width, expression.y * this.height); @@ -148,9 +150,10 @@ export class ImageMap extends LeafletMap { } convertToCustomFormat(position: L.LatLng): object { + const point = this.latLngToPoint(position); return { - [this.options.xPosKeyName]: (position.lng + 180) / 360, - [this.options.yPosKeyName]: (position.lat + 180) / 360 + [this.options.xPosKeyName]: calculateNewPointCoordinate(point.x, this.width), + [this.options.yPosKeyName]: calculateNewPointCoordinate(point.y, this.height) } } } From 9db9c36bb3497149955f409218b342d73df1723a Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 7 May 2020 11:23:36 +0300 Subject: [PATCH 4/5] Fix tests --- .../java/org/thingsboard/server/mqtt/MqttNoSqlTestSuite.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/test/java/org/thingsboard/server/mqtt/MqttNoSqlTestSuite.java b/application/src/test/java/org/thingsboard/server/mqtt/MqttNoSqlTestSuite.java index a9bb113a60..ad81884f1f 100644 --- a/application/src/test/java/org/thingsboard/server/mqtt/MqttNoSqlTestSuite.java +++ b/application/src/test/java/org/thingsboard/server/mqtt/MqttNoSqlTestSuite.java @@ -34,7 +34,7 @@ public class MqttNoSqlTestSuite { @ClassRule public static CustomSqlUnit sqlUnit = new CustomSqlUnit( Arrays.asList("sql/schema-entities-hsql.sql", "sql/system-data.sql"), - "sql/drop-all-tables.sql", + "sql/hsql/drop-all-tables.sql", "nosql-test.properties"); @ClassRule From 7a87e6c16d7709f31d2bbec5323f679e771b5483 Mon Sep 17 00:00:00 2001 From: Vladyslav Date: Thu, 7 May 2020 11:27:29 +0300 Subject: [PATCH 5/5] Fix error update websocket to change user (#2744) --- ui-ngx/src/app/core/ws/telemetry-websocket.service.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts index 1502e76fd8..09d05c3906 100644 --- a/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts +++ b/ui-ngx/src/app/core/ws/telemetry-websocket.service.ts @@ -70,10 +70,8 @@ export class TelemetryWebsocketService implements TelemetryService { private ngZone: NgZone, @Inject(WINDOW) private window: Window) { this.store.pipe(select(selectIsAuthenticated)).subscribe( - (authenticated: boolean) => { - if (!authenticated) { - this.reset(true); - } + () => { + this.reset(true); } );