@dative-gpi/foundation-core-services 0.0.9 → 0.0.11
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 -1
- package/composables/services/useAlerts.ts +7 -4
- package/composables/services/useDeviceOrganisations.ts +14 -8
- package/composables/services/useGroups.ts +7 -4
- package/composables/services/useOrganisations.ts +7 -4
- package/composables/services/useTables.ts +14 -0
- package/composables/services/useUserOrganisations.ts +14 -8
- package/composables/useOrganisationId.ts +1 -7
- package/config/urls/index.ts +1 -1
- package/config/urls/tables.ts +4 -0
- package/package.json +4 -4
- package/composables/services/useUserOrganisationDispositions.ts +0 -76
- package/config/urls/userOrganisationDispositions.ts +0 -4
|
@@ -21,6 +21,6 @@ export * from "./usePermissionCategories";
|
|
|
21
21
|
export * from "./usePermissions";
|
|
22
22
|
export * from "./useRoleOrganisations";
|
|
23
23
|
export * from "./useRoleOrganisationTypes";
|
|
24
|
-
export * from "./
|
|
24
|
+
export * from "./useTables";
|
|
25
25
|
export * from "./useUserOrganisations";
|
|
26
26
|
export * from "./useUsers";
|
|
@@ -37,10 +37,16 @@ export const useAlerts = ComposableFactory.getMany(AlertServiceFactory);
|
|
|
37
37
|
export const useRemoveAlert = ComposableFactory.remove(AlertServiceFactory);
|
|
38
38
|
export const useAcknowledgeAlert = () => {
|
|
39
39
|
const service = AlertServiceFactory();
|
|
40
|
+
const subscribersIds : number[] = [];
|
|
40
41
|
|
|
41
42
|
const changing = ref(false);
|
|
42
43
|
const changed = ref<AlertDetails | null>(null) as Ref<AlertDetails | null>;
|
|
43
44
|
|
|
45
|
+
onUnmounted(() => {
|
|
46
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
47
|
+
subscribersIds.length = 0;
|
|
48
|
+
});
|
|
49
|
+
|
|
44
50
|
const change = async (alertId: string) => {
|
|
45
51
|
changing.value = true;
|
|
46
52
|
try {
|
|
@@ -49,10 +55,7 @@ export const useAcknowledgeAlert = () => {
|
|
|
49
55
|
finally {
|
|
50
56
|
changing.value = false;
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
const subscriberId = service.subscribe("all", onEntityChanged(changed))
|
|
54
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
55
|
-
|
|
58
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(changed)));
|
|
56
59
|
return readonly(changed as Ref<AlertDetails>);
|
|
57
60
|
}
|
|
58
61
|
|
|
@@ -38,10 +38,16 @@ export const useUpdateDeviceOrganisation = ComposableFactory.update(DeviceOrgani
|
|
|
38
38
|
export const useRemoveDeviceOrganisation = ComposableFactory.remove(DeviceOrganisationServiceFactory);
|
|
39
39
|
export const useChangeDeviceOrganisationGroup = () => {
|
|
40
40
|
const service = DeviceOrganisationServiceFactory();
|
|
41
|
+
const subscriberIds: number[] = [];
|
|
41
42
|
|
|
42
43
|
const changing = ref(false);
|
|
43
44
|
const changed = ref<DeviceOrganisationDetails | null>(null) as Ref<DeviceOrganisationDetails | null>;
|
|
44
45
|
|
|
46
|
+
onUnmounted(() => {
|
|
47
|
+
subscriberIds.forEach(id => service.unsubscribe(id));
|
|
48
|
+
subscriberIds.length = 0;
|
|
49
|
+
});
|
|
50
|
+
|
|
45
51
|
const change = async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationGroupDTO) => {
|
|
46
52
|
changing.value = true;
|
|
47
53
|
try {
|
|
@@ -50,10 +56,7 @@ export const useChangeDeviceOrganisationGroup = () => {
|
|
|
50
56
|
finally {
|
|
51
57
|
changing.value = false;
|
|
52
58
|
}
|
|
53
|
-
|
|
54
|
-
const subscriberId = service.subscribe("all", onEntityChanged(changed))
|
|
55
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
56
|
-
|
|
59
|
+
subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
|
|
57
60
|
return readonly(changed as Ref<DeviceOrganisationDetails>);
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -65,10 +68,16 @@ export const useChangeDeviceOrganisationGroup = () => {
|
|
|
65
68
|
}
|
|
66
69
|
export const useChangeDeviceOrganisationLocation = () => {
|
|
67
70
|
const service = DeviceOrganisationServiceFactory();
|
|
71
|
+
const subscriberIds: number[] = [];
|
|
68
72
|
|
|
69
73
|
const changing = ref(false);
|
|
70
74
|
const changed = ref<DeviceOrganisationDetails | null>(null) as Ref<DeviceOrganisationDetails | null>;
|
|
71
75
|
|
|
76
|
+
onUnmounted(() => {
|
|
77
|
+
subscriberIds.forEach(id => service.unsubscribe(id));
|
|
78
|
+
subscriberIds.length = 0;
|
|
79
|
+
});
|
|
80
|
+
|
|
72
81
|
const change = async (deviceOrganisationId: string, payload: ChangeDeviceOrganisationLocationDTO) => {
|
|
73
82
|
changing.value = true;
|
|
74
83
|
try {
|
|
@@ -77,10 +86,7 @@ export const useChangeDeviceOrganisationLocation = () => {
|
|
|
77
86
|
finally {
|
|
78
87
|
changing.value = false;
|
|
79
88
|
}
|
|
80
|
-
|
|
81
|
-
const subscriberId = service.subscribe("all", onEntityChanged(changed))
|
|
82
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
83
|
-
|
|
89
|
+
subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
|
|
84
90
|
return readonly(changed as Ref<DeviceOrganisationDetails>);
|
|
85
91
|
}
|
|
86
92
|
|
|
@@ -30,10 +30,16 @@ export const useUpdateGroup = ComposableFactory.update(GroupServiceFactory);
|
|
|
30
30
|
export const useRemoveGroup = ComposableFactory.remove(GroupServiceFactory);
|
|
31
31
|
export const useChangeGroupParent = () => {
|
|
32
32
|
const service = GroupServiceFactory();
|
|
33
|
+
const subscriberIds: number[] = [];
|
|
33
34
|
|
|
34
35
|
const changing = ref(false);
|
|
35
36
|
const changed = ref<GroupDetails | null>(null) as Ref<GroupDetails | null>;
|
|
36
37
|
|
|
38
|
+
onUnmounted(() => {
|
|
39
|
+
subscriberIds.forEach(id => service.unsubscribe(id));
|
|
40
|
+
subscriberIds.length = 0;
|
|
41
|
+
});
|
|
42
|
+
|
|
37
43
|
const change = async (groupId: string, payload: ChangeGroupParentDTO) => {
|
|
38
44
|
changing.value = true;
|
|
39
45
|
try {
|
|
@@ -42,10 +48,7 @@ export const useChangeGroupParent = () => {
|
|
|
42
48
|
finally {
|
|
43
49
|
changing.value = false;
|
|
44
50
|
}
|
|
45
|
-
|
|
46
|
-
const subscriberId = service.subscribe("all", onEntityChanged(changed))
|
|
47
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
48
|
-
|
|
51
|
+
subscriberIds.push(service.subscribe("all", onEntityChanged(changed)));
|
|
49
52
|
return readonly(changed as Ref<GroupDetails>);
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -21,10 +21,16 @@ const OrganisationServiceFactory = new ServiceFactory<OrganisationDetailsDTO, Or
|
|
|
21
21
|
|
|
22
22
|
export const useChangeDashboardOrganisation = () => {
|
|
23
23
|
const service = OrganisationServiceFactory();
|
|
24
|
+
const subscribersIds: number[] = [];
|
|
24
25
|
|
|
25
26
|
const changing = ref(false);
|
|
26
27
|
const changed = ref<OrganisationDetails | null>(null) as Ref<OrganisationDetails | null>;
|
|
27
28
|
|
|
29
|
+
onUnmounted(() => {
|
|
30
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
31
|
+
subscribersIds.length = 0;
|
|
32
|
+
});
|
|
33
|
+
|
|
28
34
|
const change = async (payload: ChangeOrganisationDashboardDTO) => {
|
|
29
35
|
changing.value = true;
|
|
30
36
|
try {
|
|
@@ -33,10 +39,7 @@ export const useChangeDashboardOrganisation = () => {
|
|
|
33
39
|
finally {
|
|
34
40
|
changing.value = false;
|
|
35
41
|
}
|
|
36
|
-
|
|
37
|
-
const subscriberId = service.subscribe("all", onEntityChanged(changed))
|
|
38
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
39
|
-
|
|
42
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(changed)));
|
|
40
43
|
return readonly(changed as Ref<OrganisationDetails>);
|
|
41
44
|
}
|
|
42
45
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TableDetails, TableDetailsDTO, UpdateTableDTO } from "@dative-gpi/foundation-core-domain";
|
|
2
|
+
import { ComposableFactory, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
3
|
+
|
|
4
|
+
import { TABLE_URL } from "../../config/urls";
|
|
5
|
+
|
|
6
|
+
const TableServiceFactory = new ServiceFactory<TableDetailsDTO, TableDetails>("table", TableDetails).create(factory => factory.build(
|
|
7
|
+
factory.addGet(TABLE_URL),
|
|
8
|
+
factory.addUpdate<UpdateTableDTO>(TABLE_URL),
|
|
9
|
+
factory.addNotify()
|
|
10
|
+
));
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export const useTable = ComposableFactory.get(TableServiceFactory);
|
|
14
|
+
export const useUpdateTable = ComposableFactory.update(TableServiceFactory);
|
|
@@ -38,10 +38,16 @@ export const useUpdateUserOrganisation = ComposableFactory.update(UserOrganisati
|
|
|
38
38
|
export const useRemoveUserOrganisation = ComposableFactory.remove(UserOrganisationServiceFactory);
|
|
39
39
|
export const useCurrentUserOrganisation = () => {
|
|
40
40
|
const service = UserOrganisationServiceFactory();
|
|
41
|
+
const subscribersIds: number[] = [];
|
|
41
42
|
|
|
42
43
|
const fetching = ref(false);
|
|
43
44
|
const fetched = ref<UserOrganisationDetails | null>(null) as Ref<UserOrganisationDetails | null>;
|
|
44
45
|
|
|
46
|
+
onUnmounted(() => {
|
|
47
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
48
|
+
subscribersIds.length = 0;
|
|
49
|
+
});
|
|
50
|
+
|
|
45
51
|
const fetch = async () => {
|
|
46
52
|
fetching.value = true;
|
|
47
53
|
try {
|
|
@@ -50,10 +56,7 @@ export const useCurrentUserOrganisation = () => {
|
|
|
50
56
|
finally {
|
|
51
57
|
fetching.value = false;
|
|
52
58
|
}
|
|
53
|
-
|
|
54
|
-
const subscriberId = service.subscribe("all", onEntityChanged(fetched))
|
|
55
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
56
|
-
|
|
59
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(fetched)));
|
|
57
60
|
return readonly(fetched as Ref<UserOrganisationDetails>);
|
|
58
61
|
}
|
|
59
62
|
|
|
@@ -65,10 +68,16 @@ export const useCurrentUserOrganisation = () => {
|
|
|
65
68
|
}
|
|
66
69
|
export const useUpdateCurrentUserOrganisation = () => {
|
|
67
70
|
const service = UserOrganisationServiceFactory();
|
|
71
|
+
const subscribersIds: number[] = [];
|
|
68
72
|
|
|
69
73
|
const updating = ref(false);
|
|
70
74
|
const updated = ref<UserOrganisationDetails | null>(null) as Ref<UserOrganisationDetails | null>;
|
|
71
75
|
|
|
76
|
+
onUnmounted(() => {
|
|
77
|
+
subscribersIds.forEach(id => service.unsubscribe(id));
|
|
78
|
+
subscribersIds.length = 0;
|
|
79
|
+
});
|
|
80
|
+
|
|
72
81
|
const update = async (payload: UpdateUserOrganisationDTO) => {
|
|
73
82
|
updating.value = true;
|
|
74
83
|
try {
|
|
@@ -77,10 +86,7 @@ export const useUpdateCurrentUserOrganisation = () => {
|
|
|
77
86
|
finally {
|
|
78
87
|
updating.value = false;
|
|
79
88
|
}
|
|
80
|
-
|
|
81
|
-
const subscriberId = service.subscribe("all", onEntityChanged(updated))
|
|
82
|
-
onUnmounted(() => service.unsubscribe(subscriberId));
|
|
83
|
-
|
|
89
|
+
subscribersIds.push(service.subscribe("all", onEntityChanged(updated)));
|
|
84
90
|
return readonly(updated as Ref<UserOrganisationDetails>);
|
|
85
91
|
}
|
|
86
92
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { ORGANISATION_ID } from "@dative-gpi/foundation-core-services/config/literals";
|
|
1
|
+
import { ref, watch } from "vue";
|
|
4
2
|
|
|
5
3
|
let initialized = false;
|
|
6
4
|
|
|
@@ -11,10 +9,6 @@ export const useOrganisationId = () => {
|
|
|
11
9
|
organisationId.value = payload;
|
|
12
10
|
};
|
|
13
11
|
|
|
14
|
-
if (!initialized) {
|
|
15
|
-
provide(ORGANISATION_ID, organisationId);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
12
|
initialized = true;
|
|
19
13
|
|
|
20
14
|
const ready = new Promise((resolve) => {
|
package/config/urls/index.ts
CHANGED
|
@@ -23,6 +23,6 @@ export * from "./permissionCategories";
|
|
|
23
23
|
export * from "./permissions";
|
|
24
24
|
export * from "./roleOrganisations";
|
|
25
25
|
export * from "./roleOrganisationTypes";
|
|
26
|
-
export * from "./
|
|
26
|
+
export * from "./tables";
|
|
27
27
|
export * from "./userOrganisations";
|
|
28
28
|
export * from "./users";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-core-services",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"author": "",
|
|
10
10
|
"license": "ISC",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@dative-gpi/bones-ui": "^0.0.
|
|
13
|
-
"@dative-gpi/foundation-core-domain": "0.0.
|
|
12
|
+
"@dative-gpi/bones-ui": "^0.0.60",
|
|
13
|
+
"@dative-gpi/foundation-core-domain": "0.0.11",
|
|
14
14
|
"@microsoft/signalr": "^8.0.0",
|
|
15
15
|
"vue": "^3.2.0",
|
|
16
16
|
"vue-router": "^4.2.5"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "4f28939e7d42ab1ef8319c614fbc210b1291fd79"
|
|
19
19
|
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Ref, onUnmounted, readonly, ref } from "vue";
|
|
2
|
-
|
|
3
|
-
import { UpdateUserOrganisationDispositionDTO, UserOrganisationDispositionDetails, UserOrganisationDispositionDetailsDTO, UserOrganisationDispositionInfos, UserOrganisationDispositionInfosDTO } from "@dative-gpi/foundation-core-domain";
|
|
4
|
-
import { ComposableFactory, onEntityChanged, ServiceFactory } from "@dative-gpi/bones-ui";
|
|
5
|
-
|
|
6
|
-
import { USER_ORGANISATION_DISPOSITION_URL } from "../../config/urls";
|
|
7
|
-
|
|
8
|
-
const UserOrganisationDispositionServiceFactory = new ServiceFactory<UserOrganisationDispositionDetailsDTO, UserOrganisationDispositionDetails>("userOrganisationDisposition", UserOrganisationDispositionDetails).create(factory => factory.build(
|
|
9
|
-
factory.addNotify((notifyService) => ({
|
|
10
|
-
getTable: async (tableCode: string): Promise<UserOrganisationDispositionInfosDTO[]> => {
|
|
11
|
-
const response = await ServiceFactory.http.get(USER_ORGANISATION_DISPOSITION_URL(tableCode));
|
|
12
|
-
const result = response.data.map((dto: UserOrganisationDispositionInfosDTO) => new UserOrganisationDispositionInfos(dto));
|
|
13
|
-
|
|
14
|
-
notifyService.notify("update", result);
|
|
15
|
-
|
|
16
|
-
return result;
|
|
17
|
-
},
|
|
18
|
-
updateTable: async(tableCode: string, payload: UpdateUserOrganisationDispositionDTO[]): Promise<UserOrganisationDispositionInfosDTO[]> => {
|
|
19
|
-
const response = await ServiceFactory.http.post(USER_ORGANISATION_DISPOSITION_URL(tableCode), payload);
|
|
20
|
-
const result = response.data.map((dto: UserOrganisationDispositionInfosDTO) => new UserOrganisationDispositionInfos(dto));
|
|
21
|
-
|
|
22
|
-
notifyService.notify("update", result);
|
|
23
|
-
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
}))
|
|
27
|
-
));
|
|
28
|
-
|
|
29
|
-
export const useGetTable = () => {
|
|
30
|
-
const service = UserOrganisationDispositionServiceFactory();
|
|
31
|
-
|
|
32
|
-
const fetching = ref(false);
|
|
33
|
-
const fetched = ref<UserOrganisationDispositionInfos[]>([]) as Ref<UserOrganisationDispositionInfos[]>;
|
|
34
|
-
|
|
35
|
-
const fetch = async (tableCode: string) => {
|
|
36
|
-
fetching.value = true;
|
|
37
|
-
try {
|
|
38
|
-
fetched.value = await service.getTable(tableCode);
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
fetching.value = false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return readonly(fetched as Ref<UserOrganisationDispositionInfos[]>);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
fetching: readonly(fetching),
|
|
49
|
-
fetch,
|
|
50
|
-
fetched: readonly(fetched)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export const useUpdateTable = () => {
|
|
54
|
-
const service = UserOrganisationDispositionServiceFactory();
|
|
55
|
-
|
|
56
|
-
const updating = ref(false);
|
|
57
|
-
const updated = ref<UserOrganisationDispositionInfos[]>([]) as Ref<UserOrganisationDispositionInfos[]>;
|
|
58
|
-
|
|
59
|
-
const update = async (tableCode: string, payload: UpdateUserOrganisationDispositionDTO[]) => {
|
|
60
|
-
updating.value = true;
|
|
61
|
-
try {
|
|
62
|
-
updated.value = await service.updateTable(tableCode, payload);
|
|
63
|
-
}
|
|
64
|
-
finally {
|
|
65
|
-
updating.value = false;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return readonly(updated as Ref<UserOrganisationDispositionInfos[]>);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
updating: readonly(updating),
|
|
73
|
-
update,
|
|
74
|
-
updated: readonly(updated)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { CORE_URL } from "./base";
|
|
2
|
-
|
|
3
|
-
export const USER_ORGANISATION_DISPOSITIONS_URL = () => `${CORE_URL()}/user-organisation-dispositions`;
|
|
4
|
-
export const USER_ORGANISATION_DISPOSITION_URL = (tableCode: string) => `${USER_ORGANISATION_DISPOSITIONS_URL()}/${encodeURIComponent(tableCode)}`;
|