@iotready/nextjs-components-library 1.0.0-preview33 → 1.0.0-preview34
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.
|
@@ -850,7 +850,7 @@ const TrendChart = ({ filter, measures1, annotationsDataFn, measures2, enableDat
|
|
|
850
850
|
'& .MuiToggleButton-root': {
|
|
851
851
|
color: 'text.primary', fontSize: '0.95rem', fontWeight: 'normal', paddingTop: '6px', paddingBottom: '6px'
|
|
852
852
|
}
|
|
853
|
-
}, disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] }), _jsx(MuiTooltip, { placement: "top", arrow: true, title: "Connect point values", children: _jsx("span", { children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: spanGapsOption, disabled: chartLoading, onChange: () => handleSpanGaps(!spanGapsOption), sx: { ml: 1 }, children: _jsx(TimelineIcon, {}) }) }) }), annotationsData !== null && (_jsx(MuiTooltip, { placement: "top", arrow: true, title: "Show annotations", children: _jsx("span", { children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: annotationsEnabled, disabled: chartLoading, onChange: () => setAnnotationsEnabled(!annotationsEnabled), sx: { ml: 1 }, children: _jsx(EditNoteIcon, {}) }) }) }))] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { mt: 2, height: '100%' }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
|
|
853
|
+
}, disabled: chartLoading, children: [_jsx(ToggleButton, { value: "1D", sx: { px: 1 }, children: "1d" }), _jsx(ToggleButton, { value: "1W", sx: { px: 1 }, children: "1w" }), _jsx(ToggleButton, { value: "1M", sx: { px: 1 }, children: "1M" }), _jsx(ToggleButton, { value: "3M", sx: { px: 1 }, children: "3M" }), _jsx(ToggleButton, { value: "6M", sx: { px: 1 }, children: "6M" }), _jsx(ToggleButton, { value: "1Y", sx: { px: 1 }, children: "1Y" }), _jsx(ToggleButton, { value: "ALL", sx: { px: 1 }, children: "ALL" })] }), _jsx(MuiTooltip, { placement: "top", arrow: true, title: "Connect point values", children: _jsx("span", { children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: spanGapsOption, disabled: chartLoading, onChange: () => handleSpanGaps(!spanGapsOption), sx: { ml: 1 }, children: _jsx(TimelineIcon, {}) }) }) }), annotationsDataFn && annotationsData !== null && (_jsx(MuiTooltip, { placement: "top", arrow: true, title: "Show annotations", children: _jsx("span", { children: _jsx(ToggleButton, { value: "check", color: "primary", size: "small", selected: annotationsEnabled, disabled: chartLoading, onChange: () => setAnnotationsEnabled(!annotationsEnabled), sx: { ml: 1 }, children: _jsx(EditNoteIcon, {}) }) }) }))] })] }), _jsx(Box, { component: 'div', className: "chart-container", sx: { mt: 2, height: '100%' }, children: chartJsLoaded && !chartLoading && typeof window !== 'undefined' ?
|
|
854
854
|
_jsx(_Fragment, { children: dataMeasures && (dataMeasures.length > 1 || (dataMeasures.length === 1 && dataMeasures[0].data?.length)) ?
|
|
855
855
|
(_jsx(Line, { options: options, data: {
|
|
856
856
|
// datasets: dataMeasures || [{ data: [] }]
|
|
@@ -134,6 +134,9 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
|
134
134
|
getUsersGroup(currentGroup);
|
|
135
135
|
}
|
|
136
136
|
fetchDevices(currentGroup, currentGroup);
|
|
137
|
+
if (isOrg) {
|
|
138
|
+
setCheckboxSelection(true);
|
|
139
|
+
}
|
|
137
140
|
}
|
|
138
141
|
}, [currentGroup, groups]);
|
|
139
142
|
useEffect(() => {
|
|
@@ -254,26 +257,64 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
|
254
257
|
}, onCellClick: (params) => {
|
|
255
258
|
clickedIdRef.current = params.id.toString(); // aggiornamento immediato
|
|
256
259
|
}, onRowSelectionModelChange: (ids) => {
|
|
257
|
-
if (!checkboxSelection
|
|
260
|
+
if (!checkboxSelection)
|
|
258
261
|
return;
|
|
259
|
-
|
|
260
|
-
clickedIdRef.current
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
262
|
+
// Se abbiamo un clickedIdRef, gestiamo il click individuale
|
|
263
|
+
if (clickedIdRef.current) {
|
|
264
|
+
const clickedId = clickedIdRef.current;
|
|
265
|
+
clickedIdRef.current = null; // resetta subito dopo l'uso
|
|
266
|
+
setDevicesToAdd(prevIds => {
|
|
267
|
+
const updated = prevIds.includes(clickedId)
|
|
268
|
+
? prevIds.filter(id => id !== clickedId)
|
|
269
|
+
: [...prevIds, clickedId];
|
|
270
|
+
return updated;
|
|
271
|
+
});
|
|
272
|
+
setDeviceSelectedObjs(prevObjs => {
|
|
273
|
+
const isDeselecting = prevObjs.some(d => d.id.toString() === clickedId);
|
|
274
|
+
if (isDeselecting) {
|
|
275
|
+
return prevObjs.filter(d => d.id.toString() !== clickedId);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
const device = devices.find(d => d.id.toString() === clickedId);
|
|
279
|
+
return device ? [...prevObjs, device] : prevObjs;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
// Gestione del "check all" - confronta con il modello di selezione attuale
|
|
285
|
+
const currentSelection = (checkboxSelection && currentGroup === 'all')
|
|
286
|
+
? [
|
|
287
|
+
...devices
|
|
288
|
+
.filter(d => d.groups?.includes(selectedGroup))
|
|
289
|
+
.map(d => d.id.toString()),
|
|
290
|
+
...devicesToAdd,
|
|
291
|
+
]
|
|
292
|
+
: devicesToAdd;
|
|
293
|
+
// Se la selezione è diversa, aggiorna devicesToAdd
|
|
294
|
+
if (JSON.stringify(ids.sort()) !== JSON.stringify(currentSelection.sort())) {
|
|
295
|
+
// Filtra solo i dispositivi che non sono già nel gruppo
|
|
296
|
+
const selectableDevices = devices
|
|
297
|
+
.filter(d => !d.groups?.includes(selectedGroup))
|
|
298
|
+
.map(d => d.id.toString());
|
|
299
|
+
// Calcola i nuovi dispositivi da aggiungere
|
|
300
|
+
const newDevicesToAdd = ids.filter(id => selectableDevices.includes(id) && !devicesToAdd.includes(id));
|
|
301
|
+
// Calcola i dispositivi da rimuovere dalla selezione
|
|
302
|
+
const devicesToRemove = devicesToAdd.filter(id => !ids.includes(id));
|
|
303
|
+
// Aggiorna devicesToAdd
|
|
304
|
+
setDevicesToAdd(prevIds => {
|
|
305
|
+
return prevIds
|
|
306
|
+
.filter(id => !devicesToRemove.includes(id))
|
|
307
|
+
.concat(newDevicesToAdd);
|
|
308
|
+
});
|
|
309
|
+
// Aggiorna deviceSelectedObjs
|
|
310
|
+
setDeviceSelectedObjs(prevObjs => {
|
|
311
|
+
return prevObjs
|
|
312
|
+
.filter(d => !devicesToRemove.includes(d.id.toString()))
|
|
313
|
+
.concat(devices.filter(d => newDevicesToAdd.includes(d.id.toString()) &&
|
|
314
|
+
!prevObjs.some(obj => obj.id.toString() === d.id.toString())));
|
|
315
|
+
});
|
|
275
316
|
}
|
|
276
|
-
}
|
|
317
|
+
}
|
|
277
318
|
}, disableDensitySelector: true, disableColumnSelector: true, disableRowSelectionOnClick: true, loading: loadingDevices, rows: devices, columns: checkboxSelection
|
|
278
319
|
? columnsArray.filter(col => col.field !== 'id')
|
|
279
320
|
: columnsArray, slots: {
|
|
@@ -298,7 +339,7 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
|
298
339
|
_jsx(Card, { ...containerProps, children: renderDataGrid }) : _jsx(Box, { ...containerProps, children: renderDataGrid }));
|
|
299
340
|
if (!userInfo || !groups || !devices)
|
|
300
341
|
return loadingComponent;
|
|
301
|
-
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Box, { ...props, children: [_jsxs(Box, { component: "div", sx: { display: 'flex', alignItems: 'center', mb: 1, backgroundColor: editGroup && !isOrg ? 'secondary.light' : '', borderRadius: 3, px: editGroup ? 2 : 0, py: 1, height: 50, ...propsHeaderGroups }, children: [editGroup ?
|
|
342
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Box, { ...props, children: [_jsxs(Box, { component: "div", sx: { display: 'flex', alignItems: 'center', mb: 1, backgroundColor: editGroup && !isOrg ? 'secondary.light' : '', borderRadius: 3, px: editGroup ? 2 : 0, py: 1, height: 50, ...propsHeaderGroups }, children: [editGroup ? _jsx(Typography, { variant: isOrg ? 'h6' : 'subtitle1', children: _jsxs("b", { children: [labelEntity, " \"", groupInfo?.name, "\""] }) }) : '', groups && !checkboxSelection && !isOrg && !(editGroup && currentGroup === 'all') ?
|
|
302
343
|
_jsx(Autocomplete, { disablePortal: true, onChange: handleChangeGroupSelect, value: groupInfo?.name || groupsLabelAll || 'All devices', disableClearable: currentGroup === 'all', isOptionEqualToValue: (o, v) => o.label === v, options: [{ label: groupsLabelAll || 'All devices', id: 'all' }, ...groups.map((grp) => ({ label: grp.name, id: grp.id }))], sx: { width: { xs: 200, sm: 300 }, textAlign: 'left' }, size: 'small', renderInput: (params) => _jsx(TextField, { ...params, label: labelEntity }) })
|
|
303
344
|
: '', (userInfo.role === 'admin' || (groupUpdateRoles && groupUpdateRoles.includes(userInfo.role))) &&
|
|
304
345
|
_jsxs(Box, { sx: { ml: 2 }, children: [checkboxSelection ?
|
|
@@ -319,6 +360,6 @@ const GroupsDevices = ({ userInfo, handleGetUsersList, handleAddUserToGroup, han
|
|
|
319
360
|
transform: 'translate(-50%, -50%)',
|
|
320
361
|
width: 400,
|
|
321
362
|
borderRadius: 4
|
|
322
|
-
}, children: [_jsx(CardHeader, { title: "
|
|
363
|
+
}, children: [_jsx(CardHeader, { title: "New " + labelEntity, action: _jsx(IconButton, { onClick: handleCloseAdd, children: _jsx(CloseIcon, {}) }) }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: handleSubmit, children: [_jsx(TextField, { fullWidth: true, label: labelEntity + " Name", value: groupName, onChange: (e) => setGroupName(e.target.value), required: true }), _jsx(TextField, { fullWidth: true, label: "Description", value: description, onChange: (e) => setDescription(e.target.value), margin: "normal", multiline: true, rows: 4 }), _jsxs(Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [_jsx(Button, { variant: "contained", color: "info", onClick: handleCloseAdd, children: "Cancel" }), _jsx(LoadingButton, { loading: loadingAdd, variant: "contained", color: "primary", type: "submit", children: "Create" })] })] }) })] }) }), !groupUpdateVisible && renderDatagridAndMaps, groupInfo && editGroup && groupUpdateVisible && _jsx(GroupUpdate, { confirmMui: confirmMui, userInfo: userInfo, usersGroup: usersGroup, usersList: usersList, handleGetGroups: handleGetGroups, handleUpdateDevice: handleUpdateDevice, handleAddUserToGroup: handleAddUserToGroup, handleRemoveUserFromGroup: handleRemoveUserFromGroup, groupInfo: groupInfo, afterUpdateCallback: async (groupInfo) => { setGroupInfo(groupInfo); await getGroups(); await getUsersGroup(groupInfo.id); }, afterRemoveCallback: async () => { closeEditGroup(); await getGroups(); setCurrentGroup('all'); }, container: 'Card', handleDeleteGroup: handleDeleteGroup, handleUpdateGroup: handleUpdateGroup, devicesList: devices, labelEntity: labelEntity })] }) }));
|
|
323
364
|
};
|
|
324
365
|
export default GroupsDevices;
|
package/package.json
CHANGED