Commit 167e833d958db6b9feb09e98805572fb2df5de69
Committed by
GitHub
Merge pull request #4674 from vvlladd28/imrovement/convert-value/timeseries
UI: Fixed convert string to number in time-series data
Showing
2 changed files
with
11 additions
and
28 deletions
... | ... | @@ -16,16 +16,17 @@ |
16 | 16 | |
17 | 17 | import { SubscriptionData, SubscriptionDataHolder } from '@app/shared/models/telemetry/telemetry.models'; |
18 | 18 | import { |
19 | - AggregationType, calculateIntervalComparisonEndTime, | |
20 | - calculateIntervalEndTime, calculateIntervalStartEndTime, | |
19 | + AggregationType, | |
20 | + calculateIntervalComparisonEndTime, | |
21 | + calculateIntervalEndTime, | |
22 | + calculateIntervalStartEndTime, | |
21 | 23 | getCurrentTime, |
22 | - getCurrentTimeForComparison, getTime, | |
24 | + getTime, | |
23 | 25 | SubscriptionTimewindow |
24 | 26 | } from '@shared/models/time/time.models'; |
25 | 27 | import { UtilsService } from '@core/services/utils.service'; |
26 | -import { deepClone } from '@core/utils'; | |
28 | +import { deepClone, isNumeric } from '@core/utils'; | |
27 | 29 | import Timeout = NodeJS.Timeout; |
28 | -import * as moment_ from 'moment'; | |
29 | 30 | |
30 | 31 | export declare type onAggregatedData = (data: SubscriptionData, detectChanges: boolean) => void; |
31 | 32 | |
... | ... | @@ -407,24 +408,11 @@ export class DataAggregator { |
407 | 408 | } |
408 | 409 | } |
409 | 410 | |
410 | - private isNumeric(val: any): boolean { | |
411 | - return (val - parseFloat( val ) + 1) >= 0; | |
412 | - } | |
413 | - | |
414 | 411 | private convertValue(val: string): any { |
415 | - if (!this.noAggregation || val && this.isNumeric(val)) { | |
412 | + if (!this.noAggregation || val && isNumeric(val) && Number(val).toString() === val) { | |
416 | 413 | return Number(val); |
417 | - } else { | |
418 | - return val; | |
419 | - } | |
420 | - } | |
421 | - | |
422 | - private getCurrentTime() { | |
423 | - if (this.subsTw.timeForComparison) { | |
424 | - return getCurrentTimeForComparison(this.subsTw.timeForComparison as moment_.unitOfTime.DurationConstructor, this.subsTw.timezone); | |
425 | - } else { | |
426 | - return getCurrentTime(this.subsTw.timezone); | |
427 | 414 | } |
415 | + return val; | |
428 | 416 | } |
429 | 417 | |
430 | 418 | } | ... | ... |
... | ... | @@ -38,7 +38,7 @@ import { |
38 | 38 | } from '@shared/models/telemetry/telemetry.models'; |
39 | 39 | import { UtilsService } from '@core/services/utils.service'; |
40 | 40 | import { EntityDataListener, EntityDataLoadResult } from '@core/api/entity-data.service'; |
41 | -import { deepClone, isDefined, isDefinedAndNotNull, isObject, objectHashCode } from '@core/utils'; | |
41 | +import { deepClone, isDefined, isDefinedAndNotNull, isNumeric, isObject, objectHashCode } from '@core/utils'; | |
42 | 42 | import { PageData } from '@shared/models/page/page-data'; |
43 | 43 | import { DataAggregator } from '@core/api/data-aggregator'; |
44 | 44 | import { NULL_UUID } from '@shared/models/id/has-uuid'; |
... | ... | @@ -742,16 +742,11 @@ export class EntityDataSubscription { |
742 | 742 | } |
743 | 743 | } |
744 | 744 | |
745 | - private isNumeric(val: any): boolean { | |
746 | - return (val - parseFloat( val ) + 1) >= 0; | |
747 | - } | |
748 | - | |
749 | 745 | private convertValue(val: string): any { |
750 | - if (val && this.isNumeric(val) && Number(val).toString() === val) { | |
746 | + if (val && isNumeric(val) && Number(val).toString() === val) { | |
751 | 747 | return Number(val); |
752 | - } else { | |
753 | - return val; | |
754 | 748 | } |
749 | + return val; | |
755 | 750 | } |
756 | 751 | |
757 | 752 | private toSubscriptionData(sourceData: {[key: string]: TsValue | TsValue[]}, isTs: boolean): SubscriptionData { | ... | ... |