Browse Source
- TbIotHubSelectCfEntityDialogComponent: small reusable dialog mirroring the install dialog's select-entity state (Title + select-entity-for-cf description + tb-entity-select over DEVICE/ASSET/DEVICE_PROFILE/ ASSET_PROFILE, default DEVICE_PROFILE). - TbIotHubAddItemDialogComponent.onAddItem: when itemType === CALCULATED_FIELD and no parent entityId is supplied, open the new dialog and pass the chosen EntityId into installItemVersion. installItem() extracted as a shared helper. - Open-installed-CF flow now uses the descriptor's calculatedFieldId + EntityType.CALCULATED_FIELD (in installed-items-table and detail dialog), and registers /calculatedFields in baseDetailsPageByEntityType so the link resolves.pull/15548/head
7 changed files with 133 additions and 9 deletions
@ -0,0 +1,35 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2026 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. |
|||
|
|||
--> |
|||
<div class="flex flex-col gap-5 p-6"> |
|||
<h2 class="tb-iot-hub-install-title">{{ 'iot-hub.install-confirm-title' | translate:{ name: data.itemName } }}</h2> |
|||
<p class="tb-iot-hub-install-desc">{{ 'iot-hub.select-entity-for-cf' | translate:{ name: data.itemName } }}</p> |
|||
<tb-entity-select |
|||
[(ngModel)]="selectedEntityId" |
|||
[allowedEntityTypes]="cfEntityTypes" |
|||
[defaultEntityType]="defaultCfEntityType" |
|||
[filterAllowedEntityTypes]="false" |
|||
appearance="outline" |
|||
required> |
|||
</tb-entity-select> |
|||
</div> |
|||
<mat-dialog-actions align="end"> |
|||
<button mat-button (click)="cancel()">{{ 'action.cancel' | translate }}</button> |
|||
<button mat-flat-button color="primary" [disabled]="!selectedEntityId" (click)="confirm()"> |
|||
{{ 'iot-hub.install' | translate }} |
|||
</button> |
|||
</mat-dialog-actions> |
|||
@ -0,0 +1,61 @@ |
|||
///
|
|||
/// Copyright © 2016-2026 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.
|
|||
///
|
|||
|
|||
import { Component, Inject } from '@angular/core'; |
|||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|||
import { Router } from '@angular/router'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { DialogComponent } from '@shared/components/dialog.component'; |
|||
import { EntityType } from '@shared/models/entity-type.models'; |
|||
import { EntityId } from '@shared/models/id/entity-id'; |
|||
|
|||
export interface IotHubSelectCfEntityDialogData { |
|||
itemName: string; |
|||
} |
|||
|
|||
@Component({ |
|||
selector: 'tb-iot-hub-select-cf-entity-dialog', |
|||
standalone: false, |
|||
templateUrl: './iot-hub-select-cf-entity-dialog.component.html', |
|||
styleUrls: ['./iot-hub-install-dialog.component.scss'] |
|||
}) |
|||
export class TbIotHubSelectCfEntityDialogComponent |
|||
extends DialogComponent<TbIotHubSelectCfEntityDialogComponent, EntityId | null> { |
|||
|
|||
selectedEntityId: EntityId | null = null; |
|||
cfEntityTypes: EntityType[] = [EntityType.DEVICE, EntityType.ASSET, EntityType.DEVICE_PROFILE, EntityType.ASSET_PROFILE]; |
|||
defaultCfEntityType = EntityType.DEVICE_PROFILE; |
|||
|
|||
constructor( |
|||
protected store: Store<AppState>, |
|||
protected router: Router, |
|||
protected dialogRef: MatDialogRef<TbIotHubSelectCfEntityDialogComponent, EntityId | null>, |
|||
@Inject(MAT_DIALOG_DATA) public data: IotHubSelectCfEntityDialogData |
|||
) { |
|||
super(store, router, dialogRef); |
|||
} |
|||
|
|||
cancel(): void { |
|||
this.dialogRef.close(null); |
|||
} |
|||
|
|||
confirm(): void { |
|||
if (this.selectedEntityId) { |
|||
this.dialogRef.close(this.selectedEntityId); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue