Browse Source

Fixed createdTime storage. Fixed copy edge secret and key button

pull/3811/head
Volodymyr Babak 6 years ago
parent
commit
c3e1eee6c9
  1. 4
      dao/src/main/java/org/thingsboard/server/dao/model/sql/AbstractEdgeEntity.java
  2. 90
      ui-ngx/src/app/modules/home/pages/edge/edge.component.html
  3. 22
      ui-ngx/src/app/modules/home/pages/edge/edge.component.ts

4
dao/src/main/java/org/thingsboard/server/dao/model/sql/AbstractEdgeEntity.java

@ -98,6 +98,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T
if (edge.getId() != null) {
this.setUuid(edge.getId().getId());
}
this.setCreatedTime(edge.getCreatedTime());
if (edge.getTenantId() != null) {
this.tenantId = edge.getTenantId().getId();
}
@ -119,6 +120,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T
public AbstractEdgeEntity(EdgeEntity edgeEntity) {
this.setId(edgeEntity.getId());
this.setCreatedTime(edgeEntity.getCreatedTime());
this.tenantId = edgeEntity.getTenantId();
this.customerId = edgeEntity.getCustomerId();
this.rootRuleChainId = edgeEntity.getRootRuleChainId();
@ -149,7 +151,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T
protected Edge toEdge() {
Edge edge = new Edge(new EdgeId(getUuid()));
edge.setCreatedTime(Uuids.unixTimestamp(getUuid()));
edge.setCreatedTime(createdTime);
if (tenantId != null) {
edge.setTenantId(new TenantId(tenantId));
}

90
ui-ngx/src/app/modules/home/pages/edge/edge.component.html

@ -132,56 +132,50 @@
[required]="true"
[entityType]="entityType.EDGE">
</tb-entity-subtype-autocomplete>
<div fxLayout="row" [fxShow]="edgeScope === 'tenant'">
<fieldset fxFlex>
<div class="tb-hint" [innerHTML]="'edge.edge-license-key-hint' | translate"></div>
<mat-form-field class="mat-block">
<mat-label translate>edge.edge-license-key</mat-label>
<input matInput formControlName="edgeLicenseKey" required>
<mat-error *ngIf="entityForm.get('edgeLicenseKey').hasError('required')">
{{ 'edge.edge-license-key-required' | translate }}
</mat-error>
</mat-form-field>
</fieldset>
</div>
<div fxLayout="row" [fxShow]="edgeScope === 'tenant'">
<fieldset fxFlex>
<div translate class="tb-hint">edge.cloud-endpoint-hint</div>
<mat-form-field class="mat-block">
<mat-label translate>edge.cloud-endpoint</mat-label>
<input matInput formControlName="cloudEndpoint" required>
<mat-error *ngIf="entityForm.get('cloudEndpoint').hasError('required')">
{{ 'edge.cloud-endpoint-required' | translate }}
</mat-error>
</mat-form-field>
</fieldset>
</div>
<div fxLayout="row" [fxShow]="edgeScope === 'tenant'">
<fieldset fxFlex disabled>
<mat-form-field class="mat-block" fxFlex>
<mat-label translate>edge.edge-key</mat-label>
<input matInput formControlName="routingKey">
</mat-form-field>
</fieldset>
<button mat-button mat-icon-button type="button" ngxClipboard (cbOnSuccess)="onEdgeInfoCopied('key')"
[cbContent]="entityForm?.get('routingKey').value"
matTooltip="{{'edge.copy-edge-key' | translate}}">
<mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon>
</button>
<div [fxShow]="edgeScope === 'tenant'">
<div class="tb-hint" [innerHTML]="'edge.edge-license-key-hint' | translate"></div>
<mat-form-field class="mat-block">
<mat-label translate>edge.edge-license-key</mat-label>
<input matInput formControlName="edgeLicenseKey" required>
<mat-error *ngIf="entityForm.get('edgeLicenseKey').hasError('required')">
{{ 'edge.edge-license-key-required' | translate }}
</mat-error>
</mat-form-field>
</div>
<div fxLayout="row" [fxShow]="edgeScope === 'tenant'">
<fieldset fxFlex disabled>
<mat-form-field class="mat-block" fxFlex>
<mat-label translate>edge.edge-secret</mat-label>
<input matInput formControlName="secret">
</mat-form-field>
</fieldset>
<button mat-button mat-icon-button type="button" ngxClipboard (cbOnSuccess)="onEdgeInfoCopied('secret')"
[cbContent]="entityForm?.get('secret').value"
matTooltip="{{'edge.copy-edge-secret' | translate}}">
<mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon>
</button>
<div [fxShow]="edgeScope === 'tenant'">
<div translate class="tb-hint">edge.cloud-endpoint-hint</div>
<mat-form-field class="mat-block">
<mat-label translate>edge.cloud-endpoint</mat-label>
<input matInput formControlName="cloudEndpoint" required>
<mat-error *ngIf="entityForm.get('cloudEndpoint').hasError('required')">
{{ 'edge.cloud-endpoint-required' | translate }}
</mat-error>
</mat-form-field>
</div>
</fieldset>
<div fxLayout="row" [fxShow]="edgeScope === 'tenant'">
<mat-form-field class="mat-block" fxFlex>
<mat-label translate>edge.edge-key</mat-label>
<input matInput formControlName="routingKey">
</mat-form-field>
<button mat-button mat-icon-button type="button" ngxClipboard (cbOnSuccess)="onEdgeInfoCopied('key')"
[cbContent]="entityForm?.get('routingKey').value"
matTooltip="{{'edge.copy-edge-key' | translate}}">
<mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon>
</button>
</div>
<div fxLayout="row" [fxShow]="edgeScope === 'tenant'">
<mat-form-field class="mat-block" fxFlex>
<mat-label translate>edge.edge-secret</mat-label>
<input matInput formControlName="secret">
</mat-form-field>
<button mat-button mat-icon-button type="button" ngxClipboard (cbOnSuccess)="onEdgeInfoCopied('secret')"
[cbContent]="entityForm?.get('secret').value"
matTooltip="{{'edge.copy-edge-secret' | translate}}">
<mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon>
</button>
</div>
<fieldset [disabled]="(isLoading$ | async) || !isEdit">
<mat-form-field class="mat-block">
<mat-label translate>edge.label</mat-label>
<input matInput formControlName="label">

22
ui-ngx/src/app/modules/home/pages/edge/edge.component.ts

@ -69,15 +69,15 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
}
buildForm(entity: EdgeInfo): FormGroup {
return this.fb.group(
const form = this.fb.group(
{
name: [entity ? entity.name : '', [Validators.required]],
type: [entity?.type ? entity.type : 'default', [Validators.required]],
label: [entity ? entity.label : ''],
cloudEndpoint: [null, [Validators.required]],
edgeLicenseKey: ['', [Validators.required]],
routingKey: guid(),
secret: this.generateSecret(20),
routingKey: this.fb.control({ value: entity ? entity.routingKey : null, disabled: true }),
secret: this.fb.control({ value: entity ? entity.secret : null, disabled: true }),
additionalInfo: this.fb.group(
{
description: [entity && entity.additionalInfo ? entity.additionalInfo.description : '']
@ -85,6 +85,8 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
)
}
);
this.checkIsNewEdge(entity, form);
return form;
}
updateForm(entity: EdgeInfo) {
@ -100,6 +102,20 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
description: entity.additionalInfo ? entity.additionalInfo.description : ''
}
});
this.checkIsNewEdge(entity, this.entityForm);
}
updateFormState() {
super.updateFormState();
this.entityForm.get('routingKey').disable({ emitEvent: false });
this.entityForm.get('secret').disable({ emitEvent: false });
}
private checkIsNewEdge(entity: EdgeInfo, form: FormGroup) {
if (entity && !entity.id) {
form.get('routingKey').patchValue(guid(), { emitEvent: false });
form.get('secret').patchValue(this.generateSecret(20), { emitEvent: false });
}
}
onEdgeIdCopied($event) {

Loading…
Cancel
Save