Enable sorting in tab of users' media (#138)

This commit is contained in:
Manuel Stahl 2021-05-04 16:18:12 +02:00
parent 57c41cc069
commit 41ce58bac8
3 changed files with 11 additions and 9 deletions

View file

@ -4,7 +4,7 @@
This project is built using [react-admin](https://marmelab.com/react-admin/). This project is built using [react-admin](https://marmelab.com/react-admin/).
It needs at least Synapse v1.27.0 for all functions to work as expected! It needs at least Synapse v1.29.0 for all functions to work as expected!
You get your server version with the request `/_synapse/admin/v1/server_version`. 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). See also [Synapse version API](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/version_api.rst).

View file

@ -420,6 +420,7 @@ export const UserEdit = props => {
addLabel={false} addLabel={false}
pagination={<UserPagination />} pagination={<UserPagination />}
perPage={50} perPage={50}
sort={{ field: "created_ts", order: "DESC" }}
> >
<Datagrid style={{ width: "100%" }}> <Datagrid style={{ width: "100%" }}>
<DateField <DateField
@ -433,7 +434,6 @@ export const UserEdit = props => {
minute: "2-digit", minute: "2-digit",
second: "2-digit", second: "2-digit",
}} }}
sortable={false}
/> />
<DateField <DateField
source="last_access_ts" source="last_access_ts"
@ -446,14 +446,13 @@ export const UserEdit = props => {
minute: "2-digit", minute: "2-digit",
second: "2-digit", second: "2-digit",
}} }}
sortable={false}
/> />
<TextField source="media_id" sortable={false} /> <TextField source="media_id" />
<NumberField source="media_length" sortable={false} /> <NumberField source="media_length" />
<TextField source="media_type" sortable={false} /> <TextField source="media_type" />
<TextField source="upload_name" sortable={false} /> <TextField source="upload_name" />
<TextField source="quarantined_by" sortable={false} /> <TextField source="quarantined_by" />
<BooleanField source="safe_from_quarantine" sortable={false} /> <BooleanField source="safe_from_quarantine" />
<DeleteButton mutationMode="pessimistic" redirect={false} /> <DeleteButton mutationMode="pessimistic" redirect={false} />
</Datagrid> </Datagrid>
</ReferenceManyField> </ReferenceManyField>

View file

@ -314,10 +314,13 @@ const dataProvider = {
getManyReference: (resource, params) => { getManyReference: (resource, params) => {
console.log("getManyReference " + resource); console.log("getManyReference " + resource);
const { page, perPage } = params.pagination; const { page, perPage } = params.pagination;
const { field, order } = params.sort;
const from = (page - 1) * perPage; const from = (page - 1) * perPage;
const query = { const query = {
from: from, from: from,
limit: perPage, limit: perPage,
order_by: field,
dir: getSearchOrder(order),
}; };
const homeserver = localStorage.getItem("base_url"); const homeserver = localStorage.getItem("base_url");