@iotready/nextjs-components-library 1.0.0-preview4 → 1.0.0-preview40
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/assets/translations/en.json +92 -0
- package/assets/translations/index.js +4 -0
- package/assets/translations/it.json +92 -0
- package/assets/translations/scripts/export.js +74 -0
- package/assets/translations/scripts/import.js +66 -0
- package/components/accounts/AccountMenu.d.ts +2 -1
- package/components/accounts/AccountMenu.js +2 -2
- package/components/accounts/AccountProfile.d.ts +2 -1
- package/components/accounts/AccountProfile.js +15 -15
- package/components/charts/TrendChart.d.ts +28 -6
- package/components/charts/TrendChart.js +555 -149
- package/components/groups/GroupUpdate.d.ts +9 -10
- package/components/groups/GroupUpdate.js +21 -38
- package/components/groups/GroupsDevices.d.ts +22 -17
- package/components/groups/GroupsDevices.js +165 -110
- package/components/groups/Map.d.ts +5 -9
- package/components/groups/Map.js +2 -2
- package/components/settings/DynamicMenu.d.ts +1 -0
- package/components/settings/DynamicMenu.js +2 -1
- package/components/users/UserUpdate.d.ts +2 -1
- package/components/users/UserUpdate.js +2 -2
- package/components/users/UsersDataGrid.d.ts +11 -3
- package/components/users/UsersDataGrid.js +49 -32
- package/package.json +8 -4
- package/server-actions/annotations.d.ts +4 -0
- package/server-actions/annotations.js +12 -0
- package/server-actions/groups.d.ts +16 -16
- package/server-actions/groups.js +157 -72
- package/server-actions/index.d.ts +1 -0
- package/server-actions/index.js +1 -0
- package/server-actions/influx.d.ts +17 -13
- package/server-actions/influx.js +207 -98
- package/server-actions/trackle.d.ts +10 -4
- package/server-actions/trackle.js +59 -38
- package/server-actions/types.d.ts +16 -0
- package/server-actions/types.js +6 -0
- package/types/device.d.ts +19 -0
- package/types/device.js +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/user.d.ts +2 -0
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { UserType } from '../../types';
|
|
2
|
-
declare const GroupUpdate: ({
|
|
3
|
-
userInfo: UserType;
|
|
1
|
+
import { AssetType, TrackleDeviceType, UserType } from '../../types';
|
|
2
|
+
declare const GroupUpdate: ({ isOrg, labelEntity, groupInfo, usersGroup, usersList, devicesList, userInfo, handleAddUserToGroup, handleGetGroups, handleRemoveUserFromGroup, handleUpdateGroup, handleDeleteGroup, container, containerProps, afterUpdateCallback, afterRemoveCallback, confirmMui, t }: {
|
|
4
3
|
groupInfo: any;
|
|
5
4
|
usersGroup: any[];
|
|
6
5
|
usersList: any[];
|
|
7
|
-
devicesList:
|
|
8
|
-
id: string;
|
|
9
|
-
state: any;
|
|
10
|
-
managers: any[];
|
|
11
|
-
}[];
|
|
6
|
+
devicesList: AssetType[] | TrackleDeviceType[];
|
|
12
7
|
handleAddUserToGroup: (groupID: string, userName: string, userID: string) => Promise<any>;
|
|
13
8
|
handleRemoveUserFromGroup: (groupID: string, userID: string) => Promise<any>;
|
|
14
9
|
handleUpdateDevice: (id: string, body: any, user: UserType) => Promise<any>;
|
|
15
|
-
handleGetGroups: (
|
|
10
|
+
handleGetGroups: (userInfo?: UserType, parent_id?: string) => Promise<any>;
|
|
16
11
|
handleUpdateGroup: (id: string, group: any) => Promise<void>;
|
|
17
|
-
handleDeleteGroup: (id: string) => Promise<void>;
|
|
12
|
+
handleDeleteGroup: (id: string, isOrg: boolean) => Promise<void>;
|
|
18
13
|
container?: "Box" | "Card";
|
|
19
14
|
containerProps?: any;
|
|
20
15
|
afterUpdateCallback?: (groupInfo: any) => Promise<void>;
|
|
21
16
|
afterRemoveCallback?: () => Promise<void>;
|
|
22
17
|
confirmMui?: (options?: any) => Promise<void>;
|
|
18
|
+
labelEntity: string;
|
|
19
|
+
isOrg: boolean;
|
|
20
|
+
userInfo: UserType;
|
|
21
|
+
t: (key: string, params?: any) => string;
|
|
23
22
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
24
23
|
export default GroupUpdate;
|
|
@@ -2,21 +2,20 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Box, Typography, Card, CardContent, TableBody } from '@mui/material';
|
|
4
4
|
import Grid from '@mui/material/Grid2';
|
|
5
|
-
import { useState } from 'react';
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
6
|
import { FormControl, TextField, Autocomplete, Alert, Table, TableRow, TableCell } from '@mui/material';
|
|
7
7
|
import AddIcon from '@mui/icons-material/Add';
|
|
8
8
|
import CloseIcon from '@mui/icons-material/Close';
|
|
9
9
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
10
10
|
import { LoadingButton } from '@mui/lab';
|
|
11
|
-
const GroupUpdate = ({
|
|
11
|
+
const GroupUpdate = ({ isOrg, labelEntity, groupInfo, usersGroup, usersList, devicesList, userInfo, handleAddUserToGroup, handleGetGroups, handleRemoveUserFromGroup, handleUpdateGroup, handleDeleteGroup, container = 'Box', containerProps = {}, afterUpdateCallback, afterRemoveCallback, confirmMui, t }) => {
|
|
12
12
|
const [group, setGroup] = useState(groupInfo);
|
|
13
|
+
const [organizationsGroup, setOrganizationsGroup] = useState(null);
|
|
13
14
|
const [loadingUpdateButton, setLoadingUpdateButton] = useState(false);
|
|
14
15
|
const [loadingRemoveUserButton, setLoadingRemoveUserButton] = useState(false);
|
|
15
16
|
const [loadingAddUserButton, setLoadingAddUserButton] = useState(false);
|
|
16
17
|
const [loadingDeleteGroupButton, setLoadingDeleteGroupButton] = useState(false);
|
|
17
18
|
const [selectedUser, setSelectedUser] = useState(null);
|
|
18
|
-
const [error, setError] = useState(null);
|
|
19
|
-
const [success, setSuccess] = useState(null);
|
|
20
19
|
function handleChange(event) {
|
|
21
20
|
setGroup({ ...group, [event.target.name]: event.target.value });
|
|
22
21
|
}
|
|
@@ -25,23 +24,6 @@ const GroupUpdate = ({ userInfo, groupInfo, usersGroup, usersList, devicesList,
|
|
|
25
24
|
try {
|
|
26
25
|
const response = await handleRemoveUserFromGroup(group.id, userId);
|
|
27
26
|
if (response) {
|
|
28
|
-
if (devicesList.length > 0) {
|
|
29
|
-
// should check if device is present in other groups the user is member of
|
|
30
|
-
const groupsData = await handleGetGroups(1008, { role: 'support', uid: userId });
|
|
31
|
-
const userGroupIds = groupsData.map((group) => group.id);
|
|
32
|
-
// for all devices in the group set the selectedUser as manager
|
|
33
|
-
for (const device of devicesList) {
|
|
34
|
-
// check device is in a group of user is member of
|
|
35
|
-
const found = device.state.groups.some((gID) => userGroupIds.includes(gID));
|
|
36
|
-
if (!found) {
|
|
37
|
-
// remove user from managers
|
|
38
|
-
const managers = device.managers && device.managers.filter(man => man !== userId) || [];
|
|
39
|
-
await handleUpdateDevice(device.id, {
|
|
40
|
-
managers
|
|
41
|
-
}, userInfo);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
27
|
if (afterUpdateCallback) {
|
|
46
28
|
await afterUpdateCallback(group);
|
|
47
29
|
}
|
|
@@ -60,17 +42,6 @@ const GroupUpdate = ({ userInfo, groupInfo, usersGroup, usersList, devicesList,
|
|
|
60
42
|
try {
|
|
61
43
|
const response = await handleAddUserToGroup(group.id, selectedUser.label, selectedUser.id);
|
|
62
44
|
if (response) {
|
|
63
|
-
if (devicesList.length > 0) {
|
|
64
|
-
for (const device of devicesList) {
|
|
65
|
-
// for all devices in the group set the selectedUser as manager
|
|
66
|
-
await handleUpdateDevice(device.id, {
|
|
67
|
-
managers: [
|
|
68
|
-
...(device?.managers || []),
|
|
69
|
-
selectedUser.id
|
|
70
|
-
]
|
|
71
|
-
}, userInfo);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
45
|
if (afterUpdateCallback) {
|
|
75
46
|
await afterUpdateCallback(group);
|
|
76
47
|
}
|
|
@@ -104,13 +75,13 @@ const GroupUpdate = ({ userInfo, groupInfo, usersGroup, usersList, devicesList,
|
|
|
104
75
|
const deleteGroup = async () => {
|
|
105
76
|
try {
|
|
106
77
|
if (confirmMui) {
|
|
107
|
-
await confirmMui({ description:
|
|
78
|
+
await confirmMui({ description: t('library.groupUpdate.confirmDeleteGroup', { entity: labelEntity.toLowerCase() }), confirmationText: t('library.groupUpdate.yesRemoveIt'), confirmationButtonProps: { variant: 'contained', color: 'error' } });
|
|
108
79
|
}
|
|
109
80
|
else {
|
|
110
|
-
confirm(
|
|
81
|
+
confirm(t('library.groupUpdate.confirmDeleteGroup', { entity: labelEntity.toLowerCase() }));
|
|
111
82
|
}
|
|
112
83
|
setLoadingDeleteGroupButton(true);
|
|
113
|
-
await handleDeleteGroup(group.id);
|
|
84
|
+
await handleDeleteGroup(group.id, isOrg);
|
|
114
85
|
if (afterRemoveCallback) {
|
|
115
86
|
afterRemoveCallback();
|
|
116
87
|
}
|
|
@@ -122,12 +93,24 @@ const GroupUpdate = ({ userInfo, groupInfo, usersGroup, usersList, devicesList,
|
|
|
122
93
|
setLoadingDeleteGroupButton(false);
|
|
123
94
|
}
|
|
124
95
|
};
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const getInitialData = async () => {
|
|
98
|
+
if (isOrg) {
|
|
99
|
+
const response = await handleGetGroups(userInfo, group.id);
|
|
100
|
+
setOrganizationsGroup(response);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
setOrganizationsGroup([]);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
getInitialData();
|
|
107
|
+
}, []);
|
|
125
108
|
const renderGroupUpdate = () => {
|
|
126
|
-
return (_jsxs(Box, { component: "div", children: [_jsx(Grid, { container: true, spacing: 2, children: _jsx(Grid, { size: { xs: 12, md: 8 }, children: _jsxs(Box, { component: "div", children: [_jsx(FormControl, { fullWidth: true, children: _jsx(TextField, { sx: { flexGrow: 1 }, label:
|
|
109
|
+
return (_jsxs(Box, { component: "div", children: [_jsx(Grid, { container: true, spacing: 2, children: _jsx(Grid, { size: { xs: 12, md: 8 }, children: _jsxs(Box, { component: "div", children: [_jsx(FormControl, { fullWidth: true, children: _jsx(TextField, { sx: { flexGrow: 1 }, label: t('library.groupUpdate.name'), value: group.name, name: "name", onChange: handleChange }) }), _jsx(FormControl, { fullWidth: true, sx: { mt: 2 }, children: _jsx(TextField, { sx: { flexGrow: 1 }, label: t('library.groupUpdate.description'), value: group.description, name: "description", multiline: true, rows: 4, onChange: handleChange }) }), _jsx(LoadingButton, { variant: "contained", color: "primary", loading: loadingUpdateButton, sx: { mt: 2 }, onClick: () => updateGroup(), children: t('library.groupUpdate.update') })] }) }) }), _jsx(Grid, { container: true, spacing: 2, sx: { mt: 4 }, children: _jsxs(Grid, { size: { xs: 12, md: 8 }, children: [_jsx(Typography, { variant: 'body1', sx: { fontWeight: 'bold' }, children: t('library.groupUpdate.addMembers') }), _jsx(Box, { component: "div", sx: { mt: 2 }, children: usersGroup && usersGroup.length > 0 ?
|
|
127
110
|
_jsx(Table, { size: "small", children: _jsx(TableBody, { children: usersGroup.map((ug) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsx(Typography, { variant: "body1", children: ug.user.fullName }) }), _jsx(TableCell, { align: 'right', children: _jsx(LoadingButton, { size: "small", color: "error", loading: loadingRemoveUserButton, onClick: () => removeUserFromCurrentGroup(ug.user.userId), children: _jsx(CloseIcon, { sx: { m: 0, p: 0 }, fontSize: "small" }) }) })] }, ug.id))) }) })
|
|
128
|
-
: _jsx(Box, { component: 'div', sx: { mt: 2 }, children:
|
|
111
|
+
: _jsx(Box, { component: 'div', sx: { mt: 2 }, children: t('library.groupUpdate.noMembersFound') }) }), _jsxs(Box, { component: "div", sx: { mt: 4, display: 'flex', alignItems: 'center' }, children: [_jsx(Autocomplete, { fullWidth: true, disablePortal: true, options: usersList || [], value: selectedUser, size: 'small', onChange: (event, newValue) => {
|
|
129
112
|
setSelectedUser(newValue);
|
|
130
|
-
}, renderInput: (params) => _jsx(TextField, { ...params, label:
|
|
113
|
+
}, renderInput: (params) => _jsx(TextField, { ...params, label: t('library.groupUpdate.selectUser') }) }), _jsxs(LoadingButton, { variant: "contained", color: "primary", loading: loadingAddUserButton, sx: { ml: 2 }, disabled: !selectedUser, onClick: () => addUserToCurrentGroup(), children: [_jsx(AddIcon, { sx: { mr: 1 } }), " ", t('library.groupUpdate.add')] })] }), _jsxs(Box, { component: "div", sx: { mt: 4 }, children: [_jsx(Typography, { variant: 'body1', sx: { fontWeight: 'bold' }, children: t('library.groupUpdate.deleteGroup', { entity: labelEntity.toLowerCase() }) }), !isOrg ? (_jsx(Alert, { severity: "error", sx: { mt: 2 }, action: _jsxs(LoadingButton, { variant: "contained", disabled: devicesList.length > 0 || usersGroup.length > 0, color: "error", loading: loadingDeleteGroupButton, onClick: () => deleteGroup(), size: 'small', children: [_jsx(DeleteIcon, { fontSize: "small", sx: { mr: 1 } }), " ", t('library.groupUpdate.deleteGroup', { entity: labelEntity.toLowerCase() })] }), children: devicesList.length === 0 && usersGroup.length === 0 ? t('library.groupUpdate.actionCannotBeUndone') : t('library.groupUpdate.mustRemoveDevicesAndMembers', { entity: labelEntity.toLowerCase() }) })) : organizationsGroup && (_jsx(Alert, { severity: "error", sx: { mt: 2 }, action: _jsxs(LoadingButton, { variant: "contained", disabled: devicesList.length > 0 || usersGroup.length > 0 || organizationsGroup.length > 0, color: "error", loading: loadingDeleteGroupButton, onClick: () => deleteGroup(), size: 'small', children: [_jsx(DeleteIcon, { fontSize: "small", sx: { mr: 1 } }), " ", t('library.groupUpdate.deleteGroup', { entity: labelEntity.toLowerCase() })] }), children: devicesList.length === 0 && usersGroup.length === 0 && organizationsGroup.length === 0 ? t('library.groupUpdate.actionCannotBeUndone') : t('library.groupUpdate.mustRemoveDevicesMembersAndGroups', { entity: labelEntity.toLowerCase() }) }))] })] }) })] }));
|
|
131
114
|
};
|
|
132
115
|
return (container === "Card" ? (_jsx(Card, { ...containerProps, children: _jsx(CardContent, { children: renderGroupUpdate() }) })) : (_jsx(Box, { ...containerProps, children: renderGroupUpdate() })));
|
|
133
116
|
};
|
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import { UserType } from '../../types/user';
|
|
2
|
-
import { Position } from "./Map";
|
|
3
1
|
import { Theme } from "@emotion/react";
|
|
4
|
-
|
|
2
|
+
import { UserType, AssetType, DevicePositionType, TrackleDeviceType } from "../../types";
|
|
3
|
+
declare const GroupsDevices: ({ userInfo, handleGetUsersList, handleAddUserToGroup, handleRemoveUserFromGroup, handleGetGroups, handleGetUsersGroup, handleGetDevices, handleUpdateDevice, handleGetPositions, handleAddDevicesToGroup, handleRemoveDevicesFromGroup, handleCreateGroup, handleDeleteGroup, handleUpdateGroup, group, columnsArray, containerDataGrid, props, propsDatagrid, loadingComponent, containerProps, enableMaps, mapsHeight, mapsClickCallback, theme, confirmMui, propsHeaderGroups, forceGetDevices, customToolbar, groupsLabelAll, addDevicesLabel, noDevicesLabel, groupUpdateRoles, isOrg, currentOrg, t, dataGridLocaleText }: {
|
|
5
4
|
userInfo: UserType;
|
|
6
|
-
handleGetUsersList: (
|
|
7
|
-
page: number;
|
|
8
|
-
pageSize: number;
|
|
9
|
-
}) => Promise<{
|
|
10
|
-
users: UserType[];
|
|
11
|
-
}>;
|
|
5
|
+
handleGetUsersList: () => Promise<UserType[]>;
|
|
12
6
|
handleAddUserToGroup: (groupID: string, userName: string, userID: string) => Promise<any>;
|
|
13
7
|
handleRemoveUserFromGroup: (groupID: string, userID: string) => Promise<any>;
|
|
14
|
-
handleGetGroups: (
|
|
8
|
+
handleGetGroups: (userInfo?: UserType, parent_id?: string | undefined) => Promise<any>;
|
|
15
9
|
handleGetUsersGroup: (groupID: string) => Promise<any>;
|
|
16
10
|
handleCreateGroup: (group: any) => Promise<any>;
|
|
17
|
-
handleGetDevices: (user: UserType, group: string,
|
|
18
|
-
handleGetPositions
|
|
19
|
-
handleAddDevicesToGroup: (user: UserType, group: string, devicesToPatch:
|
|
20
|
-
handleRemoveDevicesFromGroup: (user: UserType, group: string, devicesToPatch:
|
|
21
|
-
handleDeleteGroup: (id: string) => Promise<void>;
|
|
11
|
+
handleGetDevices: (user: UserType, group: string, selectedGroup: string) => Promise<AssetType[] | TrackleDeviceType[]>;
|
|
12
|
+
handleGetPositions?: (devices: any) => Promise<DevicePositionType[]>;
|
|
13
|
+
handleAddDevicesToGroup: (user: UserType, group: string, devicesToPatch: AssetType[] | TrackleDeviceType[]) => Promise<TrackleDeviceType[]>;
|
|
14
|
+
handleRemoveDevicesFromGroup: (user: UserType, group: string, devicesToPatch: AssetType[] | TrackleDeviceType[]) => Promise<TrackleDeviceType[]>;
|
|
15
|
+
handleDeleteGroup: (id: string, iOrg: boolean) => Promise<void>;
|
|
22
16
|
handleUpdateGroup: (id: string, group: any) => Promise<void>;
|
|
23
|
-
handleUpdateDevice: (id: string, body: any, user: UserType) => Promise<
|
|
17
|
+
handleUpdateDevice: (id: string, body: any, user: UserType) => Promise<void>;
|
|
24
18
|
group: string;
|
|
25
19
|
columnsArray: any[];
|
|
26
20
|
containerDataGrid?: "Card" | "Box";
|
|
27
21
|
props?: any;
|
|
28
22
|
propsDatagrid?: any;
|
|
23
|
+
propsHeaderGroups?: any;
|
|
29
24
|
loadingComponent?: React.ReactNode;
|
|
30
25
|
containerProps?: any;
|
|
31
26
|
enableMaps?: boolean;
|
|
32
27
|
mapsHeight: string;
|
|
33
|
-
mapsClickCallback?: (position:
|
|
28
|
+
mapsClickCallback?: (position: DevicePositionType) => void;
|
|
34
29
|
theme: Theme;
|
|
35
30
|
confirmMui?: (options?: any) => Promise<void>;
|
|
31
|
+
forceGetDevices?: number;
|
|
32
|
+
customToolbar?: string[];
|
|
33
|
+
groupsLabelAll?: string;
|
|
34
|
+
addDevicesLabel?: string;
|
|
35
|
+
noDevicesLabel?: string;
|
|
36
|
+
groupUpdateRoles?: string[];
|
|
37
|
+
isOrg?: boolean;
|
|
38
|
+
currentOrg?: string;
|
|
39
|
+
t: (key: string, params?: any) => string;
|
|
40
|
+
dataGridLocaleText?: Record<string, string>;
|
|
36
41
|
}) => string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<import("react").ReactNode> | Promise<import("react").AwaitedReactNode> | null;
|
|
37
42
|
export default GroupsDevices;
|