diff --git a/package-lock.json b/package-lock.json
index 1fd0cc2..8d91a7c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "ucentral-client",
- "version": "0.9.25",
+ "version": "0.9.26",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "ucentral-client",
- "version": "0.9.25",
+ "version": "0.9.26",
"dependencies": {
"@coreui/coreui": "^3.4.0",
"@coreui/icons": "^2.0.1",
@@ -27,7 +27,7 @@
"react-router-dom": "^5.2.0",
"react-widgets": "^5.1.1",
"sass": "^1.35.1",
- "ucentral-libs": "^0.8.24",
+ "ucentral-libs": "^0.8.25",
"uuid": "^8.3.2"
},
"devDependencies": {
@@ -14218,9 +14218,9 @@
}
},
"node_modules/ucentral-libs": {
- "version": "0.8.24",
- "resolved": "https://registry.npmjs.org/ucentral-libs/-/ucentral-libs-0.8.24.tgz",
- "integrity": "sha512-7xjrrUvu83L0a3lnRwysMRrdaenK/tabQhjX/hbE4rbBIqR8UYglSNU/ZgUKCivXQtpNbWXywJnQefEh7iSFiA==",
+ "version": "0.8.25",
+ "resolved": "https://registry.npmjs.org/ucentral-libs/-/ucentral-libs-0.8.25.tgz",
+ "integrity": "sha512-4a7MZob8ondxbdsW+ub6MNxeSCFp6AuEGZCVPSc7zu3SqNC6NxqslsAR2z9tjnsq/2p55FLJuMd0SR3uEGqwLw==",
"engines": {
"node": ">=10"
},
@@ -26465,9 +26465,9 @@
}
},
"ucentral-libs": {
- "version": "0.8.24",
- "resolved": "https://registry.npmjs.org/ucentral-libs/-/ucentral-libs-0.8.24.tgz",
- "integrity": "sha512-7xjrrUvu83L0a3lnRwysMRrdaenK/tabQhjX/hbE4rbBIqR8UYglSNU/ZgUKCivXQtpNbWXywJnQefEh7iSFiA==",
+ "version": "0.8.25",
+ "resolved": "https://registry.npmjs.org/ucentral-libs/-/ucentral-libs-0.8.25.tgz",
+ "integrity": "sha512-4a7MZob8ondxbdsW+ub6MNxeSCFp6AuEGZCVPSc7zu3SqNC6NxqslsAR2z9tjnsq/2p55FLJuMd0SR3uEGqwLw==",
"requires": {}
},
"unbox-primitive": {
diff --git a/package.json b/package.json
index 7c7b68d..084c6e0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ucentral-client",
- "version": "0.9.25",
+ "version": "0.9.26",
"dependencies": {
"@coreui/coreui": "^3.4.0",
"@coreui/icons": "^2.0.1",
@@ -21,7 +21,7 @@
"react-router-dom": "^5.2.0",
"react-widgets": "^5.1.1",
"sass": "^1.35.1",
- "ucentral-libs": "^0.8.24",
+ "ucentral-libs": "^0.8.25",
"uuid": "^8.3.2"
},
"main": "index.js",
diff --git a/src/layout/index.js b/src/layout/index.js
index 20cacda..2a91dfe 100644
--- a/src/layout/index.js
+++ b/src/layout/index.js
@@ -48,6 +48,7 @@ const TheLayout = () => {
t={t}
i18n={i18n}
logout={logout}
+ logo="assets/OpenWiFi_LogoLockup_DarkGreyColour.svg"
authToken={currentToken}
endpoints={endpoints}
user={user}
@@ -56,7 +57,7 @@ const TheLayout = () => {
-
+
);
diff --git a/src/pages/UserListPage/index.js b/src/pages/UserListPage/index.js
index d5b2d58..5a9019e 100644
--- a/src/pages/UserListPage/index.js
+++ b/src/pages/UserListPage/index.js
@@ -55,6 +55,71 @@ const UserListPage = () => {
});
};
+ const getAvatarPromises = (userIds) => {
+ const options = {
+ headers: {
+ Accept: 'application/json',
+ Authorization: `Bearer ${currentToken}`,
+ },
+ responseType: 'arraybuffer',
+ };
+
+ const promises = userIds.map(async (id) =>
+ axiosInstance.get(`${endpoints.ucentralsec}/api/v1/avatar/${id}`, options),
+ );
+
+ return promises;
+ };
+
+ const displayUsers = async () => {
+ setLoading(true);
+
+ const startIndex = page * usersPerPage;
+ const endIndex = parseInt(startIndex, 10) + parseInt(usersPerPage, 10);
+ const idsToGet = users
+ .slice(startIndex, endIndex)
+ .map((x) => encodeURIComponent(x))
+ .join(',');
+
+ const headers = {
+ Accept: 'application/json',
+ Authorization: `Bearer ${currentToken}`,
+ };
+
+ const avatarRequests = getAvatarPromises(users.slice(startIndex, endIndex));
+
+ const avatars = await Promise.all(avatarRequests).then((results) =>
+ results.map((response) => {
+ const base64 = btoa(
+ new Uint8Array(response.data).reduce(
+ (data, byte) => data + String.fromCharCode(byte),
+ '',
+ ),
+ );
+ return `data:;base64,${base64}`;
+ }),
+ );
+
+ axiosInstance
+ .get(`${endpoints.ucentralsec}/api/v1/users?select=${idsToGet}`, {
+ headers,
+ })
+ .then((response) => {
+ const newUsers = response.data.users.map((user, index) => {
+ const newUser = {
+ ...user,
+ avatar: avatars[index],
+ };
+ return newUser;
+ });
+ setUsersToDisplay(newUsers);
+ setLoading(false);
+ })
+ .catch(() => {
+ setLoading(false);
+ });
+ };
+
const deleteUser = (userId) => {
setDeleteLoading(true);
@@ -85,34 +150,6 @@ const UserListPage = () => {
});
};
- const displayUsers = () => {
- setLoading(true);
-
- const startIndex = page * usersPerPage;
- const endIndex = parseInt(startIndex, 10) + parseInt(usersPerPage, 10);
- const idsToGet = users
- .slice(startIndex, endIndex)
- .map((x) => encodeURIComponent(x))
- .join(',');
-
- const headers = {
- Accept: 'application/json',
- Authorization: `Bearer ${currentToken}`,
- };
-
- axiosInstance
- .get(`${endpoints.ucentralsec}/api/v1/users?select=${idsToGet}`, {
- headers,
- })
- .then((response) => {
- setUsersToDisplay(response.data.users);
- setLoading(false);
- })
- .catch(() => {
- setLoading(false);
- });
- };
-
const updateUsersPerPage = (value) => {
setItem('usersPerPage', value);
setUsersPerPage(value);