Add SearchInput to users and rooms
Add filter to search in `user_id` and room name.
This commit is contained in:
parent
0ada5287d7
commit
a9477c6d97
@ -1,12 +1,25 @@
|
||||
import React from "react";
|
||||
import { Datagrid, List, TextField, Pagination } from "react-admin";
|
||||
import {
|
||||
Datagrid,
|
||||
List,
|
||||
TextField,
|
||||
Pagination,
|
||||
Filter,
|
||||
SearchInput,
|
||||
} from "react-admin";
|
||||
|
||||
const RoomPagination = props => (
|
||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||
);
|
||||
|
||||
const RoomFilter = props => (
|
||||
<Filter {...props}>
|
||||
<SearchInput source="search_term" alwaysOn />
|
||||
</Filter>
|
||||
);
|
||||
|
||||
export const RoomList = props => (
|
||||
<List {...props} pagination={<RoomPagination />}>
|
||||
<List {...props} pagination={<RoomPagination />} filters={<RoomFilter />}>
|
||||
<Datagrid>
|
||||
<TextField source="room_id" />
|
||||
<TextField source="name" />
|
||||
|
@ -29,6 +29,7 @@ import {
|
||||
regex,
|
||||
useTranslate,
|
||||
Pagination,
|
||||
SearchInput,
|
||||
} from "react-admin";
|
||||
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
|
||||
|
||||
@ -38,6 +39,7 @@ const UserPagination = props => (
|
||||
|
||||
const UserFilter = props => (
|
||||
<Filter {...props}>
|
||||
<SearchInput source="user_id" alwaysOn />
|
||||
<BooleanInput source="guests" alwaysOn />
|
||||
<BooleanInput
|
||||
label="resources.users.fields.show_deactivated"
|
||||
|
@ -86,18 +86,27 @@ function filterNullValues(key, value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function getEncodeURI(value) {
|
||||
// encodeURI if 'value' is set
|
||||
if (value) {
|
||||
return encodeURI(value);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const dataProvider = {
|
||||
getList: (resource, params) => {
|
||||
console.log("getList " + resource);
|
||||
const { user_id, guests, deactivated } = params.filter;
|
||||
const { user_id, guests, deactivated, search_term } = params.filter;
|
||||
const { page, perPage } = params.pagination;
|
||||
const from = (page - 1) * perPage;
|
||||
const query = {
|
||||
from: from,
|
||||
limit: perPage,
|
||||
user_id: user_id,
|
||||
user_id: getEncodeURI(user_id),
|
||||
guests: guests,
|
||||
deactivated: deactivated,
|
||||
search_term: getEncodeURI(search_term),
|
||||
};
|
||||
const homeserver = localStorage.getItem("base_url");
|
||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||
|
Loading…
Reference in New Issue
Block a user