@dative-gpi/foundation-core-services 0.0.2
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/hubs/index.ts +4 -0
- package/composables/hubs/useAlertsHub.ts +51 -0
- package/composables/hubs/useConnectivityAlertsHub.ts +51 -0
- package/composables/hubs/useDeviceConnectivitiesHub.ts +49 -0
- package/composables/hubs/useDeviceStatusesHub.ts +49 -0
- package/composables/index.ts +5 -0
- package/composables/services/index.ts +27 -0
- package/composables/services/useAlerts.ts +95 -0
- package/composables/services/useApplications.ts +47 -0
- package/composables/services/useArticles.ts +13 -0
- package/composables/services/useAuthTokens.ts +15 -0
- package/composables/services/useConnectivityAlerts.ts +60 -0
- package/composables/services/useCustomProperties.ts +11 -0
- package/composables/services/useCustomPropertyValues.ts +42 -0
- package/composables/services/useDataCategories.ts +13 -0
- package/composables/services/useDataDefinitions.ts +13 -0
- package/composables/services/useDeviceConnectivities.ts +46 -0
- package/composables/services/useDeviceOrganisations.ts +92 -0
- package/composables/services/useDeviceStatuses.ts +46 -0
- package/composables/services/useFamilies.ts +13 -0
- package/composables/services/useGroups.ts +57 -0
- package/composables/services/useLanguages.ts +13 -0
- package/composables/services/useLocations.ts +13 -0
- package/composables/services/useManufacturers.ts +13 -0
- package/composables/services/useModels.ts +13 -0
- package/composables/services/useOrganisationTypes.ts +13 -0
- package/composables/services/useOrganisations.ts +53 -0
- package/composables/services/usePermissionCategories.ts +11 -0
- package/composables/services/usePermissions.ts +42 -0
- package/composables/services/useRoleOrganisationTypes.ts +13 -0
- package/composables/services/useRoleOrganisations.ts +13 -0
- package/composables/services/useTimeZones.ts +11 -0
- package/composables/services/useTranslations.ts +42 -0
- package/composables/services/useUserOrganisations.ts +92 -0
- package/composables/services/useUsers.ts +90 -0
- package/composables/useLanguageCode.ts +48 -0
- package/composables/useOrganisationId.ts +50 -0
- package/composables/useTimeZone.ts +75 -0
- package/config/index.ts +2 -0
- package/config/literals/hubs.ts +14 -0
- package/config/literals/index.ts +5 -0
- package/config/urls/alerts.ts +6 -0
- package/config/urls/applications.ts +4 -0
- package/config/urls/articles.ts +4 -0
- package/config/urls/authTokens.ts +4 -0
- package/config/urls/base.ts +5 -0
- package/config/urls/connectivityAlerts.ts +6 -0
- package/config/urls/customProperties.ts +3 -0
- package/config/urls/customPropertyValues.ts +5 -0
- package/config/urls/dataCategories.ts +4 -0
- package/config/urls/dataDefinitions.ts +4 -0
- package/config/urls/deviceConnectivities.ts +6 -0
- package/config/urls/deviceOrganisations.ts +6 -0
- package/config/urls/deviceStatuses.ts +6 -0
- package/config/urls/families.ts +4 -0
- package/config/urls/files.ts +4 -0
- package/config/urls/groups.ts +4 -0
- package/config/urls/images.ts +5 -0
- package/config/urls/index.ts +29 -0
- package/config/urls/languages.ts +4 -0
- package/config/urls/locations.ts +4 -0
- package/config/urls/manufacturers.ts +4 -0
- package/config/urls/models.ts +4 -0
- package/config/urls/organisationTypes.ts +4 -0
- package/config/urls/organisations.ts +7 -0
- package/config/urls/permissionCategories.ts +3 -0
- package/config/urls/permissions.ts +3 -0
- package/config/urls/roleOrganisationTypes.ts +4 -0
- package/config/urls/roleOrganisations.ts +4 -0
- package/config/urls/timeZones.ts +3 -0
- package/config/urls/translations.ts +4 -0
- package/config/urls/urlFactory.ts +17 -0
- package/config/urls/userOrganisations.ts +5 -0
- package/config/urls/users.ts +5 -0
- package/index.ts +2 -0
- package/package.json +19 -0
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export * from "./useAlerts";
|
|
2
|
+
export * from "./useArticles";
|
|
3
|
+
export * from "./useAuthTokens";
|
|
4
|
+
export * from "./useConnectivityAlerts";
|
|
5
|
+
export * from "./useCustomProperties";
|
|
6
|
+
export * from "./useCustomPropertyValues";
|
|
7
|
+
export * from "./useDataCategories";
|
|
8
|
+
export * from "./useDataDefinitions";
|
|
9
|
+
export * from "./useDeviceConnectivities";
|
|
10
|
+
export * from "./useDeviceOrganisations";
|
|
11
|
+
export * from "./useDeviceStatuses";
|
|
12
|
+
export * from "./useFamilies";
|
|
13
|
+
export * from "./useGroups";
|
|
14
|
+
export * from "./useLanguages";
|
|
15
|
+
export * from "./useLocations";
|
|
16
|
+
export * from "./useManufacturers";
|
|
17
|
+
export * from "./useModels";
|
|
18
|
+
export * from "./useOrganisations";
|
|
19
|
+
export * from "./useOrganisationTypes";
|
|
20
|
+
export * from "./usePermissionCategories";
|
|
21
|
+
export * from "./usePermissions";
|
|
22
|
+
export * from "./useRoleOrganisations";
|
|
23
|
+
export * from "./useRoleOrganisationTypes";
|
|
24
|
+
export * from "./useTimeZones";
|
|
25
|
+
export * from "./useTranslations";
|
|
26
|
+
export * from "./useUserOrganisations";
|
|
27
|
+
export * from "./useUsers";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Ref, onUnmounted, readonly, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import { AlertDetails, AlertDetailsDTO, AlertFilters, AlertInfos, AlertInfosDTO } from "@dative-gpi/foundation-core-domain";
|
|
4
|
+
import { ComposableFactory, onEntityChanged , ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
|
+
|
|
6
|
+
import { ALERTS_URL, ALERT_URL } from "../../config/urls";
|
|
7
|
+
|
|
8
|
+
const AlertServiceFactory = new ServiceFactory<AlertDetailsDTO, AlertDetails>("alert", AlertDetails).create(factory => factory.build(
|
|
9
|
+
factory.addGet(ALERT_URL),
|
|
10
|
+
factory.addGetMany<AlertInfosDTO, AlertInfos, AlertFilters>(ALERTS_URL, AlertInfos),
|
|
11
|
+
factory.addRemove(ALERT_URL),
|
|
12
|
+
factory.addNotify((notifyService) => ({
|
|
13
|
+
acknowledge: async (alertId: string): Promise<AlertDetails> => {
|
|
14
|
+
const response = await ServiceFactory.http.patch(ALERT_URL(alertId));
|
|
15
|
+
const result = new AlertDetails(response.data);
|
|
16
|
+
|
|
17
|
+
notifyService.notify("update", result);
|
|
18
|
+
|
|
19
|
+
return result;
|
|
20
|
+
},
|
|
21
|
+
getNotify: async (alertId: string): Promise<AlertDetails> => {
|
|
22
|
+
const response = await ServiceFactory.http.get(ALERT_URL(alertId));
|
|
23
|
+
const result = new AlertDetails(response.data);
|
|
24
|
+
|
|
25
|
+
notifyService.notify("update", result);
|
|
26
|
+
|
|
27
|
+
return result;
|
|
28
|
+
},
|
|
29
|
+
removeNotify: (alertId: string): void => {
|
|
30
|
+
notifyService.notify("delete", alertId);
|
|
31
|
+
}
|
|
32
|
+
}))
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
export const useAlert = ComposableFactory.get(AlertServiceFactory);
|
|
36
|
+
export const useAlerts = ComposableFactory.getMany(AlertServiceFactory);
|
|
37
|
+
export const useRemoveAlert = ComposableFactory.remove(AlertServiceFactory);
|
|
38
|
+
export const useAcknowledgeAlert = () => {
|
|
39
|
+
const service = AlertServiceFactory();
|
|
40
|
+
|
|
41
|
+
const changing = ref(false);
|
|
42
|
+
const changed = ref<AlertDetails | null>(null) as Ref<AlertDetails | null>;
|
|
43
|
+
|
|
44
|
+
const change = async (alertId: string) => {
|
|
45
|
+
changing.value = true;
|
|
46
|
+
try {
|
|
47
|
+
changed.value = await service.acknowledge(alertId);
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
changing.value = false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const subscriberId = service.subscribe("all", onEntityChanged(changed))
|
|
54
|
+
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
55
|
+
|
|
56
|
+
return readonly(changed as Ref<AlertDetails>);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
changing: readonly(changing),
|
|
61
|
+
change,
|
|
62
|
+
changed: readonly(changed)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export const useNotifyAlert = () => {
|
|
66
|
+
const service = AlertServiceFactory();
|
|
67
|
+
|
|
68
|
+
const fetching = ref(false);
|
|
69
|
+
const fetched = ref<AlertDetails | null>(null) as Ref<AlertDetails | null>;
|
|
70
|
+
|
|
71
|
+
const fetch = async (alertId: string) => {
|
|
72
|
+
fetching.value = true;
|
|
73
|
+
try {
|
|
74
|
+
fetched.value = await service.getNotify(alertId);
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
fetching.value = false;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return readonly(fetched as Ref<AlertDetails>);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
fetching: readonly(fetching),
|
|
85
|
+
fetch,
|
|
86
|
+
fetched: readonly(fetched)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
export const useNotifyRemoveAlert = () => {
|
|
90
|
+
const service = AlertServiceFactory();
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
remove: service.removeNotify
|
|
94
|
+
};
|
|
95
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Ref, onUnmounted, readonly, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import { ApplicationDetails, ApplicationDetailsDTO } from "@dative-gpi/foundation-core-domain";
|
|
4
|
+
import { onEntityChanged, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
|
+
|
|
6
|
+
import { APPLICATION_CURRENT_URL } from "../../config/urls";
|
|
7
|
+
|
|
8
|
+
const ApplicationServiceFactory = new ServiceFactory<ApplicationDetailsDTO, ApplicationDetails>("application", ApplicationDetails).create(factory => factory.build(
|
|
9
|
+
factory.addNotify((notifyService) => ({
|
|
10
|
+
getCurrent: async (): Promise<ApplicationDetails> => {
|
|
11
|
+
const response = await ServiceFactory.http.get(APPLICATION_CURRENT_URL);
|
|
12
|
+
const result = new ApplicationDetails(response.data);
|
|
13
|
+
|
|
14
|
+
notifyService.notify("update", result);
|
|
15
|
+
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
}))
|
|
19
|
+
));
|
|
20
|
+
|
|
21
|
+
export const useCurrentApplication = () => {
|
|
22
|
+
const service = ApplicationServiceFactory();
|
|
23
|
+
|
|
24
|
+
const fetching = ref(false);
|
|
25
|
+
const fetched = ref<ApplicationDetails | null>(null) as Ref<ApplicationDetails | null>;
|
|
26
|
+
|
|
27
|
+
const fetch = async () => {
|
|
28
|
+
fetching.value = true;
|
|
29
|
+
try {
|
|
30
|
+
fetched.value = await service.getCurrent();
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
fetching.value = false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const subscriberId = service.subscribe("all", onEntityChanged(fetched))
|
|
37
|
+
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
38
|
+
|
|
39
|
+
return readonly(fetched as Ref<ApplicationDetails>);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
fetching: readonly(fetching),
|
|
44
|
+
fetch,
|
|
45
|
+
fetched: readonly(fetched)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ArticleDetails, ArticleDetailsDTO, ArticleFilters, ArticleInfos, ArticleInfosDTO } from "@dative-gpi/foundation-core-domain";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
|
+
|
|
4
|
+
import { ARTICLES_URL, ARTICLE_URL } from "../../config/urls";
|
|
5
|
+
|
|
6
|
+
const ArticleServiceFactory = new ServiceFactory<ArticleDetailsDTO, ArticleDetails>("article", ArticleDetails).create(factory => factory.build(
|
|
7
|
+
factory.addGet(ARTICLE_URL),
|
|
8
|
+
factory.addGetMany<ArticleInfosDTO, ArticleInfos, ArticleFilters>(ARTICLES_URL, ArticleInfos),
|
|
9
|
+
factory.addNotify()
|
|
10
|
+
));
|
|
11
|
+
|
|
12
|
+
export const useArticle = ComposableFactory.get(ArticleServiceFactory);
|
|
13
|
+
export const useArticles = ComposableFactory.getMany(ArticleServiceFactory);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AuthTokenDetails, AuthTokenDetailsDTO, AuthTokenFilters, AuthTokenInfos, AuthTokenInfosDTO, CreateAuthTokenDTO } from "@dative-gpi/foundation-core-domain";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
|
+
|
|
4
|
+
import { AUTH_TOKENS_URL, AUTH_TOKEN_URL } from "../../config/urls";
|
|
5
|
+
|
|
6
|
+
const AuthTokenServiceFactory = new ServiceFactory<AuthTokenDetailsDTO, AuthTokenDetails>("authToken", AuthTokenDetails).create(factory => factory.build(
|
|
7
|
+
factory.addGetMany<AuthTokenInfosDTO, AuthTokenInfos, AuthTokenFilters>(AUTH_TOKENS_URL, AuthTokenInfos),
|
|
8
|
+
factory.addCreate<CreateAuthTokenDTO>(AUTH_TOKENS_URL),
|
|
9
|
+
factory.addRemove(AUTH_TOKEN_URL),
|
|
10
|
+
factory.addNotify()
|
|
11
|
+
));
|
|
12
|
+
|
|
13
|
+
export const useAuthTokens = ComposableFactory.getMany(AuthTokenServiceFactory);
|
|
14
|
+
export const useCreateAuthToken = ComposableFactory.create(AuthTokenServiceFactory);
|
|
15
|
+
export const useRemoveAuthToken = ComposableFactory.remove(AuthTokenServiceFactory);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Ref, readonly, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import { ConnectivityAlertDetails, ConnectivityAlertDetailsDTO, ConnectivityAlertFilters, ConnectivityAlertInfos, ConnectivityAlertInfosDTO } from "@dative-gpi/foundation-core-domain";
|
|
4
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
|
+
|
|
6
|
+
import { CONNECTIVITY_ALERTS_URL, CONNECTIVITY_ALERT_URL } from "../../config/urls";
|
|
7
|
+
|
|
8
|
+
const ConnectivityAlertServiceFactory = new ServiceFactory<ConnectivityAlertDetailsDTO, ConnectivityAlertDetails>("connectivityAlert", ConnectivityAlertDetails).create(factory => factory.build(
|
|
9
|
+
factory.addGet(CONNECTIVITY_ALERT_URL),
|
|
10
|
+
factory.addGetMany<ConnectivityAlertInfosDTO, ConnectivityAlertInfos, ConnectivityAlertFilters>(CONNECTIVITY_ALERTS_URL, ConnectivityAlertInfos),
|
|
11
|
+
factory.addRemove(CONNECTIVITY_ALERT_URL),
|
|
12
|
+
factory.addNotify((notifyService) => ({
|
|
13
|
+
getNotify: async (connectivityAlertId: string): Promise<ConnectivityAlertDetails> => {
|
|
14
|
+
const response = await ServiceFactory.http.get(CONNECTIVITY_ALERT_URL(connectivityAlertId));
|
|
15
|
+
const result = new ConnectivityAlertDetails(response.data);
|
|
16
|
+
|
|
17
|
+
notifyService.notify("update", result);
|
|
18
|
+
|
|
19
|
+
return result;
|
|
20
|
+
},
|
|
21
|
+
removeNotify: (connectivityAlertId: string): void => {
|
|
22
|
+
notifyService.notify("delete", connectivityAlertId);
|
|
23
|
+
}
|
|
24
|
+
}))
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
export const useConnectivityAlert = ComposableFactory.get(ConnectivityAlertServiceFactory);
|
|
28
|
+
export const useConnectivityAlerts = ComposableFactory.getMany(ConnectivityAlertServiceFactory);
|
|
29
|
+
export const useRemoveConnectivityAlert = ComposableFactory.remove(ConnectivityAlertServiceFactory);
|
|
30
|
+
export const useNotifyConnectivityAlert = () => {
|
|
31
|
+
const service = ConnectivityAlertServiceFactory();
|
|
32
|
+
|
|
33
|
+
const fetching = ref(false);
|
|
34
|
+
const fetched = ref<ConnectivityAlertDetails | null>(null) as Ref<ConnectivityAlertDetails | null>;
|
|
35
|
+
|
|
36
|
+
const fetch = async (connectivityAlertId: string) => {
|
|
37
|
+
fetching.value = true;
|
|
38
|
+
try {
|
|
39
|
+
fetched.value = await service.getNotify(connectivityAlertId);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
fetching.value = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return readonly(fetched as Ref<ConnectivityAlertDetails>);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
fetching: readonly(fetching),
|
|
50
|
+
fetch,
|
|
51
|
+
notified: readonly(fetched)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export const useNotifyRemoveConnectivityAlert = () => {
|
|
55
|
+
const service = ConnectivityAlertServiceFactory();
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
remove: service.removeNotify
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CustomPropertyDetails, CustomPropertyDetailsDTO, CustomPropertyFilters, CustomPropertyInfos, CustomPropertyInfosDTO } from "@dative-gpi/foundation-core-domain";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
|
+
|
|
4
|
+
import { CUSTOM_PROPERTIES_URL } from "../../config/urls";
|
|
5
|
+
|
|
6
|
+
const CustomPropertyServiceFactory = new ServiceFactory<CustomPropertyDetailsDTO, CustomPropertyDetails>("customProperty", CustomPropertyDetails).create(factory => factory.build(
|
|
7
|
+
factory.addGetMany<CustomPropertyInfosDTO, CustomPropertyInfos, CustomPropertyFilters>(CUSTOM_PROPERTIES_URL, CustomPropertyInfos),
|
|
8
|
+
factory.addNotify()
|
|
9
|
+
));
|
|
10
|
+
|
|
11
|
+
export const useCustomProperties = ComposableFactory.getMany(CustomPropertyServiceFactory);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Ref, readonly, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import { CustomPropertyValueDetails, CustomPropertyValueDetailsDTO, CustomPropertyValueInfos, CustomPropertyValueInfosDTO, PropertyEntity } from "@dative-gpi/foundation-core-domain";
|
|
4
|
+
import { ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
|
+
|
|
6
|
+
import { CUSTOM_PROPERTY_VALUES_URL } from "../../config/urls";
|
|
7
|
+
|
|
8
|
+
const CustomPropertyValueServiceFactory = new ServiceFactory<CustomPropertyValueDetailsDTO, CustomPropertyValueDetails>("customPropertyValue", CustomPropertyValueDetails).create(factory => factory.build(
|
|
9
|
+
factory.addNotify(() => ({
|
|
10
|
+
getMany: async (entity: PropertyEntity, entityId: string, code: string): Promise<CustomPropertyValueInfos[]> => {
|
|
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) as Ref<CustomPropertyValueInfos[] | 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
|
+
|
|
34
|
+
return readonly(fetched as Ref<CustomPropertyValueInfos[]>);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
fetching: readonly(fetching),
|
|
39
|
+
fetch,
|
|
40
|
+
fetched: readonly(fetched)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DataCategoryDetails, DataCategoryDetailsDTO, DataCategoryFilters, DataCategoryInfos, DataCategoryInfosDTO } from "@dative-gpi/foundation-core-domain";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
|
+
|
|
4
|
+
import { DATA_CATEGORIES_URL, DATA_CATEGORY_URL } from "../../config/urls";
|
|
5
|
+
|
|
6
|
+
const DataCategoryServiceFactory = new ServiceFactory<DataCategoryDetailsDTO, DataCategoryDetails>("dataCategory", DataCategoryDetails).create(factory => factory.build(
|
|
7
|
+
factory.addGet(DATA_CATEGORY_URL),
|
|
8
|
+
factory.addGetMany<DataCategoryInfosDTO, DataCategoryInfos, DataCategoryFilters>(DATA_CATEGORIES_URL, DataCategoryInfos),
|
|
9
|
+
factory.addNotify()
|
|
10
|
+
));
|
|
11
|
+
|
|
12
|
+
export const useDataCategory = ComposableFactory.get(DataCategoryServiceFactory);
|
|
13
|
+
export const useDataCategories = ComposableFactory.getMany(DataCategoryServiceFactory);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DataDefinitionDetails, DataDefinitionDetailsDTO, DataDefinitionFilters, DataDefinitionInfos, DataDefinitionInfosDTO } from "@dative-gpi/foundation-core-domain";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
|
+
|
|
4
|
+
import { DATA_DEFINITIONS_URL, DATA_DEFINITION_URL } from "../../config/urls";
|
|
5
|
+
|
|
6
|
+
const DataDefinitionServiceFactory = new ServiceFactory<DataDefinitionDetailsDTO, DataDefinitionDetails>("dataDefinition", DataDefinitionDetails).create(factory => factory.build(
|
|
7
|
+
factory.addGet(DATA_DEFINITION_URL),
|
|
8
|
+
factory.addGetMany<DataDefinitionInfosDTO, DataDefinitionInfos, DataDefinitionFilters>(DATA_DEFINITIONS_URL, DataDefinitionInfos),
|
|
9
|
+
factory.addNotify()
|
|
10
|
+
));
|
|
11
|
+
|
|
12
|
+
export const useDataDefinition = ComposableFactory.get(DataDefinitionServiceFactory);
|
|
13
|
+
export const useDataDefinitions = ComposableFactory.getMany(DataDefinitionServiceFactory);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Ref, readonly, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
import { DeviceConnectivityDetails, DeviceConnectivityDetailsDTO } from "@dative-gpi/foundation-core-domain";
|
|
4
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
|
+
|
|
6
|
+
import { DEVICE_CONNECTIVITY_URL } from "../../config/urls";
|
|
7
|
+
|
|
8
|
+
const DeviceConnectivityServiceFactory = new ServiceFactory<DeviceConnectivityDetailsDTO, DeviceConnectivityDetails>("deviceConnectivity", DeviceConnectivityDetails).create(factory => factory.build(
|
|
9
|
+
factory.addGet(DEVICE_CONNECTIVITY_URL),
|
|
10
|
+
factory.addNotify((notifyService) => ({
|
|
11
|
+
getNotify: async (deviceConnectivityId: string): Promise<DeviceConnectivityDetails> => {
|
|
12
|
+
const response = await ServiceFactory.http.get(DEVICE_CONNECTIVITY_URL(deviceConnectivityId));
|
|
13
|
+
const result = new DeviceConnectivityDetails(response.data);
|
|
14
|
+
|
|
15
|
+
notifyService.notify("update", result);
|
|
16
|
+
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
}))
|
|
20
|
+
));
|
|
21
|
+
|
|
22
|
+
export const useDeviceConnectivity = ComposableFactory.get(DeviceConnectivityServiceFactory);
|
|
23
|
+
export const useNotifyDeviceConnectivity = () => {
|
|
24
|
+
const service = DeviceConnectivityServiceFactory();
|
|
25
|
+
|
|
26
|
+
const fetching = ref(false);
|
|
27
|
+
const fetched = ref<DeviceConnectivityDetails | null>(null) as Ref<DeviceConnectivityDetails | null>;
|
|
28
|
+
|
|
29
|
+
const fetch = async (deviceConnectivityId: string) => {
|
|
30
|
+
fetching.value = true;
|
|
31
|
+
try {
|
|
32
|
+
fetched.value = await service.getNotify(deviceConnectivityId);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
fetching.value = false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return readonly(fetched as Ref<DeviceConnectivityDetails>);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
fetching: readonly(fetching),
|
|
43
|
+
fetch,
|
|
44
|
+
fetched: readonly(fetched)
|
|
45
|
+
};
|
|
46
|
+
}
|