Commit 04722e5e8f73e2ebb4e43925c9300ee553652f3e

Authored by Igor Kulikov
2 parents 3d8aaf69 b3fa7299

Fix conflicts

  1 +--
  2 +-- Copyright © 2016-2019 The Thingsboard Authors
  3 +--
  4 +-- Licensed under the Apache License, Version 2.0 (the "License");
  5 +-- you may not use this file except in compliance with the License.
  6 +-- You may obtain a copy of the License at
  7 +--
  8 +-- http://www.apache.org/licenses/LICENSE-2.0
  9 +--
  10 +-- Unless required by applicable law or agreed to in writing, software
  11 +-- distributed under the License is distributed on an "AS IS" BASIS,
  12 +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +-- See the License for the specific language governing permissions and
  14 +-- limitations under the License.
  15 +--
  16 +
  17 +-- distributed under the License is distributed on an "AS IS" BASIS,
  18 +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19 +-- See the License for the specific language governing permissions and
  20 +-- limitations under the License.
  21 +--
  22 +
  23 +ALTER TABLE thingsboard.device ADD label text;
... ...
  1 +--
  2 +-- Copyright © 2016-2019 The Thingsboard Authors
  3 +--
  4 +-- Licensed under the Apache License, Version 2.0 (the "License");
  5 +-- you may not use this file except in compliance with the License.
  6 +-- You may obtain a copy of the License at
  7 +--
  8 +-- http://www.apache.org/licenses/LICENSE-2.0
  9 +--
  10 +-- Unless required by applicable law or agreed to in writing, software
  11 +-- distributed under the License is distributed on an "AS IS" BASIS,
  12 +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +-- See the License for the specific language governing permissions and
  14 +-- limitations under the License.
  15 +--
  16 +
  17 +ALTER TABLE device ADD COLUMN label varchar(255);
