From f3b328a4d87fbc65de78732d76aef89f29f50ab5 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 2 Aug 2022 12:23:57 +0200 Subject: [PATCH] format user/server-info tables - sort keys for consistent presentation - use text list for roles, groups, which aren't well rendered by the table-formatter (number index isn't helpful) - render timestamps - leave empty name for default server, instead of '[MAIN]' which isn't terminology used anywhere else --- .../ServerDashboard/ServerDashboard.jsx | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/jsx/src/components/ServerDashboard/ServerDashboard.jsx b/jsx/src/components/ServerDashboard/ServerDashboard.jsx index dce3a067..94c8e6d3 100644 --- a/jsx/src/components/ServerDashboard/ServerDashboard.jsx +++ b/jsx/src/components/ServerDashboard/ServerDashboard.jsx @@ -201,6 +201,25 @@ const ServerDashboard = (props) => { }; const ServerRowTable = ({ data }) => { + const sortedData = Object.keys(data) + .sort() + .reduce(function (result, key) { + let value = data[key]; + switch (key) { + case "last_activity": + case "created": + case "started": + // format timestamps + value = value ? timeSince(value) : value; + break; + } + if (Array.isArray(value)) { + // cast arrays (e.g. roles, groups) to string + value = value.sort().join(", "); + } + result[key] = value; + return result; + }, {}); return ( { valueStyle={{ padding: "4px", }} - data={data} + data={sortedData} /> ); }; @@ -251,11 +270,7 @@ const ServerDashboard = (props) => { {user.admin ? "admin" : ""} - {server.name ? ( -

{server.name}

- ) : ( -

[MAIN]

- )} +

{server.name}

{server.last_activity ? timeSince(server.last_activity) : "Never"}