Merge branch 'vvlladd28-feature/device_label'
This commit is contained in:
commit
20540b1c2b
23
application/src/main/data/upgrade/2.4.0/schema_update.cql
Normal file
23
application/src/main/data/upgrade/2.4.0/schema_update.cql
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
--
|
||||||
|
-- Copyright © 2016-2019 The Thingsboard Authors
|
||||||
|
--
|
||||||
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
-- you may not use this file except in compliance with the License.
|
||||||
|
-- You may obtain a copy of the License at
|
||||||
|
--
|
||||||
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
--
|
||||||
|
-- Unless required by applicable law or agreed to in writing, software
|
||||||
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
-- See the License for the specific language governing permissions and
|
||||||
|
-- limitations under the License.
|
||||||
|
--
|
||||||
|
|
||||||
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
-- See the License for the specific language governing permissions and
|
||||||
|
-- limitations under the License.
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE thingsboard.device ADD label text;
|
||||||
17
application/src/main/data/upgrade/2.4.0/schema_update.sql
Normal file
17
application/src/main/data/upgrade/2.4.0/schema_update.sql
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
--
|
||||||
|
-- Copyright © 2016-2019 The Thingsboard Authors
|
||||||
|
--
|
||||||
|
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
-- you may not use this file except in compliance with the License.
|
||||||
|
-- You may obtain a copy of the License at
|
||||||
|
--
|
||||||
|
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
--
|
||||||
|
-- Unless required by applicable law or agreed to in writing, software
|
||||||
|
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
-- See the License for the specific language governing permissions and
|
||||||
|
-- limitations under the License.
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE device ADD COLUMN label varchar(255);
|
||||||
@ -111,6 +111,11 @@ public class ThingsboardInstallService {
|
|||||||
|
|
||||||
databaseUpgradeService.upgradeDatabase("2.3.0");
|
databaseUpgradeService.upgradeDatabase("2.3.0");
|
||||||
|
|
||||||
|
case "2.3.1":
|
||||||
|
log.info("Upgrading ThingsBoard from version 2.3.1 to 2.4.0 ...");
|
||||||
|
|
||||||
|
databaseUpgradeService.upgradeDatabase("2.3.1");
|
||||||
|
|
||||||
log.info("Updating system data...");
|
log.info("Updating system data...");
|
||||||
|
|
||||||
systemDataLoaderService.deleteSystemWidgetBundle("charts");
|
systemDataLoaderService.deleteSystemWidgetBundle("charts");
|
||||||
@ -127,6 +132,7 @@ public class ThingsboardInstallService {
|
|||||||
systemDataLoaderService.deleteSystemWidgetBundle("date");
|
systemDataLoaderService.deleteSystemWidgetBundle("date");
|
||||||
|
|
||||||
systemDataLoaderService.loadSystemWidgets();
|
systemDataLoaderService.loadSystemWidgets();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unable to upgrade ThingsBoard, unsupported fromVersion: " + upgradeFromVersion);
|
throw new RuntimeException("Unable to upgrade ThingsBoard, unsupported fromVersion: " + upgradeFromVersion);
|
||||||
|
|||||||
@ -257,6 +257,12 @@ public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService {
|
|||||||
break;
|
break;
|
||||||
case "2.3.0":
|
case "2.3.0":
|
||||||
break;
|
break;
|
||||||
|
case "2.3.1":
|
||||||
|
log.info("Updating schema ...");
|
||||||
|
schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.4.0", SCHEMA_UPDATE_CQL);
|
||||||
|
loadCql(schemaUpdateFile);
|
||||||
|
log.info("Schema updated.");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unable to upgrade Cassandra database, unsupported fromVersion: " + fromVersion);
|
throw new RuntimeException("Unable to upgrade Cassandra database, unsupported fromVersion: " + fromVersion);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -165,6 +165,14 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService {
|
|||||||
log.info("Schema updated.");
|
log.info("Schema updated.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "2.3.1":
|
||||||
|
try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
|
||||||
|
log.info("Updating schema ...");
|
||||||
|
schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.4.0", SCHEMA_UPDATE_SQL);
|
||||||
|
loadSql(schemaUpdateFile, conn);
|
||||||
|
log.info("Schema updated.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
|
throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,8 +20,6 @@ import org.thingsboard.server.common.data.id.CustomerId;
|
|||||||
import org.thingsboard.server.common.data.id.DeviceId;
|
import org.thingsboard.server.common.data.id.DeviceId;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implements HasName, HasTenantId, HasCustomerId {
|
public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implements HasName, HasTenantId, HasCustomerId {
|
||||||
|
|
||||||
@ -31,6 +29,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
|
|||||||
private CustomerId customerId;
|
private CustomerId customerId;
|
||||||
private String name;
|
private String name;
|
||||||
private String type;
|
private String type;
|
||||||
|
private String label;
|
||||||
|
|
||||||
public Device() {
|
public Device() {
|
||||||
super();
|
super();
|
||||||
@ -46,6 +45,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
|
|||||||
this.customerId = device.getCustomerId();
|
this.customerId = device.getCustomerId();
|
||||||
this.name = device.getName();
|
this.name = device.getName();
|
||||||
this.type = device.getType();
|
this.type = device.getType();
|
||||||
|
this.label = device.getLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TenantId getTenantId() {
|
public TenantId getTenantId() {
|
||||||
@ -81,6 +81,14 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSearchText() {
|
public String getSearchText() {
|
||||||
return getName();
|
return getName();
|
||||||
@ -97,6 +105,8 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
|
|||||||
builder.append(name);
|
builder.append(name);
|
||||||
builder.append(", type=");
|
builder.append(", type=");
|
||||||
builder.append(type);
|
builder.append(type);
|
||||||
|
builder.append(", label=");
|
||||||
|
builder.append(label);
|
||||||
builder.append(", additionalInfo=");
|
builder.append(", additionalInfo=");
|
||||||
builder.append(getAdditionalInfo());
|
builder.append(getAdditionalInfo());
|
||||||
builder.append(", createdTime=");
|
builder.append(", createdTime=");
|
||||||
|
|||||||
@ -134,6 +134,7 @@ public class ModelConstants {
|
|||||||
public static final String DEVICE_CUSTOMER_ID_PROPERTY = CUSTOMER_ID_PROPERTY;
|
public static final String DEVICE_CUSTOMER_ID_PROPERTY = CUSTOMER_ID_PROPERTY;
|
||||||
public static final String DEVICE_NAME_PROPERTY = "name";
|
public static final String DEVICE_NAME_PROPERTY = "name";
|
||||||
public static final String DEVICE_TYPE_PROPERTY = "type";
|
public static final String DEVICE_TYPE_PROPERTY = "type";
|
||||||
|
public static final String DEVICE_LABEL_PROPERTY = "label";
|
||||||
public static final String DEVICE_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY;
|
public static final String DEVICE_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY;
|
||||||
public static final String DEVICE_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "device_by_tenant_and_search_text";
|
public static final String DEVICE_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "device_by_tenant_and_search_text";
|
||||||
public static final String DEVICE_BY_TENANT_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "device_by_tenant_by_type_and_search_text";
|
public static final String DEVICE_BY_TENANT_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "device_by_tenant_by_type_and_search_text";
|
||||||
|
|||||||
@ -31,14 +31,7 @@ import org.thingsboard.server.dao.model.type.JsonCodec;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_ADDITIONAL_INFO_PROPERTY;
|
import static org.thingsboard.server.dao.model.ModelConstants.*;
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_COLUMN_FAMILY_NAME;
|
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_CUSTOMER_ID_PROPERTY;
|
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_NAME_PROPERTY;
|
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_TENANT_ID_PROPERTY;
|
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_TYPE_PROPERTY;
|
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY;
|
|
||||||
import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPERTY;
|
|
||||||
|
|
||||||
@Table(name = DEVICE_COLUMN_FAMILY_NAME)
|
@Table(name = DEVICE_COLUMN_FAMILY_NAME)
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@ -64,6 +57,9 @@ public final class DeviceEntity implements SearchTextEntity<Device> {
|
|||||||
@Column(name = DEVICE_NAME_PROPERTY)
|
@Column(name = DEVICE_NAME_PROPERTY)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = DEVICE_LABEL_PROPERTY)
|
||||||
|
private String label;
|
||||||
|
|
||||||
@Column(name = SEARCH_TEXT_PROPERTY)
|
@Column(name = SEARCH_TEXT_PROPERTY)
|
||||||
private String searchText;
|
private String searchText;
|
||||||
|
|
||||||
@ -86,6 +82,7 @@ public final class DeviceEntity implements SearchTextEntity<Device> {
|
|||||||
}
|
}
|
||||||
this.name = device.getName();
|
this.name = device.getName();
|
||||||
this.type = device.getType();
|
this.type = device.getType();
|
||||||
|
this.label = device.getLabel();
|
||||||
this.additionalInfo = device.getAdditionalInfo();
|
this.additionalInfo = device.getAdditionalInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +160,7 @@ public final class DeviceEntity implements SearchTextEntity<Device> {
|
|||||||
}
|
}
|
||||||
device.setName(name);
|
device.setName(name);
|
||||||
device.setType(type);
|
device.setType(type);
|
||||||
|
device.setLabel(label);
|
||||||
device.setAdditionalInfo(additionalInfo);
|
device.setAdditionalInfo(additionalInfo);
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,6 +53,9 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT
|
|||||||
@Column(name = ModelConstants.DEVICE_NAME_PROPERTY)
|
@Column(name = ModelConstants.DEVICE_NAME_PROPERTY)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = ModelConstants.DEVICE_LABEL_PROPERTY)
|
||||||
|
private String label;
|
||||||
|
|
||||||
@Column(name = ModelConstants.SEARCH_TEXT_PROPERTY)
|
@Column(name = ModelConstants.SEARCH_TEXT_PROPERTY)
|
||||||
private String searchText;
|
private String searchText;
|
||||||
|
|
||||||
@ -76,6 +79,7 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT
|
|||||||
}
|
}
|
||||||
this.name = device.getName();
|
this.name = device.getName();
|
||||||
this.type = device.getType();
|
this.type = device.getType();
|
||||||
|
this.label = device.getLabel();
|
||||||
this.additionalInfo = device.getAdditionalInfo();
|
this.additionalInfo = device.getAdditionalInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +105,7 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT
|
|||||||
}
|
}
|
||||||
device.setName(name);
|
device.setName(name);
|
||||||
device.setType(type);
|
device.setType(type);
|
||||||
|
device.setLabel(label);
|
||||||
device.setAdditionalInfo(additionalInfo);
|
device.setAdditionalInfo(additionalInfo);
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,6 +157,7 @@ CREATE TABLE IF NOT EXISTS thingsboard.device (
|
|||||||
customer_id timeuuid,
|
customer_id timeuuid,
|
||||||
name text,
|
name text,
|
||||||
type text,
|
type text,
|
||||||
|
label text,
|
||||||
search_text text,
|
search_text text,
|
||||||
additional_info text,
|
additional_info text,
|
||||||
PRIMARY KEY (id, tenant_id, customer_id, type)
|
PRIMARY KEY (id, tenant_id, customer_id, type)
|
||||||
|
|||||||
@ -117,6 +117,7 @@ CREATE TABLE IF NOT EXISTS device (
|
|||||||
customer_id varchar(31),
|
customer_id varchar(31),
|
||||||
type varchar(255),
|
type varchar(255),
|
||||||
name varchar(255),
|
name varchar(255),
|
||||||
|
label varchar(255),
|
||||||
search_text varchar(255),
|
search_text varchar(255),
|
||||||
tenant_id varchar(31)
|
tenant_id varchar(31)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -151,7 +151,8 @@ export default class AliasController {
|
|||||||
newDatasource.entityId = resolvedEntity.id;
|
newDatasource.entityId = resolvedEntity.id;
|
||||||
newDatasource.entityType = resolvedEntity.entityType;
|
newDatasource.entityType = resolvedEntity.entityType;
|
||||||
newDatasource.entityName = resolvedEntity.name;
|
newDatasource.entityName = resolvedEntity.name;
|
||||||
newDatasource.entityDescription = resolvedEntity.entityDescription
|
newDatasource.entityLabel = resolvedEntity.label;
|
||||||
|
newDatasource.entityDescription = resolvedEntity.entityDescription;
|
||||||
newDatasource.name = resolvedEntity.name;
|
newDatasource.name = resolvedEntity.name;
|
||||||
newDatasource.generated = i > 0 ? true : false;
|
newDatasource.generated = i > 0 ? true : false;
|
||||||
datasources.push(newDatasource);
|
datasources.push(newDatasource);
|
||||||
@ -177,6 +178,7 @@ export default class AliasController {
|
|||||||
datasource.entityId = entity.id;
|
datasource.entityId = entity.id;
|
||||||
datasource.entityType = entity.entityType;
|
datasource.entityType = entity.entityType;
|
||||||
datasource.entityName = entity.name;
|
datasource.entityName = entity.name;
|
||||||
|
datasource.entityLabel = entity.label;
|
||||||
datasource.name = entity.name;
|
datasource.name = entity.name;
|
||||||
datasource.entityDescription = entity.entityDescription;
|
datasource.entityDescription = entity.entityDescription;
|
||||||
deferred.resolve([datasource]);
|
deferred.resolve([datasource]);
|
||||||
|
|||||||
@ -345,7 +345,14 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
|
|||||||
}
|
}
|
||||||
|
|
||||||
function entityToEntityInfo(entity) {
|
function entityToEntityInfo(entity) {
|
||||||
return { origEntity: entity, name: entity.name, entityType: entity.id.entityType, id: entity.id.id, entityDescription: entity.additionalInfo?entity.additionalInfo.description:"" };
|
return {
|
||||||
|
origEntity: entity,
|
||||||
|
name: entity.name,
|
||||||
|
label: entity.label?entity.label:"",
|
||||||
|
entityType: entity.id.entityType,
|
||||||
|
id: entity.id.id,
|
||||||
|
entityDescription: entity.additionalInfo?entity.additionalInfo.description:""
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function entityRelationInfoToEntityInfo(entityRelationInfo, direction) {
|
function entityRelationInfoToEntityInfo(entityRelationInfo, direction) {
|
||||||
|
|||||||
@ -503,6 +503,8 @@ function Utils($mdColorPalette, $rootScope, $window, $translate, $q, $timeout, t
|
|||||||
label = label.split(variable).join(datasource.entityName);
|
label = label.split(variable).join(datasource.entityName);
|
||||||
} else if (variableName === 'deviceName') {
|
} else if (variableName === 'deviceName') {
|
||||||
label = label.split(variable).join(datasource.entityName);
|
label = label.split(variable).join(datasource.entityName);
|
||||||
|
} else if (variableName === 'entityLabel') {
|
||||||
|
label = label.split(variable).join(datasource.entityLabel);
|
||||||
} else if (variableName === 'aliasName') {
|
} else if (variableName === 'aliasName') {
|
||||||
label = label.split(variable).join(datasource.aliasName);
|
label = label.split(variable).join(datasource.aliasName);
|
||||||
} else if (variableName === 'entityDescription') {
|
} else if (variableName === 'entityDescription') {
|
||||||
|
|||||||
@ -71,6 +71,10 @@
|
|||||||
ng-model="device.type"
|
ng-model="device.type"
|
||||||
entity-type="types.entityType.device">
|
entity-type="types.entityType.device">
|
||||||
</tb-entity-subtype-autocomplete>
|
</tb-entity-subtype-autocomplete>
|
||||||
|
<md-input-container class="md-block">
|
||||||
|
<label translate>device.label</label>
|
||||||
|
<input name="label" ng-model="device.label">
|
||||||
|
</md-input-container>
|
||||||
<md-input-container class="md-block">
|
<md-input-container class="md-block">
|
||||||
<md-checkbox ng-disabled="$root.loading || !isEdit" flex aria-label="{{ 'device.is-gateway' | translate }}"
|
<md-checkbox ng-disabled="$root.loading || !isEdit" flex aria-label="{{ 'device.is-gateway' | translate }}"
|
||||||
ng-model="device.additionalInfo.gateway">{{ 'device.is-gateway' | translate }}
|
ng-model="device.additionalInfo.gateway">{{ 'device.is-gateway' | translate }}
|
||||||
|
|||||||
@ -656,6 +656,7 @@
|
|||||||
"name": "Name",
|
"name": "Name",
|
||||||
"name-required": "Name is required.",
|
"name-required": "Name is required.",
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
|
"label": "Label",
|
||||||
"events": "Events",
|
"events": "Events",
|
||||||
"details": "Details",
|
"details": "Details",
|
||||||
"copyId": "Copy device Id",
|
"copyId": "Copy device Id",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user