Show the myTeamSpeak ID, UUID and creation date in the account tab
The ID is the account's base32 myTeamSpeak ID: the localpart of its chat ID and the user the myTeamSpeak file API addresses. All three come from the sign-in reply already fetched, on desktop and Android. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package com.ts3client.ui;
|
||||
|
||||
import com.formdev.flatlaf.util.ScaledEmptyBorder;
|
||||
import com.formdev.flatlaf.util.UIScale;
|
||||
import com.ts3client.myts.AccountInfo;
|
||||
import com.ts3client.myts.MyTeamSpeak;
|
||||
import com.ts3client.myts.MyTeamSpeakLogin;
|
||||
import com.ts3client.myts.MyTsException;
|
||||
@@ -25,6 +26,9 @@ import java.awt.CardLayout;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.io.IOException;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -50,6 +54,7 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
private final JLabel signInStatus = new JLabel(" ");
|
||||
|
||||
private final JLabel account = new JLabel();
|
||||
private final JPanel details = new JPanel(new GridBagLayout());
|
||||
private final ItemTable items = new ItemTable();
|
||||
private final JButton refresh = new JButton("Refresh");
|
||||
private final JButton importButton = new JButton("Import selected");
|
||||
@@ -108,6 +113,9 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
signOut.addActionListener(e -> signOut());
|
||||
header.add(account, BorderLayout.CENTER);
|
||||
header.add(signOut, BorderLayout.EAST);
|
||||
JPanel top = new JPanel(new BorderLayout(0, UIScale.scale(8)));
|
||||
top.add(header, BorderLayout.NORTH);
|
||||
top.add(details, BorderLayout.CENTER);
|
||||
|
||||
JPanel buttons = new JPanel();
|
||||
buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
|
||||
@@ -126,7 +134,7 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout(0, UIScale.scale(12)));
|
||||
panel.setBorder(new ScaledEmptyBorder(12, 12, 12, 12));
|
||||
panel.add(header, BorderLayout.NORTH);
|
||||
panel.add(top, BorderLayout.NORTH);
|
||||
panel.add(data, BorderLayout.CENTER);
|
||||
return panel;
|
||||
}
|
||||
@@ -167,6 +175,7 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
private void signOut() {
|
||||
login.signOut();
|
||||
accountItems = List.of();
|
||||
details.removeAll();
|
||||
items.set(List.of());
|
||||
fetched = false;
|
||||
email.setText("");
|
||||
@@ -193,8 +202,32 @@ final class MyTeamSpeakPanel extends JPanel {
|
||||
});
|
||||
}
|
||||
|
||||
private void showDetails(AccountInfo info) {
|
||||
details.removeAll();
|
||||
GridBagConstraints c = FormPanel.gbc();
|
||||
int row = 0;
|
||||
if (!info.userId().isEmpty()) FormPanel.addRow(details, c, row++, new JLabel("ID:"), selectable(info.userId()));
|
||||
if (!info.uuid().isEmpty()) FormPanel.addRow(details, c, row++, new JLabel("UUID:"), selectable(info.uuid()));
|
||||
if (info.created() != null) {
|
||||
String date = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)
|
||||
.format(info.created().atZone(ZoneId.systemDefault()));
|
||||
FormPanel.addRow(details, c, row, new JLabel("Created:"), selectable(date));
|
||||
}
|
||||
details.revalidate();
|
||||
details.repaint();
|
||||
}
|
||||
|
||||
/** A value that can be selected and copied but not edited. */
|
||||
private static JTextField selectable(String value) {
|
||||
JTextField field = new JTextField(value);
|
||||
field.setEditable(false);
|
||||
field.setCaretPosition(0);
|
||||
return field;
|
||||
}
|
||||
|
||||
private void showItems(MyTeamSpeak.Account result) {
|
||||
fetched = true;
|
||||
showDetails(result.info());
|
||||
accountItems = result.items();
|
||||
List<Row> rows = new ArrayList<>();
|
||||
for (SyncItem item : accountItems) {
|
||||
|
||||
Reference in New Issue
Block a user