Add admin API for destinations
This commit is contained in:
parent
abc9d5154e
commit
4c607be4e0
@ -5,7 +5,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.41.0 for all functions to work as expected!
|
It needs at least Synapse v1.49.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://matrix-org.github.io/synapse/develop/admin_api/version_api.html).
|
See also [Synapse version API](https://matrix-org.github.io/synapse/develop/admin_api/version_api.html).
|
||||||
|
10
src/App.js
10
src/App.js
@ -7,12 +7,14 @@ import { UserList, UserCreate, UserEdit } from "./components/users";
|
|||||||
import { RoomList, RoomShow } from "./components/rooms";
|
import { RoomList, RoomShow } from "./components/rooms";
|
||||||
import { ReportList, ReportShow } from "./components/EventReports";
|
import { ReportList, ReportShow } from "./components/EventReports";
|
||||||
import LoginPage from "./components/LoginPage";
|
import LoginPage from "./components/LoginPage";
|
||||||
import UserIcon from "@material-ui/icons/Group";
|
import CloudQueueIcon from "@material-ui/icons/CloudQueue";
|
||||||
import EqualizerIcon from "@material-ui/icons/Equalizer";
|
import EqualizerIcon from "@material-ui/icons/Equalizer";
|
||||||
|
import UserIcon from "@material-ui/icons/Group";
|
||||||
import { UserMediaStatsList } from "./components/statistics";
|
import { UserMediaStatsList } from "./components/statistics";
|
||||||
import RoomIcon from "@material-ui/icons/ViewList";
|
import RoomIcon from "@material-ui/icons/ViewList";
|
||||||
import ReportIcon from "@material-ui/icons/Warning";
|
import ReportIcon from "@material-ui/icons/Warning";
|
||||||
import FolderSharedIcon from "@material-ui/icons/FolderShared";
|
import FolderSharedIcon from "@material-ui/icons/FolderShared";
|
||||||
|
import { DestinationList, DestinationShow } from "./components/destinations";
|
||||||
import { ImportFeature } from "./components/ImportFeature";
|
import { ImportFeature } from "./components/ImportFeature";
|
||||||
import { RoomDirectoryList } from "./components/RoomDirectory";
|
import { RoomDirectoryList } from "./components/RoomDirectory";
|
||||||
import { Route } from "react-router-dom";
|
import { Route } from "react-router-dom";
|
||||||
@ -66,6 +68,12 @@ const App = () => (
|
|||||||
list={RoomDirectoryList}
|
list={RoomDirectoryList}
|
||||||
icon={FolderSharedIcon}
|
icon={FolderSharedIcon}
|
||||||
/>
|
/>
|
||||||
|
<Resource
|
||||||
|
name="destinations"
|
||||||
|
list={DestinationList}
|
||||||
|
show={DestinationShow}
|
||||||
|
icon={CloudQueueIcon}
|
||||||
|
/>
|
||||||
<Resource name="connections" />
|
<Resource name="connections" />
|
||||||
<Resource name="devices" />
|
<Resource name="devices" />
|
||||||
<Resource name="room_members" />
|
<Resource name="room_members" />
|
||||||
|
71
src/components/destinations.js
Normal file
71
src/components/destinations.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import React from "react";
|
||||||
|
import {
|
||||||
|
Datagrid,
|
||||||
|
DateField,
|
||||||
|
Filter,
|
||||||
|
List,
|
||||||
|
Pagination,
|
||||||
|
SearchInput,
|
||||||
|
SimpleShowLayout,
|
||||||
|
Show,
|
||||||
|
TextField,
|
||||||
|
} from "react-admin";
|
||||||
|
|
||||||
|
const DestinationPagination = props => (
|
||||||
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||||
|
);
|
||||||
|
|
||||||
|
const date_format = {
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
};
|
||||||
|
|
||||||
|
const destinationRowStyle = (record, index) => ({
|
||||||
|
backgroundColor: record.retry_last_ts > 0 ? "#ffcccc" : "white",
|
||||||
|
});
|
||||||
|
|
||||||
|
const DestinationFilter = ({ ...props }) => {
|
||||||
|
return (
|
||||||
|
<Filter {...props}>
|
||||||
|
<SearchInput source="destination" alwaysOn />
|
||||||
|
</Filter>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DestinationList = props => {
|
||||||
|
return (
|
||||||
|
<List
|
||||||
|
{...props}
|
||||||
|
filters={<DestinationFilter />}
|
||||||
|
pagination={<DestinationPagination />}
|
||||||
|
sort={{ field: "destination", order: "ASC" }}
|
||||||
|
bulkActionButtons={false}
|
||||||
|
>
|
||||||
|
<Datagrid rowClick="show" rowStyle={destinationRowStyle}>
|
||||||
|
<TextField source="destination" />
|
||||||
|
<DateField source="failure_ts" showTime options={date_format} />
|
||||||
|
<DateField source="retry_last_ts" showTime options={date_format} />
|
||||||
|
<TextField source="retry_interval" />
|
||||||
|
<TextField source="last_successful_stream_ordering" />
|
||||||
|
</Datagrid>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DestinationShow = props => {
|
||||||
|
return (
|
||||||
|
<Show {...props}>
|
||||||
|
<SimpleShowLayout>
|
||||||
|
<TextField source="destination" />
|
||||||
|
<DateField source="failure_ts" showTime options={date_format} />
|
||||||
|
<DateField source="retry_last_ts" showTime options={date_format} />
|
||||||
|
<TextField source="retry_interval" />
|
||||||
|
<TextField source="last_successful_stream_ordering" />
|
||||||
|
</SimpleShowLayout>
|
||||||
|
</Show>
|
||||||
|
);
|
||||||
|
};
|
@ -352,6 +352,16 @@ const de = {
|
|||||||
send_failure: "Beim Entfernen ist ein Fehler aufgetreten.",
|
send_failure: "Beim Entfernen ist ein Fehler aufgetreten.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
destinations: {
|
||||||
|
name: "Föderation",
|
||||||
|
fields: {
|
||||||
|
destination: "Ziel",
|
||||||
|
failure_ts: "Fehlerzeitpunkt",
|
||||||
|
retry_last_ts: "Letzter Wiederholungsversuch",
|
||||||
|
retry_interval: "Wiederholungsintervall",
|
||||||
|
last_successful_stream_ordering: "letzte erfogreicher Stream",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
ra: {
|
ra: {
|
||||||
...germanMessages.ra,
|
...germanMessages.ra,
|
||||||
|
@ -348,6 +348,16 @@ const en = {
|
|||||||
send_failure: "An error has occurred.",
|
send_failure: "An error has occurred.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
destinations: {
|
||||||
|
name: "Federation",
|
||||||
|
fields: {
|
||||||
|
destination: "Destination",
|
||||||
|
failure_ts: "Failure timestamp",
|
||||||
|
retry_last_ts: "Last retry timestamp",
|
||||||
|
retry_interval: "Retry interval",
|
||||||
|
last_successful_stream_ordering: "Last successful stream",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
export default en;
|
export default en;
|
||||||
|
@ -275,6 +275,17 @@ const resourceMap = {
|
|||||||
method: "PUT",
|
method: "PUT",
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
destinations: {
|
||||||
|
path: "/_synapse/admin/v1/federation/destinations",
|
||||||
|
map: dst => ({
|
||||||
|
...dst,
|
||||||
|
id: dst.destination,
|
||||||
|
}),
|
||||||
|
data: "destinations",
|
||||||
|
total: json => {
|
||||||
|
return json.total;
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function filterNullValues(key, value) {
|
function filterNullValues(key, value) {
|
||||||
@ -296,7 +307,8 @@ function getSearchOrder(order) {
|
|||||||
const dataProvider = {
|
const dataProvider = {
|
||||||
getList: (resource, params) => {
|
getList: (resource, params) => {
|
||||||
console.log("getList " + resource);
|
console.log("getList " + resource);
|
||||||
const { user_id, name, guests, deactivated, search_term } = params.filter;
|
const { user_id, name, guests, deactivated, search_term, destination } =
|
||||||
|
params.filter;
|
||||||
const { page, perPage } = params.pagination;
|
const { page, perPage } = params.pagination;
|
||||||
const { field, order } = params.sort;
|
const { field, order } = params.sort;
|
||||||
const from = (page - 1) * perPage;
|
const from = (page - 1) * perPage;
|
||||||
@ -306,6 +318,7 @@ const dataProvider = {
|
|||||||
user_id: user_id,
|
user_id: user_id,
|
||||||
search_term: search_term,
|
search_term: search_term,
|
||||||
name: name,
|
name: name,
|
||||||
|
destination: destination,
|
||||||
guests: guests,
|
guests: guests,
|
||||||
deactivated: deactivated,
|
deactivated: deactivated,
|
||||||
order_by: field,
|
order_by: field,
|
||||||
|
Loading…
Reference in New Issue
Block a user