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.
This commit is contained in:
parent
009ce803e2
commit
3884c50012
@ -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 => (
|
||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||
);
|
||||
|
||||
export const RoomList = props => (
|
||||
<List {...props} pagination={<RoomPagination />}>
|
||||
<List
|
||||
{...props}
|
||||
pagination={<RoomPagination />}
|
||||
sort={{ field: "name", order: "ASC" }}
|
||||
>
|
||||
<Datagrid>
|
||||
<TextField source="room_id" />
|
||||
<TextField source="room_id" sortable={false} />
|
||||
<TextField source="name" />
|
||||
<TextField source="canonical_alias" />
|
||||
<TextField source="joined_members" />
|
||||
<TextField source="joined_local_members" />
|
||||
<TextField source="state_events" />
|
||||
<TextField source="version" />
|
||||
<BooleanField source="is_encrypted" />
|
||||
<BooleanField source="federatable" />
|
||||
<BooleanField source="public" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
|
@ -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: {
|
||||
|
@ -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: {
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user