Add image fields for dashboard and device profile entities. Introduce getAllAlarms and getCustomerAlarms API
This commit is contained in:
parent
89c1743fa0
commit
d5b640d602
@ -78,7 +78,11 @@ CREATE TABLE IF NOT EXISTS firmware (
|
|||||||
CONSTRAINT firmware_tenant_title_version_unq_key UNIQUE (tenant_id, title, version)
|
CONSTRAINT firmware_tenant_title_version_unq_key UNIQUE (tenant_id, title, version)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ALTER TABLE dashboard
|
||||||
|
ADD COLUMN IF NOT EXISTS image varchar(1000000);
|
||||||
|
|
||||||
ALTER TABLE device_profile
|
ALTER TABLE device_profile
|
||||||
|
ADD COLUMN IF NOT EXISTS image varchar(1000000),
|
||||||
ADD COLUMN IF NOT EXISTS firmware_id uuid,
|
ADD COLUMN IF NOT EXISTS firmware_id uuid,
|
||||||
ADD COLUMN IF NOT EXISTS software_id uuid;
|
ADD COLUMN IF NOT EXISTS software_id uuid;
|
||||||
|
|
||||||
|
|||||||
@ -196,6 +196,41 @@ public class AlarmController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
|
@RequestMapping(value = "/alarms", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public PageData<AlarmInfo> getAllAlarms(
|
||||||
|
@RequestParam(required = false) String searchStatus,
|
||||||
|
@RequestParam(required = false) String status,
|
||||||
|
@RequestParam int pageSize,
|
||||||
|
@RequestParam int page,
|
||||||
|
@RequestParam(required = false) String textSearch,
|
||||||
|
@RequestParam(required = false) String sortProperty,
|
||||||
|
@RequestParam(required = false) String sortOrder,
|
||||||
|
@RequestParam(required = false) Long startTime,
|
||||||
|
@RequestParam(required = false) Long endTime,
|
||||||
|
@RequestParam(required = false) Boolean fetchOriginator
|
||||||
|
) throws ThingsboardException {
|
||||||
|
accessControlService.checkPermission(getCurrentUser(), Resource.ALARM, Operation.READ);
|
||||||
|
AlarmSearchStatus alarmSearchStatus = StringUtils.isEmpty(searchStatus) ? null : AlarmSearchStatus.valueOf(searchStatus);
|
||||||
|
AlarmStatus alarmStatus = StringUtils.isEmpty(status) ? null : AlarmStatus.valueOf(status);
|
||||||
|
if (alarmSearchStatus != null && alarmStatus != null) {
|
||||||
|
throw new ThingsboardException("Invalid alarms search query: Both parameters 'searchStatus' " +
|
||||||
|
"and 'status' can't be specified at the same time!", ThingsboardErrorCode.BAD_REQUEST_PARAMS);
|
||||||
|
}
|
||||||
|
TimePageLink pageLink = createTimePageLink(pageSize, page, textSearch, sortProperty, sortOrder, startTime, endTime);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (getCurrentUser().isCustomerUser()) {
|
||||||
|
return checkNotNull(alarmService.findCustomerAlarms(getCurrentUser().getTenantId(), getCurrentUser().getCustomerId(), new AlarmQuery(null, pageLink, alarmSearchStatus, alarmStatus, fetchOriginator)).get());
|
||||||
|
} else {
|
||||||
|
return checkNotNull(alarmService.findAlarms(getCurrentUser().getTenantId(), new AlarmQuery(null, pageLink, alarmSearchStatus, alarmStatus, fetchOriginator)).get());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw handleException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
@PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
|
||||||
@RequestMapping(value = "/alarm/highestSeverity/{entityType}/{entityId}", method = RequestMethod.GET)
|
@RequestMapping(value = "/alarm/highestSeverity/{entityType}/{entityId}", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
|
|||||||
@ -127,6 +127,11 @@ public class DefaultAlarmSubscriptionService extends AbstractSubscriptionService
|
|||||||
return alarmService.findAlarms(tenantId, query);
|
return alarmService.findAlarms(tenantId, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<PageData<AlarmInfo>> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query) {
|
||||||
|
return alarmService.findCustomerAlarms(tenantId, customerId, query);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus) {
|
public AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus) {
|
||||||
return alarmService.findHighestAlarmSeverity(tenantId, entityId, alarmSearchStatus, alarmStatus);
|
return alarmService.findHighestAlarmSeverity(tenantId, entityId, alarmSearchStatus, alarmStatus);
|
||||||
|
|||||||
@ -313,7 +313,7 @@ public abstract class BaseDeviceProfileControllerTest extends AbstractController
|
|||||||
Collections.sort(loadedDeviceProfileInfos, deviceProfileInfoIdComparator);
|
Collections.sort(loadedDeviceProfileInfos, deviceProfileInfoIdComparator);
|
||||||
|
|
||||||
List<DeviceProfileInfo> deviceProfileInfos = deviceProfiles.stream().map(deviceProfile -> new DeviceProfileInfo(deviceProfile.getId(),
|
List<DeviceProfileInfo> deviceProfileInfos = deviceProfiles.stream().map(deviceProfile -> new DeviceProfileInfo(deviceProfile.getId(),
|
||||||
deviceProfile.getName(), deviceProfile.getType(), deviceProfile.getTransportType())).collect(Collectors.toList());
|
deviceProfile.getName(), deviceProfile.getImage(), deviceProfile.getType(), deviceProfile.getTransportType())).collect(Collectors.toList());
|
||||||
|
|
||||||
Assert.assertEquals(deviceProfileInfos, loadedDeviceProfileInfos);
|
Assert.assertEquals(deviceProfileInfos, loadedDeviceProfileInfos);
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,8 @@ public interface AlarmService {
|
|||||||
|
|
||||||
ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query);
|
ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query);
|
||||||
|
|
||||||
|
ListenableFuture<PageData<AlarmInfo>> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query);
|
||||||
|
|
||||||
AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus,
|
AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus,
|
||||||
AlarmStatus alarmStatus);
|
AlarmStatus alarmStatus);
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
|
|||||||
private TenantId tenantId;
|
private TenantId tenantId;
|
||||||
@NoXss
|
@NoXss
|
||||||
private String title;
|
private String title;
|
||||||
|
private String image;
|
||||||
@Valid
|
@Valid
|
||||||
private Set<ShortCustomerInfo> assignedCustomers;
|
private Set<ShortCustomerInfo> assignedCustomers;
|
||||||
|
|
||||||
@ -45,6 +46,7 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
|
|||||||
super(dashboardInfo);
|
super(dashboardInfo);
|
||||||
this.tenantId = dashboardInfo.getTenantId();
|
this.tenantId = dashboardInfo.getTenantId();
|
||||||
this.title = dashboardInfo.getTitle();
|
this.title = dashboardInfo.getTitle();
|
||||||
|
this.image = dashboardInfo.getImage();
|
||||||
this.assignedCustomers = dashboardInfo.getAssignedCustomers();
|
this.assignedCustomers = dashboardInfo.getAssignedCustomers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +66,14 @@ public class DashboardInfo extends SearchTextBased<DashboardId> implements HasNa
|
|||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getImage() {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage(String image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
public Set<ShortCustomerInfo> getAssignedCustomers() {
|
public Set<ShortCustomerInfo> getAssignedCustomers() {
|
||||||
return assignedCustomers;
|
return assignedCustomers;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,6 +43,7 @@ public class DeviceProfile extends SearchTextBased<DeviceProfileId> implements H
|
|||||||
private String name;
|
private String name;
|
||||||
@NoXss
|
@NoXss
|
||||||
private String description;
|
private String description;
|
||||||
|
private String image;
|
||||||
private boolean isDefault;
|
private boolean isDefault;
|
||||||
private DeviceProfileType type;
|
private DeviceProfileType type;
|
||||||
private DeviceTransportType transportType;
|
private DeviceTransportType transportType;
|
||||||
@ -74,6 +75,7 @@ public class DeviceProfile extends SearchTextBased<DeviceProfileId> implements H
|
|||||||
this.tenantId = deviceProfile.getTenantId();
|
this.tenantId = deviceProfile.getTenantId();
|
||||||
this.name = deviceProfile.getName();
|
this.name = deviceProfile.getName();
|
||||||
this.description = deviceProfile.getDescription();
|
this.description = deviceProfile.getDescription();
|
||||||
|
this.image = deviceProfile.getImage();
|
||||||
this.isDefault = deviceProfile.isDefault();
|
this.isDefault = deviceProfile.isDefault();
|
||||||
this.defaultRuleChainId = deviceProfile.getDefaultRuleChainId();
|
this.defaultRuleChainId = deviceProfile.getDefaultRuleChainId();
|
||||||
this.defaultQueueName = deviceProfile.getDefaultQueueName();
|
this.defaultQueueName = deviceProfile.getDefaultQueueName();
|
||||||
|
|||||||
@ -30,21 +30,25 @@ import java.util.UUID;
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class DeviceProfileInfo extends EntityInfo {
|
public class DeviceProfileInfo extends EntityInfo {
|
||||||
|
|
||||||
|
private final String image;
|
||||||
private final DeviceProfileType type;
|
private final DeviceProfileType type;
|
||||||
private final DeviceTransportType transportType;
|
private final DeviceTransportType transportType;
|
||||||
|
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public DeviceProfileInfo(@JsonProperty("id") EntityId id,
|
public DeviceProfileInfo(@JsonProperty("id") EntityId id,
|
||||||
@JsonProperty("name") String name,
|
@JsonProperty("name") String name,
|
||||||
|
@JsonProperty("image") String image,
|
||||||
@JsonProperty("type") DeviceProfileType type,
|
@JsonProperty("type") DeviceProfileType type,
|
||||||
@JsonProperty("transportType") DeviceTransportType transportType) {
|
@JsonProperty("transportType") DeviceTransportType transportType) {
|
||||||
super(id, name);
|
super(id, name);
|
||||||
|
this.image = image;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.transportType = transportType;
|
this.transportType = transportType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceProfileInfo(UUID uuid, String name, DeviceProfileType type, DeviceTransportType transportType) {
|
public DeviceProfileInfo(UUID uuid, String name, String image, DeviceProfileType type, DeviceTransportType transportType) {
|
||||||
super(EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE_PROFILE, uuid), name);
|
super(EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE_PROFILE, uuid), name);
|
||||||
|
this.image = image;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.transportType = transportType;
|
this.transportType = transportType;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,8 @@ public interface AlarmDao extends Dao<Alarm> {
|
|||||||
|
|
||||||
PageData<AlarmInfo> findAlarms(TenantId tenantId, AlarmQuery query);
|
PageData<AlarmInfo> findAlarms(TenantId tenantId, AlarmQuery query);
|
||||||
|
|
||||||
|
PageData<AlarmInfo> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query);
|
||||||
|
|
||||||
PageData<AlarmData> findAlarmDataByQueryForEntities(TenantId tenantId, CustomerId customerId,
|
PageData<AlarmData> findAlarmDataByQueryForEntities(TenantId tenantId, CustomerId customerId,
|
||||||
AlarmDataQuery query, Collection<EntityId> orderedEntityIds);
|
AlarmDataQuery query, Collection<EntityId> orderedEntityIds);
|
||||||
|
|
||||||
|
|||||||
@ -292,6 +292,21 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
|
|||||||
public ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query) {
|
public ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query) {
|
||||||
PageData<AlarmInfo> alarms = alarmDao.findAlarms(tenantId, query);
|
PageData<AlarmInfo> alarms = alarmDao.findAlarms(tenantId, query);
|
||||||
if (query.getFetchOriginator() != null && query.getFetchOriginator().booleanValue()) {
|
if (query.getFetchOriginator() != null && query.getFetchOriginator().booleanValue()) {
|
||||||
|
return fetchAlarmsOriginators(tenantId, alarms);
|
||||||
|
}
|
||||||
|
return Futures.immediateFuture(alarms);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListenableFuture<PageData<AlarmInfo>> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query) {
|
||||||
|
PageData<AlarmInfo> alarms = alarmDao.findCustomerAlarms(tenantId, customerId, query);
|
||||||
|
if (query.getFetchOriginator() != null && query.getFetchOriginator().booleanValue()) {
|
||||||
|
return fetchAlarmsOriginators(tenantId, alarms);
|
||||||
|
}
|
||||||
|
return Futures.immediateFuture(alarms);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ListenableFuture<PageData<AlarmInfo>> fetchAlarmsOriginators(TenantId tenantId, PageData<AlarmInfo> alarms) {
|
||||||
List<ListenableFuture<AlarmInfo>> alarmFutures = new ArrayList<>(alarms.getData().size());
|
List<ListenableFuture<AlarmInfo>> alarmFutures = new ArrayList<>(alarms.getData().size());
|
||||||
for (AlarmInfo alarmInfo : alarms.getData()) {
|
for (AlarmInfo alarmInfo : alarms.getData()) {
|
||||||
alarmFutures.add(Futures.transform(
|
alarmFutures.add(Futures.transform(
|
||||||
@ -308,8 +323,6 @@ public class BaseAlarmService extends AbstractEntityService implements AlarmServ
|
|||||||
alarmInfos -> new PageData<>(alarmInfos, alarms.getTotalPages(), alarms.getTotalElements(),
|
alarmInfos -> new PageData<>(alarmInfos, alarms.getTotalPages(), alarms.getTotalElements(),
|
||||||
alarms.hasNext()), MoreExecutors.directExecutor());
|
alarms.hasNext()), MoreExecutors.directExecutor());
|
||||||
}
|
}
|
||||||
return Futures.immediateFuture(alarms);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus,
|
public AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus,
|
||||||
|
|||||||
@ -170,6 +170,7 @@ public class ModelConstants {
|
|||||||
public static final String DEVICE_PROFILE_TENANT_ID_PROPERTY = TENANT_ID_PROPERTY;
|
public static final String DEVICE_PROFILE_TENANT_ID_PROPERTY = TENANT_ID_PROPERTY;
|
||||||
public static final String DEVICE_PROFILE_NAME_PROPERTY = "name";
|
public static final String DEVICE_PROFILE_NAME_PROPERTY = "name";
|
||||||
public static final String DEVICE_PROFILE_TYPE_PROPERTY = "type";
|
public static final String DEVICE_PROFILE_TYPE_PROPERTY = "type";
|
||||||
|
public static final String DEVICE_PROFILE_IMAGE_PROPERTY = "image";
|
||||||
public static final String DEVICE_PROFILE_TRANSPORT_TYPE_PROPERTY = "transport_type";
|
public static final String DEVICE_PROFILE_TRANSPORT_TYPE_PROPERTY = "transport_type";
|
||||||
public static final String DEVICE_PROFILE_PROVISION_TYPE_PROPERTY = "provision_type";
|
public static final String DEVICE_PROFILE_PROVISION_TYPE_PROPERTY = "provision_type";
|
||||||
public static final String DEVICE_PROFILE_PROFILE_DATA_PROPERTY = "profile_data";
|
public static final String DEVICE_PROFILE_PROFILE_DATA_PROPERTY = "profile_data";
|
||||||
@ -333,6 +334,7 @@ public class ModelConstants {
|
|||||||
public static final String DASHBOARD_COLUMN_FAMILY_NAME = "dashboard";
|
public static final String DASHBOARD_COLUMN_FAMILY_NAME = "dashboard";
|
||||||
public static final String DASHBOARD_TENANT_ID_PROPERTY = TENANT_ID_PROPERTY;
|
public static final String DASHBOARD_TENANT_ID_PROPERTY = TENANT_ID_PROPERTY;
|
||||||
public static final String DASHBOARD_TITLE_PROPERTY = TITLE_PROPERTY;
|
public static final String DASHBOARD_TITLE_PROPERTY = TITLE_PROPERTY;
|
||||||
|
public static final String DASHBOARD_IMAGE_PROPERTY = "image";
|
||||||
public static final String DASHBOARD_CONFIGURATION_PROPERTY = "configuration";
|
public static final String DASHBOARD_CONFIGURATION_PROPERTY = "configuration";
|
||||||
public static final String DASHBOARD_ASSIGNED_CUSTOMERS_PROPERTY = "assigned_customers";
|
public static final String DASHBOARD_ASSIGNED_CUSTOMERS_PROPERTY = "assigned_customers";
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,9 @@ public final class DashboardEntity extends BaseSqlEntity<Dashboard> implements S
|
|||||||
@Column(name = ModelConstants.DASHBOARD_TITLE_PROPERTY)
|
@Column(name = ModelConstants.DASHBOARD_TITLE_PROPERTY)
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@Column(name = ModelConstants.DASHBOARD_IMAGE_PROPERTY)
|
||||||
|
private String image;
|
||||||
|
|
||||||
@Column(name = ModelConstants.SEARCH_TEXT_PROPERTY)
|
@Column(name = ModelConstants.SEARCH_TEXT_PROPERTY)
|
||||||
private String searchText;
|
private String searchText;
|
||||||
|
|
||||||
@ -82,6 +85,7 @@ public final class DashboardEntity extends BaseSqlEntity<Dashboard> implements S
|
|||||||
this.tenantId = dashboard.getTenantId().getId();
|
this.tenantId = dashboard.getTenantId().getId();
|
||||||
}
|
}
|
||||||
this.title = dashboard.getTitle();
|
this.title = dashboard.getTitle();
|
||||||
|
this.image = dashboard.getImage();
|
||||||
if (dashboard.getAssignedCustomers() != null) {
|
if (dashboard.getAssignedCustomers() != null) {
|
||||||
try {
|
try {
|
||||||
this.assignedCustomers = objectMapper.writeValueAsString(dashboard.getAssignedCustomers());
|
this.assignedCustomers = objectMapper.writeValueAsString(dashboard.getAssignedCustomers());
|
||||||
@ -110,6 +114,7 @@ public final class DashboardEntity extends BaseSqlEntity<Dashboard> implements S
|
|||||||
dashboard.setTenantId(new TenantId(tenantId));
|
dashboard.setTenantId(new TenantId(tenantId));
|
||||||
}
|
}
|
||||||
dashboard.setTitle(title);
|
dashboard.setTitle(title);
|
||||||
|
dashboard.setImage(image);
|
||||||
if (!StringUtils.isEmpty(assignedCustomers)) {
|
if (!StringUtils.isEmpty(assignedCustomers)) {
|
||||||
try {
|
try {
|
||||||
dashboard.setAssignedCustomers(objectMapper.readValue(assignedCustomers, assignedCustomersType));
|
dashboard.setAssignedCustomers(objectMapper.readValue(assignedCustomers, assignedCustomersType));
|
||||||
|
|||||||
@ -54,6 +54,9 @@ public class DashboardInfoEntity extends BaseSqlEntity<DashboardInfo> implements
|
|||||||
@Column(name = ModelConstants.DASHBOARD_TITLE_PROPERTY)
|
@Column(name = ModelConstants.DASHBOARD_TITLE_PROPERTY)
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@Column(name = ModelConstants.DASHBOARD_IMAGE_PROPERTY)
|
||||||
|
private String image;
|
||||||
|
|
||||||
@Column(name = ModelConstants.SEARCH_TEXT_PROPERTY)
|
@Column(name = ModelConstants.SEARCH_TEXT_PROPERTY)
|
||||||
private String searchText;
|
private String searchText;
|
||||||
|
|
||||||
@ -73,6 +76,7 @@ public class DashboardInfoEntity extends BaseSqlEntity<DashboardInfo> implements
|
|||||||
this.tenantId = dashboardInfo.getTenantId().getId();
|
this.tenantId = dashboardInfo.getTenantId().getId();
|
||||||
}
|
}
|
||||||
this.title = dashboardInfo.getTitle();
|
this.title = dashboardInfo.getTitle();
|
||||||
|
this.image = dashboardInfo.getImage();
|
||||||
if (dashboardInfo.getAssignedCustomers() != null) {
|
if (dashboardInfo.getAssignedCustomers() != null) {
|
||||||
try {
|
try {
|
||||||
this.assignedCustomers = objectMapper.writeValueAsString(dashboardInfo.getAssignedCustomers());
|
this.assignedCustomers = objectMapper.writeValueAsString(dashboardInfo.getAssignedCustomers());
|
||||||
@ -104,6 +108,7 @@ public class DashboardInfoEntity extends BaseSqlEntity<DashboardInfo> implements
|
|||||||
dashboardInfo.setTenantId(new TenantId(tenantId));
|
dashboardInfo.setTenantId(new TenantId(tenantId));
|
||||||
}
|
}
|
||||||
dashboardInfo.setTitle(title);
|
dashboardInfo.setTitle(title);
|
||||||
|
dashboardInfo.setImage(image);
|
||||||
if (!StringUtils.isEmpty(assignedCustomers)) {
|
if (!StringUtils.isEmpty(assignedCustomers)) {
|
||||||
try {
|
try {
|
||||||
dashboardInfo.setAssignedCustomers(objectMapper.readValue(assignedCustomers, assignedCustomersType));
|
dashboardInfo.setAssignedCustomers(objectMapper.readValue(assignedCustomers, assignedCustomersType));
|
||||||
|
|||||||
@ -60,6 +60,9 @@ public final class DeviceProfileEntity extends BaseSqlEntity<DeviceProfile> impl
|
|||||||
@Column(name = ModelConstants.DEVICE_PROFILE_TYPE_PROPERTY)
|
@Column(name = ModelConstants.DEVICE_PROFILE_TYPE_PROPERTY)
|
||||||
private DeviceProfileType type;
|
private DeviceProfileType type;
|
||||||
|
|
||||||
|
@Column(name = ModelConstants.DEVICE_PROFILE_IMAGE_PROPERTY)
|
||||||
|
private String image;
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(name = ModelConstants.DEVICE_PROFILE_TRANSPORT_TYPE_PROPERTY)
|
@Column(name = ModelConstants.DEVICE_PROFILE_TRANSPORT_TYPE_PROPERTY)
|
||||||
private DeviceTransportType transportType;
|
private DeviceTransportType transportType;
|
||||||
@ -110,6 +113,7 @@ public final class DeviceProfileEntity extends BaseSqlEntity<DeviceProfile> impl
|
|||||||
this.setCreatedTime(deviceProfile.getCreatedTime());
|
this.setCreatedTime(deviceProfile.getCreatedTime());
|
||||||
this.name = deviceProfile.getName();
|
this.name = deviceProfile.getName();
|
||||||
this.type = deviceProfile.getType();
|
this.type = deviceProfile.getType();
|
||||||
|
this.image = deviceProfile.getImage();
|
||||||
this.transportType = deviceProfile.getTransportType();
|
this.transportType = deviceProfile.getTransportType();
|
||||||
this.provisionType = deviceProfile.getProvisionType();
|
this.provisionType = deviceProfile.getProvisionType();
|
||||||
this.description = deviceProfile.getDescription();
|
this.description = deviceProfile.getDescription();
|
||||||
@ -151,6 +155,7 @@ public final class DeviceProfileEntity extends BaseSqlEntity<DeviceProfile> impl
|
|||||||
}
|
}
|
||||||
deviceProfile.setName(name);
|
deviceProfile.setName(name);
|
||||||
deviceProfile.setType(type);
|
deviceProfile.setType(type);
|
||||||
|
deviceProfile.setImage(image);
|
||||||
deviceProfile.setTransportType(transportType);
|
deviceProfile.setTransportType(transportType);
|
||||||
deviceProfile.setProvisionType(provisionType);
|
deviceProfile.setProvisionType(provisionType);
|
||||||
deviceProfile.setDescription(description);
|
deviceProfile.setDescription(description);
|
||||||
|
|||||||
@ -94,6 +94,70 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
|
|||||||
@Param("searchText") String searchText,
|
@Param("searchText") String searchText,
|
||||||
Pageable pageable);
|
Pageable pageable);
|
||||||
|
|
||||||
|
@Query(value = "SELECT new org.thingsboard.server.dao.model.sql.AlarmInfoEntity(a) FROM AlarmEntity a " +
|
||||||
|
"WHERE a.tenantId = :tenantId " +
|
||||||
|
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
|
||||||
|
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
|
||||||
|
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
|
||||||
|
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
|
||||||
|
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
|
||||||
|
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ",
|
||||||
|
countQuery = "" +
|
||||||
|
"SELECT count(a) " +
|
||||||
|
"FROM AlarmEntity a " +
|
||||||
|
"WHERE a.tenantId = :tenantId " +
|
||||||
|
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
|
||||||
|
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
|
||||||
|
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
|
||||||
|
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
|
||||||
|
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
|
||||||
|
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ")
|
||||||
|
Page<AlarmInfoEntity> findAllAlarms(@Param("tenantId") UUID tenantId,
|
||||||
|
@Param("startTime") Long startTime,
|
||||||
|
@Param("endTime") Long endTime,
|
||||||
|
@Param("alarmStatuses") Set<AlarmStatus> alarmStatuses,
|
||||||
|
@Param("searchText") String searchText,
|
||||||
|
Pageable pageable);
|
||||||
|
|
||||||
|
@Query(value = "SELECT new org.thingsboard.server.dao.model.sql.AlarmInfoEntity(a) FROM AlarmEntity a " +
|
||||||
|
"WHERE a.tenantId = :tenantId " +
|
||||||
|
"AND (" +
|
||||||
|
"a.originatorId IN (SELECT d.id from DeviceEntity d WHERE d.customerId = :customerId) " +
|
||||||
|
"OR a.originatorId IN (SELECT asset.id from AssetEntity asset WHERE asset.customerId = :customerId) " +
|
||||||
|
"OR a.originatorId IN (SELECT u.id from UserEntity u WHERE u.customerId = :customerId) " +
|
||||||
|
"OR a.originatorId = :customerId" +
|
||||||
|
") " +
|
||||||
|
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
|
||||||
|
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
|
||||||
|
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
|
||||||
|
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
|
||||||
|
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
|
||||||
|
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) "
|
||||||
|
,
|
||||||
|
countQuery = "" +
|
||||||
|
"SELECT count(a) " +
|
||||||
|
"FROM AlarmEntity a " +
|
||||||
|
"WHERE a.tenantId = :tenantId " +
|
||||||
|
"AND (" +
|
||||||
|
"a.originatorId IN (SELECT d.id from DeviceEntity d WHERE d.customerId = :customerId) " +
|
||||||
|
"OR a.originatorId IN (SELECT asset.id from AssetEntity asset WHERE asset.customerId = :customerId) " +
|
||||||
|
"OR a.originatorId IN (SELECT u.id from UserEntity u WHERE u.customerId = :customerId) " +
|
||||||
|
"OR a.originatorId = :customerId" +
|
||||||
|
") " +
|
||||||
|
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
|
||||||
|
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
|
||||||
|
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
|
||||||
|
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
|
||||||
|
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
|
||||||
|
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ")
|
||||||
|
Page<AlarmInfoEntity> findCustomerAlarms(@Param("tenantId") UUID tenantId,
|
||||||
|
@Param("customerId") UUID customerId,
|
||||||
|
@Param("startTime") Long startTime,
|
||||||
|
@Param("endTime") Long endTime,
|
||||||
|
@Param("alarmStatuses") Set<AlarmStatus> alarmStatuses,
|
||||||
|
@Param("searchText") String searchText,
|
||||||
|
Pageable pageable);
|
||||||
|
|
||||||
@Query(value = "SELECT a.severity FROM AlarmEntity a " +
|
@Query(value = "SELECT a.severity FROM AlarmEntity a " +
|
||||||
"LEFT JOIN RelationEntity re ON a.id = re.toId " +
|
"LEFT JOIN RelationEntity re ON a.id = re.toId " +
|
||||||
"AND re.relationTypeGroup = 'ALARM' " +
|
"AND re.relationTypeGroup = 'ALARM' " +
|
||||||
|
|||||||
@ -103,6 +103,7 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A
|
|||||||
} else if (query.getStatus() != null) {
|
} else if (query.getStatus() != null) {
|
||||||
statusSet = Collections.singleton(query.getStatus());
|
statusSet = Collections.singleton(query.getStatus());
|
||||||
}
|
}
|
||||||
|
if (affectedEntity != null) {
|
||||||
return DaoUtil.toPageData(
|
return DaoUtil.toPageData(
|
||||||
alarmRepository.findAlarms(
|
alarmRepository.findAlarms(
|
||||||
tenantId.getId(),
|
tenantId.getId(),
|
||||||
@ -115,6 +116,40 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A
|
|||||||
DaoUtil.toPageable(query.getPageLink())
|
DaoUtil.toPageable(query.getPageLink())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return DaoUtil.toPageData(
|
||||||
|
alarmRepository.findAllAlarms(
|
||||||
|
tenantId.getId(),
|
||||||
|
query.getPageLink().getStartTime(),
|
||||||
|
query.getPageLink().getEndTime(),
|
||||||
|
statusSet,
|
||||||
|
Objects.toString(query.getPageLink().getTextSearch(), ""),
|
||||||
|
DaoUtil.toPageable(query.getPageLink())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageData<AlarmInfo> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query) {
|
||||||
|
log.trace("Try to find customer alarms by status [{}] and pageLink [{}]", query.getStatus(), query.getPageLink());
|
||||||
|
Set<AlarmStatus> statusSet = null;
|
||||||
|
if (query.getSearchStatus() != null) {
|
||||||
|
statusSet = query.getSearchStatus().getStatuses();
|
||||||
|
} else if (query.getStatus() != null) {
|
||||||
|
statusSet = Collections.singleton(query.getStatus());
|
||||||
|
}
|
||||||
|
return DaoUtil.toPageData(
|
||||||
|
alarmRepository.findCustomerAlarms(
|
||||||
|
tenantId.getId(),
|
||||||
|
customerId.getId(),
|
||||||
|
query.getPageLink().getStartTime(),
|
||||||
|
query.getPageLink().getEndTime(),
|
||||||
|
statusSet,
|
||||||
|
Objects.toString(query.getPageLink().getTextSearch(), ""),
|
||||||
|
DaoUtil.toPageable(query.getPageLink())
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public interface DeviceProfileRepository extends PagingAndSortingRepository<DeviceProfileEntity, UUID> {
|
public interface DeviceProfileRepository extends PagingAndSortingRepository<DeviceProfileEntity, UUID> {
|
||||||
|
|
||||||
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.type, d.transportType) " +
|
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.image, d.type, d.transportType) " +
|
||||||
"FROM DeviceProfileEntity d " +
|
"FROM DeviceProfileEntity d " +
|
||||||
"WHERE d.id = :deviceProfileId")
|
"WHERE d.id = :deviceProfileId")
|
||||||
DeviceProfileInfo findDeviceProfileInfoById(@Param("deviceProfileId") UUID deviceProfileId);
|
DeviceProfileInfo findDeviceProfileInfoById(@Param("deviceProfileId") UUID deviceProfileId);
|
||||||
@ -39,14 +39,14 @@ public interface DeviceProfileRepository extends PagingAndSortingRepository<Devi
|
|||||||
@Param("textSearch") String textSearch,
|
@Param("textSearch") String textSearch,
|
||||||
Pageable pageable);
|
Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.type, d.transportType) " +
|
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.image, d.type, d.transportType) " +
|
||||||
"FROM DeviceProfileEntity d WHERE " +
|
"FROM DeviceProfileEntity d WHERE " +
|
||||||
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
|
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
|
||||||
Page<DeviceProfileInfo> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
|
Page<DeviceProfileInfo> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
|
||||||
@Param("textSearch") String textSearch,
|
@Param("textSearch") String textSearch,
|
||||||
Pageable pageable);
|
Pageable pageable);
|
||||||
|
|
||||||
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.type, d.transportType) " +
|
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.image, d.type, d.transportType) " +
|
||||||
"FROM DeviceProfileEntity d WHERE " +
|
"FROM DeviceProfileEntity d WHERE " +
|
||||||
"d.tenantId = :tenantId AND d.transportType = :transportType AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
|
"d.tenantId = :tenantId AND d.transportType = :transportType AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
|
||||||
Page<DeviceProfileInfo> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
|
Page<DeviceProfileInfo> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
|
||||||
@ -58,7 +58,7 @@ public interface DeviceProfileRepository extends PagingAndSortingRepository<Devi
|
|||||||
"WHERE d.tenantId = :tenantId AND d.isDefault = true")
|
"WHERE d.tenantId = :tenantId AND d.isDefault = true")
|
||||||
DeviceProfileEntity findByDefaultTrueAndTenantId(@Param("tenantId") UUID tenantId);
|
DeviceProfileEntity findByDefaultTrueAndTenantId(@Param("tenantId") UUID tenantId);
|
||||||
|
|
||||||
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.type, d.transportType) " +
|
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.image, d.type, d.transportType) " +
|
||||||
"FROM DeviceProfileEntity d " +
|
"FROM DeviceProfileEntity d " +
|
||||||
"WHERE d.tenantId = :tenantId AND d.isDefault = true")
|
"WHERE d.tenantId = :tenantId AND d.isDefault = true")
|
||||||
DeviceProfileInfo findDefaultDeviceProfileInfo(@Param("tenantId") UUID tenantId);
|
DeviceProfileInfo findDefaultDeviceProfileInfo(@Param("tenantId") UUID tenantId);
|
||||||
|
|||||||
@ -118,7 +118,8 @@ CREATE TABLE IF NOT EXISTS dashboard (
|
|||||||
assigned_customers varchar(1000000),
|
assigned_customers varchar(1000000),
|
||||||
search_text varchar(255),
|
search_text varchar(255),
|
||||||
tenant_id uuid,
|
tenant_id uuid,
|
||||||
title varchar(255)
|
title varchar(255),
|
||||||
|
image varchar(1000000)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS rule_chain (
|
CREATE TABLE IF NOT EXISTS rule_chain (
|
||||||
@ -182,6 +183,7 @@ CREATE TABLE IF NOT EXISTS device_profile (
|
|||||||
created_time bigint NOT NULL,
|
created_time bigint NOT NULL,
|
||||||
name varchar(255),
|
name varchar(255),
|
||||||
type varchar(255),
|
type varchar(255),
|
||||||
|
image varchar(1000000),
|
||||||
transport_type varchar(255),
|
transport_type varchar(255),
|
||||||
provision_type varchar(255),
|
provision_type varchar(255),
|
||||||
profile_data jsonb,
|
profile_data jsonb,
|
||||||
|
|||||||
@ -136,7 +136,8 @@ CREATE TABLE IF NOT EXISTS dashboard (
|
|||||||
assigned_customers varchar(1000000),
|
assigned_customers varchar(1000000),
|
||||||
search_text varchar(255),
|
search_text varchar(255),
|
||||||
tenant_id uuid,
|
tenant_id uuid,
|
||||||
title varchar(255)
|
title varchar(255),
|
||||||
|
image varchar(1000000)
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS rule_chain (
|
CREATE TABLE IF NOT EXISTS rule_chain (
|
||||||
@ -201,6 +202,7 @@ CREATE TABLE IF NOT EXISTS device_profile (
|
|||||||
created_time bigint NOT NULL,
|
created_time bigint NOT NULL,
|
||||||
name varchar(255),
|
name varchar(255),
|
||||||
type varchar(255),
|
type varchar(255),
|
||||||
|
image varchar(1000000),
|
||||||
transport_type varchar(255),
|
transport_type varchar(255),
|
||||||
provision_type varchar(255),
|
provision_type varchar(255),
|
||||||
profile_data jsonb,
|
profile_data jsonb,
|
||||||
|
|||||||
@ -333,7 +333,7 @@ public class BaseDeviceProfileServiceTest extends AbstractServiceTest {
|
|||||||
|
|
||||||
List<DeviceProfileInfo> deviceProfileInfos = deviceProfiles.stream()
|
List<DeviceProfileInfo> deviceProfileInfos = deviceProfiles.stream()
|
||||||
.map(deviceProfile -> new DeviceProfileInfo(deviceProfile.getId(),
|
.map(deviceProfile -> new DeviceProfileInfo(deviceProfile.getId(),
|
||||||
deviceProfile.getName(), deviceProfile.getType(), deviceProfile.getTransportType())).collect(Collectors.toList());
|
deviceProfile.getName(), deviceProfile.getImage(), deviceProfile.getType(), deviceProfile.getTransportType())).collect(Collectors.toList());
|
||||||
|
|
||||||
Assert.assertEquals(deviceProfileInfos, loadedDeviceProfileInfos);
|
Assert.assertEquals(deviceProfileInfos, loadedDeviceProfileInfos);
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,8 @@ public interface RuleEngineAlarmService {
|
|||||||
|
|
||||||
ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query);
|
ListenableFuture<PageData<AlarmInfo>> findAlarms(TenantId tenantId, AlarmQuery query);
|
||||||
|
|
||||||
|
ListenableFuture<PageData<AlarmInfo>> findCustomerAlarms(TenantId tenantId, CustomerId customerId, AlarmQuery query);
|
||||||
|
|
||||||
AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus);
|
AlarmSeverity findHighestAlarmSeverity(TenantId tenantId, EntityId entityId, AlarmSearchStatus alarmSearchStatus, AlarmStatus alarmStatus);
|
||||||
|
|
||||||
PageData<AlarmData> findAlarmDataByQueryForEntities(TenantId tenantId, CustomerId customerId, AlarmDataQuery query, Collection<EntityId> orderedEntityIds);
|
PageData<AlarmData> findAlarmDataByQueryForEntities(TenantId tenantId, CustomerId customerId, AlarmDataQuery query, Collection<EntityId> orderedEntityIds);
|
||||||
|
|||||||
@ -60,6 +60,11 @@
|
|||||||
{{ 'device-profile.type-required' | translate }}
|
{{ 'device-profile.type-required' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<tb-image-input fxFlex
|
||||||
|
label="{{'device-profile.image' | translate}}"
|
||||||
|
maxSizeByte="524288"
|
||||||
|
formControlName="image">
|
||||||
|
</tb-image-input>
|
||||||
<mat-form-field class="mat-block">
|
<mat-form-field class="mat-block">
|
||||||
<mat-label translate>device-profile.description</mat-label>
|
<mat-label translate>device-profile.description</mat-label>
|
||||||
<textarea matInput formControlName="description" rows="2"></textarea>
|
<textarea matInput formControlName="description" rows="2"></textarea>
|
||||||
|
|||||||
@ -106,6 +106,7 @@ export class AddDeviceProfileDialogComponent extends
|
|||||||
{
|
{
|
||||||
name: [data.deviceProfileName, [Validators.required]],
|
name: [data.deviceProfileName, [Validators.required]],
|
||||||
type: [DeviceProfileType.DEFAULT, [Validators.required]],
|
type: [DeviceProfileType.DEFAULT, [Validators.required]],
|
||||||
|
image: [null, []],
|
||||||
defaultRuleChainId: [null, []],
|
defaultRuleChainId: [null, []],
|
||||||
defaultQueueName: ['', []],
|
defaultQueueName: ['', []],
|
||||||
description: ['', []]
|
description: ['', []]
|
||||||
@ -183,6 +184,7 @@ export class AddDeviceProfileDialogComponent extends
|
|||||||
const deviceProfile: DeviceProfile = {
|
const deviceProfile: DeviceProfile = {
|
||||||
name: this.deviceProfileDetailsFormGroup.get('name').value,
|
name: this.deviceProfileDetailsFormGroup.get('name').value,
|
||||||
type: this.deviceProfileDetailsFormGroup.get('type').value,
|
type: this.deviceProfileDetailsFormGroup.get('type').value,
|
||||||
|
image: this.deviceProfileDetailsFormGroup.get('image').value,
|
||||||
transportType: this.transportConfigFormGroup.get('transportType').value,
|
transportType: this.transportConfigFormGroup.get('transportType').value,
|
||||||
provisionType: deviceProvisionConfiguration.type,
|
provisionType: deviceProvisionConfiguration.type,
|
||||||
provisionDeviceKey,
|
provisionDeviceKey,
|
||||||
|
|||||||
@ -86,6 +86,11 @@
|
|||||||
{{ 'device-profile.type-required' | translate }}
|
{{ 'device-profile.type-required' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<tb-image-input fxFlex
|
||||||
|
label="{{'device-profile.image' | translate}}"
|
||||||
|
maxSizeByte="524288"
|
||||||
|
formControlName="image">
|
||||||
|
</tb-image-input>
|
||||||
<mat-form-field class="mat-block">
|
<mat-form-field class="mat-block">
|
||||||
<mat-label translate>device-profile.description</mat-label>
|
<mat-label translate>device-profile.description</mat-label>
|
||||||
<textarea matInput formControlName="description" rows="2"></textarea>
|
<textarea matInput formControlName="description" rows="2"></textarea>
|
||||||
|
|||||||
@ -103,6 +103,7 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
|
|||||||
{
|
{
|
||||||
name: [entity ? entity.name : '', [Validators.required]],
|
name: [entity ? entity.name : '', [Validators.required]],
|
||||||
type: [entity ? entity.type : null, [Validators.required]],
|
type: [entity ? entity.type : null, [Validators.required]],
|
||||||
|
image: [entity ? entity.image : null],
|
||||||
transportType: [entity ? entity.transportType : null, [Validators.required]],
|
transportType: [entity ? entity.transportType : null, [Validators.required]],
|
||||||
profileData: this.fb.group({
|
profileData: this.fb.group({
|
||||||
configuration: [entity && !this.isAdd ? entity.profileData?.configuration : {}, Validators.required],
|
configuration: [entity && !this.isAdd ? entity.profileData?.configuration : {}, Validators.required],
|
||||||
@ -178,6 +179,7 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
|
|||||||
};
|
};
|
||||||
this.entityForm.patchValue({name: entity.name});
|
this.entityForm.patchValue({name: entity.name});
|
||||||
this.entityForm.patchValue({type: entity.type}, {emitEvent: false});
|
this.entityForm.patchValue({type: entity.type}, {emitEvent: false});
|
||||||
|
this.entityForm.patchValue({image: entity.image}, {emitEvent: false});
|
||||||
this.entityForm.patchValue({transportType: entity.transportType}, {emitEvent: false});
|
this.entityForm.patchValue({transportType: entity.transportType}, {emitEvent: false});
|
||||||
this.entityForm.patchValue({provisionType: entity.provisionType}, {emitEvent: false});
|
this.entityForm.patchValue({provisionType: entity.provisionType}, {emitEvent: false});
|
||||||
this.entityForm.patchValue({provisionDeviceKey: entity.provisionDeviceKey}, {emitEvent: false});
|
this.entityForm.patchValue({provisionDeviceKey: entity.provisionDeviceKey}, {emitEvent: false});
|
||||||
|
|||||||
@ -105,6 +105,11 @@
|
|||||||
{{ 'dashboard.title-required' | translate }}
|
{{ 'dashboard.title-required' | translate }}
|
||||||
</mat-error>
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<tb-image-input fxFlex
|
||||||
|
label="{{'dashboard.image' | translate}}"
|
||||||
|
maxSizeByte="524288"
|
||||||
|
formControlName="image">
|
||||||
|
</tb-image-input>
|
||||||
<div formGroupName="configuration" fxLayout="column">
|
<div formGroupName="configuration" fxLayout="column">
|
||||||
<mat-form-field class="mat-block">
|
<mat-form-field class="mat-block">
|
||||||
<mat-label translate>dashboard.description</mat-label>
|
<mat-label translate>dashboard.description</mat-label>
|
||||||
|
|||||||
@ -80,6 +80,7 @@ export class DashboardFormComponent extends EntityComponent<Dashboard> {
|
|||||||
return this.fb.group(
|
return this.fb.group(
|
||||||
{
|
{
|
||||||
title: [entity ? entity.title : '', [Validators.required]],
|
title: [entity ? entity.title : '', [Validators.required]],
|
||||||
|
image: [entity ? entity.image : null],
|
||||||
configuration: this.fb.group(
|
configuration: this.fb.group(
|
||||||
{
|
{
|
||||||
description: [entity && entity.configuration ? entity.configuration.description : ''],
|
description: [entity && entity.configuration ? entity.configuration.description : ''],
|
||||||
@ -92,6 +93,7 @@ export class DashboardFormComponent extends EntityComponent<Dashboard> {
|
|||||||
updateForm(entity: Dashboard) {
|
updateForm(entity: Dashboard) {
|
||||||
this.updateFields(entity);
|
this.updateFields(entity);
|
||||||
this.entityForm.patchValue({title: entity.title});
|
this.entityForm.patchValue({title: entity.title});
|
||||||
|
this.entityForm.patchValue({image: entity.image});
|
||||||
this.entityForm.patchValue({configuration: {description: entity.configuration ? entity.configuration.description : ''}});
|
this.entityForm.patchValue({configuration: {description: entity.configuration ? entity.configuration.description : ''}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,10 +21,10 @@
|
|||||||
[flowConfig]="{singleFile: true, allowDuplicateUploads: true}">
|
[flowConfig]="{singleFile: true, allowDuplicateUploads: true}">
|
||||||
<div class="tb-image-select-container">
|
<div class="tb-image-select-container">
|
||||||
<div *ngIf="showPreview" class="tb-image-preview-container">
|
<div *ngIf="showPreview" class="tb-image-preview-container">
|
||||||
<div *ngIf="!safeImageUrl;else elseBlock" translate>dashboard.no-image</div>
|
<div *ngIf="!safeImageUrl; else elseBlock">{{ (disabled ? 'dashboard.empty-image' : 'dashboard.no-image') | translate }}</div>
|
||||||
<ng-template #elseBlock><img class="tb-image-preview" [src]="safeImageUrl" /></ng-template>
|
<ng-template #elseBlock><img class="tb-image-preview" [src]="safeImageUrl" /></ng-template>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="showClearButton" class="tb-image-clear-container">
|
<div *ngIf="showClearButton && !disabled" class="tb-image-clear-container">
|
||||||
<button mat-button mat-icon-button color="primary"
|
<button mat-button mat-icon-button color="primary"
|
||||||
type="button"
|
type="button"
|
||||||
(click)="clearImage()"
|
(click)="clearImage()"
|
||||||
@ -34,7 +34,7 @@
|
|||||||
<mat-icon>close</mat-icon>
|
<mat-icon>close</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="drop-area tb-flow-drop"
|
<div *ngIf="!disabled" class="drop-area tb-flow-drop"
|
||||||
flowDrop
|
flowDrop
|
||||||
[flow]="flow.flowJs">
|
[flow]="flow.flowJs">
|
||||||
<label for="{{inputId}}" translate>dashboard.drop-image</label>
|
<label for="{{inputId}}" translate>dashboard.drop-image</label>
|
||||||
@ -42,5 +42,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div class="tb-hint" *ngIf="maxSizeByte" translate [translateParams]="{ size: maxSizeByte | fileSize}">dashboard.maximum-upload-file-size</div>
|
<div class="tb-hint" *ngIf="maxSizeByte && !disabled" translate [translateParams]="{ size: maxSizeByte | fileSize}">dashboard.maximum-upload-file-size</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import { Filters } from '@shared/models/query/query.models';
|
|||||||
export interface DashboardInfo extends BaseData<DashboardId> {
|
export interface DashboardInfo extends BaseData<DashboardId> {
|
||||||
tenantId?: TenantId;
|
tenantId?: TenantId;
|
||||||
title?: string;
|
title?: string;
|
||||||
|
image?: string;
|
||||||
assignedCustomers?: Array<ShortCustomerInfo>;
|
assignedCustomers?: Array<ShortCustomerInfo>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -492,6 +492,7 @@ export interface DeviceProfile extends BaseData<DeviceProfileId> {
|
|||||||
description?: string;
|
description?: string;
|
||||||
default?: boolean;
|
default?: boolean;
|
||||||
type: DeviceProfileType;
|
type: DeviceProfileType;
|
||||||
|
image?: string;
|
||||||
transportType: DeviceTransportType;
|
transportType: DeviceTransportType;
|
||||||
provisionType: DeviceProvisionType;
|
provisionType: DeviceProvisionType;
|
||||||
provisionDeviceKey?: string;
|
provisionDeviceKey?: string;
|
||||||
|
|||||||
@ -666,6 +666,7 @@
|
|||||||
"no-widgets": "No widgets configured",
|
"no-widgets": "No widgets configured",
|
||||||
"add-widget": "Add new widget",
|
"add-widget": "Add new widget",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
|
"image": "Dashboard image",
|
||||||
"select-widget-title": "Select widget",
|
"select-widget-title": "Select widget",
|
||||||
"select-widget-value": "{{title}}: select widget",
|
"select-widget-value": "{{title}}: select widget",
|
||||||
"select-widget-subtitle": "List of available widget types",
|
"select-widget-subtitle": "List of available widget types",
|
||||||
@ -712,6 +713,7 @@
|
|||||||
"background-image": "Background image",
|
"background-image": "Background image",
|
||||||
"background-size-mode": "Background size mode",
|
"background-size-mode": "Background size mode",
|
||||||
"no-image": "No image selected",
|
"no-image": "No image selected",
|
||||||
|
"empty-image": "No image",
|
||||||
"drop-image": "Drop an image or click to select a file to upload.",
|
"drop-image": "Drop an image or click to select a file to upload.",
|
||||||
"maximum-upload-file-size": "Maximum upload file size: {{ size }}",
|
"maximum-upload-file-size": "Maximum upload file size: {{ size }}",
|
||||||
"cannot-upload-file": "Cannot upload file",
|
"cannot-upload-file": "Cannot upload file",
|
||||||
@ -1028,6 +1030,7 @@
|
|||||||
"type": "Profile type",
|
"type": "Profile type",
|
||||||
"type-required": "Profile type is required.",
|
"type-required": "Profile type is required.",
|
||||||
"type-default": "Default",
|
"type-default": "Default",
|
||||||
|
"image": "Device profile image",
|
||||||
"transport-type": "Transport type",
|
"transport-type": "Transport type",
|
||||||
"transport-type-required": "Transport type is required.",
|
"transport-type-required": "Transport type is required.",
|
||||||
"transport-type-default": "Default",
|
"transport-type-default": "Default",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user