Diff

mod_client_management/mod_client_management.lua @ 5309:09656e2b4927

mod_client_management: Improve table output Requires 1f89a2a9f532 and 1023c3faffac from Prosody.
author Matthew Wild <mwild1@gmail.com>
date Thu, 06 Apr 2023 15:22:10 +0100
parent 5308:f370ccb15f05
child 5310:5806e05346b8
line wrap: on
line diff
--- a/mod_client_management/mod_client_management.lua	Thu Apr 06 15:21:09 2023 +0100
+++ b/mod_client_management/mod_client_management.lua	Thu Apr 06 15:22:10 2023 +0100
@@ -389,22 +389,25 @@
 		end
 
 		local colspec = {
-			{ title = "Software", key = "software" };
-			{ title = "Last seen", key = "last_seen" };
-			{ title = "Authentication", key = "auth_methods" };
+			{ title = "Software", key = "software", width = "1p" };
+			{ title = "Last seen", key = "last_seen", width = 10 };
+			{ title = "Authentication", key = "auth_methods", width = "2p" };
 		};
 
 		local row = require "util.human.io".table(colspec, self.session.width);
 
 		local print = self.session.print;
 		print(row());
+		print(string.rep("-", self.session.width));
 		for _, client in ipairs(clients) do
 			print(row({
-				software = client.user_agent.software;
+				id = client.id;
+				software = client.user_agent and client.user_agent.software;
 				last_seen = os.date("%Y-%m-%d", client.last_seen);
 				auth_methods = array.collect(it.keys(client.active)):sort();
 			}));
 		end
-		print(("%d clients"):format(#clients));
+		print(string.rep("-", self.session.width));
+		return true, ("%d clients"):format(#clients);
 	end
 end);