... ...
... ... @@ -111,6 +111,11 @@ public class ThingsboardInstallService {
111 111
112 112 databaseUpgradeService.upgradeDatabase("2.3.0");
113 113
  114 + case "2.3.1":
  115 + log.info("Upgrading ThingsBoard from version 2.3.1 to 2.4.0 ...");
  116 +
  117 + databaseUpgradeService.upgradeDatabase("2.3.1");
  118 +
114 119 log.info("Updating system data...");
115 120
116 121 systemDataLoaderService.deleteSystemWidgetBundle("charts");
... ... @@ -127,6 +132,7 @@ public class ThingsboardInstallService {
127 132 systemDataLoaderService.deleteSystemWidgetBundle("date");
128 133
129 134 systemDataLoaderService.loadSystemWidgets();
  135 +
130 136 break;
131 137 default:
132 138 throw new RuntimeException("Unable to upgrade ThingsBoard, unsupported fromVersion: " + upgradeFromVersion);
... ...
... ... @@ -257,6 +257,12 @@ public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService {
257 257 break;
258 258 case "2.3.0":
259 259 break;
  260 + case "2.3.1":
  261 + log.info("Updating schema ...");
  262 + schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.4.0", SCHEMA_UPDATE_CQL);
  263 + loadCql(schemaUpdateFile);
  264 + log.info("Schema updated.");
  265 + break;
260 266 default:
261 267 throw new RuntimeException("Unable to upgrade Cassandra database, unsupported fromVersion: " + fromVersion);
262 268 }
... ...
... ... @@ -165,6 +165,14 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService {
165 165 log.info("Schema updated.");
166 166 }
167 167 break;
  168 + case "2.3.1":
  169 + try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
  170 + log.info("Updating schema ...");
  171 + schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.4.0", SCHEMA_UPDATE_SQL);
  172 + loadSql(schemaUpdateFile, conn);
  173 + log.info("Schema updated.");
  174 + }
  175 + break;
168 176 default:
169 177 throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
170 178 }
... ...
... ... @@ -20,8 +20,6 @@ import org.thingsboard.server.common.data.id.CustomerId;
20 20 import org.thingsboard.server.common.data.id.DeviceId;
21 21 import org.thingsboard.server.common.data.id.TenantId;
22 22
23   -import com.fasterxml.jackson.databind.JsonNode;
24   -
25 23 @EqualsAndHashCode(callSuper = true)
26 24 public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implements HasName, HasTenantId, HasCustomerId {
27 25
... ... @@ -31,6 +29,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
31 29 private CustomerId customerId;
32 30 private String name;
33 31 private String type;
  32 + private String label;
34 33
35 34 public Device() {
36 35 super();
... ... @@ -46,6 +45,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
46 45 this.customerId = device.getCustomerId();
47 46 this.name = device.getName();
48 47 this.type = device.getType();
  48 + this.label = device.getLabel();
49 49 }
50 50
51 51 public TenantId getTenantId() {
... ... @@ -81,6 +81,14 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
81 81 this.type = type;
82 82 }
83 83
  84 + public String getLabel() {
  85 + return label;
  86 + }
  87 +
  88 + public void setLabel(String label) {
  89 + this.label = label;
  90 + }
  91 +
84 92 @Override
85 93 public String getSearchText() {
86 94 return getName();
... ... @@ -97,6 +105,8 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
97 105 builder.append(name);
98 106 builder.append(", type=");
99 107 builder.append(type);
  108 + builder.append(", label=");
  109 + builder.append(label);
100 110 builder.append(", additionalInfo=");
101 111 builder.append(getAdditionalInfo());
102 112 builder.append(", createdTime=");
... ...
... ... @@ -134,6 +134,7 @@ public class ModelConstants {
134 134 public static final String DEVICE_CUSTOMER_ID_PROPERTY = CUSTOMER_ID_PROPERTY;
135 135 public static final String DEVICE_NAME_PROPERTY = "name";
136 136 public static final String DEVICE_TYPE_PROPERTY = "type";
  137 + public static final String DEVICE_LABEL_PROPERTY = "label";
137 138 public static final String DEVICE_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY;
138 139 public static final String DEVICE_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "device_by_tenant_and_search_text";
139 140 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;
31 31
32 32 import java.util.UUID;
33 33
34   -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_ADDITIONAL_INFO_PROPERTY;
35   -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_COLUMN_FAMILY_NAME;
36   -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_CUSTOMER_ID_PROPERTY;
37   -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_NAME_PROPERTY;
38   -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_TENANT_ID_PROPERTY;
39   -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_TYPE_PROPERTY;
40   -import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY;
41   -import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPERTY;
  34 +import static org.thingsboard.server.dao.model.ModelConstants.*;
42 35
43 36 @Table(name = DEVICE_COLUMN_FAMILY_NAME)
44 37 @EqualsAndHashCode
... ... @@ -64,6 +57,9 @@ public final class DeviceEntity implements SearchTextEntity<Device> {
64 57 @Column(name = DEVICE_NAME_PROPERTY)
65 58 private String name;
66 59
  60 + @Column(name = DEVICE_LABEL_PROPERTY)
  61 + private String label;
  62 +
67 63 @Column(name = SEARCH_TEXT_PROPERTY)
68 64 private String searchText;
69 65
... ... @@ -86,6 +82,7 @@ public final class DeviceEntity implements SearchTextEntity<Device> {
86 82 }
87 83 this.name = device.getName();
88 84 this.type = device.getType();
  85 + this.label = device.getLabel();
89 86 this.additionalInfo = device.getAdditionalInfo();
90 87 }
91 88
... ... @@ -163,6 +160,7 @@ public final class DeviceEntity implements SearchTextEntity<Device> {
163 160 }
164 161 device.setName(name);
165 162 device.setType(type);
  163 + device.setLabel(label);
166 164 device.setAdditionalInfo(additionalInfo);
167 165 return device;
168 166 }
... ...
... ... @@ -53,6 +53,9 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT
53 53 @Column(name = ModelConstants.DEVICE_NAME_PROPERTY)
54 54 private String name;
55 55
  56 + @Column(name = ModelConstants.DEVICE_LABEL_PROPERTY)
  57 + private String label;
  58 +
56 59 @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY)
57 60 private String searchText;
58 61
... ... @@ -76,6 +79,7 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT
76 79 }
77 80 this.name = device.getName();
78 81 this.type = device.getType();
  82 + this.label = device.getLabel();
79 83 this.additionalInfo = device.getAdditionalInfo();
80 84 }
81 85
... ... @@ -101,6 +105,7 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT
101 105 }
102 106 device.setName(name);
103 107 device.setType(type);
  108 + device.setLabel(label);
