From 2f96951c194dbe5a1d03a1a937c503ed43cf534e Mon Sep 17 00:00:00 2001 From: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> Date: Mon, 4 Jan 2021 09:14:33 +0100 Subject: [PATCH] Add view of reported events (#84) --- README.md | 2 +- src/App.js | 10 ++- src/components/EventReports.js | 135 +++++++++++++++++++++++++++++++++ src/i18n/de.js | 25 ++++++ src/i18n/en.js | 25 ++++++ src/synapse/dataProvider.js | 9 +++ 6 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 src/components/EventReports.js diff --git a/README.md b/README.md index a2e0190..722d54b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This project is built using [react-admin](https://marmelab.com/react-admin/). -It needs at least Synapse v1.18.0 for all functions to work as expected! +It needs at least Synapse v1.23.0 for all functions to work as expected! You get your server version with the request `/_synapse/admin/v1/server_version`. See also [Synapse version API](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/version_api.rst). diff --git a/src/App.js b/src/App.js index 6ad0b22..5b784c4 100644 --- a/src/App.js +++ b/src/App.js @@ -5,9 +5,11 @@ import authProvider from "./synapse/authProvider"; import dataProvider from "./synapse/dataProvider"; import { UserList, UserCreate, UserEdit } from "./components/users"; import { RoomList, RoomShow } from "./components/rooms"; +import { ReportList, ReportShow } from "./components/EventReports"; import LoginPage from "./components/LoginPage"; import UserIcon from "@material-ui/icons/Group"; -import { ViewListIcon as RoomIcon } from "@material-ui/icons/ViewList"; +import RoomIcon from "@material-ui/icons/ViewList"; +import ReportIcon from "@material-ui/icons/Warning"; import { ImportFeature } from "./components/ImportFeature"; import { Route } from "react-router-dom"; import germanMessages from "./i18n/de"; @@ -41,6 +43,12 @@ const App = () => ( icon={UserIcon} /> + diff --git a/src/components/EventReports.js b/src/components/EventReports.js new file mode 100644 index 0000000..c73647f --- /dev/null +++ b/src/components/EventReports.js @@ -0,0 +1,135 @@ +import React from "react"; +import { + Datagrid, + DateField, + List, + NumberField, + Pagination, + ReferenceField, + Show, + Tab, + TabbedShowLayout, + TextField, + useTranslate, +} from "react-admin"; +import PageviewIcon from "@material-ui/icons/Pageview"; +import ViewListIcon from "@material-ui/icons/ViewList"; + +const ReportPagination = props => ( + +); + +export const ReportShow = props => { + const translate = useTranslate(); + return ( + + + } + > + + + + + + + + + + + + + + } + path="detail" + > + {" "} + + + + + + + + + + + + + + + + + ); +}; + +export const ReportList = ({ ...props }) => { + return ( + } + sort={{ field: "received_ts", order: "DESC" }} + bulkActionButtons={false} + > + + + + + + + + + ); +}; diff --git a/src/i18n/de.js b/src/i18n/de.js index d0d47fa..1b60545 100644 --- a/src/i18n/de.js +++ b/src/i18n/de.js @@ -29,6 +29,7 @@ export default { "Sind Sie sicher dass Sie den Raum löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden. Alle Nachrichten und Medien, die der Raum beinhaltet werden vom Server gelöscht!", }, }, + reports: { tabs: { basic: "Allgemein", detail: "Details" } }, }, import_users: { error: { @@ -173,6 +174,30 @@ export default { unencrypted: "Nicht verschlüsselt", }, }, + reports: { + name: "Ereignisbericht |||| Ereignisberichte", + fields: { + id: "ID", + received_ts: "Meldezeit", + user_id: "Meldender", + name: "Raumname", + score: "Wert", + reason: "Grund", + event_id: "Event-ID", + event_json: { + origin: "Ursprungsserver", + origin_server_ts: "Sendezeit", + type: "Eventtyp", + content: { + msgtype: "Inhaltstyp", + body: "Nachrichteninhalt", + format: "Nachrichtenformat", + formatted_body: "Formatierter Nachrichteninhalt", + algorithm: "Verschlüsselungsalgorithmus", + }, + }, + }, + }, connections: { name: "Verbindungen", fields: { diff --git a/src/i18n/en.js b/src/i18n/en.js index 43788ed..76b33aa 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -27,6 +27,7 @@ export default { "Are you sure you want to delete the room? This cannot be undone. All messages and shared media in the room will be deleted from the server!", }, }, + reports: { tabs: { basic: "Basic", detail: "Details" } }, }, import_users: { error: { @@ -170,6 +171,30 @@ export default { unencrypted: "Unencrypted", }, }, + reports: { + name: "Reported event |||| Reported events", + fields: { + id: "ID", + received_ts: "report time", + user_id: "announcer", + name: "name of the room", + score: "score", + reason: "reason", + event_id: "event ID", + event_json: { + origin: "origin server", + origin_server_ts: "time of send", + type: "event typ", + content: { + msgtype: "content type", + body: "content", + format: "format", + formatted_body: "formatted content", + algorithm: "algorithm", + }, + }, + }, + }, connections: { name: "Connections", fields: { diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index 6d5f78d..560bdb9 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -72,6 +72,15 @@ const resourceMap = { method: "POST", }), }, + reports: { + path: "/_synapse/admin/v1/event_reports", + map: er => ({ + ...er, + id: er.id, + }), + data: "event_reports", + total: json => json.total, + }, devices: { map: d => ({ ...d,