diff --git a/application/src/main/data/json/demo/dashboards/firmware.json b/application/src/main/data/json/demo/dashboards/firmware.json
index 45a88262f8..6a650b1bd9 100644
--- a/application/src/main/data/json/demo/dashboards/firmware.json
+++ b/application/src/main/data/json/demo/dashboards/firmware.json
@@ -279,7 +279,7 @@
"name": "Edit firmware",
"icon": "edit",
"type": "customPretty",
- "customHtml": "
",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n firmwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n firmwareId: vm.entity.firmwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.firmwareId = formValues.firmwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
@@ -1142,7 +1142,7 @@
"name": "Edit firmware",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n firmwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n firmwareId: vm.entity.firmwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.firmwareId = formValues.firmwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
@@ -1448,7 +1448,7 @@
"name": "Edit firmware",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n firmwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n firmwareId: vm.entity.firmwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.firmwareId = formValues.firmwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
@@ -1754,7 +1754,7 @@
"name": "Edit firmware",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n firmwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n firmwareId: vm.entity.firmwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.firmwareId = formValues.firmwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
@@ -2060,7 +2060,7 @@
"name": "Edit firmware",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n firmwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n firmwareId: vm.entity.firmwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.firmwareId = formValues.firmwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
diff --git a/application/src/main/data/json/demo/dashboards/software.json b/application/src/main/data/json/demo/dashboards/software.json
index 1fc1e0018f..96b3782315 100644
--- a/application/src/main/data/json/demo/dashboards/software.json
+++ b/application/src/main/data/json/demo/dashboards/software.json
@@ -279,7 +279,7 @@
"name": "Edit software",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n softwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n softwareId: vm.entity.softwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.softwareId = formValues.softwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
@@ -1142,7 +1142,7 @@
"name": "Edit software",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n softwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n softwareId: vm.entity.softwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.softwareId = formValues.softwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
@@ -1448,7 +1448,7 @@
"name": "Edit software",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n softwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n softwareId: vm.entity.softwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.softwareId = formValues.softwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
@@ -1754,7 +1754,7 @@
"name": "Edit software",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n softwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n softwareId: vm.entity.softwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.softwareId = formValues.softwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
@@ -2060,7 +2060,7 @@
"name": "Edit software",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": "form {\n min-width: 300px !important;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet entityService = $injector.get(widgetContext.servicesMap.get('entityService'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n\n vm.entityName = entityName;\n vm.entity = {};\n\n vm.editEntityFormGroup = vm.fb.group({\n softwareId: [null]\n });\n\n getEntityInfo();\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n\n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveEntity().subscribe(\n function () {\n // widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n };\n\n\n function getEntityInfo() {\n entityService.getEntity(entityId.entityType, entityId.id).subscribe(\n function (data) {\n vm.entity = data;\n vm.editEntityFormGroup.patchValue({\n softwareId: vm.entity.softwareId\n }, {emitEvent: false});\n }\n );\n }\n\n function saveEntity() {\n const formValues = vm.editEntityFormGroup.value;\n vm.entity.softwareId = formValues.softwareId;\n return deviceService.saveDevice(vm.entity);\n }\n}",
"customResources": [],
diff --git a/application/src/main/data/json/demo/dashboards/thermostats.json b/application/src/main/data/json/demo/dashboards/thermostats.json
index 40866db9ef..c7b8d50354 100644
--- a/application/src/main/data/json/demo/dashboards/thermostats.json
+++ b/application/src/main/data/json/demo/dashboards/thermostats.json
@@ -167,7 +167,7 @@
"name": "Add",
"icon": "add",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": ".add-entity-form{\n width: 300px;\n}\n",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\n\nopenAddEntityDialog();\n\nfunction openAddEntityDialog() {\n customDialog.customDialog(htmlTemplate, AddEntityDialogController).subscribe();\n}\n\nfunction AddEntityDialogController(instance) {\n let vm = instance;\n \n vm.addEntityFormGroup = vm.fb.group({\n entityName: ['', [vm.validators.required]],\n attributes: vm.fb.group({\n temperatureAlarmFlag: [false],\n temperatureAlarmThreshold: [{value: null, disabled: true}],\n humidityAlarmFlag: [false],\n humidityAlarmThreshold: [{value: null, disabled: true}]\n })\n });\n \n vm.addEntityFormGroup.get('attributes').get('temperatureAlarmFlag').valueChanges\n .subscribe(activate => {\n if (activate) {\n vm.addEntityFormGroup.get('attributes').get('temperatureAlarmThreshold').enable();\n } else {\n vm.addEntityFormGroup.get('attributes').get('temperatureAlarmThreshold').disable();\n }\n });\n \n vm.addEntityFormGroup.get('attributes').get('humidityAlarmFlag').valueChanges\n .subscribe(activate => {\n if (activate) {\n vm.addEntityFormGroup.get('attributes').get('humidityAlarmThreshold').enable();\n } else {\n vm.addEntityFormGroup.get('attributes').get('humidityAlarmThreshold').disable();\n }\n });\n\n vm.save = function() {\n vm.addEntityFormGroup.markAsPristine();\n saveEntityObservable().subscribe(\n function (entity) {\n saveAttributes(entity.id).subscribe(\n function () {\n widgetContext.updateAliases();\n vm.dialogRef.close(null);\n }\n );\n }\n );\n };\n \n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n \n function saveEntityObservable() {\n const formValues = vm.addEntityFormGroup.value;\n let entity = {\n name: formValues.entityName,\n type: \"thermostat\"\n };\n return deviceService.saveDevice(entity);\n }\n \n function saveAttributes(entityId) {\n let attributes = vm.addEntityFormGroup.get('attributes').value;\n let attributesArray = [];\n for (let key in attributes) {\n if(attributes[key] !== null) {\n attributesArray.push({key: key, value: attributes[key]});\n }\n }\n if (attributesArray.length > 0) {\n return attributeService.saveEntityAttributes(entityId, \"SERVER_SCOPE\", attributesArray);\n } else {\n return widgetContext.rxjs.of([]);\n }\n }\n}",
"customResources": [],
@@ -187,7 +187,7 @@
"name": "Edit",
"icon": "edit",
"type": "customPretty",
- "customHtml": "",
+ "customHtml": "",
"customCss": ".edit-entity-form{\n width: 300px;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\n\nopenEditEntityDialog();\n\nfunction openEditEntityDialog() {\n customDialog.customDialog(htmlTemplate, EditEntityDialogController).subscribe();\n}\n\nfunction EditEntityDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId;\n vm.entityName = entityName;\n vm.attributes = {};\n \n vm.editEntityFormGroup = vm.fb.group({\n entityName: [''],\n attributes: vm.fb.group({\n temperatureAlarmFlag: [false],\n temperatureAlarmThreshold: [{value: null, disabled: true}],\n humidityAlarmFlag: [false],\n humidityAlarmThreshold: [{value: null, disabled: true}]\n })\n });\n \n vm.editEntityFormGroup.get('attributes').get('temperatureAlarmFlag').valueChanges\n .subscribe(activate => {\n if (activate) {\n vm.editEntityFormGroup.get('attributes').get('temperatureAlarmThreshold').enable();\n } else {\n vm.editEntityFormGroup.get('attributes').get('temperatureAlarmThreshold').disable();\n }\n });\n \n vm.editEntityFormGroup.get('attributes').get('humidityAlarmFlag').valueChanges\n .subscribe(activate => {\n if (activate) {\n vm.editEntityFormGroup.get('attributes').get('humidityAlarmThreshold').enable();\n } else {\n vm.editEntityFormGroup.get('attributes').get('humidityAlarmThreshold').disable();\n }\n });\n \n \n getEntityInfo();\n \n \n vm.save = function() {\n vm.editEntityFormGroup.markAsPristine();\n saveAttributes(entityId).subscribe(\n function () {\n vm.dialogRef.close(null);\n }\n );\n };\n \n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n \n function getEntityAttributes(attributes) {\n for (var i = 0; i < attributes.length; i++) {\n vm.attributes[attributes[i].key] = attributes[i].value;\n }\n }\n \n function getEntityInfo() {\n attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE').subscribe(\n function (attributes) {\n getEntityAttributes(attributes);\n vm.editEntityFormGroup.patchValue({\n entityName: vm.entityName,\n attributes: vm.attributes\n });\n // if(vm.attributes.temperatureAlarmFlag) {\n // vm.editEntityFormGroup.get('attributes').get('temperatureAlarmThreshold').enable();\n // }\n // if(vm.attributes.humidityAlarmFlag) {\n // vm.editEntityFormGroup.get('attributes').get('humidityAlarmThreshold').enable();\n // }\n }\n );\n }\n \n function saveAttributes(entityId) {\n let attributes = vm.editEntityFormGroup.get('attributes').value;\n let attributesArray = [];\n for (let key in attributes) {\n if (attributes[key] !== vm.attributes[key]) {\n attributesArray.push({key: key, value: attributes[key]});\n }\n }\n if (attributesArray.length > 0) {\n return attributeService.saveEntityAttributes(entityId, \"SERVER_SCOPE\", attributesArray);\n } else {\n return widgetContext.rxjs.of([]);\n }\n }\n}",
"customResources": [],
diff --git a/application/src/main/data/json/system/widget_types/asset_admin_table.json b/application/src/main/data/json/system/widget_types/asset_admin_table.json
index 41e0727a1c..cb3a270b6d 100644
--- a/application/src/main/data/json/system/widget_types/asset_admin_table.json
+++ b/application/src/main/data/json/system/widget_types/asset_admin_table.json
@@ -16,7 +16,7 @@
"dataKeySettingsDirective": "tb-entities-table-key-settings",
"hasBasicMode": true,
"basicModeDirective": "tb-entities-table-basic-config",
- "defaultConfig": "{\"showTitle\":true,\"backgroundColor\":\"rgb(255, 255, 255)\",\"color\":\"rgba(0, 0, 0, 0.87)\",\"padding\":\"4px\",\"settings\":{\"entitiesTitle\":\"Asset admin table\",\"enableSearch\":true,\"enableSelectColumnDisplay\":true,\"enableStickyHeader\":true,\"enableStickyAction\":true,\"showCellActionsMenu\":true,\"reserveSpaceForHiddenAction\":\"true\",\"displayEntityName\":false,\"displayEntityLabel\":false,\"displayEntityType\":false,\"displayPagination\":true,\"defaultPageSize\":10,\"defaultSortOrder\":\"entityName\",\"useRowStyleFunction\":false},\"title\":\"Asset admin table\",\"dropShadow\":true,\"enableFullscreen\":true,\"titleStyle\":{\"fontSize\":\"16px\",\"fontWeight\":400,\"padding\":\"5px 10px 5px 10px\"},\"showLegend\":false,\"datasources\":[{\"type\":\"function\",\"name\":\"Simulated\",\"dataKeys\":[{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Entity name\",\"color\":\"#4caf50\",\"settings\":{},\"_hash\":0.6985800247727296,\"funcBody\":\"return 'Simulated';\",\"aggregationType\":null,\"units\":null,\"decimals\":null,\"usePostProcessing\":null,\"postFuncBody\":null},{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Entity type\",\"color\":\"#f44336\",\"settings\":{},\"_hash\":0.10073938422359707,\"funcBody\":\"return 'Device';\",\"aggregationType\":null,\"units\":null,\"decimals\":null,\"usePostProcessing\":null,\"postFuncBody\":null},{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Random\",\"color\":\"#f44336\",\"settings\":{\"columnWidth\":\"0px\",\"useCellStyleFunction\":false,\"cellStyleFunction\":\"\",\"useCellContentFunction\":false,\"cellContentFunction\":\"\"},\"_hash\":0.6401141393938932,\"funcBody\":\"var value = prevValue + Math.random() * 100 - 50;\\nvar multiplier = Math.pow(10, 2 || 0);\\nvar value = Math.round(value * multiplier) / multiplier;\\nif (value < -1000) {\\n\\tvalue = -1000;\\n} else if (value > 1000) {\\n\\tvalue = 1000;\\n}\\nreturn value;\"}],\"alarmFilterConfig\":{\"statusList\":[\"ACTIVE\"]}}],\"showTitleIcon\":false,\"titleIcon\":\"more_horiz\",\"iconColor\":\"rgba(0, 0, 0, 0.87)\",\"iconSize\":\"24px\",\"titleTooltip\":\"\",\"widgetStyle\":{},\"actions\":{\"headerButton\":[{\"name\":\"Add asset\",\"icon\":\"add\",\"type\":\"customPretty\",\"customHtml\":\"\\n\",\"customCss\":\"\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\\nlet assetService = $injector.get(widgetContext.servicesMap.get('assetService'));\\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\\n\\nopenAddAssetDialog();\\n\\nfunction openAddAssetDialog() {\\n customDialog.customDialog(htmlTemplate, AddAssetDialogController).subscribe();\\n}\\n\\nfunction AddAssetDialogController(instance) {\\n let vm = instance;\\n \\n vm.addAssetFormGroup = vm.fb.group({\\n assetName: ['', [vm.validators.required]],\\n assetType: ['', [vm.validators.required]],\\n assetLabel: [''],\\n attributes: vm.fb.group({\\n latitude: [null],\\n longitude: [null]\\n }) \\n });\\n \\n vm.cancel = function() {\\n vm.dialogRef.close(null);\\n };\\n \\n vm.save = function() {\\n vm.addAssetFormGroup.markAsPristine();\\n let asset = {\\n name: vm.addAssetFormGroup.get('assetName').value,\\n type: vm.addAssetFormGroup.get('assetType').value,\\n label: vm.addAssetFormGroup.get('assetLabel').value\\n };\\n assetService.saveAsset(asset).subscribe(\\n function (asset) {\\n saveAttributes(asset.id).subscribe(\\n function () {\\n widgetContext.updateAliases();\\n vm.dialogRef.close(null);\\n }\\n );\\n }\\n );\\n };\\n \\n function saveAttributes(entityId) {\\n let attributes = vm.addAssetFormGroup.get('attributes').value;\\n let attributesArray = [];\\n for (let key in attributes) {\\n attributesArray.push({key: key, value: attributes[key]});\\n }\\n if (attributesArray.length > 0) {\\n return attributeService.saveEntityAttributes(entityId, \\\"SERVER_SCOPE\\\", attributesArray);\\n } else {\\n return widgetContext.rxjs.of([]);\\n }\\n }\\n}\",\"customResources\":[],\"id\":\"70837a9d-c3de-a9a7-03c5-dccd14998758\"}],\"actionCellButton\":[{\"name\":\"Edit asset\",\"icon\":\"edit\",\"type\":\"customPretty\",\"customHtml\":\"\\n\",\"customCss\":\"\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\\nlet assetService = $injector.get(widgetContext.servicesMap.get('assetService'));\\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\\n\\nopenEditAssetDialog();\\n\\nfunction openEditAssetDialog() {\\n customDialog.customDialog(htmlTemplate, EditAssetDialogController).subscribe();\\n}\\n\\nfunction EditAssetDialogController(instance) {\\n let vm = instance;\\n \\n vm.asset = null;\\n vm.attributes = {};\\n \\n vm.editAssetFormGroup = vm.fb.group({\\n assetName: ['', [vm.validators.required]],\\n assetType: ['', [vm.validators.required]],\\n assetLabel: [''],\\n attributes: vm.fb.group({\\n latitude: [null],\\n longitude: [null]\\n }) \\n });\\n \\n vm.cancel = function() {\\n vm.dialogRef.close(null);\\n };\\n \\n vm.save = function() {\\n vm.editAssetFormGroup.markAsPristine();\\n vm.asset.name = vm.editAssetFormGroup.get('assetName').value,\\n vm.asset.type = vm.editAssetFormGroup.get('assetType').value,\\n vm.asset.label = vm.editAssetFormGroup.get('assetLabel').value\\n assetService.saveAsset(vm.asset).subscribe(\\n function () {\\n saveAttributes().subscribe(\\n function () {\\n widgetContext.updateAliases();\\n vm.dialogRef.close(null);\\n }\\n );\\n }\\n );\\n };\\n \\n getEntityInfo();\\n \\n function getEntityInfo() {\\n assetService.getAsset(entityId.id).subscribe(\\n function (asset) {\\n attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE',\\n ['latitude', 'longitude']).subscribe(\\n function (attributes) {\\n for (let i = 0; i < attributes.length; i++) {\\n vm.attributes[attributes[i].key] = attributes[i].value; \\n }\\n vm.asset = asset;\\n vm.editAssetFormGroup.patchValue(\\n {\\n assetName: vm.asset.name,\\n assetType: vm.asset.type,\\n assetLabel: vm.asset.label,\\n attributes: {\\n latitude: vm.attributes.latitude,\\n longitude: vm.attributes.longitude\\n }\\n }, {emitEvent: false}\\n );\\n } \\n );\\n }\\n ); \\n }\\n \\n function saveAttributes() {\\n let attributes = vm.editAssetFormGroup.get('attributes').value;\\n let attributesArray = [];\\n for (let key in attributes) {\\n attributesArray.push({key: key, value: attributes[key]});\\n }\\n if (attributesArray.length > 0) {\\n return attributeService.saveEntityAttributes(entityId, 'SERVER_SCOPE', attributesArray);\\n } else {\\n return widgetContext.rxjs.of([]);\\n }\\n }\\n}\",\"customResources\":[],\"id\":\"93931e52-5d7c-903e-67aa-b9435df44ff4\"},{\"name\":\"Delete asset\",\"icon\":\"delete\",\"type\":\"custom\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet dialogs = $injector.get(widgetContext.servicesMap.get('dialogs'));\\nlet assetService = $injector.get(widgetContext.servicesMap.get('assetService'));\\n\\nopenDeleteAssetDialog();\\n\\nfunction openDeleteAssetDialog() {\\n let title = \\\"Are you sure you want to delete the asset \\\" + entityName + \\\"?\\\";\\n let content = \\\"Be careful, after the confirmation, the asset and all related data will become unrecoverable!\\\";\\n dialogs.confirm(title, content, 'Cancel', 'Delete').subscribe(\\n function (result) {\\n if (result) {\\n deleteAsset();\\n }\\n }\\n );\\n}\\n\\nfunction deleteAsset() {\\n assetService.deleteAsset(entityId.id).subscribe(\\n function () {\\n widgetContext.updateAliases();\\n }\\n );\\n}\\n\",\"id\":\"ec2708f6-9ff0-186b-e4fc-7635ebfa3074\"}]},\"configMode\":\"basic\",\"titleFont\":null,\"titleColor\":null}"
+ "defaultConfig": "{\"showTitle\":true,\"backgroundColor\":\"rgb(255, 255, 255)\",\"color\":\"rgba(0, 0, 0, 0.87)\",\"padding\":\"4px\",\"settings\":{\"entitiesTitle\":\"Asset admin table\",\"enableSearch\":true,\"enableSelectColumnDisplay\":true,\"enableStickyHeader\":true,\"enableStickyAction\":true,\"showCellActionsMenu\":true,\"reserveSpaceForHiddenAction\":\"true\",\"displayEntityName\":false,\"displayEntityLabel\":false,\"displayEntityType\":false,\"displayPagination\":true,\"defaultPageSize\":10,\"defaultSortOrder\":\"entityName\",\"useRowStyleFunction\":false},\"title\":\"Asset admin table\",\"dropShadow\":true,\"enableFullscreen\":true,\"titleStyle\":{\"fontSize\":\"16px\",\"fontWeight\":400,\"padding\":\"5px 10px 5px 10px\"},\"showLegend\":false,\"datasources\":[{\"type\":\"function\",\"name\":\"Simulated\",\"dataKeys\":[{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Entity name\",\"color\":\"#4caf50\",\"settings\":{},\"_hash\":0.6985800247727296,\"funcBody\":\"return 'Simulated';\",\"aggregationType\":null,\"units\":null,\"decimals\":null,\"usePostProcessing\":null,\"postFuncBody\":null},{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Entity type\",\"color\":\"#f44336\",\"settings\":{},\"_hash\":0.10073938422359707,\"funcBody\":\"return 'Device';\",\"aggregationType\":null,\"units\":null,\"decimals\":null,\"usePostProcessing\":null,\"postFuncBody\":null},{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Random\",\"color\":\"#f44336\",\"settings\":{\"columnWidth\":\"0px\",\"useCellStyleFunction\":false,\"cellStyleFunction\":\"\",\"useCellContentFunction\":false,\"cellContentFunction\":\"\"},\"_hash\":0.6401141393938932,\"funcBody\":\"var value = prevValue + Math.random() * 100 - 50;\\nvar multiplier = Math.pow(10, 2 || 0);\\nvar value = Math.round(value * multiplier) / multiplier;\\nif (value < -1000) {\\n\\tvalue = -1000;\\n} else if (value > 1000) {\\n\\tvalue = 1000;\\n}\\nreturn value;\"}],\"alarmFilterConfig\":{\"statusList\":[\"ACTIVE\"]}}],\"showTitleIcon\":false,\"titleIcon\":\"more_horiz\",\"iconColor\":\"rgba(0, 0, 0, 0.87)\",\"iconSize\":\"24px\",\"titleTooltip\":\"\",\"widgetStyle\":{},\"actions\":{\"headerButton\":[{\"name\":\"Add asset\",\"icon\":\"add\",\"type\":\"customPretty\",\"customHtml\":\"\\n\",\"customCss\":\"\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\\nlet assetService = $injector.get(widgetContext.servicesMap.get('assetService'));\\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\\n\\nopenAddAssetDialog();\\n\\nfunction openAddAssetDialog() {\\n customDialog.customDialog(htmlTemplate, AddAssetDialogController).subscribe();\\n}\\n\\nfunction AddAssetDialogController(instance) {\\n let vm = instance;\\n \\n vm.addAssetFormGroup = vm.fb.group({\\n assetName: ['', [vm.validators.required]],\\n assetType: ['', [vm.validators.required]],\\n assetLabel: [''],\\n attributes: vm.fb.group({\\n latitude: [null],\\n longitude: [null]\\n }) \\n });\\n \\n vm.cancel = function() {\\n vm.dialogRef.close(null);\\n };\\n \\n vm.save = function() {\\n vm.addAssetFormGroup.markAsPristine();\\n let asset = {\\n name: vm.addAssetFormGroup.get('assetName').value,\\n type: vm.addAssetFormGroup.get('assetType').value,\\n label: vm.addAssetFormGroup.get('assetLabel').value\\n };\\n assetService.saveAsset(asset).subscribe(\\n function (asset) {\\n saveAttributes(asset.id).subscribe(\\n function () {\\n widgetContext.updateAliases();\\n vm.dialogRef.close(null);\\n }\\n );\\n }\\n );\\n };\\n \\n function saveAttributes(entityId) {\\n let attributes = vm.addAssetFormGroup.get('attributes').value;\\n let attributesArray = [];\\n for (let key in attributes) {\\n attributesArray.push({key: key, value: attributes[key]});\\n }\\n if (attributesArray.length > 0) {\\n return attributeService.saveEntityAttributes(entityId, \\\"SERVER_SCOPE\\\", attributesArray);\\n } else {\\n return widgetContext.rxjs.of([]);\\n }\\n }\\n}\",\"customResources\":[],\"id\":\"70837a9d-c3de-a9a7-03c5-dccd14998758\"}],\"actionCellButton\":[{\"name\":\"Edit asset\",\"icon\":\"edit\",\"type\":\"customPretty\",\"customHtml\":\"\\n\",\"customCss\":\"\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\\nlet assetService = $injector.get(widgetContext.servicesMap.get('assetService'));\\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\\n\\nopenEditAssetDialog();\\n\\nfunction openEditAssetDialog() {\\n customDialog.customDialog(htmlTemplate, EditAssetDialogController).subscribe();\\n}\\n\\nfunction EditAssetDialogController(instance) {\\n let vm = instance;\\n \\n vm.asset = null;\\n vm.attributes = {};\\n \\n vm.editAssetFormGroup = vm.fb.group({\\n assetName: ['', [vm.validators.required]],\\n assetType: ['', [vm.validators.required]],\\n assetLabel: [''],\\n attributes: vm.fb.group({\\n latitude: [null],\\n longitude: [null]\\n }) \\n });\\n \\n vm.cancel = function() {\\n vm.dialogRef.close(null);\\n };\\n \\n vm.save = function() {\\n vm.editAssetFormGroup.markAsPristine();\\n vm.asset.name = vm.editAssetFormGroup.get('assetName').value,\\n vm.asset.type = vm.editAssetFormGroup.get('assetType').value,\\n vm.asset.label = vm.editAssetFormGroup.get('assetLabel').value\\n assetService.saveAsset(vm.asset).subscribe(\\n function () {\\n saveAttributes().subscribe(\\n function () {\\n widgetContext.updateAliases();\\n vm.dialogRef.close(null);\\n }\\n );\\n }\\n );\\n };\\n \\n getEntityInfo();\\n \\n function getEntityInfo() {\\n assetService.getAsset(entityId.id).subscribe(\\n function (asset) {\\n attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE',\\n ['latitude', 'longitude']).subscribe(\\n function (attributes) {\\n for (let i = 0; i < attributes.length; i++) {\\n vm.attributes[attributes[i].key] = attributes[i].value; \\n }\\n vm.asset = asset;\\n vm.editAssetFormGroup.patchValue(\\n {\\n assetName: vm.asset.name,\\n assetType: vm.asset.type,\\n assetLabel: vm.asset.label,\\n attributes: {\\n latitude: vm.attributes.latitude,\\n longitude: vm.attributes.longitude\\n }\\n }, {emitEvent: false}\\n );\\n } \\n );\\n }\\n ); \\n }\\n \\n function saveAttributes() {\\n let attributes = vm.editAssetFormGroup.get('attributes').value;\\n let attributesArray = [];\\n for (let key in attributes) {\\n attributesArray.push({key: key, value: attributes[key]});\\n }\\n if (attributesArray.length > 0) {\\n return attributeService.saveEntityAttributes(entityId, 'SERVER_SCOPE', attributesArray);\\n } else {\\n return widgetContext.rxjs.of([]);\\n }\\n }\\n}\",\"customResources\":[],\"id\":\"93931e52-5d7c-903e-67aa-b9435df44ff4\"},{\"name\":\"Delete asset\",\"icon\":\"delete\",\"type\":\"custom\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet dialogs = $injector.get(widgetContext.servicesMap.get('dialogs'));\\nlet assetService = $injector.get(widgetContext.servicesMap.get('assetService'));\\n\\nopenDeleteAssetDialog();\\n\\nfunction openDeleteAssetDialog() {\\n let title = \\\"Are you sure you want to delete the asset \\\" + entityName + \\\"?\\\";\\n let content = \\\"Be careful, after the confirmation, the asset and all related data will become unrecoverable!\\\";\\n dialogs.confirm(title, content, 'Cancel', 'Delete').subscribe(\\n function (result) {\\n if (result) {\\n deleteAsset();\\n }\\n }\\n );\\n}\\n\\nfunction deleteAsset() {\\n assetService.deleteAsset(entityId.id).subscribe(\\n function () {\\n widgetContext.updateAliases();\\n }\\n );\\n}\\n\",\"id\":\"ec2708f6-9ff0-186b-e4fc-7635ebfa3074\"}]},\"configMode\":\"basic\",\"titleFont\":null,\"titleColor\":null}"
},
"tags": [
"provisioning",
diff --git a/application/src/main/data/json/system/widget_types/device_admin_table.json b/application/src/main/data/json/system/widget_types/device_admin_table.json
index 220771effb..30d37dbca2 100644
--- a/application/src/main/data/json/system/widget_types/device_admin_table.json
+++ b/application/src/main/data/json/system/widget_types/device_admin_table.json
@@ -16,7 +16,7 @@
"dataKeySettingsDirective": "tb-entities-table-key-settings",
"hasBasicMode": true,
"basicModeDirective": "tb-entities-table-basic-config",
- "defaultConfig": "{\"showTitle\":true,\"backgroundColor\":\"rgb(255, 255, 255)\",\"color\":\"rgba(0, 0, 0, 0.87)\",\"padding\":\"4px\",\"settings\":{\"entitiesTitle\":\"Device admin table\",\"enableSearch\":true,\"enableSelectColumnDisplay\":true,\"enableStickyHeader\":true,\"enableStickyAction\":true,\"showCellActionsMenu\":true,\"reserveSpaceForHiddenAction\":\"true\",\"displayEntityName\":false,\"displayEntityLabel\":false,\"displayEntityType\":false,\"displayPagination\":true,\"defaultPageSize\":10,\"defaultSortOrder\":\"entityName\",\"useRowStyleFunction\":false},\"title\":\"Device admin table\",\"dropShadow\":true,\"enableFullscreen\":true,\"titleStyle\":{\"fontSize\":\"16px\",\"fontWeight\":400,\"padding\":\"5px 10px 5px 10px\"},\"showLegend\":false,\"datasources\":[{\"type\":\"function\",\"name\":\"Simulated\",\"dataKeys\":[{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Entity name\",\"color\":\"#4caf50\",\"settings\":{},\"_hash\":0.8332260553092266,\"funcBody\":\"return 'Simulated';\",\"aggregationType\":null,\"units\":null,\"decimals\":null,\"usePostProcessing\":null,\"postFuncBody\":null},{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Entity type\",\"color\":\"#f44336\",\"settings\":{},\"_hash\":0.08583217494773887,\"funcBody\":\"return 'Device';\",\"aggregationType\":null,\"units\":null,\"decimals\":null,\"usePostProcessing\":null,\"postFuncBody\":null},{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Random\",\"color\":\"#f44336\",\"settings\":{\"columnWidth\":\"0px\",\"useCellStyleFunction\":false,\"cellStyleFunction\":\"\",\"useCellContentFunction\":false,\"cellContentFunction\":\"\"},\"_hash\":0.6401141393938932,\"funcBody\":\"var value = prevValue + Math.random() * 100 - 50;\\nvar multiplier = Math.pow(10, 2 || 0);\\nvar value = Math.round(value * multiplier) / multiplier;\\nif (value < -1000) {\\n\\tvalue = -1000;\\n} else if (value > 1000) {\\n\\tvalue = 1000;\\n}\\nreturn value;\"}],\"alarmFilterConfig\":{\"statusList\":[\"ACTIVE\"]}}],\"showTitleIcon\":false,\"titleIcon\":\"more_horiz\",\"iconColor\":\"rgba(0, 0, 0, 0.87)\",\"iconSize\":\"24px\",\"titleTooltip\":\"\",\"widgetStyle\":{},\"actions\":{\"headerButton\":[{\"name\":\"Add device\",\"icon\":\"add\",\"type\":\"customPretty\",\"customHtml\":\"\\n\",\"customCss\":\"\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\\n\\nopenAddDeviceDialog();\\n\\nfunction openAddDeviceDialog() {\\n customDialog.customDialog(htmlTemplate, AddDeviceDialogController).subscribe();\\n}\\n\\nfunction AddDeviceDialogController(instance) {\\n let vm = instance;\\n \\n vm.addDeviceFormGroup = vm.fb.group({\\n deviceName: ['', [vm.validators.required]],\\n deviceType: ['', [vm.validators.required]],\\n deviceLabel: [''],\\n attributes: vm.fb.group({\\n latitude: [null],\\n longitude: [null]\\n }) \\n });\\n \\n vm.cancel = function() {\\n vm.dialogRef.close(null);\\n };\\n \\n vm.save = function() {\\n vm.addDeviceFormGroup.markAsPristine();\\n let device = {\\n name: vm.addDeviceFormGroup.get('deviceName').value,\\n type: vm.addDeviceFormGroup.get('deviceType').value,\\n label: vm.addDeviceFormGroup.get('deviceLabel').value\\n };\\n deviceService.saveDevice(device).subscribe(\\n function (device) {\\n saveAttributes(device.id).subscribe(\\n function () {\\n widgetContext.updateAliases();\\n vm.dialogRef.close(null);\\n }\\n );\\n }\\n );\\n };\\n \\n function saveAttributes(entityId) {\\n let attributes = vm.addDeviceFormGroup.get('attributes').value;\\n let attributesArray = [];\\n for (let key in attributes) {\\n attributesArray.push({key: key, value: attributes[key]});\\n }\\n if (attributesArray.length > 0) {\\n return attributeService.saveEntityAttributes(entityId, \\\"SERVER_SCOPE\\\", attributesArray);\\n } else {\\n return widgetContext.rxjs.of([]);\\n }\\n }\\n}\",\"customResources\":[],\"id\":\"70837a9d-c3de-a9a7-03c5-dccd14998758\"}],\"actionCellButton\":[{\"name\":\"Edit device\",\"icon\":\"edit\",\"useShowWidgetActionFunction\":null,\"showWidgetActionFunction\":\"return true;\",\"type\":\"customPretty\",\"customHtml\":\"\\n\",\"customCss\":\"\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\\n\\nopenEditDeviceDialog();\\n\\nfunction openEditDeviceDialog() {\\n customDialog.customDialog(htmlTemplate, EditDeviceDialogController).subscribe();\\n}\\n\\nfunction EditDeviceDialogController(instance) {\\n let vm = instance;\\n \\n vm.device = null;\\n vm.attributes = {};\\n \\n vm.editDeviceFormGroup = vm.fb.group({\\n deviceName: ['', [vm.validators.required]],\\n deviceType: ['', [vm.validators.required]],\\n deviceLabel: [''],\\n attributes: vm.fb.group({\\n latitude: [null],\\n longitude: [null]\\n }) \\n });\\n \\n vm.cancel = function() {\\n vm.dialogRef.close(null);\\n };\\n \\n vm.save = function() {\\n vm.editDeviceFormGroup.markAsPristine();\\n if (vm.editDeviceFormGroup.get('deviceType').value !== vm.device.type) {\\n delete vm.device.deviceProfileId;\\n }\\n vm.device.name = vm.editDeviceFormGroup.get('deviceName').value,\\n vm.device.type = vm.editDeviceFormGroup.get('deviceType').value,\\n vm.device.label = vm.editDeviceFormGroup.get('deviceLabel').value\\n deviceService.saveDevice(vm.device).subscribe(\\n function () {\\n saveAttributes().subscribe(\\n function () {\\n widgetContext.updateAliases();\\n vm.dialogRef.close(null);\\n }\\n );\\n }\\n );\\n };\\n \\n getEntityInfo();\\n \\n function getEntityInfo() {\\n deviceService.getDevice(entityId.id).subscribe(\\n function (device) {\\n attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE',\\n ['latitude', 'longitude']).subscribe(\\n function (attributes) {\\n for (let i = 0; i < attributes.length; i++) {\\n vm.attributes[attributes[i].key] = attributes[i].value; \\n }\\n vm.device = device;\\n vm.editDeviceFormGroup.patchValue(\\n {\\n deviceName: vm.device.name,\\n deviceType: vm.device.type,\\n deviceLabel: vm.device.label,\\n attributes: {\\n latitude: vm.attributes.latitude,\\n longitude: vm.attributes.longitude\\n }\\n }, {emitEvent: false}\\n );\\n } \\n );\\n }\\n ); \\n }\\n \\n function saveAttributes() {\\n let attributes = vm.editDeviceFormGroup.get('attributes').value;\\n let attributesArray = [];\\n for (let key in attributes) {\\n attributesArray.push({key: key, value: attributes[key]});\\n }\\n if (attributesArray.length > 0) {\\n return attributeService.saveEntityAttributes(entityId, 'SERVER_SCOPE', attributesArray);\\n } else {\\n return widgetContext.rxjs.of([]);\\n }\\n }\\n}\",\"customResources\":[],\"openInSeparateDialog\":false,\"openInPopover\":false,\"id\":\"93931e52-5d7c-903e-67aa-b9435df44ff4\"},{\"name\":\"Delete device\",\"icon\":\"delete\",\"type\":\"custom\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet dialogs = $injector.get(widgetContext.servicesMap.get('dialogs'));\\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\\n\\nopenDeleteDeviceDialog();\\n\\nfunction openDeleteDeviceDialog() {\\n let title = \\\"Are you sure you want to delete the device \\\" + entityName + \\\"?\\\";\\n let content = \\\"Be careful, after the confirmation, the device and all related data will become unrecoverable!\\\";\\n dialogs.confirm(title, content, 'Cancel', 'Delete').subscribe(\\n function (result) {\\n if (result) {\\n deleteDevice();\\n }\\n }\\n );\\n}\\n\\nfunction deleteDevice() {\\n deviceService.deleteDevice(entityId.id).subscribe(\\n function () {\\n widgetContext.updateAliases();\\n }\\n );\\n}\\n\",\"id\":\"ec2708f6-9ff0-186b-e4fc-7635ebfa3074\"}]},\"configMode\":\"basic\"}"
+ "defaultConfig": "{\"showTitle\":true,\"backgroundColor\":\"rgb(255, 255, 255)\",\"color\":\"rgba(0, 0, 0, 0.87)\",\"padding\":\"4px\",\"settings\":{\"entitiesTitle\":\"Device admin table\",\"enableSearch\":true,\"enableSelectColumnDisplay\":true,\"enableStickyHeader\":true,\"enableStickyAction\":true,\"showCellActionsMenu\":true,\"reserveSpaceForHiddenAction\":\"true\",\"displayEntityName\":false,\"displayEntityLabel\":false,\"displayEntityType\":false,\"displayPagination\":true,\"defaultPageSize\":10,\"defaultSortOrder\":\"entityName\",\"useRowStyleFunction\":false},\"title\":\"Device admin table\",\"dropShadow\":true,\"enableFullscreen\":true,\"titleStyle\":{\"fontSize\":\"16px\",\"fontWeight\":400,\"padding\":\"5px 10px 5px 10px\"},\"showLegend\":false,\"datasources\":[{\"type\":\"function\",\"name\":\"Simulated\",\"dataKeys\":[{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Entity name\",\"color\":\"#4caf50\",\"settings\":{},\"_hash\":0.8332260553092266,\"funcBody\":\"return 'Simulated';\",\"aggregationType\":null,\"units\":null,\"decimals\":null,\"usePostProcessing\":null,\"postFuncBody\":null},{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Entity type\",\"color\":\"#f44336\",\"settings\":{},\"_hash\":0.08583217494773887,\"funcBody\":\"return 'Device';\",\"aggregationType\":null,\"units\":null,\"decimals\":null,\"usePostProcessing\":null,\"postFuncBody\":null},{\"name\":\"f(x)\",\"type\":\"function\",\"label\":\"Random\",\"color\":\"#f44336\",\"settings\":{\"columnWidth\":\"0px\",\"useCellStyleFunction\":false,\"cellStyleFunction\":\"\",\"useCellContentFunction\":false,\"cellContentFunction\":\"\"},\"_hash\":0.6401141393938932,\"funcBody\":\"var value = prevValue + Math.random() * 100 - 50;\\nvar multiplier = Math.pow(10, 2 || 0);\\nvar value = Math.round(value * multiplier) / multiplier;\\nif (value < -1000) {\\n\\tvalue = -1000;\\n} else if (value > 1000) {\\n\\tvalue = 1000;\\n}\\nreturn value;\"}],\"alarmFilterConfig\":{\"statusList\":[\"ACTIVE\"]}}],\"showTitleIcon\":false,\"titleIcon\":\"more_horiz\",\"iconColor\":\"rgba(0, 0, 0, 0.87)\",\"iconSize\":\"24px\",\"titleTooltip\":\"\",\"widgetStyle\":{},\"actions\":{\"headerButton\":[{\"name\":\"Add device\",\"icon\":\"add\",\"type\":\"customPretty\",\"customHtml\":\"\\n\",\"customCss\":\"\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\\n\\nopenAddDeviceDialog();\\n\\nfunction openAddDeviceDialog() {\\n customDialog.customDialog(htmlTemplate, AddDeviceDialogController).subscribe();\\n}\\n\\nfunction AddDeviceDialogController(instance) {\\n let vm = instance;\\n \\n vm.addDeviceFormGroup = vm.fb.group({\\n deviceName: ['', [vm.validators.required]],\\n deviceType: ['', [vm.validators.required]],\\n deviceLabel: [''],\\n attributes: vm.fb.group({\\n latitude: [null],\\n longitude: [null]\\n }) \\n });\\n \\n vm.cancel = function() {\\n vm.dialogRef.close(null);\\n };\\n \\n vm.save = function() {\\n vm.addDeviceFormGroup.markAsPristine();\\n let device = {\\n name: vm.addDeviceFormGroup.get('deviceName').value,\\n type: vm.addDeviceFormGroup.get('deviceType').value,\\n label: vm.addDeviceFormGroup.get('deviceLabel').value\\n };\\n deviceService.saveDevice(device).subscribe(\\n function (device) {\\n saveAttributes(device.id).subscribe(\\n function () {\\n widgetContext.updateAliases();\\n vm.dialogRef.close(null);\\n }\\n );\\n }\\n );\\n };\\n \\n function saveAttributes(entityId) {\\n let attributes = vm.addDeviceFormGroup.get('attributes').value;\\n let attributesArray = [];\\n for (let key in attributes) {\\n attributesArray.push({key: key, value: attributes[key]});\\n }\\n if (attributesArray.length > 0) {\\n return attributeService.saveEntityAttributes(entityId, \\\"SERVER_SCOPE\\\", attributesArray);\\n } else {\\n return widgetContext.rxjs.of([]);\\n }\\n }\\n}\",\"customResources\":[],\"id\":\"70837a9d-c3de-a9a7-03c5-dccd14998758\"}],\"actionCellButton\":[{\"name\":\"Edit device\",\"icon\":\"edit\",\"useShowWidgetActionFunction\":null,\"showWidgetActionFunction\":\"return true;\",\"type\":\"customPretty\",\"customHtml\":\"\\n\",\"customCss\":\"\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\\n\\nopenEditDeviceDialog();\\n\\nfunction openEditDeviceDialog() {\\n customDialog.customDialog(htmlTemplate, EditDeviceDialogController).subscribe();\\n}\\n\\nfunction EditDeviceDialogController(instance) {\\n let vm = instance;\\n \\n vm.device = null;\\n vm.attributes = {};\\n \\n vm.editDeviceFormGroup = vm.fb.group({\\n deviceName: ['', [vm.validators.required]],\\n deviceType: ['', [vm.validators.required]],\\n deviceLabel: [''],\\n attributes: vm.fb.group({\\n latitude: [null],\\n longitude: [null]\\n }) \\n });\\n \\n vm.cancel = function() {\\n vm.dialogRef.close(null);\\n };\\n \\n vm.save = function() {\\n vm.editDeviceFormGroup.markAsPristine();\\n if (vm.editDeviceFormGroup.get('deviceType').value !== vm.device.type) {\\n delete vm.device.deviceProfileId;\\n }\\n vm.device.name = vm.editDeviceFormGroup.get('deviceName').value,\\n vm.device.type = vm.editDeviceFormGroup.get('deviceType').value,\\n vm.device.label = vm.editDeviceFormGroup.get('deviceLabel').value\\n deviceService.saveDevice(vm.device).subscribe(\\n function () {\\n saveAttributes().subscribe(\\n function () {\\n widgetContext.updateAliases();\\n vm.dialogRef.close(null);\\n }\\n );\\n }\\n );\\n };\\n \\n getEntityInfo();\\n \\n function getEntityInfo() {\\n deviceService.getDevice(entityId.id).subscribe(\\n function (device) {\\n attributeService.getEntityAttributes(entityId, 'SERVER_SCOPE',\\n ['latitude', 'longitude']).subscribe(\\n function (attributes) {\\n for (let i = 0; i < attributes.length; i++) {\\n vm.attributes[attributes[i].key] = attributes[i].value; \\n }\\n vm.device = device;\\n vm.editDeviceFormGroup.patchValue(\\n {\\n deviceName: vm.device.name,\\n deviceType: vm.device.type,\\n deviceLabel: vm.device.label,\\n attributes: {\\n latitude: vm.attributes.latitude,\\n longitude: vm.attributes.longitude\\n }\\n }, {emitEvent: false}\\n );\\n } \\n );\\n }\\n ); \\n }\\n \\n function saveAttributes() {\\n let attributes = vm.editDeviceFormGroup.get('attributes').value;\\n let attributesArray = [];\\n for (let key in attributes) {\\n attributesArray.push({key: key, value: attributes[key]});\\n }\\n if (attributesArray.length > 0) {\\n return attributeService.saveEntityAttributes(entityId, 'SERVER_SCOPE', attributesArray);\\n } else {\\n return widgetContext.rxjs.of([]);\\n }\\n }\\n}\",\"customResources\":[],\"openInSeparateDialog\":false,\"openInPopover\":false,\"id\":\"93931e52-5d7c-903e-67aa-b9435df44ff4\"},{\"name\":\"Delete device\",\"icon\":\"delete\",\"type\":\"custom\",\"customFunction\":\"let $injector = widgetContext.$scope.$injector;\\nlet dialogs = $injector.get(widgetContext.servicesMap.get('dialogs'));\\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\\n\\nopenDeleteDeviceDialog();\\n\\nfunction openDeleteDeviceDialog() {\\n let title = \\\"Are you sure you want to delete the device \\\" + entityName + \\\"?\\\";\\n let content = \\\"Be careful, after the confirmation, the device and all related data will become unrecoverable!\\\";\\n dialogs.confirm(title, content, 'Cancel', 'Delete').subscribe(\\n function (result) {\\n if (result) {\\n deleteDevice();\\n }\\n }\\n );\\n}\\n\\nfunction deleteDevice() {\\n deviceService.deleteDevice(entityId.id).subscribe(\\n function () {\\n widgetContext.updateAliases();\\n }\\n );\\n}\\n\",\"id\":\"ec2708f6-9ff0-186b-e4fc-7635ebfa3074\"}]},\"configMode\":\"basic\"}"
},
"tags": [
"provisioning",
diff --git a/application/src/main/data/resources/dashboards/gateways_dashboard.json b/application/src/main/data/resources/dashboards/gateways_dashboard.json
index a35d70d006..ed6b20a176 100644
--- a/application/src/main/data/resources/dashboards/gateways_dashboard.json
+++ b/application/src/main/data/resources/dashboards/gateways_dashboard.json
@@ -160,7 +160,7 @@
"useShowWidgetActionFunction": null,
"showWidgetActionFunction": "return true;",
"type": "customPretty",
- "customHtml": "\n
\n {{ 'gateway.launch-command' | translate }}
\n \n \n \n \n
\n
\n \n
\n
\n",
+ "customHtml": "\n
\n {{ 'gateway.launch-command' | translate }}
\n \n \n \n \n
\n
\n \n
\n
\n",
"customCss": ".container {\n display: grid;\n grid-template-rows: min-content minmax(auto, 1fr) min-content;\n height: 100%;\n max-height: 100vh;\n width: 600px;\n max-width: 100%;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\n\nopenCommands();\n\nfunction openCommands() {\n customDialog.customDialog(htmlTemplate, CommandsDialogController, {panelClass: \"test\"}).subscribe();\n}\n\nfunction CommandsDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId.id;\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n}\n",
"customResources": [
@@ -257,7 +257,7 @@
"useShowWidgetActionFunction": null,
"showWidgetActionFunction": "return true;",
"type": "customPretty",
- "customHtml": "\r\n",
+ "customHtml": "\r\n",
"customCss": ".add-entity-form {\r\n min-width: 400px !important;\r\n}\r\n\r\n.add-entity-form .boolean-value-input {\r\n padding-left: 5px;\r\n}\r\n\r\n.add-entity-form .boolean-value-input .checkbox-label {\r\n margin-bottom: 8px;\r\n color: rgba(0,0,0,0.54);\r\n font-size: 12px;\r\n}\r\n\r\n.relations-list .header {\r\n padding-right: 5px;\r\n padding-bottom: 5px;\r\n padding-left: 5px;\r\n}\r\n\r\n.relations-list .header .cell {\r\n padding-right: 5px;\r\n padding-left: 5px;\r\n font-size: 12px;\r\n font-weight: 700;\r\n color: rgba(0, 0, 0, .54);\r\n white-space: nowrap;\r\n}\r\n\r\n.relations-list .mat-form-field-infix {\r\n width: auto !important;\r\n}\r\n\r\n.relations-list .body {\r\n padding-right: 5px;\r\n padding-bottom: 15px;\r\n padding-left: 5px;\r\n}\r\n\r\n.relations-list .body .row {\r\n padding-top: 5px;\r\n}\r\n\r\n.relations-list .body .cell {\r\n padding-right: 5px;\r\n padding-left: 5px;\r\n}\r\n\r\n.relations-list .body .md-button {\r\n margin: 0;\r\n}\r\n\r\n",
"customFunction": "let $injector = widgetContext.$scope.$injector;\r\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\r\nlet assetService = $injector.get(widgetContext.servicesMap.get('assetService'));\r\nlet deviceService = $injector.get(widgetContext.servicesMap.get('deviceService'));\r\nlet attributeService = $injector.get(widgetContext.servicesMap.get('attributeService'));\r\nlet entityRelationService = $injector.get(widgetContext.servicesMap.get('entityRelationService'));\r\nlet userSettingsService = $injector.get(widgetContext.servicesMap.get('userSettingsService'));\r\n\r\nopenAddEntityDialog();\r\n\r\nfunction openAddEntityDialog() {\r\n customDialog.customDialog(htmlTemplate, AddEntityDialogController).subscribe();\r\n}\r\n\r\nfunction AddEntityDialogController(instance) {\r\n let vm = instance;\r\n let userSettings;\r\n userSettingsService.loadUserSettings().subscribe(settings=> {\r\n userSettings = settings;\r\n if (!userSettings.createdGatewaysCount) userSettings.createdGatewaysCount = 0;\r\n });\r\n \r\n\r\n vm.addEntityFormGroup = vm.fb.group({\r\n entityName: ['', [vm.validators.required, vm.validators.pattern(/.*\\S.*/)]],\r\n entityType: ['DEVICE'],\r\n entityLabel: [''],\r\n type: ['', [vm.validators.required]],\r\n });\r\n\r\n vm.cancel = function() {\r\n vm.dialogRef.close(null);\r\n };\r\n\r\n\r\n vm.save = function($event) {\r\n vm.addEntityFormGroup.markAsPristine();\r\n saveEntityObservable().subscribe(\r\n function (device) {\r\n widgetContext.updateAliases();\r\n userSettingsService.putUserSettings({ createdGatewaysCount: ++userSettings.createdGatewaysCount }).subscribe(_=>{\r\n });\r\n vm.dialogRef.close(null);\r\n openCommandDialog(device, $event);\r\n }\r\n );\r\n };\r\n \r\n function openCommandDialog(device, $event) {\r\n vm.device = device;\r\n let openCommandAction = widgetContext.actionsApi.getActionDescriptors(\"actionCellButton\").find(action => action.name == \"Launch command\");\r\n setTimeout(() => {\r\n widgetContext.actionsApi.handleWidgetAction($event, openCommandAction, device.id, device.name, {newDevice: true});\r\n });\r\n goToConfigState();\r\n }\r\n\r\n \r\n function goToConfigState() {\r\n const stateParams = {};\r\n stateParams.entityId = vm.device.id;\r\n stateParams.entityName = vm.device.name;\r\n const newStateParams = {\r\n targetEntityParamName: 'default',\r\n new_gateway: {\r\n entityId: vm.device.id,\r\n entityName: vm.device.name\r\n }\r\n }\r\n const params = {...stateParams, ...newStateParams};\r\n widgetContext.stateController.openState('gateway_details', params, false);\r\n }\r\n\r\n function saveEntityObservable() {\r\n const formValues = vm.addEntityFormGroup.value;\r\n let entity = {\r\n name: formValues.entityName.trim(),\r\n type: formValues.type,\r\n label: formValues.entityLabel,\r\n additionalInfo: {\r\n gateway: true\r\n }\r\n };\r\n return deviceService.saveDevice(entity);\r\n }\r\n}\r\n",
"customResources": [],
@@ -1536,7 +1536,7 @@
"useShowWidgetActionFunction": null,
"showWidgetActionFunction": "return true;",
"type": "customPretty",
- "customHtml": "\n
\n {{ 'gateway.launch-command' | translate }}
\n \n \n \n \n
\n
\n \n
\n
\n",
+ "customHtml": "\n
\n {{ 'gateway.launch-command' | translate }}
\n \n \n \n \n
\n
\n \n
\n
\n",
"customCss": ".container {\n display: grid;\n grid-template-rows: min-content minmax(auto, 1fr) min-content;\n height: 100%;\n max-height: 100vh;\n width: 600px;\n max-width: 100%;\n}",
"customFunction": "let $injector = widgetContext.$scope.$injector;\nlet customDialog = $injector.get(widgetContext.servicesMap.get('customDialog'));\n\nopenCommands();\n\nfunction openCommands() {\n customDialog.customDialog(htmlTemplate, CommandsDialogController, {panelClass: \"test\"}).subscribe();\n}\n\nfunction CommandsDialogController(instance) {\n let vm = instance;\n \n vm.entityId = entityId.id;\n\n vm.cancel = function() {\n vm.dialogRef.close(null);\n };\n}\n",
"customResources": [
diff --git a/application/src/main/java/org/thingsboard/server/controller/SignUpController.java b/application/src/main/java/org/thingsboard/server/controller/SignUpController.java
index a1bdf912bb..aff74dfcd0 100644
--- a/application/src/main/java/org/thingsboard/server/controller/SignUpController.java
+++ b/application/src/main/java/org/thingsboard/server/controller/SignUpController.java
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: BUSL-1.1
package org.thingsboard.server.controller;
-import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.ServiceAccountCredentials;
@@ -117,10 +116,6 @@ public class SignUpController extends BaseController {
private static final String MOBILE_APP_BUNDLE_WAS_NOT_FOUND = "Mobile app bundle was not found";
- private static final String PRIVACY_POLICY_ACCEPTED = "privacyPolicyAccepted";
-
- private static final String TERMS_OF_USE_ACCEPTED = "termsOfUseAccepted";
-
private RestTemplate restTemplate;
@Autowired
@@ -402,8 +397,9 @@ public class SignUpController extends BaseController {
String encodedPassword = userCredentials.getPassword();
UserCredentials credentials = userService.activateUserCredentials(TenantId.SYS_TENANT_ID, emailCode, encodedPassword);
User user = userService.findUserById(TenantId.SYS_TENANT_ID, credentials.getUserId());
- setPrivacyPolicyAccepted(user);
- setTermsOfUseAccepted(user);
+ long acceptedTs = System.currentTimeMillis();
+ user.setPrivacyPolicyAccepted(acceptedTs);
+ user.setTermsOfUseAccepted(acceptedTs);
user = userService.saveUser(tenantId, user);
UserPrincipal principal = new UserPrincipal(UserPrincipal.Type.USER_NAME, user.getEmail());
SecurityUser securityUser = new SecurityUser(user, credentials.isEnabled(), principal, getMergedUserPermissions(user, false));
@@ -428,23 +424,6 @@ public class SignUpController extends BaseController {
return tokenFactory.createTokenPair(securityUser);
}
- private void setPrivacyPolicyAccepted(User user) {
- JsonNode additionalInfo = user.getAdditionalInfo();
- if (!(additionalInfo instanceof ObjectNode)) {
- additionalInfo = JacksonUtil.newObjectNode();
- }
- ((ObjectNode) additionalInfo).put(PRIVACY_POLICY_ACCEPTED, true);
- user.setAdditionalInfo(additionalInfo);
- }
-
- private boolean isPrivacyPolicyAccepted(User user) {
- JsonNode additionalInfo = user.getAdditionalInfo();
- if (additionalInfo != null && additionalInfo.has(PRIVACY_POLICY_ACCEPTED)) {
- return additionalInfo.get(PRIVACY_POLICY_ACCEPTED).asBoolean();
- }
- return false;
- }
-
@ApiOperation(value = "Check privacy policy (privacyPolicyAccepted)",
notes = "Checks that current user accepted the privacy policy.")
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@@ -453,43 +432,23 @@ public class SignUpController extends BaseController {
Boolean privacyPolicyAccepted() throws ThingsboardException {
SecurityUser securityUser = getCurrentUser();
User user = userService.findUserById(securityUser.getTenantId(), securityUser.getId());
- return isPrivacyPolicyAccepted(user);
+ return user.isPrivacyPolicyAccepted();
}
@ApiOperation(value = "Accept privacy policy (acceptPrivacyPolicy)",
- notes = "Accept privacy policy by the current user.")
+ notes = "Accept privacy policy by the current user. " +
+ "Stores the acceptance flag 'privacyPolicyAccepted' and the acceptance time 'privacyPolicyAcceptedTs' (epoch milliseconds) " +
+ "in the user's additional info. Repeated acceptance overwrites the stored time.")
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@PostMapping(value = "/signup/acceptPrivacyPolicy")
- public JsonNode acceptPrivacyPolicy() throws ThingsboardException {
+ public JwtPair acceptPrivacyPolicy() throws ThingsboardException {
SecurityUser securityUser = getCurrentUser();
User user = userService.findUserById(securityUser.getTenantId(), securityUser.getId());
- setPrivacyPolicyAccepted(user);
+ user.setPrivacyPolicyAccepted();
user = userService.saveUser(securityUser.getTenantId(), user);
UserPrincipal principal = new UserPrincipal(UserPrincipal.Type.USER_NAME, user.getEmail());
securityUser = new SecurityUser(user, true, principal, getMergedUserPermissions(user, false));
- JwtPair tokenPair = tokenFactory.createTokenPair(securityUser);
-
- ObjectNode tokenObject = JacksonUtil.newObjectNode();
- tokenObject.put("token", tokenPair.getToken());
- tokenObject.put("refreshToken", tokenPair.getRefreshToken());
- return tokenObject;
- }
-
- private void setTermsOfUseAccepted(User user) {
- JsonNode additionalInfo = user.getAdditionalInfo();
- if (!(additionalInfo instanceof ObjectNode)) {
- additionalInfo = JacksonUtil.newObjectNode();
- }
- ((ObjectNode) additionalInfo).put(TERMS_OF_USE_ACCEPTED, true);
- user.setAdditionalInfo(additionalInfo);
- }
-
- private boolean isTermsOfUseAccepted(User user) {
- JsonNode additionalInfo = user.getAdditionalInfo();
- if (additionalInfo != null && additionalInfo.has(TERMS_OF_USE_ACCEPTED)) {
- return additionalInfo.get(TERMS_OF_USE_ACCEPTED).asBoolean();
- }
- return false;
+ return tokenFactory.createTokenPair(securityUser);
}
@ApiOperation(value = "Check Terms Of User (termsOfUseAccepted)",
@@ -500,26 +459,23 @@ public class SignUpController extends BaseController {
Boolean termsOfUseAccepted() throws ThingsboardException {
SecurityUser securityUser = getCurrentUser();
User user = userService.findUserById(securityUser.getTenantId(), securityUser.getId());
- return isTermsOfUseAccepted(user);
+ return user.isTermsOfUseAccepted();
}
@ApiOperation(value = "Accept Terms of Use (acceptTermsOfUse)",
- notes = "Accept Terms of Use by the current user.")
+ notes = "Accept Terms of Use by the current user. " +
+ "Stores the acceptance flag 'termsOfUseAccepted' and the acceptance time 'termsOfUseAcceptedTs' (epoch milliseconds) " +
+ "in the user's additional info. Repeated acceptance overwrites the stored time.")
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
@PostMapping(value = "/signup/acceptTermsOfUse")
- public JsonNode acceptTermsOfUse() throws ThingsboardException {
+ public JwtPair acceptTermsOfUse() throws ThingsboardException {
SecurityUser securityUser = getCurrentUser();
User user = userService.findUserById(securityUser.getTenantId(), securityUser.getId());
- setTermsOfUseAccepted(user);
+ user.setTermsOfUseAccepted();
user = userService.saveUser(securityUser.getTenantId(), user);
UserPrincipal principal = new UserPrincipal(UserPrincipal.Type.USER_NAME, user.getEmail());
securityUser = new SecurityUser(user, true, principal, getMergedUserPermissions(user, false));
- JwtPair tokenPair = tokenFactory.createTokenPair(securityUser);
-
- ObjectNode tokenObject = JacksonUtil.newObjectNode();
- tokenObject.put("token", tokenPair.getToken());
- tokenObject.put("refreshToken", tokenPair.getRefreshToken());
- return tokenObject;
+ return tokenFactory.createTokenPair(securityUser);
}
private void validateReCaptcha(String userResponse, String ipAddress, String recaptchaSecretKey) throws ThingsboardException {
diff --git a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java
index c74c8be477..06ef375109 100644
--- a/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java
+++ b/application/src/main/java/org/thingsboard/server/service/iot_hub/DefaultIotHubService.java
@@ -11,7 +11,6 @@ import org.springframework.stereotype.Service;
import org.thingsboard.common.util.ExceptionUtil;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.Customer;
-import org.thingsboard.server.common.data.Dashboard;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.asset.AssetProfile;
@@ -35,7 +34,6 @@ import org.thingsboard.server.common.data.id.RuleChainId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.iot_hub.AlarmRuleInstalledItemDescriptor;
import org.thingsboard.server.common.data.iot_hub.CalculatedFieldInstalledItemDescriptor;
-import org.thingsboard.server.common.data.iot_hub.DashboardInstalledItemDescriptor;
import org.thingsboard.server.common.data.iot_hub.DeviceInstalledItemDescriptor;
import org.thingsboard.server.common.data.iot_hub.IotHubInstalledItem;
import org.thingsboard.server.common.data.iot_hub.IotHubInstalledItemDescriptor;
@@ -100,7 +98,6 @@ public class DefaultIotHubService implements IotHubService {
private static final String SECTION_RULE_CHAIN_METADATA = "rule chain metadata";
private static final String ITEM_TYPE_WIDGET = "widget";
- private static final String ITEM_TYPE_DASHBOARD = "dashboard";
private static final String ITEM_TYPE_CALCULATED_FIELD = "calculated field";
private static final String ITEM_TYPE_ALARM_RULE = "alarm rule";
private static final String ITEM_TYPE_RULE_CHAIN = "rule chain";
@@ -183,7 +180,6 @@ public class DefaultIotHubService implements IotHubService {
IotHubInstalledItemDescriptor descriptor = switch (itemType) {
case "WIDGET" -> installWidget(user, tenantId, fileData);
- case "DASHBOARD" -> installDashboard(user, tenantId, fileData, data);
case "CALCULATED_FIELD" -> installCalculatedField(user, tenantId, fileData, data);
case "ALARM_RULE" -> installAlarmRule(user, tenantId, fileData, data);
case "RULE_CHAIN" -> installRuleChain(user, tenantId, fileData, data);
@@ -244,58 +240,6 @@ public class DefaultIotHubService implements IotHubService {
return descriptor;
}
- private DashboardInstalledItemDescriptor installDashboard(SecurityUser user, TenantId tenantId, byte[] fileData, JsonNode data) throws Exception {
- Dashboard dashboard;
- try {
- dashboard = JacksonUtil.fromString(new String(fileData), Dashboard.class, true);
- } catch (Exception e) {
- throw parseFailure(ACTION_INSTALL, ITEM_TYPE_DASHBOARD, e);
- }
- dashboard.setId(null);
- dashboard.setTenantId(tenantId);
-
- if (data != null && data.hasNonNull("customerId") && data.get("customerId").isTextual()) {
- String strCustomerId = data.get("customerId").asText();
- if (!strCustomerId.isEmpty()) {
- CustomerId customerId = new CustomerId(UUID.fromString(strCustomerId));
- Customer customer = customerService.findCustomerById(tenantId, customerId);
- if (customer == null) {
- throw new IllegalArgumentException("Customer with id [" + customerId + "] is not found");
- }
- if (!tenantId.equals(customer.getTenantId())) {
- throw new IllegalArgumentException("Customer [" + customerId + "] does not belong to the current tenant");
- }
- dashboard.setCustomerId(customerId);
- }
- }
-
- List entityGroups = null;
- if (data != null && data.hasNonNull("entityGroupId") && data.get("entityGroupId").isTextual()) {
- String strEntityGroupId = data.get("entityGroupId").asText();
- if (!strEntityGroupId.isEmpty()) {
- EntityGroupId entityGroupId = new EntityGroupId(UUID.fromString(strEntityGroupId));
- EntityGroupInfo entityGroup = checkEntityGroup(user, entityGroupId);
- if (entityGroup.getType() != EntityType.DASHBOARD) {
- throw new IllegalArgumentException("Entity group [" + entityGroupId + "] is not a dashboard group (type: " + entityGroup.getType() + ")");
- }
- entityGroups = List.of(entityGroup);
- // If the entity group is owned by a customer, align the dashboard owner with the group owner
- // (mirrors BaseController.saveGroupEntity logic for new entities).
- if (dashboard.getCustomerId() == null || dashboard.getCustomerId().isNullUid()) {
- if (entityGroup.getOwnerId().getEntityType() == EntityType.CUSTOMER) {
- dashboard.setOwnerId(new CustomerId(entityGroup.getOwnerId().getId()));
- }
- }
- }
- }
-
- Dashboard saved = tbDashboardService.save(dashboard, entityGroups, user);
- log.debug("[{}] Dashboard installed: {}", tenantId, saved.getTitle());
- DashboardInstalledItemDescriptor descriptor = new DashboardInstalledItemDescriptor();
- descriptor.setDashboardId(saved.getId());
- return descriptor;
- }
-
private EntityGroupInfo checkEntityGroup(SecurityUser user, EntityGroupId entityGroupId) throws ThingsboardException {
EntityGroupInfo entityGroup = entityGroupService.findEntityGroupInfoById(user.getTenantId(), entityGroupId);
if (entityGroup == null) {
@@ -466,7 +410,6 @@ public class DefaultIotHubService implements IotHubService {
}
String itemType = installedItem.getItemType();
-
IotHubInstalledItemDescriptor descriptor = installedItem.getDescriptor();
// Skip checksum validation for solution templates
@@ -508,7 +451,6 @@ public class DefaultIotHubService implements IotHubService {
switch (itemType) {
case "WIDGET" -> updateWidget(user, tenantId, (WidgetInstalledItemDescriptor) descriptor, fileData);
- case "DASHBOARD" -> updateDashboard(user, tenantId, (DashboardInstalledItemDescriptor) descriptor, fileData);
case "CALCULATED_FIELD" -> updateCalculatedField(user, tenantId, (CalculatedFieldInstalledItemDescriptor) descriptor, fileData);
case "ALARM_RULE" -> updateAlarmRule(user, tenantId, (AlarmRuleInstalledItemDescriptor) descriptor, fileData);
case "RULE_CHAIN" -> updateRuleChain(tenantId, (RuleChainInstalledItemDescriptor) descriptor, fileData);
@@ -567,22 +509,6 @@ public class DefaultIotHubService implements IotHubService {
tbWidgetTypeService.save(existing, false, user);
}
- private void updateDashboard(SecurityUser user, TenantId tenantId, DashboardInstalledItemDescriptor descriptor, byte[] fileData) throws Exception {
- Dashboard newDashboard;
- try {
- newDashboard = JacksonUtil.fromString(new String(fileData), Dashboard.class, true);
- } catch (Exception e) {
- throw parseFailure(ACTION_UPDATE, ITEM_TYPE_DASHBOARD, e);
- }
- Dashboard existing = dashboardService.findDashboardById(tenantId, descriptor.getDashboardId());
- if (existing == null) {
- throw new Exception("Dashboard not found for update");
- }
- existing.setTitle(newDashboard.getTitle());
- existing.setConfiguration(newDashboard.getConfiguration());
- tbDashboardService.save(existing, (List) null, user);
- }
-
private void updateCalculatedField(SecurityUser user, TenantId tenantId, CalculatedFieldInstalledItemDescriptor descriptor, byte[] fileData) throws Exception {
CalculatedField newCf;
try {
@@ -649,8 +575,6 @@ public class DefaultIotHubService implements IotHubService {
IotHubInstalledItemDescriptor descriptor = installedItem.getDescriptor();
if (descriptor instanceof WidgetInstalledItemDescriptor wd) {
return calculateWidgetChecksum(tenantId, wd);
- } else if (descriptor instanceof DashboardInstalledItemDescriptor dd) {
- return calculateDashboardChecksum(tenantId, dd);
} else if (descriptor instanceof CalculatedFieldInstalledItemDescriptor cd) {
return calculateCalculatedFieldChecksum(tenantId, cd.getCalculatedFieldId());
} else if (descriptor instanceof AlarmRuleInstalledItemDescriptor ad) {
@@ -672,16 +596,6 @@ public class DefaultIotHubService implements IotHubService {
return sha256(content);
}
- private String calculateDashboardChecksum(TenantId tenantId, DashboardInstalledItemDescriptor descriptor) {
- Dashboard dashboard = dashboardService.findDashboardById(tenantId, descriptor.getDashboardId());
- if (dashboard == null) {
- return null;
- }
- String content = (dashboard.getTitle() != null ? dashboard.getTitle() : "") +
- (dashboard.getConfiguration() != null ? dashboard.getConfiguration().toString() : "");
- return sha256(content);
- }
-
private String calculateWidgetChecksum(TenantId tenantId, WidgetInstalledItemDescriptor descriptor) {
WidgetTypeDetails widgetType = widgetTypeService.findWidgetTypeDetailsById(tenantId, descriptor.getWidgetTypeId());
if (widgetType == null) {
@@ -865,11 +779,6 @@ public class DefaultIotHubService implements IotHubService {
if (widgetType != null) {
tbWidgetTypeService.delete(widgetType, user);
}
- } else if (descriptor instanceof DashboardInstalledItemDescriptor dd) {
- Dashboard dashboard = dashboardService.findDashboardById(tenantId, dd.getDashboardId());
- if (dashboard != null) {
- tbDashboardService.delete(dashboard, user);
- }
} else if (descriptor instanceof CalculatedFieldInstalledItemDescriptor cd) {
CalculatedField calculatedField = calculatedFieldService.findById(tenantId, cd.getCalculatedFieldId());
if (calculatedField != null) {
diff --git a/application/src/test/java/org/thingsboard/server/controller/SignUpControllerSqlTest.java b/application/src/test/java/org/thingsboard/server/controller/SignUpControllerSqlTest.java
index 143326d394..02b37c92ba 100644
--- a/application/src/test/java/org/thingsboard/server/controller/SignUpControllerSqlTest.java
+++ b/application/src/test/java/org/thingsboard/server/controller/SignUpControllerSqlTest.java
@@ -14,6 +14,7 @@ import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.CustomerInfo;
import org.thingsboard.server.common.data.Dashboard;
+import org.thingsboard.server.common.data.DataConstants;
import org.thingsboard.server.common.data.EntityInfo;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.StringUtils;
@@ -35,11 +36,11 @@ import org.thingsboard.server.common.data.oauth2.PlatformType;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.selfregistration.DefaultDashboardParams;
import org.thingsboard.server.common.data.selfregistration.HomeDashboardParams;
-import org.thingsboard.server.common.data.selfregistration.V2CaptchaParams;
import org.thingsboard.server.common.data.selfregistration.MobileRedirectParams;
import org.thingsboard.server.common.data.selfregistration.MobileSelfRegistrationParams;
import org.thingsboard.server.common.data.selfregistration.SignUpField;
import org.thingsboard.server.common.data.selfregistration.SignUpFieldId;
+import org.thingsboard.server.common.data.selfregistration.V2CaptchaParams;
import org.thingsboard.server.common.data.selfregistration.WebSelfRegistrationParams;
import org.thingsboard.server.common.data.signup.SignUpRequest;
import org.thingsboard.server.common.data.signup.SignUpResult;
@@ -200,6 +201,38 @@ public class SignUpControllerSqlTest extends AbstractControllerTest {
removeCreatedUser(user);
}
+ @Test
+ public void testActivationByEmailCodeStoresPolicyAcceptanceTimestamps() throws Exception {
+ createWebSelfRegistrationSettings();
+ doSignUp(createWebSignUpRequest(CUSTOMER_TEST_EMAIL));
+ User user = userService.findUserByEmail(tenantId, CUSTOMER_TEST_EMAIL);
+ String activateToken = userService.findUserCredentialsByUserId(tenantId, user.getId()).getActivateToken();
+
+ doPost("/api/noauth/activateByEmailCode", JsonNode.class, "emailCode", activateToken);
+
+ User activatedUser = userService.findUserById(tenantId, user.getId());
+ assertPrivacyPolicyAccepted(activatedUser);
+ assertTermsOfUseAccepted(activatedUser);
+
+ removeCreatedUser(activatedUser);
+ }
+
+ @Test
+ public void testAcceptPrivacyPolicyStoresAcceptanceTimestamp() {
+ doPost("/api/signup/acceptPrivacyPolicy", JsonNode.class);
+
+ User user = userService.findUserById(tenantId, tenantAdminUserId);
+ assertPrivacyPolicyAccepted(user);
+ }
+
+ @Test
+ public void testAcceptTermsOfUseStoresAcceptanceTimestamp() {
+ doPost("/api/signup/acceptTermsOfUse", JsonNode.class);
+
+ User user = userService.findUserById(tenantId, tenantAdminUserId);
+ assertTermsOfUseAccepted(user);
+ }
+
@Test
public void testSelfRegistrationCreateMessageInRuleChain() throws Exception {
createWebSelfRegistrationSettings();
@@ -263,6 +296,22 @@ public class SignUpControllerSqlTest extends AbstractControllerTest {
return signUpRequest;
}
+ private void assertPrivacyPolicyAccepted(User user) {
+ assertThat(user.isPrivacyPolicyAccepted()).isTrue();
+ assertAcceptedTsIsPositive(user, DataConstants.PRIVACY_POLICY_ACCEPTED_TS);
+ }
+
+ private void assertTermsOfUseAccepted(User user) {
+ assertThat(user.isTermsOfUseAccepted()).isTrue();
+ assertAcceptedTsIsPositive(user, DataConstants.TERMS_OF_USE_ACCEPTED_TS);
+ }
+
+ private void assertAcceptedTsIsPositive(User user, String acceptedTsKey) {
+ JsonNode acceptedTs = user.getAdditionalInfo().path(acceptedTsKey);
+ assertThat(acceptedTs.isNumber()).isTrue();
+ assertThat(acceptedTs.asLong()).isPositive();
+ }
+
protected SignUpRequest createMobileSignUpRequest(String email, String pkgName, String appSecret, PlatformType platformType) {
var signUpRequest = new SignUpRequest();
signUpRequest.setFields(Map.of(SignUpFieldId.EMAIL, email,
diff --git a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java
index cb9221db18..2f1a0ada5b 100644
--- a/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java
+++ b/application/src/test/java/org/thingsboard/server/service/iot_hub/DefaultIotHubServiceTest.java
@@ -15,8 +15,8 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.thingsboard.common.util.JacksonUtil;
import org.thingsboard.server.common.data.id.IotHubInstalledItemId;
import org.thingsboard.server.common.data.id.TenantId;
-import org.thingsboard.server.common.data.iot_hub.DashboardInstalledItemDescriptor;
import org.thingsboard.server.common.data.iot_hub.IotHubInstalledItem;
+import org.thingsboard.server.common.data.iot_hub.RuleChainInstalledItemDescriptor;
import org.thingsboard.server.dao.iot_hub.IotHubInstalledItemService;
import org.thingsboard.server.service.security.model.SecurityUser;
@@ -89,7 +89,7 @@ class DefaultIotHubServiceTest {
mockTenant();
String versionId = UUID.randomUUID().toString();
String itemId = UUID.randomUUID().toString();
- when(iotHubRestClient.getVersionInfo(versionId)).thenReturn(version(versionId, itemId, "DASHBOARD", "Root", "1.0"));
+ when(iotHubRestClient.getVersionInfo(versionId)).thenReturn(version(versionId, itemId, "RULE_CHAIN", "Root", "1.0"));
when(iotHubInstalledItemService.findInstalledItemIdsByTenantIdAndItemIdIn(eq(tenantId), any())).thenReturn(List.of());
InstallPlan plan = service.resolveInstallPlan(user, versionId);
@@ -107,7 +107,7 @@ class DefaultIotHubServiceTest {
String versionId = UUID.randomUUID().toString();
String rootItemId = UUID.randomUUID().toString();
String relatedItemId = UUID.randomUUID().toString();
- ObjectNode root = version(versionId, rootItemId, "DASHBOARD", "Root", "1.0");
+ ObjectNode root = version(versionId, rootItemId, "RULE_CHAIN", "Root", "1.0");
root.putArray("relatedItems").add(relatedItemId);
when(iotHubRestClient.getVersionInfo(versionId)).thenReturn(root);
when(iotHubRestClient.getPublishedVersionByItemId(relatedItemId))
@@ -129,7 +129,7 @@ class DefaultIotHubServiceTest {
String versionId = UUID.randomUUID().toString();
String rootItemId = UUID.randomUUID().toString();
String relatedItemId = UUID.randomUUID().toString();
- ObjectNode root = version(versionId, rootItemId, "DASHBOARD", "Root", "1.0");
+ ObjectNode root = version(versionId, rootItemId, "RULE_CHAIN", "Root", "1.0");
root.putArray("relatedItems").add(relatedItemId);
when(iotHubRestClient.getVersionInfo(versionId)).thenReturn(root);
when(iotHubRestClient.getPublishedVersionByItemId(relatedItemId)).thenReturn(null);
@@ -149,7 +149,7 @@ class DefaultIotHubServiceTest {
String versionId = UUID.randomUUID().toString();
String rootItemId = UUID.randomUUID().toString();
String relatedItemId = UUID.randomUUID().toString();
- ObjectNode root = version(versionId, rootItemId, "DASHBOARD", "Root", "1.0");
+ ObjectNode root = version(versionId, rootItemId, "RULE_CHAIN", "Root", "1.0");
root.putArray("relatedItems").add(relatedItemId);
when(iotHubRestClient.getVersionInfo(versionId)).thenReturn(root);
when(iotHubRestClient.getPublishedVersionByItemId(relatedItemId)).thenThrow(new RuntimeException("boom"));
@@ -280,7 +280,7 @@ class DefaultIotHubServiceTest {
when(iotHubInstalledItemService.findInstalledItemIdsByTenantIdAndItemIdIn(eq(tenantId), any())).thenReturn(List.of());
IotHubInstalledItem depItem = installedItem(UUID.randomUUID());
IotHubInstalledItem rootItem = installedItem(UUID.randomUUID());
- DashboardInstalledItemDescriptor rootDescriptor = new DashboardInstalledItemDescriptor();
+ RuleChainInstalledItemDescriptor rootDescriptor = new RuleChainInstalledItemDescriptor();
rootItem.setDescriptor(rootDescriptor);
doReturn(depItem).when(service).doInstallVersion(eq(user), eq(depVersionId), any(), any());
doReturn(rootItem).when(service).doInstallVersion(eq(user), eq(rootVersionId), any(), any());
diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java b/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java
index 625f1fc514..9d20a0e5e8 100644
--- a/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java
+++ b/common/data/src/main/java/org/thingsboard/server/common/data/DataConstants.java
@@ -160,6 +160,11 @@ public class DataConstants {
public static final String CF_QUEUE_NAME = "CalculatedFields";
public static final String CF_STATES_QUEUE_NAME = "CalculatedFieldStates";
+ public static final String PRIVACY_POLICY_ACCEPTED = "privacyPolicyAccepted";
+ public static final String PRIVACY_POLICY_ACCEPTED_TS = "privacyPolicyAcceptedTs";
+ public static final String TERMS_OF_USE_ACCEPTED = "termsOfUseAccepted";
+ public static final String TERMS_OF_USE_ACCEPTED_TS = "termsOfUseAcceptedTs";
+
public static final String LATEST_TELEMETRY_SCOPE = "LATEST_TELEMETRY";
}
diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/User.java b/common/data/src/main/java/org/thingsboard/server/common/data/User.java
index c8f3683736..17797a912a 100644
--- a/common/data/src/main/java/org/thingsboard/server/common/data/User.java
+++ b/common/data/src/main/java/org/thingsboard/server/common/data/User.java
@@ -6,6 +6,8 @@ package org.thingsboard.server.common.data;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.BooleanNode;
+import com.fasterxml.jackson.databind.node.LongNode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -251,6 +253,34 @@ public class User extends BaseDataWithAdditionalInfo implements GroupEnt
return !isSystemAdmin() && !isTenantAdmin();
}
+ @JsonIgnore
+ public boolean isPrivacyPolicyAccepted() {
+ return getAdditionalInfoField(DataConstants.PRIVACY_POLICY_ACCEPTED, JsonNode::asBoolean, false);
+ }
+
+ public void setPrivacyPolicyAccepted() {
+ setPrivacyPolicyAccepted(System.currentTimeMillis());
+ }
+
+ public void setPrivacyPolicyAccepted(long acceptedTs) {
+ setAdditionalInfoField(DataConstants.PRIVACY_POLICY_ACCEPTED, BooleanNode.TRUE);
+ setAdditionalInfoField(DataConstants.PRIVACY_POLICY_ACCEPTED_TS, LongNode.valueOf(acceptedTs));
+ }
+
+ @JsonIgnore
+ public boolean isTermsOfUseAccepted() {
+ return getAdditionalInfoField(DataConstants.TERMS_OF_USE_ACCEPTED, JsonNode::asBoolean, false);
+ }
+
+ public void setTermsOfUseAccepted() {
+ setTermsOfUseAccepted(System.currentTimeMillis());
+ }
+
+ public void setTermsOfUseAccepted(long acceptedTs) {
+ setAdditionalInfoField(DataConstants.TERMS_OF_USE_ACCEPTED, BooleanNode.TRUE);
+ setAdditionalInfoField(DataConstants.TERMS_OF_USE_ACCEPTED_TS, LongNode.valueOf(acceptedTs));
+ }
+
@JsonIgnore
public String getLocale() {
return getAdditionalInfoField("lang", JsonNode::asText, Locale.US.toString());
diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/iot_hub/DashboardInstalledItemDescriptor.java b/common/data/src/main/java/org/thingsboard/server/common/data/iot_hub/DashboardInstalledItemDescriptor.java
deleted file mode 100644
index e39e6d7be8..0000000000
--- a/common/data/src/main/java/org/thingsboard/server/common/data/iot_hub/DashboardInstalledItemDescriptor.java
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
-// SPDX-License-Identifier: Apache-2.0
-package org.thingsboard.server.common.data.iot_hub;
-
-import lombok.Data;
-import org.thingsboard.server.common.data.id.DashboardId;
-
-@Data
-public class DashboardInstalledItemDescriptor implements IotHubInstalledItemDescriptor {
-
- private DashboardId dashboardId;
-
-}
diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/iot_hub/IotHubInstalledItemDescriptor.java b/common/data/src/main/java/org/thingsboard/server/common/data/iot_hub/IotHubInstalledItemDescriptor.java
index e35cadaea6..675dbe4601 100644
--- a/common/data/src/main/java/org/thingsboard/server/common/data/iot_hub/IotHubInstalledItemDescriptor.java
+++ b/common/data/src/main/java/org/thingsboard/server/common/data/iot_hub/IotHubInstalledItemDescriptor.java
@@ -15,7 +15,6 @@ import java.io.Serializable;
property = "type")
@JsonSubTypes({
@Type(name = "WIDGET", value = WidgetInstalledItemDescriptor.class),
- @Type(name = "DASHBOARD", value = DashboardInstalledItemDescriptor.class),
@Type(name = "CALCULATED_FIELD", value = CalculatedFieldInstalledItemDescriptor.class),
@Type(name = "ALARM_RULE", value = AlarmRuleInstalledItemDescriptor.class),
@Type(name = "RULE_CHAIN", value = RuleChainInstalledItemDescriptor.class),
diff --git a/common/data/src/test/java/org/thingsboard/server/common/data/UserTest.java b/common/data/src/test/java/org/thingsboard/server/common/data/UserTest.java
new file mode 100644
index 0000000000..3220ba22a6
--- /dev/null
+++ b/common/data/src/test/java/org/thingsboard/server/common/data/UserTest.java
@@ -0,0 +1,188 @@
+// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
+// SPDX-License-Identifier: BUSL-1.1
+package org.thingsboard.server.common.data;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.node.TextNode;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+
+import java.util.function.Consumer;
+import java.util.function.ObjLongConsumer;
+import java.util.function.Predicate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+class UserTest {
+
+ private static final long TS = 1_700_000_000_000L;
+
+ @Getter
+ @RequiredArgsConstructor
+ enum PolicyDocument {
+
+ PRIVACY_POLICY(DataConstants.PRIVACY_POLICY_ACCEPTED, DataConstants.PRIVACY_POLICY_ACCEPTED_TS,
+ User::setPrivacyPolicyAccepted, User::setPrivacyPolicyAccepted, User::isPrivacyPolicyAccepted),
+ TERMS_OF_USE(DataConstants.TERMS_OF_USE_ACCEPTED, DataConstants.TERMS_OF_USE_ACCEPTED_TS,
+ User::setTermsOfUseAccepted, User::setTermsOfUseAccepted, User::isTermsOfUseAccepted);
+
+ private final String acceptedKey;
+ private final String acceptedTsKey;
+ private final Consumer accept;
+ private final ObjLongConsumer acceptAt;
+ private final Predicate accepted;
+
+ PolicyDocument other() {
+ return this == PRIVACY_POLICY ? TERMS_OF_USE : PRIVACY_POLICY;
+ }
+
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldCreateAdditionalInfo_whenAdditionalInfoIsNull(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+
+ // WHEN
+ document.getAcceptAt().accept(user, TS);
+
+ // THEN
+ assertAcceptedAt(user, document, TS);
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldReplaceAdditionalInfo_whenAdditionalInfoIsNotObject(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+ user.setAdditionalInfo(TextNode.valueOf("not an object"));
+
+ // WHEN
+ document.getAcceptAt().accept(user, TS);
+
+ // THEN
+ assertAcceptedAt(user, document, TS);
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldPreserveExistingFields_whenAdditionalInfoIsObject(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+ ObjectNode additionalInfo = JsonNodeFactory.instance.objectNode();
+ additionalInfo.put("lang", "en_US");
+ user.setAdditionalInfo(additionalInfo);
+
+ // WHEN
+ document.getAcceptAt().accept(user, TS);
+
+ // THEN
+ assertAcceptedAt(user, document, TS);
+ assertThat(user.getAdditionalInfo().get("lang").asText()).isEqualTo("en_US");
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldOverwriteTimestamp_whenAcceptedAgain(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+ document.getAcceptAt().accept(user, TS);
+
+ // WHEN
+ document.getAcceptAt().accept(user, TS + 1);
+
+ // THEN
+ assertAcceptedAt(user, document, TS + 1);
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldNotTouchOtherDocument(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+
+ // WHEN
+ document.getAcceptAt().accept(user, TS);
+
+ // THEN
+ PolicyDocument other = document.other();
+ assertThat(user.getAdditionalInfo().has(other.getAcceptedKey())).isFalse();
+ assertThat(user.getAdditionalInfo().has(other.getAcceptedTsKey())).isFalse();
+ assertThat(other.getAccepted().test(user)).isFalse();
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldStampCurrentTime_whenAcceptedWithoutTimestamp(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+ long before = System.currentTimeMillis();
+
+ // WHEN
+ document.getAccept().accept(user);
+
+ // THEN
+ long after = System.currentTimeMillis();
+ assertThat(document.getAccepted().test(user)).isTrue();
+ assertThat(user.getAdditionalInfo().get(document.getAcceptedTsKey()).asLong()).isBetween(before, after);
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldReportAccepted_whenMarked(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+ document.getAcceptAt().accept(user, TS);
+
+ // WHEN-THEN
+ assertThat(document.getAccepted().test(user)).isTrue();
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldReportNotAccepted_whenAdditionalInfoIsNull(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+
+ // WHEN-THEN
+ assertThat(document.getAccepted().test(user)).isFalse();
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldReportNotAccepted_whenFlagIsAbsent(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+ user.setAdditionalInfo(JsonNodeFactory.instance.objectNode());
+
+ // WHEN-THEN
+ assertThat(document.getAccepted().test(user)).isFalse();
+ }
+
+ @ParameterizedTest
+ @EnumSource(PolicyDocument.class)
+ void shouldReportNotAccepted_whenFlagIsFalse(PolicyDocument document) {
+ // GIVEN
+ User user = new User();
+ ObjectNode additionalInfo = JsonNodeFactory.instance.objectNode();
+ additionalInfo.put(document.getAcceptedKey(), false);
+ user.setAdditionalInfo(additionalInfo);
+
+ // WHEN-THEN
+ assertThat(document.getAccepted().test(user)).isFalse();
+ }
+
+ private static void assertAcceptedAt(User user, PolicyDocument document, long expectedTs) {
+ JsonNode additionalInfo = user.getAdditionalInfo();
+ assertThat(additionalInfo).isInstanceOf(ObjectNode.class);
+ assertThat(additionalInfo.get(document.getAcceptedKey()).asBoolean()).isTrue();
+ assertThat(additionalInfo.get(document.getAcceptedTsKey()).asLong()).isEqualTo(expectedTs);
+ assertThat(document.getAccepted().test(user)).isTrue();
+ }
+
+}
diff --git a/common/edge-api/src/main/proto/edge.proto b/common/edge-api/src/main/proto/edge.proto
index b6fbc6a82e..0c17d43e5f 100644
--- a/common/edge-api/src/main/proto/edge.proto
+++ b/common/edge-api/src/main/proto/edge.proto
@@ -41,6 +41,7 @@ enum EdgeVersion {
V_4_2_2_4 = 4224;
V_4_2_2_5 = 4225;
V_4_2_2_6 = 4226;
+ V_4_2_2_7 = 4227;
V_4_3_0_1 = 15;
V_4_3_1 = 4310;
V_4_3_1_1 = 4311;
@@ -49,7 +50,9 @@ enum EdgeVersion {
V_4_3_1_4 = 4314;
V_4_3_1_5 = 4315;
V_4_3_1_6 = 4316;
+ V_4_3_1_7 = 4317;
V_4_4_0 = 4400;
+ V_4_4_0_1 = 4401;
V_LATEST = 99999;
}
diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml
index 9cbbacbb5f..82d4ca6810 100644
--- a/msa/black-box-tests/pom.xml
+++ b/msa/black-box-tests/pom.xml
@@ -128,10 +128,6 @@
awaitility
test
-
- org.eclipse.californium
- californium-core
-
ch.qos.logback
logback-classic
diff --git a/ui-ngx/src/app/core/http/iot-hub-api.service.ts b/ui-ngx/src/app/core/http/iot-hub-api.service.ts
index 99f5d5b716..439976d6c5 100644
--- a/ui-ngx/src/app/core/http/iot-hub-api.service.ts
+++ b/ui-ngx/src/app/core/http/iot-hub-api.service.ts
@@ -7,7 +7,11 @@ import { Store } from '@ngrx/store';
import { Observable } from 'rxjs';
import { PageData } from '@shared/models/page/page-data';
import { PageLink } from '@shared/models/page/page-link';
-import { MpItemVersionQuery, MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models';
+import {
+ MpItemVersionQuery,
+ MpItemVersionQueryOptions,
+ MpItemVersionView
+} from '@shared/models/iot-hub/iot-hub-version.models';
import { CreatorView } from '@shared/models/iot-hub/iot-hub-creator.models';
import { IotHubInstalledItem, InstallItemVersionResult, InstallPlan, InstallPlanResult, UpdateItemVersionResult, ItemPublishedVersionInfo } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { ItemType, ItemTypeFilterInfo, WidgetCategory } from '@shared/models/iot-hub/iot-hub-item.models';
@@ -70,36 +74,47 @@ export class IotHubApiService {
}
public getPublishedVersions(query: MpItemVersionQuery, config?: IotHubRequestConfig): Observable> {
- if (query.options.tbVersion == null) {
- query.options.tbVersion = tbVersionToInt(env.tbVersion);
- }
- if (query.options.ceOnly == null) {
- query.options.ceOnly = false;
- }
+ this.applyPlatformFilters(query.options);
return this.http.get>(
`${this.baseUrl}/api/versions/published${query.toQuery()}`,
{ params: this.buildParams(config) }
);
}
+ /** What this platform can install: items of every edition, nothing built for a newer ThingsBoard. */
+ private platformScope(): { ceOnly: boolean; tbVersion: number } {
+ return { ceOnly: false, tbVersion: tbVersionToInt(env.tbVersion) };
+ }
+
+ /** Fills in the platform scope wherever the caller did not set it. */
+ private applyPlatformFilters(options: MpItemVersionQueryOptions): void {
+ const scope = this.platformScope();
+ options.tbVersion ??= scope.tbVersion;
+ options.ceOnly ??= scope.ceOnly;
+ }
+
+ private platformScopeParams(): string[] {
+ const scope = this.platformScope();
+ return [`ceOnly=${scope.ceOnly}`, `tbVersion=${scope.tbVersion}`];
+ }
+
public getFilterInfo(itemType: ItemType, config?: IotHubRequestConfig): Observable {
- const url = `${this.baseUrl}/api/item-listing/filterInfo/${itemType}`
- + `?ceOnly=false&tbVersion=${tbVersionToInt(env.tbVersion)}`;
+ const url = `${this.baseUrl}/api/item-listing/filterInfo/${itemType}?${this.platformScopeParams().join('&')}`;
return this.http.get(url, { params: this.buildParams(config) });
}
- public getWidgetCategories(textSearch?: string, scadaFirst?: boolean,
+ public getWidgetCategories(textSearch?: string, scadaFirst?: boolean, creatorVerified?: boolean,
config?: IotHubRequestConfig): Observable {
- const queryParams: string[] = [
- `ceOnly=false`,
- `tbVersion=${tbVersionToInt(env.tbVersion)}`
- ];
+ const queryParams: string[] = this.platformScopeParams();
if (textSearch?.trim()) {
queryParams.push(`textSearch=${encodeURIComponent(textSearch.trim())}`);
}
if (scadaFirst != null) {
queryParams.push(`scadaFirst=${scadaFirst}`);
}
+ if (creatorVerified) {
+ queryParams.push(`creatorVerified=true`);
+ }
const url = `${this.baseUrl}/api/item-listing/widgetCategories?${queryParams.join('&')}`;
return this.http.get(url, { params: this.buildParams(config) });
}
@@ -133,7 +148,7 @@ export class IotHubApiService {
public getListingItemVersion(slug: string, config?: IotHubRequestConfig): Observable {
const queryParams = [
'ce=false',
- `tbVersion=${tbVersionToInt(env.tbVersion)}`
+ `tbVersion=${this.platformScope().tbVersion}`
];
return this.http.get(
`${this.baseUrl}/api/listings/public/by-slug/${encodeURIComponent(slug)}/item-version?${queryParams.join('&')}`,
diff --git a/ui-ngx/src/app/core/http/white-labeling.service.ts b/ui-ngx/src/app/core/http/white-labeling.service.ts
index 8441a3356e..456d7dfe35 100644
--- a/ui-ngx/src/app/core/http/white-labeling.service.ts
+++ b/ui-ngx/src/app/core/http/white-labeling.service.ts
@@ -210,7 +210,7 @@ export class WhiteLabelingService {
}
public isPrimaryColorPanels(): boolean {
- return this.getCurrentWlParams() ? this.getCurrentWlParams().primaryColorPanels : false;
+ return !!this.getCurrentWlParams()?.primaryColorPanels;
}
public isPrimaryColorPanels$(): Observable {
diff --git a/ui-ngx/src/app/core/services/resources.service.ts b/ui-ngx/src/app/core/services/resources.service.ts
index 46c020ca30..a8c34534d1 100644
--- a/ui-ngx/src/app/core/services/resources.service.ts
+++ b/ui-ngx/src/app/core/services/resources.service.ts
@@ -17,7 +17,7 @@ import {
DOCUMENT
} from '@angular/core';
-import { forkJoin, from, Observable, ReplaySubject, throwError } from 'rxjs';
+import { forkJoin, from, Observable, of, ReplaySubject, throwError } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { IModulesMap } from '@modules/common/modules-map.models';
import { TbResourceId } from '@shared/models/id/tb-resource-id';
@@ -26,7 +26,7 @@ import { AuthService } from '@core/auth/auth.service';
import { select, Store } from '@ngrx/store';
import { selectIsAuthenticated } from '@core/auth/auth.selectors';
import { AppState } from '@core/core.state';
-import { map, tap } from 'rxjs/operators';
+import { catchError, map, switchMap, tap } from 'rxjs/operators';
import { RequestConfig } from '@core/http/http-utils';
import { isJSResource, removeTbResourcePrefix } from '@shared/models/resource.models';
@@ -96,6 +96,22 @@ const resourceFileType = (url: string, baseUrl: string): string => {
return /^(css|js)\d*$/.exec(segment)?.[1];
};
+// The file type of a resource served under a URL that does not tell it, as Google Fonts' /icon, from the Content-Type
+// of a HEAD response. Works only for same-origin URLs and servers that allow cross-origin requests.
+const resourceFileTypeFromContentType = (url: string): Observable =>
+ from(fetch(url, {method: 'HEAD'})).pipe(
+ map(response => {
+ const mimeType = response.headers.get('content-type')?.split(';')[0].trim().toLowerCase();
+ if (mimeType === 'text/css') {
+ return 'css';
+ } else if (/^(text|application)\/(x-)?(javascript|ecmascript)$/.test(mimeType)) {
+ return 'js';
+ }
+ return undefined;
+ }),
+ catchError(() => of(undefined))
+ );
+
const matchesSelector = (selectors: ɵCssSelectorList, selector: string) =>
selectors.some(s => s.some(s1 => typeof s1 === 'string' && s1 === selector));
@@ -160,12 +176,17 @@ export class ResourcesService {
}
const fileType = resourceFileType(url, this.document.baseURI);
- if (!fileType) {
- return throwError(() => new Error(`Unable to detect file type from url: ${url}`));
- } else if (fileType !== 'css' && fileType !== 'js') {
- return throwError(() => new Error(`Unsupported file type: ${fileType}`));
- }
- return this.loadResourceByType(fileType, url);
+ const fileType$ = fileType ? of(fileType) : resourceFileTypeFromContentType(url);
+ return fileType$.pipe(
+ switchMap(type => {
+ if (!type) {
+ return throwError(() => new Error(`Unable to detect file type from url: ${url}`));
+ } else if (type !== 'css' && type !== 'js') {
+ return throwError(() => new Error(`Unsupported file type: ${type}`));
+ }
+ return this.loadedResources[url] ? this.loadedResources[url].asObservable() : this.loadResourceByType(type, url);
+ })
+ );
}
public downloadResource(downloadUrl: string, config?: RequestConfig): Observable {
diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html
index b069ec3134..c8ffe55c78 100644
--- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html
+++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.html
@@ -85,12 +85,12 @@
}
@if (selectWidgetMode === 'iotHub' && iotHubSubMode !== 'default') {
- @for (option of iotHubSortOptions; track option.value; let i = $index) {
-
+ @for (option of iotHubSortOptions; track option.value) {
+
}
}
@@ -462,120 +462,129 @@
}
} @else {
-
-
-
- {{ 'iot-hub.type' | translate }}
- @if (iotHubAppliedWidgetTypes.size) {
- {{ iotHubAppliedWidgetTypes.size }}
- }
-
-
- @if (iotHubWidgetTypeOptions.length >= 10) {
-
- search
-
- @if (iotHubFilterSearch['widgetType']) {
-
- }
-
- }
- 8"
- (mouseenter)="getFilteredIotHubItems(iotHubWidgetTypeOptions, 'widgetType').length > 8 && (iotHubFilterItemsHovered = true)"
- (mouseleave)="iotHubFilterItemsHovered = false">
- @for (opt of getFilteredIotHubItems(iotHubWidgetTypeOptions, 'widgetType'); track opt.key) {
-
-
- {{ getIotHubWidgetTypeLabel(opt.key) }}
-
-
- }
-
-
- @if (!hideCategoriesFilterSection) {
+
+
+ {{ 'iot-hub.verified-creators-only' | translate }}
+
+
+ @if (iotHubSubMode !== 'default') {
-
+
- {{ 'iot-hub.category' | translate }}
- @if (iotHubAppliedCategories.size) {
- {{ iotHubAppliedCategories.size }}
+ {{ 'iot-hub.type' | translate }}
+ @if (iotHubAppliedWidgetTypes.size) {
+ {{ iotHubAppliedWidgetTypes.size }}
}
- @if (iotHubCategoryOptions.length >= 10) {
+ @if (iotHubWidgetTypeOptions.length >= 10) {
search
- @if (iotHubFilterSearch['category']) {
-
}
- 8"
- (mouseenter)="getFilteredIotHubItems(iotHubCategoryOptions, 'category').length > 8 && (iotHubFilterItemsHovered = true)"
+
8"
+ (mouseenter)="getFilteredIotHubItems(iotHubWidgetTypeOptions, 'widgetType').length > 8 && (iotHubFilterItemsHovered = true)"
(mouseleave)="iotHubFilterItemsHovered = false">
- @for (opt of getFilteredIotHubItems(iotHubCategoryOptions, 'category'); track opt.key) {
+ @for (opt of getFilteredIotHubItems(iotHubWidgetTypeOptions, 'widgetType'); track opt.key) {
-
- {{ opt.key }}
+
+ {{ getIotHubWidgetTypeLabel(opt.key) }}
}
- }
-
-
-
-
- {{ 'iot-hub.use-case' | translate }}
- @if (iotHubAppliedUseCases.size) {
- {{ iotHubAppliedUseCases.size }}
- }
-
-
- @if (iotHubUseCaseOptions.length >= 10) {
-
- search
-
- @if (iotHubFilterSearch['useCase']) {
-
- close
-
- }
-
- }
- 8"
- (mouseenter)="getFilteredIotHubItems(iotHubUseCaseOptions, 'useCase').length > 8 && (iotHubFilterItemsHovered = true)"
- (mouseleave)="iotHubFilterItemsHovered = false">
- @for (group of getGroupedIotHubFilterItems(iotHubUseCaseOptions, 'useCase'); track group.label) {
- @if (group.label) {
-
{{ group.label | translate }}
- }
- @for (opt of group.items; track opt.key) {
-
-
- {{ opt.key }}
-
+ @if (!hideCategoriesFilterSection) {
+
+
+
+
+ {{ 'iot-hub.category' | translate }}
+ @if (iotHubAppliedCategories.size) {
+ {{ iotHubAppliedCategories.size }}
+ }
+
+
+ @if (iotHubCategoryOptions.length >= 10) {
+
+ search
+
+ @if (iotHubFilterSearch['category']) {
+
+ close
+
+ }
}
+ 8"
+ (mouseenter)="getFilteredIotHubItems(iotHubCategoryOptions, 'category').length > 8 && (iotHubFilterItemsHovered = true)"
+ (mouseleave)="iotHubFilterItemsHovered = false">
+ @for (opt of getFilteredIotHubItems(iotHubCategoryOptions, 'category'); track opt.key) {
+
+
+ {{ opt.key }}
+
+
+ }
+
+
+ }
+
+
+
+
+ {{ 'iot-hub.use-case' | translate }}
+ @if (iotHubAppliedUseCases.size) {
+ {{ iotHubAppliedUseCases.size }}
+ }
+
+
+ @if (iotHubUseCaseOptions.length >= 10) {
+
+ search
+
+ @if (iotHubFilterSearch['useCase']) {
+
+ close
+
+ }
+
}
-
-
+
8"
+ (mouseenter)="getFilteredIotHubItems(iotHubUseCaseOptions, 'useCase').length > 8 && (iotHubFilterItemsHovered = true)"
+ (mouseleave)="iotHubFilterItemsHovered = false">
+ @for (group of getGroupedIotHubFilterItems(iotHubUseCaseOptions, 'useCase'); track group.label) {
+ @if (group.label) {
+
{{ group.label | translate }}
+ }
+ @for (opt of group.items; track opt.key) {
+
+
+ {{ opt.key }}
+
+
+ }
+ }
+
+
+ }
}
diff --git a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts
index a20b55f8e8..04c244c481 100644
--- a/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts
+++ b/ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-widget-select.component.ts
@@ -35,7 +35,14 @@ import {
MpItemVersionView,
widgetTypeTranslations
} from '@shared/models/iot-hub/iot-hub-version.models';
-import { FilterParamInfo, ItemType, WidgetCategory } from '@shared/models/iot-hub/iot-hub-item.models';
+import {
+ FilterParamInfo,
+ IOT_HUB_SORT_OPTIONS,
+ ItemType,
+ RELEVANCE_SORT_PROPERTY,
+ SortOption,
+ WidgetCategory
+} from '@shared/models/iot-hub/iot-hub-item.models';
import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service';
@@ -54,16 +61,13 @@ import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { Authority } from '@shared/models/authority.enum';
import { WhiteLabelingService } from '@core/http/white-labeling.service';
+/** The Installed list is sorted locally, and only the Hub can rank by relevance. */
+const INSTALLED_SORT_OPTIONS = IOT_HUB_SORT_OPTIONS.filter(o => o.value !== RELEVANCE_SORT_PROPERTY);
+
type selectWidgetMode = 'installed' | 'iotHub';
type installedSubMode = 'default' | 'allWidgets';
type iotHubSubMode = 'default' | 'allWidgets' | 'installed' | 'category';
-interface WidgetSelectSortOption {
- value: string;
- label: string;
- direction: Direction;
-}
-
const LOGICAL_ALL_WIDGETS = '__logical_all_widgets__';
const LOGICAL_INSTALLED_FROM_IOT_HUB = '__logical_installed_from_iot_hub__';
@@ -111,12 +115,7 @@ export class DashboardWidgetSelectComponent {
includeDeprecated = false;
searchFocused = false;
- iotHubSortOptions: WidgetSelectSortOption[] = [
- { value: 'totalInstallCount', label: 'iot-hub.sort-most-installed', direction: Direction.DESC },
- { value: 'publishedTime', label: 'iot-hub.sort-newest', direction: Direction.DESC },
- { value: 'name', label: 'iot-hub.sort-name', direction: Direction.ASC }
- ];
- iotHubSelectedSortIndex = 0;
+ private iotHubSelectedSortValue = IOT_HUB_SORT_OPTIONS[0].value;
@Input()
aliasController: IAliasController;
@@ -160,6 +159,7 @@ export class DashboardWidgetSelectComponent {
this.iotHubAppliedWidgetTypes.clear();
this.iotHubAppliedCategories.clear();
this.iotHubAppliedUseCases.clear();
+ this.iotHubVerifiedCreatorsOnly = false;
this.iotHubFilterCount = 0;
}
}
@@ -283,6 +283,7 @@ export class DashboardWidgetSelectComponent {
iotHubAppliedWidgetTypes = new Set();
iotHubAppliedCategories = new Set();
iotHubAppliedUseCases = new Set();
+ iotHubVerifiedCreatorsOnly = false;
iotHubWidgetTypeOptions: FilterParamInfo[] = [];
iotHubCategoryOptions: FilterParamInfo[] = [];
@@ -330,7 +331,7 @@ export class DashboardWidgetSelectComponent {
this.iotHubWidgetsFetchFunction = (pageSize, page, filter) => {
const search = typeof filter === 'string' ? filter.split('|')[0] : filter;
- const sort = this.iotHubSortOptions[this.iotHubSelectedSortIndex];
+ const sort = this.iotHubSelectedSort;
const sortOrder: SortOrder = { property: sort.value, direction: sort.direction };
const pageLink = new PageLink(pageSize, page, search || null, sortOrder);
const effectiveCategories = this.iotHubSelectedCategory
@@ -341,7 +342,8 @@ export class DashboardWidgetSelectComponent {
categories: effectiveCategories,
useCases: this.iotHubAppliedUseCases.size > 0 ? Array.from(this.iotHubAppliedUseCases) : undefined,
widgetTypes: this.iotHubAppliedWidgetTypes.size > 0 ? Array.from(this.iotHubAppliedWidgetTypes) : undefined,
- scadaFirst: this.scadaFirst ? true : undefined
+ scadaFirst: this.scadaFirst ? true : undefined,
+ creatorVerified: this.iotHubVerifiedCreatorsOnly
});
return this.iotHubApiService.getPublishedVersions(query, { ignoreLoading: true });
};
@@ -364,7 +366,8 @@ export class DashboardWidgetSelectComponent {
this.iotHubDefaultFetchFunction = (pageSize, page, filter) => {
const search = typeof filter === 'string' ? filter.split('|')[0] : filter;
return this.iotHubApiService.getWidgetCategories(search || undefined,
- this.scadaFirst ? true : undefined, { ignoreLoading: true }).pipe(
+ this.scadaFirst ? true : undefined,
+ this.iotHubVerifiedCreatorsOnly, { ignoreLoading: true }).pipe(
map(categories => ({
data: categories.slice(page * pageSize, page * pageSize + pageSize),
totalPages: Math.ceil(categories.length / pageSize),
@@ -581,11 +584,19 @@ export class DashboardWidgetSelectComponent {
this.onIotHubFiltersChanged();
}
+ toggleIotHubVerifiedCreators(): void {
+ this.iotHubVerifiedCreatorsOnly = !this.iotHubVerifiedCreatorsOnly;
+ this.loadWidgetCategories();
+ this.onIotHubFiltersChanged();
+ }
+
clearIotHubFilters(): void {
this.iotHubAppliedWidgetTypes.clear();
this.iotHubAppliedCategories.clear();
this.iotHubAppliedUseCases.clear();
+ this.iotHubVerifiedCreatorsOnly = false;
this.iotHubFilterSearch = {};
+ this.loadWidgetCategories();
this.onIotHubFiltersChanged();
}
@@ -593,13 +604,27 @@ export class DashboardWidgetSelectComponent {
this.iotHubFilterCount =
this.iotHubAppliedWidgetTypes.size +
(this.iotHubSelectedCategory ? 0 : this.iotHubAppliedCategories.size) +
- this.iotHubAppliedUseCases.size;
+ this.iotHubAppliedUseCases.size +
+ (this.iotHubVerifiedCreatorsOnly ? 1 : 0);
this.reloadIotHubWidgets();
}
- onIotHubSortChange(index: number): void {
- if (this.iotHubSelectedSortIndex !== index) {
- this.iotHubSelectedSortIndex = index;
+ get iotHubSortOptions(): SortOption[] {
+ return this.iotHubSubMode === 'installed' ? INSTALLED_SORT_OPTIONS : IOT_HUB_SORT_OPTIONS;
+ }
+
+ /** The chosen sort, or the list's first option where the chosen one is not offered. */
+ get iotHubSelectedSort(): SortOption {
+ const options = this.iotHubSortOptions;
+ return options.find(o => o.value === this.iotHubSelectedSortValue) ?? options[0];
+ }
+
+ onIotHubSortChange(option: SortOption): void {
+ // Store the choice even when it is already the effective sort (the Installed list's fallback
+ // for relevance), so it survives a switch back to the IoT Hub list; reload only on a change.
+ const effective = this.iotHubSelectedSort.value;
+ this.iotHubSelectedSortValue = option.value;
+ if (effective !== option.value) {
this.installedWidgetVersions = null;
this.reloadIotHubWidgets();
}
@@ -609,6 +634,9 @@ export class DashboardWidgetSelectComponent {
if (this.selectWidgetMode === 'installed') {
return (this.filterWidgetTypes?.length ?? 0) + (this.includeDeprecated ? 1 : 0);
}
+ if (this.iotHubSubMode === 'default') {
+ return this.iotHubVerifiedCreatorsOnly ? 1 : 0;
+ }
return this.iotHubFilterCount;
}
@@ -618,7 +646,8 @@ export class DashboardWidgetSelectComponent {
}
return this.iotHubAppliedWidgetTypes.size > 0
|| this.iotHubAppliedCategories.size > 0
- || this.iotHubAppliedUseCases.size > 0;
+ || this.iotHubAppliedUseCases.size > 0
+ || this.iotHubVerifiedCreatorsOnly;
}
clearAllFilters(): void {
@@ -657,7 +686,8 @@ export class DashboardWidgetSelectComponent {
isFilterVisible(): boolean {
if (this.selectWidgetMode === 'iotHub') {
- return this.iotHubSubMode !== 'default';
+ // The category landing honours only the verified filter, so the button stays while it is on
+ return this.iotHubSubMode !== 'default' || this.iotHubVerifiedCreatorsOnly;
}
return this.installedSubMode === 'allWidgets' || this.widgetsBundle !== null;
}
@@ -869,6 +899,9 @@ export class DashboardWidgetSelectComponent {
if (this.iotHubAppliedUseCases.size > 0) {
filtered = filtered.filter(v => v.useCases?.some(u => this.iotHubAppliedUseCases.has(u)));
}
+ if (this.iotHubVerifiedCreatorsOnly) {
+ filtered = filtered.filter(v => v.creatorVerified);
+ }
filtered = this.sortInstalledVersions(filtered);
const start = page * pageSize;
const data = filtered.slice(start, start + pageSize);
@@ -876,7 +909,7 @@ export class DashboardWidgetSelectComponent {
}
private sortInstalledVersions(versions: MpItemVersionView[]): MpItemVersionView[] {
- const sort = this.iotHubSortOptions[this.iotHubSelectedSortIndex];
+ const sort = this.iotHubSelectedSort;
const sign = sort.direction === Direction.ASC ? 1 : -1;
const copy = [...versions];
copy.sort((a, b) => {
diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.html b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.html
index 8c370cdd5d..cf3970ef5d 100644
--- a/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.html
+++ b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.html
@@ -1,11 +1,12 @@
@for (subEntity of subEntities; track subEntity) {
-
{{ subEntity.name | customTranslate }}
diff --git a/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.scss b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.scss
index ee4b487f32..045156fad3 100644
--- a/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.scss
+++ b/ui-ngx/src/app/modules/home/components/entity/entity-chips.component.scss
@@ -1,11 +1,15 @@
// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
-// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
+// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
:host {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: 4px 0;
+ width: 0;
+ min-width: 100%;
a.tb-entity-chip {
+ max-width: 100%;
padding: 4px 8px;
border-radius: 12px;
line-height: 16px;
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss b/ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss
index 25c2092de0..3c0e06d114 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/_iot-hub-common.scss
@@ -119,3 +119,33 @@
pointer-events: none;
}
}
+
+// Scroll area whose thumb shows only while the container is hovered (the filter panels').
+@mixin tb-iot-hub-hover-scrollbar {
+ &::-webkit-scrollbar {
+ width: 6px;
+ }
+
+ &::-webkit-scrollbar-track {
+ background-color: transparent;
+ }
+
+ &::-webkit-scrollbar-thumb {
+ background-color: transparent;
+ border-radius: 3px;
+ }
+
+ &:hover {
+ &::-webkit-scrollbar-track {
+ background-color: rgba(0, 0, 0, 0.04);
+ }
+
+ &::-webkit-scrollbar-thumb {
+ background-color: rgba(0, 0, 0, 0.2);
+
+ &:hover {
+ background-color: rgba(0, 0, 0, 0.35);
+ }
+ }
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.html
index bea4732b05..3bc2fbcbd4 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.html
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.html
@@ -199,7 +199,8 @@
+ labelPosition="bottom"
+ (selectionChange)="onStepSelectionChange($event)">
done
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts
index 554e09a210..ee4a325742 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts
@@ -9,6 +9,7 @@ import { AppState } from '@core/core.state';
import { DialogComponent } from '@shared/components/dialog.component';
import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms';
import { MatStepper } from '@angular/material/stepper';
+import { StepperSelectionEvent } from '@angular/cdk/stepper';
import { firstValueFrom } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
import { PageLink } from '@shared/models/page/page-link';
@@ -252,10 +253,7 @@ export class TbDeviceInstallDialogComponent extends DialogComponent {
- this.stepper?.next();
- this.onStepActivated();
- }, 0);
+ setTimeout(() => this.stepper?.next(), 0);
return;
}
this.startWizard();
@@ -306,12 +304,9 @@ export class TbDeviceInstallDialogComponent extends DialogComponent
+
+ {{ 'iot-hub.verified-creators-only' | translate }}
+
+
+
@if (!fixedSubType && subtypeOptions.length > 0 && activeType !== ItemType.ALARM_RULE) {
@@ -43,8 +50,8 @@
}
}
- 8"
- (mouseenter)="getFilteredItems(subtypeOptions, 'subtype').length > 8 && (filterItemsHovered = true)"
+
scrollThreshold"
+ (mouseenter)="getFilteredItems(subtypeOptions, 'subtype').length > scrollThreshold && (filterItemsHovered = true)"
(mouseleave)="filterItemsHovered = false">
@for (opt of getFilteredItems(subtypeOptions, 'subtype'); track opt.key) {
}
- 8"
- (mouseenter)="getFilteredItems(vendorOptions, 'vendor').length > 8 && (filterItemsHovered = true)"
+
scrollThreshold"
+ (mouseenter)="getFilteredItems(vendorOptions, 'vendor').length > scrollThreshold && (filterItemsHovered = true)"
(mouseleave)="filterItemsHovered = false">
@for (group of getGroupedFilterItems(vendorOptions, 'vendor'); track group.label) {
@if (group.label) {
@@ -114,8 +121,8 @@
}
}
-
8"
- (mouseenter)="getFilteredItems(hardwareTypeOptions, 'hardwareType').length > 8 && (filterItemsHovered = true)"
+
scrollThreshold"
+ (mouseenter)="getFilteredItems(hardwareTypeOptions, 'hardwareType').length > scrollThreshold && (filterItemsHovered = true)"
(mouseleave)="filterItemsHovered = false">
@for (ht of getFilteredItems(hardwareTypeOptions, 'hardwareType'); track ht.key) {
}
- 8"
- (mouseenter)="allConnectivityCount > 8 && (filterItemsHovered = true)"
+
scrollThreshold"
+ (mouseenter)="allConnectivityCount > scrollThreshold && (filterItemsHovered = true)"
(mouseleave)="filterItemsHovered = false">
@for (group of getFilteredConnectivityGroups('connectivity'); track group.group) {
{{ group.group }}
@@ -182,8 +189,8 @@
}
}
-
8"
- (mouseenter)="getFilteredItems(categoryOptions, 'category').length > 8 && (filterItemsHovered = true)"
+
scrollThreshold"
+ (mouseenter)="getFilteredItems(categoryOptions, 'category').length > scrollThreshold && (filterItemsHovered = true)"
(mouseleave)="filterItemsHovered = false">
@for (cat of getFilteredItems(categoryOptions, 'category'); track cat.key) {
}
- 8"
- (mouseenter)="getFilteredItems(useCaseOptions, 'useCase').length > 8 && (filterItemsHovered = true)"
+
scrollThreshold"
+ (mouseenter)="getFilteredItems(useCaseOptions, 'useCase').length > scrollThreshold && (filterItemsHovered = true)"
(mouseleave)="filterItemsHovered = false">
@for (group of getGroupedFilterItems(useCaseOptions, 'useCase'); track group.label) {
@if (group.label) {
@@ -253,6 +260,12 @@
+ @if (verifiedCreatorsOnly) {
+
+ {{ 'iot-hub.verified-creators-only' | translate }}
+ close
+
+ }
@for (key of getActiveSubtypesArray(); track key) {
{{ getSubtypeLabel(key) }}
@@ -305,6 +318,8 @@
@@ -347,6 +362,12 @@
@if (hasActiveDropdownFilters()) {
+ @if (verifiedCreatorsOnly) {
+
+ {{ 'iot-hub.verified-creators-only' | translate }}
+ close
+
+ }
@for (key of getActiveSubtypesArray(); track key) {
{{ getSubtypeLabel(key) }}
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.scss
index a98019cd2c..1b8fa45c82 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.scss
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.scss
@@ -98,6 +98,17 @@
}
}
+.tb-iot-hub-filters-header {
+ padding: 16px 16px 12px 56px;
+ font-size: 18px;
+ font-weight: 500;
+ color: rgba(0, 0, 0, 0.87);
+}
+
+.tb-iot-hub-filters-desktop .tb-iot-hub-filters-inner {
+ padding-top: 8px;
+}
+
.tb-iot-hub-filters-wrapper {
position: sticky;
max-height: calc(100vh - var(--mat-toolbar-standard-height, 64px));
@@ -168,6 +179,10 @@
padding: 0;
}
+ .tb-iot-hub-filter-standalone {
+ margin-left: 13px;
+ }
+
.tb-iot-hub-filter-panel.mat-expansion-panel {
.mat-expansion-panel-header {
padding-left: 24px;
@@ -200,6 +215,21 @@
background: rgba(0, 0, 0, 0.12);
}
+// 56px section-title inset minus the checkbox's own 11px
+.tb-iot-hub-filter-standalone {
+ margin-left: 45px;
+}
+
+.tb-iot-hub-filter-panel.mat-expansion-panel mat-checkbox,
+.tb-iot-hub-filter-standalone {
+ display: block;
+ overflow: hidden;
+
+ &:hover {
+ background: rgba(0, 0, 0, 0.04);
+ }
+}
+
// Filter expansion panels — Design: no shadow, pl-40 for content
.tb-iot-hub-filter-panel.mat-expansion-panel {
box-shadow: none;
@@ -222,15 +252,6 @@
padding: 0 8px 0 0;
}
- mat-checkbox {
- display: block;
- overflow: hidden;
-
- &:hover {
- background: rgba(0, 0, 0, 0.04);
- }
- }
-
.tb-iot-hub-filter-items {
padding-left: 44px;
max-height: 340px;
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts
index 019faf750a..ed5a1e90b1 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-browse.component.ts
@@ -4,23 +4,29 @@ import { AfterViewInit, Component, ElementRef, EventEmitter, Input, NgZone, OnDe
import { Subject } from 'rxjs';
import { debounceTime, takeUntil } from 'rxjs/operators';
import { PageLink } from '@shared/models/page/page-link';
-import { Direction, SortOrder } from '@shared/models/page/sort-order';
+import { SortOrder } from '@shared/models/page/sort-order';
import { PageData } from '@shared/models/page/page-data';
import { MpItemVersionQuery, MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models';
-import { ItemType, FilterParamInfo, CREATOR_VISIBLE_ITEM_TYPES } from '@shared/models/iot-hub/iot-hub-item.models';
+import {
+ CREATOR_VISIBLE_ITEM_TYPES,
+ FilterParamInfo,
+ IOT_HUB_SORT_OPTIONS,
+ isCompactItemType,
+ ItemType
+} from '@shared/models/iot-hub/iot-hub-item.models';
import { widgetTypeTranslations, cfTypeTranslations, ruleChainTypeTranslations } from '@shared/models/iot-hub/iot-hub-version.models';
import { IotHubInstalledItem, DeviceInstalledItemDescriptor } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
import { TranslateService } from '@ngx-translate/core';
import { ActivatedRoute, Router } from '@angular/router';
import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service';
-import { filterIotHubItemsBySearch, groupIotHubFilterItems, IotHubFilterGroup } from '@home/components/iot-hub/iot-hub-utils';
-
-interface SortOption {
- value: string;
- label: string;
- direction: Direction;
-}
+import {
+ filterIotHubItemsBySearch,
+ groupIotHubFilterItems,
+ IOT_HUB_FILTER_SCROLL_THRESHOLD,
+ IotHubFilterGroup,
+ measureGridColumns
+} from '@home/components/iot-hub/iot-hub-utils';
@Component({
selector: 'tb-iot-hub-browse',
@@ -34,7 +40,6 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
private static typeTabLabel(t: ItemType): string {
switch (t) {
case ItemType.WIDGET: return 'item.type-widget-plural';
- case ItemType.DASHBOARD: return 'item.type-dashboard-plural';
case ItemType.SOLUTION_TEMPLATE: return 'item.type-solution-template-plural';
case ItemType.CALCULATED_FIELD: return 'item.type-calculated-field-plural';
case ItemType.ALARM_RULE: return 'item.type-alarm-rule-plural';
@@ -44,6 +49,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
}
readonly ItemType = ItemType;
+ readonly scrollThreshold = IOT_HUB_FILTER_SCROLL_THRESHOLD;
@Input() creatorId: string;
@Input() embedded = false;
@@ -79,15 +85,12 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
}
get isCompactType(): boolean {
- return this._activeType === ItemType.CALCULATED_FIELD
- || this._activeType === ItemType.ALARM_RULE
- || this._activeType === ItemType.RULE_CHAIN;
+ return isCompactItemType(this._activeType);
}
get searchPlaceholderKey(): string {
switch (this._activeType) {
case ItemType.WIDGET: return 'iot-hub.search-widgets';
- case ItemType.DASHBOARD: return 'iot-hub.search-dashboards';
case ItemType.SOLUTION_TEMPLATE: return 'iot-hub.search-solution-templates';
case ItemType.CALCULATED_FIELD: return 'iot-hub.search-calculated-fields';
case ItemType.ALARM_RULE: return 'iot-hub.search-alarm-rules';
@@ -130,12 +133,9 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
activeConnectivity = new Set();
activeHardwareTypes = new Set();
activeVendors = new Set();
+ verifiedCreatorsOnly = false;
- sortOptions: SortOption[] = [
- { value: 'totalInstallCount', label: 'iot-hub.sort-most-installed', direction: Direction.DESC },
- { value: 'publishedTime', label: 'iot-hub.sort-newest', direction: Direction.DESC },
- { value: 'name', label: 'iot-hub.sort-name', direction: Direction.ASC }
- ];
+ readonly sortOptions = IOT_HUB_SORT_OPTIONS;
typeTabs: { type: ItemType; label: string }[] = CREATOR_VISIBLE_ITEM_TYPES.map(t => ({
type: t,
@@ -222,17 +222,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
if (!el) {
return this.probeCols;
}
- // Force layout so `grid-template-columns` resolves to pixel tracks, not `repeat(...)`.
- void el.offsetWidth;
- const tracks = getComputedStyle(el).gridTemplateColumns;
- if (!tracks || tracks === 'none') {
- return 1;
- }
- if (tracks.startsWith('repeat(')) {
- const match = tracks.match(/^repeat\(\s*(\d+)\s*,/);
- return match ? parseInt(match[1], 10) : 1;
- }
- return Math.max(1, tracks.trim().split(/\s+/).filter(t => t.length > 0).length);
+ return measureGridColumns(el);
}
private adjustPageSize(): void {
@@ -398,6 +388,12 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
this.loadItems();
}
+ onVerifiedCreatorsToggle(): void {
+ this.verifiedCreatorsOnly = !this.verifiedCreatorsOnly;
+ this.pageIndex = 0;
+ this.loadItems();
+ }
+
isVendorActive(vendor: string): boolean {
return this.activeVendors.has(vendor);
}
@@ -501,12 +497,14 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
this.activeConnectivity.clear();
this.activeHardwareTypes.clear();
this.activeVendors.clear();
+ this.verifiedCreatorsOnly = false;
}
get activeFilterCount(): number {
const subtypeCount = this.fixedSubType ? this.getActiveSubtypesArray().length : (this.getActiveSubtypes()?.size || 0);
return subtypeCount + this.activeCategories.size + this.activeUseCases.size +
- this.activeConnectivity.size + this.activeHardwareTypes.size + this.activeVendors.size;
+ this.activeConnectivity.size + this.activeHardwareTypes.size + this.activeVendors.size +
+ (this.verifiedCreatorsOnly ? 1 : 0);
}
hasActiveDropdownFilters(): boolean {
@@ -514,7 +512,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
return this.activeCategories.size > 0 ||
this.activeUseCases.size > 0 || subtypeCount > 0 ||
this.activeConnectivity.size > 0 || this.activeHardwareTypes.size > 0 ||
- this.activeVendors.size > 0;
+ this.activeVendors.size > 0 || this.verifiedCreatorsOnly;
}
hasActiveFilters(): boolean {
@@ -524,7 +522,6 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
getTitle(): string {
switch (this.activeType) {
case ItemType.WIDGET: return 'iot-hub.title-widgets';
- case ItemType.DASHBOARD: return 'iot-hub.title-dashboards';
case ItemType.SOLUTION_TEMPLATE: return 'iot-hub.title-solution-templates';
case ItemType.CALCULATED_FIELD: return 'iot-hub.title-calculated-fields';
case ItemType.ALARM_RULE: return 'iot-hub.title-alarm-rules';
@@ -703,7 +700,8 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy
ruleChainTypes: this.activeRuleChainTypes.size > 0 ? Array.from(this.activeRuleChainTypes) : undefined,
hardwareTypes: this.activeHardwareTypes.size > 0 ? Array.from(this.activeHardwareTypes) : undefined,
connectivity: this.activeConnectivity.size > 0 ? Array.from(this.activeConnectivity) : undefined,
- vendors: this.activeVendors.size > 0 ? Array.from(this.activeVendors) : undefined
+ vendors: this.activeVendors.size > 0 ? Array.from(this.activeVendors) : undefined,
+ creatorVerified: this.verifiedCreatorsOnly
});
this.iotHubApiService.getPublishedVersions(
query,
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts
index 78b1742ea0..ea754e42f9 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-components.module.ts
@@ -15,6 +15,7 @@ import { TbIotHubUnpublishedWarningDialogComponent } from './iot-hub-unpublished
import { TbDeviceInstallDialogComponent } from './device-install-dialog/device-install-dialog.component';
import { InstallFormRendererComponent } from './device-install-dialog/install-form-renderer/install-form-renderer.component';
import { TbIotHubSearchComponent } from './iot-hub-search.component';
+import { TbIotHubFacetListComponent } from './iot-hub-facet-list.component';
import { TbIotHubInstalledItemsTableComponent } from './iot-hub-installed-items-table.component';
import { TbIotHubInstalledItemsDialogComponent } from './iot-hub-installed-items-dialog.component';
import { TbIotHubSelectCfEntityDialogComponent } from './iot-hub-select-cf-entity-dialog.component';
@@ -36,6 +37,7 @@ import { IotHubItemLinkModule } from './iot-hub-item-link-card/iot-hub-item-link
TbIotHubUnpublishedWarningDialogComponent,
TbDeviceInstallDialogComponent,
TbIotHubSearchComponent,
+ TbIotHubFacetListComponent,
TbIotHubInstalledItemsTableComponent,
TbIotHubInstalledItemsDialogComponent,
TbIotHubSelectCfEntityDialogComponent,
@@ -63,6 +65,7 @@ import { IotHubItemLinkModule } from './iot-hub-item-link-card/iot-hub-item-link
TbIotHubUnpublishedWarningDialogComponent,
TbDeviceInstallDialogComponent,
TbIotHubSearchComponent,
+ TbIotHubFacetListComponent,
TbIotHubInstalledItemsTableComponent,
TbIotHubInstalledItemsDialogComponent,
TbIotHubSelectCfEntityDialogComponent,
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.html
new file mode 100644
index 0000000000..4683eb2d65
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.html
@@ -0,0 +1,31 @@
+
+
+
+ {{ label | translate }}
+
+
+ @if (searchable) {
+
+ search
+
+ @if (search) {
+
+ close
+
+ }
+
+ }
+
+
+ @for (key of visibleOptions; track key) {
+
+ {{ labelFor(key) }}
+
+ }
+
+
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss
new file mode 100644
index 0000000000..6f41a53bc8
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.scss
@@ -0,0 +1,63 @@
+// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
+// SPDX-License-Identifier: Apache-2.0
+@import "./iot-hub-common";
+
+// Matches the type pages' filter panel, minus its rail indent.
+.tb-iot-hub-facet-panel.mat-expansion-panel {
+ box-shadow: none;
+ border-radius: 0;
+ background: transparent;
+
+ // Text is indented by --tb-facet-indent (set by the host); the rules between facets are not.
+ .mat-expansion-panel-header {
+ padding: 8px 16px 8px var(--tb-facet-indent, 16px);
+ height: 48px;
+ min-height: 48px;
+ }
+
+ ::ng-deep .mat-expansion-panel-header-title {
+ font-size: 14px;
+ font-weight: 500;
+ color: rgba(0, 0, 0, 0.87);
+ }
+
+ ::ng-deep .mat-expansion-panel-body {
+ padding: 0 8px 8px var(--tb-facet-indent, 16px);
+ }
+
+ mat-checkbox {
+ display: block;
+ overflow: hidden;
+
+ &:hover {
+ background: rgba(0, 0, 0, 0.04);
+ }
+ }
+
+ .tb-iot-hub-facet-items {
+ // Capped only when long enough to scroll.
+ &.scrollable {
+ max-height: 280px;
+ overflow-y: auto;
+ }
+
+ @include tb-iot-hub-hover-scrollbar;
+ }
+
+ .tb-iot-hub-facet-search {
+ @include tb-iot-hub-search-container;
+ margin: 4px 8px 8px 0;
+
+ mat-icon {
+ @include tb-iot-hub-search-icon(rgba(0, 0, 0, 0.54));
+ }
+
+ input {
+ @include tb-iot-hub-search-input-text(0.2px);
+ }
+
+ .tb-iot-hub-facet-search-clear.mat-mdc-icon-button {
+ @include tb-iot-hub-search-clear;
+ }
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.ts
new file mode 100644
index 0000000000..a1c11f500f
--- /dev/null
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-facet-list.component.ts
@@ -0,0 +1,60 @@
+// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
+// SPDX-License-Identifier: Apache-2.0
+import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
+import { filterByLabel, IOT_HUB_FILTER_SCROLL_THRESHOLD } from '@home/components/iot-hub/iot-hub-utils';
+
+/**
+ * One checkbox facet of a filter panel: a title, the option keys, and the set of keys currently
+ * selected. Presentational only - the host decides what a toggle means.
+ */
+@Component({
+ selector: 'tb-iot-hub-facet-list',
+ standalone: false,
+ templateUrl: './iot-hub-facet-list.component.html',
+ styleUrls: ['./iot-hub-facet-list.component.scss']
+})
+export class TbIotHubFacetListComponent implements OnChanges {
+
+ /** Translation key for the facet's heading. */
+ @Input() label: string;
+
+ @Input() options: string[] = [];
+
+ /** Keys the host has selected. The host hands over a new Set on every toggle. */
+ @Input() selected = new Set();
+
+ /** Turns an option key into what the user reads. */
+ @Input() labelFor: (key: string) => string = (key) => key;
+
+ @Input() expanded = true;
+
+ @Output() toggled = new EventEmitter();
+
+ search = '';
+ searchable = false;
+ visibleOptions: string[] = [];
+ scrollable = false;
+
+ ngOnChanges(): void {
+ this.searchable = this.options.length > IOT_HUB_FILTER_SCROLL_THRESHOLD;
+ this.applySearch();
+ }
+
+ onSearchChange(search: string): void {
+ this.search = search;
+ this.applySearch();
+ }
+
+ isSelected(key: string): boolean {
+ return this.selected.has(key);
+ }
+
+ onToggle(key: string): void {
+ this.toggled.emit(key);
+ }
+
+ private applySearch(): void {
+ this.visibleOptions = filterByLabel(this.options, this.search, this.labelFor);
+ this.scrollable = this.visibleOptions.length > IOT_HUB_FILTER_SCROLL_THRESHOLD;
+ }
+}
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.scss
index 78c5d11dfd..9f304d2751 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.scss
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.scss
@@ -116,7 +116,6 @@
.tb-type-calc-field { color: #3db5e0; background: rgba(61, 181, 224, 0.06); }
.tb-type-alarm-rule { color: #d7702f; background: rgba(215, 112, 47, 0.06); }
.tb-type-rule-chain { color: #aa5be3; background: rgba(170, 91, 227, 0.06); }
-.tb-type-dashboard { color: #607d8b; background: rgba(96, 125, 139, 0.06); }
// "vX.X.X Available" button — Design: border rgba(0,0,0,0.12), rounded-4, px-12 py-6, gap-8
.tb-installed-version-btn {
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts
index a1206c4f1b..f3e692e704 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-installed-items-table.component.ts
@@ -158,7 +158,6 @@ export class TbIotHubInstalledItemsTableComponent implements OnInit, OnChanges,
getItemTypeChipClass(itemType: string): string {
switch (itemType) {
case 'WIDGET': return 'tb-type-widget';
- case 'DASHBOARD': return 'tb-type-dashboard';
case 'CALCULATED_FIELD': return 'tb-type-calc-field';
case 'ALARM_RULE': return 'tb-type-alarm-rule';
case 'RULE_CHAIN': return 'tb-type-rule-chain';
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.html
index 6015a689a6..d1ff08ba3a 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.html
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.html
@@ -71,14 +71,15 @@
}
} @else {
-
+
@if (getPreviewUrl(); as previewUrl) {
![]()
} @else {
- {{ getPlaceholderIcon() }}
+
+ {{ getPlaceholderIcon() }}
}
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.ts
index 972e20c6bb..7dbe4d066e 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.ts
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-card.component.ts
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MpItemVersionView, cfTypeTranslations, cfTypeIcons, ruleChainTypeTranslations, widgetTypeTranslations } from '@shared/models/iot-hub/iot-hub-version.models';
-import { getItemTypeIcon, ItemType } from '@shared/models/iot-hub/iot-hub-item.models';
+import { getItemTypeIcon, isCompactItemType, ItemType } from '@shared/models/iot-hub/iot-hub-item.models';
import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models';
import { TranslateService } from '@ngx-translate/core';
import { IotHubApiService } from '@core/http/iot-hub-api.service';
@@ -23,6 +23,11 @@ export class TbIotHubItemCardComponent {
@Input() showTypeChip = true;
@Input() showSubtype = false;
@Input() mode: 'default' | 'add' = 'default';
+ /**
+ * `auto`: compact row for the types with nothing to preview (single-type grids widen their
+ * cells for it). `preview`: the tall card for every type, for grids that mix types.
+ */
+ @Input() layout: 'auto' | 'preview' = 'auto';
@Output() cardClick = new EventEmitter
();
@Output() creatorClick = new EventEmitter();
@Output() installClick = new EventEmitter();
@@ -47,9 +52,10 @@ export class TbIotHubItemCardComponent {
}
isCompactLayout(): boolean {
- return this.item.type === ItemType.CALCULATED_FIELD
- || this.item.type === ItemType.ALARM_RULE
- || this.item.type === ItemType.RULE_CHAIN;
+ if (this.layout === 'preview') {
+ return false;
+ }
+ return isCompactItemType(this.item.type);
}
getPreviewUrl(): string | null {
diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.html b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.html
index 81eac5a956..d544727d91 100644
--- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.html
+++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-item-detail-dialog.component.html
@@ -13,7 +13,7 @@
}
-
{{ item.name }}
+
{{ itemTitle }}
{{ getTypeIcon() }}
@@ -75,7 +75,7 @@
@if (isCompactLayout()) {
-
+
@if (item.description) {
@@ -86,11 +86,15 @@
} @else {
-
+
1">
- @if (item.type === ItemType.SOLUTION_TEMPLATE && carouselImages.length > 1) {
+ [class.dlg-preview-carousel]="carouselImages.length > 1"
+ tbPhotoSwipeGallery galleryChildrenSelector=".dlg-carousel-item, .dlg-preview-img"
+ (lightboxOpened)="lightboxOpen = true"
+ (slideChanged)="carouselIndex = $event"
+ (lightboxClosed)="lightboxOpen = false">
+ @if (carouselImages.length > 1) {
@@ -131,7 +135,7 @@
} @else {
- @if (getPreviewUrl(); as url) {
+ @if (carouselImages[0]; as url) {
![]()
} @else {