@dative-gpi/foundation-shared-domain 1.0.128-fix-mobile → 1.0.128-mountain-alpha
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/models/applications/applicationDetails.ts +4 -2
- package/models/authTokens/authTokenInfos.ts +1 -1
- package/models/images/imageDetails.ts +1 -0
- package/models/languages/languageDetails.ts +2 -1
- package/models/notifications/notificationInfos.ts +2 -41
- package/models/organisationTypes/organisationTypeDetails.ts +3 -2
- package/models/organisations/organisationDetails.ts +5 -3
- package/models/permissions/permissionDetails.ts +2 -1
- package/models/terminals/terminalInfos.ts +1 -1
- package/models/timeZones/timeZoneDetails.ts +2 -1
- package/models/translations/translationDetails.ts +2 -1
- package/models/users/userDetails.ts +2 -1
- package/package.json +2 -2
- package/tools/datesTools.ts +10 -0
- package/tools/deviceExplorerElements.ts +34 -0
- package/tools/index.ts +2 -0
- package/tools/notificationsTools.ts +39 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { LanguageInfosDTO } from "../languages/languageInfos";
|
|
2
|
+
import { LanguageInfos } from "../languages/languageInfos";
|
|
3
|
+
import type { ApplicationInfosDTO } from "./applicationInfos";
|
|
4
|
+
import { ApplicationInfos } from "./applicationInfos";
|
|
3
5
|
|
|
4
6
|
export class ApplicationDetails extends ApplicationInfos {
|
|
5
7
|
languages: LanguageInfos[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LanguageInfosDTO } from "./languageInfos";
|
|
2
|
+
import { LanguageInfos } from "./languageInfos";
|
|
2
3
|
|
|
3
4
|
export class LanguageDetails extends LanguageInfos {
|
|
4
5
|
constructor(params: LanguageDetailsDTO) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { type MessageType } from "
|
|
2
|
-
import { isoToEpoch } from "
|
|
3
|
-
import { Scope } from "../../enums/applications";
|
|
4
|
-
import { Criticity } from "../../enums/alerts";
|
|
1
|
+
import { type Criticity, type MessageType, type Scope } from "@dative-gpi/foundation-shared-domain/enums";
|
|
2
|
+
import { isoToEpoch } from "@dative-gpi/foundation-shared-domain/tools";
|
|
5
3
|
|
|
6
4
|
export class NotificationInfos {
|
|
7
5
|
id: string;
|
|
@@ -34,43 +32,6 @@ export class NotificationInfos {
|
|
|
34
32
|
this.acknowledgingTimestamp = params.acknowledgingTimestamp ?
|
|
35
33
|
isoToEpoch(params.acknowledgingTimestamp) : null;
|
|
36
34
|
}
|
|
37
|
-
|
|
38
|
-
static getFromAudience = (
|
|
39
|
-
notifications: NotificationInfos[],
|
|
40
|
-
application: boolean,
|
|
41
|
-
criticity: Criticity,
|
|
42
|
-
organisationId?: string | null,
|
|
43
|
-
userId?: string | null,
|
|
44
|
-
): NotificationInfos[] => notifications.filter((n: NotificationInfos) => {
|
|
45
|
-
if (n.acknowledged) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
if (![Criticity.None, n.criticity].includes(criticity)) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
switch (n.audienceScope) {
|
|
52
|
-
case Scope.Organisation :
|
|
53
|
-
case Scope.UserOrganisation: return organisationId && n.organisationId && n.organisationId === organisationId;
|
|
54
|
-
case Scope.User : return userId && n.audienceId === userId;
|
|
55
|
-
case Scope.Application :
|
|
56
|
-
case Scope.Public : return application;
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
return false;
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
static getForDrawer = (
|
|
63
|
-
notifications: NotificationInfos[],
|
|
64
|
-
organisationId: string,
|
|
65
|
-
userId: string,
|
|
66
|
-
criticity: Criticity = Criticity.None
|
|
67
|
-
): NotificationInfos[] => NotificationInfos.getFromAudience(notifications, true, criticity, organisationId, userId);
|
|
68
|
-
|
|
69
|
-
static getForCard = (
|
|
70
|
-
notifications: NotificationInfos[],
|
|
71
|
-
organisationId: string,
|
|
72
|
-
criticity: Criticity = Criticity.None
|
|
73
|
-
): NotificationInfos[] => NotificationInfos.getFromAudience(notifications, false, criticity, organisationId, null);
|
|
74
35
|
}
|
|
75
36
|
|
|
76
37
|
export interface NotificationInfosDTO {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { OrganisationTypeInfosDTO } from "./organisationTypeInfos";
|
|
2
|
+
import { OrganisationTypeInfos } from "./organisationTypeInfos";
|
|
3
|
+
import type { DashboardType } from "../../enums/dashboards";
|
|
3
4
|
|
|
4
5
|
export class OrganisationTypeDetails extends OrganisationTypeInfos {
|
|
5
6
|
description: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { PermissionInfosDTO } from "../permissions/permissionInfos";
|
|
2
|
+
import { PermissionInfos } from "../permissions/permissionInfos";
|
|
3
|
+
import type { OrganisationInfosDTO } from "./organisationInfos";
|
|
4
|
+
import { OrganisationInfos } from "./organisationInfos";
|
|
5
|
+
import type { DashboardType } from "../../enums/dashboards";
|
|
4
6
|
|
|
5
7
|
export class OrganisationDetails extends OrganisationInfos {
|
|
6
8
|
code: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PermissionInfosDTO } from "./permissionInfos";
|
|
2
|
+
import { PermissionInfos } from "./permissionInfos";
|
|
2
3
|
|
|
3
4
|
export class PermissionDetails extends PermissionInfos {
|
|
4
5
|
constructor(params: PermissionDetailsDTO) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TimeZoneInfosDTO } from "./timeZoneInfos";
|
|
2
|
+
import { TimeZoneInfos } from "./timeZoneInfos";
|
|
2
3
|
|
|
3
4
|
export class TimeZoneDetails extends TimeZoneInfos {
|
|
4
5
|
constructor(params: TimeZoneDetailsDTO) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TranslationInfosDTO } from "./translationInfos";
|
|
2
|
+
import { TranslationInfos } from "./translationInfos";
|
|
2
3
|
|
|
3
4
|
export class TranslationDetails extends TranslationInfos {
|
|
4
5
|
constructor(params: TranslationDetailsDTO) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-domain",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.128-
|
|
4
|
+
"version": "1.0.128-mountain-alpha",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"date-fns": "^3.6.0"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "37cef6036141cc79839c97f8ffc124c024e5486a"
|
|
16
16
|
}
|
package/tools/datesTools.ts
CHANGED
|
@@ -7,6 +7,10 @@ export const OPTIONS: { [key: string]: Intl.DateTimeFormatOptions } = {
|
|
|
7
7
|
day: "2-digit",
|
|
8
8
|
month: "long"
|
|
9
9
|
},
|
|
10
|
+
dayMonthShortOnly: {
|
|
11
|
+
day: "2-digit",
|
|
12
|
+
month: "2-digit"
|
|
13
|
+
},
|
|
10
14
|
shortDate: {
|
|
11
15
|
day: "2-digit",
|
|
12
16
|
month: "2-digit",
|
|
@@ -18,6 +22,12 @@ export const OPTIONS: { [key: string]: Intl.DateTimeFormatOptions } = {
|
|
|
18
22
|
month: "long",
|
|
19
23
|
year: "numeric"
|
|
20
24
|
},
|
|
25
|
+
monthShortTime: {
|
|
26
|
+
day: "2-digit",
|
|
27
|
+
month: "2-digit",
|
|
28
|
+
hour: "2-digit",
|
|
29
|
+
minute: "2-digit"
|
|
30
|
+
},
|
|
21
31
|
shortTime: {
|
|
22
32
|
day: "2-digit",
|
|
23
33
|
month: "2-digit",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type DeviceExplorerElementInfos, type DeviceOrganisationInfos, type GroupInfos } from "@dative-gpi/foundation-core-domain/models";
|
|
2
|
+
|
|
3
|
+
import { DeviceExplorerElementType } from "../enums";
|
|
4
|
+
|
|
5
|
+
export const fromDeviceOrganisation = (deviceOrganisation: DeviceOrganisationInfos): DeviceExplorerElementInfos => ({
|
|
6
|
+
...deviceOrganisation,
|
|
7
|
+
type: DeviceExplorerElementType.DeviceOrganisation,
|
|
8
|
+
parentId: deviceOrganisation.groupId,
|
|
9
|
+
icon: null,
|
|
10
|
+
groupsIds: null,
|
|
11
|
+
deviceOrganisationsIds: null,
|
|
12
|
+
modelsIds: null,
|
|
13
|
+
recursiveGroupsIds: null,
|
|
14
|
+
recursiveDeviceOrganisationsIds: null,
|
|
15
|
+
recursiveModelsIds: null
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const fromGroup = (group: GroupInfos): DeviceExplorerElementInfos => ({
|
|
19
|
+
...group,
|
|
20
|
+
type: DeviceExplorerElementType.Group,
|
|
21
|
+
manufacturerLabel: null,
|
|
22
|
+
articleLabel: null,
|
|
23
|
+
modelLabel: null,
|
|
24
|
+
ownerLabel: null,
|
|
25
|
+
managerName: null,
|
|
26
|
+
unrestricted: null,
|
|
27
|
+
online: null,
|
|
28
|
+
meta: null,
|
|
29
|
+
modelStatuses: null,
|
|
30
|
+
status: null,
|
|
31
|
+
connectivity: null,
|
|
32
|
+
alerts: null,
|
|
33
|
+
worstAlert: null
|
|
34
|
+
});
|
package/tools/index.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type NotificationInfos } from "../models";
|
|
2
|
+
import { Criticity, Scope } from "../enums";
|
|
3
|
+
|
|
4
|
+
export const getFromAudience = (
|
|
5
|
+
notifications: NotificationInfos[],
|
|
6
|
+
application: boolean,
|
|
7
|
+
criticity: Criticity,
|
|
8
|
+
organisationId?: string | null,
|
|
9
|
+
userId?: string | null,
|
|
10
|
+
): NotificationInfos[] => notifications.filter((n: NotificationInfos) => {
|
|
11
|
+
if (n.acknowledged) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (![Criticity.None, n.criticity].includes(criticity)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
switch (n.audienceScope) {
|
|
18
|
+
case Scope.Organisation :
|
|
19
|
+
case Scope.UserOrganisation: return organisationId && n.organisationId && n.organisationId === organisationId;
|
|
20
|
+
case Scope.User : return userId && n.audienceId === userId;
|
|
21
|
+
case Scope.Application :
|
|
22
|
+
case Scope.Public : return application;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const getForDrawer = (
|
|
29
|
+
notifications: NotificationInfos[],
|
|
30
|
+
organisationId: string,
|
|
31
|
+
userId: string,
|
|
32
|
+
criticity: Criticity = Criticity.None
|
|
33
|
+
): NotificationInfos[] => getFromAudience(notifications, true, criticity, organisationId, userId);
|
|
34
|
+
|
|
35
|
+
export const getForCard = (
|
|
36
|
+
notifications: NotificationInfos[],
|
|
37
|
+
organisationId: string,
|
|
38
|
+
criticity: Criticity = Criticity.None
|
|
39
|
+
): NotificationInfos[] => getFromAudience(notifications, false, criticity, organisationId, null);
|