Commit c3e1eee6c9ee8e8ac956791d28b3db980bd241a6
1 parent
aa947644
Fixed createdTime storage. Fixed copy edge secret and key button
Showing
3 changed files
with
64 additions
and
52 deletions
@@ -98,6 +98,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T | @@ -98,6 +98,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T | ||
98 | if (edge.getId() != null) { | 98 | if (edge.getId() != null) { |
99 | this.setUuid(edge.getId().getId()); | 99 | this.setUuid(edge.getId().getId()); |
100 | } | 100 | } |
101 | + this.setCreatedTime(edge.getCreatedTime()); | ||
101 | if (edge.getTenantId() != null) { | 102 | if (edge.getTenantId() != null) { |
102 | this.tenantId = edge.getTenantId().getId(); | 103 | this.tenantId = edge.getTenantId().getId(); |
103 | } | 104 | } |
@@ -119,6 +120,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T | @@ -119,6 +120,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T | ||
119 | 120 | ||
120 | public AbstractEdgeEntity(EdgeEntity edgeEntity) { | 121 | public AbstractEdgeEntity(EdgeEntity edgeEntity) { |
121 | this.setId(edgeEntity.getId()); | 122 | this.setId(edgeEntity.getId()); |
123 | + this.setCreatedTime(edgeEntity.getCreatedTime()); | ||
122 | this.tenantId = edgeEntity.getTenantId(); | 124 | this.tenantId = edgeEntity.getTenantId(); |
123 | this.customerId = edgeEntity.getCustomerId(); | 125 | this.customerId = edgeEntity.getCustomerId(); |
124 | this.rootRuleChainId = edgeEntity.getRootRuleChainId(); | 126 | this.rootRuleChainId = edgeEntity.getRootRuleChainId(); |
@@ -149,7 +151,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T | @@ -149,7 +151,7 @@ public abstract class AbstractEdgeEntity<T extends Edge> extends BaseSqlEntity<T | ||
149 | 151 | ||
150 | protected Edge toEdge() { | 152 | protected Edge toEdge() { |
151 | Edge edge = new Edge(new EdgeId(getUuid())); | 153 | Edge edge = new Edge(new EdgeId(getUuid())); |
152 | - edge.setCreatedTime(Uuids.unixTimestamp(getUuid())); | 154 | + edge.setCreatedTime(createdTime); |
153 | if (tenantId != null) { | 155 | if (tenantId != null) { |
154 | edge.setTenantId(new TenantId(tenantId)); | 156 | edge.setTenantId(new TenantId(tenantId)); |
155 | } | 157 | } |
@@ -132,56 +132,50 @@ | @@ -132,56 +132,50 @@ | ||
132 | [required]="true" | 132 | [required]="true" |
133 | [entityType]="entityType.EDGE"> | 133 | [entityType]="entityType.EDGE"> |
134 | </tb-entity-subtype-autocomplete> | 134 | </tb-entity-subtype-autocomplete> |
135 | - <div fxLayout="row" [fxShow]="edgeScope === 'tenant'"> | ||
136 | - <fieldset fxFlex> | ||
137 | - <div class="tb-hint" [innerHTML]="'edge.edge-license-key-hint' | translate"></div> | ||
138 | - <mat-form-field class="mat-block"> | ||
139 | - <mat-label translate>edge.edge-license-key</mat-label> | ||
140 | - <input matInput formControlName="edgeLicenseKey" required> | ||
141 | - <mat-error *ngIf="entityForm.get('edgeLicenseKey').hasError('required')"> | ||
142 | - {{ 'edge.edge-license-key-required' | translate }} | ||
143 | - </mat-error> | ||
144 | - </mat-form-field> | ||
145 | - </fieldset> | ||
146 | - </div> | ||
147 | - <div fxLayout="row" [fxShow]="edgeScope === 'tenant'"> | ||
148 | - <fieldset fxFlex> | ||
149 | - <div translate class="tb-hint">edge.cloud-endpoint-hint</div> | ||
150 | - <mat-form-field class="mat-block"> | ||
151 | - <mat-label translate>edge.cloud-endpoint</mat-label> | ||
152 | - <input matInput formControlName="cloudEndpoint" required> | ||
153 | - <mat-error *ngIf="entityForm.get('cloudEndpoint').hasError('required')"> | ||
154 | - {{ 'edge.cloud-endpoint-required' | translate }} | ||
155 | - </mat-error> | ||
156 | - </mat-form-field> | ||
157 | - </fieldset> | ||
158 | - </div> | ||
159 | - <div fxLayout="row" [fxShow]="edgeScope === 'tenant'"> | ||
160 | - <fieldset fxFlex disabled> | ||
161 | - <mat-form-field class="mat-block" fxFlex> | ||
162 | - <mat-label translate>edge.edge-key</mat-label> | ||
163 | - <input matInput formControlName="routingKey"> | ||
164 | - </mat-form-field> | ||
165 | - </fieldset> | ||
166 | - <button mat-button mat-icon-button type="button" ngxClipboard (cbOnSuccess)="onEdgeInfoCopied('key')" | ||
167 | - [cbContent]="entityForm?.get('routingKey').value" | ||
168 | - matTooltip="{{'edge.copy-edge-key' | translate}}"> | ||
169 | - <mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon> | ||
170 | - </button> | 135 | + <div [fxShow]="edgeScope === 'tenant'"> |
136 | + <div class="tb-hint" [innerHTML]="'edge.edge-license-key-hint' | translate"></div> | ||
137 | + <mat-form-field class="mat-block"> | ||
138 | + <mat-label translate>edge.edge-license-key</mat-label> | ||
139 | + <input matInput formControlName="edgeLicenseKey" required> | ||
140 | + <mat-error *ngIf="entityForm.get('edgeLicenseKey').hasError('required')"> | ||
141 | + {{ 'edge.edge-license-key-required' | translate }} | ||
142 | + </mat-error> | ||
143 | + </mat-form-field> | ||
171 | </div> | 144 | </div> |
172 | - <div fxLayout="row" [fxShow]="edgeScope === 'tenant'"> | ||
173 | - <fieldset fxFlex disabled> | ||
174 | - <mat-form-field class="mat-block" fxFlex> | ||
175 | - <mat-label translate>edge.edge-secret</mat-label> | ||
176 | - <input matInput formControlName="secret"> | ||
177 | - </mat-form-field> | ||
178 | - </fieldset> | ||
179 | - <button mat-button mat-icon-button type="button" ngxClipboard (cbOnSuccess)="onEdgeInfoCopied('secret')" | ||
180 | - [cbContent]="entityForm?.get('secret').value" | ||
181 | - matTooltip="{{'edge.copy-edge-secret' | translate}}"> | ||
182 | - <mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon> | ||
183 | - </button> | 145 | + <div [fxShow]="edgeScope === 'tenant'"> |
146 | + <div translate class="tb-hint">edge.cloud-endpoint-hint</div> | ||
147 | + <mat-form-field class="mat-block"> | ||
148 | + <mat-label translate>edge.cloud-endpoint</mat-label> | ||
149 | + <input matInput formControlName="cloudEndpoint" required> | ||
150 | + <mat-error *ngIf="entityForm.get('cloudEndpoint').hasError('required')"> | ||
151 | + {{ 'edge.cloud-endpoint-required' | translate }} | ||
152 | + </mat-error> | ||
153 | + </mat-form-field> | ||
184 | </div> | 154 | </div> |
155 | + </fieldset> | ||
156 | + <div fxLayout="row" [fxShow]="edgeScope === 'tenant'"> | ||
157 | + <mat-form-field class="mat-block" fxFlex> | ||
158 | + <mat-label translate>edge.edge-key</mat-label> | ||
159 | + <input matInput formControlName="routingKey"> | ||
160 | + </mat-form-field> | ||
161 | + <button mat-button mat-icon-button type="button" ngxClipboard (cbOnSuccess)="onEdgeInfoCopied('key')" | ||
162 | + [cbContent]="entityForm?.get('routingKey').value" | ||
163 | + matTooltip="{{'edge.copy-edge-key' | translate}}"> | ||
164 | + <mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon> | ||
165 | + </button> | ||
166 | + </div> | ||
167 | + <div fxLayout="row" [fxShow]="edgeScope === 'tenant'"> | ||
168 | + <mat-form-field class="mat-block" fxFlex> | ||
169 | + <mat-label translate>edge.edge-secret</mat-label> | ||
170 | + <input matInput formControlName="secret"> | ||
171 | + </mat-form-field> | ||
172 | + <button mat-button mat-icon-button type="button" ngxClipboard (cbOnSuccess)="onEdgeInfoCopied('secret')" | ||
173 | + [cbContent]="entityForm?.get('secret').value" | ||
174 | + matTooltip="{{'edge.copy-edge-secret' | translate}}"> | ||
175 | + <mat-icon svgIcon="mdi:clipboard-arrow-left"></mat-icon> | ||
176 | + </button> | ||
177 | + </div> | ||
178 | + <fieldset [disabled]="(isLoading$ | async) || !isEdit"> | ||
185 | <mat-form-field class="mat-block"> | 179 | <mat-form-field class="mat-block"> |
186 | <mat-label translate>edge.label</mat-label> | 180 | <mat-label translate>edge.label</mat-label> |
187 | <input matInput formControlName="label"> | 181 | <input matInput formControlName="label"> |
@@ -69,15 +69,15 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> { | @@ -69,15 +69,15 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> { | ||
69 | } | 69 | } |
70 | 70 | ||
71 | buildForm(entity: EdgeInfo): FormGroup { | 71 | buildForm(entity: EdgeInfo): FormGroup { |
72 | - return this.fb.group( | 72 | + const form = this.fb.group( |
73 | { | 73 | { |
74 | name: [entity ? entity.name : '', [Validators.required]], | 74 | name: [entity ? entity.name : '', [Validators.required]], |
75 | type: [entity?.type ? entity.type : 'default', [Validators.required]], | 75 | type: [entity?.type ? entity.type : 'default', [Validators.required]], |
76 | label: [entity ? entity.label : ''], | 76 | label: [entity ? entity.label : ''], |
77 | cloudEndpoint: [null, [Validators.required]], | 77 | cloudEndpoint: [null, [Validators.required]], |
78 | edgeLicenseKey: ['', [Validators.required]], | 78 | edgeLicenseKey: ['', [Validators.required]], |
79 | - routingKey: guid(), | ||
80 | - secret: this.generateSecret(20), | 79 | + routingKey: this.fb.control({ value: entity ? entity.routingKey : null, disabled: true }), |
80 | + secret: this.fb.control({ value: entity ? entity.secret : null, disabled: true }), | ||
81 | additionalInfo: this.fb.group( | 81 | additionalInfo: this.fb.group( |
82 | { | 82 | { |
83 | description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''] | 83 | description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''] |
@@ -85,6 +85,8 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> { | @@ -85,6 +85,8 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> { | ||
85 | ) | 85 | ) |
86 | } | 86 | } |
87 | ); | 87 | ); |
88 | + this.checkIsNewEdge(entity, form); | ||
89 | + return form; | ||
88 | } | 90 | } |
89 | 91 | ||
90 | updateForm(entity: EdgeInfo) { | 92 | updateForm(entity: EdgeInfo) { |
@@ -100,6 +102,20 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> { | @@ -100,6 +102,20 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> { | ||
100 | description: entity.additionalInfo ? entity.additionalInfo.description : '' | 102 | description: entity.additionalInfo ? entity.additionalInfo.description : '' |
101 | } | 103 | } |
102 | }); | 104 | }); |
105 | + this.checkIsNewEdge(entity, this.entityForm); | ||
106 | + } | ||
107 | + | ||
108 | + updateFormState() { | ||
109 | + super.updateFormState(); | ||
110 | + this.entityForm.get('routingKey').disable({ emitEvent: false }); | ||
111 | + this.entityForm.get('secret').disable({ emitEvent: false }); | ||
112 | + } | ||
113 | + | ||
114 | + private checkIsNewEdge(entity: EdgeInfo, form: FormGroup) { | ||
115 | + if (entity && !entity.id) { | ||
116 | + form.get('routingKey').patchValue(guid(), { emitEvent: false }); | ||
117 | + form.get('secret').patchValue(this.generateSecret(20), { emitEvent: false }); | ||
118 | + } | ||
103 | } | 119 | } |
104 | 120 | ||
105 | onEdgeIdCopied($event) { | 121 | onEdgeIdCopied($event) { |