ato-water-lib 0.0.34 → 0.0.37
Sign up to get free protection for your applications and to get access to all the features.
- package/esm2020/ato-water-lib.mjs +5 -0
- package/esm2020/lib/ato-water-lib.component.mjs +19 -0
- package/esm2020/lib/ato-water-lib.module.mjs +49 -0
- package/esm2020/lib/ato-water-lib.service.mjs +14 -0
- package/esm2020/lib/components/asset-flow/asset-flow.component.mjs +123 -0
- package/esm2020/lib/components/asset-params-view/asset-params-view.component.mjs +26 -0
- package/esm2020/lib/components/flow-diagram-lib/flow-diagram-lib.component.mjs +54 -0
- package/esm2020/lib/constants/applicable-prefixes-const.mjs +441 -0
- package/esm2020/lib/constants/base64.const.mjs +5 -0
- package/esm2020/lib/constants/components-group-const.mjs +1629 -0
- package/esm2020/lib/constants/icon-base64.const.mjs +4 -0
- package/esm2020/lib/constants/key.const.mjs +4 -0
- package/esm2020/lib/constants/plant.constant.mjs +51 -0
- package/esm2020/lib/constants/value.const.mjs +782 -0
- package/esm2020/lib/directive/ato-loading.directive.mjs +55 -0
- package/esm2020/lib/directive/ng-var.directive.mjs +31 -0
- package/esm2020/lib/models/ato-asset-flow.model.mjs +2 -0
- package/esm2020/lib/models/default-gojs-editor.model.mjs +3227 -0
- package/esm2020/lib/models/gojs-data.model.mjs +6 -0
- package/esm2020/lib/models/gojs-editor.model.mjs +1754 -0
- package/esm2020/lib/services/utils/utils.service.mjs +133 -0
- package/esm2020/public-api.mjs +15 -0
- package/fesm2015/ato-water-lib.mjs +8208 -0
- package/fesm2015/ato-water-lib.mjs.map +1 -0
- package/fesm2020/ato-water-lib.mjs +8360 -0
- package/fesm2020/ato-water-lib.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/ato-water-lib.component.d.ts +5 -0
- package/lib/ato-water-lib.module.d.ts +13 -0
- package/lib/ato-water-lib.service.d.ts +6 -0
- package/lib/components/asset-flow/asset-flow.component.d.ts +35 -0
- package/lib/components/asset-params-view/asset-params-view.component.d.ts +10 -0
- package/lib/components/flow-diagram-lib/flow-diagram-lib.component.d.ts +16 -0
- package/lib/constants/applicable-prefixes-const.d.ts +162 -0
- package/lib/constants/base64.const.d.ts +3 -0
- package/lib/constants/components-group-const.d.ts +1264 -0
- package/lib/constants/icon-base64.const.d.ts +3 -0
- package/lib/constants/key.const.d.ts +1 -0
- package/lib/constants/plant.constant.d.ts +7 -0
- package/lib/constants/value.const.d.ts +71 -0
- package/lib/directive/ato-loading.directive.d.ts +14 -0
- package/lib/directive/ng-var.directive.d.ts +12 -0
- package/lib/models/ato-asset-flow.model.d.ts +5 -0
- package/lib/models/default-gojs-editor.model.d.ts +197 -0
- package/{src/lib/models/gojs-data.model.ts → lib/models/gojs-data.model.d.ts} +3 -3
- package/lib/models/gojs-editor.model.d.ts +436 -0
- package/lib/services/utils/utils.service.d.ts +24 -0
- package/package.json +22 -3
- package/{src/public-api.ts → public-api.d.ts} +0 -10
- package/ng-package.json +0 -11
- package/src/lib/ato-water-lib.component.spec.ts +0 -23
- package/src/lib/ato-water-lib.component.ts +0 -15
- package/src/lib/ato-water-lib.module.ts +0 -31
- package/src/lib/ato-water-lib.service.spec.ts +0 -16
- package/src/lib/ato-water-lib.service.ts +0 -9
- package/src/lib/components/asset-flow/asset-flow.component.html +0 -21
- package/src/lib/components/asset-flow/asset-flow.component.scss +0 -4
- package/src/lib/components/asset-flow/asset-flow.component.spec.ts +0 -23
- package/src/lib/components/asset-flow/asset-flow.component.ts +0 -137
- package/src/lib/components/asset-params-view/asset-params-view.component.html +0 -85
- package/src/lib/components/asset-params-view/asset-params-view.component.scss +0 -37
- package/src/lib/components/asset-params-view/asset-params-view.component.spec.ts +0 -23
- package/src/lib/components/asset-params-view/asset-params-view.component.ts +0 -16
- package/src/lib/components/flow-diagram-lib/flow-diagram-lib.component.css +0 -0
- package/src/lib/components/flow-diagram-lib/flow-diagram-lib.component.html +0 -25
- package/src/lib/components/flow-diagram-lib/flow-diagram-lib.component.ts +0 -69
- package/src/lib/constants/applicable-prefixes-const.ts +0 -452
- package/src/lib/constants/base64.const.ts +0 -5
- package/src/lib/constants/components-group-const.ts +0 -1637
- package/src/lib/constants/icon-base64.const.ts +0 -3
- package/src/lib/constants/icon-svg.const.ts +0 -8
- package/src/lib/constants/key.const.ts +0 -5
- package/src/lib/constants/plant.constant.ts +0 -52
- package/src/lib/constants/value.const.ts +0 -822
- package/src/lib/directive/ato-loading.directive.ts +0 -55
- package/src/lib/directive/ng-var.directive.ts +0 -28
- package/src/lib/models/default-gojs-editor.model.ts +0 -4906
- package/src/lib/models/gojs-editor.model.ts +0 -1901
- package/src/lib/services/utils/utils.service.ts +0 -141
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
@@ -1,141 +0,0 @@
|
|
1
|
-
import { DecimalPipe } from '@angular/common';
|
2
|
-
import { Injectable } from '@angular/core';
|
3
|
-
import { ATO_ABBREVIATION, APPLICABLE_PREFIXES, ROUNDED_NUMBER, } from '../../constants/applicable-prefixes-const';
|
4
|
-
import { v4 as uuidV4 } from 'uuid';
|
5
|
-
import _ from 'lodash';
|
6
|
-
|
7
|
-
@Injectable({
|
8
|
-
providedIn: 'root',
|
9
|
-
})
|
10
|
-
export class UtilsService {
|
11
|
-
static convertPrefixesData(data: { value: number | string | any; unit: string | any; isChangeUnitKwh?: boolean }): {
|
12
|
-
shortenedNumber: number | string | null;
|
13
|
-
unitPrefixes: number | null | string;
|
14
|
-
} {
|
15
|
-
if (!data?.unit || (!+data?.value && data?.value !== '0')) {
|
16
|
-
return {
|
17
|
-
shortenedNumber: data?.value ?? '0',
|
18
|
-
unitPrefixes: '',
|
19
|
-
};
|
20
|
-
}
|
21
|
-
|
22
|
-
const [unitToConvert, suffixUnit] = data?.unit?.split('/');
|
23
|
-
|
24
|
-
if (unitToConvert === ATO_ABBREVIATION.kWh) {
|
25
|
-
return this.getDataFormatSpecialKwh(data?.value, data?.isChangeUnitKwh);
|
26
|
-
}
|
27
|
-
|
28
|
-
return this.getDataFormatUnit(data?.value, unitToConvert);
|
29
|
-
}
|
30
|
-
|
31
|
-
static getDataFormatSpecialKwh(value: any, isChangeUnitKwh: any) {
|
32
|
-
const _DecimalPipe = new DecimalPipe('en');
|
33
|
-
|
34
|
-
if (!!isChangeUnitKwh) {
|
35
|
-
// 1.000.000 KWh => 1 GWh
|
36
|
-
if (Math.abs(value) >= ROUNDED_NUMBER.MILLION) {
|
37
|
-
return {
|
38
|
-
shortenedNumber: _DecimalPipe.transform(+(value / ROUNDED_NUMBER.MILLION) ?? 0, '1.0-2'),
|
39
|
-
unitPrefixes: APPLICABLE_PREFIXES?.[ATO_ABBREVIATION.kWh]?.[ROUNDED_NUMBER.BILLION],
|
40
|
-
};
|
41
|
-
}
|
42
|
-
// 1000 KWh => 1 MWh
|
43
|
-
if (Math.abs(value) >= ROUNDED_NUMBER.THOUSAND) {
|
44
|
-
return {
|
45
|
-
shortenedNumber: _DecimalPipe.transform(+(value / ROUNDED_NUMBER.THOUSAND) ?? 0, '1.0-2'),
|
46
|
-
unitPrefixes: APPLICABLE_PREFIXES?.[ATO_ABBREVIATION.kWh]?.[ROUNDED_NUMBER.MILLION],
|
47
|
-
};
|
48
|
-
}
|
49
|
-
}
|
50
|
-
if (Math.abs(value) >= ROUNDED_NUMBER.BILLION) {
|
51
|
-
return {
|
52
|
-
shortenedNumber: _DecimalPipe.transform(+(value / ROUNDED_NUMBER.MILLION) ?? 0, '1.0-2'),
|
53
|
-
unitPrefixes: APPLICABLE_PREFIXES?.[ATO_ABBREVIATION.kWh]?.[ROUNDED_NUMBER.BILLION],
|
54
|
-
};
|
55
|
-
}
|
56
|
-
if (Math.abs(value) >= ROUNDED_NUMBER.MILLION) {
|
57
|
-
return {
|
58
|
-
shortenedNumber: _DecimalPipe.transform(+(value / ROUNDED_NUMBER.MILLION) ?? 0, '1.0-2'),
|
59
|
-
unitPrefixes: APPLICABLE_PREFIXES?.[ATO_ABBREVIATION.kWh]?.[ROUNDED_NUMBER.MILLION],
|
60
|
-
};
|
61
|
-
}
|
62
|
-
if (Math.abs(value) >= ROUNDED_NUMBER.THOUSAND) {
|
63
|
-
return {
|
64
|
-
shortenedNumber: _DecimalPipe.transform(+(value / ROUNDED_NUMBER.THOUSAND) ?? 0, '1.0-2'),
|
65
|
-
unitPrefixes: APPLICABLE_PREFIXES?.[ATO_ABBREVIATION.kWh]?.[ROUNDED_NUMBER.THOUSAND],
|
66
|
-
};
|
67
|
-
}
|
68
|
-
|
69
|
-
return {
|
70
|
-
shortenedNumber: _DecimalPipe.transform(+value ?? 0, '1.0-2') ?? '0',
|
71
|
-
unitPrefixes: '',
|
72
|
-
};
|
73
|
-
}
|
74
|
-
|
75
|
-
static getDataFormatUnit(value: any, unit: string) {
|
76
|
-
const _DecimalPipe = new DecimalPipe('en');
|
77
|
-
|
78
|
-
if (Math.abs(value) >= ROUNDED_NUMBER.BILLION) {
|
79
|
-
return {
|
80
|
-
shortenedNumber: _DecimalPipe.transform(+(value / ROUNDED_NUMBER.BILLION) ?? 0, '1.0-2'),
|
81
|
-
unitPrefixes: (APPLICABLE_PREFIXES as any)?.[unit]?.[ROUNDED_NUMBER.BILLION],
|
82
|
-
};
|
83
|
-
}
|
84
|
-
if (Math.abs(value) >= ROUNDED_NUMBER.MILLION) {
|
85
|
-
return {
|
86
|
-
shortenedNumber: _DecimalPipe.transform(+(value / ROUNDED_NUMBER.MILLION) ?? 0, '1.0-2'),
|
87
|
-
unitPrefixes: (APPLICABLE_PREFIXES as any)?.[unit]?.[ROUNDED_NUMBER.MILLION],
|
88
|
-
};
|
89
|
-
}
|
90
|
-
if (Math.abs(value) >= ROUNDED_NUMBER.THOUSAND) {
|
91
|
-
return {
|
92
|
-
shortenedNumber: _DecimalPipe.transform(+(value / ROUNDED_NUMBER.THOUSAND) ?? 0, '1.0-2'),
|
93
|
-
unitPrefixes: (APPLICABLE_PREFIXES as any)?.[unit]?.[ROUNDED_NUMBER.THOUSAND],
|
94
|
-
};
|
95
|
-
}
|
96
|
-
return {
|
97
|
-
shortenedNumber: _DecimalPipe.transform(+value ?? 0, '1.0-2') ?? '0',
|
98
|
-
unitPrefixes: '',
|
99
|
-
};
|
100
|
-
}
|
101
|
-
|
102
|
-
static convertSpecialUnit(unit: string, unitPrefixes?: any) {
|
103
|
-
switch (unit) {
|
104
|
-
case ATO_ABBREVIATION.kWh: {
|
105
|
-
return unitPrefixes ? ATO_ABBREVIATION.Wh : ATO_ABBREVIATION.kWh;
|
106
|
-
}
|
107
|
-
case ATO_ABBREVIATION.m3: {
|
108
|
-
return ATO_ABBREVIATION.m3_Special;
|
109
|
-
}
|
110
|
-
case ATO_ABBREVIATION.m3_unit: {
|
111
|
-
return ATO_ABBREVIATION.m3_unit_Special;
|
112
|
-
}
|
113
|
-
case ATO_ABBREVIATION.degC: {
|
114
|
-
return ATO_ABBREVIATION.degC_unit_Special;
|
115
|
-
}
|
116
|
-
case ATO_ABBREVIATION.degF: {
|
117
|
-
return ATO_ABBREVIATION.degF_unit_Special;
|
118
|
-
}
|
119
|
-
default: {
|
120
|
-
unit = UtilsService.replaceAll(unit ?? '', ATO_ABBREVIATION.m3, ATO_ABBREVIATION.m3_Special);
|
121
|
-
return UtilsService.replaceAll(unit ?? '', ATO_ABBREVIATION.CO2, ATO_ABBREVIATION.CO2_Special);
|
122
|
-
}
|
123
|
-
}
|
124
|
-
}
|
125
|
-
|
126
|
-
static generateUUID() {
|
127
|
-
const id = UtilsService.replaceAll(uuidV4(), '-', '').toUpperCase();
|
128
|
-
const randomPosition = _.random(0, 32);
|
129
|
-
const randomNumber = _.random(0, 9).toString();
|
130
|
-
const leftChar = id.slice(0, randomPosition);
|
131
|
-
const rightChar = id.slice(randomPosition);
|
132
|
-
return `${leftChar}${randomNumber}${rightChar}`;
|
133
|
-
}
|
134
|
-
|
135
|
-
static replaceAll(text: any, find: any, replace: any): string {
|
136
|
-
function escapeRegExp(str: any) {
|
137
|
-
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
|
138
|
-
}
|
139
|
-
return text.replace(new RegExp(escapeRegExp(find), 'g'), replace);
|
140
|
-
}
|
141
|
-
}
|
package/tsconfig.lib.json
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
2
|
-
{
|
3
|
-
"extends": "../../tsconfig.json",
|
4
|
-
"compilerOptions": {
|
5
|
-
"outDir": "../../out-tsc/lib",
|
6
|
-
"declaration": true,
|
7
|
-
"declarationMap": true,
|
8
|
-
"inlineSources": true,
|
9
|
-
"types": []
|
10
|
-
},
|
11
|
-
"exclude": [
|
12
|
-
"**/*.spec.ts"
|
13
|
-
]
|
14
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
package/tsconfig.spec.json
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
2
|
-
{
|
3
|
-
"extends": "../../tsconfig.json",
|
4
|
-
"compilerOptions": {
|
5
|
-
"outDir": "../../out-tsc/spec",
|
6
|
-
"types": [
|
7
|
-
"jasmine"
|
8
|
-
]
|
9
|
-
},
|
10
|
-
"include": [
|
11
|
-
"**/*.spec.ts",
|
12
|
-
"**/*.d.ts"
|
13
|
-
]
|
14
|
-
}
|