Compare commits
32 Commits
master
...
AMP/2021.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b5c0e2845 | ||
|
|
da8cb12756 | ||
|
|
56a359b704 | ||
|
|
5906dcc129 | ||
|
|
270d48607a | ||
|
|
931fafc21d | ||
|
|
c604b47adc | ||
|
|
fb8cff3e3e | ||
|
|
725e24d944 | ||
|
|
dd00a76603 | ||
|
|
2915fd3e5b | ||
|
|
a4662c2557 | ||
|
|
f6ca169fbc | ||
|
|
07862591fd | ||
|
|
ab649fbf70 | ||
|
|
880223e5de | ||
|
|
76fdc80e3e | ||
|
|
375649756f | ||
|
|
662735a91f | ||
|
|
0823976edd | ||
|
|
d3cd2e9e33 | ||
|
|
24abcd4e4a | ||
|
|
c1c32e3268 | ||
|
|
ca15435625 | ||
|
|
e9c3901b68 | ||
|
|
7aec6f9369 | ||
|
|
d2a3f07a59 | ||
|
|
bf7867f106 | ||
|
|
f0e32abc4f | ||
|
|
61b1580735 | ||
|
|
0f7e4c1909 | ||
|
|
c9bce409d2 |
5
.env
5
.env
@@ -1,5 +0,0 @@
|
||||
# This setting allows to fix the homeserver.
|
||||
# If you set this setting, the user will not be able to select
|
||||
# the server and have to use synapse-admin with this server.
|
||||
|
||||
#REACT_APP_SERVER=https://yourmatrixserver.example.com
|
||||
21
.github/workflows/build-test.yml
vendored
21
.github/workflows/build-test.yml
vendored
@@ -1,21 +0,0 @@
|
||||
name: build-test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 14
|
||||
- name: Install dependencies
|
||||
run: yarn --frozen-lockfile
|
||||
- name: Run tests
|
||||
run: yarn test
|
||||
51
.github/workflows/docker-release.yml
vendored
51
.github/workflows/docker-release.yml
vendored
@@ -1,51 +0,0 @@
|
||||
name: Create docker image(s) and push to docker hub
|
||||
|
||||
on:
|
||||
push:
|
||||
# Sequence of patterns matched against refs/heads
|
||||
# prettier-ignore
|
||||
branches:
|
||||
# Push events on master branch
|
||||
- master
|
||||
# Sequence of patterns matched against refs/tags
|
||||
tags:
|
||||
- '[0-9]+\.[0-9]+\.[0-9]+' # Push events to 0.X.X tag
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Calculate docker image tag
|
||||
id: set-tag
|
||||
run: |
|
||||
case "${GITHUB_REF}" in
|
||||
refs/heads/master|refs/heads/main)
|
||||
tag=latest
|
||||
;;
|
||||
refs/tags/*)
|
||||
tag=${GITHUB_REF#refs/tags/}
|
||||
;;
|
||||
*)
|
||||
tag=${GITHUB_SHA}
|
||||
;;
|
||||
esac
|
||||
echo "::set-output name=tag::$tag"
|
||||
- name: Build and Push Tag
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: "awesometechnologies/synapse-admin:${{ steps.set-tag.outputs.tag }}"
|
||||
platforms: linux/amd64,linux/arm64
|
||||
26
.github/workflows/edge_ghpage.yml
vendored
26
.github/workflows/edge_ghpage.yml
vendored
@@ -1,26 +0,0 @@
|
||||
name: Build and Deploy Edge version to GH Pages
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout 🛎️
|
||||
uses: actions/checkout@v2.3.1
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "14"
|
||||
- name: Install and Build 🔧
|
||||
run: |
|
||||
yarn install
|
||||
yarn build
|
||||
|
||||
- name: Deploy 🚀
|
||||
uses: JamesIves/github-pages-deploy-action@4.1.5
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: build
|
||||
31
.github/workflows/github-release.yml
vendored
31
.github/workflows/github-release.yml
vendored
@@ -1,31 +0,0 @@
|
||||
name: Create release tarball and attach to tag
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "14"
|
||||
- run: yarn install
|
||||
- run: yarn build
|
||||
- run: |
|
||||
version=`git describe --dirty --tags || echo unknown`
|
||||
mkdir -p dist
|
||||
cp -r build synapse-admin-$version
|
||||
tar chvzf dist/synapse-admin-$version.tar.gz synapse-admin-$version
|
||||
- uses: softprops/action-gh-release@b7e450da2a4b4cb4bfbae528f788167786cfcedf
|
||||
with:
|
||||
files: dist/*.tar.gz
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -7,5 +7,5 @@
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false,
|
||||
"arrowParens": "avoid"
|
||||
"arrowParens": "avoid",
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- lts/*
|
||||
- 13
|
||||
|
||||
cache: yarn
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
# Builder
|
||||
FROM node:lts as builder
|
||||
|
||||
ARG PUBLIC_URL=/
|
||||
ARG REACT_APP_SERVER
|
||||
FROM node:current as builder
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY . /src
|
||||
RUN yarn --network-timeout=100000 install
|
||||
RUN PUBLIC_URL=$PUBLIC_URL REACT_APP_SERVER=$REACT_APP_SERVER yarn build
|
||||
RUN yarn build
|
||||
|
||||
|
||||
# App
|
||||
|
||||
69
README.md
69
README.md
@@ -1,72 +1,31 @@
|
||||
[](https://travis-ci.org/Awesome-Technologies/synapse-admin)
|
||||
[](https://github.com/Awesome-Technologies/synapse-admin/actions/workflows/build-test.yml)
|
||||
|
||||
# Synapse admin ui
|
||||
|
||||
This project is built using [react-admin](https://marmelab.com/react-admin/).
|
||||
|
||||
```
|
||||
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
|
||||
|
||||
## Run `sudo apt-get install -y nodejs` to install Node.js 14.x and npm
|
||||
## You may also need development tools to build native addons:
|
||||
sudo apt-get install gcc g++ make
|
||||
## To install the Yarn package manager, run:
|
||||
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
|
||||
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
|
||||
sudo apt-get update && sudo apt-get install yarn
|
||||
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Supported Synapse
|
||||
|
||||
It needs at least [Synapse](https://github.com/matrix-org/synapse) v1.42.0 for all functions to work as expected!
|
||||
It needs at least Synapse v1.27.0 for all functions to work as expected!
|
||||
|
||||
You get your server version with the request `/_synapse/admin/v1/server_version`.
|
||||
See also [Synapse version API](https://matrix-org.github.io/synapse/develop/admin_api/version_api.html).
|
||||
See also [Synapse version API](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/version_api.rst).
|
||||
|
||||
After entering the URL on the login page of synapse-admin the server version appears below the input field.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
You need access to the following endpoints:
|
||||
|
||||
- `/_matrix`
|
||||
- `/_synapse/admin`
|
||||
|
||||
See also [Synapse administration endpoints](https://matrix-org.github.io/synapse/develop/reverse_proxy.html#synapse-administration-endpoints)
|
||||
See also [Synapse administration endpoints](https://github.com/matrix-org/synapse/blob/develop/docs/reverse_proxy.md#synapse-administration-endpoints)
|
||||
|
||||
### Use without install
|
||||
## Step-By-Step install:
|
||||
|
||||
You can use the current version of Synapse Admin without own installation direct
|
||||
via [GitHub Pages](https://awesome-technologies.github.io/synapse-admin/).
|
||||
You have two options:
|
||||
|
||||
**Note:**
|
||||
If you want to use the deployment, you have to make sure that the admin endpoints (`/_synapse/admin`) are accessible for your browser.
|
||||
**Remember: You have no need to expose these endpoints to the internet but to your network.**
|
||||
If you want your own deployment, follow the [Step-By-Step Install Guide](#step-by-step-install) below.
|
||||
1. Download the source code from github and run using nodejs
|
||||
2. Run the Docker container
|
||||
|
||||
### Step-By-Step install
|
||||
|
||||
You have three options:
|
||||
|
||||
1. [Download the tarball and serve with any webserver](#steps-for-1)
|
||||
2. [Download the source code from github and run using nodejs](#steps-for-2)
|
||||
3. [Run the Docker container](#steps-for-3)
|
||||
|
||||
#### Steps for 1)
|
||||
|
||||
- make sure you have a webserver installed that can serve static files (any webserver like nginx or apache will do)
|
||||
- configure a vhost for synapse admin on your webserver
|
||||
- download the .tar.gz from the latest release: https://github.com/Awesome-Technologies/synapse-admin/releases/latest
|
||||
- unpack the .tar.gz
|
||||
- move or symlink the `synapse-admin-x.x.x` into your vhosts root dir
|
||||
- open the url of the vhost in your browser
|
||||
|
||||
#### Steps for 2)
|
||||
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`
|
||||
@@ -74,14 +33,9 @@ You have three options:
|
||||
- download dependencies: `yarn install`
|
||||
- start web server: `yarn start`
|
||||
|
||||
You can fix the homeserver, so that the user can no longer define it himself.
|
||||
Either you define it at startup (e.g. `REACT_APP_SERVER=https://yourmatrixserver.example.com yarn start`)
|
||||
or by editing it in the [.env](.env) file. See also the
|
||||
[documentation](https://create-react-app.dev/docs/adding-custom-environment-variables/).
|
||||
Steps for 2):
|
||||
|
||||
#### Steps for 3)
|
||||
|
||||
- run the Docker container from the public docker registry: `docker run -p 8080:80 awesometechnologies/synapse-admin` or use the [docker-compose.yml](docker-compose.yml): `docker-compose up -d`
|
||||
- run the Docker container from the public docker registry: `docker run -p 8080:80 awesometechnologies/synapse-admin` or use the (docker-compose.yml)[docker-compose.yml]: `docker-compose up -d`
|
||||
|
||||
> note: if you're building on an architecture other than amd64 (for example a raspberry pi), make sure to define a maximum ram for node. otherwise the build will fail.
|
||||
|
||||
@@ -96,9 +50,6 @@ or by editing it in the [.env](.env) file. See also the
|
||||
context: https://github.com/Awesome-Technologies/synapse-admin.git
|
||||
# args:
|
||||
# - NODE_OPTIONS="--max_old_space_size=1024"
|
||||
# # see #266
|
||||
# - PUBLIC_URL="/synapse-admin"
|
||||
# - REACT_APP_SERVER="https://matrix.example.com"
|
||||
ports:
|
||||
- "8080:80"
|
||||
restart: unless-stopped
|
||||
|
||||
30
package.json
30
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "synapse-admin",
|
||||
"version": "0.8.5",
|
||||
"version": "AMP/2021.05",
|
||||
"description": "Admin GUI for the Matrix.org server Synapse",
|
||||
"author": "Awesome Technologies Innovationslabor GmbH",
|
||||
"license": "Apache-2.0",
|
||||
@@ -11,24 +11,30 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/jest-dom": "^5.1.1",
|
||||
"@testing-library/react": "^11.2.6",
|
||||
"@testing-library/user-event": "^13.1.8",
|
||||
"eslint": "^7.25.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"@testing-library/react": "^10.0.2",
|
||||
"@testing-library/user-event": "^12.0.11",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-react-16": "^1.15.2",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.10.1",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"jest-fetch-mock": "^3.0.3",
|
||||
"prettier": "^2.2.0",
|
||||
"ra-test": "^3.15.0"
|
||||
"prettier": "^2.0.0",
|
||||
"ra-test": "^3.14.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@progress/kendo-drawing": "^1.6.0",
|
||||
"@progress/kendo-react-pdf": "^3.10.1",
|
||||
"babel-preset-jest": "^24.9.0",
|
||||
"papaparse": "^5.2.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"qrcode.react": "^1.0.0",
|
||||
"ra-language-chinese": "^2.0.10",
|
||||
"ra-language-german": "^3.13.4",
|
||||
"ra-language-german": "^2.1.2",
|
||||
"react": "^17.0.0",
|
||||
"react-admin": "^3.19.7",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-scripts": "^4.0.0"
|
||||
"react-admin": "^3.14.0",
|
||||
"react-dom": "^16.14.0",
|
||||
"react-scripts": "^3.4.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "REACT_APP_VERSION=$(git describe --tags) react-scripts start",
|
||||
@@ -36,7 +42,7 @@
|
||||
"fix:other": "yarn prettier --write",
|
||||
"fix:code": "yarn test:lint --fix",
|
||||
"fix": "yarn fix:code && yarn fix:other",
|
||||
"prettier": "prettier --ignore-path .gitignore \"**/*.{js,jsx,json,md,scss,yaml,yml}\"",
|
||||
"prettier": "prettier \"**/*.{js,jsx,json,md,scss,yaml,yml}\"",
|
||||
"test:code": "react-scripts test",
|
||||
"test:lint": "eslint --ignore-path .gitignore --ext .js,.jsx .",
|
||||
"test:style": "yarn prettier --list-different",
|
||||
|
||||
BIN
public/fonts/DejaVu/DejaVuSans-Bold.ttf
Normal file
BIN
public/fonts/DejaVu/DejaVuSans-Bold.ttf
Normal file
Binary file not shown.
BIN
public/fonts/DejaVu/DejaVuSans-Mono.ttf
Normal file
BIN
public/fonts/DejaVu/DejaVuSans-Mono.ttf
Normal file
Binary file not shown.
BIN
public/fonts/DejaVu/DejaVuSans-Oblique.ttf
Normal file
BIN
public/fonts/DejaVu/DejaVuSans-Oblique.ttf
Normal file
Binary file not shown.
BIN
public/fonts/DejaVu/DejaVuSans.ttf
Normal file
BIN
public/fonts/DejaVu/DejaVuSans.ttf
Normal file
Binary file not shown.
BIN
public/images/logo.png
Normal file
BIN
public/images/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 358 KiB |
@@ -9,6 +9,32 @@
|
||||
name="description"
|
||||
content="Synapse-Admin"
|
||||
/>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: "DejaVu Sans";
|
||||
src: url("%PUBLIC_URL%/fonts/DejaVu/DejaVuSans.ttf") format("truetype");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "DejaVu Sans";
|
||||
font-weight: bold;
|
||||
src: url("%PUBLIC_URL%/fonts/DejaVu/DejaVuSans-Bold.ttf") format("truetype");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "DejaVu Sans";
|
||||
font-style: italic;
|
||||
src: url("%PUBLIC_URL%/fonts/DejaVu/DejaVuSans-Oblique.ttf") format("truetype");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "DejaVu Sans";
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
src: url("%PUBLIC_URL%/fonts/DejaVu/DejaVuSans-Oblique.ttf") format("truetype");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "DejaVu Sans Mono";
|
||||
src: url("%PUBLIC_URL%/fonts/DejaVu/DejaVuSans-Mono.ttf") format("truetype");
|
||||
}
|
||||
</style>
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
@@ -46,4 +72,4 @@
|
||||
</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
29
src/App.js
29
src/App.js
@@ -4,27 +4,22 @@ import polyglotI18nProvider from "ra-i18n-polyglot";
|
||||
import authProvider from "./synapse/authProvider";
|
||||
import dataProvider from "./synapse/dataProvider";
|
||||
import { UserList, UserCreate, UserEdit } from "./components/users";
|
||||
import { RoomList, RoomShow } from "./components/rooms";
|
||||
import { RoomList, RoomCreate, RoomShow, RoomEdit } from "./components/rooms";
|
||||
import { ReportList, ReportShow } from "./components/EventReports";
|
||||
import LoginPage from "./components/LoginPage";
|
||||
import UserIcon from "@material-ui/icons/Group";
|
||||
import ConfirmationNumberIcon from "@material-ui/icons/ConfirmationNumber";
|
||||
import EqualizerIcon from "@material-ui/icons/Equalizer";
|
||||
import { UserMediaStatsList } from "./components/statistics";
|
||||
import RoomIcon from "@material-ui/icons/ViewList";
|
||||
import ReportIcon from "@material-ui/icons/Warning";
|
||||
import FolderSharedIcon from "@material-ui/icons/FolderShared";
|
||||
import { ImportFeature } from "./components/ImportFeature";
|
||||
import {
|
||||
RegistrationTokenCreate,
|
||||
RegistrationTokenEdit,
|
||||
RegistrationTokenList,
|
||||
} from "./components/RegistrationTokens";
|
||||
import { RoomDirectoryList } from "./components/RoomDirectory";
|
||||
import { Route } from "react-router-dom";
|
||||
import germanMessages from "./i18n/de";
|
||||
import englishMessages from "./i18n/en";
|
||||
import chineseMessages from "./i18n/zh";
|
||||
import ShowUserPdf from "./components/ShowUserPdf";
|
||||
|
||||
// TODO: Can we use lazy loading together with browser locale?
|
||||
const messages = {
|
||||
@@ -45,7 +40,7 @@ const App = () => (
|
||||
dataProvider={dataProvider}
|
||||
i18nProvider={i18nProvider}
|
||||
customRoutes={[
|
||||
<Route key="userImport" path="/import_users" component={ImportFeature} />,
|
||||
<Route key="showpdf" path="/showpdf" component={ShowUserPdf} />,
|
||||
]}
|
||||
>
|
||||
<Resource
|
||||
@@ -55,7 +50,14 @@ const App = () => (
|
||||
edit={UserEdit}
|
||||
icon={UserIcon}
|
||||
/>
|
||||
<Resource name="rooms" list={RoomList} show={RoomShow} icon={RoomIcon} />
|
||||
<Resource
|
||||
name="rooms"
|
||||
list={RoomList}
|
||||
create={RoomCreate}
|
||||
show={RoomShow}
|
||||
edit={RoomEdit}
|
||||
icon={RoomIcon}
|
||||
/>
|
||||
<Resource
|
||||
name="user_media_statistics"
|
||||
list={UserMediaStatsList}
|
||||
@@ -72,13 +74,6 @@ const App = () => (
|
||||
list={RoomDirectoryList}
|
||||
icon={FolderSharedIcon}
|
||||
/>
|
||||
<Resource
|
||||
name="registration_tokens"
|
||||
list={RegistrationTokenList}
|
||||
create={RegistrationTokenCreate}
|
||||
edit={RegistrationTokenEdit}
|
||||
icon={ConfirmationNumberIcon}
|
||||
/>
|
||||
<Resource name="connections" />
|
||||
<Resource name="devices" />
|
||||
<Resource name="room_members" />
|
||||
@@ -86,9 +81,7 @@ const App = () => (
|
||||
<Resource name="joined_rooms" />
|
||||
<Resource name="pushers" />
|
||||
<Resource name="servernotices" />
|
||||
<Resource name="forward_extremities" />
|
||||
<Resource name="room_state" />
|
||||
<Resource name="user_urlpreview" />
|
||||
</Admin>
|
||||
);
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { TestContext } from "ra-test";
|
||||
import { shallow } from "enzyme";
|
||||
import App from "./App";
|
||||
|
||||
describe("App", () => {
|
||||
it("renders", () => {
|
||||
render(<App />);
|
||||
shallow(
|
||||
<TestContext>
|
||||
<App />
|
||||
</TestContext>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,15 +15,6 @@ import {
|
||||
import PageviewIcon from "@material-ui/icons/Pageview";
|
||||
import ViewListIcon from "@material-ui/icons/ViewList";
|
||||
|
||||
const date_format = {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
};
|
||||
|
||||
const ReportPagination = props => (
|
||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||
);
|
||||
@@ -42,7 +33,14 @@ export const ReportShow = props => {
|
||||
<DateField
|
||||
source="received_ts"
|
||||
showTime
|
||||
options={date_format}
|
||||
options={{
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}}
|
||||
sortable={true}
|
||||
/>
|
||||
<ReferenceField source="user_id" reference="users">
|
||||
@@ -70,10 +68,18 @@ export const ReportShow = props => {
|
||||
icon={<PageviewIcon />}
|
||||
path="detail"
|
||||
>
|
||||
{" "}
|
||||
<DateField
|
||||
source="event_json.origin_server_ts"
|
||||
showTime
|
||||
options={date_format}
|
||||
options={{
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}}
|
||||
sortable={true}
|
||||
/>
|
||||
<ReferenceField source="sender" reference="users">
|
||||
@@ -110,7 +116,14 @@ export const ReportList = ({ ...props }) => {
|
||||
<DateField
|
||||
source="received_ts"
|
||||
showTime
|
||||
options={date_format}
|
||||
options={{
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}}
|
||||
sortable={true}
|
||||
/>
|
||||
<TextField sortable={false} source="user_id" />
|
||||
|
||||
@@ -78,48 +78,10 @@ const LoginPage = ({ theme }) => {
|
||||
const login = useLogin();
|
||||
const notify = useNotify();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [supportPassAuth, setSupportPassAuth] = useState(true);
|
||||
var locale = useLocale();
|
||||
const setLocale = useSetLocale();
|
||||
const translate = useTranslate();
|
||||
const base_url = localStorage.getItem("base_url");
|
||||
const cfg_base_url = process.env.REACT_APP_SERVER;
|
||||
const [ssoBaseUrl, setSSOBaseUrl] = useState("");
|
||||
const loginToken = /\?loginToken=([a-zA-Z0-9_-]+)/.exec(window.location.href);
|
||||
|
||||
if (loginToken) {
|
||||
const ssoToken = loginToken[1];
|
||||
console.log("SSO token is", ssoToken);
|
||||
// Prevent further requests
|
||||
window.history.replaceState(
|
||||
{},
|
||||
"",
|
||||
window.location.href.replace(loginToken[0], "#").split("#")[0]
|
||||
);
|
||||
const baseUrl = localStorage.getItem("sso_base_url");
|
||||
localStorage.removeItem("sso_base_url");
|
||||
if (baseUrl) {
|
||||
const auth = {
|
||||
base_url: baseUrl,
|
||||
username: null,
|
||||
password: null,
|
||||
loginToken: ssoToken,
|
||||
};
|
||||
console.log("Base URL is:", baseUrl);
|
||||
console.log("SSO Token is:", ssoToken);
|
||||
console.log("Let's try token login...");
|
||||
login(auth).catch(error => {
|
||||
alert(
|
||||
typeof error === "string"
|
||||
? error
|
||||
: typeof error === "undefined" || !error.message
|
||||
? "ra.auth.sign_in_error"
|
||||
: error.message
|
||||
);
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const renderInput = ({
|
||||
meta: { touched, error } = {},
|
||||
@@ -149,9 +111,7 @@ const LoginPage = ({ theme }) => {
|
||||
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})?[^?&\s]*$/
|
||||
)
|
||||
!values.base_url.match(/^(http|https):\/\/[a-zA-Z0-9\-.]+(:\d{1,5})?$/)
|
||||
) {
|
||||
errors.base_url = translate("synapseadmin.auth.url_error");
|
||||
}
|
||||
@@ -174,14 +134,6 @@ const LoginPage = ({ theme }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleSSO = () => {
|
||||
localStorage.setItem("sso_base_url", ssoBaseUrl);
|
||||
const ssoFullUrl = `${ssoBaseUrl}/_matrix/client/r0/login/sso/redirect?redirectUrl=${encodeURIComponent(
|
||||
window.location.href
|
||||
)}`;
|
||||
window.location.href = ssoFullUrl;
|
||||
};
|
||||
|
||||
const extractHomeServer = username => {
|
||||
const usernameRegex = /@[a-zA-Z0-9._=\-/]+:([a-zA-Z0-9\-.]+\.[a-zA-Z]+)/;
|
||||
if (!username) return null;
|
||||
@@ -195,7 +147,7 @@ const LoginPage = ({ theme }) => {
|
||||
const [serverVersion, setServerVersion] = useState("");
|
||||
|
||||
const handleUsernameChange = _ => {
|
||||
if (formData.base_url || cfg_base_url) return;
|
||||
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`;
|
||||
@@ -233,31 +185,6 @@ const LoginPage = ({ theme }) => {
|
||||
.catch(_ => {
|
||||
setServerVersion("");
|
||||
});
|
||||
|
||||
// Set SSO Url
|
||||
const authMethodUrl = `${formData.base_url}/_matrix/client/r0/login`;
|
||||
let supportPass = false,
|
||||
supportSSO = false;
|
||||
fetchUtils
|
||||
.fetchJson(authMethodUrl, { method: "GET" })
|
||||
.then(({ json }) => {
|
||||
json.flows.forEach(f => {
|
||||
if (f.type === "m.login.password") {
|
||||
supportPass = true;
|
||||
} else if (f.type === "m.login.sso") {
|
||||
supportSSO = true;
|
||||
}
|
||||
});
|
||||
setSupportPassAuth(supportPass);
|
||||
if (supportSSO) {
|
||||
setSSOBaseUrl(formData.base_url);
|
||||
} else {
|
||||
setSSOBaseUrl("");
|
||||
}
|
||||
})
|
||||
.catch(_ => {
|
||||
setSSOBaseUrl("");
|
||||
});
|
||||
},
|
||||
[formData.base_url]
|
||||
);
|
||||
@@ -270,9 +197,8 @@ const LoginPage = ({ theme }) => {
|
||||
name="username"
|
||||
component={renderInput}
|
||||
label={translate("ra.auth.username")}
|
||||
disabled={loading || !supportPassAuth}
|
||||
disabled={loading}
|
||||
onBlur={handleUsernameChange}
|
||||
resettable
|
||||
fullWidth
|
||||
/>
|
||||
</div>
|
||||
@@ -282,8 +208,7 @@ const LoginPage = ({ theme }) => {
|
||||
component={renderInput}
|
||||
label={translate("ra.auth.password")}
|
||||
type="password"
|
||||
disabled={loading || !supportPassAuth}
|
||||
resettable
|
||||
disabled={loading}
|
||||
fullWidth
|
||||
/>
|
||||
</div>
|
||||
@@ -292,8 +217,7 @@ const LoginPage = ({ theme }) => {
|
||||
name="base_url"
|
||||
component={renderInput}
|
||||
label={translate("synapseadmin.auth.base_url")}
|
||||
disabled={cfg_base_url || loading}
|
||||
resettable
|
||||
disabled={loading}
|
||||
fullWidth
|
||||
/>
|
||||
</div>
|
||||
@@ -304,7 +228,7 @@ const LoginPage = ({ theme }) => {
|
||||
|
||||
return (
|
||||
<Form
|
||||
initialValues={{ base_url: cfg_base_url || base_url }}
|
||||
initialValues={{ base_url: base_url }}
|
||||
onSubmit={handleSubmit}
|
||||
validate={validate}
|
||||
render={({ handleSubmit }) => (
|
||||
@@ -343,24 +267,13 @@ const LoginPage = ({ theme }) => {
|
||||
variant="contained"
|
||||
type="submit"
|
||||
color="primary"
|
||||
disabled={loading || !supportPassAuth}
|
||||
disabled={loading}
|
||||
className={classes.button}
|
||||
fullWidth
|
||||
>
|
||||
{loading && <CircularProgress size={25} thickness={2} />}
|
||||
{translate("ra.auth.sign_in")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
onClick={handleSSO}
|
||||
disabled={loading || ssoBaseUrl === ""}
|
||||
className={classes.button}
|
||||
fullWidth
|
||||
>
|
||||
{loading && <CircularProgress size={25} thickness={2} />}
|
||||
{translate("synapseadmin.auth.sso_sign_in")}
|
||||
</Button>
|
||||
</CardActions>
|
||||
</Card>
|
||||
<Notification />
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { TestContext } from "ra-test";
|
||||
import { shallow } from "enzyme";
|
||||
import LoginPage from "./LoginPage";
|
||||
|
||||
describe("LoginForm", () => {
|
||||
it("renders", () => {
|
||||
render(
|
||||
shallow(
|
||||
<TestContext>
|
||||
<LoginPage />
|
||||
</TestContext>
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
import React from "react";
|
||||
import {
|
||||
BooleanInput,
|
||||
Create,
|
||||
Datagrid,
|
||||
DateField,
|
||||
DateTimeInput,
|
||||
Edit,
|
||||
Filter,
|
||||
List,
|
||||
maxValue,
|
||||
number,
|
||||
NumberField,
|
||||
NumberInput,
|
||||
regex,
|
||||
SimpleForm,
|
||||
TextInput,
|
||||
TextField,
|
||||
Toolbar,
|
||||
} from "react-admin";
|
||||
|
||||
const date_format = {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
};
|
||||
|
||||
const validateToken = [regex(/^[A-Za-z0-9._~-]{0,64}$/)];
|
||||
const validateUsesAllowed = [number()];
|
||||
const validateLength = [number(), maxValue(64)];
|
||||
|
||||
const dateParser = v => {
|
||||
const d = new Date(v);
|
||||
if (isNaN(d)) return 0;
|
||||
return d.getTime();
|
||||
};
|
||||
|
||||
const dateFormatter = v => {
|
||||
if (v === undefined || v === null) return;
|
||||
const d = new Date(v);
|
||||
|
||||
const pad = "00";
|
||||
const year = d.getFullYear().toString();
|
||||
const month = (pad + (d.getMonth() + 1).toString()).slice(-2);
|
||||
const day = (pad + d.getDate().toString()).slice(-2);
|
||||
const hour = (pad + d.getHours().toString()).slice(-2);
|
||||
const minute = (pad + d.getMinutes().toString()).slice(-2);
|
||||
|
||||
// target format yyyy-MM-ddThh:mm
|
||||
return `${year}-${month}-${day}T${hour}:${minute}`;
|
||||
};
|
||||
|
||||
const RegistrationTokenFilter = props => (
|
||||
<Filter {...props}>
|
||||
<BooleanInput source="valid" alwaysOn />
|
||||
</Filter>
|
||||
);
|
||||
|
||||
export const RegistrationTokenList = props => {
|
||||
return (
|
||||
<List
|
||||
{...props}
|
||||
filters={<RegistrationTokenFilter />}
|
||||
filterDefaultValues={{ valid: true }}
|
||||
pagination={false}
|
||||
perPage={500}
|
||||
>
|
||||
<Datagrid rowClick="edit">
|
||||
<TextField source="token" sortable={false} />
|
||||
<NumberField source="uses_allowed" sortable={false} />
|
||||
<NumberField source="pending" sortable={false} />
|
||||
<NumberField source="completed" sortable={false} />
|
||||
<DateField
|
||||
source="expiry_time"
|
||||
showTime
|
||||
options={date_format}
|
||||
sortable={false}
|
||||
/>
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
|
||||
export const RegistrationTokenCreate = props => (
|
||||
<Create {...props}>
|
||||
<SimpleForm redirect="list" toolbar={<Toolbar alwaysEnableSaveButton />}>
|
||||
<TextInput
|
||||
source="token"
|
||||
autoComplete="off"
|
||||
validate={validateToken}
|
||||
resettable
|
||||
/>
|
||||
<NumberInput
|
||||
source="length"
|
||||
validate={validateLength}
|
||||
helperText="resources.registration_tokens.helper.length"
|
||||
step={1}
|
||||
/>
|
||||
<NumberInput
|
||||
source="uses_allowed"
|
||||
validate={validateUsesAllowed}
|
||||
step={1}
|
||||
/>
|
||||
<DateTimeInput source="expiry_time" parse={dateParser} />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
|
||||
export const RegistrationTokenEdit = props => {
|
||||
return (
|
||||
<Edit {...props}>
|
||||
<SimpleForm>
|
||||
<TextInput source="token" disabled />
|
||||
<NumberInput source="pending" disabled />
|
||||
<NumberInput source="completed" disabled />
|
||||
<NumberInput
|
||||
source="uses_allowed"
|
||||
validate={validateUsesAllowed}
|
||||
step={1}
|
||||
/>
|
||||
<DateTimeInput
|
||||
source="expiry_time"
|
||||
parse={dateParser}
|
||||
format={dateFormatter}
|
||||
/>
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
};
|
||||
@@ -59,7 +59,7 @@ export const RoomDirectoryBulkDeleteButton = props => (
|
||||
<BulkDeleteButton
|
||||
{...props}
|
||||
label="resources.room_directory.action.erase"
|
||||
mutationMode="pessimistic"
|
||||
undoable={false}
|
||||
confirmTitle="resources.room_directory.action.title"
|
||||
confirmContent="resources.room_directory.action.content"
|
||||
resource="room_directory"
|
||||
@@ -171,14 +171,10 @@ const RoomDirectoryFilter = ({ ...props }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const FilterableRoomDirectoryList = ({
|
||||
roomDirectoryFilters,
|
||||
dispatch,
|
||||
...props
|
||||
}) => {
|
||||
export const FilterableRoomDirectoryList = ({ ...props }) => {
|
||||
const classes = useStyles();
|
||||
const translate = useTranslate();
|
||||
const filter = roomDirectoryFilters;
|
||||
const filter = props.roomDirectoryFilters;
|
||||
const roomIdFilter = filter && filter.room_id ? true : false;
|
||||
const topicFilter = filter && filter.topic ? true : false;
|
||||
const canonicalAliasFilter = filter && filter.canonical_alias ? true : false;
|
||||
@@ -191,7 +187,7 @@ export const FilterableRoomDirectoryList = ({
|
||||
filters={<RoomDirectoryFilter />}
|
||||
perPage={100}
|
||||
>
|
||||
<Datagrid rowClick={(id, basePath, record) => "/rooms/" + id + "/show"}>
|
||||
<Datagrid>
|
||||
<AvatarField
|
||||
source="avatar_src"
|
||||
sortable={false}
|
||||
|
||||
35
src/components/SaveQrButton.js
Normal file
35
src/components/SaveQrButton.js
Normal file
@@ -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;
|
||||
@@ -24,10 +24,7 @@ const ServerNoticeDialog = ({ open, loading, onClose, onSend }) => {
|
||||
|
||||
const ServerNoticeToolbar = props => (
|
||||
<Toolbar {...props}>
|
||||
<SaveButton
|
||||
label="resources.servernotices.action.send"
|
||||
disabled={props.pristine}
|
||||
/>
|
||||
<SaveButton label="resources.servernotices.action.send" />
|
||||
<Button label="ra.action.cancel" onClick={onClose}>
|
||||
<IconCancel />
|
||||
</Button>
|
||||
|
||||
210
src/components/ShowUserPdf.js
Normal file
210
src/components/ShowUserPdf.js
Normal file
@@ -0,0 +1,210 @@
|
||||
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",
|
||||
fontFamily: "DejaVu Sans, Sans-Serif",
|
||||
fontSize: 15,
|
||||
},
|
||||
header: {
|
||||
height: 144,
|
||||
width: 534,
|
||||
marginLeft: 32,
|
||||
marginTop: 15,
|
||||
},
|
||||
name: {
|
||||
width: 240,
|
||||
fontSize: 35,
|
||||
float: "left",
|
||||
marginTop: 100,
|
||||
},
|
||||
logo: {
|
||||
width: 90,
|
||||
marginTop: 50,
|
||||
marginRight: 70,
|
||||
float: "right",
|
||||
},
|
||||
body: {
|
||||
clear: "both",
|
||||
},
|
||||
table_cell: {
|
||||
verticalAlign: "top",
|
||||
},
|
||||
code_note: {
|
||||
marginLeft: 32,
|
||||
marginTop: 86,
|
||||
},
|
||||
qr: {
|
||||
marginTop: 15,
|
||||
marginLeft: 32,
|
||||
},
|
||||
credentials_note: {
|
||||
marginTop: 86,
|
||||
marginLeft: 10,
|
||||
},
|
||||
credentials_text: {
|
||||
marginLeft: 10,
|
||||
fontSize: 12,
|
||||
},
|
||||
credentials: {
|
||||
fontFamily: "DejaVu Sans Mono, monospace",
|
||||
},
|
||||
note: {
|
||||
fontSize: 18,
|
||||
marginTop: 100,
|
||||
marginLeft: 32,
|
||||
marginRight: 32,
|
||||
},
|
||||
}));
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
var resume;
|
||||
|
||||
const exportPDF = () => {
|
||||
resume.save();
|
||||
};
|
||||
|
||||
var qrCode = "";
|
||||
var displayname = "";
|
||||
var id = "";
|
||||
var password = "";
|
||||
var username = "";
|
||||
var serverUrl = "";
|
||||
|
||||
if (
|
||||
props.location.state &&
|
||||
props.location.state.id &&
|
||||
props.location.state.password
|
||||
) {
|
||||
id = props.location.state.id;
|
||||
password = props.location.state.password;
|
||||
|
||||
username = id.substring(1, id.indexOf(":"));
|
||||
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.header}>
|
||||
<div className={classes.name}>{displayname}</div>
|
||||
<img className={classes.logo} alt="Logo" src="images/logo.png" />
|
||||
</div>
|
||||
<div className={classes.body}>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td width="200px">
|
||||
<div className={classes.code_note}>
|
||||
Ihr persönlicher Anmeldecode:
|
||||
</div>
|
||||
</td>
|
||||
<td className={classes.table_cell}>
|
||||
<div className={classes.credentials_note}>
|
||||
Ihre persönlichen Zugangsdaten:
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div className={classes.qr}>{qrCode}</div>
|
||||
</td>
|
||||
<td className={classes.table_cell}>
|
||||
<div className={classes.credentials_text}>
|
||||
<br />
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Heimserver:</td>
|
||||
<td>
|
||||
<span className={classes.credentials}>
|
||||
{serverUrl}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Benutzername:</td>
|
||||
<td>
|
||||
<span className={classes.credentials}>
|
||||
{username}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Passwort:</td>
|
||||
<td>
|
||||
<span className={classes.credentials}>
|
||||
{password}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div className={classes.note}>
|
||||
Hier können Sie Ihre selbst gewählte
|
||||
Schlüsselsicherungs-Passphrase notieren:
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<hr />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</PDFExport>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ShowUserPdf;
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "react-admin";
|
||||
import ActionDelete from "@material-ui/icons/Delete";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { alpha } from "@material-ui/core/styles/colorManipulator";
|
||||
import { fade } from "@material-ui/core/styles/colorManipulator";
|
||||
import classnames from "classnames";
|
||||
|
||||
const useStyles = makeStyles(
|
||||
@@ -16,7 +16,7 @@ const useStyles = makeStyles(
|
||||
deleteButton: {
|
||||
color: theme.palette.error.main,
|
||||
"&:hover": {
|
||||
backgroundColor: alpha(theme.palette.error.main, 0.12),
|
||||
backgroundColor: fade(theme.palette.error.main, 0.12),
|
||||
// Reset on mouse devices
|
||||
"@media (hover: none)": {
|
||||
backgroundColor: "transparent",
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import React, { Fragment, useState } from "react";
|
||||
import classnames from "classnames";
|
||||
import { alpha } from "@material-ui/core/styles/colorManipulator";
|
||||
import { fade } from "@material-ui/core/styles/colorManipulator";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { Tooltip } from "@material-ui/core";
|
||||
import {
|
||||
BooleanInput,
|
||||
Button,
|
||||
@@ -11,29 +10,23 @@ import {
|
||||
SaveButton,
|
||||
SimpleForm,
|
||||
Toolbar,
|
||||
useCreate,
|
||||
useDelete,
|
||||
useNotify,
|
||||
useRefresh,
|
||||
useTranslate,
|
||||
} from "react-admin";
|
||||
import BlockIcon from "@material-ui/icons/Block";
|
||||
import ClearIcon from "@material-ui/icons/Clear";
|
||||
import DeleteSweepIcon from "@material-ui/icons/DeleteSweep";
|
||||
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";
|
||||
import IconCancel from "@material-ui/icons/Cancel";
|
||||
import LockIcon from "@material-ui/icons/Lock";
|
||||
import LockOpenIcon from "@material-ui/icons/LockOpen";
|
||||
import DeleteSweepIcon from "@material-ui/icons/DeleteSweep";
|
||||
|
||||
const useStyles = makeStyles(
|
||||
theme => ({
|
||||
deleteButton: {
|
||||
color: theme.palette.error.main,
|
||||
"&:hover": {
|
||||
backgroundColor: alpha(theme.palette.error.main, 0.12),
|
||||
backgroundColor: fade(theme.palette.error.main, 0.12),
|
||||
// Reset on mouse devices
|
||||
"@media (hover: none)": {
|
||||
backgroundColor: "transparent",
|
||||
@@ -150,178 +143,3 @@ export const DeleteMediaButton = props => {
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export const ProtectMediaButton = props => {
|
||||
const { record } = props;
|
||||
const translate = useTranslate();
|
||||
const refresh = useRefresh();
|
||||
const notify = useNotify();
|
||||
const [create, { loading }] = useCreate("protect_media");
|
||||
const [deleteOne] = useDelete("protect_media");
|
||||
|
||||
if (!record) return null;
|
||||
|
||||
const handleProtect = () => {
|
||||
create(
|
||||
{ payload: { data: record } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.protect_media.action.send_success");
|
||||
refresh();
|
||||
},
|
||||
onFailure: () =>
|
||||
notify("resources.protect_media.action.send_failure", "error"),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const handleUnprotect = () => {
|
||||
deleteOne(
|
||||
{ payload: { ...record } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.protect_media.action.send_success");
|
||||
refresh();
|
||||
},
|
||||
onFailure: () =>
|
||||
notify("resources.protect_media.action.send_failure", "error"),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
/*
|
||||
Wrapping Tooltip with <div>
|
||||
https://github.com/marmelab/react-admin/issues/4349#issuecomment-578594735
|
||||
*/
|
||||
<Fragment>
|
||||
{record.quarantined_by && (
|
||||
<Tooltip
|
||||
title={translate("resources.protect_media.action.none", {
|
||||
_: "resources.protect_media.action.none",
|
||||
})}
|
||||
>
|
||||
<div>
|
||||
{/*
|
||||
Button instead BooleanField for
|
||||
consistent appearance and position in the column
|
||||
*/}
|
||||
<Button disabled={true}>
|
||||
<ClearIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
{record.safe_from_quarantine && (
|
||||
<Tooltip
|
||||
title={translate("resources.protect_media.action.delete", {
|
||||
_: "resources.protect_media.action.delete",
|
||||
})}
|
||||
arrow
|
||||
>
|
||||
<div>
|
||||
<Button onClick={handleUnprotect} disabled={loading}>
|
||||
<LockIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
{!record.safe_from_quarantine && !record.quarantined_by && (
|
||||
<Tooltip
|
||||
title={translate("resources.protect_media.action.create", {
|
||||
_: "resources.protect_media.action.create",
|
||||
})}
|
||||
>
|
||||
<div>
|
||||
<Button onClick={handleProtect} disabled={loading}>
|
||||
<LockOpenIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export const QuarantineMediaButton = props => {
|
||||
const { record } = props;
|
||||
const translate = useTranslate();
|
||||
const refresh = useRefresh();
|
||||
const notify = useNotify();
|
||||
const [create, { loading }] = useCreate("quarantine_media");
|
||||
const [deleteOne] = useDelete("quarantine_media");
|
||||
|
||||
if (!record) return null;
|
||||
|
||||
const handleQuarantaine = () => {
|
||||
create(
|
||||
{ payload: { data: record } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.quarantine_media.action.send_success");
|
||||
refresh();
|
||||
},
|
||||
onFailure: () =>
|
||||
notify("resources.quarantine_media.action.send_failure", "error"),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const handleRemoveQuarantaine = () => {
|
||||
deleteOne(
|
||||
{ payload: { ...record } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.quarantine_media.action.send_success");
|
||||
refresh();
|
||||
},
|
||||
onFailure: () =>
|
||||
notify("resources.quarantine_media.action.send_failure", "error"),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{record.safe_from_quarantine && (
|
||||
<Tooltip
|
||||
title={translate("resources.quarantine_media.action.none", {
|
||||
_: "resources.quarantine_media.action.none",
|
||||
})}
|
||||
>
|
||||
<div>
|
||||
<Button disabled={true}>
|
||||
<ClearIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
{record.quarantined_by && (
|
||||
<Tooltip
|
||||
title={translate("resources.quarantine_media.action.delete", {
|
||||
_: "resources.quarantine_media.action.delete",
|
||||
})}
|
||||
>
|
||||
<div>
|
||||
<Button onClick={handleRemoveQuarantaine} disabled={loading}>
|
||||
<BlockIcon color="error" />
|
||||
</Button>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
{!record.safe_from_quarantine && !record.quarantined_by && (
|
||||
<Tooltip
|
||||
title={translate("resources.quarantine_media.action.create", {
|
||||
_: "resources.quarantine_media.action.create",
|
||||
})}
|
||||
>
|
||||
<div>
|
||||
<Button onClick={handleQuarantaine} disabled={loading}>
|
||||
<BlockIcon />
|
||||
</Button>
|
||||
</div>
|
||||
</Tooltip>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,40 +1,60 @@
|
||||
import React, { Fragment } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { Route, Link } from "react-router-dom";
|
||||
import {
|
||||
AutocompleteArrayInput,
|
||||
AutocompleteInput,
|
||||
BooleanInput,
|
||||
BooleanField,
|
||||
BulkDeleteButton,
|
||||
DateField,
|
||||
Button,
|
||||
Create,
|
||||
Edit,
|
||||
Datagrid,
|
||||
DateField,
|
||||
DeleteButton,
|
||||
Filter,
|
||||
FormTab,
|
||||
List,
|
||||
NumberField,
|
||||
Pagination,
|
||||
ReferenceArrayInput,
|
||||
ReferenceField,
|
||||
ReferenceInput,
|
||||
ReferenceManyField,
|
||||
SearchInput,
|
||||
SelectField,
|
||||
Show,
|
||||
SimpleForm,
|
||||
Tab,
|
||||
TabbedForm,
|
||||
TabbedShowLayout,
|
||||
TextField,
|
||||
TextInput,
|
||||
Toolbar,
|
||||
TopToolbar,
|
||||
useRecordContext,
|
||||
useDataProvider,
|
||||
useRefresh,
|
||||
useTranslate,
|
||||
} from "react-admin";
|
||||
import get from "lodash/get";
|
||||
import PropTypes from "prop-types";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { Tooltip, Typography, Chip } from "@material-ui/core";
|
||||
import FastForwardIcon from "@material-ui/icons/FastForward";
|
||||
import {
|
||||
Tooltip,
|
||||
Typography,
|
||||
Chip,
|
||||
Drawer,
|
||||
styled,
|
||||
withStyles,
|
||||
Select,
|
||||
MenuItem,
|
||||
} from "@material-ui/core";
|
||||
import HttpsIcon from "@material-ui/icons/Https";
|
||||
import NoEncryptionIcon from "@material-ui/icons/NoEncryption";
|
||||
import PageviewIcon from "@material-ui/icons/Pageview";
|
||||
import UserIcon from "@material-ui/icons/Group";
|
||||
import ViewListIcon from "@material-ui/icons/ViewList";
|
||||
import VisibilityIcon from "@material-ui/icons/Visibility";
|
||||
import ContentSave from "@material-ui/icons/Save";
|
||||
import EventIcon from "@material-ui/icons/Event";
|
||||
|
||||
import {
|
||||
RoomDirectoryBulkDeleteButton,
|
||||
RoomDirectoryBulkSaveButton,
|
||||
@@ -42,22 +62,6 @@ import {
|
||||
RoomDirectorySaveButton,
|
||||
} from "./RoomDirectory";
|
||||
|
||||
const date_format = {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
};
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
helper_forward_extremities: {
|
||||
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
||||
margin: "0.5em",
|
||||
},
|
||||
}));
|
||||
|
||||
const RoomPagination = props => (
|
||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||
);
|
||||
@@ -88,20 +92,368 @@ const EncryptionField = ({ source, record = {}, emptyText }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const RoomTitle = ({ record }) => {
|
||||
const translate = useTranslate();
|
||||
var name = "";
|
||||
if (record) {
|
||||
name = record.name !== "" ? record.name : record.id;
|
||||
const validateDisplayName = fieldval => {
|
||||
return fieldval == null
|
||||
? "synapseadmin.rooms.room_name_required"
|
||||
: fieldval.length === 0
|
||||
? "synapseadmin.rooms.room_name_required"
|
||||
: undefined;
|
||||
};
|
||||
|
||||
function approximateAliasLength(alias, homeserver) {
|
||||
/* TODO maybe handle punycode in homeserver name */
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
const aliasLength = te === undefined ? alias.length : te.encode(alias).length;
|
||||
|
||||
return "#".length + aliasLength + ":".length + homeserver.length;
|
||||
}
|
||||
|
||||
const validateAlias = fieldval => {
|
||||
if (fieldval === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const homeserver = localStorage.getItem("home_server");
|
||||
|
||||
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}>
|
||||
<TabbedForm validate={validateHasAliasIfPublic}>
|
||||
<FormTab label="synapseadmin.rooms.details" icon={<ViewListIcon />}>
|
||||
<TextInput
|
||||
source="name"
|
||||
parse={removeLeadingWhitespace}
|
||||
validate={validateDisplayName}
|
||||
/>
|
||||
<TextInput
|
||||
source="canonical_alias"
|
||||
parse={fv => replaceAllWhitespace(removeLeadingSigil(fv))}
|
||||
validate={validateAlias}
|
||||
placeholder="#"
|
||||
/>
|
||||
<ReferenceInput
|
||||
reference="users"
|
||||
source="owner"
|
||||
filterToQuery={searchText => ({ user_id: searchText })}
|
||||
>
|
||||
<AutocompleteInput
|
||||
optionText="displayname"
|
||||
suggestionText="displayname"
|
||||
/>
|
||||
</ReferenceInput>
|
||||
<BooleanInput source="public" label="synapseadmin.rooms.make_public" />
|
||||
<BooleanInput
|
||||
source="encrypt"
|
||||
initialValue={true}
|
||||
label="synapseadmin.rooms.encrypt"
|
||||
/>
|
||||
</FormTab>
|
||||
<FormTab
|
||||
label="resources.rooms.fields.invite_members"
|
||||
icon={<UserIcon />}
|
||||
>
|
||||
<ReferenceArrayInput
|
||||
reference="users"
|
||||
source="invitees"
|
||||
filterToQuery={searchText => ({ user_id: searchText })}
|
||||
>
|
||||
<AutocompleteArrayInput
|
||||
optionText="displayname"
|
||||
suggestionText="displayname"
|
||||
/>
|
||||
</ReferenceArrayInput>
|
||||
</FormTab>
|
||||
</TabbedForm>
|
||||
</Create>
|
||||
);
|
||||
|
||||
const RoomTitle = ({ record }) => {
|
||||
const translate = useTranslate();
|
||||
return (
|
||||
<span>
|
||||
{translate("resources.rooms.name", 1)} {name}
|
||||
{translate("resources.rooms.name", 1)} {record ? `"${record.name}"` : ""}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
// Explicitely passing "to" prop
|
||||
// Toolbar adds all kinds of unsupported props to its children :(
|
||||
const StyledLink = styles => {
|
||||
const Styled = styled(Link)(styles);
|
||||
return ({ to, children }) => <Styled to={to}>{children}</Styled>;
|
||||
};
|
||||
|
||||
const RoomMemberEditToolbar = ({ backLink, translate, onSave, ...props }) => {
|
||||
const SaveLink = StyledLink({
|
||||
textDecoration: "none",
|
||||
});
|
||||
const CancelLink = StyledLink({
|
||||
textDecoration: "none",
|
||||
marginLeft: "1em",
|
||||
});
|
||||
const SaveIcon = styled(ContentSave)({
|
||||
width: "1rem",
|
||||
marginRight: "0.25em",
|
||||
});
|
||||
|
||||
return (
|
||||
<Toolbar {...props}>
|
||||
<SaveLink to={backLink}>
|
||||
<Button onClick={onSave} variant="contained">
|
||||
<React.Fragment>
|
||||
<SaveIcon />
|
||||
{translate("ra.action.save")}
|
||||
</React.Fragment>
|
||||
</Button>
|
||||
</SaveLink>
|
||||
<CancelLink to={backLink}>
|
||||
<Button>
|
||||
<React.Fragment>{translate("ra.action.cancel")}</React.Fragment>
|
||||
</Button>
|
||||
</CancelLink>
|
||||
</Toolbar>
|
||||
);
|
||||
};
|
||||
|
||||
const RoomMemberIdField = ({ memberId, data = {} }) => {
|
||||
const value = get(data[memberId], "id");
|
||||
|
||||
return (
|
||||
<Typography component="span" variant="body2">
|
||||
{value}
|
||||
</Typography>
|
||||
);
|
||||
};
|
||||
|
||||
const RoomMemberRoleInput = ({ memberId, data = {}, translate, onChange }) => {
|
||||
const roleValue = get(data[memberId], "role");
|
||||
const [role, setRole] = React.useState(roleValue);
|
||||
|
||||
React.useEffect(() => {
|
||||
onChange(roleValue);
|
||||
}, [onChange, roleValue]);
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Select
|
||||
labelId="demo-simple-select-label"
|
||||
id="demo-simple-select"
|
||||
value={role}
|
||||
onChange={event => {
|
||||
setRole(event.target.value);
|
||||
onChange(event.target.value);
|
||||
}}
|
||||
>
|
||||
<MenuItem value={"user"}>
|
||||
{translate("resources.users.roles.user")}
|
||||
</MenuItem>
|
||||
<MenuItem value={"mod"}>
|
||||
{translate("resources.users.roles.mod")}
|
||||
</MenuItem>
|
||||
<MenuItem value={"admin"}>
|
||||
{translate("resources.users.roles.admin")}
|
||||
</MenuItem>
|
||||
</Select>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const RoomMemberEdit = ({ backLink, memberId, ...props }) => {
|
||||
const translate = useTranslate();
|
||||
const refresh = useRefresh();
|
||||
const dataProvider = useDataProvider();
|
||||
|
||||
const [role, setRole] = React.useState();
|
||||
|
||||
const { id } = props;
|
||||
|
||||
return (
|
||||
<Edit title=" " {...props}>
|
||||
<SimpleForm
|
||||
toolbar={
|
||||
<RoomMemberEditToolbar
|
||||
backLink={backLink}
|
||||
translate={translate}
|
||||
onSave={() => {
|
||||
dataProvider
|
||||
.update("rooms", {
|
||||
data: {
|
||||
id,
|
||||
member_roles: [{ member_id: memberId, role }],
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
refresh();
|
||||
});
|
||||
}}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ReferenceManyField
|
||||
reference="room_members"
|
||||
target="room_id"
|
||||
label="resources.users.fields.id"
|
||||
>
|
||||
<RoomMemberIdField memberId={memberId} />
|
||||
</ReferenceManyField>
|
||||
<ReferenceManyField
|
||||
reference="room_members"
|
||||
target="room_id"
|
||||
label="resources.users.fields.role"
|
||||
>
|
||||
<RoomMemberRoleInput
|
||||
memberId={memberId}
|
||||
translate={translate}
|
||||
onChange={setRole}
|
||||
/>
|
||||
</ReferenceManyField>
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
};
|
||||
|
||||
const drawerStyles = {
|
||||
paper: {
|
||||
width: 300,
|
||||
},
|
||||
};
|
||||
const StyledDrawer = withStyles(drawerStyles)(({ classes, ...props }) => (
|
||||
<Drawer {...props} classes={classes} />
|
||||
));
|
||||
|
||||
export const RoomEdit = props => {
|
||||
const translate = useTranslate();
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Edit {...props} title={<RoomTitle />}>
|
||||
<TabbedForm>
|
||||
<FormTab label="synapseadmin.rooms.tabs.members" icon={<UserIcon />}>
|
||||
<ReferenceArrayInput
|
||||
reference="users"
|
||||
source="invitees"
|
||||
filterToQuery={searchText => ({ user_id: searchText })}
|
||||
>
|
||||
<AutocompleteArrayInput
|
||||
optionText="displayname"
|
||||
suggestionText="displayname"
|
||||
/>
|
||||
</ReferenceArrayInput>
|
||||
|
||||
<ReferenceManyField
|
||||
reference="room_members"
|
||||
target="room_id"
|
||||
addLabel={false}
|
||||
>
|
||||
<Datagrid
|
||||
style={{ width: "100%" }}
|
||||
rowClick={(id, basePath, record) =>
|
||||
`/rooms/${encodeURIComponent(
|
||||
record.parentId
|
||||
)}/${encodeURIComponent(id)}`
|
||||
}
|
||||
>
|
||||
<TextField
|
||||
source="id"
|
||||
sortable={false}
|
||||
label="resources.users.fields.id"
|
||||
/>
|
||||
<ReferenceField
|
||||
label="resources.users.fields.displayname"
|
||||
source="id"
|
||||
reference="users"
|
||||
sortable={false}
|
||||
link=""
|
||||
>
|
||||
<TextField source="displayname" sortable={false} />
|
||||
</ReferenceField>
|
||||
<SelectField
|
||||
source="role"
|
||||
label="resources.users.fields.role"
|
||||
choices={[
|
||||
{
|
||||
id: "user",
|
||||
name: translate("resources.users.roles.user"),
|
||||
},
|
||||
{ id: "mod", name: translate("resources.users.roles.mod") },
|
||||
{
|
||||
id: "admin",
|
||||
name: translate("resources.users.roles.admin"),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Datagrid>
|
||||
</ReferenceManyField>
|
||||
</FormTab>
|
||||
</TabbedForm>
|
||||
</Edit>
|
||||
<Route path="/rooms/:roomId/:memberId">
|
||||
{({ match }) => {
|
||||
const isMatch = !!match && !!match.params;
|
||||
|
||||
return (
|
||||
<StyledDrawer open={isMatch} anchor="right">
|
||||
{isMatch ? (
|
||||
<RoomMemberEdit
|
||||
{...props}
|
||||
memberId={
|
||||
isMatch ? decodeURIComponent(match.params.memberId) : null
|
||||
}
|
||||
backLink={`/rooms/${match.params.roomId}`}
|
||||
/>
|
||||
) : (
|
||||
<div />
|
||||
)}
|
||||
</StyledDrawer>
|
||||
);
|
||||
}}
|
||||
</Route>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const RoomShowActions = ({ basePath, data, resource }) => {
|
||||
var roomDirectoryStatus = "";
|
||||
if (data) {
|
||||
@@ -129,7 +481,6 @@ const RoomShowActions = ({ basePath, data, resource }) => {
|
||||
};
|
||||
|
||||
export const RoomShow = props => {
|
||||
const classes = useStyles({ props });
|
||||
const translate = useTranslate();
|
||||
return (
|
||||
<Show {...props} actions={<RoomShowActions />} title={<RoomTitle />}>
|
||||
@@ -159,11 +510,7 @@ export const RoomShow = props => {
|
||||
/>
|
||||
</Tab>
|
||||
|
||||
<Tab
|
||||
label="synapseadmin.rooms.tabs.members"
|
||||
icon={<UserIcon />}
|
||||
path="members"
|
||||
>
|
||||
<Tab label="synapseadmin.rooms.tabs.members" icon={<UserIcon />}>
|
||||
<ReferenceManyField
|
||||
reference="room_members"
|
||||
target="room_id"
|
||||
@@ -245,7 +592,6 @@ export const RoomShow = props => {
|
||||
]}
|
||||
/>
|
||||
</Tab>
|
||||
|
||||
<Tab
|
||||
label={translate("resources.room_state.name", { smart_count: 2 })}
|
||||
icon={<EventIcon />}
|
||||
@@ -261,7 +607,14 @@ export const RoomShow = props => {
|
||||
<DateField
|
||||
source="origin_server_ts"
|
||||
showTime
|
||||
options={date_format}
|
||||
options={{
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}}
|
||||
sortable={false}
|
||||
/>
|
||||
<TextField source="content" sortable={false} />
|
||||
@@ -275,35 +628,6 @@ export const RoomShow = props => {
|
||||
</Datagrid>
|
||||
</ReferenceManyField>
|
||||
</Tab>
|
||||
|
||||
<Tab
|
||||
label="resources.forward_extremities.name"
|
||||
icon={<FastForwardIcon />}
|
||||
path="forward_extremities"
|
||||
>
|
||||
<div className={classes.helper_forward_extremities}>
|
||||
{translate("resources.rooms.helper.forward_extremities")}
|
||||
</div>
|
||||
<ReferenceManyField
|
||||
reference="forward_extremities"
|
||||
target="room_id"
|
||||
addLabel={false}
|
||||
>
|
||||
<Datagrid style={{ width: "100%" }}>
|
||||
<TextField source="id" sortable={false} />
|
||||
<DateField
|
||||
source="received_ts"
|
||||
showTime
|
||||
options={date_format}
|
||||
sortable={false}
|
||||
/>
|
||||
<NumberField source="depth" sortable={false} />
|
||||
<TextField source="state_group" sortable={false} />
|
||||
</Datagrid>
|
||||
</ReferenceManyField>
|
||||
</Tab>
|
||||
|
||||
|
||||
</TabbedShowLayout>
|
||||
</Show>
|
||||
);
|
||||
@@ -317,7 +641,7 @@ const RoomBulkActionButtons = props => (
|
||||
{...props}
|
||||
confirmTitle="resources.rooms.action.erase.title"
|
||||
confirmContent="resources.rooms.action.erase.content"
|
||||
mutationMode="pessimistic"
|
||||
undoable={false}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
@@ -355,22 +679,8 @@ const RoomFilter = ({ ...props }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const RoomNameField = props => {
|
||||
const { source } = props;
|
||||
const record = useRecordContext(props);
|
||||
return (
|
||||
<span>{record[source] || record["canonical_alias"] || record["id"]}</span>
|
||||
);
|
||||
};
|
||||
|
||||
RoomNameField.propTypes = {
|
||||
label: PropTypes.string,
|
||||
record: PropTypes.object,
|
||||
source: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
const FilterableRoomList = ({ roomFilters, dispatch, ...props }) => {
|
||||
const filter = roomFilters;
|
||||
const FilterableRoomList = ({ ...props }) => {
|
||||
const filter = props.roomFilters;
|
||||
const localMembersFilter =
|
||||
filter && filter.joined_local_members ? true : false;
|
||||
const stateEventsFilter = filter && filter.state_events ? true : false;
|
||||
@@ -391,7 +701,7 @@ const FilterableRoomList = ({ roomFilters, dispatch, ...props }) => {
|
||||
sortBy="encryption"
|
||||
label={<HttpsIcon />}
|
||||
/>
|
||||
<RoomNameField source="name" />
|
||||
<TextField source="name" />
|
||||
<TextField source="joined_members" />
|
||||
{localMembersFilter && <TextField source="joined_local_members" />}
|
||||
{stateEventsFilter && <TextField source="state_events" />}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import React, { cloneElement, Fragment } from "react";
|
||||
import Avatar from "@material-ui/core/Avatar";
|
||||
import AssignmentIndIcon from "@material-ui/icons/AssignmentInd";
|
||||
import PersonPinIcon from "@material-ui/icons/PersonPin";
|
||||
import ContactMailIcon from "@material-ui/icons/ContactMail";
|
||||
import DevicesIcon from "@material-ui/icons/Devices";
|
||||
import GetAppIcon from "@material-ui/icons/GetApp";
|
||||
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
|
||||
import NotificationsIcon from "@material-ui/icons/Notifications";
|
||||
import PermMediaIcon from "@material-ui/icons/PermMedia";
|
||||
import PersonPinIcon from "@material-ui/icons/PersonPin";
|
||||
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
|
||||
import ViewListIcon from "@material-ui/icons/ViewList";
|
||||
|
||||
import {
|
||||
ArrayInput,
|
||||
ArrayField,
|
||||
@@ -30,16 +28,16 @@ import {
|
||||
PasswordInput,
|
||||
TextField,
|
||||
TextInput,
|
||||
SearchInput,
|
||||
ReferenceField,
|
||||
ReferenceManyField,
|
||||
SearchInput,
|
||||
SelectField,
|
||||
SelectInput,
|
||||
BulkDeleteButton,
|
||||
DeleteButton,
|
||||
SaveButton,
|
||||
maxLength,
|
||||
regex,
|
||||
required,
|
||||
useRedirect,
|
||||
useTranslate,
|
||||
Pagination,
|
||||
CreateButton,
|
||||
@@ -48,18 +46,11 @@ import {
|
||||
sanitizeListRestProps,
|
||||
NumberField,
|
||||
} from "react-admin";
|
||||
import { Link } from "react-router-dom";
|
||||
import SaveQrButton from "./SaveQrButton";
|
||||
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
|
||||
import { DeviceRemoveButton } from "./devices";
|
||||
import { ProtectMediaButton, QuarantineMediaButton } from "./media";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
|
||||
const redirect = () => {
|
||||
return {
|
||||
pathname: "/import_users",
|
||||
};
|
||||
};
|
||||
|
||||
const useStyles = makeStyles({
|
||||
small: {
|
||||
height: "40px",
|
||||
@@ -72,15 +63,6 @@ const useStyles = makeStyles({
|
||||
},
|
||||
});
|
||||
|
||||
const date_format = {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
};
|
||||
|
||||
const UserListActions = ({
|
||||
currentSort,
|
||||
className,
|
||||
@@ -99,6 +81,7 @@ const UserListActions = ({
|
||||
total,
|
||||
...rest
|
||||
}) => {
|
||||
const redirectTo = useRedirect();
|
||||
return (
|
||||
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
|
||||
{filters &&
|
||||
@@ -118,10 +101,6 @@ const UserListActions = ({
|
||||
exporter={exporter}
|
||||
maxResults={maxResults}
|
||||
/>
|
||||
{/* Add your custom actions */}
|
||||
<Button component={Link} to={redirect} label="CSV Import">
|
||||
<GetAppIcon style={{ transform: "rotate(180deg)", fontSize: "20" }} />
|
||||
</Button>
|
||||
</TopToolbar>
|
||||
);
|
||||
};
|
||||
@@ -154,7 +133,7 @@ const UserBulkActionButtons = props => (
|
||||
{...props}
|
||||
label="resources.users.action.erase"
|
||||
confirmTitle="resources.users.helper.erase"
|
||||
mutationMode="pessimistic"
|
||||
undoable={false}
|
||||
/>
|
||||
</Fragment>
|
||||
);
|
||||
@@ -170,7 +149,6 @@ export const UserList = props => {
|
||||
{...props}
|
||||
filters={<UserFilter />}
|
||||
filterDefaultValues={{ guests: true, deactivated: false }}
|
||||
sort={{ field: "name", order: "ASC" }}
|
||||
actions={<UserListActions maxResults={10000} />}
|
||||
bulkActionButtons={<UserBulkActionButtons />}
|
||||
pagination={<UserPagination />}
|
||||
@@ -178,36 +156,60 @@ export const UserList = props => {
|
||||
<Datagrid rowClick="edit">
|
||||
<AvatarField
|
||||
source="avatar_src"
|
||||
sortable={false}
|
||||
className={classes.small}
|
||||
sortBy="avatar_url"
|
||||
/>
|
||||
<TextField source="id" sortBy="name" />
|
||||
<TextField source="id" sortable={false} />
|
||||
<TextField source="displayname" />
|
||||
<BooleanField source="is_guest" />
|
||||
<BooleanField source="admin" />
|
||||
<BooleanField source="deactivated" />
|
||||
<DateField
|
||||
source="creation_ts"
|
||||
label="resources.users.fields.creation_ts_ms"
|
||||
showTime
|
||||
options={date_format}
|
||||
<BooleanField source="is_guest" sortable={false} />
|
||||
<BooleanField source="admin" sortable={false} />
|
||||
<SelectField
|
||||
source="user_type"
|
||||
choices={[
|
||||
{ id: null, name: "resources.users.type.default" },
|
||||
{ id: "free", name: "resources.users.type.free" },
|
||||
{ id: "limited", name: "resources.users.type.limited" },
|
||||
]}
|
||||
/>
|
||||
<BooleanField source="deactivated" sortable={false} />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
};
|
||||
|
||||
// https://matrix.org/docs/spec/appendices#user-identifiers
|
||||
// here only local part of user_id
|
||||
// maxLength = 255 - "@" - ":" - localStorage.getItem("home_server").length
|
||||
// localStorage.getItem("home_server").length is not valid here
|
||||
const validateUser = [
|
||||
required(),
|
||||
maxLength(253),
|
||||
regex(/^[a-z0-9._=\-/]+$/, "synapseadmin.users.invalid_user_id"),
|
||||
];
|
||||
// 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 validateAddress = [required(), maxLength(255)];
|
||||
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
|
||||
const validateUser = regex(
|
||||
/^@[a-z0-9._=\-/]+:.*/,
|
||||
"synapseadmin.users.invalid_user_id"
|
||||
);
|
||||
|
||||
export function generateRandomUser() {
|
||||
const homeserver = localStorage.getItem("home_server");
|
||||
@@ -254,7 +256,17 @@ const UserEditToolbar = props => {
|
||||
const translate = useTranslate();
|
||||
return (
|
||||
<Toolbar {...props}>
|
||||
<SaveButton submitOnEnter={true} disabled={props.pristine} />
|
||||
<SaveQrButton
|
||||
label="synapseadmin.action.save_and_show"
|
||||
redirect={redirect}
|
||||
submitOnEnter={true}
|
||||
/>
|
||||
<SaveButton
|
||||
label="synapseadmin.action.save_only"
|
||||
redirect="list"
|
||||
submitOnEnter={false}
|
||||
variant="text"
|
||||
/>
|
||||
<DeleteButton
|
||||
label="resources.users.action.erase"
|
||||
confirmTitle={translate("resources.users.helper.erase", {
|
||||
@@ -268,37 +280,30 @@ const UserEditToolbar = props => {
|
||||
};
|
||||
|
||||
export const UserCreate = props => (
|
||||
<Create {...props}>
|
||||
<SimpleForm>
|
||||
<Create record={generateRandomUser()} {...props}>
|
||||
<SimpleForm toolbar={<UserCreateToolbar />}>
|
||||
<TextInput source="id" autoComplete="off" validate={validateUser} />
|
||||
<TextInput source="displayname" validate={maxLength(256)} />
|
||||
<PasswordInput
|
||||
source="password"
|
||||
autoComplete="new-password"
|
||||
validate={maxLength(512)}
|
||||
/>
|
||||
<TextInput source="displayname" />
|
||||
<PasswordInput source="password" autoComplete="new-password" />
|
||||
<BooleanInput source="admin" />
|
||||
<SelectInput
|
||||
source="user_type"
|
||||
choices={[
|
||||
{ id: null, name: "resources.users.type.default" },
|
||||
{ id: "free", name: "resources.users.type.free" },
|
||||
{ id: "limited", name: "resources.users.type.limited" },
|
||||
]}
|
||||
/>
|
||||
<ArrayInput source="threepids">
|
||||
<SimpleFormIterator disableReordering>
|
||||
<SimpleFormIterator>
|
||||
<SelectInput
|
||||
source="medium"
|
||||
choices={[
|
||||
{ id: "email", name: "resources.users.email" },
|
||||
{ id: "msisdn", name: "resources.users.msisdn" },
|
||||
]}
|
||||
validate={required()}
|
||||
/>
|
||||
<TextInput source="address" validate={validateAddress} />
|
||||
</SimpleFormIterator>
|
||||
</ArrayInput>
|
||||
<ArrayInput source="external_ids" label="synapseadmin.users.tabs.sso">
|
||||
<SimpleFormIterator disableReordering>
|
||||
<TextInput source="auth_provider" validate={required()} />
|
||||
<TextInput
|
||||
source="external_id"
|
||||
label="resources.users.fields.id"
|
||||
validate={required()}
|
||||
/>
|
||||
<TextInput source="address" />
|
||||
</SimpleFormIterator>
|
||||
</ArrayInput>
|
||||
</SimpleForm>
|
||||
@@ -316,6 +321,7 @@ const UserTitle = ({ record }) => {
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
export const UserEdit = props => {
|
||||
const classes = useStyles();
|
||||
const translate = useTranslate();
|
||||
@@ -334,12 +340,32 @@ export const UserEdit = props => {
|
||||
<TextInput source="id" disabled />
|
||||
<TextInput source="displayname" />
|
||||
<PasswordInput source="password" autoComplete="new-password" />
|
||||
<SelectInput
|
||||
source="user_type"
|
||||
choices={[
|
||||
{ id: null, name: "resources.users.type.default" },
|
||||
{ id: "free", name: "resources.users.type.free" },
|
||||
{ id: "limited", name: "resources.users.type.limited" },
|
||||
]}
|
||||
emptyText="resources.users.type.default"
|
||||
/>
|
||||
<BooleanInput source="admin" />
|
||||
<BooleanInput
|
||||
source="deactivated"
|
||||
helperText="resources.users.helper.deactivate"
|
||||
/>
|
||||
<DateField source="creation_ts_ms" showTime options={date_format} />
|
||||
<DateField
|
||||
source="creation_ts_ms"
|
||||
showTime
|
||||
options={{
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}}
|
||||
/>
|
||||
<TextField source="consent_version" />
|
||||
</FormTab>
|
||||
|
||||
@@ -349,7 +375,7 @@ export const UserEdit = props => {
|
||||
path="threepid"
|
||||
>
|
||||
<ArrayInput source="threepids">
|
||||
<SimpleFormIterator disableReordering>
|
||||
<SimpleFormIterator>
|
||||
<SelectInput
|
||||
source="medium"
|
||||
choices={[
|
||||
@@ -362,23 +388,6 @@ export const UserEdit = props => {
|
||||
</ArrayInput>
|
||||
</FormTab>
|
||||
|
||||
<FormTab
|
||||
label="synapseadmin.users.tabs.sso"
|
||||
icon={<AssignmentIndIcon />}
|
||||
path="sso"
|
||||
>
|
||||
<ArrayInput source="external_ids" label={false}>
|
||||
<SimpleFormIterator disableReordering>
|
||||
<TextInput source="auth_provider" validate={required()} />
|
||||
<TextInput
|
||||
source="external_id"
|
||||
label="resources.users.fields.id"
|
||||
validate={required()}
|
||||
/>
|
||||
</SimpleFormIterator>
|
||||
</ArrayInput>
|
||||
</FormTab>
|
||||
|
||||
<FormTab
|
||||
label={translate("resources.devices.name", { smart_count: 2 })}
|
||||
icon={<DevicesIcon />}
|
||||
@@ -396,7 +405,14 @@ export const UserEdit = props => {
|
||||
<DateField
|
||||
source="last_seen_ts"
|
||||
showTime
|
||||
options={date_format}
|
||||
options={{
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}}
|
||||
sortable={false}
|
||||
/>
|
||||
<DeviceRemoveButton />
|
||||
@@ -421,18 +437,23 @@ export const UserEdit = props => {
|
||||
>
|
||||
<Datagrid style={{ width: "100%" }}>
|
||||
<TextField source="ip" sortable={false} />
|
||||
<TextField source="port" sortable={false} emptyText="13001" />
|
||||
|
||||
<DateField
|
||||
source="last_seen"
|
||||
showTime
|
||||
options={date_format}
|
||||
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: "90%" }}
|
||||
style={{ width: "100%" }}
|
||||
/>
|
||||
</Datagrid>
|
||||
</ArrayField>
|
||||
@@ -450,44 +471,41 @@ export const UserEdit = props => {
|
||||
addLabel={false}
|
||||
pagination={<UserPagination />}
|
||||
perPage={50}
|
||||
sort={{ field: "created_ts", order: "DESC" }}
|
||||
>
|
||||
<Datagrid style={{ width: "100%" }}>
|
||||
<DateField source="created_ts" showTime options={date_format} />
|
||||
<DateField
|
||||
source="created_ts"
|
||||
showTime
|
||||
options={{
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}}
|
||||
sortable={false}
|
||||
/>
|
||||
<DateField
|
||||
source="last_access_ts"
|
||||
showTime
|
||||
options={date_format}
|
||||
options={{
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
}}
|
||||
sortable={false}
|
||||
/>
|
||||
<TextField source="media_id" />
|
||||
<NumberField source="media_length" />
|
||||
<TextField source="media_type" />
|
||||
<TextField source="upload_name" />
|
||||
<TextField source="quarantined_by" />
|
||||
<QuarantineMediaButton label="resources.quarantine_media.action.name" />
|
||||
<ProtectMediaButton label="resources.users_media.fields.safe_from_quarantine" />
|
||||
<DeleteButton mutationMode="pessimistic" redirect={false} />
|
||||
</Datagrid>
|
||||
</ReferenceManyField>
|
||||
</FormTab>
|
||||
|
||||
<FormTab
|
||||
label={translate("resources.urlpreview.name", { smart_count: 2 })}
|
||||
icon={<PermMediaIcon />}
|
||||
path="user_urlpreview"
|
||||
>
|
||||
<ReferenceManyField
|
||||
reference="user_urlpreview"
|
||||
target="user_id"
|
||||
addLabel={false}
|
||||
pagination={<UserPagination />}
|
||||
perPage={50}
|
||||
sort={{ field: "created_ts", order: "DESC" }}
|
||||
>
|
||||
<Datagrid style={{ width: "100%" }}>
|
||||
<DateField source="created_ts" showTime options={date_format} sortable={false} />
|
||||
<TextField source="media_id" sortable={false} />
|
||||
<TextField source="url_cache" sortable={false} />
|
||||
<NumberField source="media_length" sortable={false} />
|
||||
<TextField source="media_type" sortable={false} />
|
||||
<TextField source="upload_name" sortable={false} />
|
||||
<TextField source="quarantined_by" sortable={false} />
|
||||
<BooleanField source="safe_from_quarantine" sortable={false} />
|
||||
<DeleteButton mutationMode="pessimistic" redirect={false} />
|
||||
</Datagrid>
|
||||
</ReferenceManyField>
|
||||
</FormTab>
|
||||
|
||||
101
src/i18n/de.js
101
src/i18n/de.js
@@ -1,6 +1,6 @@
|
||||
import germanMessages from "ra-language-german";
|
||||
|
||||
const de = {
|
||||
export default {
|
||||
...germanMessages,
|
||||
synapseadmin: {
|
||||
auth: {
|
||||
@@ -10,14 +10,26 @@ const de = {
|
||||
username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'",
|
||||
protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen",
|
||||
url_error: "Keine gültige Matrix Server URL",
|
||||
sso_sign_in: "Anmeldung mit SSO",
|
||||
},
|
||||
action: {
|
||||
save_and_show: "Speichern und QR Code erzeugen",
|
||||
save_only: "Nur speichern",
|
||||
download_pdf: "PDF speichern",
|
||||
},
|
||||
users: {
|
||||
invalid_user_id: "Lokaler Anteil der Matrix Benutzer-ID ohne Homeserver.",
|
||||
tabs: { sso: "SSO" },
|
||||
invalid_user_id:
|
||||
"Muss eine vollständige Matrix Benutzer-ID sein, z.B. @benutzer_id:homeserver",
|
||||
},
|
||||
rooms: {
|
||||
details: "Raumdetails",
|
||||
room_name: "Raumname",
|
||||
make_public: "Öffentlicher Raum",
|
||||
encrypt: "Verschlüsselter Raum",
|
||||
room_name_required: "Muss angegeben werden",
|
||||
alias_required_if_public: "Muss für öffentliche Räume angegeben werden.",
|
||||
alias: "Alias",
|
||||
alias_too_long:
|
||||
"Darf zusammen mit der Domain des Homeservers 255 bytes nicht überschreiten",
|
||||
tabs: {
|
||||
basic: "Allgemein",
|
||||
members: "Mitglieder",
|
||||
@@ -97,6 +109,7 @@ const de = {
|
||||
},
|
||||
resources: {
|
||||
users: {
|
||||
backtolist: "Zurück zur Liste",
|
||||
name: "Benutzer",
|
||||
email: "E-Mail",
|
||||
msisdn: "Telefon",
|
||||
@@ -120,7 +133,18 @@ const de = {
|
||||
address: "Adresse",
|
||||
creation_ts_ms: "Zeitpunkt der Erstellung",
|
||||
consent_version: "Zugestimmte Geschäftsbedingungen",
|
||||
auth_provider: "Provider",
|
||||
user_type: "Kontotyp",
|
||||
// Devices:
|
||||
device_id: "Geräte-ID",
|
||||
display_name: "Gerätename",
|
||||
last_seen_ts: "Zeitstempel",
|
||||
last_seen_ip: "IP-Adresse",
|
||||
role: "Rolle",
|
||||
},
|
||||
type: {
|
||||
default: "Standard",
|
||||
free: "Basic",
|
||||
limited: "Eingeschränkt",
|
||||
},
|
||||
helper: {
|
||||
deactivate:
|
||||
@@ -130,6 +154,11 @@ const de = {
|
||||
action: {
|
||||
erase: "Lösche Benutzerdaten",
|
||||
},
|
||||
roles: {
|
||||
user: "Nutzer",
|
||||
mod: "Moderator",
|
||||
admin: "Administrator",
|
||||
},
|
||||
},
|
||||
rooms: {
|
||||
name: "Raum |||| Räume",
|
||||
@@ -138,6 +167,8 @@ const de = {
|
||||
name: "Name",
|
||||
canonical_alias: "Alias",
|
||||
joined_members: "Mitglieder",
|
||||
invite_members: "Mitglieder einladen",
|
||||
invitees: "Einladungen",
|
||||
joined_local_members: "Lokale Mitglieder",
|
||||
joined_local_devices: "Lokale Endgeräte",
|
||||
state_events: "Zustandsereignisse / Komplexität",
|
||||
@@ -153,10 +184,6 @@ const de = {
|
||||
topic: "Thema",
|
||||
avatar: "Avatar",
|
||||
},
|
||||
helper: {
|
||||
forward_extremities:
|
||||
"Forward extremities are the leaf events at the end of a Directed acyclic graph (DAG) in a room, aka events that have no children. The more exist in a room, the more state resolution that Synapse needs to perform (hint: it's an expensive operation). While Synapse has code to prevent too many of these existing at one time in a room, bugs can sometimes make them crop up again. If a room has >10 forward extremities, it's worth checking which room is the culprit and potentially removing them using the SQL queries mentioned in #1760.",
|
||||
},
|
||||
enums: {
|
||||
join_rules: {
|
||||
public: "Öffentlich",
|
||||
@@ -241,7 +268,7 @@ const de = {
|
||||
media_type: "Typ",
|
||||
upload_name: "Dateiname",
|
||||
quarantined_by: "Zur Quarantäne hinzugefügt",
|
||||
safe_from_quarantine: "Schutz vor Quarantäne",
|
||||
safe_from_quarantine: "Geschützt vor Quarantäne",
|
||||
created_ts: "Erstellt",
|
||||
last_access_ts: "Letzter Zugriff",
|
||||
},
|
||||
@@ -259,26 +286,8 @@ const de = {
|
||||
send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
|
||||
},
|
||||
helper: {
|
||||
send: "Diese API löscht die lokalen Medien von der Festplatte des eigenen Servers. Dies umfasst alle lokalen Miniaturbilder und Kopien von Medien. Diese API wirkt sich nicht auf Medien aus, die sich in externen Medien-Repositories befinden.",
|
||||
},
|
||||
},
|
||||
protect_media: {
|
||||
action: {
|
||||
create: "Ungeschützt, Schutz erstellen",
|
||||
delete: "Geschützt, Schutz aufheben",
|
||||
none: "In Quarantäne",
|
||||
send_success: "Erfolgreich den Schutz-Status geändert.",
|
||||
send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
|
||||
},
|
||||
},
|
||||
quarantine_media: {
|
||||
action: {
|
||||
name: "Quarantäne",
|
||||
create: "Zur Quarantäne hinzufügen",
|
||||
delete: "In Quarantäne, Quarantäne aufheben",
|
||||
none: "Geschützt vor Quarantäne",
|
||||
send_success: "Erfolgreich den Quarantäne-Status geändert.",
|
||||
send_failure: "Beim Versenden ist ein Fehler aufgetreten.",
|
||||
send:
|
||||
"Diese API löscht die lokalen Medien von der Festplatte des eigenen Servers. Dies umfasst alle lokalen Miniaturbilder und Kopien von Medien. Diese API wirkt sich nicht auf Medien aus, die sich in externen Medien-Repositories befinden.",
|
||||
},
|
||||
},
|
||||
pushers: {
|
||||
@@ -307,7 +316,8 @@ const de = {
|
||||
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.',
|
||||
send:
|
||||
'Sendet eine Serverbenachrichtigung an die ausgewählten Nutzer. Hierfür muss das Feature "Server Notices" auf dem Server aktiviert sein.',
|
||||
},
|
||||
},
|
||||
user_media_statistics: {
|
||||
@@ -317,15 +327,6 @@ const de = {
|
||||
media_length: "Größe der Dateien",
|
||||
},
|
||||
},
|
||||
forward_extremities: {
|
||||
name: "Vorderextremitäten",
|
||||
fields: {
|
||||
id: "Event-ID",
|
||||
received_ts: "Zeitstempel",
|
||||
depth: "Tiefe",
|
||||
state_group: "Zustandsgruppe",
|
||||
},
|
||||
},
|
||||
room_state: {
|
||||
name: "Zustandsereignisse",
|
||||
fields: {
|
||||
@@ -352,19 +353,6 @@ const de = {
|
||||
send_failure: "Beim Entfernen ist ein Fehler aufgetreten.",
|
||||
},
|
||||
},
|
||||
registration_tokens: {
|
||||
name: "Registrierungstoken",
|
||||
fields: {
|
||||
token: "Token",
|
||||
valid: "Gültige Token",
|
||||
uses_allowed: "Anzahl",
|
||||
pending: "Ausstehend",
|
||||
completed: "Abgeschlossen",
|
||||
expiry_time: "Ablaufzeit",
|
||||
length: "Länge",
|
||||
},
|
||||
helper: { length: "Länge des Tokens, wenn kein Token vorgegeben wird." },
|
||||
},
|
||||
},
|
||||
ra: {
|
||||
...germanMessages.ra,
|
||||
@@ -385,7 +373,7 @@ const de = {
|
||||
},
|
||||
},
|
||||
notification: {
|
||||
...germanMessages.ra.notification,
|
||||
...germanMessages.ra.notifiaction,
|
||||
logged_out: "Abgemeldet",
|
||||
},
|
||||
page: {
|
||||
@@ -393,10 +381,5 @@ const de = {
|
||||
empty: "Keine Einträge vorhanden",
|
||||
invite: "",
|
||||
},
|
||||
navigation: {
|
||||
...germanMessages.ra.navigation,
|
||||
skip_nav: "Zum Inhalt springen",
|
||||
},
|
||||
},
|
||||
};
|
||||
export default de;
|
||||
|
||||
105
src/i18n/en.js
105
src/i18n/en.js
@@ -1,6 +1,6 @@
|
||||
import englishMessages from "ra-language-english";
|
||||
|
||||
const en = {
|
||||
export default {
|
||||
...englishMessages,
|
||||
synapseadmin: {
|
||||
auth: {
|
||||
@@ -10,13 +10,26 @@ const en = {
|
||||
username_error: "Please enter fully qualified user ID: '@user:domain'",
|
||||
protocol_error: "URL has to start with 'http://' or 'https://'",
|
||||
url_error: "Not a valid Matrix server URL",
|
||||
sso_sign_in: "Sign in with SSO",
|
||||
},
|
||||
action: {
|
||||
save_and_show: "Create QR code",
|
||||
save_only: "Save",
|
||||
download_pdf: "Download PDF",
|
||||
},
|
||||
users: {
|
||||
invalid_user_id: "Localpart of a Matrix user-id without homeserver.",
|
||||
tabs: { sso: "SSO" },
|
||||
invalid_user_id:
|
||||
"Must be a fully qualified Matrix user-id, e.g. @user_id:homeserver",
|
||||
},
|
||||
rooms: {
|
||||
details: "Room Details",
|
||||
room_name: "Room Name",
|
||||
make_public: "Make room public",
|
||||
encrypt: "Encrypt room",
|
||||
room_name_required: "Must be provided",
|
||||
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.",
|
||||
tabs: {
|
||||
basic: "Basic",
|
||||
members: "Members",
|
||||
@@ -96,6 +109,7 @@ const en = {
|
||||
},
|
||||
resources: {
|
||||
users: {
|
||||
backtolist: "Back to list",
|
||||
name: "User |||| Users",
|
||||
email: "Email",
|
||||
msisdn: "Phone",
|
||||
@@ -119,7 +133,17 @@ const en = {
|
||||
address: "Address",
|
||||
creation_ts_ms: "Creation timestamp",
|
||||
consent_version: "Consent version",
|
||||
auth_provider: "Provider",
|
||||
// Devices:
|
||||
device_id: "Device-ID",
|
||||
display_name: "Device name",
|
||||
last_seen_ts: "Timestamp",
|
||||
last_seen_ip: "IP address",
|
||||
role: "Role",
|
||||
},
|
||||
type: {
|
||||
default: "Standard",
|
||||
free: "Basic",
|
||||
limited: "Limited",
|
||||
},
|
||||
helper: {
|
||||
deactivate: "You must provide a password to re-activate an account.",
|
||||
@@ -128,6 +152,11 @@ const en = {
|
||||
action: {
|
||||
erase: "Erase user data",
|
||||
},
|
||||
roles: {
|
||||
user: "User",
|
||||
mod: "Moderator",
|
||||
admin: "Administrator",
|
||||
},
|
||||
},
|
||||
rooms: {
|
||||
name: "Room |||| Rooms",
|
||||
@@ -136,6 +165,8 @@ const en = {
|
||||
name: "Name",
|
||||
canonical_alias: "Alias",
|
||||
joined_members: "Members",
|
||||
invite_members: "Invite Members",
|
||||
invitees: "Invitations",
|
||||
joined_local_members: "Local members",
|
||||
joined_local_devices: "Local devices",
|
||||
state_events: "State events / Complexity",
|
||||
@@ -151,10 +182,6 @@ const en = {
|
||||
topic: "Topic",
|
||||
avatar: "Avatar",
|
||||
},
|
||||
helper: {
|
||||
forward_extremities:
|
||||
"Forward extremities are the leaf events at the end of a Directed acyclic graph (DAG) in a room, aka events that have no children. The more exist in a room, the more state resolution that Synapse needs to perform (hint: it's an expensive operation). While Synapse has code to prevent too many of these existing at one time in a room, bugs can sometimes make them crop up again. If a room has >10 forward extremities, it's worth checking which room is the culprit and potentially removing them using the SQL queries mentioned in #1760.",
|
||||
},
|
||||
enums: {
|
||||
join_rules: {
|
||||
public: "Public",
|
||||
@@ -174,12 +201,10 @@ const en = {
|
||||
},
|
||||
unencrypted: "Unencrypted",
|
||||
},
|
||||
action: {
|
||||
erase: {
|
||||
title: "Delete room",
|
||||
content:
|
||||
"Are you sure you want to delete the room? This cannot be undone. All messages and shared media in the room will be deleted from the server!",
|
||||
},
|
||||
erase: {
|
||||
title: "Delete room",
|
||||
content:
|
||||
"Are you sure you want to delete the room? This cannot be undone. All messages and shared media in the room will be deleted from the server!",
|
||||
},
|
||||
},
|
||||
reports: {
|
||||
@@ -235,7 +260,7 @@ const en = {
|
||||
name: "Media",
|
||||
fields: {
|
||||
media_id: "Media ID",
|
||||
media_length: "File Size (in Bytes)",
|
||||
media_length: "Lenght",
|
||||
media_type: "Type",
|
||||
upload_name: "File name",
|
||||
quarantined_by: "Quarantined by",
|
||||
@@ -257,26 +282,8 @@ const en = {
|
||||
send_failure: "An error has occurred.",
|
||||
},
|
||||
helper: {
|
||||
send: "This API deletes the local media from the disk of your own server. This includes any local thumbnails and copies of media downloaded. This API will not affect media that has been uploaded to external media repositories.",
|
||||
},
|
||||
},
|
||||
protect_media: {
|
||||
action: {
|
||||
create: "Unprotected, create protection",
|
||||
delete: "Protected, remove protection",
|
||||
none: "In quarantine",
|
||||
send_success: "Successfully changed the protection status.",
|
||||
send_failure: "An error has occurred.",
|
||||
},
|
||||
},
|
||||
quarantine_media: {
|
||||
action: {
|
||||
name: "Quarantine",
|
||||
create: "Add to quarantine",
|
||||
delete: "In quarantine, unquarantine",
|
||||
none: "Protected from quarantine",
|
||||
send_success: "Successfully changed the quarantine status.",
|
||||
send_failure: "An error has occurred.",
|
||||
send:
|
||||
"This API deletes the local media from the disk of your own server. This includes any local thumbnails and copies of media downloaded. This API will not affect media that has been uploaded to external media repositories.",
|
||||
},
|
||||
},
|
||||
pushers: {
|
||||
@@ -305,7 +312,8 @@ const en = {
|
||||
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.',
|
||||
send:
|
||||
'Sends a server notice to the selected users. The feature "Server Notices" has to be activated at the server.',
|
||||
},
|
||||
},
|
||||
user_media_statistics: {
|
||||
@@ -315,15 +323,6 @@ const en = {
|
||||
media_length: "Media length",
|
||||
},
|
||||
},
|
||||
forward_extremities: {
|
||||
name: "Forward Extremities",
|
||||
fields: {
|
||||
id: "Event ID",
|
||||
received_ts: "Timestamp",
|
||||
depth: "Depth",
|
||||
state_group: "State group",
|
||||
},
|
||||
},
|
||||
room_state: {
|
||||
name: "State events",
|
||||
fields: {
|
||||
@@ -351,18 +350,4 @@ const en = {
|
||||
},
|
||||
},
|
||||
},
|
||||
registration_tokens: {
|
||||
name: "Registration tokens",
|
||||
fields: {
|
||||
token: "Token",
|
||||
valid: "Valid token",
|
||||
uses_allowed: "Uses allowed",
|
||||
pending: "Pending",
|
||||
completed: "Completed",
|
||||
expiry_time: "Expiry time",
|
||||
length: "Length",
|
||||
},
|
||||
helper: { length: "Length of the token if no token is given." },
|
||||
},
|
||||
};
|
||||
export default en;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import chineseMessages from "ra-language-chinese";
|
||||
|
||||
const zh = {
|
||||
export default {
|
||||
...chineseMessages,
|
||||
synapseadmin: {
|
||||
auth: {
|
||||
@@ -10,12 +10,10 @@ const zh = {
|
||||
username_error: "请输入完整有效的用户 ID: '@user:domain'",
|
||||
protocol_error: "URL 需要以'http://'或'https://'作为起始",
|
||||
url_error: "不是一个有效的 Matrix 服务器地址",
|
||||
sso_sign_in: "使用 SSO 登录",
|
||||
},
|
||||
users: {
|
||||
invalid_user_id:
|
||||
"必须要是一个有效的 Matrix 用户 ID ,例如 @user_id:homeserver",
|
||||
tabs: { sso: "SSO" },
|
||||
},
|
||||
rooms: {
|
||||
tabs: {
|
||||
@@ -100,6 +98,7 @@ const zh = {
|
||||
},
|
||||
resources: {
|
||||
users: {
|
||||
backtolist: "回到列表",
|
||||
name: "用户",
|
||||
email: "邮箱",
|
||||
msisdn: "电话",
|
||||
@@ -123,7 +122,6 @@ const zh = {
|
||||
address: "地址",
|
||||
creation_ts_ms: "创建时间戳",
|
||||
consent_version: "协议版本",
|
||||
device_id: "设备ID"
|
||||
},
|
||||
helper: {
|
||||
deactivate: "您必须提供一串密码来激活账户。",
|
||||
@@ -171,16 +169,13 @@ const zh = {
|
||||
},
|
||||
unencrypted: "未加密",
|
||||
},
|
||||
helper: {
|
||||
forward_extremities: "转发"
|
||||
}
|
||||
},
|
||||
reports: {
|
||||
name: "举报事件",
|
||||
name: "报告事件",
|
||||
fields: {
|
||||
id: "ID",
|
||||
received_ts: "举报时间",
|
||||
user_id: "举报者",
|
||||
received_ts: "报告时间",
|
||||
user_id: "报告者",
|
||||
name: "房间名",
|
||||
score: "分数",
|
||||
reason: "原因",
|
||||
@@ -203,8 +198,7 @@ const zh = {
|
||||
name: "连接",
|
||||
fields: {
|
||||
last_seen: "日期",
|
||||
ip: "源IP地址",
|
||||
port: "源端口",
|
||||
ip: "IP 地址",
|
||||
user_agent: "用户代理 (UA)",
|
||||
},
|
||||
},
|
||||
@@ -251,7 +245,8 @@ const zh = {
|
||||
send_failure: "出现了一个错误。",
|
||||
},
|
||||
helper: {
|
||||
send: "这个API会删除您硬盘上的本地媒体。包含了任何的本地缓存和下载的媒体备份。这个API不会影响上传到外部媒体存储库上的媒体文件。",
|
||||
send:
|
||||
"这个API会删除您硬盘上的本地媒体。包含了任何的本地缓存和下载的媒体备份。这个API不会影响上传到外部媒体存储库上的媒体文件。",
|
||||
},
|
||||
},
|
||||
pushers: {
|
||||
@@ -280,7 +275,8 @@ const zh = {
|
||||
send_failure: "出现了一个错误。",
|
||||
},
|
||||
helper: {
|
||||
send: '向选中的用户发送服务器提示。服务器配置中的 "服务器提示(Server Notices)" 选项需要被设置为启用。',
|
||||
send:
|
||||
'向选中的用户发送服务器提示。服务器配置中的 "服务器提示(Server Notices)" 选项需要被设置为启用。',
|
||||
},
|
||||
},
|
||||
user_media_statistics: {
|
||||
@@ -290,29 +286,5 @@ const zh = {
|
||||
media_length: "媒体文件长度",
|
||||
},
|
||||
},
|
||||
room_state: {
|
||||
name: "状态"
|
||||
},
|
||||
room_directory:{
|
||||
name: "目录",
|
||||
action: {
|
||||
create: "新建"
|
||||
}
|
||||
},
|
||||
forward_extremities: {
|
||||
name: "转发"
|
||||
},
|
||||
registration_tokens: {
|
||||
name: "注册"
|
||||
},
|
||||
urlpreview: {
|
||||
name: "第三方链接"
|
||||
},
|
||||
quarantine_media: {
|
||||
action: {
|
||||
name: "隔离"
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
export default zh;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { configure } from "enzyme";
|
||||
import Adapter from "enzyme-adapter-react-16";
|
||||
import fetchMock from "jest-fetch-mock";
|
||||
|
||||
configure({ adapter: new Adapter() });
|
||||
fetchMock.enableMocks();
|
||||
|
||||
@@ -2,37 +2,21 @@ import { fetchUtils } from "react-admin";
|
||||
|
||||
const authProvider = {
|
||||
// called when the user attempts to log in
|
||||
login: ({ base_url, username, password, loginToken }) => {
|
||||
// force homeserver for protection in case the form is manipulated
|
||||
base_url = process.env.REACT_APP_SERVER || base_url;
|
||||
|
||||
login: ({ base_url, username, password }) => {
|
||||
console.log("login ");
|
||||
const options = {
|
||||
method: "POST",
|
||||
body: JSON.stringify(
|
||||
Object.assign(
|
||||
{
|
||||
device_id: localStorage.getItem("device_id"),
|
||||
initial_device_display_name: "Synapse Admin",
|
||||
},
|
||||
loginToken
|
||||
? {
|
||||
type: "m.login.token",
|
||||
token: loginToken,
|
||||
}
|
||||
: {
|
||||
type: "m.login.password",
|
||||
user: username,
|
||||
password: password,
|
||||
}
|
||||
)
|
||||
),
|
||||
body: JSON.stringify({
|
||||
type: "m.login.password",
|
||||
user: username,
|
||||
password: password,
|
||||
initial_device_display_name: "Synapse Admin",
|
||||
}),
|
||||
};
|
||||
|
||||
// use the base_url from login instead of the well_known entry from the
|
||||
// server, since the admin might want to access the admin API via some
|
||||
// private address
|
||||
base_url = base_url.replace(/\/+$/g, "");
|
||||
localStorage.setItem("base_url", base_url);
|
||||
|
||||
const decoded_base_url = window.decodeURIComponent(base_url);
|
||||
@@ -64,6 +48,7 @@ const authProvider = {
|
||||
if (typeof access_token === "string") {
|
||||
fetchUtils.fetchJson(logout_api_url, options).then(({ json }) => {
|
||||
localStorage.removeItem("access_token");
|
||||
localStorage.removeItem("device_id");
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
||||
@@ -25,6 +25,16 @@ const mxcUrlToHttp = mxcUrl => {
|
||||
return `${homeserver}/_matrix/media/r0/thumbnail/${serverName}/${mediaId}?width=24&height=24&method=scale`;
|
||||
};
|
||||
|
||||
const powerLevelToRole = powerLevel =>
|
||||
powerLevel < 100 ? (powerLevel < 50 ? "user" : "mod") : "admin";
|
||||
|
||||
const POWER_LEVELS = {
|
||||
admin: 100,
|
||||
mod: 50,
|
||||
user: 0,
|
||||
};
|
||||
const roleToPowerLevel = role => POWER_LEVELS[role] || 0;
|
||||
|
||||
const resourceMap = {
|
||||
users: {
|
||||
path: "/_synapse/admin/v2/users",
|
||||
@@ -35,15 +45,14 @@ const resourceMap = {
|
||||
is_guest: !!u.is_guest,
|
||||
admin: !!u.admin,
|
||||
deactivated: !!u.deactivated,
|
||||
displayname: u.display_name || u.displayname,
|
||||
// need timestamp in milliseconds
|
||||
creation_ts_ms: u.creation_ts * 1000,
|
||||
}),
|
||||
data: "users",
|
||||
total: json => json.total,
|
||||
create: data => ({
|
||||
endpoint: `/_synapse/admin/v2/users/@${data.id}:${localStorage.getItem(
|
||||
"home_server"
|
||||
)}`,
|
||||
endpoint: `/_synapse/admin/v2/users/${data.id}`,
|
||||
body: data,
|
||||
method: "PUT",
|
||||
}),
|
||||
@@ -65,12 +74,45 @@ const resourceMap = {
|
||||
public: !!r.public,
|
||||
}),
|
||||
data: "rooms",
|
||||
total: json => {
|
||||
return json.total_rooms;
|
||||
total: json => json.total_rooms,
|
||||
create: data => ({
|
||||
endpoint: "/_synapse/admin/v1/rooms",
|
||||
body: {
|
||||
owner: data.owner,
|
||||
name: data.name,
|
||||
room_alias_name: data.canonical_alias,
|
||||
visibility: data.public ? "public" : "private",
|
||||
invite:
|
||||
Array.isArray(data.invitees) && data.invitees.length > 0
|
||||
? data.invitees
|
||||
: undefined,
|
||||
initial_state: data.encrypt
|
||||
? [
|
||||
{
|
||||
type: "m.room.encryption",
|
||||
state_key: "",
|
||||
content: {
|
||||
algorithm: "m.megolm.v1.aes-sha2",
|
||||
},
|
||||
},
|
||||
]
|
||||
: undefined,
|
||||
},
|
||||
method: "POST",
|
||||
}),
|
||||
transformBeforeUpdate: data => {
|
||||
return {
|
||||
...data,
|
||||
member_roles: (data.member_roles || []).map(member => ({
|
||||
member_id: member.member_id,
|
||||
power_level: roleToPowerLevel(member.role),
|
||||
})),
|
||||
};
|
||||
},
|
||||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v1/rooms/${params.id}`,
|
||||
endpoint: `/_synapse/admin/v1/rooms/${params.id}/delete`,
|
||||
body: { block: false },
|
||||
method: "POST",
|
||||
}),
|
||||
},
|
||||
reports: {
|
||||
@@ -102,7 +144,7 @@ const resourceMap = {
|
||||
path: "/_synapse/admin/v1/whois",
|
||||
map: c => ({
|
||||
...c,
|
||||
id: c.user_id
|
||||
id: c.user_id,
|
||||
}),
|
||||
data: "connections",
|
||||
},
|
||||
@@ -156,19 +198,6 @@ const resourceMap = {
|
||||
return json.total;
|
||||
},
|
||||
},
|
||||
user_urlpreview: {
|
||||
map: uu => ({
|
||||
...uu,
|
||||
id: uu.media_id,
|
||||
}),
|
||||
reference: id => ({
|
||||
endpoint: `/_synapse/admin/v1/users/${id}/urlpreview`,
|
||||
}),
|
||||
data: "urlpreview",
|
||||
total: json => {
|
||||
return json.total;
|
||||
},
|
||||
},
|
||||
users_media: {
|
||||
map: um => ({
|
||||
...um,
|
||||
@@ -197,32 +226,6 @@ const resourceMap = {
|
||||
method: "POST",
|
||||
}),
|
||||
},
|
||||
protect_media: {
|
||||
map: pm => ({ id: pm.media_id }),
|
||||
create: params => ({
|
||||
endpoint: `/_synapse/admin/v1/media/protect/${params.media_id}`,
|
||||
method: "POST",
|
||||
}),
|
||||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v1/media/unprotect/${params.media_id}`,
|
||||
method: "POST",
|
||||
}),
|
||||
},
|
||||
quarantine_media: {
|
||||
map: qm => ({ id: qm.media_id }),
|
||||
create: params => ({
|
||||
endpoint: `/_synapse/admin/v1/media/quarantine/${localStorage.getItem(
|
||||
"home_server"
|
||||
)}/${params.media_id}`,
|
||||
method: "POST",
|
||||
}),
|
||||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v1/media/unquarantine/${localStorage.getItem(
|
||||
"home_server"
|
||||
)}/${params.media_id}`,
|
||||
method: "POST",
|
||||
}),
|
||||
},
|
||||
servernotices: {
|
||||
map: n => ({ id: n.event_id }),
|
||||
create: data => ({
|
||||
@@ -248,22 +251,6 @@ const resourceMap = {
|
||||
return json.total;
|
||||
},
|
||||
},
|
||||
forward_extremities: {
|
||||
map: fe => ({
|
||||
...fe,
|
||||
id: fe.event_id,
|
||||
}),
|
||||
reference: id => ({
|
||||
endpoint: `/_synapse/admin/v1/rooms/${id}/forward_extremities`,
|
||||
}),
|
||||
data: "results",
|
||||
total: json => {
|
||||
return json.count;
|
||||
},
|
||||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v1/rooms/${params.id}/forward_extremities`,
|
||||
}),
|
||||
},
|
||||
room_directory: {
|
||||
path: "/_matrix/client/r0/publicRooms",
|
||||
map: rd => ({
|
||||
@@ -288,25 +275,6 @@ const resourceMap = {
|
||||
method: "PUT",
|
||||
}),
|
||||
},
|
||||
registration_tokens: {
|
||||
path: "/_synapse/admin/v1/registration_tokens",
|
||||
map: rt => ({
|
||||
...rt,
|
||||
id: rt.token,
|
||||
}),
|
||||
data: "registration_tokens",
|
||||
total: json => {
|
||||
return json.registration_tokens.length;
|
||||
},
|
||||
create: params => ({
|
||||
endpoint: "/_synapse/admin/v1/registration_tokens/new",
|
||||
body: params,
|
||||
method: "POST",
|
||||
}),
|
||||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v1/registration_tokens/${params.id}`,
|
||||
}),
|
||||
}
|
||||
};
|
||||
|
||||
function filterNullValues(key, value) {
|
||||
@@ -328,8 +296,7 @@ function getSearchOrder(order) {
|
||||
const dataProvider = {
|
||||
getList: (resource, params) => {
|
||||
console.log("getList " + resource);
|
||||
const { user_id, name, guests, deactivated, search_term, valid } =
|
||||
params.filter;
|
||||
const { user_id, name, guests, deactivated, search_term } = params.filter;
|
||||
const { page, perPage } = params.pagination;
|
||||
const { field, order } = params.sort;
|
||||
const from = (page - 1) * perPage;
|
||||
@@ -341,7 +308,6 @@ const dataProvider = {
|
||||
name: name,
|
||||
guests: guests,
|
||||
deactivated: deactivated,
|
||||
valid: valid,
|
||||
order_by: field,
|
||||
dir: getSearchOrder(order),
|
||||
};
|
||||
@@ -360,7 +326,7 @@ const dataProvider = {
|
||||
},
|
||||
|
||||
getOne: (resource, params) => {
|
||||
console.log("getOne " + resource);
|
||||
console.log("getOne " + resource, params);
|
||||
const homeserver = localStorage.getItem("base_url");
|
||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||
|
||||
@@ -391,13 +357,10 @@ const dataProvider = {
|
||||
getManyReference: (resource, params) => {
|
||||
console.log("getManyReference " + resource);
|
||||
const { page, perPage } = params.pagination;
|
||||
const { field, order } = params.sort;
|
||||
const from = (page - 1) * perPage;
|
||||
const query = {
|
||||
from: from,
|
||||
limit: perPage,
|
||||
order_by: field,
|
||||
dir: getSearchOrder(order),
|
||||
};
|
||||
|
||||
const homeserver = localStorage.getItem("base_url");
|
||||
@@ -421,10 +384,13 @@ const dataProvider = {
|
||||
|
||||
const res = resourceMap[resource];
|
||||
|
||||
const transform = res.transformBeforeUpdate || (x => x);
|
||||
const data = transform(params.data);
|
||||
|
||||
const endpoint_url = homeserver + res.path;
|
||||
return jsonClient(`${endpoint_url}/${params.data.id}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(params.data, filterNullValues),
|
||||
body: JSON.stringify(data, filterNullValues),
|
||||
}).then(({ json }) => ({
|
||||
data: res.map(json),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user