admin_lsac 2.0.28 → 2.0.29
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/README.md +2 -0
- package/dist/esm/src/components/AdminPage.js +21 -17
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@ import { MaterialReactTable } from 'material-react-table';
|
|
|
8
8
|
import { mkConfig, generateCsv, download } from 'export-to-csv';
|
|
9
9
|
import Swal from 'sweetalert2';
|
|
10
10
|
import MenuItem from '@mui/material/MenuItem';
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
import { io } from 'socket.io-client';
|
|
12
|
+
import { newSocket } from '../utils/websockets';
|
|
13
13
|
export function pageToUrl(page) {
|
|
14
14
|
return `${page.name.toLowerCase().replace(' ', '_')}`;
|
|
15
15
|
}
|
|
@@ -59,27 +59,31 @@ export function AdminPage({ pages, selectedPage, basePath, apiURL = '', }) {
|
|
|
59
59
|
const [rowId, setRowId] = useState();
|
|
60
60
|
const [rowObject, setRowObject] = useState([]);
|
|
61
61
|
const [refetch, setRefetch] = useState(false);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const [socket, setSocket] = useState(io);
|
|
63
|
+
if (apiURL !== '') {
|
|
64
|
+
newSocket(setSocket, apiURL);
|
|
65
|
+
}
|
|
65
66
|
useEffect(() => {
|
|
66
67
|
selectedPage.getRequest().then((resArray) => {
|
|
67
68
|
setData(resArray);
|
|
68
69
|
setRefetch(false);
|
|
69
70
|
});
|
|
70
71
|
}, [refetch]); // Do not remove 'refetch' from here !!!
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (apiURL !== '') {
|
|
74
|
+
socket.on('updateData', (message) => {
|
|
75
|
+
console.log('Message emitted from socket: ' + message);
|
|
76
|
+
setRefetch(true);
|
|
77
|
+
const rowActionsMenu = document.querySelector('.MuiPaper-root.MuiPopover-paper.MuiMenu-paper');
|
|
78
|
+
if (rowActionsMenu) {
|
|
79
|
+
rowActionsMenu.remove();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return () => {
|
|
83
|
+
socket.off('updateData');
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}, [socket, selectedPage, apiURL]);
|
|
83
87
|
useEffect(() => {
|
|
84
88
|
setDisplayData(data.map((row) => selectedPage.tableFields.map((field) => field.access(row))));
|
|
85
89
|
}, [data]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "admin_lsac",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.29",
|
|
5
5
|
"description": "Generic Admin Panel created for storing events' data",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@chakra-ui/react": "^2.8.2",
|
|
24
|
+
"@mui/icons-material": "^5.18.0",
|
|
24
25
|
"@mui/material": "^5.15.20",
|
|
25
26
|
"axios": "^1.7.2",
|
|
26
27
|
"export-to-csv": "^1.3.0",
|