Allow searching for users
Change-Id: Icf4a3b05b24c66971f55b22e7540a1dc904a3a92
This commit is contained in:
parent
d2a3f07a59
commit
7aec6f9369
@ -12,6 +12,7 @@ import {
|
|||||||
PasswordInput,
|
PasswordInput,
|
||||||
TextField,
|
TextField,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
SearchInput,
|
||||||
ReferenceField,
|
ReferenceField,
|
||||||
SaveButton,
|
SaveButton,
|
||||||
Toolbar,
|
Toolbar,
|
||||||
@ -21,6 +22,7 @@ import SaveQrButton from "./SaveQrButton";
|
|||||||
|
|
||||||
const UserFilter = props => (
|
const UserFilter = props => (
|
||||||
<Filter {...props}>
|
<Filter {...props}>
|
||||||
|
<SearchInput source="q" alwaysOn />
|
||||||
<BooleanInput source="guests" alwaysOn />
|
<BooleanInput source="guests" alwaysOn />
|
||||||
<BooleanInput
|
<BooleanInput
|
||||||
label="resources.users.fields.show_deactivated"
|
label="resources.users.fields.show_deactivated"
|
||||||
|
@ -70,6 +70,25 @@ const dataProvider = {
|
|||||||
const homeserver_url = "https://" + homeserver + res.path;
|
const homeserver_url = "https://" + homeserver + res.path;
|
||||||
const url = `${homeserver_url}?${stringify(query)}`;
|
const url = `${homeserver_url}?${stringify(query)}`;
|
||||||
|
|
||||||
|
// searching for users is not implemented in admin api
|
||||||
|
if (params.filter.q) {
|
||||||
|
console.log("searching");
|
||||||
|
const search_query = { limit: perPage, search_term: params.filter.q };
|
||||||
|
const search_url =
|
||||||
|
homeserver + `/_matrix/client/r0/user_directory/search`;
|
||||||
|
return jsonClient(search_url, {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify(search_query),
|
||||||
|
}).then(({ json }) => ({
|
||||||
|
data: json["results"].map(u => ({
|
||||||
|
...u,
|
||||||
|
id: u.user_id,
|
||||||
|
name: u.user_id,
|
||||||
|
})),
|
||||||
|
total: json.limited ? perPage * 2 : json.results.length,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
return jsonClient(url).then(({ json }) => ({
|
return jsonClient(url).then(({ json }) => ({
|
||||||
data: json[res.data].map(res.map),
|
data: json[res.data].map(res.map),
|
||||||
total: res.total(json, perPage),
|
total: res.total(json, perPage),
|
||||||
|
Loading…
Reference in New Issue
Block a user