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] 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öderiert",
+ 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();