Browse Source

Merge pull request #4674 from vvlladd28/imrovement/convert-value/timeseries

UI: Fixed convert string to number in time-series data
pull/4691/head
Igor Kulikov 5 years ago
committed by GitHub
parent
commit
167e833d95
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      ui-ngx/src/app/core/api/data-aggregator.ts
  2. 11
      ui-ngx/src/app/core/api/entity-data-subscription.ts

28
ui-ngx/src/app/core/api/data-aggregator.ts

@ -16,16 +16,17 @@
import { SubscriptionData, SubscriptionDataHolder } from '@app/shared/models/telemetry/telemetry.models';
import {
AggregationType, calculateIntervalComparisonEndTime,
calculateIntervalEndTime, calculateIntervalStartEndTime,
AggregationType,
calculateIntervalComparisonEndTime,
calculateIntervalEndTime,
calculateIntervalStartEndTime,
getCurrentTime,
getCurrentTimeForComparison, getTime,
getTime,
SubscriptionTimewindow
} from '@shared/models/time/time.models';
import { UtilsService } from '@core/services/utils.service';
import { deepClone } from '@core/utils';
import { deepClone, isNumeric } from '@core/utils';
import Timeout = NodeJS.Timeout;
import * as moment_ from 'moment';
export declare type onAggregatedData = (data: SubscriptionData, detectChanges: boolean) => void;
@ -407,24 +408,11 @@ export class DataAggregator {
}
}
private isNumeric(val: any): boolean {
return (val - parseFloat( val ) + 1) >= 0;
}
private convertValue(val: string): any {
if (!this.noAggregation || val && this.isNumeric(val)) {
if (!this.noAggregation || val && isNumeric(val) && Number(val).toString() === val) {
return Number(val);
} else {
return val;
}
}
private getCurrentTime() {
if (this.subsTw.timeForComparison) {
return getCurrentTimeForComparison(this.subsTw.timeForComparison as moment_.unitOfTime.DurationConstructor, this.subsTw.timezone);
} else {
return getCurrentTime(this.subsTw.timezone);
}
return val;
}
}

11
ui-ngx/src/app/core/api/entity-data-subscription.ts

@ -38,7 +38,7 @@ import {
} from '@shared/models/telemetry/telemetry.models';
import { UtilsService } from '@core/services/utils.service';
import { EntityDataListener, EntityDataLoadResult } from '@core/api/entity-data.service';
import { deepClone, isDefined, isDefinedAndNotNull, isObject, objectHashCode } from '@core/utils';
import { deepClone, isDefined, isDefinedAndNotNull, isNumeric, isObject, objectHashCode } from '@core/utils';
import { PageData } from '@shared/models/page/page-data';
import { DataAggregator } from '@core/api/data-aggregator';
import { NULL_UUID } from '@shared/models/id/has-uuid';
@ -742,16 +742,11 @@ export class EntityDataSubscription {
}
}
private isNumeric(val: any): boolean {
return (val - parseFloat( val ) + 1) >= 0;
}
private convertValue(val: string): any {
if (val && this.isNumeric(val) && Number(val).toString() === val) {
if (val && isNumeric(val) && Number(val).toString() === val) {
return Number(val);
} else {
return val;
}
return val;
}
private toSubscriptionData(sourceData: {[key: string]: TsValue | TsValue[]}, isTs: boolean): SubscriptionData {

Loading…
Cancel
Save