104 109 device.setAdditionalInfo(additionalInfo);
105 110 return device;
106 111 }
... ...
... ... @@ -157,6 +157,7 @@ CREATE TABLE IF NOT EXISTS thingsboard.device (
157 157 customer_id timeuuid,
158 158 name text,
159 159 type text,
  160 + label text,
160 161 search_text text,
161 162 additional_info text,
162 163 PRIMARY KEY (id, tenant_id, customer_id, type)
... ...
... ... @@ -117,6 +117,7 @@ CREATE TABLE IF NOT EXISTS device (
117 117 customer_id varchar(31),
118 118 type varchar(255),
119 119 name varchar(255),
  120 + label varchar(255),
120 121 search_text varchar(255),
121 122 tenant_id varchar(31)
122 123 );
... ...
... ... @@ -151,7 +151,8 @@ export default class AliasController {
151 151 newDatasource.entityId = resolvedEntity.id;
152 152 newDatasource.entityType = resolvedEntity.entityType;
153 153 newDatasource.entityName = resolvedEntity.name;
154   - newDatasource.entityDescription = resolvedEntity.entityDescription
  154 + newDatasource.entityLabel = resolvedEntity.label;
  155 + newDatasource.entityDescription = resolvedEntity.entityDescription;
155 156 newDatasource.name = resolvedEntity.name;
156 157 newDatasource.generated = i > 0 ? true : false;
157 158 datasources.push(newDatasource);
... ... @@ -177,6 +178,7 @@ export default class AliasController {
177 178 datasource.entityId = entity.id;
178 179 datasource.entityType = entity.entityType;
179 180 datasource.entityName = entity.name;
  181 + datasource.entityLabel = entity.label;
180 182 datasource.name = entity.name;
181 183 datasource.entityDescription = entity.entityDescription;
182 184 deferred.resolve([datasource]);
... ...
... ... @@ -345,7 +345,14 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
345 345 }
346 346
347 347 function entityToEntityInfo(entity) {
348   - return { origEntity: entity, name: entity.name, entityType: entity.id.entityType, id: entity.id.id, entityDescription: entity.additionalInfo?entity.additionalInfo.description:"" };
  348 + return {
  349 + origEntity: entity,
  350 + name: entity.name,
  351 + label: entity.label?entity.label:"",
  352 + entityType: entity.id.entityType,
  353 + id: entity.id.id,
  354 + entityDescription: entity.additionalInfo?entity.additionalInfo.description:""
  355 + };
349 356 }
350 357
351 358 function entityRelationInfoToEntityInfo(entityRelationInfo, direction) {
... ...
... ... @@ -503,6 +503,8 @@ function Utils($mdColorPalette, $rootScope, $window, $translate, $q, $timeout, t
503 503 label = label.split(variable).join(datasource.entityName);
504 504 } else if (variableName === 'deviceName') {
505 505 label = label.split(variable).join(datasource.entityName);
  506 + } else if (variableName === 'entityLabel') {
  507 + label = label.split(variable).join(datasource.entityLabel);
506 508 } else if (variableName === 'aliasName') {
507 509 label = label.split(variable).join(datasource.aliasName);
508 510 } else if (variableName === 'entityDescription') {
... ...
... ... @@ -72,6 +72,10 @@
72 72 entity-type="types.entityType.device">
73 73 </tb-entity-subtype-autocomplete>
74 74 <md-input-container class="md-block">
  75 + <label translate>device.label</label>
  76 + <input name="label" ng-model="device.label">
  77 + </md-input-container>
  78 + <md-input-container class="md-block">
75 79 <md-checkbox ng-disabled="$root.loading || !isEdit" flex aria-label="{{ 'device.is-gateway' | translate }}"
76 80 ng-model="device.additionalInfo.gateway">{{ 'device.is-gateway' | translate }}
77 81 </md-checkbox>
... ...
... ... @@ -656,6 +656,7 @@
656 656 "name": "Name",
657 657 "name-required": "Name is required.",
658 658 "description": "Description",
  659 + "label": "Label",
659 660 "events": "Events",
660 661 "details": "Details",
661 662 "copyId": "Copy device Id",
... ...