@dative-gpi/foundation-shared-components 1.0.188 → 1.0.189-add-absolute-composable2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30,18 +30,31 @@ export default defineComponent({
|
|
|
30
30
|
label : {
|
|
31
31
|
type: String,
|
|
32
32
|
required: false
|
|
33
|
-
}
|
|
33
|
+
},
|
|
34
|
+
allowedAggregation: {
|
|
35
|
+
type: Array as PropType<AggregationType[]>,
|
|
36
|
+
required: false,
|
|
37
|
+
default: null
|
|
38
|
+
},
|
|
34
39
|
},
|
|
35
40
|
emits: ['update:modelValue'],
|
|
36
|
-
setup() {
|
|
41
|
+
setup(props) {
|
|
37
42
|
|
|
38
43
|
const aggregationTypeItems = computed(()=>{
|
|
44
|
+
if (props.allowedAggregation != null) {
|
|
45
|
+
return props.allowedAggregation.map((f)=>{
|
|
46
|
+
return {
|
|
47
|
+
id: f,
|
|
48
|
+
label: aggregationTypeLabel(f)
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
}
|
|
39
52
|
return getEnumEntries(AggregationType).filter(f=>f.value != AggregationType.None).map((f)=>{
|
|
40
53
|
return {
|
|
41
54
|
id: f.value,
|
|
42
55
|
label: aggregationTypeLabel(f.value)
|
|
43
56
|
}
|
|
44
|
-
})
|
|
57
|
+
});
|
|
45
58
|
});
|
|
46
59
|
|
|
47
60
|
return {
|
package/composables/index.ts
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import { uuidv4 } from "@dative-gpi/bones-ui";
|
|
4
|
+
|
|
5
|
+
import { getManyDatas } from "@dative-gpi/foundation-core-services/composables";
|
|
6
|
+
|
|
7
|
+
import { RootMode } from "@dative-gpi/foundation-shared-domain/enums";
|
|
8
|
+
|
|
9
|
+
import type { DataFiltersDTO, DataLeafDTO, AbsoluteProfitsComparisonFilter } from "@dative-gpi/foundation-core-domain/models";
|
|
10
|
+
|
|
11
|
+
export const useAbsoluteProfitsComparison = () => {
|
|
12
|
+
const fetching = ref(false);
|
|
13
|
+
const error = ref<string | null>(null);
|
|
14
|
+
const rawReferenceValue = ref<number | null>(null);
|
|
15
|
+
const rawObservedValue = ref<number | null>(null);
|
|
16
|
+
|
|
17
|
+
const fetch = async (filter: AbsoluteProfitsComparisonFilter) => {
|
|
18
|
+
fetching.value = true;
|
|
19
|
+
|
|
20
|
+
const leaf = {
|
|
21
|
+
correlationId: uuidv4(),
|
|
22
|
+
entitiesIds: filter.entitiesIds,
|
|
23
|
+
entityType: filter.entityType,
|
|
24
|
+
labelTemplate: "",
|
|
25
|
+
aggregateByEntity: 0,
|
|
26
|
+
aggregationTimeStep: undefined,
|
|
27
|
+
duration: 0,
|
|
28
|
+
durationTimeStep: undefined,
|
|
29
|
+
durationDataDefinitionId: undefined,
|
|
30
|
+
durationDataScale: 0,
|
|
31
|
+
dataDefinitions: [
|
|
32
|
+
{
|
|
33
|
+
dataDefinitionId: filter.dataDefinitionId,
|
|
34
|
+
codeTemplate: "",
|
|
35
|
+
label: "",
|
|
36
|
+
unit: filter.unit,
|
|
37
|
+
sort: 0,
|
|
38
|
+
aggregation: filter.aggregation,
|
|
39
|
+
code: ""
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
groupByDataDefinitionIds: [],
|
|
43
|
+
take: 0,
|
|
44
|
+
removeRedundants: false,
|
|
45
|
+
dataCriterias: [],
|
|
46
|
+
timeCriterias: [],
|
|
47
|
+
executionIndex: 0
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
error.value = null;
|
|
51
|
+
rawReferenceValue.value = null;
|
|
52
|
+
rawObservedValue.value = null;
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const refFilters: DataFiltersDTO = {
|
|
56
|
+
startDate: filter.referencePeriodStart,
|
|
57
|
+
endDate: filter.referencePeriodEnd,
|
|
58
|
+
timeOffset: filter.timeOffset,
|
|
59
|
+
dateVariables: [],
|
|
60
|
+
mode: RootMode.Leaf,
|
|
61
|
+
leaf: { ...leaf, correlationId: uuidv4() } as DataLeafDTO
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const actFilters: DataFiltersDTO = {
|
|
65
|
+
startDate: filter.observedPeriodStart,
|
|
66
|
+
endDate: filter.observedPeriodEnd,
|
|
67
|
+
timeOffset: filter.timeOffset,
|
|
68
|
+
dateVariables: [],
|
|
69
|
+
mode: RootMode.Leaf,
|
|
70
|
+
leaf: { ...leaf, correlationId: uuidv4() } as DataLeafDTO
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const dataSerieReference = await getManyDatas(refFilters);
|
|
74
|
+
const dataSerieObserved = await getManyDatas(actFilters);
|
|
75
|
+
|
|
76
|
+
const rawRef = dataSerieReference?.[0]?.datas?.[0]?.values?.[0];
|
|
77
|
+
const rawObs = dataSerieObserved?.[0]?.datas?.[0]?.values?.[0];
|
|
78
|
+
|
|
79
|
+
rawReferenceValue.value = rawRef == null ? null : Number(rawRef);
|
|
80
|
+
rawObservedValue.value = rawObs == null ? null : Number(rawObs);
|
|
81
|
+
|
|
82
|
+
} catch (exception: any) {
|
|
83
|
+
error.value = exception.response?.data ?? exception.message;
|
|
84
|
+
} finally {
|
|
85
|
+
fetching.value = false;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
fetching,
|
|
91
|
+
error,
|
|
92
|
+
rawReferenceValue,
|
|
93
|
+
rawObservedValue,
|
|
94
|
+
fetch,
|
|
95
|
+
};
|
|
96
|
+
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/Dative-GPI/foundation-shared-ui.git"
|
|
5
5
|
},
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"version": "1.0.
|
|
7
|
+
"version": "1.0.189-add-absolute-composable2",
|
|
8
8
|
"description": "",
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"author": "",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@dative-gpi/foundation-shared-domain": "1.0.
|
|
17
|
-
"@dative-gpi/foundation-shared-services": "1.0.
|
|
16
|
+
"@dative-gpi/foundation-shared-domain": "1.0.189-add-absolute-composable2",
|
|
17
|
+
"@dative-gpi/foundation-shared-services": "1.0.189-add-absolute-composable2"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"sass": "1.71.1",
|
|
39
39
|
"sass-loader": "13.3.2"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "db43320daa21c762f0f6cc298e03fa93c86d49d8"
|
|
42
42
|
}
|