Merge branch 'develop/3.6' of github.com:thingsboard/thingsboard into develop/3.6
This commit is contained in:
commit
f3e89f7dff
@ -18,6 +18,7 @@ package org.thingsboard.server.service.entitiy.widgets.type;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.common.data.EntityType;
|
import org.thingsboard.server.common.data.EntityType;
|
||||||
|
import org.thingsboard.server.common.data.StringUtils;
|
||||||
import org.thingsboard.server.common.data.User;
|
import org.thingsboard.server.common.data.User;
|
||||||
import org.thingsboard.server.common.data.audit.ActionType;
|
import org.thingsboard.server.common.data.audit.ActionType;
|
||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
@ -42,7 +43,7 @@ public class DefaultWidgetTypeService extends AbstractTbEntityService implements
|
|||||||
@Override
|
@Override
|
||||||
public WidgetTypeDetails save(WidgetTypeDetails widgetTypeDetails, boolean updateExistingByFqn, User user) throws Exception {
|
public WidgetTypeDetails save(WidgetTypeDetails widgetTypeDetails, boolean updateExistingByFqn, User user) throws Exception {
|
||||||
TenantId tenantId = widgetTypeDetails.getTenantId();
|
TenantId tenantId = widgetTypeDetails.getTenantId();
|
||||||
if (widgetTypeDetails.getId() == null && updateExistingByFqn) {
|
if (widgetTypeDetails.getId() == null && StringUtils.isNotEmpty(widgetTypeDetails.getFqn()) && updateExistingByFqn) {
|
||||||
WidgetType widgetType = widgetTypeService.findWidgetTypeByTenantIdAndFqn(tenantId, widgetTypeDetails.getFqn());
|
WidgetType widgetType = widgetTypeService.findWidgetTypeByTenantIdAndFqn(tenantId, widgetTypeDetails.getFqn());
|
||||||
if (widgetType != null) {
|
if (widgetType != null) {
|
||||||
widgetTypeDetails.setId(widgetType.getId());
|
widgetTypeDetails.setId(widgetType.getId());
|
||||||
|
|||||||
@ -398,7 +398,9 @@ export class ImportExportService {
|
|||||||
const widgetTypesDetails = widgetsBundleItem.widgetTypes;
|
const widgetTypesDetails = widgetsBundleItem.widgetTypes;
|
||||||
const saveWidgetTypesObservables: Array<Observable<WidgetTypeDetails>> = [];
|
const saveWidgetTypesObservables: Array<Observable<WidgetTypeDetails>> = [];
|
||||||
for (const widgetTypeDetails of widgetTypesDetails) {
|
for (const widgetTypeDetails of widgetTypesDetails) {
|
||||||
saveWidgetTypesObservables.push(this.widgetService.saveImportedWidgetTypeDetails(widgetTypeDetails));
|
saveWidgetTypesObservables.push(
|
||||||
|
this.widgetService.saveImportedWidgetTypeDetails(this.prepareWidgetType(widgetTypeDetails, savedWidgetsBundle))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
widgetTypesObservable = forkJoin(saveWidgetTypesObservables);
|
widgetTypesObservable = forkJoin(saveWidgetTypesObservables);
|
||||||
} else {
|
} else {
|
||||||
@ -432,6 +434,15 @@ export class ImportExportService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private prepareWidgetType(widgetType: WidgetTypeDetails & {alias?: string}, widgetsBundle: WidgetsBundle): WidgetTypeDetails {
|
||||||
|
if (!widgetType.fqn) {
|
||||||
|
widgetType.fqn = `${widgetsBundle.alias}.${widgetType.alias
|
||||||
|
? widgetType.alias
|
||||||
|
: widgetType.name.toLowerCase().replace(/\W/g, '_')}`;
|
||||||
|
}
|
||||||
|
return widgetType;
|
||||||
|
}
|
||||||
|
|
||||||
public bulkImportEntities(entitiesData: BulkImportRequest, entityType: EntityType, config?: RequestConfig): Observable<BulkImportResult> {
|
public bulkImportEntities(entitiesData: BulkImportRequest, entityType: EntityType, config?: RequestConfig): Observable<BulkImportResult> {
|
||||||
switch (entityType) {
|
switch (entityType) {
|
||||||
case EntityType.DEVICE:
|
case EntityType.DEVICE:
|
||||||
|
|||||||
@ -75,6 +75,7 @@
|
|||||||
</mat-slide-toggle>
|
</mat-slide-toggle>
|
||||||
</div>
|
</div>
|
||||||
<tb-entity-autocomplete
|
<tb-entity-autocomplete
|
||||||
|
useFullEntityId
|
||||||
formControlName="customerId"
|
formControlName="customerId"
|
||||||
labelText="device.assign-to-customer"
|
labelText="device.assign-to-customer"
|
||||||
[entityType]="entityType.CUSTOMER">
|
[entityType]="entityType.CUSTOMER">
|
||||||
|
|||||||
@ -22,7 +22,7 @@ $previewSize: 78px !default;
|
|||||||
|
|
||||||
.tb-container {
|
.tb-container {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
padding: 0;
|
padding: 0 0 16px;
|
||||||
label.tb-title {
|
label.tb-title {
|
||||||
display: block;
|
display: block;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
@ -121,6 +121,7 @@ $previewSize: 78px !default;
|
|||||||
|
|
||||||
.tb-hint{
|
.tb-hint{
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user