Add a new tab to user page with media (#87)

* Add a new tab to user page with media
This commit is contained in:
Dirk Klimpel
2021-02-11 21:11:34 +01:00
committed by GitHub
parent 706114a382
commit ea59d0dd02
5 changed files with 103 additions and 2 deletions

View File

@@ -142,6 +142,24 @@ const resourceMap = {
return json.total;
},
},
users_media: {
map: um => ({
...um,
id: um.media_id,
}),
reference: id => ({
endpoint: `/_synapse/admin/v1/users/${id}/media`,
}),
data: "media",
total: json => {
return json.total;
},
delete: params => ({
endpoint: `/_synapse/admin/v1/media/${localStorage.getItem(
"home_server"
)}/${params.id}`,
}),
},
servernotices: {
map: n => ({ id: n.event_id }),
create: data => ({
@@ -239,6 +257,10 @@ const dataProvider = {
console.log("getManyReference " + resource);
const { page, perPage } = params.pagination;
const from = (page - 1) * perPage;
const query = {
from: from,
limit: perPage,
};
const homeserver = localStorage.getItem("base_url");
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
@@ -246,7 +268,7 @@ const dataProvider = {
const res = resourceMap[resource];
const ref = res["reference"](params.id);
const endpoint_url = homeserver + ref.endpoint;
const endpoint_url = `${homeserver}${ref.endpoint}?${stringify(query)}`;
return jsonClient(endpoint_url).then(({ headers, json }) => ({
data: json[res.data].map(res.map),