@dative-gpi/foundation-core-services 0.0.53 → 0.0.55
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/useAlerts.ts +48 -9
- package/composables/services/useConnectivityAlerts.ts +42 -5
- package/composables/services/useCustomPropertyValues.ts +6 -37
- package/composables/services/useDeviceConnectivities.ts +20 -4
- package/composables/services/useDeviceOrganisations.ts +63 -15
- package/composables/services/useDeviceStatuses.ts +20 -4
- package/composables/services/useGroups.ts +8 -3
- package/composables/services/useOrganisations.ts +8 -3
- package/composables/services/useUserOrganisations.ts +24 -6
- package/package.json +4 -4
- package/composables/hubs/index.ts +0 -4
- package/composables/hubs/useAlertsHub.ts +0 -51
- package/composables/hubs/useConnectivityAlertsHub.ts +0 -51
- package/composables/hubs/useDeviceConnectivitiesHub.ts +0 -49
- package/composables/hubs/useDeviceStatusesHub.ts +0 -49
|
@@ -1,19 +1,58 @@
|
|
|
1
|
-
import { onUnmounted, ref } from "vue";
|
|
2
|
-
|
|
3
|
-
import { AlertDetails, AlertDetailsDTO, AlertFilters, AlertInfos, AlertInfosDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
4
1
|
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
2
|
+
import { AlertDetails, AlertDetailsDTO, AlertFilters, AlertInfos, AlertInfosDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
3
|
+
import { HubFactory } from "@dative-gpi/foundation-shared-services/tools/hubFactory";
|
|
5
4
|
|
|
6
|
-
import {
|
|
5
|
+
import { HUBS } from "../../config/literals";
|
|
6
|
+
import { ALERTS_HUB_URL, ALERTS_URL, ALERT_URL } from "../../config/urls";
|
|
7
7
|
|
|
8
8
|
const AlertServiceFactory = new ServiceFactory<AlertDetailsDTO, AlertDetails>("alert", AlertDetails).create(factory => factory.build(
|
|
9
9
|
factory.addGet(ALERT_URL),
|
|
10
10
|
factory.addGetMany<AlertInfosDTO, AlertInfos, AlertFilters>(ALERTS_URL, AlertInfos),
|
|
11
11
|
factory.addRemove(ALERT_URL),
|
|
12
|
-
factory.
|
|
13
|
-
|
|
12
|
+
factory.addNotify(notify => ({
|
|
13
|
+
notifyCreate: (alert: AlertDetails) => notify.notify("add", alert),
|
|
14
|
+
notifyUpdate: (alert: AlertDetails) => notify.notify("update", alert),
|
|
15
|
+
notifyRemove: (alertId: string) => notify.notify("delete", alertId),
|
|
16
|
+
...ServiceFactory.addCustom("acknowledge", (axios, alertId: string) => axios.patch(ALERT_URL(alertId)), (dto: AlertDetailsDTO) => {
|
|
17
|
+
const result = new AlertDetails(dto);
|
|
18
|
+
notify.notify("update", result);
|
|
19
|
+
return result;
|
|
20
|
+
})
|
|
21
|
+
}))
|
|
14
22
|
));
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
const useAlertsHub = HubFactory.create(ALERTS_HUB_URL,
|
|
25
|
+
(connection, { isWatched, hasWatchers }) => {
|
|
26
|
+
connection.on(HUBS.CREATE_ALERT, (alertId: string) => hasWatchers()
|
|
27
|
+
? AlertServiceFactory.get(alertId).then(AlertServiceFactory.notifyCreate)
|
|
28
|
+
: null);
|
|
29
|
+
connection.on(HUBS.UPDATE_ALERT, (alertId: string) => isWatched(alertId) || hasWatchers()
|
|
30
|
+
? AlertServiceFactory.get(alertId).then(AlertServiceFactory.notifyUpdate)
|
|
31
|
+
: null);
|
|
32
|
+
connection.on(HUBS.REMOVE_ALERT, (alertId: string) => hasWatchers()
|
|
33
|
+
? AlertServiceFactory.notifyRemove(alertId)
|
|
34
|
+
: null);
|
|
35
|
+
},
|
|
36
|
+
async (connection) => {
|
|
37
|
+
await connection.invoke(HUBS.SUBSCRIBE);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const useWatchAlerts = HubFactory.createWatcher(useAlertsHub);
|
|
42
|
+
|
|
43
|
+
export const useAlert = ComposableFactory.get(AlertServiceFactory, () => {
|
|
44
|
+
const { watchOne } = useWatchAlerts();
|
|
45
|
+
return (alert) => {
|
|
46
|
+
watchOne(alert.value.id)
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const useAlerts = ComposableFactory.getMany(AlertServiceFactory, () => {
|
|
51
|
+
const { watchMany } = useWatchAlerts();
|
|
52
|
+
return (_alert) => {
|
|
53
|
+
watchMany();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
18
57
|
export const useRemoveAlert = ComposableFactory.remove(AlertServiceFactory);
|
|
19
|
-
export const useAcknowledgeAlert = ComposableFactory.custom(AlertServiceFactory
|
|
58
|
+
export const useAcknowledgeAlert = ComposableFactory.custom(AlertServiceFactory.acknowledge);
|
|
@@ -1,15 +1,52 @@
|
|
|
1
|
-
import { ConnectivityAlertDetails, ConnectivityAlertDetailsDTO, ConnectivityAlertFilters, ConnectivityAlertInfos, ConnectivityAlertInfosDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
2
1
|
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
2
|
+
import { ConnectivityAlertDetails, ConnectivityAlertDetailsDTO, ConnectivityAlertFilters, ConnectivityAlertInfos, ConnectivityAlertInfosDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
3
|
+
import { HubFactory } from "@dative-gpi/foundation-shared-services/tools/hubFactory";
|
|
3
4
|
|
|
4
|
-
import { CONNECTIVITY_ALERTS_URL, CONNECTIVITY_ALERT_URL } from "../../config/urls";
|
|
5
|
+
import { CONNECTIVITY_ALERTS_HUB_URL, CONNECTIVITY_ALERTS_URL, CONNECTIVITY_ALERT_URL } from "../../config/urls";
|
|
6
|
+
import { HUBS } from "../../config/literals";
|
|
5
7
|
|
|
6
8
|
const ConnectivityAlertServiceFactory = new ServiceFactory<ConnectivityAlertDetailsDTO, ConnectivityAlertDetails>("connectivityAlert", ConnectivityAlertDetails).create(factory => factory.build(
|
|
7
9
|
factory.addGet(CONNECTIVITY_ALERT_URL),
|
|
8
10
|
factory.addGetMany<ConnectivityAlertInfosDTO, ConnectivityAlertInfos, ConnectivityAlertFilters>(CONNECTIVITY_ALERTS_URL, ConnectivityAlertInfos),
|
|
9
11
|
factory.addRemove(CONNECTIVITY_ALERT_URL),
|
|
10
|
-
factory.addNotify(
|
|
12
|
+
factory.addNotify(notify => ({
|
|
13
|
+
notifyCreate: (alert: ConnectivityAlertDetails) => notify.notify("add", alert),
|
|
14
|
+
notifyUpdate: (alert: ConnectivityAlertDetails) => notify.notify("update", alert),
|
|
15
|
+
notifyRemove: (alertId: string) => notify.notify("delete", alertId),
|
|
16
|
+
}))
|
|
11
17
|
));
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
19
|
+
const useConnectivityAlertsHub = HubFactory.create(CONNECTIVITY_ALERTS_HUB_URL,
|
|
20
|
+
(connection, { isWatched, hasWatchers }) => {
|
|
21
|
+
connection.on(HUBS.CREATE_CONNECTIVITY_ALERT, (alertId: string) => hasWatchers()
|
|
22
|
+
? ConnectivityAlertServiceFactory.get(alertId).then(ConnectivityAlertServiceFactory.notifyCreate)
|
|
23
|
+
: null);
|
|
24
|
+
connection.on(HUBS.UPDATE_CONNECTIVITY_ALERT, (alertId: string) => isWatched(alertId) || hasWatchers()
|
|
25
|
+
? ConnectivityAlertServiceFactory.get(alertId).then(ConnectivityAlertServiceFactory.notifyCreate)
|
|
26
|
+
: null);
|
|
27
|
+
connection.on(HUBS.REMOVE_CONNECTIVITY_ALERT, (alertId: string) => hasWatchers()
|
|
28
|
+
? ConnectivityAlertServiceFactory.notifyRemove(alertId)
|
|
29
|
+
: null);
|
|
30
|
+
},
|
|
31
|
+
async (connection) => {
|
|
32
|
+
await connection.invoke(HUBS.SUBSCRIBE);
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const useWatchConnectivityAlerts = HubFactory.createWatcher(useConnectivityAlertsHub);
|
|
37
|
+
|
|
38
|
+
export const useConnectivityAlert = ComposableFactory.get(ConnectivityAlertServiceFactory, () => {
|
|
39
|
+
const { watchOne } = useWatchConnectivityAlerts();
|
|
40
|
+
return (alert) => {
|
|
41
|
+
watchOne(alert.value.id)
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const useConnectivityAlerts = ComposableFactory.getMany(ConnectivityAlertServiceFactory, () => {
|
|
46
|
+
const { watchMany } = useWatchConnectivityAlerts();
|
|
47
|
+
return (_alerts) => {
|
|
48
|
+
watchMany();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
15
52
|
export const useRemoveConnectivityAlert = ComposableFactory.remove(ConnectivityAlertServiceFactory);
|
|
@@ -1,41 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { CustomPropertyValueDetails, CustomPropertyValueDetailsDTO, CustomPropertyValueInfos, CustomPropertyValueInfosDTO, PropertyEntity } from "@dative-gpi/foundation-core-domain/models";
|
|
4
|
-
import { ServiceFactory } from "@dative-gpi/bones-ui";
|
|
1
|
+
import { CustomPropertyValueInfos, CustomPropertyValueInfosDTO, PropertyEntity } from "@dative-gpi/foundation-core-domain/models";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
3
|
|
|
6
4
|
import { CUSTOM_PROPERTY_VALUES_URL } from "../../config/urls";
|
|
7
5
|
|
|
8
|
-
const CustomPropertyValueServiceFactory =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const response = await ServiceFactory.http.get(CUSTOM_PROPERTY_VALUES_URL(entity, entityId, code));
|
|
12
|
-
const result = response.data.map((dto: CustomPropertyValueInfosDTO) => new CustomPropertyValueInfos(dto));
|
|
13
|
-
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
}))
|
|
17
|
-
));
|
|
18
|
-
|
|
19
|
-
export const useCustomPropertyValues = () => {
|
|
20
|
-
const service = CustomPropertyValueServiceFactory();
|
|
21
|
-
|
|
22
|
-
const fetching = ref(false);
|
|
23
|
-
const fetched = ref<CustomPropertyValueInfos[] | null>(null);
|
|
24
|
-
|
|
25
|
-
const fetch = async (entity: PropertyEntity, entityId: string, code: string) => {
|
|
26
|
-
fetching.value = true;
|
|
27
|
-
try {
|
|
28
|
-
fetched.value = await service.getMany(entity, entityId, code);
|
|
29
|
-
}
|
|
30
|
-
finally {
|
|
31
|
-
fetching.value = false;
|
|
32
|
-
}
|
|
33
|
-
return fetched;
|
|
34
|
-
}
|
|
6
|
+
const CustomPropertyValueServiceFactory = {
|
|
7
|
+
...ServiceFactory.addCustom("getMany", (axios, entity: PropertyEntity, entityId: string, code: string) => axios.get(CUSTOM_PROPERTY_VALUES_URL(entity, entityId, code)), (dtos: CustomPropertyValueInfosDTO[]) => dtos.map((dto: CustomPropertyValueInfosDTO) => new CustomPropertyValueInfos(dto))),
|
|
8
|
+
};
|
|
35
9
|
|
|
36
|
-
|
|
37
|
-
fetching,
|
|
38
|
-
fetch,
|
|
39
|
-
fetched
|
|
40
|
-
}
|
|
41
|
-
}
|
|
10
|
+
export const useCustomPropertyValues = ComposableFactory.custom(CustomPropertyValueServiceFactory.getMany);
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import { DeviceConnectivityDetails, DeviceConnectivityDetailsDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
2
1
|
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
2
|
+
import { DeviceConnectivityDetails, DeviceConnectivityDetailsDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
3
|
+
import { HubFactory } from "@dative-gpi/foundation-shared-services/tools/hubFactory";
|
|
3
4
|
|
|
4
|
-
import { DEVICE_CONNECTIVITY_URL } from "../../config/urls";
|
|
5
|
+
import { DEVICE_CONNECTIVITIES_HUB_URL, DEVICE_CONNECTIVITY_URL } from "../../config/urls";
|
|
6
|
+
import { HUBS } from "../../config/literals";
|
|
5
7
|
|
|
6
8
|
const DeviceConnectivityServiceFactory = new ServiceFactory<DeviceConnectivityDetailsDTO, DeviceConnectivityDetails>("deviceConnectivity", DeviceConnectivityDetails).create(factory => factory.build(
|
|
7
9
|
factory.addGet(DEVICE_CONNECTIVITY_URL),
|
|
8
|
-
factory.addNotify(
|
|
10
|
+
factory.addNotify(notify => ({
|
|
11
|
+
notifyUpdate: (connectivity: DeviceConnectivityDetails) => notify.notify("update", connectivity)
|
|
12
|
+
}))
|
|
9
13
|
));
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
const useDeviceConnectivityHub = HubFactory.create(DEVICE_CONNECTIVITIES_HUB_URL,
|
|
16
|
+
(connection) => {
|
|
17
|
+
connection.on(HUBS.UPDATE_DEVICE_CONNECTIVITY,
|
|
18
|
+
(payload: DeviceConnectivityDetailsDTO) => DeviceConnectivityServiceFactory.notifyUpdate(new DeviceConnectivityDetails(payload)));
|
|
19
|
+
},
|
|
20
|
+
async (connection) => {
|
|
21
|
+
await connection.invoke(HUBS.SUBSCRIBE);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const useDeviceConnectivity = ComposableFactory.get(DeviceConnectivityServiceFactory);
|
|
26
|
+
export const useTrackDeviceConnectivity = ComposableFactory.track(DeviceConnectivityServiceFactory);
|
|
27
|
+
export const useWatchDeviceConnectivity = HubFactory.createWatcher(useDeviceConnectivityHub);
|
|
@@ -1,25 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Ref } from "vue";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
3
|
import { ChangeDeviceOrganisationGroupDTO, ChangeDeviceOrganisationLocationDTO, CreateDeviceOrganisationDTO, DeviceOrganisationDetails, DeviceOrganisationDetailsDTO, DeviceOrganisationFilters, DeviceOrganisationInfos, DeviceOrganisationInfosDTO, UpdateDeviceOrganisationDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
4
|
-
import { ComposableFactory, onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
4
|
|
|
6
5
|
import { DEVICE_ORGANISATIONS_URL, DEVICE_ORGANISATION_URL, DEVICE_ORGANISATION_GROUP_URL, DEVICE_ORGANISATION_LOCATION_URL } from "../../config/urls";
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
import { useTrackDeviceStatuses, useWatchDeviceStatuses } from "./useDeviceStatuses";
|
|
8
|
+
import { useTrackDeviceConnectivity, useWatchDeviceConnectivity } from "./useDeviceConnectivities";
|
|
9
|
+
|
|
10
|
+
const DeviceOrganisationServiceFactory = new ServiceFactory<DeviceOrganisationDetailsDTO, DeviceOrganisationDetails>("deviceOrganisation", DeviceOrganisationDetails)
|
|
11
|
+
.create(factory => factory.build(
|
|
9
12
|
factory.addGet(DEVICE_ORGANISATION_URL),
|
|
10
13
|
factory.addGetMany<DeviceOrganisationInfosDTO, DeviceOrganisationInfos, DeviceOrganisationFilters>(DEVICE_ORGANISATIONS_URL, DeviceOrganisationInfos),
|
|
11
14
|
factory.addCreate<CreateDeviceOrganisationDTO>(DEVICE_ORGANISATIONS_URL),
|
|
12
15
|
factory.addUpdate<UpdateDeviceOrganisationDTO>(DEVICE_ORGANISATION_URL),
|
|
13
16
|
factory.addRemove(DEVICE_ORGANISATION_URL),
|
|
14
|
-
factory.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
factory.addNotify(notify => ({
|
|
18
|
+
...ServiceFactory.addCustom("changeGroup", (axios, deviceOrganisationId: string, payload: ChangeDeviceOrganisationGroupDTO) => axios.put(DEVICE_ORGANISATION_GROUP_URL(deviceOrganisationId), payload), (dto: DeviceOrganisationDetailsDTO) => {
|
|
19
|
+
const result = new DeviceOrganisationDetails(dto);
|
|
20
|
+
notify.notify("update", result);
|
|
21
|
+
return result;
|
|
22
|
+
}),
|
|
23
|
+
...ServiceFactory.addCustom("changeLocation", (axios, deviceOrganisationId: string, payload: ChangeDeviceOrganisationLocationDTO) => axios.put(DEVICE_ORGANISATION_LOCATION_URL(deviceOrganisationId), payload), (dto: DeviceOrganisationDetailsDTO) => {
|
|
24
|
+
const result = new DeviceOrganisationDetails(dto);
|
|
25
|
+
notify.notify("update", result);
|
|
26
|
+
return result;
|
|
27
|
+
})
|
|
28
|
+
}))
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
const trackDeviceOrganisation = () => {
|
|
32
|
+
const { track: trackDeviceStatuses } = useTrackDeviceStatuses();
|
|
33
|
+
const { track: trackDeviceConnectivity } = useTrackDeviceConnectivity();
|
|
34
|
+
|
|
35
|
+
const { watchOne: watchDeviceStatuses } = useWatchDeviceStatuses();
|
|
36
|
+
const { watchOne: watchDeviceConnectivity } = useWatchDeviceConnectivity();
|
|
37
|
+
|
|
38
|
+
return (deviceOrganisation: Ref<DeviceOrganisationDetails>) => {
|
|
39
|
+
watchDeviceStatuses(deviceOrganisation.value.status.id);
|
|
40
|
+
watchDeviceConnectivity(deviceOrganisation.value.connectivity.id);
|
|
41
|
+
|
|
42
|
+
trackDeviceStatuses(deviceOrganisation.value.status, s => deviceOrganisation.value.status = s);
|
|
43
|
+
trackDeviceConnectivity(deviceOrganisation.value.connectivity, c => deviceOrganisation.value.connectivity = c);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const trackDeviceOrganisations = () => {
|
|
48
|
+
const { track: trackDeviceStatuses } = useTrackDeviceStatuses();
|
|
49
|
+
const { track: trackDeviceConnectivity } = useTrackDeviceConnectivity();
|
|
50
|
+
|
|
51
|
+
const { watchMany: watchDevicesStatuses } = useWatchDeviceStatuses();
|
|
52
|
+
const { watchMany: watchDevicesConnectivity } = useWatchDeviceConnectivity();
|
|
53
|
+
|
|
54
|
+
return (deviceOrganisations: Ref<DeviceOrganisationInfos[]>) => {
|
|
55
|
+
watchDevicesStatuses();
|
|
56
|
+
watchDevicesConnectivity();
|
|
57
|
+
|
|
58
|
+
for (const deviceOrganisation of deviceOrganisations.value) {
|
|
59
|
+
trackDeviceStatuses(deviceOrganisation.status, s => deviceOrganisation.status = s);
|
|
60
|
+
trackDeviceConnectivity(deviceOrganisation.connectivity, c => deviceOrganisation.connectivity = c);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const useDeviceOrganisation = ComposableFactory.get(DeviceOrganisationServiceFactory, trackDeviceOrganisation);
|
|
66
|
+
export const useDeviceOrganisations = ComposableFactory.getMany(DeviceOrganisationServiceFactory, trackDeviceOrganisations);
|
|
67
|
+
export const useCreateDeviceOrganisation = ComposableFactory.create(DeviceOrganisationServiceFactory, trackDeviceOrganisation);
|
|
68
|
+
export const useUpdateDeviceOrganisation = ComposableFactory.update(DeviceOrganisationServiceFactory, trackDeviceOrganisation);
|
|
69
|
+
|
|
23
70
|
export const useRemoveDeviceOrganisation = ComposableFactory.remove(DeviceOrganisationServiceFactory);
|
|
24
|
-
|
|
25
|
-
export const
|
|
71
|
+
|
|
72
|
+
export const useChangeDeviceOrganisationGroup = ComposableFactory.custom(DeviceOrganisationServiceFactory.changeGroup, trackDeviceOrganisation);
|
|
73
|
+
export const useChangeDeviceOrganisationLocation = ComposableFactory.custom(DeviceOrganisationServiceFactory.changeLocation, trackDeviceOrganisation);
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
import { DeviceStatusDetails, DeviceStatusDetailsDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
2
1
|
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
2
|
+
import { DeviceStatusDetails, DeviceStatusDetailsDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
3
|
+
import { HubFactory } from "@dative-gpi/foundation-shared-services/tools/hubFactory";
|
|
3
4
|
|
|
4
|
-
import { DEVICE_STATUS_URL } from "../../config/urls";
|
|
5
|
+
import { DEVICE_STATUSES_HUB_URL, DEVICE_STATUS_URL } from "../../config/urls";
|
|
6
|
+
import { HUBS } from "../../config/literals";
|
|
5
7
|
|
|
6
8
|
const DeviceStatusServiceFactory = new ServiceFactory<DeviceStatusDetailsDTO, DeviceStatusDetails>("deviceStatus", DeviceStatusDetails).create(factory => factory.build(
|
|
7
9
|
factory.addGet(DEVICE_STATUS_URL),
|
|
8
|
-
factory.addNotify(
|
|
10
|
+
factory.addNotify(notify => ({
|
|
11
|
+
notifyUpdate: (status: DeviceStatusDetails) => notify.notify("update", status)
|
|
12
|
+
}))
|
|
9
13
|
));
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
const useDeviceStatusesHub = HubFactory.create(DEVICE_STATUSES_HUB_URL,
|
|
16
|
+
(connection) => {
|
|
17
|
+
connection.on(HUBS.UPDATE_DEVICE_STATUS,
|
|
18
|
+
(payload: DeviceStatusDetailsDTO) => DeviceStatusServiceFactory.notifyUpdate(new DeviceStatusDetails(payload)));
|
|
19
|
+
},
|
|
20
|
+
async (connection) => {
|
|
21
|
+
await connection.invoke(HUBS.SUBSCRIBE);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const useDeviceStatus = ComposableFactory.get(DeviceStatusServiceFactory);
|
|
26
|
+
export const useTrackDeviceStatuses = ComposableFactory.track(DeviceStatusServiceFactory);
|
|
27
|
+
export const useWatchDeviceStatuses = HubFactory.createWatcher(useDeviceStatusesHub);
|
|
@@ -9,8 +9,13 @@ const GroupServiceFactory = new ServiceFactory<GroupDetailsDTO, GroupDetails>("g
|
|
|
9
9
|
factory.addCreate<CreateGroupDTO>(GROUPS_URL),
|
|
10
10
|
factory.addUpdate<UpdateGroupDTO>(GROUP_URL),
|
|
11
11
|
factory.addRemove(GROUP_URL),
|
|
12
|
-
factory.
|
|
13
|
-
|
|
12
|
+
factory.addNotify(notify => ({
|
|
13
|
+
...ServiceFactory.addCustom("changeParent", (axios, groupdId: string, payload: ChangeGroupParentDTO) => axios.put(GROUP_URL(groupdId), payload), (dto: GroupDetailsDTO) => {
|
|
14
|
+
const result = new GroupDetails(dto);
|
|
15
|
+
notify.notify("update", result);
|
|
16
|
+
return result;
|
|
17
|
+
})
|
|
18
|
+
}))
|
|
14
19
|
));
|
|
15
20
|
|
|
16
21
|
export const useGroup = ComposableFactory.get(GroupServiceFactory);
|
|
@@ -18,4 +23,4 @@ export const useGroups = ComposableFactory.getMany(GroupServiceFactory);
|
|
|
18
23
|
export const useCreateGroup = ComposableFactory.create(GroupServiceFactory);
|
|
19
24
|
export const useUpdateGroup = ComposableFactory.update(GroupServiceFactory);
|
|
20
25
|
export const useRemoveGroup = ComposableFactory.remove(GroupServiceFactory);
|
|
21
|
-
export const useChangeGroupParent = ComposableFactory.custom(GroupServiceFactory
|
|
26
|
+
export const useChangeGroupParent = ComposableFactory.custom(GroupServiceFactory.changeParent);
|
|
@@ -5,8 +5,13 @@ import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
|
5
5
|
import { ORGANISATION_DASHBOARD_URL } from "../../config/urls";
|
|
6
6
|
|
|
7
7
|
const OrganisationServiceFactory = new ServiceFactory<OrganisationDetailsDTO, OrganisationDetails>("organisation", OrganisationDetails).create(factory => factory.build(
|
|
8
|
-
factory.
|
|
9
|
-
|
|
8
|
+
factory.addNotify(notify => ({
|
|
9
|
+
...ServiceFactory.addCustom("changeDashboard", (axios, payload: ChangeOrganisationDashboardDTO) => axios.put(ORGANISATION_DASHBOARD_URL(), payload), (dto: OrganisationDetailsDTO) => {
|
|
10
|
+
const result = new OrganisationDetails(dto);
|
|
11
|
+
notify.notify("update", result);
|
|
12
|
+
return result;
|
|
13
|
+
})
|
|
14
|
+
}))
|
|
10
15
|
));
|
|
11
16
|
|
|
12
|
-
export const useChangeDashboardOrganisation = ComposableFactory.custom(OrganisationServiceFactory
|
|
17
|
+
export const useChangeDashboardOrganisation = ComposableFactory.custom(OrganisationServiceFactory.changeDashboard);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref } from "vue";
|
|
2
2
|
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
|
+
import { CreateUserOrganisationDTO, UpdateUserOrganisationDTO, UserOrganisationDetails, UserOrganisationDetailsDTO, UserOrganisationFilters, UserOrganisationInfos, UserOrganisationInfosDTO } from "@dative-gpi/foundation-core-domain/models";
|
|
3
4
|
|
|
4
5
|
import { USER_ORGANISATIONS_URL, USER_ORGANISATION_CURRENT_URL, USER_ORGANISATION_URL } from "../../config/urls";
|
|
5
6
|
|
|
@@ -9,15 +10,32 @@ const UserOrganisationServiceFactory = new ServiceFactory<UserOrganisationDetail
|
|
|
9
10
|
factory.addCreate<CreateUserOrganisationDTO>(USER_ORGANISATIONS_URL),
|
|
10
11
|
factory.addUpdate<UpdateUserOrganisationDTO>(USER_ORGANISATION_URL),
|
|
11
12
|
factory.addRemove(USER_ORGANISATION_URL),
|
|
12
|
-
|
|
13
|
-
factory.
|
|
14
|
-
|
|
13
|
+
ServiceFactory.addCustom("getCurrent", (axios) => axios.get(USER_ORGANISATION_CURRENT_URL()), (dto: UserOrganisationDetailsDTO) => new UserOrganisationDetails(dto)),
|
|
14
|
+
factory.addNotify(notify => ({
|
|
15
|
+
...ServiceFactory.addCustom("updateCurrent", (axios, payload: UpdateUserOrganisationDTO) => axios.post(USER_ORGANISATION_CURRENT_URL(), payload), (dto: UserOrganisationDetailsDTO) => {
|
|
16
|
+
const result = new UserOrganisationDetails(dto)
|
|
17
|
+
notify.notify("update", result);
|
|
18
|
+
return result;
|
|
19
|
+
}),
|
|
20
|
+
}))
|
|
15
21
|
));
|
|
16
22
|
|
|
23
|
+
export const useTrackUserOrganisation = ComposableFactory.track(UserOrganisationServiceFactory);
|
|
24
|
+
export const useTrackUserOrganisationRef = ComposableFactory.trackRef(UserOrganisationServiceFactory);
|
|
25
|
+
|
|
26
|
+
const trackUserOrganisation = () => {
|
|
27
|
+
const { track } = useTrackUserOrganisationRef();
|
|
28
|
+
|
|
29
|
+
return (userOrganisation: Ref<UserOrganisationDetails>) => {
|
|
30
|
+
track(userOrganisation);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
export const useUserOrganisation = ComposableFactory.get(UserOrganisationServiceFactory);
|
|
18
35
|
export const useUserOrganisations = ComposableFactory.getMany(UserOrganisationServiceFactory);
|
|
19
36
|
export const useCreateUserOrganisation = ComposableFactory.create(UserOrganisationServiceFactory);
|
|
20
37
|
export const useUpdateUserOrganisation = ComposableFactory.update(UserOrganisationServiceFactory);
|
|
21
38
|
export const useRemoveUserOrganisation = ComposableFactory.remove(UserOrganisationServiceFactory);
|
|
22
|
-
|
|
23
|
-
export const
|
|
39
|
+
|
|
40
|
+
export const useCurrentUserOrganisation = ComposableFactory.custom(UserOrganisationServiceFactory.getCurrent, trackUserOrganisation);
|
|
41
|
+
export const useUpdateCurrentUserOrganisation = ComposableFactory.custom(UserOrganisationServiceFactory.updateCurrent, trackUserOrganisation);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-core-services",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.55",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/bones-ui": "^0.0.
|
|
14
|
-
"@dative-gpi/foundation-core-domain": "0.0.
|
|
13
|
+
"@dative-gpi/bones-ui": "^0.0.73",
|
|
14
|
+
"@dative-gpi/foundation-core-domain": "0.0.55",
|
|
15
15
|
"@microsoft/signalr": "^8.0.0",
|
|
16
16
|
"vue": "^3.2.0",
|
|
17
17
|
"vue-router": "^4.2.5"
|
|
18
18
|
},
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "c7ec3fb302319a1f49bb44f60c288eda9dec57d6"
|
|
20
20
|
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { onMounted, ref, watch } from "vue";
|
|
2
|
-
|
|
3
|
-
import * as signalR from "@microsoft/signalr";
|
|
4
|
-
|
|
5
|
-
import { useNotifyAlert, useNotifyRemoveAlert } from "../services/useAlerts";
|
|
6
|
-
import { ALERTS_HUB_URL } from "../../config/urls";
|
|
7
|
-
import { HUBS } from "../../config/literals";
|
|
8
|
-
|
|
9
|
-
let initialized = false;
|
|
10
|
-
|
|
11
|
-
const connection = ref<signalR.HubConnection | null>(null);
|
|
12
|
-
|
|
13
|
-
export const useAlertsHub = () => {
|
|
14
|
-
if (!initialized) {
|
|
15
|
-
onMounted(async () => {
|
|
16
|
-
if (!connection.value) {
|
|
17
|
-
connection.value = new signalR.HubConnectionBuilder()
|
|
18
|
-
.withUrl(ALERTS_HUB_URL())
|
|
19
|
-
.configureLogging(signalR.LogLevel.Warning)
|
|
20
|
-
.withAutomaticReconnect()
|
|
21
|
-
.build();
|
|
22
|
-
}
|
|
23
|
-
if (connection.value.state !== signalR.HubConnectionState.Connected) {
|
|
24
|
-
await connection.value.start();
|
|
25
|
-
}
|
|
26
|
-
connection.value.invoke(HUBS.SUBSCRIBE);
|
|
27
|
-
connection.value.on(HUBS.CREATE_ALERT, (alertId: string) => useNotifyAlert().fetch(alertId));
|
|
28
|
-
connection.value.on(HUBS.UPDATE_ALERT, (alertId: string) => useNotifyAlert().fetch(alertId));
|
|
29
|
-
connection.value.on(HUBS.REMOVE_ALERT, (alertId: string) => useNotifyRemoveAlert().remove(alertId));
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
initialized = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const ready = new Promise((resolve) => {
|
|
36
|
-
if (connection.value && connection.value.state === signalR.HubConnectionState.Connected) {
|
|
37
|
-
resolve(true);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
watch(connection, () => {
|
|
41
|
-
if (connection.value && connection.value.state === signalR.HubConnectionState.Connected) {
|
|
42
|
-
resolve(true);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
ready
|
|
50
|
-
};
|
|
51
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { onMounted, ref, watch } from "vue";
|
|
2
|
-
|
|
3
|
-
import * as signalR from "@microsoft/signalr";
|
|
4
|
-
|
|
5
|
-
import { useNotifyConnectivityAlert, useNotifyRemoveConnectivityAlert } from "../services/useConnectivityAlerts";
|
|
6
|
-
import { CONNECTIVITY_ALERTS_HUB_URL } from "../../config/urls";
|
|
7
|
-
import { HUBS } from "../../config/literals";
|
|
8
|
-
|
|
9
|
-
let initialized = false;
|
|
10
|
-
|
|
11
|
-
const connection = ref<signalR.HubConnection | null>(null);
|
|
12
|
-
|
|
13
|
-
export const useConnectivityAlertsHub = () => {
|
|
14
|
-
if (!initialized) {
|
|
15
|
-
onMounted(async () => {
|
|
16
|
-
if (!connection.value) {
|
|
17
|
-
connection.value = new signalR.HubConnectionBuilder()
|
|
18
|
-
.withUrl(CONNECTIVITY_ALERTS_HUB_URL())
|
|
19
|
-
.configureLogging(signalR.LogLevel.Warning)
|
|
20
|
-
.withAutomaticReconnect()
|
|
21
|
-
.build();
|
|
22
|
-
}
|
|
23
|
-
if (connection.value.state !== signalR.HubConnectionState.Connected) {
|
|
24
|
-
await connection.value.start();
|
|
25
|
-
}
|
|
26
|
-
connection.value.invoke(HUBS.SUBSCRIBE);
|
|
27
|
-
connection.value.on(HUBS.CREATE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyConnectivityAlert().fetch(connectivityAlertId));
|
|
28
|
-
connection.value.on(HUBS.UPDATE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyConnectivityAlert().fetch(connectivityAlertId));
|
|
29
|
-
connection.value.on(HUBS.REMOVE_CONNECTIVITY_ALERT, (connectivityAlertId: string) => useNotifyRemoveConnectivityAlert().remove(connectivityAlertId));
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
initialized = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const ready = new Promise((resolve) => {
|
|
36
|
-
if (connection.value && connection.value.state === signalR.HubConnectionState.Connected) {
|
|
37
|
-
resolve(true);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
watch(connection, () => {
|
|
41
|
-
if (connection.value && connection.value.state === signalR.HubConnectionState.Connected) {
|
|
42
|
-
resolve(true);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
ready
|
|
50
|
-
};
|
|
51
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { onMounted, ref, watch } from "vue";
|
|
2
|
-
|
|
3
|
-
import * as signalR from "@microsoft/signalr";
|
|
4
|
-
|
|
5
|
-
import { useNotifyDeviceConnectivity } from "../services/useDeviceConnectivities";
|
|
6
|
-
import { DEVICE_CONNECTIVITIES_HUB_URL } from "../../config/urls";
|
|
7
|
-
import { HUBS } from "../../config/literals";
|
|
8
|
-
|
|
9
|
-
let initialized = false;
|
|
10
|
-
|
|
11
|
-
const connection = ref<signalR.HubConnection | null>(null);
|
|
12
|
-
|
|
13
|
-
export const useDeviceConnectivitiesHub = () => {
|
|
14
|
-
if (!initialized) {
|
|
15
|
-
onMounted(async () => {
|
|
16
|
-
if (!connection.value) {
|
|
17
|
-
connection.value = new signalR.HubConnectionBuilder()
|
|
18
|
-
.withUrl(DEVICE_CONNECTIVITIES_HUB_URL())
|
|
19
|
-
.configureLogging(signalR.LogLevel.Warning)
|
|
20
|
-
.withAutomaticReconnect()
|
|
21
|
-
.build();
|
|
22
|
-
}
|
|
23
|
-
if (connection.value.state !== signalR.HubConnectionState.Connected) {
|
|
24
|
-
await connection.value.start();
|
|
25
|
-
}
|
|
26
|
-
connection.value.invoke(HUBS.SUBSCRIBE);
|
|
27
|
-
connection.value.on(HUBS.UPDATE_DEVICE_CONNECTIVITY, (deviceOrganisationId: string) => useNotifyDeviceConnectivity().fetch(deviceOrganisationId));
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
initialized = true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const ready = new Promise((resolve) => {
|
|
34
|
-
if (connection.value && connection.value.state === signalR.HubConnectionState.Connected) {
|
|
35
|
-
resolve(true);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
watch(connection, () => {
|
|
39
|
-
if (connection.value && connection.value.state === signalR.HubConnectionState.Connected) {
|
|
40
|
-
resolve(true);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
ready
|
|
48
|
-
};
|
|
49
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { onMounted, ref, watch } from "vue";
|
|
2
|
-
|
|
3
|
-
import * as signalR from "@microsoft/signalr";
|
|
4
|
-
|
|
5
|
-
import { useNotifyDeviceStatus } from "../services/useDeviceStatuses";
|
|
6
|
-
import { DEVICE_STATUSES_HUB_URL } from "../../config/urls";
|
|
7
|
-
import { HUBS } from "../../config/literals";
|
|
8
|
-
|
|
9
|
-
let initialized = false;
|
|
10
|
-
|
|
11
|
-
const connection = ref<signalR.HubConnection | null>(null);
|
|
12
|
-
|
|
13
|
-
export const useDeviceStatusesHub = () => {
|
|
14
|
-
if (!initialized) {
|
|
15
|
-
onMounted(async () => {
|
|
16
|
-
if (!connection.value) {
|
|
17
|
-
connection.value = new signalR.HubConnectionBuilder()
|
|
18
|
-
.withUrl(DEVICE_STATUSES_HUB_URL())
|
|
19
|
-
.configureLogging(signalR.LogLevel.Warning)
|
|
20
|
-
.withAutomaticReconnect()
|
|
21
|
-
.build();
|
|
22
|
-
}
|
|
23
|
-
if (connection.value.state !== signalR.HubConnectionState.Connected) {
|
|
24
|
-
await connection.value.start();
|
|
25
|
-
}
|
|
26
|
-
connection.value.invoke(HUBS.SUBSCRIBE);
|
|
27
|
-
connection.value.on(HUBS.UPDATE_DEVICE_STATUS, (deviceOrganisationId: string) => useNotifyDeviceStatus().fetch(deviceOrganisationId));
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
initialized = true;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const ready = new Promise((resolve) => {
|
|
34
|
-
if (connection.value && connection.value.state === signalR.HubConnectionState.Connected) {
|
|
35
|
-
resolve(true);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
watch(connection, () => {
|
|
39
|
-
if (connection.value && connection.value.state === signalR.HubConnectionState.Connected) {
|
|
40
|
-
resolve(true);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
ready
|
|
48
|
-
};
|
|
49
|
-
}
|