@iotready/nextjs-components-library 1.0.0-preview15 → 1.0.0-preview17
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/components/charts/TrendChart.d.ts +1 -0
- package/components/charts/TrendChart.js +3 -3
- package/components/groups/GroupUpdate.d.ts +1 -1
- package/components/groups/GroupUpdate.js +1 -1
- package/components/groups/GroupsDevices.d.ts +1 -1
- package/components/groups/GroupsDevices.js +3 -4
- package/package.json +1 -1
- package/server-actions/trackle.d.ts +2 -1
- package/server-actions/trackle.js +1 -1
@@ -144,7 +144,7 @@ function getPollTime(intervalInSeconds, pollTime) {
|
|
144
144
|
}
|
145
145
|
function getCsvData(data, measures) {
|
146
146
|
// Initialize the header with timestamp and measure names
|
147
|
-
const headers = ["timestamp", ...measures.map(measure => measure.name)];
|
147
|
+
const headers = ["timestamp", ...measures.map(measure => measure.description || measure.name)];
|
148
148
|
const csvData = [];
|
149
149
|
// Add the header to the csvData
|
150
150
|
csvData.push(headers);
|
@@ -305,7 +305,7 @@ const TrendChart = ({ deviceId, measures1, measures2, enableDatePicker, handleGe
|
|
305
305
|
const influxData = await handleGetInfluxData(measure.name, timeStart, timeEnd, deviceId, polltime, !measure.polltime && rawQuery, !measure.polltime);
|
306
306
|
const points = getChartPoints(influxData);
|
307
307
|
return {
|
308
|
-
label: measure.name,
|
308
|
+
label: measure.description || measure.name,
|
309
309
|
data: points,
|
310
310
|
unit: measure.unit,
|
311
311
|
borderWidth: 2,
|
@@ -484,7 +484,7 @@ const TrendChart = ({ deviceId, measures1, measures2, enableDatePicker, handleGe
|
|
484
484
|
}, minDateTime: moment(timeStart * 1000), slotProps: {
|
485
485
|
textField: { size: 'small', sx: { width: { sm: 210 } } }
|
486
486
|
} })] }) });
|
487
|
-
return (_jsxs(ThemeProvider, { theme: theme, children: [enableDatePicker && _jsx(Box, { sx: { display: { xs: 'flex', lg: 'none', justifyContent: 'flex-end' }, mb: 2 }, children: datePicker }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center' }, children: [!enableExportData && measures && measures.length === 1 ? _jsx(Typography, { variant: 'body1', sx: { mr: 2 }, children: measures[0].name }) : '', enableExportData && (_jsxs(_Fragment, { children: [_jsxs(LoadingButton, { sx: { minWidth: '40px !important', mr: 1, px: 1 }, loading: loadingButton, type: "submit", variant: "text", color: "primary", onClick: handleExportData, disabled: !dataMeasures || !dataMeasures.length, size: 'small', children: [_jsx(LoginIcon, { fontSize: 'small', style: { transform: "rotate(90deg)" } }), _jsx(Box, { sx: { display: { xs: 'none', xl: 'block' }, ml: { md: 1 } }, children: "Export" })] }), _jsx(CSVLink
|
487
|
+
return (_jsxs(ThemeProvider, { theme: theme, children: [enableDatePicker && _jsx(Box, { sx: { display: { xs: 'flex', lg: 'none', justifyContent: 'flex-end' }, mb: 2 }, children: datePicker }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center' }, children: [!enableExportData && measures && measures.length === 1 ? _jsx(Typography, { variant: 'body1', sx: { mr: 2 }, children: measures[0].description || measures[0].name }) : '', enableExportData && (_jsxs(_Fragment, { children: [_jsxs(LoadingButton, { sx: { minWidth: '40px !important', mr: 1, px: 1 }, loading: loadingButton, type: "submit", variant: "text", color: "primary", onClick: handleExportData, disabled: !dataMeasures || !dataMeasures.length, size: 'small', children: [_jsx(LoginIcon, { fontSize: 'small', style: { transform: "rotate(90deg)" } }), _jsx(Box, { sx: { display: { xs: 'none', xl: 'block' }, ml: { md: 1 } }, children: "Export" })] }), _jsx(CSVLink
|
488
488
|
//@ts-ignore
|
489
489
|
, {
|
490
490
|
//@ts-ignore
|
@@ -12,7 +12,7 @@ declare const GroupUpdate: ({ userInfo, groupInfo, usersGroup, usersList, device
|
|
12
12
|
handleAddUserToGroup: (groupID: string, userName: string, userID: string) => Promise<any>;
|
13
13
|
handleRemoveUserFromGroup: (groupID: string, userID: string) => Promise<any>;
|
14
14
|
handleUpdateDevice: (id: string, body: any, user: UserType) => Promise<any>;
|
15
|
-
handleGetGroups: (
|
15
|
+
handleGetGroups: (userInfo?: UserType) => Promise<any>;
|
16
16
|
handleUpdateGroup: (id: string, group: any) => Promise<void>;
|
17
17
|
handleDeleteGroup: (id: string) => Promise<void>;
|
18
18
|
container?: "Box" | "Card";
|
@@ -27,7 +27,7 @@ const GroupUpdate = ({ userInfo, groupInfo, usersGroup, usersList, devicesList,
|
|
27
27
|
if (response) {
|
28
28
|
if (devicesList.length > 0) {
|
29
29
|
// should check if device is present in other groups the user is member of
|
30
|
-
const groupsData = await handleGetGroups(
|
30
|
+
const groupsData = await handleGetGroups({ role: 'support', uid: userId });
|
31
31
|
const userGroupIds = groupsData.map((group) => group.id);
|
32
32
|
// for all devices in the group set the selectedUser as manager
|
33
33
|
for (const device of devicesList) {
|
@@ -11,7 +11,7 @@ declare const GroupsDevices: ({ userInfo, handleGetUsersList, handleAddUserToGro
|
|
11
11
|
}>;
|
12
12
|
handleAddUserToGroup: (groupID: string, userName: string, userID: string) => Promise<any>;
|
13
13
|
handleRemoveUserFromGroup: (groupID: string, userID: string) => Promise<any>;
|
14
|
-
handleGetGroups: (
|
14
|
+
handleGetGroups: (userInfo?: UserType) => Promise<any>;
|
15
15
|
handleGetUsersGroup: (groupID: string) => Promise<any>;
|
16
16
|
handleCreateGroup: (group: any) => Promise<any>;
|
17
17
|
handleGetDevices: (user: UserType, query: string) => Promise<any>;
|
@@ -102,7 +102,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
102
102
|
};
|
103
103
|
const getGroups = async () => {
|
104
104
|
try {
|
105
|
-
const responseData = await handleGetGroups(
|
105
|
+
const responseData = await handleGetGroups(userInfo);
|
106
106
|
setGroups(responseData);
|
107
107
|
}
|
108
108
|
catch (err) {
|
@@ -145,7 +145,6 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
145
145
|
const newGroup = {
|
146
146
|
name: groupName,
|
147
147
|
description,
|
148
|
-
productID: 1008, // Assuming this is the correct productID
|
149
148
|
};
|
150
149
|
const id = await handleCreateGroup(newGroup);
|
151
150
|
await getGroups();
|
@@ -198,7 +197,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
198
197
|
// add members to devices managers
|
199
198
|
await handleUpdateDevice(device.id, {
|
200
199
|
managers: [
|
201
|
-
...device
|
200
|
+
...(device?.managers || []),
|
202
201
|
...userIdsToAdd
|
203
202
|
]
|
204
203
|
}, userInfo);
|
@@ -229,7 +228,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
229
228
|
let managersToKeep = device.managers || [];
|
230
229
|
for (const manager of device.managers) {
|
231
230
|
// should check if device is present in other groups the user is member of
|
232
|
-
const groupsData = await handleGetGroups(
|
231
|
+
const groupsData = await handleGetGroups({ role: 'support', uid: manager });
|
233
232
|
const userGroupIds = groupsData.map((group) => group.id);
|
234
233
|
const found = device.groups && device.groups.some((gID) => userGroupIds.includes(gID));
|
235
234
|
if (!found) {
|
package/package.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
export type TrackleConfig = {
|
2
|
+
orgName: string;
|
2
3
|
apiUrl: string;
|
3
|
-
createCustomerUrl: string;
|
4
4
|
clientId: string;
|
5
5
|
clientSecret: string;
|
6
6
|
tokenUrl: string;
|
7
7
|
cookieName: string;
|
8
8
|
cookieSecure: boolean;
|
9
9
|
apiTimeout: number;
|
10
|
+
productID: number;
|
10
11
|
};
|
11
12
|
export declare function logOut(trackleConfig: TrackleConfig): Promise<void>;
|
12
13
|
export declare function createCustomer(trackleConfig: TrackleConfig, uid: string): Promise<{
|
@@ -48,7 +48,7 @@ export async function logOut(trackleConfig) {
|
|
48
48
|
cookies().delete(trackleConfig.cookieName);
|
49
49
|
}
|
50
50
|
export async function createCustomer(trackleConfig, uid) {
|
51
|
-
return await wretch(trackleConfig.
|
51
|
+
return await wretch(`${trackleConfig.apiUrl}/orgs/${trackleConfig.orgName}/customers`)
|
52
52
|
.headers({
|
53
53
|
Authorization: `Basic ${btoa(`${trackleConfig.clientId}:${trackleConfig.clientSecret}`)}`
|
54
54
|
})
|