@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,48 @@
|
|
|
1
|
+
import { onMounted, provide, ref, watch } from "vue";
|
|
2
|
+
|
|
3
|
+
import { LANGUAGE_CODE } from "../config/literals";
|
|
4
|
+
|
|
5
|
+
let initialized = false;
|
|
6
|
+
|
|
7
|
+
const languageCode = ref<string | null>(null);
|
|
8
|
+
|
|
9
|
+
export const useLanguageCode = () => {
|
|
10
|
+
const setLanguageCode = (payload: string) => {
|
|
11
|
+
localStorage.setItem(LANGUAGE_CODE, payload);
|
|
12
|
+
languageCode.value = payload;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (!initialized) {
|
|
16
|
+
provide(LANGUAGE_CODE, languageCode);
|
|
17
|
+
|
|
18
|
+
onMounted(() => {
|
|
19
|
+
if (languageCode.value) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (localStorage.getItem(LANGUAGE_CODE) != null) {
|
|
23
|
+
languageCode.value = localStorage.getItem(LANGUAGE_CODE);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
initialized = true;
|
|
29
|
+
|
|
30
|
+
const ready = new Promise((resolve) => {
|
|
31
|
+
if (languageCode.value) {
|
|
32
|
+
resolve(languageCode.value);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
watch(languageCode, () => {
|
|
36
|
+
if (languageCode.value) {
|
|
37
|
+
resolve(languageCode.value);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
ready,
|
|
45
|
+
languageCode,
|
|
46
|
+
setLanguageCode
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { onMounted, provide, ref, watch } from "vue";
|
|
2
|
+
import { useRouter } from "vue-router";
|
|
3
|
+
|
|
4
|
+
import { setOrganisationId } from "../config/urls/urlFactory";
|
|
5
|
+
import { ORGANISATION_ID } from "../config/literals";
|
|
6
|
+
|
|
7
|
+
let initialized = false;
|
|
8
|
+
|
|
9
|
+
const organisationId = ref<string | null>(null);
|
|
10
|
+
|
|
11
|
+
export const useOrganisationId = () => {
|
|
12
|
+
if (!initialized) {
|
|
13
|
+
provide(ORGANISATION_ID, organisationId);
|
|
14
|
+
|
|
15
|
+
const router = useRouter();
|
|
16
|
+
|
|
17
|
+
watch(router.currentRoute, () => {
|
|
18
|
+
organisationId.value = router.currentRoute.value.params[ORGANISATION_ID] as string | null;
|
|
19
|
+
setOrganisationId(organisationId);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
onMounted(() => {
|
|
23
|
+
if (organisationId.value) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
organisationId.value = router.currentRoute.value.params[ORGANISATION_ID] as string | null;
|
|
27
|
+
setOrganisationId(organisationId);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
initialized = true;
|
|
32
|
+
|
|
33
|
+
const ready = new Promise((resolve) => {
|
|
34
|
+
if (organisationId.value) {
|
|
35
|
+
resolve(organisationId.value);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
watch(organisationId, () => {
|
|
39
|
+
if (organisationId.value) {
|
|
40
|
+
resolve(organisationId.value);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
ready,
|
|
48
|
+
organisationId,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { onMounted, provide, ref, watch } from "vue";
|
|
2
|
+
|
|
3
|
+
import { TimeZoneInfos } from "@dative-gpi/foundation-core-domain/models";
|
|
4
|
+
|
|
5
|
+
import { TIME_ZONE } from "../config/literals";
|
|
6
|
+
|
|
7
|
+
let initialized = false;
|
|
8
|
+
|
|
9
|
+
const timeZone = ref<TimeZoneInfos | null>(null);
|
|
10
|
+
|
|
11
|
+
const getLocalOffset = (): string => {
|
|
12
|
+
const timeZoneName = Intl.DateTimeFormat("ia", {
|
|
13
|
+
timeZoneName: "short",
|
|
14
|
+
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
15
|
+
}).formatToParts().find((i) => i.type === "timeZoneName")?.value ?? "";
|
|
16
|
+
|
|
17
|
+
const offset = timeZoneName.slice(3);
|
|
18
|
+
if (!offset) {
|
|
19
|
+
return "UTC ";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const matchData = offset.match(/([+-])(\d+)(?::(\d+))?/);
|
|
23
|
+
if (matchData) {
|
|
24
|
+
const [_, sign, hour, minute] = matchData;
|
|
25
|
+
return `UTC ${sign}${hour.padStart(2, "0")}:${(minute ?? "").padStart(2, "0")}:00`;
|
|
26
|
+
}
|
|
27
|
+
return "UTC ";
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const useTimeZone = () => {
|
|
31
|
+
const setTimeZone = (payload: TimeZoneInfos) => {
|
|
32
|
+
localStorage.setItem(TIME_ZONE, JSON.stringify(payload));
|
|
33
|
+
timeZone.value = payload;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
if (!initialized) {
|
|
37
|
+
provide(TIME_ZONE, timeZone);
|
|
38
|
+
|
|
39
|
+
onMounted(() => {
|
|
40
|
+
if (timeZone.value) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (localStorage.getItem(TIME_ZONE) != null) {
|
|
44
|
+
timeZone.value = JSON.parse(localStorage.getItem(TIME_ZONE)!) as TimeZoneInfos;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setTimeZone(new TimeZoneInfos({
|
|
48
|
+
id: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
49
|
+
offset: getLocalOffset()
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
initialized = true;
|
|
56
|
+
|
|
57
|
+
const ready = new Promise((resolve) => {
|
|
58
|
+
if (timeZone.value) {
|
|
59
|
+
resolve(timeZone.value);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
watch(timeZone, () => {
|
|
63
|
+
if (timeZone.value) {
|
|
64
|
+
resolve(timeZone.value);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
ready,
|
|
72
|
+
timeZone,
|
|
73
|
+
setTimeZone
|
|
74
|
+
};
|
|
75
|
+
}
|
package/config/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const SUBSCRIBE = "Subscribe";
|
|
2
|
+
export const UNSUBSCRIBE = "Unsubscribe";
|
|
3
|
+
|
|
4
|
+
export const UPDATE_DEVICE_STATUS = "UpdateDeviceStatus";
|
|
5
|
+
|
|
6
|
+
export const UPDATE_DEVICE_CONNECTIVITY = "UpdateDeviceConnectivity";
|
|
7
|
+
|
|
8
|
+
export const CREATE_ALERT = "CreateAlert";
|
|
9
|
+
export const UPDATE_ALERT = "UpdateAlert";
|
|
10
|
+
export const REMOVE_ALERT = "RemoveAlert";
|
|
11
|
+
|
|
12
|
+
export const CREATE_CONNECTIVITY_ALERT = "CreateConnectivityAlert";
|
|
13
|
+
export const UPDATE_CONNECTIVITY_ALERT = "UpdateConnectivityAlert";
|
|
14
|
+
export const REMOVE_CONNECTIVITY_ALERT = "RemoveConnectivityAlert";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { urlFactory } from "./urlFactory";
|
|
2
|
+
|
|
3
|
+
export const GATEWAY_URL = "/api/foundation/shared/v1";
|
|
4
|
+
export const CORE_URL = urlFactory(organisationId => `/api/foundation/core/v1/organisations/${encodeURIComponent(organisationId)}`);
|
|
5
|
+
export const HUBS_URL = urlFactory(organisationId => `/api/foundation/hubs/v1/organisations/${encodeURIComponent(organisationId)}`);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CORE_URL, HUBS_URL } from "./base";
|
|
2
|
+
|
|
3
|
+
export const CONNECTIVITY_ALERTS_URL = `${CORE_URL}/connectivity-alerts`;
|
|
4
|
+
export const CONNECTIVITY_ALERT_URL = (connectivityAlertId: string) => `${CONNECTIVITY_ALERTS_URL}/${encodeURIComponent(connectivityAlertId)}`;
|
|
5
|
+
|
|
6
|
+
export const CONNECTIVITY_ALERTS_HUB_URL = `${HUBS_URL}/connectivity-alerts`;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PropertyEntity } from "@dative-gpi/foundation-core-domain";
|
|
2
|
+
|
|
3
|
+
import { CORE_URL } from "./base";
|
|
4
|
+
|
|
5
|
+
export const CUSTOM_PROPERTY_VALUES_URL = (entity: PropertyEntity, entityId: string, code: string) => `${CORE_URL}/custom-property-values/${encodeURIComponent(entity)}/${encodeURIComponent(entityId)}/${encodeURIComponent(code)}`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DEVICE_ORGANISATION_URL } from "./deviceOrganisations";
|
|
2
|
+
import { HUBS_URL } from "./base";
|
|
3
|
+
|
|
4
|
+
export const DEVICE_CONNECTIVITY_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATION_URL(deviceOrganisationId)}/connectivity`;
|
|
5
|
+
|
|
6
|
+
export const DEVICE_CONNECTIVITIES_HUB_URL = `${HUBS_URL}/connectivities`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CORE_URL } from "./base";
|
|
2
|
+
|
|
3
|
+
export const DEVICE_ORGANISATIONS_URL = `${CORE_URL}/device-organisations`;
|
|
4
|
+
export const DEVICE_ORGANISATION_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATIONS_URL}/${encodeURIComponent(deviceOrganisationId)}`;
|
|
5
|
+
export const DEVICE_ORGANISATION_GROUP_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATION_URL(deviceOrganisationId)}/group`;
|
|
6
|
+
export const DEVICE_ORGANISATION_LOCATION_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATION_URL(deviceOrganisationId)}/location`;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DEVICE_ORGANISATION_URL } from "./deviceOrganisations";
|
|
2
|
+
import { HUBS_URL } from "./base";
|
|
3
|
+
|
|
4
|
+
export const DEVICE_STATUS_URL = (deviceOrganisationId: string) => `${DEVICE_ORGANISATION_URL(deviceOrganisationId)}/status`;
|
|
5
|
+
|
|
6
|
+
export const DEVICE_STATUSES_HUB_URL = `${HUBS_URL}/statuses`;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CORE_URL } from "./base";
|
|
2
|
+
|
|
3
|
+
export const IMAGES_URL = `${CORE_URL}/images`;
|
|
4
|
+
export const IMAGE_RAW_URL = (imageId: string) => `${IMAGES_URL}/raw/${encodeURIComponent(imageId)}`;
|
|
5
|
+
export const IMAGE_THUMBNAIL_URL = (imageId: string) => `${IMAGES_URL}/thumbnail/${encodeURIComponent(imageId)}`
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from "./alerts";
|
|
2
|
+
export * from "./applications";
|
|
3
|
+
export * from "./articles";
|
|
4
|
+
export * from "./authTokens";
|
|
5
|
+
export * from "./connectivityAlerts";
|
|
6
|
+
export * from "./customProperties";
|
|
7
|
+
export * from "./customPropertyValues";
|
|
8
|
+
export * from "./dataCategories";
|
|
9
|
+
export * from "./dataDefinitions";
|
|
10
|
+
export * from "./deviceConnectivities";
|
|
11
|
+
export * from "./deviceOrganisations";
|
|
12
|
+
export * from "./deviceStatuses";
|
|
13
|
+
export * from "./families";
|
|
14
|
+
export * from "./groups";
|
|
15
|
+
export * from "./images";
|
|
16
|
+
export * from "./languages";
|
|
17
|
+
export * from "./locations";
|
|
18
|
+
export * from "./manufacturers";
|
|
19
|
+
export * from "./models";
|
|
20
|
+
export * from "./organisations";
|
|
21
|
+
export * from "./organisationTypes";
|
|
22
|
+
export * from "./permissionCategories";
|
|
23
|
+
export * from "./permissions";
|
|
24
|
+
export * from "./roleOrganisations";
|
|
25
|
+
export * from "./roleOrganisationTypes";
|
|
26
|
+
export * from "./timeZones";
|
|
27
|
+
export * from "./translations";
|
|
28
|
+
export * from "./userOrganisations";
|
|
29
|
+
export * from "./users";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { urlFactory } from "./urlFactory";
|
|
2
|
+
import { GATEWAY_URL } from "./base";
|
|
3
|
+
|
|
4
|
+
export const ORGANISATIONS_URL = `${GATEWAY_URL}/organisations`;
|
|
5
|
+
export const ORGANISATION_URL = urlFactory(organisationId => `${ORGANISATIONS_URL}/${encodeURIComponent(organisationId)}`);
|
|
6
|
+
|
|
7
|
+
export const ORGANISATION_DASHBOARD_URL = `${ORGANISATION_URL()}/dashboard`;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CORE_URL } from "./base";
|
|
2
|
+
|
|
3
|
+
export const ROLE_ORGANISATION_TYPES_URL = `${CORE_URL}/role-organisation-types`;
|
|
4
|
+
export const ROLE_ORGANISATION_TYPE_URL = (roleOrganisationTypeId: string) => `${ROLE_ORGANISATION_TYPES_URL}/${encodeURIComponent(roleOrganisationTypeId)}`;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Ref, ref } from "vue";
|
|
2
|
+
|
|
3
|
+
const organisationId = ref<string | null>(null);
|
|
4
|
+
|
|
5
|
+
export function setOrganisationId(orgId: Ref<string | null>) {
|
|
6
|
+
organisationId.value = orgId.value;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function urlFactory(url: (orgId: string) => string) {
|
|
10
|
+
return () => {
|
|
11
|
+
if (!organisationId.value) {
|
|
12
|
+
throw new Error("OrganisationId is not set");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return url(organisationId.value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CORE_URL } from "./base";
|
|
2
|
+
|
|
3
|
+
export const USER_ORGANISATIONS_URL = `${CORE_URL}/user-organisations`;
|
|
4
|
+
export const USER_ORGANISATION_URL = (userOrganisationId: string) => `${USER_ORGANISATIONS_URL}/${encodeURIComponent(userOrganisationId)}`;
|
|
5
|
+
export const USER_ORGANISATION_CURRENT_URL = `${USER_ORGANISATIONS_URL}/current`;
|
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dative-gpi/foundation-core-services",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "index.ts",
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@dative-gpi/bones-ui": "^0.0.50",
|
|
13
|
+
"@dative-gpi/foundation-core-domain": "0.0.2",
|
|
14
|
+
"@microsoft/signalr": "^8.0.0",
|
|
15
|
+
"vue": "^3.2.0",
|
|
16
|
+
"vue-router": "^4.2.5"
|
|
17
|
+
},
|
|
18
|
+
"gitHead": "44e9629c836e0cd06289b208b53120f07775ea5e"
|
|
19
|
+
}
|