Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 76fdc80e3e | |||
| 375649756f | |||
| 662735a91f | |||
| 0823976edd | |||
| d3cd2e9e33 | |||
| 24abcd4e4a | |||
| c1c32e3268 | |||
| ca15435625 | |||
| e9c3901b68 | |||
| 7aec6f9369 | |||
| d2a3f07a59 | |||
| bf7867f106 | |||
| f0e32abc4f | |||
| 61b1580735 | |||
| 0f7e4c1909 | |||
| c9bce409d2 |
@@ -4,28 +4,6 @@
|
|||||||
|
|
||||||
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.14.0 for all functions to work as expected!
|
Use `yarn install` after cloning this repo.
|
||||||
|
|
||||||
## Step-By-Step install:
|
Use `yarn start` to launch the webserver.
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||

|
|
||||||
|
|||||||
+8
-6
@@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "synapse-admin",
|
"name": "synapse-admin",
|
||||||
"version": "0.2.1",
|
"version": "0.1.0",
|
||||||
"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",
|
||||||
"homepage": ".",
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Awesome-Technologies/synapse-admin"
|
"url": "https://github.com/Awesome-Technologies/synapse-admin"
|
||||||
@@ -12,7 +11,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": "^12.0.11",
|
"@testing-library/user-event": "^10.0.1",
|
||||||
"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",
|
||||||
@@ -21,16 +20,19 @@
|
|||||||
"prettier": "^2.0.0"
|
"prettier": "^2.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@progress/kendo-drawing": "^1.6.0",
|
||||||
|
"@progress/kendo-react-pdf": "^3.10.1",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
|
"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.7.0",
|
"react-admin": "^3.4.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_APP_VERSION=$(git describe --tags) react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "REACT_APP_VERSION=$(git describe --tags) react-scripts build",
|
"build": "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",
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 358 KiB |
+1
-8
@@ -38,12 +38,5 @@
|
|||||||
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>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 222 KiB |
+13
-3
@@ -4,12 +4,14 @@ import polyglotI18nProvider from "ra-i18n-polyglot";
|
|||||||
import authProvider from "./synapse/authProvider";
|
import authProvider from "./synapse/authProvider";
|
||||||
import dataProvider from "./synapse/dataProvider";
|
import dataProvider from "./synapse/dataProvider";
|
||||||
import { UserList, UserCreate, UserEdit } from "./components/users";
|
import { UserList, UserCreate, UserEdit } from "./components/users";
|
||||||
import { RoomList, RoomShow } from "./components/rooms";
|
import { RoomList, RoomCreate, RoomShow } from "./components/rooms";
|
||||||
import LoginPage from "./components/LoginPage";
|
import LoginPage from "./components/LoginPage";
|
||||||
import UserIcon from "@material-ui/icons/Group";
|
import UserIcon from "@material-ui/icons/Group";
|
||||||
import { ViewListIcon as RoomIcon } from "@material-ui/icons/ViewList";
|
import { ViewListIcon as RoomIcon } from "@material-ui/icons/ViewList";
|
||||||
import germanMessages from "./i18n/de";
|
import germanMessages from "./i18n/de";
|
||||||
import englishMessages from "./i18n/en";
|
import englishMessages from "./i18n/en";
|
||||||
|
import ShowUserPdf from "./components/ShowUserPdf";
|
||||||
|
import { Route } from "react-router-dom";
|
||||||
|
|
||||||
// TODO: Can we use lazy loading together with browser locale?
|
// TODO: Can we use lazy loading together with browser locale?
|
||||||
const messages = {
|
const messages = {
|
||||||
@@ -27,6 +29,9 @@ const App = () => (
|
|||||||
authProvider={authProvider}
|
authProvider={authProvider}
|
||||||
dataProvider={dataProvider}
|
dataProvider={dataProvider}
|
||||||
i18nProvider={i18nProvider}
|
i18nProvider={i18nProvider}
|
||||||
|
customRoutes={[
|
||||||
|
<Route key="showpdf" path="/showpdf" component={ShowUserPdf} />,
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Resource
|
<Resource
|
||||||
name="users"
|
name="users"
|
||||||
@@ -35,9 +40,14 @@ const App = () => (
|
|||||||
edit={UserEdit}
|
edit={UserEdit}
|
||||||
icon={UserIcon}
|
icon={UserIcon}
|
||||||
/>
|
/>
|
||||||
<Resource name="rooms" list={RoomList} show={RoomShow} icon={RoomIcon} />
|
<Resource
|
||||||
|
name="rooms"
|
||||||
|
list={RoomList}
|
||||||
|
create={RoomCreate}
|
||||||
|
show={RoomShow}
|
||||||
|
icon={RoomIcon}
|
||||||
|
/>
|
||||||
<Resource name="connections" />
|
<Resource name="connections" />
|
||||||
<Resource name="servernotices" />
|
|
||||||
</Admin>
|
</Admin>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+35
-123
@@ -1,17 +1,13 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
fetchUtils,
|
|
||||||
FormDataConsumer,
|
|
||||||
Notification,
|
Notification,
|
||||||
useLogin,
|
useLogin,
|
||||||
useNotify,
|
useNotify,
|
||||||
useLocale,
|
useLocale,
|
||||||
useSetLocale,
|
useSetLocale,
|
||||||
useTranslate,
|
useTranslate,
|
||||||
PasswordInput,
|
|
||||||
TextInput,
|
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import { Form, useForm } from "react-final-form";
|
import { Field, Form } from "react-final-form";
|
||||||
import {
|
import {
|
||||||
Avatar,
|
Avatar,
|
||||||
Button,
|
Button,
|
||||||
@@ -29,7 +25,7 @@ const useStyles = makeStyles(theme => ({
|
|||||||
main: {
|
main: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
minHeight: "calc(100vh - 1em)",
|
minHeight: "100vh",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "flex-start",
|
justifyContent: "flex-start",
|
||||||
background: "url(./images/floating-cogs.svg)",
|
background: "url(./images/floating-cogs.svg)",
|
||||||
@@ -38,9 +34,8 @@ const useStyles = makeStyles(theme => ({
|
|||||||
backgroundSize: "cover",
|
backgroundSize: "cover",
|
||||||
},
|
},
|
||||||
card: {
|
card: {
|
||||||
minWidth: "30em",
|
minWidth: 300,
|
||||||
marginTop: "6em",
|
marginTop: "6em",
|
||||||
marginBottom: "6em",
|
|
||||||
},
|
},
|
||||||
avatar: {
|
avatar: {
|
||||||
margin: "1em",
|
margin: "1em",
|
||||||
@@ -65,12 +60,6 @@ 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 }) => {
|
||||||
@@ -81,7 +70,7 @@ const LoginPage = ({ theme }) => {
|
|||||||
var locale = useLocale();
|
var locale = useLocale();
|
||||||
const setLocale = useSetLocale();
|
const setLocale = useSetLocale();
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
const base_url = localStorage.getItem("base_url");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
|
|
||||||
const renderInput = ({
|
const renderInput = ({
|
||||||
meta: { touched, error } = {},
|
meta: { touched, error } = {},
|
||||||
@@ -99,23 +88,15 @@ const LoginPage = ({ theme }) => {
|
|||||||
|
|
||||||
const validate = values => {
|
const validate = values => {
|
||||||
const errors = {};
|
const errors = {};
|
||||||
|
if (!values.homeserver) {
|
||||||
|
errors.homeserver = translate("ra.validation.required");
|
||||||
|
}
|
||||||
if (!values.username) {
|
if (!values.username) {
|
||||||
errors.username = translate("ra.validation.required");
|
errors.username = translate("ra.validation.required");
|
||||||
}
|
}
|
||||||
if (!values.password) {
|
if (!values.password) {
|
||||||
errors.password = translate("ra.validation.required");
|
errors.password = translate("ra.validation.required");
|
||||||
}
|
}
|
||||||
if (!values.base_url) {
|
|
||||||
errors.base_url = translate("ra.validation.required");
|
|
||||||
} else {
|
|
||||||
if (!values.base_url.match(/^(http|https):\/\//)) {
|
|
||||||
errors.base_url = translate("synapseadmin.auth.protocol_error");
|
|
||||||
} else if (
|
|
||||||
!values.base_url.match(/^(http|https):\/\/[a-zA-Z0-9\-.]+(:\d{1,5})?$/)
|
|
||||||
) {
|
|
||||||
errors.base_url = translate("synapseadmin.auth.url_error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return errors;
|
return errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -134,101 +115,9 @@ const LoginPage = ({ theme }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const extractHomeServer = username => {
|
|
||||||
const usernameRegex = /@[a-zA-Z0-9._=\-/]+:([a-zA-Z0-9\-.]+\.[a-zA-Z]+)/;
|
|
||||||
if (!username) return null;
|
|
||||||
const res = username.match(usernameRegex);
|
|
||||||
if (res) return res[1];
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const UserData = ({ formData }) => {
|
|
||||||
const form = useForm();
|
|
||||||
const [serverVersion, setServerVersion] = useState("");
|
|
||||||
|
|
||||||
const handleUsernameChange = _ => {
|
|
||||||
if (formData.base_url) return;
|
|
||||||
// check if username is a full qualified userId then set base_url accordially
|
|
||||||
const home_server = extractHomeServer(formData.username);
|
|
||||||
const wellKnownUrl = `https://${home_server}/.well-known/matrix/client`;
|
|
||||||
if (home_server) {
|
|
||||||
// fetch .well-known entry to get base_url
|
|
||||||
fetchUtils
|
|
||||||
.fetchJson(wellKnownUrl, { method: "GET" })
|
|
||||||
.then(({ json }) => {
|
|
||||||
form.change("base_url", json["m.homeserver"].base_url);
|
|
||||||
})
|
|
||||||
.catch(_ => {
|
|
||||||
// if there is no .well-known entry, try the home server name
|
|
||||||
form.change("base_url", `https://${home_server}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
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 (
|
|
||||||
<div>
|
|
||||||
<div className={classes.input}>
|
|
||||||
<TextInput
|
|
||||||
autoFocus
|
|
||||||
name="username"
|
|
||||||
component={renderInput}
|
|
||||||
label={translate("ra.auth.username")}
|
|
||||||
disabled={loading}
|
|
||||||
onBlur={handleUsernameChange}
|
|
||||||
fullWidth
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className={classes.input}>
|
|
||||||
<PasswordInput
|
|
||||||
name="password"
|
|
||||||
component={renderInput}
|
|
||||||
label={translate("ra.auth.password")}
|
|
||||||
type="password"
|
|
||||||
disabled={loading}
|
|
||||||
fullWidth
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className={classes.input}>
|
|
||||||
<TextInput
|
|
||||||
name="base_url"
|
|
||||||
component={renderInput}
|
|
||||||
label={translate("synapseadmin.auth.base_url")}
|
|
||||||
disabled={loading}
|
|
||||||
fullWidth
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className={classes.serverVersion}>{serverVersion}</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
initialValues={{ base_url: base_url }}
|
initialValues={{ homeserver: homeserver }}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
validate={validate}
|
validate={validate}
|
||||||
render={({ handleSubmit }) => (
|
render={({ handleSubmit }) => (
|
||||||
@@ -257,9 +146,32 @@ const LoginPage = ({ theme }) => {
|
|||||||
<MenuItem value="en">English</MenuItem>
|
<MenuItem value="en">English</MenuItem>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
<FormDataConsumer>
|
<div className={classes.input}>
|
||||||
{formDataProps => <UserData {...formDataProps} />}
|
<Field
|
||||||
</FormDataConsumer>
|
autoFocus
|
||||||
|
name="homeserver"
|
||||||
|
component={renderInput}
|
||||||
|
label={translate("synapseadmin.auth.homeserver")}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={classes.input}>
|
||||||
|
<Field
|
||||||
|
name="username"
|
||||||
|
component={renderInput}
|
||||||
|
label={translate("ra.auth.username")}
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className={classes.input}>
|
||||||
|
<Field
|
||||||
|
name="password"
|
||||||
|
component={renderInput}
|
||||||
|
label={translate("ra.auth.password")}
|
||||||
|
type="password"
|
||||||
|
disabled={loading}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<CardActions className={classes.actions}>
|
<CardActions className={classes.actions}>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import React, { useCallback } from "react";
|
||||||
|
import { SaveButton, useCreate, useRedirect, useNotify } from "react-admin";
|
||||||
|
|
||||||
|
const SaveQrButton = props => {
|
||||||
|
const [create] = useCreate("users");
|
||||||
|
const redirectTo = useRedirect();
|
||||||
|
const notify = useNotify();
|
||||||
|
const { basePath } = props;
|
||||||
|
|
||||||
|
const handleSave = useCallback(
|
||||||
|
(values, redirect) => {
|
||||||
|
create(
|
||||||
|
{
|
||||||
|
payload: { data: { ...values } },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onSuccess: ({ data: newRecord }) => {
|
||||||
|
notify("ra.notification.created", "info", {
|
||||||
|
smart_count: 1,
|
||||||
|
});
|
||||||
|
redirectTo(redirect, basePath, newRecord.id, {
|
||||||
|
password: values.password,
|
||||||
|
...newRecord,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
[create, notify, redirectTo, basePath]
|
||||||
|
);
|
||||||
|
|
||||||
|
return <SaveButton {...props} onSave={handleSave} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SaveQrButton;
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
import React, { Fragment, useState } from "react";
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
SaveButton,
|
|
||||||
SimpleForm,
|
|
||||||
TextInput,
|
|
||||||
Toolbar,
|
|
||||||
required,
|
|
||||||
useCreate,
|
|
||||||
useMutation,
|
|
||||||
useNotify,
|
|
||||||
useTranslate,
|
|
||||||
useUnselectAll,
|
|
||||||
} from "react-admin";
|
|
||||||
import MessageIcon from "@material-ui/icons/Message";
|
|
||||||
import IconCancel from "@material-ui/icons/Cancel";
|
|
||||||
import Dialog from "@material-ui/core/Dialog";
|
|
||||||
import DialogContent from "@material-ui/core/DialogContent";
|
|
||||||
import DialogContentText from "@material-ui/core/DialogContentText";
|
|
||||||
import DialogTitle from "@material-ui/core/DialogTitle";
|
|
||||||
|
|
||||||
const ServerNoticeDialog = ({ open, loading, onClose, onSend }) => {
|
|
||||||
const translate = useTranslate();
|
|
||||||
|
|
||||||
const ServerNoticeToolbar = props => (
|
|
||||||
<Toolbar {...props}>
|
|
||||||
<SaveButton label="resources.servernotices.action.send" />
|
|
||||||
<Button label="ra.action.cancel" onClick={onClose}>
|
|
||||||
<IconCancel />
|
|
||||||
</Button>
|
|
||||||
</Toolbar>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog open={open} onClose={onClose} loading={loading}>
|
|
||||||
<DialogTitle>
|
|
||||||
{translate("resources.servernotices.action.send")}
|
|
||||||
</DialogTitle>
|
|
||||||
<DialogContent>
|
|
||||||
<DialogContentText>
|
|
||||||
{translate("resources.servernotices.helper.send")}
|
|
||||||
</DialogContentText>
|
|
||||||
<SimpleForm
|
|
||||||
toolbar={<ServerNoticeToolbar />}
|
|
||||||
submitOnEnter={false}
|
|
||||||
redirect={false}
|
|
||||||
save={onSend}
|
|
||||||
>
|
|
||||||
<TextInput
|
|
||||||
source="body"
|
|
||||||
label="resources.servernotices.fields.body"
|
|
||||||
fullWidth
|
|
||||||
multiline
|
|
||||||
rows="4"
|
|
||||||
resettable
|
|
||||||
validate={required()}
|
|
||||||
/>
|
|
||||||
</SimpleForm>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ServerNoticeButton = ({ record }) => {
|
|
||||||
const [open, setOpen] = useState(false);
|
|
||||||
const notify = useNotify();
|
|
||||||
const [create, { loading }] = useCreate("servernotices");
|
|
||||||
|
|
||||||
const handleDialogOpen = () => setOpen(true);
|
|
||||||
const handleDialogClose = () => setOpen(false);
|
|
||||||
|
|
||||||
const handleSend = values => {
|
|
||||||
create(
|
|
||||||
{ payload: { data: { id: record.id, ...values } } },
|
|
||||||
{
|
|
||||||
onSuccess: () => {
|
|
||||||
notify("resources.servernotices.action.send_success");
|
|
||||||
handleDialogClose();
|
|
||||||
},
|
|
||||||
onFailure: () =>
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Title, Button } from "react-admin";
|
||||||
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
|
import { PDFExport } from "@progress/kendo-react-pdf";
|
||||||
|
import QRCode from "qrcode.react";
|
||||||
|
|
||||||
|
function xor(a, b) {
|
||||||
|
var res = "";
|
||||||
|
for (var i = 0; i < a.length; i++) {
|
||||||
|
res += String.fromCharCode(a.charCodeAt(i) ^ b.charCodeAt(i % b.length));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculateQrString(serverUrl, username, password) {
|
||||||
|
const magicString = "wo9k5tep252qxsa5yde7366kugy6c01w7oeeya9hrmpf0t7ii7";
|
||||||
|
var urlString = "user=" + username + "&password=" + password;
|
||||||
|
|
||||||
|
urlString = xor(urlString, magicString); // xor with magic string
|
||||||
|
urlString = btoa(urlString); // to base64
|
||||||
|
|
||||||
|
return serverUrl + "/#" + urlString;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ShowUserPdf = props => {
|
||||||
|
const useStyles = makeStyles(theme => ({
|
||||||
|
page: {
|
||||||
|
height: 800,
|
||||||
|
width: 566,
|
||||||
|
padding: "none",
|
||||||
|
backgroundColor: "white",
|
||||||
|
boxShadow: "5px 5px 5px black",
|
||||||
|
margin: "auto",
|
||||||
|
overflowX: "hidden",
|
||||||
|
overflowY: "hidden",
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
height: 144,
|
||||||
|
width: 534,
|
||||||
|
marginLeft: 32,
|
||||||
|
marginTop: 15,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
width: 233,
|
||||||
|
fontSize: 40,
|
||||||
|
float: "left",
|
||||||
|
marginTop: 15,
|
||||||
|
},
|
||||||
|
logo: {
|
||||||
|
width: 90,
|
||||||
|
marginTop: 20,
|
||||||
|
marginRight: 32,
|
||||||
|
float: "left",
|
||||||
|
},
|
||||||
|
code: {
|
||||||
|
marginLeft: 330,
|
||||||
|
marginTop: 86,
|
||||||
|
},
|
||||||
|
qr: {
|
||||||
|
marginRight: 40,
|
||||||
|
float: "right",
|
||||||
|
},
|
||||||
|
note: {
|
||||||
|
fontSize: 18,
|
||||||
|
marginTop: 100,
|
||||||
|
marginLeft: 32,
|
||||||
|
marginRight: 32,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const classes = useStyles();
|
||||||
|
|
||||||
|
var resume;
|
||||||
|
|
||||||
|
const exportPDF = () => {
|
||||||
|
resume.save();
|
||||||
|
};
|
||||||
|
|
||||||
|
var qrCode = "";
|
||||||
|
var displayname = "";
|
||||||
|
|
||||||
|
if (
|
||||||
|
props.location.state &&
|
||||||
|
props.location.state.id &&
|
||||||
|
props.location.state.password
|
||||||
|
) {
|
||||||
|
const { id, password } = props.location.state;
|
||||||
|
|
||||||
|
const username = id.substring(1, id.indexOf(":"));
|
||||||
|
const serverUrl = "https://" + id.substring(id.indexOf(":") + 1);
|
||||||
|
|
||||||
|
const qrString = calculateQrString(serverUrl, username, password);
|
||||||
|
|
||||||
|
qrCode = <QRCode value={qrString} size={128} />;
|
||||||
|
displayname = props.location.state.displayname;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Title title="PDF" />
|
||||||
|
<Button label="synapseadmin.action.download_pdf" onClick={exportPDF} />
|
||||||
|
|
||||||
|
<PDFExport
|
||||||
|
paperSize={"A4"}
|
||||||
|
fileName="User.pdf"
|
||||||
|
title=""
|
||||||
|
subject=""
|
||||||
|
keywords=""
|
||||||
|
ref={r => (resume = r)}
|
||||||
|
>
|
||||||
|
<div className={classes.page}>
|
||||||
|
<div className={classes.code}>Ihr persönlicher Anmeldecode:</div>
|
||||||
|
<div className={classes.header}>
|
||||||
|
<div className={classes.name}>{displayname}</div>
|
||||||
|
<img className={classes.logo} alt="Logo" src="images/logo.png" />
|
||||||
|
<div className={classes.qr}>{qrCode}</div>
|
||||||
|
</div>
|
||||||
|
<div className={classes.note}>
|
||||||
|
Hier können Sie Ihre selbst gewählte Schlüsselsicherungs-Passphrase
|
||||||
|
notieren:
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<hr />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PDFExport>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ShowUserPdf;
|
||||||
+117
-193
@@ -1,224 +1,148 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
|
||||||
import {
|
import {
|
||||||
BooleanField,
|
BooleanField,
|
||||||
|
BooleanInput,
|
||||||
|
Create,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
Filter,
|
|
||||||
List,
|
List,
|
||||||
Pagination,
|
Pagination,
|
||||||
SelectField,
|
ReferenceArrayField,
|
||||||
Show,
|
Show,
|
||||||
|
SimpleForm,
|
||||||
Tab,
|
Tab,
|
||||||
TabbedShowLayout,
|
TabbedShowLayout,
|
||||||
TextField,
|
TextField,
|
||||||
|
TextInput,
|
||||||
useTranslate,
|
useTranslate,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
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 ViewListIcon from "@material-ui/icons/ViewList";
|
import ViewListIcon from "@material-ui/icons/ViewList";
|
||||||
import VisibilityIcon from "@material-ui/icons/Visibility";
|
import UserIcon from "@material-ui/icons/Group";
|
||||||
|
|
||||||
const RoomPagination = props => (
|
const RoomPagination = props => (
|
||||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||||
);
|
);
|
||||||
|
|
||||||
const EncryptionField = ({ source, record = {}, emptyText }) => {
|
export const RoomList = props => (
|
||||||
const translate = useTranslate();
|
<List {...props} pagination={<RoomPagination />}>
|
||||||
const value = get(record, source);
|
<Datagrid rowClick="show">
|
||||||
let ariaLabel = value === false ? "ra.boolean.false" : "ra.boolean.true";
|
<TextField source="room_id" />
|
||||||
|
<TextField source="name" />
|
||||||
|
<TextField source="canonical_alias" />
|
||||||
|
<TextField source="joined_members" />
|
||||||
|
</Datagrid>
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
|
||||||
if (value === false || value === true) {
|
const validateDisplayName = fieldval =>
|
||||||
return (
|
fieldval === undefined
|
||||||
<Typography component="span" variant="body2">
|
? "synapseadmin.rooms.room_name_required"
|
||||||
<Tooltip title={translate(ariaLabel, { _: ariaLabel })}>
|
: fieldval.length === 0
|
||||||
{value === true ? (
|
? "synapseadmin.rooms.room_name_required"
|
||||||
<HttpsIcon data-testid="true" htmlColor="limegreen" />
|
: undefined;
|
||||||
) : (
|
|
||||||
<NoEncryptionIcon data-testid="false" color="error" />
|
function approximateAliasLength(alias, homeserver) {
|
||||||
)}
|
/* TODO maybe handle punycode in homeserver URL */
|
||||||
</Tooltip>
|
|
||||||
</Typography>
|
var te;
|
||||||
);
|
|
||||||
|
// Support for TextEncoder is quite widespread, but the polyfill is
|
||||||
|
// pretty large; We will only underestimate the size with the regular
|
||||||
|
// length attribute of String, so we never prevent the user from using
|
||||||
|
// an alias that is short enough for the server, but too long for our
|
||||||
|
// heuristic.
|
||||||
|
try {
|
||||||
|
te = new TextEncoder();
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof ReferenceError) {
|
||||||
|
te = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
const aliasLength = te === undefined ? alias.length : te.encode(alias).length;
|
||||||
<Typography component="span" variant="body2">
|
|
||||||
{emptyText}
|
return "#".length + aliasLength + ":".length + homeserver.length;
|
||||||
</Typography>
|
}
|
||||||
);
|
|
||||||
|
const validateAlias = fieldval => {
|
||||||
|
if (fieldval === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const homeserver = localStorage.getItem("home_server_url");
|
||||||
|
|
||||||
|
if (approximateAliasLength(fieldval, homeserver) > 255) {
|
||||||
|
return "synapseadmin.rooms.alias_too_long";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const removeLeadingWhitespace = fieldVal =>
|
||||||
|
fieldVal === undefined ? undefined : fieldVal.trimStart();
|
||||||
|
const replaceAllWhitespace = fieldVal =>
|
||||||
|
fieldVal === undefined ? undefined : fieldVal.replace(/\s/, "_");
|
||||||
|
const removeLeadingSigil = fieldVal =>
|
||||||
|
fieldVal === undefined
|
||||||
|
? undefined
|
||||||
|
: fieldVal.startsWith("#")
|
||||||
|
? fieldVal.substr(1)
|
||||||
|
: fieldVal;
|
||||||
|
|
||||||
|
const validateHasAliasIfPublic = formdata => {
|
||||||
|
let errors = {};
|
||||||
|
if (formdata.public) {
|
||||||
|
if (
|
||||||
|
formdata.canonical_alias === undefined ||
|
||||||
|
formdata.canonical_alias.trim().length === 0
|
||||||
|
) {
|
||||||
|
errors.canonical_alias = "synapseadmin.rooms.alias_required_if_public";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return errors;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const RoomCreate = props => (
|
||||||
|
<Create {...props}>
|
||||||
|
<SimpleForm validate={validateHasAliasIfPublic}>
|
||||||
|
<TextInput
|
||||||
|
source="name"
|
||||||
|
parse={removeLeadingWhitespace}
|
||||||
|
validate={validateDisplayName}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
source="canonical_alias"
|
||||||
|
parse={fv => replaceAllWhitespace(removeLeadingSigil(fv))}
|
||||||
|
validate={validateAlias}
|
||||||
|
placeholder="#"
|
||||||
|
/>
|
||||||
|
<BooleanInput source="public" label="synapseadmin.rooms.make_public" />
|
||||||
|
</SimpleForm>
|
||||||
|
</Create>
|
||||||
|
);
|
||||||
|
|
||||||
const RoomTitle = ({ record }) => {
|
const RoomTitle = ({ record }) => {
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
var name = "";
|
|
||||||
if (record) {
|
|
||||||
name = record.name !== "" ? record.name : record.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{translate("resources.rooms.name", 1)} {name}
|
{translate("resources.rooms.name", 1)} {record ? `"${record.name}"` : ""}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
export const RoomShow = props => (
|
||||||
export const RoomShow = props => {
|
<Show {...props} title={<RoomTitle />}>
|
||||||
const translate = useTranslate();
|
<TabbedShowLayout>
|
||||||
return (
|
<Tab label="synapseadmin.rooms.details" icon={<ViewListIcon />}>
|
||||||
<Show {...props} title={<RoomTitle />}>
|
<TextField source="id" disabled />
|
||||||
<TabbedShowLayout>
|
|
||||||
<Tab label="synapseadmin.rooms.tabs.basic" icon={<ViewListIcon />}>
|
|
||||||
<TextField source="room_id" />
|
|
||||||
<TextField source="name" />
|
|
||||||
<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
|
|
||||||
source="join_rules"
|
|
||||||
choices={[
|
|
||||||
{ id: "public", name: "resources.rooms.enums.join_rules.public" },
|
|
||||||
{ id: "knock", name: "resources.rooms.enums.join_rules.knock" },
|
|
||||||
{ id: "invite", name: "resources.rooms.enums.join_rules.invite" },
|
|
||||||
{
|
|
||||||
id: "private",
|
|
||||||
name: "resources.rooms.enums.join_rules.private",
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
<SelectField
|
|
||||||
source="guest_access"
|
|
||||||
choices={[
|
|
||||||
{
|
|
||||||
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>
|
|
||||||
</TabbedShowLayout>
|
|
||||||
</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="name" />
|
||||||
<TextField source="joined_members" />
|
<TextField source="canonical_alias" />
|
||||||
{localMembersFilter && <TextField source="joined_local_members" />}
|
<TextField source="join_rules" />
|
||||||
{stateEventsFilter && <TextField source="state_events" />}
|
<TextField source="guest_access" />
|
||||||
{versionFilter && <TextField source="version" />}
|
</Tab>
|
||||||
{federateableFilter && <BooleanField source="federatable" />}
|
<Tab label="resources.rooms.fields.joined_members" icon={<UserIcon />}>
|
||||||
<BooleanField source="public" />
|
<ReferenceArrayField reference="users" source="members">
|
||||||
</Datagrid>
|
<Datagrid>
|
||||||
</List>
|
<TextField source="id" />
|
||||||
);
|
<TextField source="displayname" />
|
||||||
};
|
</Datagrid>
|
||||||
|
</ReferenceArrayField>
|
||||||
function mapStateToProps(state) {
|
</Tab>
|
||||||
return {
|
</TabbedShowLayout>
|
||||||
roomFilters: state.admin.resources.rooms.list.params.displayedFilters,
|
</Show>
|
||||||
};
|
);
|
||||||
}
|
|
||||||
|
|
||||||
export const RoomList = connect(mapStateToProps)(FilterableRoomList);
|
|
||||||
|
|||||||
+163
-188
@@ -1,7 +1,5 @@
|
|||||||
import React, { cloneElement, Fragment } from "react";
|
import React, { 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,
|
||||||
@@ -19,9 +17,11 @@ import {
|
|||||||
FormTab,
|
FormTab,
|
||||||
BooleanField,
|
BooleanField,
|
||||||
BooleanInput,
|
BooleanInput,
|
||||||
|
ImageField,
|
||||||
PasswordInput,
|
PasswordInput,
|
||||||
TextField,
|
TextField,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
SearchInput,
|
||||||
ReferenceField,
|
ReferenceField,
|
||||||
SelectInput,
|
SelectInput,
|
||||||
BulkDeleteButton,
|
BulkDeleteButton,
|
||||||
@@ -30,64 +30,8 @@ import {
|
|||||||
regex,
|
regex,
|
||||||
useTranslate,
|
useTranslate,
|
||||||
Pagination,
|
Pagination,
|
||||||
CreateButton,
|
|
||||||
ExportButton,
|
|
||||||
TopToolbar,
|
|
||||||
sanitizeListRestProps,
|
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
|
import SaveQrButton from "./SaveQrButton";
|
||||||
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]} />
|
||||||
@@ -95,6 +39,7 @@ const UserPagination = props => (
|
|||||||
|
|
||||||
const UserFilter = props => (
|
const UserFilter = props => (
|
||||||
<Filter {...props}>
|
<Filter {...props}>
|
||||||
|
<SearchInput source="user_id" alwaysOn />
|
||||||
<BooleanInput source="guests" alwaysOn />
|
<BooleanInput source="guests" alwaysOn />
|
||||||
<BooleanInput
|
<BooleanInput
|
||||||
label="resources.users.fields.show_deactivated"
|
label="resources.users.fields.show_deactivated"
|
||||||
@@ -108,7 +53,6 @@ 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"
|
||||||
@@ -118,37 +62,94 @@ const UserBulkActionButtons = props => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const AvatarField = ({ source, className, record = {} }) => (
|
export const UserList = props => (
|
||||||
<Avatar src={record[source]} className={className} />
|
<List
|
||||||
|
{...props}
|
||||||
|
filters={<UserFilter />}
|
||||||
|
filterDefaultValues={{ guests: true, deactivated: false }}
|
||||||
|
bulkActionButtons={<UserBulkActionButtons />}
|
||||||
|
pagination={<UserPagination />}
|
||||||
|
>
|
||||||
|
<Datagrid rowClick="edit">
|
||||||
|
<ImageField source="avatar_url" title="displayname" />
|
||||||
|
<TextField source="id" sortable={false} />
|
||||||
|
<TextField source="displayname" />
|
||||||
|
<BooleanField source="is_guest" sortable={false} />
|
||||||
|
<BooleanField source="admin" sortable={false} />
|
||||||
|
<BooleanField source="deactivated" sortable={false} />
|
||||||
|
</Datagrid>
|
||||||
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UserList = props => {
|
function generateRandomUser() {
|
||||||
const classes = useStyles();
|
const homeserver = localStorage.getItem("home_server_url");
|
||||||
return (
|
const user_id =
|
||||||
<List
|
"@" +
|
||||||
{...props}
|
Array(8)
|
||||||
filters={<UserFilter />}
|
.fill("0123456789abcdefghijklmnopqrstuvwxyz")
|
||||||
filterDefaultValues={{ guests: true, deactivated: false }}
|
.map(
|
||||||
actions={<UserListActions maxResults={10000} />}
|
x =>
|
||||||
bulkActionButtons={<UserBulkActionButtons />}
|
x[
|
||||||
pagination={<UserPagination />}
|
Math.floor(
|
||||||
>
|
(crypto.getRandomValues(new Uint32Array(1))[0] /
|
||||||
<Datagrid rowClick="edit">
|
(0xffffffff + 1)) *
|
||||||
<AvatarField
|
x.length
|
||||||
source="avatar_src"
|
)
|
||||||
sortable={false}
|
]
|
||||||
className={classes.small}
|
)
|
||||||
/>
|
.join("") +
|
||||||
<TextField source="id" sortable={false} />
|
":" +
|
||||||
<TextField source="displayname" sortable={false} />
|
homeserver;
|
||||||
<BooleanField source="is_guest" sortable={false} />
|
|
||||||
<BooleanField source="admin" sortable={false} />
|
const password = Array(20)
|
||||||
<BooleanField source="deactivated" sortable={false} />
|
.fill(
|
||||||
</Datagrid>
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$"
|
||||||
</List>
|
)
|
||||||
);
|
.map(
|
||||||
|
x =>
|
||||||
|
x[
|
||||||
|
Math.floor(
|
||||||
|
(crypto.getRandomValues(new Uint32Array(1))[0] / (0xffffffff + 1)) *
|
||||||
|
x.length
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
.join("");
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: user_id,
|
||||||
|
password: password,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// redirect to the related Author show page
|
||||||
|
const redirect = (basePath, id, data) => {
|
||||||
|
return {
|
||||||
|
pathname: "/showpdf",
|
||||||
|
state: {
|
||||||
|
id: data.id,
|
||||||
|
displayname: data.displayname,
|
||||||
|
password: data.password,
|
||||||
|
},
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const UserCreateToolbar = props => (
|
||||||
|
<Toolbar {...props}>
|
||||||
|
<SaveQrButton
|
||||||
|
label="synapseadmin.action.save_and_show"
|
||||||
|
redirect={redirect}
|
||||||
|
submitOnEnter={true}
|
||||||
|
/>
|
||||||
|
<SaveButton
|
||||||
|
label="synapseadmin.action.save_only"
|
||||||
|
redirect="list"
|
||||||
|
submitOnEnter={false}
|
||||||
|
variant="text"
|
||||||
|
/>
|
||||||
|
</Toolbar>
|
||||||
|
);
|
||||||
|
|
||||||
// https://matrix.org/docs/spec/appendices#user-identifiers
|
// https://matrix.org/docs/spec/appendices#user-identifiers
|
||||||
const validateUser = regex(
|
const validateUser = regex(
|
||||||
/^@[a-z0-9._=\-/]+:.*/,
|
/^@[a-z0-9._=\-/]+:.*/,
|
||||||
@@ -159,19 +160,28 @@ const UserEditToolbar = props => {
|
|||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
return (
|
return (
|
||||||
<Toolbar {...props}>
|
<Toolbar {...props}>
|
||||||
<SaveButton submitOnEnter={true} />
|
<SaveQrButton
|
||||||
|
label="synapseadmin.action.save_and_show"
|
||||||
|
redirect={redirect}
|
||||||
|
submitOnEnter={true}
|
||||||
|
/>
|
||||||
|
<SaveButton
|
||||||
|
label="synapseadmin.action.save_only"
|
||||||
|
redirect="list"
|
||||||
|
submitOnEnter={false}
|
||||||
|
variant="text"
|
||||||
|
/>
|
||||||
<DeleteButton
|
<DeleteButton
|
||||||
label="resources.users.action.erase"
|
label="resources.users.action.erase"
|
||||||
title={translate("resources.users.helper.erase")}
|
title={translate("resources.users.helper.erase")}
|
||||||
/>
|
/>
|
||||||
<ServerNoticeButton />
|
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UserCreate = props => (
|
export const UserCreate = props => (
|
||||||
<Create {...props}>
|
<Create record={generateRandomUser()} {...props}>
|
||||||
<SimpleForm>
|
<SimpleForm toolbar={<UserCreateToolbar />}>
|
||||||
<TextInput source="id" autoComplete="off" validate={validateUser} />
|
<TextInput source="id" autoComplete="off" validate={validateUser} />
|
||||||
<TextInput source="displayname" />
|
<TextInput source="displayname" />
|
||||||
<PasswordInput source="password" autoComplete="new-password" />
|
<PasswordInput source="password" autoComplete="new-password" />
|
||||||
@@ -196,104 +206,69 @@ 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();
|
<Edit {...props} title={<UserTitle />}>
|
||||||
return (
|
<TabbedForm toolbar={<UserEditToolbar />}>
|
||||||
<Edit {...props} title={<UserTitle />}>
|
<FormTab label="resources.users.name" icon={<PersonPinIcon />}>
|
||||||
<TabbedForm toolbar={<UserEditToolbar />}>
|
<TextInput source="id" disabled />
|
||||||
<FormTab label="resources.users.name" icon={<PersonPinIcon />}>
|
<TextInput source="displayname" />
|
||||||
<AvatarField
|
<PasswordInput source="password" autoComplete="new-password" />
|
||||||
source="avatar_src"
|
<BooleanInput source="admin" />
|
||||||
sortable={false}
|
<BooleanInput
|
||||||
className={classes.large}
|
source="deactivated"
|
||||||
/>
|
helperText="resources.users.helper.deactivate"
|
||||||
<TextInput source="id" disabled />
|
/>
|
||||||
<TextInput source="displayname" />
|
<ArrayInput source="threepids">
|
||||||
<PasswordInput source="password" autoComplete="new-password" />
|
<SimpleFormIterator>
|
||||||
<BooleanInput source="admin" />
|
<SelectInput
|
||||||
<BooleanInput
|
source="medium"
|
||||||
source="deactivated"
|
choices={[
|
||||||
helperText="resources.users.helper.deactivate"
|
{ id: "email", name: "resources.users.email" },
|
||||||
/>
|
{ id: "msisdn", name: "resources.users.msisdn" },
|
||||||
<DateField
|
]}
|
||||||
source="creation_ts_ms"
|
/>
|
||||||
showTime
|
<TextInput source="address" />
|
||||||
options={{
|
</SimpleFormIterator>
|
||||||
year: "numeric",
|
</ArrayInput>
|
||||||
month: "2-digit",
|
</FormTab>
|
||||||
day: "2-digit",
|
<FormTab
|
||||||
hour: "2-digit",
|
label="resources.connections.name"
|
||||||
minute: "2-digit",
|
icon={<SettingsInputComponentIcon />}
|
||||||
second: "2-digit",
|
>
|
||||||
}}
|
<ReferenceField reference="connections" source="id" addLabel={false}>
|
||||||
/>
|
<ArrayField
|
||||||
<TextField source="consent_version" />
|
source="devices[].sessions[0].connections"
|
||||||
</FormTab>
|
label="resources.connections.name"
|
||||||
<FormTab
|
|
||||||
label="resources.users.threepid"
|
|
||||||
icon={<ContactMailIcon />}
|
|
||||||
path="threepid"
|
|
||||||
>
|
|
||||||
<ArrayInput source="threepids">
|
|
||||||
<SimpleFormIterator>
|
|
||||||
<SelectInput
|
|
||||||
source="medium"
|
|
||||||
choices={[
|
|
||||||
{ id: "email", name: "resources.users.email" },
|
|
||||||
{ id: "msisdn", name: "resources.users.msisdn" },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
<TextInput source="address" />
|
|
||||||
</SimpleFormIterator>
|
|
||||||
</ArrayInput>
|
|
||||||
</FormTab>
|
|
||||||
<FormTab
|
|
||||||
label="resources.connections.name"
|
|
||||||
icon={<SettingsInputComponentIcon />}
|
|
||||||
path="connections"
|
|
||||||
>
|
|
||||||
<ReferenceField
|
|
||||||
reference="connections"
|
|
||||||
source="id"
|
|
||||||
addLabel={false}
|
|
||||||
link={false}
|
|
||||||
>
|
>
|
||||||
<ArrayField
|
<Datagrid style={{ width: "100%" }}>
|
||||||
source="devices[].sessions[0].connections"
|
<TextField source="ip" sortable={false} />
|
||||||
label="resources.connections.name"
|
<DateField
|
||||||
>
|
source="last_seen"
|
||||||
<Datagrid style={{ width: "100%" }}>
|
showTime
|
||||||
<TextField source="ip" sortable={false} />
|
options={{
|
||||||
<DateField
|
year: "numeric",
|
||||||
source="last_seen"
|
month: "2-digit",
|
||||||
showTime
|
day: "2-digit",
|
||||||
options={{
|
hour: "2-digit",
|
||||||
year: "numeric",
|
minute: "2-digit",
|
||||||
month: "2-digit",
|
second: "2-digit",
|
||||||
day: "2-digit",
|
}}
|
||||||
hour: "2-digit",
|
sortable={false}
|
||||||
minute: "2-digit",
|
/>
|
||||||
second: "2-digit",
|
<TextField
|
||||||
}}
|
source="user_agent"
|
||||||
sortable={false}
|
sortable={false}
|
||||||
/>
|
style={{ width: "100%" }}
|
||||||
<TextField
|
/>
|
||||||
source="user_agent"
|
</Datagrid>
|
||||||
sortable={false}
|
</ArrayField>
|
||||||
style={{ width: "100%" }}
|
</ReferenceField>
|
||||||
/>
|
</FormTab>
|
||||||
</Datagrid>
|
</TabbedForm>
|
||||||
</ArrayField>
|
</Edit>
|
||||||
</ReferenceField>
|
);
|
||||||
</FormTab>
|
|
||||||
</TabbedForm>
|
|
||||||
</Edit>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|||||||
+13
-69
@@ -4,12 +4,13 @@ export default {
|
|||||||
...germanMessages,
|
...germanMessages,
|
||||||
synapseadmin: {
|
synapseadmin: {
|
||||||
auth: {
|
auth: {
|
||||||
base_url: "Heimserver URL",
|
homeserver: "Heimserver",
|
||||||
welcome: "Willkommen bei Synapse-admin",
|
welcome: "Willkommen bei Synapse-admin",
|
||||||
server_version: "Synapse Version",
|
},
|
||||||
username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'",
|
action: {
|
||||||
protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen",
|
save_and_show: "Speichern und QR Code erzeugen",
|
||||||
url_error: "Keine gültige Matrix Server URL",
|
save_only: "Nur speichern",
|
||||||
|
download_pdf: "PDF speichern",
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id:
|
invalid_user_id:
|
||||||
@@ -17,12 +18,13 @@ export default {
|
|||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
details: "Raumdetails",
|
details: "Raumdetails",
|
||||||
tabs: {
|
room_name: "Raumname",
|
||||||
basic: "Allgemein",
|
make_public: "Öffentlicher Raum",
|
||||||
members: "Mitglieder",
|
room_name_required: "Muss angegeben werden",
|
||||||
detail: "Details",
|
alias_required_if_public: "Muss für öffentliche Räume angegeben werden.",
|
||||||
permission: "Berechtigungen",
|
alias: "Alias",
|
||||||
},
|
alias_too_long:
|
||||||
|
"Darf zusammen mit der Domain des Homeservers 255 bytes nicht überschreiten",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
@@ -31,7 +33,6 @@ 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",
|
||||||
@@ -45,12 +46,9 @@ 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.",
|
||||||
@@ -67,36 +65,6 @@ export default {
|
|||||||
name: "Name",
|
name: "Name",
|
||||||
canonical_alias: "Alias",
|
canonical_alias: "Alias",
|
||||||
joined_members: "Mitglieder",
|
joined_members: "Mitglieder",
|
||||||
joined_local_members: "Lokale Mitglieder",
|
|
||||||
state_events: "Ereignisse",
|
|
||||||
version: "Version",
|
|
||||||
is_encrypted: "Verschlüsselt",
|
|
||||||
encryption: "Verschlüsselungs-Algorithmus",
|
|
||||||
federatable: "Föderierbar",
|
|
||||||
public: "Öffentlich",
|
|
||||||
creator: "Ersteller",
|
|
||||||
join_rules: "Beitrittsregeln",
|
|
||||||
guest_access: "Gastzugriff",
|
|
||||||
history_visibility: "Historie-Sichtbarkeit",
|
|
||||||
},
|
|
||||||
enums: {
|
|
||||||
join_rules: {
|
|
||||||
public: "Öffentlich",
|
|
||||||
knock: "Auf Anfrage",
|
|
||||||
invite: "Nur auf Einladung",
|
|
||||||
private: "Privat",
|
|
||||||
},
|
|
||||||
guest_access: {
|
|
||||||
can_join: "Gäste können 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: {
|
||||||
@@ -107,29 +75,9 @@ export default {
|
|||||||
user_agent: "User Agent",
|
user_agent: "User Agent",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
servernotices: {
|
|
||||||
name: "Serverbenachrichtigungen",
|
|
||||||
send: "Servernachricht versenden",
|
|
||||||
fields: {
|
|
||||||
body: "Nachricht",
|
|
||||||
},
|
|
||||||
action: {
|
|
||||||
send: "Sende Nachricht",
|
|
||||||
send_success: "Nachricht erfolgreich versendet.",
|
|
||||||
send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
|
|
||||||
},
|
|
||||||
helper: {
|
|
||||||
send:
|
|
||||||
'Sendet eine Serverbenachrichtigung an die ausgewählten Nutzer. Hierfür muss das Feature "Server Notices" auf dem Server aktiviert sein.',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
ra: {
|
ra: {
|
||||||
...germanMessages.ra,
|
...germanMessages.ra,
|
||||||
auth: {
|
|
||||||
...germanMessages.ra.auth,
|
|
||||||
auth_check_error: "Anmeldung fehlgeschlagen",
|
|
||||||
},
|
|
||||||
input: {
|
input: {
|
||||||
...germanMessages.ra.input,
|
...germanMessages.ra.input,
|
||||||
password: {
|
password: {
|
||||||
@@ -138,9 +86,5 @@ export default {
|
|||||||
toggle_visible: "Verstecken",
|
toggle_visible: "Verstecken",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
notification: {
|
|
||||||
...germanMessages.ra.notifiaction,
|
|
||||||
logged_out: "Abgemeldet",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+14
-60
@@ -4,23 +4,27 @@ export default {
|
|||||||
...englishMessages,
|
...englishMessages,
|
||||||
synapseadmin: {
|
synapseadmin: {
|
||||||
auth: {
|
auth: {
|
||||||
base_url: "Homeserver URL",
|
homeserver: "Homeserver",
|
||||||
welcome: "Welcome to Synapse-admin",
|
welcome: "Welcome to Synapse-admin",
|
||||||
username_error: "Please enter fully qualified user ID: '@user:domain'",
|
},
|
||||||
protocol_error: "URL has to start with 'http://' or 'https://'",
|
action: {
|
||||||
url_error: "Not a valid Matrix server URL",
|
save_and_show: "Create QR code",
|
||||||
|
save_only: "Save",
|
||||||
|
download_pdf: "Download PDF",
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id:
|
invalid_user_id:
|
||||||
"Must be a fully qualified Matrix user-id, e.g. @user_id:homeserver",
|
"Must be a fully qualified Matrix user-id, e.g. @user_id:homeserver",
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
tabs: {
|
details: "Room Details",
|
||||||
basic: "Basic",
|
room_name: "Room Name",
|
||||||
members: "Members",
|
make_public: "Make room public",
|
||||||
detail: "Details",
|
room_name_required: "Must be provided",
|
||||||
permission: "Permissions",
|
alias_required_if_public: "Must be provided for a public room",
|
||||||
},
|
alias: "Alias",
|
||||||
|
alias_too_long:
|
||||||
|
"Must not exceed 255 bytes including the domain of the homeserver.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
@@ -29,7 +33,6 @@ 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",
|
||||||
@@ -43,12 +46,9 @@ 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",
|
||||||
@@ -65,36 +65,6 @@ export default {
|
|||||||
name: "Name",
|
name: "Name",
|
||||||
canonical_alias: "Alias",
|
canonical_alias: "Alias",
|
||||||
joined_members: "Members",
|
joined_members: "Members",
|
||||||
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: {
|
|
||||||
join_rules: {
|
|
||||||
public: "Public",
|
|
||||||
knock: "Knock",
|
|
||||||
invite: "Invite",
|
|
||||||
private: "Private",
|
|
||||||
},
|
|
||||||
guest_access: {
|
|
||||||
can_join: "Guests can join",
|
|
||||||
forbidden: "Guests can not join",
|
|
||||||
},
|
|
||||||
history_visibility: {
|
|
||||||
invited: "Since invited",
|
|
||||||
joined: "Since joined",
|
|
||||||
shared: "Since shared",
|
|
||||||
world_readable: "Anyone",
|
|
||||||
},
|
|
||||||
unencrypted: "Unencrypted",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
connections: {
|
connections: {
|
||||||
@@ -105,21 +75,5 @@ export default {
|
|||||||
user_agent: "User agent",
|
user_agent: "User agent",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
servernotices: {
|
|
||||||
name: "Server Notices",
|
|
||||||
send: "Send server notices",
|
|
||||||
fields: {
|
|
||||||
body: "Message",
|
|
||||||
},
|
|
||||||
action: {
|
|
||||||
send: "Send note",
|
|
||||||
send_success: "Server notice successfully sent.",
|
|
||||||
send_failure: "An error has occurred.",
|
|
||||||
},
|
|
||||||
helper: {
|
|
||||||
send:
|
|
||||||
'Sends a server notice to the selected users. The feature "Server Notices" has to be activated at the server.',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,23 @@
|
|||||||
import { fetchUtils } from "react-admin";
|
import { fetchUtils } from "react-admin";
|
||||||
|
|
||||||
|
const ensureHttpsForUrl = url => {
|
||||||
|
if (/^https:\/\//i.test(url)) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
const domain = url.replace(/http.?:\/\//g, "");
|
||||||
|
return "https://" + domain;
|
||||||
|
};
|
||||||
|
|
||||||
|
const stripTrailingSlash = str => {
|
||||||
|
if (!str) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return str.endsWith("/") ? str.slice(0, -1) : str;
|
||||||
|
};
|
||||||
|
|
||||||
const authProvider = {
|
const authProvider = {
|
||||||
// called when the user attempts to log in
|
// called when the user attempts to log in
|
||||||
login: ({ base_url, username, password }) => {
|
login: ({ homeserver, username, password }) => {
|
||||||
console.log("login ");
|
console.log("login ");
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -13,16 +28,17 @@ const authProvider = {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
// use the base_url from login instead of the well_known entry from the
|
const url = window.decodeURIComponent(homeserver);
|
||||||
// server, since the admin might want to access the admin API via some
|
const trimmed_url = url.trim().replace(/\s/g, "");
|
||||||
// private address
|
const login_api_url =
|
||||||
localStorage.setItem("base_url", base_url);
|
ensureHttpsForUrl(trimmed_url) + "/_matrix/client/r0/login";
|
||||||
|
|
||||||
const decoded_base_url = window.decodeURIComponent(base_url);
|
|
||||||
const login_api_url = decoded_base_url + "/_matrix/client/r0/login";
|
|
||||||
|
|
||||||
return fetchUtils.fetchJson(login_api_url, options).then(({ json }) => {
|
return fetchUtils.fetchJson(login_api_url, options).then(({ json }) => {
|
||||||
localStorage.setItem("home_server", json.home_server);
|
const normalized_base_url = stripTrailingSlash(
|
||||||
|
json.well_known["m.homeserver"].base_url
|
||||||
|
);
|
||||||
|
localStorage.setItem("base_url", normalized_base_url);
|
||||||
|
localStorage.setItem("home_server_url", json.home_server);
|
||||||
localStorage.setItem("user_id", json.user_id);
|
localStorage.setItem("user_id", json.user_id);
|
||||||
localStorage.setItem("access_token", json.access_token);
|
localStorage.setItem("access_token", json.access_token);
|
||||||
localStorage.setItem("device_id", json.device_id);
|
localStorage.setItem("device_id", json.device_id);
|
||||||
|
|||||||
+29
-84
@@ -14,37 +14,18 @@ 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,
|
||||||
// need timestamp in milliseconds
|
|
||||||
creation_ts_ms: u.creation_ts * 1000,
|
|
||||||
}),
|
}),
|
||||||
data: "users",
|
data: "users",
|
||||||
total: json => json.total,
|
total: json => json.total,
|
||||||
create: data => ({
|
|
||||||
endpoint: `/_synapse/admin/v2/users/${data.id}`,
|
|
||||||
body: data,
|
|
||||||
method: "PUT",
|
|
||||||
}),
|
|
||||||
delete: id => ({
|
delete: id => ({
|
||||||
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
||||||
body: { erase: true },
|
body: { erase: true },
|
||||||
@@ -56,16 +37,19 @@ 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 => {
|
total: json => json.total_rooms,
|
||||||
return json.total_rooms;
|
create: params => ({
|
||||||
},
|
method: "POST",
|
||||||
|
endpoint: "/_matrix/client/r0/createRoom",
|
||||||
|
body: {
|
||||||
|
name: params.data.name,
|
||||||
|
room_alias_name: params.data.canonical_alias,
|
||||||
|
visibility: params.data.public ? "public" : "private",
|
||||||
|
},
|
||||||
|
map: r => ({ id: r.room_id }),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
connections: {
|
connections: {
|
||||||
path: "/_synapse/admin/v1/whois",
|
path: "/_synapse/admin/v1/whois",
|
||||||
@@ -75,20 +59,6 @@ const resourceMap = {
|
|||||||
}),
|
}),
|
||||||
data: "connections",
|
data: "connections",
|
||||||
},
|
},
|
||||||
servernotices: {
|
|
||||||
map: n => ({ id: n.event_id }),
|
|
||||||
create: data => ({
|
|
||||||
endpoint: "/_synapse/admin/v1/send_server_notice",
|
|
||||||
body: {
|
|
||||||
user_id: data.id,
|
|
||||||
content: {
|
|
||||||
msgtype: "m.text",
|
|
||||||
body: data.body,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
method: "POST",
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function filterNullValues(key, value) {
|
function filterNullValues(key, value) {
|
||||||
@@ -99,20 +69,11 @@ 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,
|
||||||
@@ -120,8 +81,6 @@ 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();
|
||||||
@@ -233,39 +192,25 @@ const dataProvider = {
|
|||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
if (!("create" in res)) return Promise.reject();
|
|
||||||
|
|
||||||
const create = res["create"](params.data);
|
if ("create" in res) {
|
||||||
const endpoint_url = homeserver + create.endpoint;
|
const create = res["create"](params);
|
||||||
return jsonClient(endpoint_url, {
|
const endpoint_url = homeserver + create.endpoint;
|
||||||
method: create.method,
|
return jsonClient(endpoint_url, {
|
||||||
body: JSON.stringify(create.body, filterNullValues),
|
method: create.method,
|
||||||
}).then(({ json }) => ({
|
body: JSON.stringify(create.body, filterNullValues),
|
||||||
data: res.map(json),
|
}).then(({ json }) => ({
|
||||||
}));
|
data: create.map(json),
|
||||||
},
|
}));
|
||||||
|
} else {
|
||||||
createMany: (resource, params) => {
|
const endpoint_url = homeserver + res.path;
|
||||||
console.log("createMany " + resource);
|
return jsonClient(`${endpoint_url}/${params.data.id}`, {
|
||||||
const homeserver = localStorage.getItem("base_url");
|
method: "PUT",
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
body: JSON.stringify(params.data, filterNullValues),
|
||||||
|
}).then(({ json }) => ({
|
||||||
const res = resourceMap[resource];
|
data: res.map(json),
|
||||||
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) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user