125 changed files with 2709 additions and 832 deletions
@ -0,0 +1,78 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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. |
|||
*/ |
|||
package org.thingsboard.server.actors.shared; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.thingsboard.server.actors.ActorSystemContext; |
|||
import org.thingsboard.server.actors.TbActor; |
|||
import org.thingsboard.server.actors.TbActorId; |
|||
import org.thingsboard.server.actors.TbStringActorId; |
|||
import org.thingsboard.server.actors.service.ContextAwareActor; |
|||
import org.thingsboard.server.actors.service.ContextBasedCreator; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.msg.TbActorMsg; |
|||
import org.thingsboard.server.common.msg.aware.RuleChainAwareMsg; |
|||
import org.thingsboard.server.common.msg.queue.RuleEngineException; |
|||
|
|||
import java.util.UUID; |
|||
|
|||
@Slf4j |
|||
public class RuleChainErrorActor extends ContextAwareActor { |
|||
|
|||
private final TenantId tenantId; |
|||
private final RuleEngineException error; |
|||
|
|||
private RuleChainErrorActor(ActorSystemContext systemContext, TenantId tenantId, RuleEngineException error) { |
|||
super(systemContext); |
|||
this.tenantId = tenantId; |
|||
this.error = error; |
|||
} |
|||
|
|||
@Override |
|||
protected boolean doProcess(TbActorMsg msg) { |
|||
if (msg instanceof RuleChainAwareMsg) { |
|||
log.debug("[{}] Reply with {} for message {}", tenantId, error.getMessage(), msg); |
|||
var rcMsg = (RuleChainAwareMsg) msg; |
|||
rcMsg.getMsg().getCallback().onFailure(error); |
|||
return true; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public static class ActorCreator extends ContextBasedCreator { |
|||
|
|||
private final TenantId tenantId; |
|||
private final RuleEngineException error; |
|||
|
|||
public ActorCreator(ActorSystemContext context, TenantId tenantId, RuleEngineException error) { |
|||
super(context); |
|||
this.tenantId = tenantId; |
|||
this.error = error; |
|||
} |
|||
|
|||
@Override |
|||
public TbActorId createActorId() { |
|||
return new TbStringActorId(UUID.randomUUID().toString()); |
|||
} |
|||
|
|||
@Override |
|||
public TbActor createActor() { |
|||
return new RuleChainErrorActor(context, tenantId, error); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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. |
|||
*/ |
|||
package org.thingsboard.server.cache.resourceInfo; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.EqualsAndHashCode; |
|||
import lombok.Getter; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.thingsboard.server.common.data.id.TbResourceId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Getter |
|||
@EqualsAndHashCode |
|||
@RequiredArgsConstructor |
|||
@Builder |
|||
public class ResourceInfoCacheKey implements Serializable { |
|||
|
|||
private final TenantId tenantId; |
|||
private final TbResourceId tbResourceId; |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return tenantId + "_" + tbResourceId; |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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. |
|||
*/ |
|||
package org.thingsboard.server.cache.resourceInfo; |
|||
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
|||
import org.springframework.cache.CacheManager; |
|||
import org.springframework.stereotype.Service; |
|||
import org.thingsboard.server.cache.CaffeineTbTransactionalCache; |
|||
import org.thingsboard.server.common.data.CacheConstants; |
|||
import org.thingsboard.server.common.data.TbResourceInfo; |
|||
|
|||
|
|||
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "caffeine", matchIfMissing = true) |
|||
@Service("ResourceInfoCache") |
|||
public class ResourceInfoCaffeineCache extends CaffeineTbTransactionalCache<ResourceInfoCacheKey, TbResourceInfo> { |
|||
|
|||
public ResourceInfoCaffeineCache(CacheManager cacheManager) { |
|||
super(cacheManager, CacheConstants.RESOURCE_INFO_CACHE); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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. |
|||
*/ |
|||
package org.thingsboard.server.cache.resourceInfo; |
|||
|
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.data.id.TbResourceId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
|
|||
@Data |
|||
public class ResourceInfoEvictEvent { |
|||
private final TenantId tenantId; |
|||
private final TbResourceId resourceId; |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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. |
|||
*/ |
|||
package org.thingsboard.server.cache.resourceInfo; |
|||
|
|||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
|||
import org.springframework.data.redis.connection.RedisConnectionFactory; |
|||
import org.springframework.stereotype.Service; |
|||
import org.thingsboard.server.cache.CacheSpecsMap; |
|||
import org.thingsboard.server.cache.RedisTbTransactionalCache; |
|||
import org.thingsboard.server.cache.TBRedisCacheConfiguration; |
|||
import org.thingsboard.server.cache.TbFSTRedisSerializer; |
|||
import org.thingsboard.server.common.data.CacheConstants; |
|||
import org.thingsboard.server.common.data.TbResourceInfo; |
|||
|
|||
@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis") |
|||
@Service("ResourceInfoCache") |
|||
public class ResourceInfoRedisCache extends RedisTbTransactionalCache<ResourceInfoCacheKey, TbResourceInfo> { |
|||
|
|||
public ResourceInfoRedisCache(TBRedisCacheConfiguration configuration, CacheSpecsMap cacheSpecsMap, RedisConnectionFactory connectionFactory) { |
|||
super(CacheConstants.RESOURCE_INFO_CACHE, cacheSpecsMap, connectionFactory, configuration, new TbFSTRedisSerializer<>()); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg; |
|||
|
|||
public interface TbActorError { |
|||
|
|||
boolean isUnrecoverable(); |
|||
|
|||
} |
|||
@ -1,2 +1,5 @@ |
|||
--PostgreSQL specific truncate to fit constraints |
|||
TRUNCATE TABLE device_credentials, device, device_profile, asset, asset_profile, ota_package, rule_node_state, rule_node, rule_chain, alarm_comment, alarm, entity_alarm; |
|||
TRUNCATE TABLE device_credentials, device, device_profile, asset, asset_profile, ota_package, rule_node_state, rule_node, rule_chain, alarm_comment, alarm, entity_alarm; |
|||
|
|||
-- Decrease seq_id column to make sure to cover cases of new sequential cycle during the tests |
|||
ALTER SEQUENCE edge_event_seq_id_seq MAXVALUE 256; |
|||
|
|||
@ -0,0 +1,61 @@ |
|||
/** |
|||
* Copyright © 2016-2023 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. |
|||
*/ |
|||
package org.thingsboard.rule.engine.external; |
|||
|
|||
import org.thingsboard.rule.engine.api.TbContext; |
|||
import org.thingsboard.rule.engine.api.TbNode; |
|||
import org.thingsboard.rule.engine.api.TbRelationTypes; |
|||
import org.thingsboard.server.common.msg.TbMsg; |
|||
|
|||
public abstract class TbAbstractExternalNode implements TbNode { |
|||
|
|||
private boolean forceAck; |
|||
|
|||
public void init(TbContext ctx) { |
|||
this.forceAck = ctx.isExternalNodeForceAck(); |
|||
} |
|||
|
|||
protected void tellSuccess(TbContext ctx, TbMsg tbMsg) { |
|||
if (forceAck) { |
|||
ctx.enqueueForTellNext(tbMsg.copyWithNewCtx(), TbRelationTypes.SUCCESS); |
|||
} else { |
|||
ctx.tellSuccess(tbMsg); |
|||
} |
|||
} |
|||
|
|||
protected void tellFailure(TbContext ctx, TbMsg tbMsg, Throwable t) { |
|||
if (forceAck) { |
|||
if (t == null) { |
|||
ctx.enqueueForTellNext(tbMsg.copyWithNewCtx(), TbRelationTypes.FAILURE); |
|||
} else { |
|||
ctx.enqueueForTellFailure(tbMsg.copyWithNewCtx(), t); |
|||
} |
|||
} else { |
|||
if (t == null) { |
|||
ctx.tellNext(tbMsg, TbRelationTypes.FAILURE); |
|||
} else { |
|||
ctx.tellFailure(tbMsg, t); |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected void ackIfNeeded(TbContext ctx, TbMsg msg) { |
|||
if (forceAck) { |
|||
ctx.ack(msg); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,94 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2023 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. |
|||
|
|||
--> |
|||
<ng-container [formGroup]="timeseriesTableWidgetConfigForm"> |
|||
<tb-timewindow-config-panel formControlName="timewindowConfig"> |
|||
</tb-timewindow-config-panel> |
|||
<tb-datasources |
|||
[configMode]="basicMode" |
|||
hideDataKeys |
|||
formControlName="datasources"> |
|||
</tb-datasources> |
|||
<tb-data-keys-panel |
|||
panelTitle="{{ 'widgets.table.columns' | translate }}" |
|||
addKeyTitle="{{ 'widgets.table.add-column' | translate }}" |
|||
keySettingsTitle="{{ 'widgets.table.column-settings' | translate }}" |
|||
removeKeyTitle="{{ 'widgets.table.remove-column' | translate }}" |
|||
noKeysText="{{ 'widgets.table.no-columns' | translate }}" |
|||
requiredKeysText="{{ 'widgets.table.timeseries-column-error' | translate }}" |
|||
hideDataKeyColor |
|||
[datasourceType]="datasource?.type" |
|||
[deviceId]="datasource?.deviceId" |
|||
[entityAliasId]="datasource?.entityAliasId" |
|||
formControlName="columns"> |
|||
</tb-data-keys-panel> |
|||
<div class="tb-widget-config-panel"> |
|||
<div class="tb-widget-config-panel-title" translate>widget-config.appearance</div> |
|||
<div class="tb-widget-config-row"> |
|||
<mat-slide-toggle class="mat-slide" formControlName="showTitle"> |
|||
{{ 'widget-config.card-title' | translate }} |
|||
</mat-slide-toggle> |
|||
<mat-form-field fxFlex appearance="outline" subscriptSizing="dynamic"> |
|||
<input matInput formControlName="title" placeholder="{{ 'widget-config.set' | translate }}"> |
|||
</mat-form-field> |
|||
</div> |
|||
<div class="tb-widget-config-row space-between same-padding"> |
|||
<mat-slide-toggle class="mat-slide" formControlName="showTitleIcon"> |
|||
{{ 'widget-config.card-icon' | translate }} |
|||
</mat-slide-toggle> |
|||
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="16px"> |
|||
<tb-material-icon-select asBoxInput |
|||
[color]="timeseriesTableWidgetConfigForm.get('iconColor').value" |
|||
formControlName="titleIcon"> |
|||
</tb-material-icon-select> |
|||
<mat-divider vertical></mat-divider> |
|||
<tb-color-input asBoxInput |
|||
formControlName="iconColor"> |
|||
</tb-color-input> |
|||
</div> |
|||
</div> |
|||
<div class="tb-widget-config-row space-between"> |
|||
<div translate>widgets.table.show-card-buttons</div> |
|||
<mat-chip-listbox multiple formControlName="cardButtons"> |
|||
<mat-chip-option value="search">{{ 'action.search' | translate }}</mat-chip-option> |
|||
<mat-chip-option value="columnsToDisplay">{{ 'widgets.table.columns-to-display' | translate }}</mat-chip-option> |
|||
<mat-chip-option value="fullscreen">{{ 'fullscreen.fullscreen' | translate }}</mat-chip-option> |
|||
</mat-chip-listbox> |
|||
</div> |
|||
<div class="tb-widget-config-row space-between same-padding"> |
|||
<div>{{ 'widget-config.text-color' | translate }}</div> |
|||
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="16px"> |
|||
<mat-divider vertical></mat-divider> |
|||
<tb-color-input asBoxInput |
|||
formControlName="color"> |
|||
</tb-color-input> |
|||
</div> |
|||
</div> |
|||
<div class="tb-widget-config-row space-between same-padding"> |
|||
<div>{{ 'widget-config.background-color' | translate }}</div> |
|||
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="16px"> |
|||
<mat-divider vertical></mat-divider> |
|||
<tb-color-input asBoxInput |
|||
formControlName="backgroundColor"> |
|||
</tb-color-input> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<tb-widget-actions-panel |
|||
formControlName="actions"> |
|||
</tb-widget-actions-panel> |
|||
</ng-container> |
|||
@ -0,0 +1,181 @@ |
|||
///
|
|||
/// Copyright © 2016-2023 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 } from '@angular/core'; |
|||
import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { BasicWidgetConfigComponent } from '@home/components/widget/config/widget-config.component.models'; |
|||
import { WidgetConfigComponentData } from '@home/models/widget-component.models'; |
|||
import { |
|||
DataKey, |
|||
Datasource, |
|||
datasourcesHasAggregation, |
|||
datasourcesHasOnlyComparisonAggregation, WidgetConfig |
|||
} from '@shared/models/widget.models'; |
|||
import { WidgetConfigComponent } from '@home/components/widget/widget-config.component'; |
|||
import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; |
|||
import { deepClone, isUndefined } from '@core/utils'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-timeseries-table-basic-config', |
|||
templateUrl: './timeseries-table-basic-config.component.html', |
|||
styleUrls: ['../basic-config.scss'] |
|||
}) |
|||
export class TimeseriesTableBasicConfigComponent extends BasicWidgetConfigComponent { |
|||
|
|||
public get datasource(): Datasource { |
|||
const datasources: Datasource[] = this.timeseriesTableWidgetConfigForm.get('datasources').value; |
|||
if (datasources && datasources.length) { |
|||
return datasources[0]; |
|||
} else { |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
timeseriesTableWidgetConfigForm: UntypedFormGroup; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
protected widgetConfigComponent: WidgetConfigComponent, |
|||
private fb: UntypedFormBuilder) { |
|||
super(store, widgetConfigComponent); |
|||
} |
|||
|
|||
protected configForm(): UntypedFormGroup { |
|||
return this.timeseriesTableWidgetConfigForm; |
|||
} |
|||
|
|||
protected setupDefaults(configData: WidgetConfigComponentData) { |
|||
this.setupDefaultDatasource(configData, |
|||
[{ name: 'temperature', label: 'Temperature', type: DataKeyType.timeseries, units: '°C', decimals: 0 }]); |
|||
} |
|||
|
|||
protected onConfigSet(configData: WidgetConfigComponentData) { |
|||
this.timeseriesTableWidgetConfigForm = this.fb.group({ |
|||
timewindowConfig: [{ |
|||
useDashboardTimewindow: configData.config.useDashboardTimewindow, |
|||
displayTimewindow: configData.config.displayTimewindow, |
|||
timewindow: configData.config.timewindow |
|||
}, []], |
|||
datasources: [configData.config.datasources, []], |
|||
columns: [this.getColumns(configData.config.datasources), []], |
|||
showTitle: [configData.config.showTitle, []], |
|||
title: [configData.config.title, []], |
|||
showTitleIcon: [configData.config.showTitleIcon, []], |
|||
titleIcon: [configData.config.titleIcon, []], |
|||
iconColor: [configData.config.iconColor, []], |
|||
cardButtons: [this.getCardButtons(configData.config), []], |
|||
color: [configData.config.color, []], |
|||
backgroundColor: [configData.config.backgroundColor, []], |
|||
actions: [configData.config.actions || {}, []] |
|||
}); |
|||
} |
|||
|
|||
protected prepareOutputConfig(config: any): WidgetConfigComponentData { |
|||
this.widgetConfig.config.useDashboardTimewindow = config.timewindowConfig.useDashboardTimewindow; |
|||
this.widgetConfig.config.displayTimewindow = config.timewindowConfig.displayTimewindow; |
|||
this.widgetConfig.config.timewindow = config.timewindowConfig.timewindow; |
|||
this.widgetConfig.config.datasources = config.datasources; |
|||
this.setColumns(config.columns, this.widgetConfig.config.datasources); |
|||
this.widgetConfig.config.actions = config.actions; |
|||
this.widgetConfig.config.showTitle = config.showTitle; |
|||
this.widgetConfig.config.settings = this.widgetConfig.config.settings || {}; |
|||
this.widgetConfig.config.settings.entitiesTitle = config.title; |
|||
this.widgetConfig.config.showTitleIcon = config.showTitleIcon; |
|||
this.widgetConfig.config.titleIcon = config.titleIcon; |
|||
this.widgetConfig.config.iconColor = config.iconColor; |
|||
this.setCardButtons(config.cardButtons, this.widgetConfig.config); |
|||
this.widgetConfig.config.color = config.color; |
|||
this.widgetConfig.config.backgroundColor = config.backgroundColor; |
|||
return this.widgetConfig; |
|||
} |
|||
|
|||
protected validatorTriggers(): string[] { |
|||
return ['showTitle', 'showTitleIcon']; |
|||
} |
|||
|
|||
protected updateValidators(emitEvent: boolean, trigger?: string) { |
|||
const showTitle: boolean = this.timeseriesTableWidgetConfigForm.get('showTitle').value; |
|||
const showTitleIcon: boolean = this.timeseriesTableWidgetConfigForm.get('showTitleIcon').value; |
|||
if (showTitle) { |
|||
this.timeseriesTableWidgetConfigForm.get('title').enable(); |
|||
this.timeseriesTableWidgetConfigForm.get('showTitleIcon').enable({emitEvent: false}); |
|||
if (showTitleIcon) { |
|||
this.timeseriesTableWidgetConfigForm.get('titleIcon').enable(); |
|||
this.timeseriesTableWidgetConfigForm.get('iconColor').enable(); |
|||
} else { |
|||
this.timeseriesTableWidgetConfigForm.get('titleIcon').disable(); |
|||
this.timeseriesTableWidgetConfigForm.get('iconColor').disable(); |
|||
} |
|||
} else { |
|||
this.timeseriesTableWidgetConfigForm.get('title').disable(); |
|||
this.timeseriesTableWidgetConfigForm.get('showTitleIcon').disable({emitEvent: false}); |
|||
this.timeseriesTableWidgetConfigForm.get('titleIcon').disable(); |
|||
this.timeseriesTableWidgetConfigForm.get('iconColor').disable(); |
|||
} |
|||
this.timeseriesTableWidgetConfigForm.get('title').updateValueAndValidity({emitEvent}); |
|||
this.timeseriesTableWidgetConfigForm.get('showTitleIcon').updateValueAndValidity({emitEvent: false}); |
|||
this.timeseriesTableWidgetConfigForm.get('titleIcon').updateValueAndValidity({emitEvent}); |
|||
this.timeseriesTableWidgetConfigForm.get('iconColor').updateValueAndValidity({emitEvent}); |
|||
} |
|||
|
|||
private getColumns(datasources?: Datasource[]): DataKey[] { |
|||
if (datasources && datasources.length) { |
|||
const dataKeys = deepClone(datasources[0].dataKeys) || []; |
|||
dataKeys.forEach(k => { |
|||
(k as any).latest = false; |
|||
}); |
|||
const latestDataKeys = deepClone(datasources[0].latestDataKeys) || []; |
|||
latestDataKeys.forEach(k => { |
|||
(k as any).latest = true; |
|||
}); |
|||
return dataKeys.concat(latestDataKeys); |
|||
} |
|||
return []; |
|||
} |
|||
|
|||
private setColumns(columns: DataKey[], datasources?: Datasource[]) { |
|||
if (datasources && datasources.length) { |
|||
const dataKeys = deepClone(columns.filter(c => !(c as any).latest)); |
|||
dataKeys.forEach(k => delete (k as any).latest); |
|||
const latestDataKeys = deepClone(columns.filter(c => (c as any).latest)); |
|||
latestDataKeys.forEach(k => delete (k as any).latest); |
|||
datasources[0].dataKeys = dataKeys; |
|||
datasources[0].latestDataKeys = latestDataKeys; |
|||
} |
|||
} |
|||
|
|||
private getCardButtons(config: WidgetConfig): string[] { |
|||
const buttons: string[] = []; |
|||
if (isUndefined(config.settings?.enableSearch) || config.settings?.enableSearch) { |
|||
buttons.push('search'); |
|||
} |
|||
if (isUndefined(config.settings?.enableSelectColumnDisplay) || config.settings?.enableSelectColumnDisplay) { |
|||
buttons.push('columnsToDisplay'); |
|||
} |
|||
if (isUndefined(config.enableFullscreen) || config.enableFullscreen) { |
|||
buttons.push('fullscreen'); |
|||
} |
|||
return buttons; |
|||
} |
|||
|
|||
private setCardButtons(buttons: string[], config: WidgetConfig) { |
|||
config.settings.enableSearch = buttons.includes('search'); |
|||
config.settings.enableSelectColumnDisplay = buttons.includes('columnsToDisplay'); |
|||
config.enableFullscreen = buttons.includes('fullscreen'); |
|||
} |
|||
|
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue