@dative-gpi/foundation-core-services 1.0.109 → 1.0.111
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.
- package/composables/services/index.ts +1 -0
- package/composables/services/useDeviceExplorerElements.ts +98 -0
- package/composables/services/useDeviceOrganisations.ts +2 -0
- package/composables/services/useGroups.ts +2 -0
- package/config/urls/deviceExplorerElements.ts +3 -0
- package/config/urls/index.ts +1 -0
- package/package.json +3 -3
|
@@ -18,6 +18,7 @@ export * from "./useDataCategories";
|
|
|
18
18
|
export * from "./useDataDefinitions";
|
|
19
19
|
export * from "./useDataTables";
|
|
20
20
|
export * from "./useDeviceConnectivities";
|
|
21
|
+
export * from "./useDeviceExplorerElements";
|
|
21
22
|
export * from "./useDeviceOrganisations";
|
|
22
23
|
export * from "./useDeviceStatuses";
|
|
23
24
|
export * from "./useFolders";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import { DeviceExplorerElementDetails, type DeviceExplorerElementDetailsDTO, type DeviceExplorerElementFilters, DeviceExplorerElementInfos, type DeviceExplorerElementInfosDTO, type DeviceOrganisationDetails, type GroupDetails } from "@dative-gpi/foundation-core-domain/models";
|
|
4
|
+
import { type AddOrUpdateCallback, type DeleteCallback, type NotifyEvent, onCollectionChanged } from "@dative-gpi/bones-ui";
|
|
5
|
+
import { fromDeviceOrganisation, fromGroup } from "@dative-gpi/foundation-shared-domain/tools";
|
|
6
|
+
import { ServiceFactory } from "@dative-gpi/bones-ui/core";
|
|
7
|
+
|
|
8
|
+
import { DEVICE_EXPLORER_ELEMENTS_URL } from "../../config/urls";
|
|
9
|
+
|
|
10
|
+
import { useTrackDeviceConnectivity, useWatchDeviceConnectivity } from "./useDeviceConnectivities";
|
|
11
|
+
import { useTrackDeviceStatuses, useWatchDeviceStatuses } from "./useDeviceStatuses";
|
|
12
|
+
import { useSubscribeToDeviceOrganisations } from "./useDeviceOrganisations";
|
|
13
|
+
import { useSubscribeToGroups } from "./useGroups";
|
|
14
|
+
|
|
15
|
+
const DeviceExplorerElementServiceFactory = new ServiceFactory<DeviceExplorerElementDetailsDTO, DeviceExplorerElementDetails>("deviceExplorerElement", DeviceExplorerElementDetails).create(factory => factory.build(
|
|
16
|
+
factory.addGetMany<DeviceExplorerElementInfosDTO, DeviceExplorerElementInfos, DeviceExplorerElementFilters>(DEVICE_EXPLORER_ELEMENTS_URL, DeviceExplorerElementInfos),
|
|
17
|
+
factory.addNotify()
|
|
18
|
+
));
|
|
19
|
+
|
|
20
|
+
export const useDeviceExplorerElements = () => {
|
|
21
|
+
const { watchMany: watchDevicesConnectivity } = useWatchDeviceConnectivity();
|
|
22
|
+
const { watchMany: watchDevicesStatuses } = useWatchDeviceStatuses();
|
|
23
|
+
|
|
24
|
+
const { track: trackDeviceConnectivity } = useTrackDeviceConnectivity();
|
|
25
|
+
const { track: trackDeviceStatuses } = useTrackDeviceStatuses();
|
|
26
|
+
|
|
27
|
+
const { subscribe: subscribeToDeviceOrganisations } = useSubscribeToDeviceOrganisations();
|
|
28
|
+
const { subscribe: subscribeToGroups } = useSubscribeToGroups();
|
|
29
|
+
|
|
30
|
+
const fetching = ref(false);
|
|
31
|
+
const entities = ref<DeviceExplorerElementInfos[]>([]);
|
|
32
|
+
const filters = ref<DeviceExplorerElementFilters | null>(null);
|
|
33
|
+
|
|
34
|
+
const getMany = async (...args: Parameters<typeof DeviceExplorerElementServiceFactory.getMany>) => {
|
|
35
|
+
fetching.value = true;
|
|
36
|
+
filters.value = args.pop() ?? null;
|
|
37
|
+
|
|
38
|
+
const filterMethod = (el: DeviceExplorerElementInfos): boolean => {
|
|
39
|
+
if (!filters.value) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (!filters.value.search) {
|
|
43
|
+
return (filters.value.root && !el.parentId) || (!!filters.value.parentId && filters.value.parentId == el.parentId);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const fullText = `${el.label} ${el.code} ${el.tags.join(" ")}`;
|
|
47
|
+
return (!filters.value.parentId || el.path.some(p => p.id === filters.value!.parentId)) &&
|
|
48
|
+
(fullText.toLowerCase().includes(filters.value.search.toLowerCase()));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const onCollectionChangedCustom = onCollectionChanged(entities, filterMethod) ;
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
entities.value = await DeviceExplorerElementServiceFactory.getMany(...args);
|
|
55
|
+
|
|
56
|
+
subscribeToDeviceOrganisations("all", (ev: NotifyEvent, el: DeviceOrganisationDetails | any) => {
|
|
57
|
+
switch(ev) {
|
|
58
|
+
case "add":
|
|
59
|
+
case "update":
|
|
60
|
+
(onCollectionChangedCustom as AddOrUpdateCallback<DeviceExplorerElementInfos>)(ev, fromDeviceOrganisation(el));
|
|
61
|
+
break;
|
|
62
|
+
case "delete":
|
|
63
|
+
(onCollectionChangedCustom as DeleteCallback)(ev, el);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
subscribeToGroups("all", (ev: NotifyEvent, el: GroupDetails | any) => {
|
|
69
|
+
switch(ev) {
|
|
70
|
+
case "add":
|
|
71
|
+
case "update":
|
|
72
|
+
(onCollectionChangedCustom as AddOrUpdateCallback<DeviceExplorerElementInfos>)(ev, fromGroup(el));
|
|
73
|
+
break;
|
|
74
|
+
case "delete":
|
|
75
|
+
(onCollectionChangedCustom as DeleteCallback)(ev, el);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
watchDevicesStatuses();
|
|
81
|
+
watchDevicesConnectivity();
|
|
82
|
+
|
|
83
|
+
for (const deviceExplorerElement of entities.value) {
|
|
84
|
+
trackDeviceStatuses(deviceExplorerElement.status!, s => deviceExplorerElement.status = s);
|
|
85
|
+
trackDeviceConnectivity(deviceExplorerElement.connectivity!, c => deviceExplorerElement.connectivity = c);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
fetching.value = false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
fetching,
|
|
95
|
+
getMany,
|
|
96
|
+
entities
|
|
97
|
+
}
|
|
98
|
+
};
|
|
@@ -62,6 +62,8 @@ const trackDeviceOrganisations = () => {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
export const useSubscribeToDeviceOrganisations = ComposableFactory.subscribe(DeviceOrganisationServiceFactory);
|
|
66
|
+
|
|
65
67
|
export const useDeviceOrganisation = ComposableFactory.get(DeviceOrganisationServiceFactory, trackDeviceOrganisation);
|
|
66
68
|
export const useDeviceOrganisations = ComposableFactory.getMany(DeviceOrganisationServiceFactory, trackDeviceOrganisations);
|
|
67
69
|
export const useCreateDeviceOrganisation = ComposableFactory.create(DeviceOrganisationServiceFactory, trackDeviceOrganisation);
|
|
@@ -18,6 +18,8 @@ const GroupServiceFactory = new ServiceFactory<GroupDetailsDTO, GroupDetails>("g
|
|
|
18
18
|
}))
|
|
19
19
|
));
|
|
20
20
|
|
|
21
|
+
export const useSubscribeToGroups = ComposableFactory.subscribe(GroupServiceFactory);
|
|
22
|
+
|
|
21
23
|
export const useGroup = ComposableFactory.get(GroupServiceFactory);
|
|
22
24
|
export const useGroups = ComposableFactory.getMany(GroupServiceFactory);
|
|
23
25
|
export const useCreateGroup = ComposableFactory.create(GroupServiceFactory);
|
package/config/urls/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./dataCategories";
|
|
|
17
17
|
export * from "./dataDefinitions";
|
|
18
18
|
export * from "./deviceConnectivities";
|
|
19
19
|
export * from "./deviceOrganisations";
|
|
20
|
+
export * from "./deviceExplorerElements";
|
|
20
21
|
export * from "./deviceStatuses";
|
|
21
22
|
export * from "./folders";
|
|
22
23
|
export * from "./groups";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-core-services",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.111",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-core-domain": "1.0.
|
|
13
|
+
"@dative-gpi/foundation-core-domain": "1.0.111"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"vue": "^3.4.29",
|
|
19
19
|
"vue-router": "^4.3.0"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "8a5582e544900743384c63aa9cf137b780e65ecc"
|
|
22
22
|
}
|