Merge tag '0.4.1' into amp.chat

Change-Id: I44c9f00e5aa7abe413f8a819e1143bebc4f08ce2
This commit is contained in:
Manuel Stahl 2020-07-23 08:48:16 +02:00
commit 2915fd3e5b
12 changed files with 1979 additions and 1355 deletions

View File

@ -4,6 +4,28 @@
This project is built using [react-admin](https://marmelab.com/react-admin/). This project is built using [react-admin](https://marmelab.com/react-admin/).
Use `yarn install` after cloning this repo. It needs at least Synapse v1.14.0 for all functions to work as expected!
Use `yarn start` to launch the webserver. ## Step-By-Step install:
You have two options:
1. Download the source code from github and run using nodejs
2. Run the Docker container
Steps for 1):
- make sure you have installed the following: git, yarn, nodejs
- download the source code: `git clone https://github.com/Awesome-Technologies/synapse-admin.git`
- change into downloaded directory: `cd synapse-admin`
- download dependencies: `yarn install`
- start web server: `yarn start`
Steps for 2):
- run the Docker container: `docker run -p 8080:80 awesometechnologies/synapse-admin`
- browse to http://localhost:8080
## Screenshots
![Screenshots](./screenshots.jpg)

View File

@ -1,6 +1,6 @@
{ {
"name": "synapse-admin", "name": "synapse-admin",
"version": "0.1.0", "version": "AMP/2020.07",
"description": "Admin GUI for the Matrix.org server Synapse", "description": "Admin GUI for the Matrix.org server Synapse",
"author": "Awesome Technologies Innovationslabor GmbH", "author": "Awesome Technologies Innovationslabor GmbH",
"license": "Apache-2.0", "license": "Apache-2.0",
@ -12,7 +12,7 @@
"devDependencies": { "devDependencies": {
"@testing-library/jest-dom": "^5.1.1", "@testing-library/jest-dom": "^5.1.1",
"@testing-library/react": "^10.0.2", "@testing-library/react": "^10.0.2",
"@testing-library/user-event": "^10.0.1", "@testing-library/user-event": "^12.0.11",
"enzyme": "^3.11.0", "enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2", "enzyme-adapter-react-16": "^1.15.2",
"eslint": "^6.8.0", "eslint": "^6.8.0",
@ -23,17 +23,18 @@
"dependencies": { "dependencies": {
"@progress/kendo-drawing": "^1.6.0", "@progress/kendo-drawing": "^1.6.0",
"@progress/kendo-react-pdf": "^3.10.1", "@progress/kendo-react-pdf": "^3.10.1",
"babel-preset-jest": "^24.9.0",
"prop-types": "^15.7.2", "prop-types": "^15.7.2",
"qrcode.react": "^1.0.0", "qrcode.react": "^1.0.0",
"ra-language-german": "^2.1.2", "ra-language-german": "^2.1.2",
"react": "^16.13.1", "react": "^16.13.1",
"react-admin": "^3.4.0", "react-admin": "^3.7.0",
"react-dom": "^16.13.1", "react-dom": "^16.13.1",
"react-scripts": "^3.4.1" "react-scripts": "^3.4.1"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "REACT_APP_VERSION=$(git describe --tags) react-scripts start",
"build": "react-scripts build", "build": "REACT_APP_VERSION=$(git describe --tags) react-scripts build",
"fix:other": "yarn prettier --write", "fix:other": "yarn prettier --write",
"fix:code": "yarn test:lint --fix", "fix:code": "yarn test:lint --fix",
"fix": "yarn fix:code && yarn fix:other", "fix": "yarn fix:code && yarn fix:other",

View File

@ -38,5 +38,12 @@
To begin the development, run `npm start` or `yarn start`. To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`. To create a production bundle, use `npm run build` or `yarn build`.
--> -->
<footer
style="position: relative; z-index: 2; height: 2em; margin-top: -2em; line-height: 2em; background-color: #eee; border: 0.5px solid #ddd">
<a id="copyright" href="https://github.com/Awesome-Technologies/synapse-admin"
style="margin-left: 1em; color: #888; font-family: Roboto, Helvetica, Arial, sans-serif; font-weight: 100; font-size: 0.8em; text-decoration: none;">
Synapse-Admin <b>(%REACT_APP_VERSION%)</b> by Awesome Technologies Innovationslabor GmbH
</a>
</footer>
</body> </body>
</html> </html>

BIN
screenshots.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

View File

@ -1,4 +1,4 @@
import React, { useState } from "react"; import React, { useState, useEffect } from "react";
import { import {
fetchUtils, fetchUtils,
FormDataConsumer, FormDataConsumer,
@ -29,7 +29,7 @@ const useStyles = makeStyles(theme => ({
main: { main: {
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
minHeight: "100vh", minHeight: "calc(100vh - 1em)",
alignItems: "center", alignItems: "center",
justifyContent: "flex-start", justifyContent: "flex-start",
background: "url(./images/floating-cogs.svg)", background: "url(./images/floating-cogs.svg)",
@ -40,6 +40,7 @@ const useStyles = makeStyles(theme => ({
card: { card: {
minWidth: "30em", minWidth: "30em",
marginTop: "6em", marginTop: "6em",
marginBottom: "6em",
}, },
avatar: { avatar: {
margin: "1em", margin: "1em",
@ -64,6 +65,12 @@ const useStyles = makeStyles(theme => ({
actions: { actions: {
padding: "0 1em 1em 1em", padding: "0 1em 1em 1em",
}, },
serverVersion: {
color: "#9e9e9e",
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
marginBottom: "1em",
marginLeft: "0.5em",
},
})); }));
const LoginPage = ({ theme }) => { const LoginPage = ({ theme }) => {
@ -137,6 +144,7 @@ const LoginPage = ({ theme }) => {
const UserData = ({ formData }) => { const UserData = ({ formData }) => {
const form = useForm(); const form = useForm();
const [serverVersion, setServerVersion] = useState("");
const handleUsernameChange = _ => { const handleUsernameChange = _ => {
if (formData.base_url) return; if (formData.base_url) return;
@ -157,6 +165,30 @@ const LoginPage = ({ theme }) => {
} }
}; };
useEffect(
_ => {
if (
!formData.base_url ||
!formData.base_url.match(/^(http|https):\/\/[a-zA-Z0-9\-.]+$/)
)
return;
const versionUrl = `${formData.base_url}/_synapse/admin/v1/server_version`;
fetchUtils
.fetchJson(versionUrl, { method: "GET" })
.then(({ json }) => {
setServerVersion(
`${translate("synapseadmin.auth.server_version")} ${
json["server_version"]
}`
);
})
.catch(_ => {
setServerVersion("");
});
},
[formData.base_url]
);
return ( return (
<div> <div>
<div className={classes.input}> <div className={classes.input}>
@ -189,6 +221,7 @@ const LoginPage = ({ theme }) => {
fullWidth fullWidth
/> />
</div> </div>
<div className={classes.serverVersion}>{serverVersion}</div>
</div> </div>
); );
}; };

View File

@ -7,8 +7,10 @@ import {
Toolbar, Toolbar,
required, required,
useCreate, useCreate,
useMutation,
useNotify, useNotify,
useTranslate, useTranslate,
useUnselectAll,
} from "react-admin"; } from "react-admin";
import MessageIcon from "@material-ui/icons/Message"; import MessageIcon from "@material-ui/icons/Message";
import IconCancel from "@material-ui/icons/Cancel"; import IconCancel from "@material-ui/icons/Cancel";
@ -98,3 +100,49 @@ export const ServerNoticeButton = ({ record }) => {
</Fragment> </Fragment>
); );
}; };
export const ServerNoticeBulkButton = ({ selectedIds }) => {
const [open, setOpen] = useState(false);
const notify = useNotify();
const unselectAll = useUnselectAll();
const [createMany, { loading }] = useMutation();
const handleDialogOpen = () => setOpen(true);
const handleDialogClose = () => setOpen(false);
const handleSend = values => {
createMany(
{
type: "createMany",
resource: "servernotices",
payload: { ids: selectedIds, data: values },
},
{
onSuccess: ({ data }) => {
notify("resources.servernotices.action.send_success");
unselectAll("users");
handleDialogClose();
},
onFailure: error =>
notify("resources.servernotices.action.send_failure", "error"),
}
);
};
return (
<Fragment>
<Button
label="resources.servernotices.send"
onClick={handleDialogOpen}
disabled={loading}
>
<MessageIcon />
</Button>
<ServerNoticeDialog
open={open}
onClose={handleDialogClose}
onSend={handleSend}
/>
</Fragment>
);
};

View File

@ -1,13 +1,15 @@
import React from "react"; import React from "react";
import { connect } from "react-redux";
import { import {
AutocompleteArrayInput, AutocompleteArrayInput,
BooleanInput, BooleanInput,
BooleanField,
Create, Create,
Datagrid, Datagrid,
Filter,
FormTab, FormTab,
List, List,
Pagination, Pagination,
ReferenceArrayField,
ReferenceArrayInput, ReferenceArrayInput,
SelectField, SelectField,
Show, Show,
@ -18,23 +20,44 @@ import {
TextInput, TextInput,
useTranslate, useTranslate,
} from "react-admin"; } from "react-admin";
import ViewListIcon from "@material-ui/icons/ViewList"; import get from "lodash/get";
import { Tooltip, Typography, Chip } from "@material-ui/core";
import HttpsIcon from "@material-ui/icons/Https";
import NoEncryptionIcon from "@material-ui/icons/NoEncryption";
import PageviewIcon from "@material-ui/icons/Pageview";
import UserIcon from "@material-ui/icons/Group"; import UserIcon from "@material-ui/icons/Group";
import ViewListIcon from "@material-ui/icons/ViewList";
import VisibilityIcon from "@material-ui/icons/Visibility";
const RoomPagination = props => ( const RoomPagination = props => (
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} /> <Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
); );
export const RoomList = props => ( const EncryptionField = ({ source, record = {}, emptyText }) => {
<List {...props} pagination={<RoomPagination />}> const translate = useTranslate();
<Datagrid rowClick="show"> const value = get(record, source);
<TextField source="room_id" /> let ariaLabel = value === false ? "ra.boolean.false" : "ra.boolean.true";
<TextField source="name" />
<TextField source="canonical_alias" /> if (value === false || value === true) {
<TextField source="joined_members" /> return (
</Datagrid> <Typography component="span" variant="body2">
</List> <Tooltip title={translate(ariaLabel, { _: ariaLabel })}>
); {value === true ? (
<HttpsIcon data-testid="true" htmlColor="limegreen" />
) : (
<NoEncryptionIcon data-testid="false" color="error" />
)}
</Tooltip>
</Typography>
);
}
return (
<Typography component="span" variant="body2">
{emptyText}
</Typography>
);
};
const validateDisplayName = fieldval => const validateDisplayName = fieldval =>
fieldval === undefined fieldval === undefined
@ -117,7 +140,11 @@ export const RoomCreate = props => (
placeholder="#" placeholder="#"
/> />
<BooleanInput source="public" label="synapseadmin.rooms.make_public" /> <BooleanInput source="public" label="synapseadmin.rooms.make_public" />
<BooleanInput source="encrypt" initialValue={true} label="synapseadmin.rooms.encrypt" /> <BooleanInput
source="encrypt"
initialValue={true}
label="synapseadmin.rooms.encrypt"
/>
</FormTab> </FormTab>
<FormTab <FormTab
label="resources.rooms.fields.invite_members" label="resources.rooms.fields.invite_members"
@ -147,39 +174,160 @@ const RoomTitle = ({ record }) => {
); );
}; };
export const RoomShow = props => ( export const RoomShow = props => {
const translate = useTranslate();
return (
<Show {...props} title={<RoomTitle />}> <Show {...props} title={<RoomTitle />}>
<TabbedShowLayout> <TabbedShowLayout>
<Tab label="synapseadmin.rooms.details" icon={<ViewListIcon />}> <Tab label="synapseadmin.rooms.tabs.basic" icon={<ViewListIcon />}>
<TextField source="id" disabled /> <TextField source="room_id" />
<TextField source="name" /> <TextField source="name" />
<TextField source="canonical_alias" /> <TextField source="canonical_alias" />
<TextField source="creator" />
</Tab>
<Tab
label="synapseadmin.rooms.tabs.detail"
icon={<PageviewIcon />}
path="detail"
>
<TextField source="joined_members" />
<TextField source="joined_local_members" />
<TextField source="state_events" />
<TextField source="version" />
<TextField
source="encryption"
emptyText={translate("resources.rooms.enums.unencrypted")}
/>
</Tab>
<Tab
label="synapseadmin.rooms.tabs.permission"
icon={<VisibilityIcon />}
path="permission"
>
<BooleanField source="federatable" />
<BooleanField source="public" />
<SelectField <SelectField
source="join_rules" source="join_rules"
choices={[ choices={[
{ id: 'public', name: 'resources.rooms.enums.join_rules.public' }, { id: "public", name: "resources.rooms.enums.join_rules.public" },
{ id: 'knock', name: 'resources.rooms.enums.join_rules.knock' }, { id: "knock", name: "resources.rooms.enums.join_rules.knock" },
{ id: 'invite', name: 'resources.rooms.enums.join_rules.invite' }, { id: "invite", name: "resources.rooms.enums.join_rules.invite" },
{ id: 'private', name: 'resources.rooms.enums.join_rules.private' }, {
id: "private",
name: "resources.rooms.enums.join_rules.private",
},
]} ]}
/> />
<SelectField <SelectField
source="guest_access" source="guest_access"
choices={[ choices={[
{ id: 'can_join', name: 'resources.rooms.enums.guest_access.can_join' }, {
{ id: 'forbidden', name: 'resources.rooms.enums.guest_access.forbidden' }, id: "can_join",
name: "resources.rooms.enums.guest_access.can_join",
},
{
id: "forbidden",
name: "resources.rooms.enums.guest_access.forbidden",
},
]}
/>
<SelectField
source="history_visibility"
choices={[
{
id: "invited",
name: "resources.rooms.enums.history_visibility.invited",
},
{
id: "joined",
name: "resources.rooms.enums.history_visibility.joined",
},
{
id: "shared",
name: "resources.rooms.enums.history_visibility.shared",
},
{
id: "world_readable",
name: "resources.rooms.enums.history_visibility.world_readable",
},
]} ]}
/> />
</Tab> </Tab>
<Tab label="resources.rooms.fields.joined_members" icon={<UserIcon />}>
<ReferenceArrayField reference="users" source="members">
<Datagrid>
<TextField source="id" />
<TextField source="displayname" />
<TextField source="power_level" />
</Datagrid>
</ReferenceArrayField>
</Tab>
</TabbedShowLayout> </TabbedShowLayout>
</Show> </Show>
); );
};
const RoomFilter = ({ ...props }) => {
const translate = useTranslate();
return (
<Filter {...props}>
<Chip
label={translate("resources.rooms.fields.joined_local_members")}
source="joined_local_members"
defaultValue={false}
style={{ marginBottom: 8 }}
/>
<Chip
label={translate("resources.rooms.fields.state_events")}
source="state_events"
defaultValue={false}
style={{ marginBottom: 8 }}
/>
<Chip
label={translate("resources.rooms.fields.version")}
source="version"
defaultValue={false}
style={{ marginBottom: 8 }}
/>
<Chip
label={translate("resources.rooms.fields.federatable")}
source="federatable"
defaultValue={false}
style={{ marginBottom: 8 }}
/>
</Filter>
);
};
const FilterableRoomList = ({ ...props }) => {
const filter = props.roomFilters;
const localMembersFilter =
filter && filter.joined_local_members ? true : false;
const stateEventsFilter = filter && filter.state_events ? true : false;
const versionFilter = filter && filter.version ? true : false;
const federateableFilter = filter && filter.federatable ? true : false;
return (
<List
{...props}
pagination={<RoomPagination />}
sort={{ field: "name", order: "ASC" }}
filters={<RoomFilter />}
>
<Datagrid rowClick="show">
<EncryptionField
source="is_encrypted"
sortBy="encryption"
label={<HttpsIcon />}
/>
<TextField source="name" />
<TextField source="joined_members" />
{localMembersFilter && <TextField source="joined_local_members" />}
{stateEventsFilter && <TextField source="state_events" />}
{versionFilter && <TextField source="version" />}
{federateableFilter && <BooleanField source="federatable" />}
<BooleanField source="public" />
</Datagrid>
</List>
);
};
function mapStateToProps(state) {
return {
roomFilters: state.admin.resources.rooms.list.params.displayedFilters,
};
}
export const RoomList = connect(mapStateToProps)(FilterableRoomList);

View File

@ -1,5 +1,7 @@
import React, { Fragment } from "react"; import React, { cloneElement, Fragment } from "react";
import Avatar from "@material-ui/core/Avatar";
import PersonPinIcon from "@material-ui/icons/PersonPin"; import PersonPinIcon from "@material-ui/icons/PersonPin";
import ContactMailIcon from "@material-ui/icons/ContactMail";
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent"; import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
import { import {
ArrayInput, ArrayInput,
@ -17,7 +19,6 @@ import {
FormTab, FormTab,
BooleanField, BooleanField,
BooleanInput, BooleanInput,
ImageField,
PasswordInput, PasswordInput,
TextField, TextField,
TextInput, TextInput,
@ -30,9 +31,65 @@ import {
regex, regex,
useTranslate, useTranslate,
Pagination, Pagination,
CreateButton,
ExportButton,
TopToolbar,
sanitizeListRestProps,
} from "react-admin"; } from "react-admin";
import SaveQrButton from "./SaveQrButton"; import SaveQrButton from "./SaveQrButton";
import { ServerNoticeButton } from "./ServerNotices"; import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles({
small: {
height: "40px",
width: "40px",
},
large: {
height: "120px",
width: "120px",
float: "right",
},
});
const UserListActions = ({
currentSort,
className,
resource,
filters,
displayedFilters,
exporter, // you can hide ExportButton if exporter = (null || false)
filterValues,
permanentFilter,
hasCreate, // you can hide CreateButton if hasCreate = false
basePath,
selectedIds,
onUnselectItems,
showFilter,
maxResults,
total,
...rest
}) => (
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
{filters &&
cloneElement(filters, {
resource,
showFilter,
displayedFilters,
filterValues,
context: "button",
})}
<CreateButton basePath={basePath} />
<ExportButton
disabled={total === 0}
resource={resource}
sort={currentSort}
filter={{ ...filterValues, ...permanentFilter }}
exporter={exporter}
maxResults={maxResults}
/>
</TopToolbar>
);
const UserPagination = props => ( const UserPagination = props => (
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} /> <Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
@ -54,6 +111,7 @@ const UserBulkActionButtons = props => {
const translate = useTranslate(); const translate = useTranslate();
return ( return (
<Fragment> <Fragment>
<ServerNoticeBulkButton {...props} />
<BulkDeleteButton <BulkDeleteButton
{...props} {...props}
label="resources.users.action.erase" label="resources.users.action.erase"
@ -63,16 +121,27 @@ const UserBulkActionButtons = props => {
); );
}; };
export const UserList = props => ( const AvatarField = ({ source, className, record = {} }) => (
<Avatar src={record[source]} className={className} />
);
export const UserList = props => {
const classes = useStyles();
return (
<List <List
{...props} {...props}
filters={<UserFilter />} filters={<UserFilter />}
filterDefaultValues={{ guests: true, deactivated: false }} filterDefaultValues={{ guests: true, deactivated: false }}
actions={<UserListActions maxResults={10000} />}
bulkActionButtons={<UserBulkActionButtons />} bulkActionButtons={<UserBulkActionButtons />}
pagination={<UserPagination />} pagination={<UserPagination />}
> >
<Datagrid rowClick="edit"> <Datagrid rowClick="edit">
<ImageField source="avatar_url" title="displayname" /> <AvatarField
source="avatar_src"
sortable={false}
className={classes.small}
/>
<TextField source="id" sortable={false} /> <TextField source="id" sortable={false} />
<TextField source="displayname" /> <TextField source="displayname" />
<BooleanField source="is_guest" sortable={false} /> <BooleanField source="is_guest" sortable={false} />
@ -80,7 +149,8 @@ export const UserList = props => (
<BooleanField source="deactivated" sortable={false} /> <BooleanField source="deactivated" sortable={false} />
</Datagrid> </Datagrid>
</List> </List>
); );
};
function generateRandomUser() { function generateRandomUser() {
const homeserver = localStorage.getItem("home_server"); const homeserver = localStorage.getItem("home_server");
@ -208,15 +278,25 @@ const UserTitle = ({ record }) => {
const translate = useTranslate(); const translate = useTranslate();
return ( return (
<span> <span>
{translate("resources.users.name")}{" "} {translate("resources.users.name", {
smart_count: 1,
})}{" "}
{record ? `"${record.displayname}"` : ""} {record ? `"${record.displayname}"` : ""}
</span> </span>
); );
}; };
export const UserEdit = props => (
export const UserEdit = props => {
const classes = useStyles();
return (
<Edit {...props} title={<UserTitle />}> <Edit {...props} title={<UserTitle />}>
<TabbedForm toolbar={<UserEditToolbar />}> <TabbedForm toolbar={<UserEditToolbar />}>
<FormTab label="resources.users.name" icon={<PersonPinIcon />}> <FormTab label="resources.users.name" icon={<PersonPinIcon />}>
<AvatarField
source="avatar_src"
sortable={false}
className={classes.large}
/>
<TextInput source="id" disabled /> <TextInput source="id" disabled />
<TextInput source="displayname" /> <TextInput source="displayname" />
<PasswordInput source="password" autoComplete="new-password" /> <PasswordInput source="password" autoComplete="new-password" />
@ -225,6 +305,25 @@ export const UserEdit = props => (
source="deactivated" source="deactivated"
helperText="resources.users.helper.deactivate" helperText="resources.users.helper.deactivate"
/> />
<DateField
source="creation_ts_ms"
showTime
options={{
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
}}
/>
<TextField source="consent_version" />
</FormTab>
<FormTab
label="resources.users.threepid"
icon={<ContactMailIcon />}
path="threepid"
>
<ArrayInput source="threepids"> <ArrayInput source="threepids">
<SimpleFormIterator> <SimpleFormIterator>
<SelectInput <SelectInput
@ -241,8 +340,14 @@ export const UserEdit = props => (
<FormTab <FormTab
label="resources.connections.name" label="resources.connections.name"
icon={<SettingsInputComponentIcon />} icon={<SettingsInputComponentIcon />}
path="connections"
>
<ReferenceField
reference="connections"
source="id"
addLabel={false}
link={false}
> >
<ReferenceField reference="connections" source="id" addLabel={false}>
<ArrayField <ArrayField
source="devices[].sessions[0].connections" source="devices[].sessions[0].connections"
label="resources.connections.name" label="resources.connections.name"
@ -273,4 +378,5 @@ export const UserEdit = props => (
</FormTab> </FormTab>
</TabbedForm> </TabbedForm>
</Edit> </Edit>
); );
};

View File

@ -6,6 +6,7 @@ export default {
auth: { auth: {
base_url: "Heimserver URL", base_url: "Heimserver URL",
welcome: "Willkommen bei Synapse-admin", welcome: "Willkommen bei Synapse-admin",
server_version: "Synapse Version",
username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'", username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'",
protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen", protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen",
url_error: "Keine gültige Matrix Server URL", url_error: "Keine gültige Matrix Server URL",
@ -29,6 +30,12 @@ export default {
alias: "Alias", alias: "Alias",
alias_too_long: alias_too_long:
"Darf zusammen mit der Domain des Homeservers 255 bytes nicht überschreiten", "Darf zusammen mit der Domain des Homeservers 255 bytes nicht überschreiten",
tabs: {
basic: "Allgemein",
members: "Mitglieder",
detail: "Details",
permission: "Berechtigungen",
},
}, },
}, },
resources: { resources: {
@ -37,6 +44,7 @@ export default {
name: "Benutzer", name: "Benutzer",
email: "E-Mail", email: "E-Mail",
msisdn: "Telefon", msisdn: "Telefon",
threepid: "E-Mail / Telefon",
fields: { fields: {
avatar: "Avatar", avatar: "Avatar",
id: "Benutzer-ID", id: "Benutzer-ID",
@ -50,9 +58,12 @@ export default {
displayname: "Anzeigename", displayname: "Anzeigename",
password: "Passwort", password: "Passwort",
avatar_url: "Avatar URL", avatar_url: "Avatar URL",
avatar_src: "Avatar",
medium: "Medium", medium: "Medium",
threepids: "3PIDs", threepids: "3PIDs",
address: "Adresse", address: "Adresse",
creation_ts_ms: "Zeitpunkt der Erstellung",
consent_version: "Zugestimmte Geschäftsbedingungen",
}, },
helper: { helper: {
deactivate: "Deaktivierte Nutzer können nicht wieder aktiviert werden.", deactivate: "Deaktivierte Nutzer können nicht wieder aktiviert werden.",
@ -71,9 +82,17 @@ export default {
joined_members: "Mitglieder", joined_members: "Mitglieder",
invite_members: "Mitglieder einladen", invite_members: "Mitglieder einladen",
invitees: "Einladungen", invitees: "Einladungen",
guest_access: "Gastzugang", joined_local_members: "Lokale Mitglieder",
join_rules: "Zugang zum Raum", state_events: "Ereignisse",
members: "Mitglieder", version: "Version",
is_encrypted: "Verschlüsselt",
encryption: "Verschlüsselungs-Algorithmus",
federatable: "Fö­de­rierbar",
public: "Öffentlich",
creator: "Ersteller",
join_rules: "Beitrittsregeln",
guest_access: "Gastzugriff",
history_visibility: "Historie-Sichtbarkeit",
}, },
enums: { enums: {
join_rules: { join_rules: {
@ -84,8 +103,15 @@ export default {
}, },
guest_access: { guest_access: {
can_join: "Gäste können beitreten", can_join: "Gäste können beitreten",
forbidden: "Gäste können nicht beitreten" forbidden: "Gäste können nicht beitreten",
}, },
history_visibility: {
invited: "Ab Einladung",
joined: "Ab Beitritt",
shared: "Ab Setzen der Einstellung",
world_readable: "Jeder",
},
unencrypted: "Nicht verschlüsselt",
}, },
}, },
connections: { connections: {
@ -132,15 +158,4 @@ export default {
logged_out: "Abgemeldet", logged_out: "Abgemeldet",
}, },
}, },
ra: {
...germanMessages.ra,
input: {
...germanMessages.ra.input,
password: {
...germanMessages.ra.input.password,
toggle_hidden: "Anzeigen",
toggle_visible: "Verstecken",
},
},
},
}; };

View File

@ -6,6 +6,7 @@ export default {
auth: { auth: {
base_url: "Homeserver URL", base_url: "Homeserver URL",
welcome: "Welcome to Synapse-admin", welcome: "Welcome to Synapse-admin",
server_version: "Synapse version",
username_error: "Please enter fully qualified user ID: '@user:domain'", username_error: "Please enter fully qualified user ID: '@user:domain'",
protocol_error: "URL has to start with 'http://' or 'https://'", protocol_error: "URL has to start with 'http://' or 'https://'",
url_error: "Not a valid Matrix server URL", url_error: "Not a valid Matrix server URL",
@ -29,6 +30,12 @@ export default {
alias: "Alias", alias: "Alias",
alias_too_long: alias_too_long:
"Must not exceed 255 bytes including the domain of the homeserver.", "Must not exceed 255 bytes including the domain of the homeserver.",
tabs: {
basic: "Basic",
members: "Members",
detail: "Details",
permission: "Permissions",
},
}, },
}, },
resources: { resources: {
@ -37,6 +44,7 @@ export default {
name: "User |||| Users", name: "User |||| Users",
email: "Email", email: "Email",
msisdn: "Phone", msisdn: "Phone",
threepid: "Email / Phone",
fields: { fields: {
avatar: "Avatar", avatar: "Avatar",
id: "User-ID", id: "User-ID",
@ -50,9 +58,12 @@ export default {
displayname: "Displayname", displayname: "Displayname",
password: "Password", password: "Password",
avatar_url: "Avatar URL", avatar_url: "Avatar URL",
avatar_src: "Avatar",
medium: "Medium", medium: "Medium",
threepids: "3PIDs", threepids: "3PIDs",
address: "Address", address: "Address",
creation_ts_ms: "Creation timestamp",
consent_version: "Consent version",
}, },
helper: { helper: {
deactivate: "Deactivated users cannot be reactivated", deactivate: "Deactivated users cannot be reactivated",
@ -70,8 +81,18 @@ export default {
canonical_alias: "Alias", canonical_alias: "Alias",
joined_members: "Members", joined_members: "Members",
invite_members: "Invite Members", invite_members: "Invite Members",
invitees: "Invitations", invitees: "Invitations",
joined_local_members: "local members",
state_events: "State events",
version: "Version",
is_encrypted: "Encrypted",
encryption: "Encryption",
federatable: "Federatable",
public: "Public",
creator: "Creator",
join_rules: "Join rules",
guest_access: "Guest access",
history_visibility: "History visibility",
}, },
enums: { enums: {
join_rules: { join_rules: {
@ -82,8 +103,15 @@ export default {
}, },
guest_access: { guest_access: {
can_join: "Guests can join", can_join: "Guests can join",
forbidden: "Guests can not join" forbidden: "Guests can not join",
}, },
history_visibility: {
invited: "Since invited",
joined: "Since joined",
shared: "Since shared",
world_readable: "Anyone",
},
unencrypted: "Unencrypted",
}, },
}, },
connections: { connections: {

View File

@ -14,16 +14,30 @@ const jsonClient = (url, options = {}) => {
return fetchUtils.fetchJson(url, options); return fetchUtils.fetchJson(url, options);
}; };
const mxcUrlToHttp = mxcUrl => {
const homeserver = localStorage.getItem("base_url");
const re = /^mxc:\/\/([^/]+)\/(\w+)/;
var ret = re.exec(mxcUrl);
console.log("mxcClient " + ret);
if (ret == null) return null;
const serverName = ret[1];
const mediaId = ret[2];
return `${homeserver}/_matrix/media/r0/thumbnail/${serverName}/${mediaId}?width=24&height=24&method=scale`;
};
const resourceMap = { const resourceMap = {
users: { users: {
path: "/_synapse/admin/v2/users", path: "/_synapse/admin/v2/users",
map: u => ({ map: u => ({
...u, ...u,
id: u.name, id: u.name,
avatar_src: mxcUrlToHttp(u.avatar_url),
is_guest: !!u.is_guest, is_guest: !!u.is_guest,
admin: !!u.admin, admin: !!u.admin,
deactivated: !!u.deactivated, deactivated: !!u.deactivated,
displayname: u.display_name || u.displayname, displayname: u.display_name || u.displayname,
// need timestamp in milliseconds
creation_ts_ms: u.creation_ts * 1000,
}), }),
data: "users", data: "users",
total: json => json.total, total: json => json.total,
@ -43,6 +57,11 @@ const resourceMap = {
map: r => ({ map: r => ({
...r, ...r,
id: r.room_id, id: r.room_id,
alias: r.canonical_alias,
members: r.joined_members,
is_encrypted: !!r.encryption,
federatable: !!r.federatable,
public: !!r.public,
}), }),
data: "rooms", data: "rooms",
total: json => json.total_rooms, total: json => json.total_rooms,
@ -56,16 +75,20 @@ const resourceMap = {
Array.isArray(data.invitees) && data.invitees.length > 0 Array.isArray(data.invitees) && data.invitees.length > 0
? data.invitees ? data.invitees
: undefined, : undefined,
initial_state: data.encrypt ? [{ initial_state: data.encrypt
type: 'm.room.encryption', ? [
state_key: '', {
type: "m.room.encryption",
state_key: "",
content: { content: {
algorithm: 'm.megolm.v1.aes-sha2', algorithm: "m.megolm.v1.aes-sha2",
} },
}] : undefined, },
]
: undefined,
}, },
method: "POST", method: "POST",
}) }),
}, },
connections: { connections: {
path: "/_synapse/admin/v1/whois", path: "/_synapse/admin/v1/whois",
@ -99,11 +122,20 @@ function filterNullValues(key, value) {
return value; return value;
} }
function getSearchOrder(order) {
if (order === "DESC") {
return "b";
} else {
return "f";
}
}
const dataProvider = { const dataProvider = {
getList: (resource, params) => { getList: (resource, params) => {
console.log("getList " + resource); console.log("getList " + resource);
const { user_id, guests, deactivated } = params.filter; const { user_id, guests, deactivated } = params.filter;
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,
@ -111,6 +143,8 @@ const dataProvider = {
user_id: user_id, user_id: user_id,
guests: guests, guests: guests,
deactivated: deactivated, deactivated: deactivated,
order_by: field,
dir: getSearchOrder(order),
}; };
const homeserver = localStorage.getItem("base_url"); const homeserver = localStorage.getItem("base_url");
if (!homeserver || !(resource in resourceMap)) return Promise.reject(); if (!homeserver || !(resource in resourceMap)) return Promise.reject();
@ -234,6 +268,29 @@ const dataProvider = {
})); }));
}, },
createMany: (resource, params) => {
console.log("createMany " + resource);
const homeserver = localStorage.getItem("base_url");
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
const res = resourceMap[resource];
if (!("create" in res)) return Promise.reject();
return Promise.all(
params.ids.map(id => {
params.data.id = id;
const cre = res["create"](params.data);
const endpoint_url = homeserver + cre.endpoint;
return jsonClient(endpoint_url, {
method: cre.method,
body: JSON.stringify(cre.body, filterNullValues),
});
})
).then(responses => ({
data: responses.map(({ json }) => json),
}));
},
delete: (resource, params) => { delete: (resource, params) => {
console.log("delete " + resource); console.log("delete " + resource);
const homeserver = localStorage.getItem("base_url"); const homeserver = localStorage.getItem("base_url");

2549
yarn.lock

File diff suppressed because it is too large Load Diff