Merge pull request #12685 from maxunbearable/feature/calculated-fields-adjustments-13-02
Calculated field adjustments
This commit is contained in:
commit
d65551cdaa
@ -280,7 +280,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
|
||||
filter(Boolean),
|
||||
tap(expression => {
|
||||
if (openCalculatedFieldEdit) {
|
||||
this.editCalculatedField({...calculatedField, configuration: {...calculatedField.configuration, expression } }, true)
|
||||
this.editCalculatedField({ entityId: this.entityId, ...calculatedField, configuration: {...calculatedField.configuration, expression } }, true)
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
@ -100,12 +100,22 @@
|
||||
[disableUndefinedCheck]="true"
|
||||
[scriptLanguage]="ScriptLanguage.TBEL"
|
||||
helpId="calculated-field/expression_fn"
|
||||
/>
|
||||
>
|
||||
<button toolbarSuffixButton
|
||||
mat-icon-button
|
||||
matTooltip="{{ 'common.test-function' | translate }}"
|
||||
matTooltipPosition="above"
|
||||
class="tb-mat-32"
|
||||
[disabled]="configFormGroup.get('expressionSCRIPT').invalid || configFormGroup.get('arguments').invalid"
|
||||
(click)="onTestScript()">
|
||||
<mat-icon class="material-icons" color="primary">bug_report</mat-icon>
|
||||
</button>
|
||||
</tb-js-func>
|
||||
<div>
|
||||
<button mat-button mat-raised-button color="primary"
|
||||
type="button"
|
||||
(click)="onTestScript()"
|
||||
[disabled]="configFormGroup.get('expressionSCRIPT').invalid || configFormGroup.get('arguments').invalid ">
|
||||
[disabled]="configFormGroup.get('expressionSCRIPT').invalid || configFormGroup.get('arguments').invalid">
|
||||
{{ 'common.test-function' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
@ -122,18 +132,17 @@
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
@if (outputFormGroup.get('type').value === OutputType.Attribute) {
|
||||
@if (outputFormGroup.get('type').value === OutputType.Attribute
|
||||
&& (data.entityId.entityType === EntityType.DEVICE || data.entityId.entityType === EntityType.DEVICE_PROFILE)) {
|
||||
<mat-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-label>{{ 'calculated-fields.attribute-scope' | translate }}</mat-label>
|
||||
<mat-select formControlName="scope" class="w-full">
|
||||
<mat-option [value]="AttributeScope.SERVER_SCOPE">
|
||||
{{ 'calculated-fields.server-attributes' | translate }}
|
||||
</mat-option>
|
||||
@if (data.entityId.entityType === EntityType.DEVICE) {
|
||||
<mat-option [value]="AttributeScope.SHARED_SCOPE">
|
||||
{{ 'calculated-fields.shared-attributes' | translate }}
|
||||
</mat-option>
|
||||
}
|
||||
<mat-option [value]="AttributeScope.SHARED_SCOPE">
|
||||
{{ 'calculated-fields.shared-attributes' | translate }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
}
|
||||
|
||||
@ -689,7 +689,7 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
|
||||
}
|
||||
|
||||
cellTooltip(entity: BaseData<HasId>, column: EntityColumn<BaseData<HasId>>, row: number) {
|
||||
if (column instanceof EntityTableColumn) {
|
||||
if (column instanceof EntityTableColumn || column instanceof EntityLinkTableColumn) {
|
||||
const col = this.entitiesTableConfig.columns.indexOf(column);
|
||||
const index = row * this.entitiesTableConfig.columns.length + col;
|
||||
let res = this.cellTooltipCache[index];
|
||||
|
||||
@ -18,6 +18,7 @@ import {
|
||||
CellActionDescriptorType,
|
||||
DateEntityTableColumn,
|
||||
EntityActionTableColumn,
|
||||
EntityLinkTableColumn,
|
||||
EntityTableColumn,
|
||||
EntityTableConfig
|
||||
} from '@home/models/entity/entities-table-config.models';
|
||||
@ -29,7 +30,7 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { EntityId } from '@shared/models/id/entity-id';
|
||||
import { EventService } from '@app/core/http/event.service';
|
||||
import { EventTableHeaderComponent } from '@home/components/event/event-table-header.component';
|
||||
import { EntityTypeResource } from '@shared/models/entity-type.models';
|
||||
import { EntityType, EntityTypeResource } from '@shared/models/entity-type.models';
|
||||
import { fromEvent, Observable } from 'rxjs';
|
||||
import { PageData } from '@shared/models/page/page-data';
|
||||
import { Direction } from '@shared/models/page/sort-order';
|
||||
@ -39,7 +40,7 @@ import {
|
||||
EventContentDialogComponent,
|
||||
EventContentDialogData
|
||||
} from '@home/components/event/event-content-dialog.component';
|
||||
import { isEqual, sortObjectKeys } from '@core/utils';
|
||||
import { getEntityDetailsPageURL, isEqual, sortObjectKeys } from '@core/utils';
|
||||
import { DAY, historyInterval, MINUTE } from '@shared/models/time/time.models';
|
||||
import { Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
||||
import { ChangeDetectorRef, EventEmitter, Injector, StaticProvider, ViewContainerRef } from '@angular/core';
|
||||
@ -359,13 +360,13 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
|
||||
this.columns[0].width = '80px';
|
||||
this.columns[1].width = '100px';
|
||||
this.columns.push(
|
||||
new EntityTableColumn<Event>('entityId', 'event.entity-id', '100px',
|
||||
new EntityLinkTableColumn<Event>('entityId', 'event.entity-id', '100px',
|
||||
(entity) => `<span style="display: inline-block; width: 9ch">${entity.body.entityId.substring(0, 8)}…</span>`,
|
||||
() => ({padding: '0 12px 0 0'}),
|
||||
(entity) => getEntityDetailsPageURL(entity.body.entityId, entity.body.entityType as EntityType),
|
||||
false,
|
||||
() => ({padding: '0 12px 0 0'}),
|
||||
() => undefined,
|
||||
false,
|
||||
() => ({padding: '0 12px 0 0'}),
|
||||
(entity) => entity.body.entityId,
|
||||
{
|
||||
name: this.translate.instant('event.copy-entity-id'),
|
||||
icon: 'content_paste',
|
||||
@ -384,7 +385,7 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
|
||||
() => ({padding: '0 12px 0 0'}),
|
||||
false,
|
||||
() => ({padding: '0 12px 0 0'}),
|
||||
() => undefined,
|
||||
(entity) => entity.body.msgId,
|
||||
false,
|
||||
{
|
||||
name: this.translate.instant('event.copy-message-id'),
|
||||
|
||||
@ -121,7 +121,11 @@ export class EntityLinkTableColumn<T extends BaseData<HasId>> extends BaseEntity
|
||||
public width: string = '0px',
|
||||
public cellContentFunction: CellContentFunction<T> = (entity, property) => entity[property] ? entity[property] : '',
|
||||
public entityURL: (entity) => string,
|
||||
public sortable: boolean = true) {
|
||||
public sortable: boolean = true,
|
||||
public cellStyleFunction: CellStyleFunction<T> = () => ({}),
|
||||
public headerCellStyleFunction: HeaderCellStyleFunction<T> = () => ({}),
|
||||
public cellTooltipFunction: CellTooltipFunction<T> = () => undefined,
|
||||
public actionCell: CellActionDescriptor<T> = null) {
|
||||
super('link', key, title, width, sortable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,6 +40,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</mat-tab>
|
||||
<mat-tab *ngIf="entity && authUser.authority === authorities.TENANT_ADMIN && !isEdit"
|
||||
label="{{ 'entity.type-calculated-fields' | translate }}" #calculatedFieldsTab="matTab">
|
||||
<tb-calculated-fields-table [active]="calculatedFieldsTab.isActive" [entityId]="entity.id" [entityName]="entity.name"/>
|
||||
</mat-tab>
|
||||
<mat-tab *ngIf="entity" #alarmRules="matTab"
|
||||
label="{{'device-profile.alarm-rules-with-count' | translate:
|
||||
{count: this.detailsForm.get('profileData.alarms').value?.length ? this.detailsForm.get('profileData.alarms').value.length : 0}
|
||||
@ -69,10 +73,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</mat-tab>
|
||||
<mat-tab *ngIf="entity && authUser.authority === authorities.TENANT_ADMIN && !isEdit"
|
||||
label="{{ 'entity.type-calculated-fields' | translate }}" #calculatedFieldsTab="matTab">
|
||||
<tb-calculated-fields-table [active]="calculatedFieldsTab.isActive" [entityId]="entity.id" [entityName]="entity.name"/>
|
||||
</mat-tab>
|
||||
<mat-tab *ngIf="entity && !isEdit" #auditLogsTab="matTab"
|
||||
label="{{ 'audit-log.audit-logs' | translate }}">
|
||||
<tb-audit-log-table detailsMode="true" [active]="auditLogsTab.isActive" [auditLogMode]="auditLogModes.ENTITY" [entityId]="entity.id"></tb-audit-log-table>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user