Merge branch 'AD/bug-fix/aggregation-index' of github.com:ArtemDzhereleiko/thingsboard into AD/bug-fix/aggregation-index
This commit is contained in:
commit
0fe0a84d32
@ -201,7 +201,7 @@ export class DataKeyConfigComponent extends PageComponent implements OnInit, Con
|
|||||||
let newLabel = this.dataKeyFormGroup.get('name').value;
|
let newLabel = this.dataKeyFormGroup.get('name').value;
|
||||||
if (aggType !== AggregationType.NONE) {
|
if (aggType !== AggregationType.NONE) {
|
||||||
const prefix = this.translate.instant(aggregationTranslations.get(aggType));
|
const prefix = this.translate.instant(aggregationTranslations.get(aggType));
|
||||||
newLabel = prefix + ' ' + newLabel;
|
newLabel = this.genNextLabelWithAggregation(prefix + ' ' + newLabel);
|
||||||
}
|
}
|
||||||
this.dataKeyFormGroup.get('label').patchValue(newLabel);
|
this.dataKeyFormGroup.get('label').patchValue(newLabel);
|
||||||
}
|
}
|
||||||
@ -241,6 +241,30 @@ export class DataKeyConfigComponent extends PageComponent implements OnInit, Con
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private genNextLabelWithAggregation(name: string): string {
|
||||||
|
let label = name;
|
||||||
|
let i = 1;
|
||||||
|
let matches = false;
|
||||||
|
const datasources = this.widget.config.datasources;
|
||||||
|
if (datasources) {
|
||||||
|
do {
|
||||||
|
matches = false;
|
||||||
|
datasources.forEach((datasource) => {
|
||||||
|
if (datasource && datasource?.dataKeys) {
|
||||||
|
datasource.dataKeys.forEach((dataKey) => {
|
||||||
|
if (dataKey.label === label) {
|
||||||
|
i++;
|
||||||
|
label = name + ' ' + i;
|
||||||
|
matches = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} while (matches);
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
registerOnChange(fn: any): void {
|
registerOnChange(fn: any): void {
|
||||||
this.propagateChange = fn;
|
this.propagateChange = fn;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user