Compare commits
37 Commits
0.8.5
..
AMP/2021.08
| Author | SHA1 | Date | |
|---|---|---|---|
| 444f648191 | |||
| af51cca461 | |||
| 364234f4f4 | |||
| 1fe0b2f330 | |||
| 1aaa137afe | |||
| 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 |
@@ -2,14 +2,8 @@ name: Create docker image(s) and push to docker hub
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
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:
|
tags:
|
||||||
- '[0-9]+\.[0-9]+\.[0-9]+' # Push events to 0.X.X tag
|
- '[0-9]+\.[0-9]+\.[0-9]+'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
docker:
|
docker:
|
||||||
@@ -27,25 +21,16 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
- name: Calculate docker image tag
|
- name: Build and push
|
||||||
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
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
|
||||||
tags: "awesometechnologies/synapse-admin:${{ steps.set-tag.outputs.tag }}"
|
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: awesometechnologies/synapse-admin:latest
|
||||||
|
- name: Update repo description
|
||||||
|
uses: peter-evans/dockerhub-description@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
repository: awesometechnologies/synapse-admin
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -8,9 +8,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@
|
|||||||
"trailingComma": "es5",
|
"trailingComma": "es5",
|
||||||
"bracketSpacing": true,
|
"bracketSpacing": true,
|
||||||
"jsxBracketSameLine": false,
|
"jsxBracketSameLine": false,
|
||||||
"arrowParens": "avoid"
|
"arrowParens": "avoid",
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Builder
|
# Builder
|
||||||
FROM node:lts as builder
|
FROM node:current as builder
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
This project is built using [react-admin](https://marmelab.com/react-admin/).
|
This project is built using [react-admin](https://marmelab.com/react-admin/).
|
||||||
|
|
||||||
It needs at least Synapse v1.42.0 for all functions to work as expected!
|
It needs at least Synapse v1.38.0 for all functions to work as expected!
|
||||||
|
|
||||||
You get your server version with the request `/_synapse/admin/v1/server_version`.
|
You get your server version with the request `/_synapse/admin/v1/server_version`.
|
||||||
See also [Synapse version API](https://matrix-org.github.io/synapse/develop/admin_api/version_api.html).
|
See also [Synapse version API](https://matrix-org.github.io/synapse/develop/admin_api/version_api.html).
|
||||||
@@ -19,15 +19,15 @@ You need access to the following endpoints:
|
|||||||
|
|
||||||
See also [Synapse administration endpoints](https://matrix-org.github.io/synapse/develop/reverse_proxy.html#synapse-administration-endpoints)
|
See also [Synapse administration endpoints](https://matrix-org.github.io/synapse/develop/reverse_proxy.html#synapse-administration-endpoints)
|
||||||
|
|
||||||
## Step-By-Step install
|
## Step-By-Step install:
|
||||||
|
|
||||||
You have three options:
|
You have three options:
|
||||||
|
|
||||||
1. [Download the tarball and serve with any webserver](#steps-for-1)
|
1. Download the tarball and serve with any webserver
|
||||||
2. [Download the source code from github and run using nodejs](#steps-for-2)
|
2. Download the source code from github and run using nodejs
|
||||||
3. [Run the Docker container](#steps-for-3)
|
3. Run the Docker container
|
||||||
|
|
||||||
### Steps for 1)
|
Steps for 1):
|
||||||
|
|
||||||
- make sure you have a webserver installed that can serve static files (any webserver like nginx or apache will do)
|
- 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
|
- configure a vhost for synapse admin on your webserver
|
||||||
@@ -36,7 +36,7 @@ You have three options:
|
|||||||
- move or symlink the `synapse-admin-x.x.x` into your vhosts root dir
|
- move or symlink the `synapse-admin-x.x.x` into your vhosts root dir
|
||||||
- open the url of the vhost in your browser
|
- open the url of the vhost in your browser
|
||||||
|
|
||||||
### Steps for 2)
|
Steps for 2):
|
||||||
|
|
||||||
- make sure you have installed the following: git, yarn, nodejs
|
- make sure you have installed the following: git, yarn, nodejs
|
||||||
- download the source code: `git clone https://github.com/Awesome-Technologies/synapse-admin.git`
|
- download the source code: `git clone https://github.com/Awesome-Technologies/synapse-admin.git`
|
||||||
@@ -49,7 +49,7 @@ Either you define it at startup (e.g. `REACT_APP_SERVER=https://yourmatrixserver
|
|||||||
or by editing it in the [.env](.env) file. See also the
|
or by editing it in the [.env](.env) file. See also the
|
||||||
[documentation](https://create-react-app.dev/docs/adding-custom-environment-variables/).
|
[documentation](https://create-react-app.dev/docs/adding-custom-environment-variables/).
|
||||||
|
|
||||||
### Steps for 3)
|
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`
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "synapse-admin",
|
"name": "synapse-admin",
|
||||||
"version": "0.8.5",
|
"version": "AMP/2021.08",
|
||||||
"description": "Admin GUI for the Matrix.org server Synapse",
|
"description": "Admin GUI for the Matrix.org server Synapse",
|
||||||
"author": "Awesome Technologies Innovationslabor GmbH",
|
"author": "Awesome Technologies Innovationslabor GmbH",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
@@ -21,8 +21,12 @@
|
|||||||
"ra-test": "^3.15.0"
|
"ra-test": "^3.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@progress/kendo-drawing": "^1.6.0",
|
||||||
|
"@progress/kendo-react-pdf": "^3.10.1",
|
||||||
|
"babel-preset-jest": "^24.9.0",
|
||||||
"papaparse": "^5.2.0",
|
"papaparse": "^5.2.0",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
|
"qrcode.react": "^1.0.0",
|
||||||
"ra-language-chinese": "^2.0.10",
|
"ra-language-chinese": "^2.0.10",
|
||||||
"ra-language-german": "^3.13.4",
|
"ra-language-german": "^3.13.4",
|
||||||
"react": "^17.0.0",
|
"react": "^17.0.0",
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 358 KiB |
@@ -9,6 +9,32 @@
|
|||||||
name="description"
|
name="description"
|
||||||
content="Synapse-Admin"
|
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
|
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/
|
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||||
|
|||||||
+13
-17
@@ -4,27 +4,22 @@ import polyglotI18nProvider from "ra-i18n-polyglot";
|
|||||||
import authProvider from "./synapse/authProvider";
|
import authProvider from "./synapse/authProvider";
|
||||||
import dataProvider from "./synapse/dataProvider";
|
import dataProvider from "./synapse/dataProvider";
|
||||||
import { UserList, UserCreate, UserEdit } from "./components/users";
|
import { UserList, UserCreate, UserEdit } from "./components/users";
|
||||||
import { RoomList, RoomShow } from "./components/rooms";
|
import { RoomList, RoomCreate, RoomShow, RoomEdit } from "./components/rooms";
|
||||||
import { ReportList, ReportShow } from "./components/EventReports";
|
import { ReportList, ReportShow } from "./components/EventReports";
|
||||||
|
import ImportFeature from "./components/ImportFeature";
|
||||||
import LoginPage from "./components/LoginPage";
|
import LoginPage from "./components/LoginPage";
|
||||||
import UserIcon from "@material-ui/icons/Group";
|
import UserIcon from "@material-ui/icons/Group";
|
||||||
import ConfirmationNumberIcon from "@material-ui/icons/ConfirmationNumber";
|
|
||||||
import EqualizerIcon from "@material-ui/icons/Equalizer";
|
import EqualizerIcon from "@material-ui/icons/Equalizer";
|
||||||
import { UserMediaStatsList } from "./components/statistics";
|
import { UserMediaStatsList } from "./components/statistics";
|
||||||
import RoomIcon from "@material-ui/icons/ViewList";
|
import RoomIcon from "@material-ui/icons/ViewList";
|
||||||
import ReportIcon from "@material-ui/icons/Warning";
|
import ReportIcon from "@material-ui/icons/Warning";
|
||||||
import FolderSharedIcon from "@material-ui/icons/FolderShared";
|
import FolderSharedIcon from "@material-ui/icons/FolderShared";
|
||||||
import { ImportFeature } from "./components/ImportFeature";
|
|
||||||
import {
|
|
||||||
RegistrationTokenCreate,
|
|
||||||
RegistrationTokenEdit,
|
|
||||||
RegistrationTokenList,
|
|
||||||
} from "./components/RegistrationTokens";
|
|
||||||
import { RoomDirectoryList } from "./components/RoomDirectory";
|
import { RoomDirectoryList } from "./components/RoomDirectory";
|
||||||
import { Route } from "react-router-dom";
|
import { Route } from "react-router-dom";
|
||||||
import germanMessages from "./i18n/de";
|
import germanMessages from "./i18n/de";
|
||||||
import englishMessages from "./i18n/en";
|
import englishMessages from "./i18n/en";
|
||||||
import chineseMessages from "./i18n/zh";
|
import chineseMessages from "./i18n/zh";
|
||||||
|
import ShowUserPdf from "./components/ShowUserPdf";
|
||||||
|
|
||||||
// TODO: Can we use lazy loading together with browser locale?
|
// TODO: Can we use lazy loading together with browser locale?
|
||||||
const messages = {
|
const messages = {
|
||||||
@@ -45,7 +40,8 @@ const App = () => (
|
|||||||
dataProvider={dataProvider}
|
dataProvider={dataProvider}
|
||||||
i18nProvider={i18nProvider}
|
i18nProvider={i18nProvider}
|
||||||
customRoutes={[
|
customRoutes={[
|
||||||
<Route key="userImport" path="/import_users" component={ImportFeature} />,
|
<Route key="csvImport" path="/importcsv" component={ImportFeature} />,
|
||||||
|
<Route key="showpdf" path="/showpdf" component={ShowUserPdf} />,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Resource
|
<Resource
|
||||||
@@ -55,7 +51,14 @@ const App = () => (
|
|||||||
edit={UserEdit}
|
edit={UserEdit}
|
||||||
icon={UserIcon}
|
icon={UserIcon}
|
||||||
/>
|
/>
|
||||||
<Resource name="rooms" list={RoomList} show={RoomShow} icon={RoomIcon} />
|
<Resource
|
||||||
|
name="rooms"
|
||||||
|
list={RoomList}
|
||||||
|
create={RoomCreate}
|
||||||
|
show={RoomShow}
|
||||||
|
edit={RoomEdit}
|
||||||
|
icon={RoomIcon}
|
||||||
|
/>
|
||||||
<Resource
|
<Resource
|
||||||
name="user_media_statistics"
|
name="user_media_statistics"
|
||||||
list={UserMediaStatsList}
|
list={UserMediaStatsList}
|
||||||
@@ -72,13 +75,6 @@ const App = () => (
|
|||||||
list={RoomDirectoryList}
|
list={RoomDirectoryList}
|
||||||
icon={FolderSharedIcon}
|
icon={FolderSharedIcon}
|
||||||
/>
|
/>
|
||||||
<Resource
|
|
||||||
name="registration_tokens"
|
|
||||||
list={RegistrationTokenList}
|
|
||||||
create={RegistrationTokenCreate}
|
|
||||||
edit={RegistrationTokenEdit}
|
|
||||||
icon={ConfirmationNumberIcon}
|
|
||||||
/>
|
|
||||||
<Resource name="connections" />
|
<Resource name="connections" />
|
||||||
<Resource name="devices" />
|
<Resource name="devices" />
|
||||||
<Resource name="room_members" />
|
<Resource name="room_members" />
|
||||||
|
|||||||
@@ -15,15 +15,6 @@ import {
|
|||||||
import PageviewIcon from "@material-ui/icons/Pageview";
|
import PageviewIcon from "@material-ui/icons/Pageview";
|
||||||
import ViewListIcon from "@material-ui/icons/ViewList";
|
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 => (
|
const ReportPagination = props => (
|
||||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||||
);
|
);
|
||||||
@@ -42,7 +33,14 @@ export const ReportShow = props => {
|
|||||||
<DateField
|
<DateField
|
||||||
source="received_ts"
|
source="received_ts"
|
||||||
showTime
|
showTime
|
||||||
options={date_format}
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
sortable={true}
|
sortable={true}
|
||||||
/>
|
/>
|
||||||
<ReferenceField source="user_id" reference="users">
|
<ReferenceField source="user_id" reference="users">
|
||||||
@@ -74,7 +72,14 @@ export const ReportShow = props => {
|
|||||||
<DateField
|
<DateField
|
||||||
source="event_json.origin_server_ts"
|
source="event_json.origin_server_ts"
|
||||||
showTime
|
showTime
|
||||||
options={date_format}
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
sortable={true}
|
sortable={true}
|
||||||
/>
|
/>
|
||||||
<ReferenceField source="sender" reference="users">
|
<ReferenceField source="sender" reference="users">
|
||||||
@@ -111,7 +116,14 @@ export const ReportList = ({ ...props }) => {
|
|||||||
<DateField
|
<DateField
|
||||||
source="received_ts"
|
source="received_ts"
|
||||||
showTime
|
showTime
|
||||||
options={date_format}
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
sortable={true}
|
sortable={true}
|
||||||
/>
|
/>
|
||||||
<TextField sortable={false} source="user_id" />
|
<TextField sortable={false} source="user_id" />
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
import { useTranslate } from "ra-core";
|
import { useTranslate } from "ra-core";
|
||||||
import Container from "@material-ui/core/Container/Container";
|
import Container from "@material-ui/core/Container/Container";
|
||||||
import { generateRandomUser } from "./users";
|
import { generateRandomUser } from "./users";
|
||||||
|
import ShowUserPdf from "./ShowUserPdf";
|
||||||
|
|
||||||
const LOGGING = true;
|
const LOGGING = true;
|
||||||
|
|
||||||
@@ -59,6 +60,8 @@ const FilePicker = props => {
|
|||||||
|
|
||||||
const [progress, setProgress] = useState(null);
|
const [progress, setProgress] = useState(null);
|
||||||
|
|
||||||
|
const [pdfRecords, setPdfRecords] = useState(null);
|
||||||
|
|
||||||
const [importResults, setImportResults] = useState(null);
|
const [importResults, setImportResults] = useState(null);
|
||||||
const [skippedRecords, setSkippedRecords] = useState(null);
|
const [skippedRecords, setSkippedRecords] = useState(null);
|
||||||
|
|
||||||
@@ -66,17 +69,23 @@ const FilePicker = props => {
|
|||||||
const [passwordMode, setPasswordMode] = useState(true);
|
const [passwordMode, setPasswordMode] = useState(true);
|
||||||
const [useridMode, setUseridMode] = useState("ignore");
|
const [useridMode, setUseridMode] = useState("ignore");
|
||||||
|
|
||||||
|
const [showingPdf, setShowingPdf] = useState(false);
|
||||||
|
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
|
|
||||||
const dataProvider = useDataProvider();
|
const dataProvider = useDataProvider();
|
||||||
|
|
||||||
const onFileChange = async e => {
|
const onFileChange = async e => {
|
||||||
if (progress !== null) return;
|
if (progress !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (LOGGING) console.log("onFileChange was called");
|
||||||
setValues(null);
|
setValues(null);
|
||||||
setError(null);
|
setError(null);
|
||||||
setStats(null);
|
setStats(null);
|
||||||
|
setPdfRecords(null);
|
||||||
|
|
||||||
setImportResults(null);
|
setImportResults(null);
|
||||||
const file = e.target.files ? e.target.files[0] : null;
|
const file = e.target.files ? e.target.files[0] : null;
|
||||||
/* Let's refuse some unreasonably big files instead of freezing
|
/* Let's refuse some unreasonably big files instead of freezing
|
||||||
@@ -126,6 +135,11 @@ const FilePicker = props => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (eF.length !== 0) {
|
if (eF.length !== 0) {
|
||||||
|
if (LOGGING) {
|
||||||
|
console.log(meta.fields);
|
||||||
|
console.log(eF);
|
||||||
|
console.log(oF);
|
||||||
|
}
|
||||||
setError(
|
setError(
|
||||||
translate("import_users.error.required_field", { field: eF[0] })
|
translate("import_users.error.required_field", { field: eF[0] })
|
||||||
);
|
);
|
||||||
@@ -226,6 +240,9 @@ const FilePicker = props => {
|
|||||||
setProgress,
|
setProgress,
|
||||||
setError
|
setError
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setPdfRecords(results.recordsForPdf);
|
||||||
|
|
||||||
setImportResults(results);
|
setImportResults(results);
|
||||||
// offer CSV download of skipped or errored records
|
// offer CSV download of skipped or errored records
|
||||||
// (so that the user doesn't have to filter out successful
|
// (so that the user doesn't have to filter out successful
|
||||||
@@ -251,6 +268,8 @@ const FilePicker = props => {
|
|||||||
let skippedRecords = [];
|
let skippedRecords = [];
|
||||||
let erroredRecords = [];
|
let erroredRecords = [];
|
||||||
let succeededRecords = [];
|
let succeededRecords = [];
|
||||||
|
let recordsForPdf = [];
|
||||||
|
|
||||||
let changeStats = {
|
let changeStats = {
|
||||||
toAdmin: 0,
|
toAdmin: 0,
|
||||||
toGuest: 0,
|
toGuest: 0,
|
||||||
@@ -365,6 +384,14 @@ const FilePicker = props => {
|
|||||||
await dataProvider.create("users", { data: recordData });
|
await dataProvider.create("users", { data: recordData });
|
||||||
}
|
}
|
||||||
succeededRecords.push(recordData);
|
succeededRecords.push(recordData);
|
||||||
|
|
||||||
|
if (recordData.password !== undefined) {
|
||||||
|
recordsForPdf.push({
|
||||||
|
id: recordData.id,
|
||||||
|
password: recordData.password,
|
||||||
|
displayname: recordData.displayname,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -389,6 +416,7 @@ const FilePicker = props => {
|
|||||||
erroredRecords,
|
erroredRecords,
|
||||||
succeededRecords,
|
succeededRecords,
|
||||||
totalRecordCount: entriesCount,
|
totalRecordCount: entriesCount,
|
||||||
|
recordsForPdf,
|
||||||
changeStats,
|
changeStats,
|
||||||
wasDryRun: dryRun,
|
wasDryRun: dryRun,
|
||||||
};
|
};
|
||||||
@@ -618,6 +646,10 @@ const FilePicker = props => {
|
|||||||
<br />,
|
<br />,
|
||||||
]
|
]
|
||||||
: ""}
|
: ""}
|
||||||
|
{translate(
|
||||||
|
"import_users.cards.results.for_print",
|
||||||
|
importResults.recordsForPdf.length
|
||||||
|
)}
|
||||||
<br />
|
<br />
|
||||||
{importResults.wasDryRun && [
|
{importResults.wasDryRun && [
|
||||||
translate("import_users.cards.results.simulated_only"),
|
translate("import_users.cards.results.simulated_only"),
|
||||||
@@ -655,20 +687,43 @@ const FilePicker = props => {
|
|||||||
</CardActions>
|
</CardActions>
|
||||||
);
|
);
|
||||||
|
|
||||||
let allCards = [];
|
let pdfDisplay =
|
||||||
if (uploadCard) allCards.push(uploadCard);
|
pdfRecords && showingPdf && pdfRecords.length ? (
|
||||||
if (errorCards) allCards.push(errorCards);
|
<ShowUserPdf records={pdfRecords} />
|
||||||
if (conflictCards) allCards.push(conflictCards);
|
) : null;
|
||||||
if (statsCards) allCards.push(...statsCards);
|
|
||||||
if (startImportCard) allCards.push(startImportCard);
|
|
||||||
if (resultsCard) allCards.push(resultsCard);
|
|
||||||
|
|
||||||
let cardContainer = <Card>{allCards}</Card>;
|
let pdfActions = pdfRecords ? (
|
||||||
|
<CardActions>
|
||||||
|
<Button
|
||||||
|
size="large"
|
||||||
|
onClick={e => {
|
||||||
|
setShowingPdf(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{translate("import_users.goToPdf")}
|
||||||
|
</Button>
|
||||||
|
</CardActions>
|
||||||
|
) : null;
|
||||||
|
|
||||||
return [
|
if (pdfRecords && showingPdf) {
|
||||||
<Title defaultTitle={translate("import_users.title")} />,
|
return <Card>{pdfDisplay}</Card>;
|
||||||
cardContainer,
|
} else {
|
||||||
];
|
let allCards = [];
|
||||||
|
if (uploadCard) allCards.push(uploadCard);
|
||||||
|
if (errorCards) allCards.push(errorCards);
|
||||||
|
if (conflictCards) allCards.push(conflictCards);
|
||||||
|
if (statsCards) allCards.push(...statsCards);
|
||||||
|
if (startImportCard) allCards.push(startImportCard);
|
||||||
|
if (resultsCard) allCards.push(resultsCard);
|
||||||
|
if (pdfActions) allCards.push(pdfActions);
|
||||||
|
|
||||||
|
let cardContainer = <Card>{allCards}</Card>;
|
||||||
|
|
||||||
|
return [
|
||||||
|
<Title defaultTitle={translate("import_users.title")} />,
|
||||||
|
cardContainer,
|
||||||
|
];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ImportFeature = FilePicker;
|
export const ImportFeature = FilePicker;
|
||||||
|
|||||||
@@ -78,48 +78,11 @@ const LoginPage = ({ theme }) => {
|
|||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [supportPassAuth, setSupportPassAuth] = useState(true);
|
|
||||||
var locale = useLocale();
|
var locale = useLocale();
|
||||||
const setLocale = useSetLocale();
|
const setLocale = useSetLocale();
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
const base_url = localStorage.getItem("base_url");
|
const base_url = localStorage.getItem("base_url");
|
||||||
const cfg_base_url = process.env.REACT_APP_SERVER;
|
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 = ({
|
const renderInput = ({
|
||||||
meta: { touched, error } = {},
|
meta: { touched, error } = {},
|
||||||
@@ -174,14 +137,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 extractHomeServer = username => {
|
||||||
const usernameRegex = /@[a-zA-Z0-9._=\-/]+:([a-zA-Z0-9\-.]+\.[a-zA-Z]+)/;
|
const usernameRegex = /@[a-zA-Z0-9._=\-/]+:([a-zA-Z0-9\-.]+\.[a-zA-Z]+)/;
|
||||||
if (!username) return null;
|
if (!username) return null;
|
||||||
@@ -233,31 +188,6 @@ const LoginPage = ({ theme }) => {
|
|||||||
.catch(_ => {
|
.catch(_ => {
|
||||||
setServerVersion("");
|
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]
|
[formData.base_url]
|
||||||
);
|
);
|
||||||
@@ -270,7 +200,7 @@ const LoginPage = ({ theme }) => {
|
|||||||
name="username"
|
name="username"
|
||||||
component={renderInput}
|
component={renderInput}
|
||||||
label={translate("ra.auth.username")}
|
label={translate("ra.auth.username")}
|
||||||
disabled={loading || !supportPassAuth}
|
disabled={loading}
|
||||||
onBlur={handleUsernameChange}
|
onBlur={handleUsernameChange}
|
||||||
resettable
|
resettable
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -282,7 +212,7 @@ const LoginPage = ({ theme }) => {
|
|||||||
component={renderInput}
|
component={renderInput}
|
||||||
label={translate("ra.auth.password")}
|
label={translate("ra.auth.password")}
|
||||||
type="password"
|
type="password"
|
||||||
disabled={loading || !supportPassAuth}
|
disabled={loading}
|
||||||
resettable
|
resettable
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
@@ -343,24 +273,13 @@ const LoginPage = ({ theme }) => {
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
type="submit"
|
type="submit"
|
||||||
color="primary"
|
color="primary"
|
||||||
disabled={loading || !supportPassAuth}
|
disabled={loading}
|
||||||
className={classes.button}
|
className={classes.button}
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
{loading && <CircularProgress size={25} thickness={2} />}
|
{loading && <CircularProgress size={25} thickness={2} />}
|
||||||
{translate("ra.auth.sign_in")}
|
{translate("ra.auth.sign_in")}
|
||||||
</Button>
|
</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>
|
</CardActions>
|
||||||
</Card>
|
</Card>
|
||||||
<Notification />
|
<Notification />
|
||||||
|
|||||||
@@ -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
|
<BulkDeleteButton
|
||||||
{...props}
|
{...props}
|
||||||
label="resources.room_directory.action.erase"
|
label="resources.room_directory.action.erase"
|
||||||
mutationMode="pessimistic"
|
undoable={false}
|
||||||
confirmTitle="resources.room_directory.action.title"
|
confirmTitle="resources.room_directory.action.title"
|
||||||
confirmContent="resources.room_directory.action.content"
|
confirmContent="resources.room_directory.action.content"
|
||||||
resource="room_directory"
|
resource="room_directory"
|
||||||
@@ -191,7 +191,7 @@ export const FilterableRoomDirectoryList = ({
|
|||||||
filters={<RoomDirectoryFilter />}
|
filters={<RoomDirectoryFilter />}
|
||||||
perPage={100}
|
perPage={100}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick={(id, basePath, record) => "/rooms/" + id + "/show"}>
|
<Datagrid>
|
||||||
<AvatarField
|
<AvatarField
|
||||||
source="avatar_src"
|
source="avatar_src"
|
||||||
sortable={false}
|
sortable={false}
|
||||||
|
|||||||
@@ -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 => (
|
const ServerNoticeToolbar = props => (
|
||||||
<Toolbar {...props}>
|
<Toolbar {...props}>
|
||||||
<SaveButton
|
<SaveButton label="resources.servernotices.action.send" />
|
||||||
label="resources.servernotices.action.send"
|
|
||||||
disabled={props.pristine}
|
|
||||||
/>
|
|
||||||
<Button label="ra.action.cancel" onClick={onClose}>
|
<Button label="ra.action.cancel" onClick={onClose}>
|
||||||
<IconCancel />
|
<IconCancel />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -0,0 +1,263 @@
|
|||||||
|
import React, { useRef } 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";
|
||||||
|
import { string, any } from "prop-types";
|
||||||
|
|
||||||
|
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";
|
||||||
|
const origUrlString = "user=" + username + "&password=" + password;
|
||||||
|
|
||||||
|
var urlString = xor(origUrlString, magicString); // xor with magic string
|
||||||
|
if (origUrlString !== xor(urlString, magicString)) {
|
||||||
|
console.error(
|
||||||
|
"xoring this url string with magicString twice gave different results:",
|
||||||
|
origUrlString,
|
||||||
|
urlString,
|
||||||
|
xor(urlString, magicString)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
urlString = btoa(urlString); // to base64
|
||||||
|
|
||||||
|
return serverUrl + "/#" + urlString;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserPdfPage.propTypes = {
|
||||||
|
classes: any,
|
||||||
|
displayname: string,
|
||||||
|
qrCode: any,
|
||||||
|
serverUrl: string,
|
||||||
|
username: string,
|
||||||
|
password: string,
|
||||||
|
};
|
||||||
|
|
||||||
|
function UserPdfPage({
|
||||||
|
classes,
|
||||||
|
displayname,
|
||||||
|
qrCode,
|
||||||
|
serverUrl,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<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>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 ShowUserPdf = props => {
|
||||||
|
const classes = useStyles();
|
||||||
|
const userPdf = useRef(null);
|
||||||
|
|
||||||
|
const exportPDF = () => {
|
||||||
|
userPdf.current.save();
|
||||||
|
};
|
||||||
|
|
||||||
|
let userRecords;
|
||||||
|
|
||||||
|
if (props.records) {
|
||||||
|
userRecords = props.records;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
props.location &&
|
||||||
|
props.location.state &&
|
||||||
|
props.location.state.id &&
|
||||||
|
props.location.state.password
|
||||||
|
) {
|
||||||
|
userRecords = [
|
||||||
|
{
|
||||||
|
id: props.location.state.id,
|
||||||
|
password: props.location.state.password,
|
||||||
|
displayname: props.location.state.displayname,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Title title="PDF" />
|
||||||
|
<Button label="synapseadmin.action.download_pdf" onClick={exportPDF} />
|
||||||
|
|
||||||
|
<PDFExport
|
||||||
|
paperSize={"A4"}
|
||||||
|
fileName="Users.pdf"
|
||||||
|
title=""
|
||||||
|
subject=""
|
||||||
|
keywords=""
|
||||||
|
ref={userPdf}
|
||||||
|
//ref={r => (resume = r)}
|
||||||
|
>
|
||||||
|
{userRecords.map(record => {
|
||||||
|
if (record.id && record.password) {
|
||||||
|
const username = record.id.substring(1, record.id.indexOf(":"));
|
||||||
|
const serverUrl =
|
||||||
|
"https://" + record.id.substring(record.id.indexOf(":") + 1);
|
||||||
|
const qrString = calculateQrString(
|
||||||
|
serverUrl,
|
||||||
|
username,
|
||||||
|
record.password
|
||||||
|
);
|
||||||
|
const qrCode = <QRCode value={qrString} size={128} />;
|
||||||
|
return (
|
||||||
|
<UserPdfPage
|
||||||
|
classes={classes}
|
||||||
|
displayname={record.displayname}
|
||||||
|
qrCode={qrCode}
|
||||||
|
serverUrl={serverUrl}
|
||||||
|
username={username}
|
||||||
|
password={record.password}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
/* Skip empty PDF pages */
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</PDFExport>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ShowUserPdf;
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import ActionDelete from "@material-ui/icons/Delete";
|
import ActionDelete from "@material-ui/icons/Delete";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
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";
|
import classnames from "classnames";
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
@@ -16,7 +16,7 @@ const useStyles = makeStyles(
|
|||||||
deleteButton: {
|
deleteButton: {
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: alpha(theme.palette.error.main, 0.12),
|
backgroundColor: fade(theme.palette.error.main, 0.12),
|
||||||
// Reset on mouse devices
|
// Reset on mouse devices
|
||||||
"@media (hover: none)": {
|
"@media (hover: none)": {
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { Fragment, useState } from "react";
|
import React, { Fragment, useState } from "react";
|
||||||
import classnames from "classnames";
|
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 { makeStyles } from "@material-ui/core/styles";
|
||||||
import { Tooltip } from "@material-ui/core";
|
import { Tooltip } from "@material-ui/core";
|
||||||
import {
|
import {
|
||||||
@@ -33,7 +33,7 @@ const useStyles = makeStyles(
|
|||||||
deleteButton: {
|
deleteButton: {
|
||||||
color: theme.palette.error.main,
|
color: theme.palette.error.main,
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
backgroundColor: alpha(theme.palette.error.main, 0.12),
|
backgroundColor: fade(theme.palette.error.main, 0.12),
|
||||||
// Reset on mouse devices
|
// Reset on mouse devices
|
||||||
"@media (hover: none)": {
|
"@media (hover: none)": {
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
|
|||||||
+399
-20
@@ -1,31 +1,56 @@
|
|||||||
import React, { Fragment } from "react";
|
import React, { Fragment } from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
|
import { Route, Link } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
|
AutocompleteArrayInput,
|
||||||
|
AutocompleteInput,
|
||||||
|
BooleanInput,
|
||||||
BooleanField,
|
BooleanField,
|
||||||
BulkDeleteButton,
|
BulkDeleteButton,
|
||||||
DateField,
|
Button,
|
||||||
|
Create,
|
||||||
|
Edit,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
DateField,
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
Filter,
|
Filter,
|
||||||
|
FormTab,
|
||||||
List,
|
List,
|
||||||
NumberField,
|
NumberField,
|
||||||
Pagination,
|
Pagination,
|
||||||
|
ReferenceArrayInput,
|
||||||
ReferenceField,
|
ReferenceField,
|
||||||
|
ReferenceInput,
|
||||||
ReferenceManyField,
|
ReferenceManyField,
|
||||||
SearchInput,
|
SearchInput,
|
||||||
SelectField,
|
SelectField,
|
||||||
Show,
|
Show,
|
||||||
|
SimpleForm,
|
||||||
Tab,
|
Tab,
|
||||||
|
TabbedForm,
|
||||||
TabbedShowLayout,
|
TabbedShowLayout,
|
||||||
TextField,
|
TextField,
|
||||||
|
TextInput,
|
||||||
|
Toolbar,
|
||||||
TopToolbar,
|
TopToolbar,
|
||||||
|
useDataProvider,
|
||||||
useRecordContext,
|
useRecordContext,
|
||||||
|
useRefresh,
|
||||||
useTranslate,
|
useTranslate,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import get from "lodash/get";
|
import get from "lodash/get";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
import { Tooltip, Typography, Chip } from "@material-ui/core";
|
import {
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
|
Chip,
|
||||||
|
Drawer,
|
||||||
|
styled,
|
||||||
|
withStyles,
|
||||||
|
Select,
|
||||||
|
MenuItem,
|
||||||
|
} from "@material-ui/core";
|
||||||
import FastForwardIcon from "@material-ui/icons/FastForward";
|
import FastForwardIcon from "@material-ui/icons/FastForward";
|
||||||
import HttpsIcon from "@material-ui/icons/Https";
|
import HttpsIcon from "@material-ui/icons/Https";
|
||||||
import NoEncryptionIcon from "@material-ui/icons/NoEncryption";
|
import NoEncryptionIcon from "@material-ui/icons/NoEncryption";
|
||||||
@@ -33,6 +58,7 @@ import PageviewIcon from "@material-ui/icons/Pageview";
|
|||||||
import UserIcon from "@material-ui/icons/Group";
|
import UserIcon from "@material-ui/icons/Group";
|
||||||
import ViewListIcon from "@material-ui/icons/ViewList";
|
import ViewListIcon from "@material-ui/icons/ViewList";
|
||||||
import VisibilityIcon from "@material-ui/icons/Visibility";
|
import VisibilityIcon from "@material-ui/icons/Visibility";
|
||||||
|
import ContentSave from "@material-ui/icons/Save";
|
||||||
import EventIcon from "@material-ui/icons/Event";
|
import EventIcon from "@material-ui/icons/Event";
|
||||||
import {
|
import {
|
||||||
RoomDirectoryBulkDeleteButton,
|
RoomDirectoryBulkDeleteButton,
|
||||||
@@ -41,15 +67,6 @@ import {
|
|||||||
RoomDirectorySaveButton,
|
RoomDirectorySaveButton,
|
||||||
} from "./RoomDirectory";
|
} 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 => ({
|
const useStyles = makeStyles(theme => ({
|
||||||
helper_forward_extremities: {
|
helper_forward_extremities: {
|
||||||
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
||||||
@@ -87,20 +104,368 @@ const EncryptionField = ({ source, record = {}, emptyText }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const RoomTitle = ({ record }) => {
|
const validateDisplayName = fieldval => {
|
||||||
const translate = useTranslate();
|
return fieldval == null
|
||||||
var name = "";
|
? "synapseadmin.rooms.room_name_required"
|
||||||
if (record) {
|
: fieldval.length === 0
|
||||||
name = record.name !== "" ? record.name : record.id;
|
? "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 (
|
return (
|
||||||
<span>
|
<span>
|
||||||
{translate("resources.rooms.name", 1)} {name}
|
{translate("resources.rooms.name", 1)} {record ? `"${record.name}"` : ""}
|
||||||
</span>
|
</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 }) => {
|
const RoomShowActions = ({ basePath, data, resource }) => {
|
||||||
var roomDirectoryStatus = "";
|
var roomDirectoryStatus = "";
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -256,7 +621,14 @@ export const RoomShow = props => {
|
|||||||
<DateField
|
<DateField
|
||||||
source="origin_server_ts"
|
source="origin_server_ts"
|
||||||
showTime
|
showTime
|
||||||
options={date_format}
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
sortable={false}
|
sortable={false}
|
||||||
/>
|
/>
|
||||||
<TextField source="content" sortable={false} />
|
<TextField source="content" sortable={false} />
|
||||||
@@ -289,7 +661,14 @@ export const RoomShow = props => {
|
|||||||
<DateField
|
<DateField
|
||||||
source="received_ts"
|
source="received_ts"
|
||||||
showTime
|
showTime
|
||||||
options={date_format}
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
sortable={false}
|
sortable={false}
|
||||||
/>
|
/>
|
||||||
<NumberField source="depth" sortable={false} />
|
<NumberField source="depth" sortable={false} />
|
||||||
@@ -310,7 +689,7 @@ const RoomBulkActionButtons = props => (
|
|||||||
{...props}
|
{...props}
|
||||||
confirmTitle="resources.rooms.action.erase.title"
|
confirmTitle="resources.rooms.action.erase.title"
|
||||||
confirmContent="resources.rooms.action.erase.content"
|
confirmContent="resources.rooms.action.erase.content"
|
||||||
mutationMode="pessimistic"
|
undoable={false}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
|||||||
+137
-66
@@ -13,10 +13,12 @@ import {
|
|||||||
ArrayInput,
|
ArrayInput,
|
||||||
ArrayField,
|
ArrayField,
|
||||||
Button,
|
Button,
|
||||||
|
CreateButton,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
DateField,
|
DateField,
|
||||||
Create,
|
Create,
|
||||||
Edit,
|
Edit,
|
||||||
|
ExportButton,
|
||||||
List,
|
List,
|
||||||
Filter,
|
Filter,
|
||||||
Toolbar,
|
Toolbar,
|
||||||
@@ -29,33 +31,31 @@ import {
|
|||||||
PasswordInput,
|
PasswordInput,
|
||||||
TextField,
|
TextField,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
SearchInput,
|
||||||
ReferenceField,
|
ReferenceField,
|
||||||
ReferenceManyField,
|
ReferenceManyField,
|
||||||
SearchInput,
|
SelectField,
|
||||||
SelectInput,
|
SelectInput,
|
||||||
BulkDeleteButton,
|
BulkDeleteButton,
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
SaveButton,
|
SaveButton,
|
||||||
maxLength,
|
|
||||||
regex,
|
regex,
|
||||||
required,
|
|
||||||
useTranslate,
|
useTranslate,
|
||||||
Pagination,
|
Pagination,
|
||||||
CreateButton,
|
|
||||||
ExportButton,
|
|
||||||
TopToolbar,
|
TopToolbar,
|
||||||
sanitizeListRestProps,
|
sanitizeListRestProps,
|
||||||
NumberField,
|
NumberField,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import { Link } from "react-router-dom";
|
import SaveQrButton from "./SaveQrButton";
|
||||||
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
|
import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
|
||||||
import { DeviceRemoveButton } from "./devices";
|
import { DeviceRemoveButton } from "./devices";
|
||||||
import { ProtectMediaButton, QuarantineMediaButton } from "./media";
|
import { ProtectMediaButton, QuarantineMediaButton } from "./media";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
const redirect = () => {
|
const redirect = () => {
|
||||||
return {
|
return {
|
||||||
pathname: "/import_users",
|
pathname: "/importcsv",
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,15 +71,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 = ({
|
const UserListActions = ({
|
||||||
currentSort,
|
currentSort,
|
||||||
className,
|
className,
|
||||||
@@ -153,7 +144,7 @@ const UserBulkActionButtons = props => (
|
|||||||
{...props}
|
{...props}
|
||||||
label="resources.users.action.erase"
|
label="resources.users.action.erase"
|
||||||
confirmTitle="resources.users.helper.erase"
|
confirmTitle="resources.users.helper.erase"
|
||||||
mutationMode="pessimistic"
|
undoable={false}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
@@ -184,29 +175,53 @@ export const UserList = props => {
|
|||||||
<TextField source="displayname" />
|
<TextField source="displayname" />
|
||||||
<BooleanField source="is_guest" />
|
<BooleanField source="is_guest" />
|
||||||
<BooleanField source="admin" />
|
<BooleanField source="admin" />
|
||||||
<BooleanField source="deactivated" />
|
<SelectField
|
||||||
<DateField
|
source="user_type"
|
||||||
source="creation_ts"
|
choices={[
|
||||||
label="resources.users.fields.creation_ts_ms"
|
{ id: null, name: "resources.users.type.default" },
|
||||||
showTime
|
{ id: "free", name: "resources.users.type.free" },
|
||||||
options={date_format}
|
{ id: "limited", name: "resources.users.type.limited" },
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
|
<BooleanField source="deactivated" />
|
||||||
</Datagrid>
|
</Datagrid>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://matrix.org/docs/spec/appendices#user-identifiers
|
// redirect to the related Author show page
|
||||||
// here only local part of user_id
|
const redirectToPdf = (basePath, id, data) => {
|
||||||
// maxLength = 255 - "@" - ":" - localStorage.getItem("home_server").length
|
return {
|
||||||
// localStorage.getItem("home_server").length is not valid here
|
pathname: "/showpdf",
|
||||||
const validateUser = [
|
state: {
|
||||||
required(),
|
id: data.id,
|
||||||
maxLength(253),
|
displayname: data.displayname,
|
||||||
regex(/^[a-z0-9._=\-/]+$/, "synapseadmin.users.invalid_user_id"),
|
password: data.password,
|
||||||
];
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const validateAddress = [required(), maxLength(255)];
|
const UserCreateToolbar = props => (
|
||||||
|
<Toolbar {...props}>
|
||||||
|
<SaveQrButton
|
||||||
|
label="synapseadmin.action.save_and_show"
|
||||||
|
redirect={redirectToPdf}
|
||||||
|
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() {
|
export function generateRandomUser() {
|
||||||
const homeserver = localStorage.getItem("home_server");
|
const homeserver = localStorage.getItem("home_server");
|
||||||
@@ -253,7 +268,17 @@ const UserEditToolbar = props => {
|
|||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
return (
|
return (
|
||||||
<Toolbar {...props}>
|
<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
|
<DeleteButton
|
||||||
label="resources.users.action.erase"
|
label="resources.users.action.erase"
|
||||||
confirmTitle={translate("resources.users.helper.erase", {
|
confirmTitle={translate("resources.users.helper.erase", {
|
||||||
@@ -267,16 +292,20 @@ const UserEditToolbar = props => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const UserCreate = props => (
|
export const UserCreate = props => (
|
||||||
<Create {...props}>
|
<Create record={generateRandomUser()} {...props}>
|
||||||
<SimpleForm>
|
<SimpleForm toolbar={<UserCreateToolbar />}>
|
||||||
<TextInput source="id" autoComplete="off" validate={validateUser} />
|
<TextInput source="id" autoComplete="off" validate={validateUser} />
|
||||||
<TextInput source="displayname" validate={maxLength(256)} />
|
<TextInput source="displayname" />
|
||||||
<PasswordInput
|
<PasswordInput source="password" autoComplete="new-password" />
|
||||||
source="password"
|
|
||||||
autoComplete="new-password"
|
|
||||||
validate={maxLength(512)}
|
|
||||||
/>
|
|
||||||
<BooleanInput source="admin" />
|
<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">
|
<ArrayInput source="threepids">
|
||||||
<SimpleFormIterator>
|
<SimpleFormIterator>
|
||||||
<SelectInput
|
<SelectInput
|
||||||
@@ -285,19 +314,8 @@ export const UserCreate = props => (
|
|||||||
{ id: "email", name: "resources.users.email" },
|
{ id: "email", name: "resources.users.email" },
|
||||||
{ id: "msisdn", name: "resources.users.msisdn" },
|
{ 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>
|
|
||||||
<TextInput source="auth_provider" validate={required()} />
|
|
||||||
<TextInput
|
|
||||||
source="external_id"
|
|
||||||
label="resources.users.fields.id"
|
|
||||||
validate={required()}
|
|
||||||
/>
|
/>
|
||||||
|
<TextInput source="address" />
|
||||||
</SimpleFormIterator>
|
</SimpleFormIterator>
|
||||||
</ArrayInput>
|
</ArrayInput>
|
||||||
</SimpleForm>
|
</SimpleForm>
|
||||||
@@ -315,6 +333,7 @@ const UserTitle = ({ record }) => {
|
|||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UserEdit = props => {
|
export const UserEdit = props => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
@@ -333,12 +352,32 @@ export const UserEdit = props => {
|
|||||||
<TextInput source="id" disabled />
|
<TextInput source="id" disabled />
|
||||||
<TextInput source="displayname" />
|
<TextInput source="displayname" />
|
||||||
<PasswordInput source="password" autoComplete="new-password" />
|
<PasswordInput source="password" autoComplete="new-password" />
|
||||||
|
<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="admin" />
|
||||||
<BooleanInput
|
<BooleanInput
|
||||||
source="deactivated"
|
source="deactivated"
|
||||||
helperText="resources.users.helper.deactivate"
|
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" />
|
<TextField source="consent_version" />
|
||||||
</FormTab>
|
</FormTab>
|
||||||
|
|
||||||
@@ -366,16 +405,16 @@ export const UserEdit = props => {
|
|||||||
icon={<AssignmentIndIcon />}
|
icon={<AssignmentIndIcon />}
|
||||||
path="sso"
|
path="sso"
|
||||||
>
|
>
|
||||||
<ArrayInput source="external_ids" label={false}>
|
<ArrayField source="external_ids" label={false}>
|
||||||
<SimpleFormIterator>
|
<Datagrid style={{ width: "100%" }}>
|
||||||
<TextInput source="auth_provider" validate={required()} />
|
<TextField source="auth_provider" sortable={false} />
|
||||||
<TextInput
|
<TextField
|
||||||
source="external_id"
|
source="external_id"
|
||||||
label="resources.users.fields.id"
|
label="resources.users.fields.id"
|
||||||
validate={required()}
|
sortable={false}
|
||||||
/>
|
/>
|
||||||
</SimpleFormIterator>
|
</Datagrid>
|
||||||
</ArrayInput>
|
</ArrayField>
|
||||||
</FormTab>
|
</FormTab>
|
||||||
|
|
||||||
<FormTab
|
<FormTab
|
||||||
@@ -395,7 +434,14 @@ export const UserEdit = props => {
|
|||||||
<DateField
|
<DateField
|
||||||
source="last_seen_ts"
|
source="last_seen_ts"
|
||||||
showTime
|
showTime
|
||||||
options={date_format}
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
sortable={false}
|
sortable={false}
|
||||||
/>
|
/>
|
||||||
<DeviceRemoveButton />
|
<DeviceRemoveButton />
|
||||||
@@ -423,7 +469,14 @@ export const UserEdit = props => {
|
|||||||
<DateField
|
<DateField
|
||||||
source="last_seen"
|
source="last_seen"
|
||||||
showTime
|
showTime
|
||||||
options={date_format}
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
sortable={false}
|
sortable={false}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
@@ -450,11 +503,29 @@ export const UserEdit = props => {
|
|||||||
sort={{ field: "created_ts", order: "DESC" }}
|
sort={{ field: "created_ts", order: "DESC" }}
|
||||||
>
|
>
|
||||||
<Datagrid style={{ width: "100%" }}>
|
<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",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<DateField
|
<DateField
|
||||||
source="last_access_ts"
|
source="last_access_ts"
|
||||||
showTime
|
showTime
|
||||||
options={date_format}
|
options={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
second: "2-digit",
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<TextField source="media_id" />
|
<TextField source="media_id" />
|
||||||
<NumberField source="media_length" />
|
<NumberField source="media_length" />
|
||||||
|
|||||||
+38
-16
@@ -10,14 +10,27 @@ const de = {
|
|||||||
username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'",
|
username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'",
|
||||||
protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen",
|
protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen",
|
||||||
url_error: "Keine gültige Matrix Server URL",
|
url_error: "Keine gültige Matrix Server URL",
|
||||||
sso_sign_in: "Anmeldung mit SSO",
|
},
|
||||||
|
action: {
|
||||||
|
save_and_show: "Speichern und QR Code erzeugen",
|
||||||
|
save_only: "Nur speichern",
|
||||||
|
download_pdf: "PDF speichern",
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "Lokaler Anteil der Matrix Benutzer-ID ohne Homeserver.",
|
invalid_user_id:
|
||||||
|
"Muss eine vollständige Matrix Benutzer-ID sein, z.B. @benutzer_id:homeserver",
|
||||||
tabs: { sso: "SSO" },
|
tabs: { sso: "SSO" },
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
details: "Raumdetails",
|
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: {
|
tabs: {
|
||||||
basic: "Allgemein",
|
basic: "Allgemein",
|
||||||
members: "Mitglieder",
|
members: "Mitglieder",
|
||||||
@@ -92,11 +105,14 @@ const de = {
|
|||||||
with_error:
|
with_error:
|
||||||
"%{smart_count} Eintrag mit Fehlern ||| %{smart_count} Einträge mit Fehlern",
|
"%{smart_count} Eintrag mit Fehlern ||| %{smart_count} Einträge mit Fehlern",
|
||||||
simulated_only: "Import-Vorgang war nur simuliert",
|
simulated_only: "Import-Vorgang war nur simuliert",
|
||||||
|
for_print:
|
||||||
|
"%{smart_count} Eintrag zum Drucken verfügbar |||| %{smart_count} Einträge zum Drucken verfügbar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
users: {
|
users: {
|
||||||
|
backtolist: "Zurück zur Liste",
|
||||||
name: "Benutzer",
|
name: "Benutzer",
|
||||||
email: "E-Mail",
|
email: "E-Mail",
|
||||||
msisdn: "Telefon",
|
msisdn: "Telefon",
|
||||||
@@ -121,6 +137,18 @@ const de = {
|
|||||||
creation_ts_ms: "Zeitpunkt der Erstellung",
|
creation_ts_ms: "Zeitpunkt der Erstellung",
|
||||||
consent_version: "Zugestimmte Geschäftsbedingungen",
|
consent_version: "Zugestimmte Geschäftsbedingungen",
|
||||||
auth_provider: "Provider",
|
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: {
|
helper: {
|
||||||
deactivate:
|
deactivate:
|
||||||
@@ -130,6 +158,11 @@ const de = {
|
|||||||
action: {
|
action: {
|
||||||
erase: "Lösche Benutzerdaten",
|
erase: "Lösche Benutzerdaten",
|
||||||
},
|
},
|
||||||
|
roles: {
|
||||||
|
user: "Nutzer",
|
||||||
|
mod: "Moderator",
|
||||||
|
admin: "Administrator",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "Raum |||| Räume",
|
name: "Raum |||| Räume",
|
||||||
@@ -138,6 +171,8 @@ const de = {
|
|||||||
name: "Name",
|
name: "Name",
|
||||||
canonical_alias: "Alias",
|
canonical_alias: "Alias",
|
||||||
joined_members: "Mitglieder",
|
joined_members: "Mitglieder",
|
||||||
|
invite_members: "Mitglieder einladen",
|
||||||
|
invitees: "Einladungen",
|
||||||
joined_local_members: "Lokale Mitglieder",
|
joined_local_members: "Lokale Mitglieder",
|
||||||
joined_local_devices: "Lokale Endgeräte",
|
joined_local_devices: "Lokale Endgeräte",
|
||||||
state_events: "Zustandsereignisse / Komplexität",
|
state_events: "Zustandsereignisse / Komplexität",
|
||||||
@@ -352,19 +387,6 @@ const de = {
|
|||||||
send_failure: "Beim Entfernen ist ein Fehler aufgetreten.",
|
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: {
|
ra: {
|
||||||
...germanMessages.ra,
|
...germanMessages.ra,
|
||||||
@@ -385,7 +407,7 @@ const de = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
notification: {
|
notification: {
|
||||||
...germanMessages.ra.notification,
|
...germanMessages.ra.notifiaction,
|
||||||
logged_out: "Abgemeldet",
|
logged_out: "Abgemeldet",
|
||||||
},
|
},
|
||||||
page: {
|
page: {
|
||||||
|
|||||||
+41
-21
@@ -10,13 +10,27 @@ const en = {
|
|||||||
username_error: "Please enter fully qualified user ID: '@user:domain'",
|
username_error: "Please enter fully qualified user ID: '@user:domain'",
|
||||||
protocol_error: "URL has to start with 'http://' or 'https://'",
|
protocol_error: "URL has to start with 'http://' or 'https://'",
|
||||||
url_error: "Not a valid Matrix server URL",
|
url_error: "Not a valid Matrix server URL",
|
||||||
sso_sign_in: "Sign in with SSO",
|
},
|
||||||
|
action: {
|
||||||
|
save_and_show: "Create QR code",
|
||||||
|
save_only: "Save",
|
||||||
|
download_pdf: "Download PDF",
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "Localpart of a Matrix user-id without homeserver.",
|
invalid_user_id:
|
||||||
|
"Must be a fully qualified Matrix user-id, e.g. @user_id:homeserver",
|
||||||
tabs: { sso: "SSO" },
|
tabs: { sso: "SSO" },
|
||||||
},
|
},
|
||||||
rooms: {
|
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: {
|
tabs: {
|
||||||
basic: "Basic",
|
basic: "Basic",
|
||||||
members: "Members",
|
members: "Members",
|
||||||
@@ -91,11 +105,14 @@ const en = {
|
|||||||
with_error:
|
with_error:
|
||||||
"%{smart_count} entry with errors ||| %{smart_count} entries with errors",
|
"%{smart_count} entry with errors ||| %{smart_count} entries with errors",
|
||||||
simulated_only: "Run was only simulated",
|
simulated_only: "Run was only simulated",
|
||||||
|
for_print:
|
||||||
|
"%{smart_count} entry available for printing |||| %{smart_count} entries available for printing",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
users: {
|
users: {
|
||||||
|
backtolist: "Back to list",
|
||||||
name: "User |||| Users",
|
name: "User |||| Users",
|
||||||
email: "Email",
|
email: "Email",
|
||||||
msisdn: "Phone",
|
msisdn: "Phone",
|
||||||
@@ -120,6 +137,17 @@ const en = {
|
|||||||
creation_ts_ms: "Creation timestamp",
|
creation_ts_ms: "Creation timestamp",
|
||||||
consent_version: "Consent version",
|
consent_version: "Consent version",
|
||||||
auth_provider: "Provider",
|
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: {
|
helper: {
|
||||||
deactivate: "You must provide a password to re-activate an account.",
|
deactivate: "You must provide a password to re-activate an account.",
|
||||||
@@ -128,6 +156,11 @@ const en = {
|
|||||||
action: {
|
action: {
|
||||||
erase: "Erase user data",
|
erase: "Erase user data",
|
||||||
},
|
},
|
||||||
|
roles: {
|
||||||
|
user: "User",
|
||||||
|
mod: "Moderator",
|
||||||
|
admin: "Administrator",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "Room |||| Rooms",
|
name: "Room |||| Rooms",
|
||||||
@@ -136,6 +169,8 @@ const en = {
|
|||||||
name: "Name",
|
name: "Name",
|
||||||
canonical_alias: "Alias",
|
canonical_alias: "Alias",
|
||||||
joined_members: "Members",
|
joined_members: "Members",
|
||||||
|
invite_members: "Invite Members",
|
||||||
|
invitees: "Invitations",
|
||||||
joined_local_members: "Local members",
|
joined_local_members: "Local members",
|
||||||
joined_local_devices: "Local devices",
|
joined_local_devices: "Local devices",
|
||||||
state_events: "State events / Complexity",
|
state_events: "State events / Complexity",
|
||||||
@@ -174,12 +209,10 @@ const en = {
|
|||||||
},
|
},
|
||||||
unencrypted: "Unencrypted",
|
unencrypted: "Unencrypted",
|
||||||
},
|
},
|
||||||
action: {
|
erase: {
|
||||||
erase: {
|
title: "Delete room",
|
||||||
title: "Delete room",
|
content:
|
||||||
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!",
|
||||||
"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: {
|
reports: {
|
||||||
@@ -351,18 +384,5 @@ 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;
|
export default en;
|
||||||
|
|||||||
+1
-2
@@ -10,12 +10,10 @@ const zh = {
|
|||||||
username_error: "请输入完整有效的用户 ID: '@user:domain'",
|
username_error: "请输入完整有效的用户 ID: '@user:domain'",
|
||||||
protocol_error: "URL 需要以'http://'或'https://'作为起始",
|
protocol_error: "URL 需要以'http://'或'https://'作为起始",
|
||||||
url_error: "不是一个有效的 Matrix 服务器地址",
|
url_error: "不是一个有效的 Matrix 服务器地址",
|
||||||
sso_sign_in: "使用 SSO 登录",
|
|
||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id:
|
invalid_user_id:
|
||||||
"必须要是一个有效的 Matrix 用户 ID ,例如 @user_id:homeserver",
|
"必须要是一个有效的 Matrix 用户 ID ,例如 @user_id:homeserver",
|
||||||
tabs: { sso: "SSO" },
|
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
tabs: {
|
tabs: {
|
||||||
@@ -100,6 +98,7 @@ const zh = {
|
|||||||
},
|
},
|
||||||
resources: {
|
resources: {
|
||||||
users: {
|
users: {
|
||||||
|
backtolist: "回到列表",
|
||||||
name: "用户",
|
name: "用户",
|
||||||
email: "邮箱",
|
email: "邮箱",
|
||||||
msisdn: "电话",
|
msisdn: "电话",
|
||||||
|
|||||||
@@ -2,31 +2,20 @@ import { fetchUtils } from "react-admin";
|
|||||||
|
|
||||||
const authProvider = {
|
const authProvider = {
|
||||||
// called when the user attempts to log in
|
// called when the user attempts to log in
|
||||||
login: ({ base_url, username, password, loginToken }) => {
|
login: ({ base_url, username, password }) => {
|
||||||
// force homeserver for protection in case the form is manipulated
|
// force homeserver for protection in case the form is manipulated
|
||||||
base_url = process.env.REACT_APP_SERVER || base_url;
|
base_url = process.env.REACT_APP_SERVER || base_url;
|
||||||
|
|
||||||
console.log("login ");
|
console.log("login ");
|
||||||
const options = {
|
const options = {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(
|
body: JSON.stringify({
|
||||||
Object.assign(
|
type: "m.login.password",
|
||||||
{
|
user: username,
|
||||||
device_id: localStorage.getItem("device_id"),
|
password: password,
|
||||||
initial_device_display_name: "Synapse Admin",
|
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,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// use the base_url from login instead of the well_known entry from the
|
// use the base_url from login instead of the well_known entry from the
|
||||||
|
|||||||
+49
-29
@@ -25,6 +25,13 @@ const mxcUrlToHttp = mxcUrl => {
|
|||||||
return `${homeserver}/_matrix/media/r0/thumbnail/${serverName}/${mediaId}?width=24&height=24&method=scale`;
|
return `${homeserver}/_matrix/media/r0/thumbnail/${serverName}/${mediaId}?width=24&height=24&method=scale`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const POWER_LEVELS = {
|
||||||
|
admin: 100,
|
||||||
|
mod: 50,
|
||||||
|
user: 0,
|
||||||
|
};
|
||||||
|
const roleToPowerLevel = role => POWER_LEVELS[role] || 0;
|
||||||
|
|
||||||
const resourceMap = {
|
const resourceMap = {
|
||||||
users: {
|
users: {
|
||||||
path: "/_synapse/admin/v2/users",
|
path: "/_synapse/admin/v2/users",
|
||||||
@@ -35,15 +42,14 @@ const resourceMap = {
|
|||||||
is_guest: !!u.is_guest,
|
is_guest: !!u.is_guest,
|
||||||
admin: !!u.admin,
|
admin: !!u.admin,
|
||||||
deactivated: !!u.deactivated,
|
deactivated: !!u.deactivated,
|
||||||
|
displayname: u.display_name || u.displayname,
|
||||||
// need timestamp in milliseconds
|
// need timestamp in milliseconds
|
||||||
creation_ts_ms: u.creation_ts * 1000,
|
creation_ts_ms: u.creation_ts * 1000,
|
||||||
}),
|
}),
|
||||||
data: "users",
|
data: "users",
|
||||||
total: json => json.total,
|
total: json => json.total,
|
||||||
create: data => ({
|
create: data => ({
|
||||||
endpoint: `/_synapse/admin/v2/users/@${data.id}:${localStorage.getItem(
|
endpoint: `/_synapse/admin/v2/users/${data.id}`,
|
||||||
"home_server"
|
|
||||||
)}`,
|
|
||||||
body: data,
|
body: data,
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
}),
|
}),
|
||||||
@@ -65,8 +71,40 @@ const resourceMap = {
|
|||||||
public: !!r.public,
|
public: !!r.public,
|
||||||
}),
|
}),
|
||||||
data: "rooms",
|
data: "rooms",
|
||||||
total: json => {
|
total: json => json.total_rooms,
|
||||||
return 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 => ({
|
delete: params => ({
|
||||||
endpoint: `/_synapse/admin/v1/rooms/${params.id}`,
|
endpoint: `/_synapse/admin/v1/rooms/${params.id}`,
|
||||||
@@ -275,25 +313,6 @@ const resourceMap = {
|
|||||||
method: "PUT",
|
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) {
|
function filterNullValues(key, value) {
|
||||||
@@ -315,8 +334,7 @@ function getSearchOrder(order) {
|
|||||||
const dataProvider = {
|
const dataProvider = {
|
||||||
getList: (resource, params) => {
|
getList: (resource, params) => {
|
||||||
console.log("getList " + resource);
|
console.log("getList " + resource);
|
||||||
const { user_id, name, guests, deactivated, search_term, valid } =
|
const { user_id, name, guests, deactivated, search_term } = params.filter;
|
||||||
params.filter;
|
|
||||||
const { page, perPage } = params.pagination;
|
const { page, perPage } = params.pagination;
|
||||||
const { field, order } = params.sort;
|
const { field, order } = params.sort;
|
||||||
const from = (page - 1) * perPage;
|
const from = (page - 1) * perPage;
|
||||||
@@ -328,7 +346,6 @@ const dataProvider = {
|
|||||||
name: name,
|
name: name,
|
||||||
guests: guests,
|
guests: guests,
|
||||||
deactivated: deactivated,
|
deactivated: deactivated,
|
||||||
valid: valid,
|
|
||||||
order_by: field,
|
order_by: field,
|
||||||
dir: getSearchOrder(order),
|
dir: getSearchOrder(order),
|
||||||
};
|
};
|
||||||
@@ -347,7 +364,7 @@ const dataProvider = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getOne: (resource, params) => {
|
getOne: (resource, params) => {
|
||||||
console.log("getOne " + resource);
|
console.log("getOne " + resource, params);
|
||||||
const homeserver = localStorage.getItem("base_url");
|
const homeserver = localStorage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
if (!homeserver || !(resource in resourceMap)) return Promise.reject();
|
||||||
|
|
||||||
@@ -408,10 +425,13 @@ const dataProvider = {
|
|||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
|
|
||||||
|
const transform = res.transformBeforeUpdate || (x => x);
|
||||||
|
const data = transform(params.data);
|
||||||
|
|
||||||
const endpoint_url = homeserver + res.path;
|
const endpoint_url = homeserver + res.path;
|
||||||
return jsonClient(`${endpoint_url}/${params.data.id}`, {
|
return jsonClient(`${endpoint_url}/${params.data.id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify(params.data, filterNullValues),
|
body: JSON.stringify(data, filterNullValues),
|
||||||
}).then(({ json }) => ({
|
}).then(({ json }) => ({
|
||||||
data: res.map(json),
|
data: res.map(json),
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user