Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7f009e559 | |||
| 2240559f74 | |||
| 445c7fc327 | |||
| 965645874c | |||
| 185d71e5fc | |||
| 7ef6bc05c6 | |||
| dfc643a10f | |||
| fccf23c64c | |||
| e4dd013c19 | |||
| 7eeb60539f | |||
| d099e582e0 | |||
| 0a241539f2 | |||
| 316d674060 | |||
| 40b5031550 | |||
| 475aa11f06 |
+2
-1
@@ -6,5 +6,6 @@
|
|||||||
"singleQuote": false,
|
"singleQuote": false,
|
||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"bracketSpacing": true,
|
"bracketSpacing": true,
|
||||||
"jsxBracketSameLine": false
|
"jsxBracketSameLine": false,
|
||||||
|
"arrowParens": "avoid",
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-12
@@ -10,25 +10,22 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@testing-library/jest-dom": "^5.1.1",
|
"@testing-library/jest-dom": "^5.1.1",
|
||||||
"@testing-library/react": "^9.4.0",
|
"@testing-library/react": "^10.0.2",
|
||||||
"@testing-library/user-event": "^8.1.0",
|
"@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",
|
||||||
"eslint-config-prettier": "^6.10.0",
|
"eslint-config-prettier": "^6.10.1",
|
||||||
"eslint-plugin-prettier": "^3.1.2",
|
"eslint-plugin-prettier": "^3.1.2",
|
||||||
"prettier": "^1.19.1"
|
"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.12.0",
|
"react": "^16.13.1",
|
||||||
"react-admin": "^3.1.3",
|
"react-admin": "^3.4.0",
|
||||||
"react-dom": "^16.12.0",
|
"react-dom": "^16.13.1",
|
||||||
"react-scripts": "^3.3.0"
|
"react-scripts": "^3.4.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
@@ -36,7 +33,7 @@
|
|||||||
"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",
|
||||||
"prettier": "prettier \"**/*.{json,md,scss,yaml,yml}\"",
|
"prettier": "prettier \"**/*.{js,jsx,json,md,scss,yaml,yml}\"",
|
||||||
"test:code": "react-scripts test",
|
"test:code": "react-scripts test",
|
||||||
"test:lint": "eslint --ignore-path .gitignore --ext .js,.jsx .",
|
"test:lint": "eslint --ignore-path .gitignore --ext .js,.jsx .",
|
||||||
"test:style": "yarn prettier --list-different",
|
"test:style": "yarn prettier --list-different",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 358 KiB |
+1
-5
@@ -10,8 +10,6 @@ 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 = {
|
||||||
@@ -29,9 +27,6 @@ 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"
|
||||||
@@ -41,6 +36,7 @@ const App = () => (
|
|||||||
icon={UserIcon}
|
icon={UserIcon}
|
||||||
/>
|
/>
|
||||||
<Resource name="rooms" list={RoomList} icon={RoomIcon} />
|
<Resource name="rooms" list={RoomList} icon={RoomIcon} />
|
||||||
|
<Resource name="connections" />
|
||||||
</Admin>
|
</Admin>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -70,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 homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
|
|
||||||
const renderInput = ({
|
const renderInput = ({
|
||||||
meta: { touched, error } = {},
|
meta: { touched, error } = {},
|
||||||
|
|||||||
@@ -1,133 +0,0 @@
|
|||||||
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: {
|
|
||||||
height: 90,
|
|
||||||
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;
|
|
||||||
@@ -1,8 +1,12 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Datagrid, List, TextField } from "react-admin";
|
import { Datagrid, List, TextField, Pagination } from "react-admin";
|
||||||
|
|
||||||
|
const RoomPagination = props => (
|
||||||
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||||
|
);
|
||||||
|
|
||||||
export const RoomList = props => (
|
export const RoomList = props => (
|
||||||
<List {...props}>
|
<List {...props} pagination={<RoomPagination />}>
|
||||||
<Datagrid>
|
<Datagrid>
|
||||||
<TextField source="room_id" />
|
<TextField source="room_id" />
|
||||||
<TextField source="name" />
|
<TextField source="name" />
|
||||||
|
|||||||
+118
-81
@@ -1,11 +1,20 @@
|
|||||||
import React from "react";
|
import React, { Fragment } from "react";
|
||||||
|
import PersonPinIcon from "@material-ui/icons/PersonPin";
|
||||||
|
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
|
||||||
import {
|
import {
|
||||||
|
ArrayInput,
|
||||||
|
ArrayField,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
DateField,
|
||||||
Create,
|
Create,
|
||||||
Edit,
|
Edit,
|
||||||
List,
|
List,
|
||||||
Filter,
|
Filter,
|
||||||
|
Toolbar,
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
|
SimpleFormIterator,
|
||||||
|
TabbedForm,
|
||||||
|
FormTab,
|
||||||
BooleanField,
|
BooleanField,
|
||||||
BooleanInput,
|
BooleanInput,
|
||||||
ImageField,
|
ImageField,
|
||||||
@@ -13,11 +22,19 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
TextInput,
|
TextInput,
|
||||||
ReferenceField,
|
ReferenceField,
|
||||||
|
SelectInput,
|
||||||
|
BulkDeleteButton,
|
||||||
|
DeleteButton,
|
||||||
SaveButton,
|
SaveButton,
|
||||||
Toolbar,
|
|
||||||
regex,
|
regex,
|
||||||
|
useTranslate,
|
||||||
|
Pagination,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
|
|
||||||
|
const UserPagination = props => (
|
||||||
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||||
|
);
|
||||||
|
|
||||||
const UserFilter = props => (
|
const UserFilter = props => (
|
||||||
<Filter {...props}>
|
<Filter {...props}>
|
||||||
<BooleanInput source="guests" alwaysOn />
|
<BooleanInput source="guests" alwaysOn />
|
||||||
@@ -29,12 +46,26 @@ const UserFilter = props => (
|
|||||||
</Filter>
|
</Filter>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const UserBulkActionButtons = props => {
|
||||||
|
const translate = useTranslate();
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<BulkDeleteButton
|
||||||
|
{...props}
|
||||||
|
label="resources.users.action.erase"
|
||||||
|
title={translate("resources.users.helper.erase")}
|
||||||
|
/>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const UserList = props => (
|
export const UserList = props => (
|
||||||
<List
|
<List
|
||||||
{...props}
|
{...props}
|
||||||
filters={<UserFilter />}
|
filters={<UserFilter />}
|
||||||
filterDefaultValues={{ guests: true, deactivated: false }}
|
filterDefaultValues={{ guests: true, deactivated: false }}
|
||||||
bulkActionButtons={false}
|
bulkActionButtons={<UserBulkActionButtons />}
|
||||||
|
pagination={<UserPagination />}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick="edit">
|
<Datagrid rowClick="edit">
|
||||||
<ReferenceField
|
<ReferenceField
|
||||||
@@ -62,100 +93,106 @@ export const UserList = props => (
|
|||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
function generateRandomUser() {
|
|
||||||
const homeserver = localStorage.getItem("home_server");
|
|
||||||
const user_id =
|
|
||||||
"@" +
|
|
||||||
Array(8)
|
|
||||||
.fill("0123456789abcdefghijklmnopqrstuvwxyz")
|
|
||||||
.map(
|
|
||||||
x =>
|
|
||||||
x[
|
|
||||||
Math.floor(
|
|
||||||
(crypto.getRandomValues(new Uint32Array(1))[0] /
|
|
||||||
(0xffffffff + 1)) *
|
|
||||||
x.length
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
.join("") +
|
|
||||||
":" +
|
|
||||||
homeserver;
|
|
||||||
|
|
||||||
const password = Array(20)
|
|
||||||
.fill(
|
|
||||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$"
|
|
||||||
)
|
|
||||||
.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}>
|
|
||||||
<SaveButton
|
|
||||||
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._=\-/]+:.*/,
|
||||||
"synapseadmin.users.invalid_user_id"
|
"synapseadmin.users.invalid_user_id"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const UserEditToolbar = props => {
|
||||||
|
const translate = useTranslate();
|
||||||
|
return (
|
||||||
|
<Toolbar {...props}>
|
||||||
|
<SaveButton submitOnEnter={true} />
|
||||||
|
<DeleteButton
|
||||||
|
label="resources.users.action.erase"
|
||||||
|
title={translate("resources.users.helper.erase")}
|
||||||
|
/>
|
||||||
|
</Toolbar>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const UserCreate = props => (
|
export const UserCreate = props => (
|
||||||
<Create record={generateRandomUser()} {...props}>
|
<Create {...props}>
|
||||||
<SimpleForm toolbar={<UserCreateToolbar />}>
|
<SimpleForm>
|
||||||
<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" />
|
||||||
<BooleanInput source="admin" />
|
<BooleanInput source="admin" />
|
||||||
|
<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>
|
||||||
</SimpleForm>
|
</SimpleForm>
|
||||||
</Create>
|
</Create>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const UserEdit = props => (
|
export const UserEdit = props => (
|
||||||
<Edit {...props}>
|
<Edit {...props}>
|
||||||
<SimpleForm toolbar={<UserCreateToolbar />}>
|
<TabbedForm toolbar={<UserEditToolbar />}>
|
||||||
<TextInput source="id" disabled />
|
<FormTab label="resources.users.name" icon={<PersonPinIcon />}>
|
||||||
<TextInput source="displayname" />
|
<TextInput source="id" disabled />
|
||||||
<PasswordInput source="password" autoComplete="new-password" />
|
<TextInput source="displayname" />
|
||||||
<BooleanInput source="admin" />
|
<PasswordInput source="password" autoComplete="new-password" />
|
||||||
<BooleanInput source="deactivated" />
|
<BooleanInput source="admin" />
|
||||||
</SimpleForm>
|
<BooleanInput
|
||||||
|
source="deactivated"
|
||||||
|
helperText="resources.users.helper.deactivate"
|
||||||
|
/>
|
||||||
|
<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 />}
|
||||||
|
>
|
||||||
|
<ReferenceField reference="connections" source="id" addLabel={false}>
|
||||||
|
<ArrayField
|
||||||
|
source="devices[].sessions[0].connections"
|
||||||
|
label="resources.connections.name"
|
||||||
|
>
|
||||||
|
<Datagrid style={{ width: "100%" }}>
|
||||||
|
<TextField source="ip" sortable={false} />
|
||||||
|
<DateField
|
||||||
|
source="last_seen"
|
||||||
|
showTime
|
||||||
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
|
sortable={false}
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
source="user_agent"
|
||||||
|
sortable={false}
|
||||||
|
style={{ width: "100%" }}
|
||||||
|
/>
|
||||||
|
</Datagrid>
|
||||||
|
</ArrayField>
|
||||||
|
</ReferenceField>
|
||||||
|
</FormTab>
|
||||||
|
</TabbedForm>
|
||||||
</Edit>
|
</Edit>
|
||||||
);
|
);
|
||||||
|
|||||||
+22
-5
@@ -7,11 +7,6 @@ export default {
|
|||||||
homeserver: "Heimserver",
|
homeserver: "Heimserver",
|
||||||
welcome: "Willkommen bei Synapse-admin",
|
welcome: "Willkommen bei Synapse-admin",
|
||||||
},
|
},
|
||||||
action: {
|
|
||||||
save_and_show: "QR Code erzeugen",
|
|
||||||
save_only: "Speichern",
|
|
||||||
download_pdf: "PDF speichern",
|
|
||||||
},
|
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id:
|
invalid_user_id:
|
||||||
"Muss eine vollständige Matrix Benutzer-ID sein, z.B. @benutzer_id:homeserver",
|
"Muss eine vollständige Matrix Benutzer-ID sein, z.B. @benutzer_id:homeserver",
|
||||||
@@ -19,7 +14,10 @@ export default {
|
|||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
users: {
|
users: {
|
||||||
|
backtolist: "Zurück zur Liste",
|
||||||
name: "Benutzer",
|
name: "Benutzer",
|
||||||
|
email: "E-Mail",
|
||||||
|
msisdn: "Telefon",
|
||||||
fields: {
|
fields: {
|
||||||
avatar: "Avatar",
|
avatar: "Avatar",
|
||||||
id: "Benutzer-ID",
|
id: "Benutzer-ID",
|
||||||
@@ -32,6 +30,17 @@ export default {
|
|||||||
user_id: "Suche Benutzer",
|
user_id: "Suche Benutzer",
|
||||||
displayname: "Anzeigename",
|
displayname: "Anzeigename",
|
||||||
password: "Passwort",
|
password: "Passwort",
|
||||||
|
avatar_url: "Avatar URL",
|
||||||
|
medium: "Medium",
|
||||||
|
threepids: "3PIDs",
|
||||||
|
address: "Adresse",
|
||||||
|
},
|
||||||
|
helper: {
|
||||||
|
deactivate: "Deaktivierte Nutzer können nicht wieder aktiviert werden.",
|
||||||
|
erase: "DSGVO konformes Löschen der Benutzerdaten",
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
erase: "Lösche Benutzerdaten",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
@@ -43,5 +52,13 @@ export default {
|
|||||||
joined_members: "Mitglieder",
|
joined_members: "Mitglieder",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
connections: {
|
||||||
|
name: "Verbindungen",
|
||||||
|
fields: {
|
||||||
|
last_seen: "Datum",
|
||||||
|
ip: "IP-Adresse",
|
||||||
|
user_agent: "User Agent",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+22
-5
@@ -7,11 +7,6 @@ export default {
|
|||||||
homeserver: "Homeserver",
|
homeserver: "Homeserver",
|
||||||
welcome: "Welcome to Synapse-admin",
|
welcome: "Welcome to Synapse-admin",
|
||||||
},
|
},
|
||||||
action: {
|
|
||||||
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",
|
||||||
@@ -19,7 +14,10 @@ export default {
|
|||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
users: {
|
users: {
|
||||||
|
backtolist: "Back to list",
|
||||||
name: "User |||| Users",
|
name: "User |||| Users",
|
||||||
|
email: "Email",
|
||||||
|
msisdn: "Phone",
|
||||||
fields: {
|
fields: {
|
||||||
avatar: "Avatar",
|
avatar: "Avatar",
|
||||||
id: "User-ID",
|
id: "User-ID",
|
||||||
@@ -32,6 +30,17 @@ export default {
|
|||||||
user_id: "Search user",
|
user_id: "Search user",
|
||||||
displayname: "Displayname",
|
displayname: "Displayname",
|
||||||
password: "Password",
|
password: "Password",
|
||||||
|
avatar_url: "Avatar URL",
|
||||||
|
medium: "Medium",
|
||||||
|
threepids: "3PIDs",
|
||||||
|
address: "Address",
|
||||||
|
},
|
||||||
|
helper: {
|
||||||
|
deactivate: "Deactivated users cannot be reactivated",
|
||||||
|
erase: "Mark the user as GDPR-erased",
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
erase: "Erase user data",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
@@ -43,5 +52,13 @@ export default {
|
|||||||
joined_members: "Members",
|
joined_members: "Members",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
connections: {
|
||||||
|
name: "Connections",
|
||||||
|
fields: {
|
||||||
|
last_seen: "Date",
|
||||||
|
ip: "IP address",
|
||||||
|
user_agent: "User agent",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
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: ({ homeserver, username, password }) => {
|
login: ({ homeserver, username, password }) => {
|
||||||
@@ -13,16 +28,17 @@ const authProvider = {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
// add 'https://' to homeserver url if its missing
|
const url = window.decodeURIComponent(homeserver);
|
||||||
let newUrl = window.decodeURIComponent(homeserver);
|
const trimmed_url = url.trim().replace(/\s/g, "");
|
||||||
newUrl = newUrl.trim().replace(/\s/g, "");
|
const login_api_url =
|
||||||
if (!/^https?:\/\//i.test(newUrl)) {
|
ensureHttpsForUrl(trimmed_url) + "/_matrix/client/r0/login";
|
||||||
homeserver = `https://${newUrl}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = homeserver + "/_matrix/client/r0/login";
|
return fetchUtils.fetchJson(login_api_url, options).then(({ json }) => {
|
||||||
return fetchUtils.fetchJson(url, options).then(({ json }) => {
|
const normalized_base_url = stripTrailingSlash(
|
||||||
localStorage.setItem("home_server", json.home_server);
|
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);
|
||||||
|
|||||||
+92
-45
@@ -25,9 +25,16 @@ const resourceMap = {
|
|||||||
deactivated: !!u.deactivated,
|
deactivated: !!u.deactivated,
|
||||||
}),
|
}),
|
||||||
data: "users",
|
data: "users",
|
||||||
total: (json, perPage) => {
|
total: (json, from, perPage) => {
|
||||||
return parseInt(json.next_token, 10) + perPage;
|
return json.next_token
|
||||||
|
? parseInt(json.next_token, 10) + perPage
|
||||||
|
: from + json.users.length;
|
||||||
},
|
},
|
||||||
|
delete: id => ({
|
||||||
|
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
||||||
|
body: { erase: true },
|
||||||
|
method: "POST",
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
path: "/_synapse/admin/v1/rooms",
|
path: "/_synapse/admin/v1/rooms",
|
||||||
@@ -42,6 +49,14 @@ const resourceMap = {
|
|||||||
return json.total_rooms;
|
return json.total_rooms;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
connections: {
|
||||||
|
path: "/_synapse/admin/v1/whois",
|
||||||
|
map: c => ({
|
||||||
|
...c,
|
||||||
|
id: c.user_id,
|
||||||
|
}),
|
||||||
|
data: "connections",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function filterNullValues(key, value) {
|
function filterNullValues(key, value) {
|
||||||
@@ -55,34 +70,38 @@ function filterNullValues(key, value) {
|
|||||||
const dataProvider = {
|
const dataProvider = {
|
||||||
getList: (resource, params) => {
|
getList: (resource, params) => {
|
||||||
console.log("getList " + resource);
|
console.log("getList " + resource);
|
||||||
const { user_id, guests } = params.filter;
|
const { user_id, guests, deactivated } = params.filter;
|
||||||
const { page, perPage } = params.pagination;
|
const { page, perPage } = params.pagination;
|
||||||
|
const from = (page - 1) * perPage;
|
||||||
const query = {
|
const query = {
|
||||||
from: (page - 1) * perPage,
|
from: from,
|
||||||
limit: perPage,
|
limit: perPage,
|
||||||
user_id: user_id,
|
user_id: user_id,
|
||||||
guests: guests,
|
guests: guests,
|
||||||
|
deactivated: deactivated,
|
||||||
};
|
};
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
const url = `${homeserver_url}?${stringify(query)}`;
|
const url = `${homeserver_url}?${stringify(query)}`;
|
||||||
|
|
||||||
return jsonClient(url).then(({ json }) => ({
|
return jsonClient(url).then(({ json }) => ({
|
||||||
data: json[res.data].map(res.map),
|
data: json[res.data].map(res.map),
|
||||||
total: res.total(json, perPage),
|
total: res.total(json, from, perPage),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
getOne: (resource, params) => {
|
getOne: (resource, params) => {
|
||||||
console.log("getOne " + resource);
|
console.log("getOne " + resource);
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
return jsonClient(`${homeserver_url}/${params.id}`).then(({ json }) => ({
|
return jsonClient(`${homeserver_url}/${params.id}`).then(({ json }) => ({
|
||||||
data: res.map(json),
|
data: res.map(json),
|
||||||
}));
|
}));
|
||||||
@@ -90,11 +109,12 @@ const dataProvider = {
|
|||||||
|
|
||||||
getMany: (resource, params) => {
|
getMany: (resource, params) => {
|
||||||
console.log("getMany " + resource);
|
console.log("getMany " + resource);
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
params.ids.map(id => jsonClient(`${homeserver_url}/${id}`))
|
params.ids.map(id => jsonClient(`${homeserver_url}/${id}`))
|
||||||
).then(responses => ({
|
).then(responses => ({
|
||||||
@@ -116,32 +136,28 @@ const dataProvider = {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
const url = `${homeserver_url}?${stringify(query)}`;
|
const url = `${homeserver_url}?${stringify(query)}`;
|
||||||
|
|
||||||
return jsonClient(url).then(({ headers, json }) => ({
|
return jsonClient(url).then(({ headers, json }) => ({
|
||||||
data: json,
|
data: json,
|
||||||
total: parseInt(
|
total: parseInt(headers.get("content-range").split("/").pop(), 10),
|
||||||
headers
|
|
||||||
.get("content-range")
|
|
||||||
.split("/")
|
|
||||||
.pop(),
|
|
||||||
10
|
|
||||||
),
|
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
update: (resource, params) => {
|
update: (resource, params) => {
|
||||||
console.log("update " + resource);
|
console.log("update " + resource);
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
return jsonClient(`${homeserver_url}/${params.data.id}`, {
|
return jsonClient(`${homeserver_url}/${params.data.id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify(params.data, filterNullValues),
|
body: JSON.stringify(params.data, filterNullValues),
|
||||||
@@ -152,11 +168,12 @@ const dataProvider = {
|
|||||||
|
|
||||||
updateMany: (resource, params) => {
|
updateMany: (resource, params) => {
|
||||||
console.log("updateMany " + resource);
|
console.log("updateMany " + resource);
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
params.ids.map(id => jsonClient(`${homeserver_url}/${id}`), {
|
params.ids.map(id => jsonClient(`${homeserver_url}/${id}`), {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
@@ -169,11 +186,12 @@ const dataProvider = {
|
|||||||
|
|
||||||
create: (resource, params) => {
|
create: (resource, params) => {
|
||||||
console.log("create " + resource);
|
console.log("create " + resource);
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
return jsonClient(`${homeserver_url}/${params.data.id}`, {
|
return jsonClient(`${homeserver_url}/${params.data.id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify(params.data, filterNullValues),
|
body: JSON.stringify(params.data, filterNullValues),
|
||||||
@@ -184,35 +202,64 @@ const dataProvider = {
|
|||||||
|
|
||||||
delete: (resource, params) => {
|
delete: (resource, params) => {
|
||||||
console.log("delete " + resource);
|
console.log("delete " + resource);
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
return jsonClient(`${homeserver_url}/${params.id}`, {
|
if ("delete" in res) {
|
||||||
method: "DELETE",
|
const del = res["delete"](params.id);
|
||||||
}).then(({ json }) => ({
|
const homeserver_url = homeserver + del.endpoint;
|
||||||
data: json,
|
return jsonClient(homeserver_url, {
|
||||||
}));
|
method: del.method,
|
||||||
|
body: JSON.stringify(del.body),
|
||||||
|
}).then(({ json }) => ({
|
||||||
|
data: json,
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
|
return jsonClient(`${homeserver_url}/${params.id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
body: JSON.stringify(params.data, filterNullValues),
|
||||||
|
}).then(({ json }) => ({
|
||||||
|
data: json,
|
||||||
|
}));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteMany: (resource, params) => {
|
deleteMany: (resource, params) => {
|
||||||
console.log("deleteMany " + resource);
|
console.log("deleteMany " + resource);
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
const homeserver_url = "https://" + homeserver + res.path;
|
|
||||||
return Promise.all(
|
if ("delete" in res) {
|
||||||
params.ids.map(id =>
|
return Promise.all(
|
||||||
jsonClient(`${homeserver_url}/${id}`, {
|
params.ids.map(id => {
|
||||||
method: "DELETE",
|
const del = res["delete"](id);
|
||||||
body: JSON.stringify(params.data, filterNullValues),
|
const homeserver_url = homeserver + del.endpoint;
|
||||||
}).then(responses => ({
|
return jsonClient(homeserver_url, {
|
||||||
data: responses.map(({ json }) => json),
|
method: del.method,
|
||||||
}))
|
body: JSON.stringify(del.body),
|
||||||
)
|
});
|
||||||
);
|
})
|
||||||
|
).then(responses => ({
|
||||||
|
data: responses.map(({ json }) => json),
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
|
return Promise.all(
|
||||||
|
params.ids.map(id =>
|
||||||
|
jsonClient(`${homeserver_url}/${id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
body: JSON.stringify(params.data, filterNullValues),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
).then(responses => ({
|
||||||
|
data: responses.map(({ json }) => json),
|
||||||
|
}));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user