From 3884c500124916d24f2ebfee2c5217530fc6b335 Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Sat, 23 May 2020 17:43:33 +0200 Subject: [PATCH 1/5] Extend the room list with further attributes Add further attributes: - is_encrypted - federatable - public - state_events - version - joined_local_members Also add the ability to sort. API was added by synapse v1.13.0. --- src/components/rooms.js | 22 +++++++++++++++++++--- src/i18n/de.js | 6 ++++++ src/i18n/en.js | 6 ++++++ src/synapse/dataProvider.js | 14 ++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/components/rooms.js b/src/components/rooms.js index 8cac414..a28290f 100644 --- a/src/components/rooms.js +++ b/src/components/rooms.js @@ -1,17 +1,33 @@ import React from "react"; -import { Datagrid, List, TextField, Pagination } from "react-admin"; +import { + Datagrid, + List, + TextField, + Pagination, + BooleanField, +} from "react-admin"; const RoomPagination = props => ( ); export const RoomList = props => ( - }> + } + sort={{ field: "name", order: "ASC" }} + > - + + + + + + + ); diff --git a/src/i18n/de.js b/src/i18n/de.js index a467c1a..c7466b4 100644 --- a/src/i18n/de.js +++ b/src/i18n/de.js @@ -53,6 +53,12 @@ export default { name: "Name", canonical_alias: "Alias", joined_members: "Mitglieder", + joined_local_members: "lokale Mitglieder", + state_events: "Ereignisse", + version: "Version", + is_encrypted: "Verschlüsselt", + federatable: "Fö­de­riert", + public: "Öffentlich", }, }, connections: { diff --git a/src/i18n/en.js b/src/i18n/en.js index a7a6141..e6335e0 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -53,6 +53,12 @@ export default { name: "Name", canonical_alias: "Alias", joined_members: "Members", + joined_local_members: "local members", + state_events: "State events", + version: "Version", + is_encrypted: "Encrypted", + federatable: "Federatable", + public: "Public", }, }, connections: { diff --git a/src/synapse/dataProvider.js b/src/synapse/dataProvider.js index 6d5486c..0729094 100644 --- a/src/synapse/dataProvider.js +++ b/src/synapse/dataProvider.js @@ -48,6 +48,9 @@ const resourceMap = { id: r.room_id, alias: r.canonical_alias, members: r.joined_members, + is_encrypted: !!r.encryption, + federatable: !!r.federatable, + public: !!r.public, }), data: "rooms", total: json => { @@ -86,11 +89,20 @@ function filterNullValues(key, value) { return value; } +function getSearchOrder(order) { + if (order === "DESC") { + return "b"; + } else { + return "f"; + } +} + const dataProvider = { getList: (resource, params) => { console.log("getList " + resource); const { user_id, guests, deactivated } = params.filter; const { page, perPage } = params.pagination; + const { field, order } = params.sort; const from = (page - 1) * perPage; const query = { from: from, @@ -98,6 +110,8 @@ const dataProvider = { user_id: user_id, guests: guests, deactivated: deactivated, + order_by: field, + dir: getSearchOrder(order), }; const homeserver = localStorage.getItem("base_url"); if (!homeserver || !(resource in resourceMap)) return Promise.reject(); From 168e24929698684609469d38664f76d92ef2e608 Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Tue, 16 Jun 2020 07:54:49 +0200 Subject: [PATCH 2/5] Bugfix removes the ability to click on individual connections. If you click on a connection in UserEdit, you will get an empty page. This solves the problem. --- src/components/users.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/users.js b/src/components/users.js index d978c26..fd334f0 100644 --- a/src/components/users.js +++ b/src/components/users.js @@ -176,7 +176,12 @@ export const UserEdit = props => ( label="resources.connections.name" icon={} > - + Date: Tue, 16 Jun 2020 09:24:49 +0200 Subject: [PATCH 3/5] Add creation timestamp and consent version to UserEdit Add information about the user to UserEdit - creation timestamp - consent version --- src/components/users.js | 13 +++++++++++++ src/i18n/de.js | 2 ++ src/i18n/en.js | 2 ++ src/synapse/dataProvider.js | 2 ++ 4 files changed, 19 insertions(+) diff --git a/src/components/users.js b/src/components/users.js index fd334f0..9f57e85 100644 --- a/src/components/users.js +++ b/src/components/users.js @@ -159,6 +159,19 @@ export const UserEdit = props => ( source="deactivated" helperText="resources.users.helper.deactivate" /> + + { From aaf1ebb9093b1aa041f9b7745a85012c45303545 Mon Sep 17 00:00:00 2001 From: dklimpel <5740567+dklimpel@users.noreply.github.com> Date: Tue, 16 Jun 2020 10:05:38 +0200 Subject: [PATCH 4/5] Change field `creation_ts * 1000` to `creation_ts_ms` --- src/components/users.js | 2 +- src/i18n/de.js | 4 ++-- src/i18n/en.js | 2 +- src/synapse/dataProvider.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/users.js b/src/components/users.js index 9f57e85..e83b70e 100644 --- a/src/components/users.js +++ b/src/components/users.js @@ -160,7 +160,7 @@ export const UserEdit = props => ( helperText="resources.users.helper.deactivate" /> { From 3fd615943cc441ee154d4fc278b036b16fdd1986 Mon Sep 17 00:00:00 2001 From: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> Date: Wed, 1 Jul 2020 22:36:15 +0200 Subject: [PATCH 5/5] Shows encrypted status with icons --- src/components/rooms.js | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/components/rooms.js b/src/components/rooms.js index a28290f..4c598b9 100644 --- a/src/components/rooms.js +++ b/src/components/rooms.js @@ -5,12 +5,43 @@ import { TextField, Pagination, BooleanField, + useTranslate, } from "react-admin"; +import get from "lodash/get"; +import { Tooltip, Typography } from "@material-ui/core"; +import HttpsIcon from "@material-ui/icons/Https"; +import NoEncryptionIcon from "@material-ui/icons/NoEncryption"; const RoomPagination = props => ( ); +const EncryptionField = ({ source, record = {}, emptyText }) => { + const translate = useTranslate(); + const value = get(record, source); + let ariaLabel = value === false ? "ra.boolean.false" : "ra.boolean.true"; + + if (value === false || value === true) { + return ( + + + {value === true ? ( + + ) : ( + + )} + + + ); + } + + return ( + + {emptyText} + + ); +}; + export const RoomList = props => ( ( sort={{ field: "name", order: "ASC" }} > + } + /> @@ -25,7 +61,6 @@ export const RoomList = props => ( -