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),
|
filter(Boolean),
|
||||||
tap(expression => {
|
tap(expression => {
|
||||||
if (openCalculatedFieldEdit) {
|
if (openCalculatedFieldEdit) {
|
||||||
this.editCalculatedField({...calculatedField, configuration: {...calculatedField.configuration, expression } }, true)
|
this.editCalculatedField({ entityId: this.entityId, ...calculatedField, configuration: {...calculatedField.configuration, expression } }, true)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -100,7 +100,17 @@
|
|||||||
[disableUndefinedCheck]="true"
|
[disableUndefinedCheck]="true"
|
||||||
[scriptLanguage]="ScriptLanguage.TBEL"
|
[scriptLanguage]="ScriptLanguage.TBEL"
|
||||||
helpId="calculated-field/expression_fn"
|
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>
|
<div>
|
||||||
<button mat-button mat-raised-button color="primary"
|
<button mat-button mat-raised-button color="primary"
|
||||||
type="button"
|
type="button"
|
||||||
@ -122,18 +132,17 @@
|
|||||||
}
|
}
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</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-form-field class="flex-1" appearance="outline" subscriptSizing="dynamic">
|
||||||
<mat-label>{{ 'calculated-fields.attribute-scope' | translate }}</mat-label>
|
<mat-label>{{ 'calculated-fields.attribute-scope' | translate }}</mat-label>
|
||||||
<mat-select formControlName="scope" class="w-full">
|
<mat-select formControlName="scope" class="w-full">
|
||||||
<mat-option [value]="AttributeScope.SERVER_SCOPE">
|
<mat-option [value]="AttributeScope.SERVER_SCOPE">
|
||||||
{{ 'calculated-fields.server-attributes' | translate }}
|
{{ 'calculated-fields.server-attributes' | translate }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
@if (data.entityId.entityType === EntityType.DEVICE) {
|
|
||||||
<mat-option [value]="AttributeScope.SHARED_SCOPE">
|
<mat-option [value]="AttributeScope.SHARED_SCOPE">
|
||||||
{{ 'calculated-fields.shared-attributes' | translate }}
|
{{ 'calculated-fields.shared-attributes' | translate }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
}
|
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -689,7 +689,7 @@ export class EntitiesTableComponent extends PageComponent implements IEntitiesTa
|
|||||||
}
|
}
|
||||||
|
|
||||||
cellTooltip(entity: BaseData<HasId>, column: EntityColumn<BaseData<HasId>>, row: number) {
|
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 col = this.entitiesTableConfig.columns.indexOf(column);
|
||||||
const index = row * this.entitiesTableConfig.columns.length + col;
|
const index = row * this.entitiesTableConfig.columns.length + col;
|
||||||
let res = this.cellTooltipCache[index];
|
let res = this.cellTooltipCache[index];
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import {
|
|||||||
CellActionDescriptorType,
|
CellActionDescriptorType,
|
||||||
DateEntityTableColumn,
|
DateEntityTableColumn,
|
||||||
EntityActionTableColumn,
|
EntityActionTableColumn,
|
||||||
|
EntityLinkTableColumn,
|
||||||
EntityTableColumn,
|
EntityTableColumn,
|
||||||
EntityTableConfig
|
EntityTableConfig
|
||||||
} from '@home/models/entity/entities-table-config.models';
|
} 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 { EntityId } from '@shared/models/id/entity-id';
|
||||||
import { EventService } from '@app/core/http/event.service';
|
import { EventService } from '@app/core/http/event.service';
|
||||||
import { EventTableHeaderComponent } from '@home/components/event/event-table-header.component';
|
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 { fromEvent, Observable } from 'rxjs';
|
||||||
import { PageData } from '@shared/models/page/page-data';
|
import { PageData } from '@shared/models/page/page-data';
|
||||||
import { Direction } from '@shared/models/page/sort-order';
|
import { Direction } from '@shared/models/page/sort-order';
|
||||||
@ -39,7 +40,7 @@ import {
|
|||||||
EventContentDialogComponent,
|
EventContentDialogComponent,
|
||||||
EventContentDialogData
|
EventContentDialogData
|
||||||
} from '@home/components/event/event-content-dialog.component';
|
} 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 { DAY, historyInterval, MINUTE } from '@shared/models/time/time.models';
|
||||||
import { Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
import { Overlay, OverlayConfig, OverlayRef } from '@angular/cdk/overlay';
|
||||||
import { ChangeDetectorRef, EventEmitter, Injector, StaticProvider, ViewContainerRef } from '@angular/core';
|
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[0].width = '80px';
|
||||||
this.columns[1].width = '100px';
|
this.columns[1].width = '100px';
|
||||||
this.columns.push(
|
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>`,
|
(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,
|
false,
|
||||||
() => ({padding: '0 12px 0 0'}),
|
() => ({padding: '0 12px 0 0'}),
|
||||||
() => undefined,
|
() => ({padding: '0 12px 0 0'}),
|
||||||
false,
|
(entity) => entity.body.entityId,
|
||||||
{
|
{
|
||||||
name: this.translate.instant('event.copy-entity-id'),
|
name: this.translate.instant('event.copy-entity-id'),
|
||||||
icon: 'content_paste',
|
icon: 'content_paste',
|
||||||
@ -384,7 +385,7 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
|
|||||||
() => ({padding: '0 12px 0 0'}),
|
() => ({padding: '0 12px 0 0'}),
|
||||||
false,
|
false,
|
||||||
() => ({padding: '0 12px 0 0'}),
|
() => ({padding: '0 12px 0 0'}),
|
||||||
() => undefined,
|
(entity) => entity.body.msgId,
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
name: this.translate.instant('event.copy-message-id'),
|
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 width: string = '0px',
|
||||||
public cellContentFunction: CellContentFunction<T> = (entity, property) => entity[property] ? entity[property] : '',
|
public cellContentFunction: CellContentFunction<T> = (entity, property) => entity[property] ? entity[property] : '',
|
||||||
public entityURL: (entity) => string,
|
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);
|
super('link', key, title, width, sortable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-tab>
|
</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"
|
<mat-tab *ngIf="entity" #alarmRules="matTab"
|
||||||
label="{{'device-profile.alarm-rules-with-count' | translate:
|
label="{{'device-profile.alarm-rules-with-count' | translate:
|
||||||
{count: this.detailsForm.get('profileData.alarms').value?.length ? this.detailsForm.get('profileData.alarms').value.length : 0}
|
{count: this.detailsForm.get('profileData.alarms').value?.length ? this.detailsForm.get('profileData.alarms').value.length : 0}
|
||||||
@ -69,10 +73,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-tab>
|
</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"
|
<mat-tab *ngIf="entity && !isEdit" #auditLogsTab="matTab"
|
||||||
label="{{ 'audit-log.audit-logs' | translate }}">
|
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>
|
<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