UI: Aggregated value card

This commit is contained in:
Igor Kulikov 2023-08-15 17:39:14 +03:00
parent 95f07b3994
commit 943788f25e
8 changed files with 50 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -33,7 +33,7 @@ import {
ComparisonResultType, ComparisonResultType,
DataKey, DataKey,
DataKeyConfigMode, DataKeyConfigMode,
DatasourceType, DatasourceType, Widget,
widgetType widgetType
} from '@shared/models/widget.models'; } from '@shared/models/widget.models';
import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
@ -100,6 +100,10 @@ export class AggregatedDataKeyRowComponent implements ControlValueAccessor, OnIn
return this.widgetConfigComponent.widgetConfigCallbacks; return this.widgetConfigComponent.widgetConfigCallbacks;
} }
get widget(): Widget {
return this.widgetConfigComponent.widget;
}
get isEntityDatasource(): boolean { get isEntityDatasource(): boolean {
return [DatasourceType.device, DatasourceType.entity].includes(this.datasourceType); return [DatasourceType.device, DatasourceType.entity].includes(this.datasourceType);
} }
@ -190,7 +194,7 @@ export class AggregatedDataKeyRowComponent implements ControlValueAccessor, OnIn
dataKeySettingsDirective: null, dataKeySettingsDirective: null,
dashboard: null, dashboard: null,
aliasController: null, aliasController: null,
widget: null, widget: this.widget,
widgetType: widgetType.latest, widgetType: widgetType.latest,
deviceId: null, deviceId: null,
entityAliasId: null, entityAliasId: null,

View File

@ -28,8 +28,7 @@
<div class="tb-form-table-header-cell tb-actions-header"></div> <div class="tb-form-table-header-cell tb-actions-header"></div>
</div> </div>
<div *ngIf="keysFormArray().controls.length; else noKeys" class="tb-form-table-body"> <div *ngIf="keysFormArray().controls.length; else noKeys" class="tb-form-table-body">
<div class="tb-form-table-row" <div *ngFor="let keyControl of keysFormArray().controls; trackBy: trackByKey; let $index = index;">
*ngFor="let keyControl of keysFormArray().controls; trackBy: trackByKey; let $index = index;">
<tb-aggregated-data-key-row fxFlex <tb-aggregated-data-key-row fxFlex
[formControl]="keyControl" [formControl]="keyControl"
[datasourceType]="datasourceType" [datasourceType]="datasourceType"

View File

@ -112,6 +112,8 @@ export class AggregatedValueCardBasicConfigComponent extends BasicWidgetConfigCo
protected onConfigSet(configData: WidgetConfigComponentData) { protected onConfigSet(configData: WidgetConfigComponentData) {
const settings: AggregatedValueCardWidgetSettings = {...aggregatedValueCardDefaultSettings, ...(configData.config.settings || {})}; const settings: AggregatedValueCardWidgetSettings = {...aggregatedValueCardDefaultSettings, ...(configData.config.settings || {})};
const dataKey = getDataKey(configData.config.datasources);
const keyName = dataKey?.name;
const iconSize = resolveCssSize(configData.config.iconSize); const iconSize = resolveCssSize(configData.config.iconSize);
this.aggregatedValueCardWidgetConfigForm = this.fb.group({ this.aggregatedValueCardWidgetConfigForm = this.fb.group({
timewindowConfig: [getTimewindowConfig(configData.config), []], timewindowConfig: [getTimewindowConfig(configData.config), []],
@ -141,7 +143,7 @@ export class AggregatedValueCardBasicConfigComponent extends BasicWidgetConfigCo
showChart: [settings.showChart, []], showChart: [settings.showChart, []],
chartColor: [settings.chartColor, []], chartColor: [settings.chartColor, []],
values: [this.getValues(configData.config.datasources), []], values: [this.getValues(configData.config.datasources, keyName), []],
background: [settings.background, []], background: [settings.background, []],
@ -257,9 +259,9 @@ export class AggregatedValueCardBasicConfigComponent extends BasicWidgetConfigCo
} }
} }
private getValues(datasources?: Datasource[]): DataKey[] { private getValues(datasources: Datasource[], keyName: string): DataKey[] {
if (datasources && datasources.length) { if (datasources && datasources.length) {
return datasources[0].latestDataKeys || []; return (datasources[0].latestDataKeys || []).filter(k => k.name === keyName);
} }
return []; return [];
} }

View File

@ -15,7 +15,7 @@
limitations under the License. limitations under the License.
--> -->
<div [formGroup]="keyRowFormGroup" class="tb-form-table-row tb-data-key-row no-padding-right"> <div [formGroup]="keyRowFormGroup" class="tb-form-table-row tb-data-key-row">
<mat-form-field *ngIf="hasAdditionalLatestDataKeys" class="tb-inline-field tb-source-field" appearance="outline" subscriptSizing="dynamic"> <mat-form-field *ngIf="hasAdditionalLatestDataKeys" class="tb-inline-field tb-source-field" appearance="outline" subscriptSizing="dynamic">
<mat-select formControlName="latest"> <mat-select formControlName="latest">
<mat-option [value]="false">{{ 'datakey.timeseries' | translate }}</mat-option> <mat-option [value]="false">{{ 'datakey.timeseries' | translate }}</mat-option>

View File

@ -32,7 +32,7 @@
[cdkDropListDisabled]="!dragEnabled" [cdkDropListDisabled]="!dragEnabled"
(cdkDropListDropped)="keyDrop($event)"> (cdkDropListDropped)="keyDrop($event)">
<div cdkDrag [cdkDragDisabled]="!dragEnabled" <div cdkDrag [cdkDragDisabled]="!dragEnabled"
class="tb-form-table-row tb-draggable no-padding-right" class="tb-draggable-form-table-row"
*ngFor="let keyControl of keysFormArray().controls; trackBy: trackByKey; let $index = index;"> *ngFor="let keyControl of keysFormArray().controls; trackBy: trackByKey; let $index = index;">
<tb-data-key-row fxFlex <tb-data-key-row fxFlex
[formControl]="keyControl" [formControl]="keyControl"

View File

@ -149,6 +149,7 @@ export class AggregatedValueCardWidgetComponent implements OnInit, AfterViewInit
if (this.showChart) { if (this.showChart) {
const settings = { const settings = {
shadowSize: 0, shadowSize: 0,
enableSelection: false,
smoothLines: false, smoothLines: false,
grid: { grid: {
tickColor: 'rgba(0,0,0,0.12)', tickColor: 'rgba(0,0,0,0.12)',

View File

@ -400,12 +400,18 @@
} }
} }
.tb-form-table-row { .tb-draggable-form-table-row {
&.tb-draggable {
gap: 0;
padding-left: 0;
background: #fff; background: #fff;
display: flex;
flex-direction: row;
place-content: center flex-start;
align-items: center;
.tb-form-table-row {
padding-right: 0;
} }
}
.tb-form-table-row {
&-cell { &-cell {
color: rgba(0, 0, 0, 0.87); color: rgba(0, 0, 0, 0.87);