Add list of client connections per user (#26)

List the result of GET /_synapse/admin/v1/whois/<user_id>.
This commit is contained in:
dklimpel 2020-03-28 21:25:34 +01:00 committed by Manuel Stahl
parent dfc643a10f
commit 7ef6bc05c6
5 changed files with 87 additions and 19 deletions

View file

@ -36,6 +36,7 @@ const App = () => (
icon={UserIcon}
/>
<Resource name="rooms" list={RoomList} icon={RoomIcon} />
<Resource name="connections" />
</Admin>
);

View file

@ -1,13 +1,19 @@
import React from "react";
import PersonPinIcon from "@material-ui/icons/PersonPin";
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
import {
ArrayInput,
ArrayField,
Datagrid,
DateField,
Create,
Edit,
List,
Filter,
SimpleForm,
SimpleFormIterator,
TabbedForm,
FormTab,
BooleanField,
BooleanInput,
ImageField,
@ -94,24 +100,59 @@ export const UserCreate = props => (
export const UserEdit = props => (
<Edit {...props}>
<SimpleForm>
<TextInput source="id" disabled />
<TextInput source="displayname" />
<PasswordInput source="password" autoComplete="new-password" />
<BooleanInput source="admin" />
<BooleanInput source="deactivated" />
<ArrayInput source="threepids">
<SimpleFormIterator>
<SelectInput
source="medium"
choices={[
{ id: "email", name: "resources.users.email" },
{ id: "msisdn", name: "resources.users.msisdn" },
]}
/>
<TextInput source="address" />
</SimpleFormIterator>
</ArrayInput>
</SimpleForm>
<TabbedForm>
<FormTab label="resources.users.name" icon={<PersonPinIcon />}>
<TextInput source="id" disabled />
<TextInput source="displayname" />
<PasswordInput source="password" autoComplete="new-password" />
<BooleanInput source="admin" />
<BooleanInput source="deactivated" />
<ArrayInput source="threepids">
<SimpleFormIterator>
<SelectInput
source="medium"
choices={[
{ id: "email", name: "resources.users.email" },
{ id: "msisdn", name: "resources.users.msisdn" },
]}
/>
<TextInput source="address" />
</SimpleFormIterator>
</ArrayInput>
</FormTab>
<FormTab
label="resources.connections.name"
icon={<SettingsInputComponentIcon />}
>
<ReferenceField reference="connections" source="id" addLabel={false}>
<ArrayField
source="devices[].sessions[0].connections"
label="resources.connections.name"
>
<Datagrid style={{ width: "100%" }}>
<TextField source="ip" sortable={false} />
<DateField
source="last_seen"
showTime
options={{
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
}}
sortable={false}
/>
<TextField
source="user_agent"
sortable={false}
style={{ width: "100%" }}
/>
</Datagrid>
</ArrayField>
</ReferenceField>
</FormTab>
</TabbedForm>
</Edit>
);

View file

@ -14,6 +14,7 @@ export default {
},
resources: {
users: {
backtolist: "Zurück zur Liste",
name: "Benutzer",
email: "E-Mail",
msisdn: "Telefon",
@ -44,5 +45,13 @@ export default {
joined_members: "Mitglieder",
},
},
connections: {
name: "Verbindungen",
fields: {
last_seen: "Datum",
ip: "IP-Adresse",
user_agent: "User Agent",
},
},
},
};

View file

@ -14,6 +14,7 @@ export default {
},
resources: {
users: {
backtolist: "Back to list",
name: "User |||| Users",
email: "Email",
msisdn: "Phone",
@ -44,5 +45,13 @@ export default {
joined_members: "Members",
},
},
connections: {
name: "Connections",
fields: {
last_seen: "Date",
ip: "IP address",
user_agent: "User agent",
},
},
},
};

View file

@ -44,6 +44,14 @@ const resourceMap = {
return json.total_rooms;
},
},
connections: {
path: "/_synapse/admin/v1/whois",
map: c => ({
...c,
id: c.user_id,
}),
data: "connections",
},
};
function filterNullValues(key, value) {