Compare commits
95 Commits
v0.10.3-et
...
v0.10.3-et
Author | SHA1 | Date | |
---|---|---|---|
![]() |
915e3564f8 | ||
![]() |
1570ca5485 | ||
![]() |
b94b782547 | ||
![]() |
90328a5b19 | ||
![]() |
b42eb07a2f | ||
![]() |
131bfaaece | ||
![]() |
b759d5d5fb | ||
![]() |
003e9da792 | ||
![]() |
908271060b | ||
![]() |
08cd427084 | ||
![]() |
73a1d952b1 | ||
![]() |
1d5511421d | ||
![]() |
b925c63171 | ||
![]() |
6faebaf9df | ||
![]() |
c698f57395 | ||
![]() |
9adc13e722 | ||
![]() |
a04b24a5d5 | ||
![]() |
cd1ca7c039 | ||
![]() |
86b4987b7f | ||
![]() |
a7cf647669 | ||
![]() |
80d40d2fb5 | ||
![]() |
b19e961a35 | ||
![]() |
08f5f8ebd2 | ||
![]() |
1edf196049 | ||
![]() |
1f66b4d14a | ||
![]() |
cec5b0af9a | ||
![]() |
2b0e1e7c0e | ||
![]() |
a613a88232 | ||
![]() |
7afce71bef | ||
![]() |
fe4ba22a03 | ||
![]() |
eb35d9e122 | ||
![]() |
fa79fecc9d | ||
![]() |
61366b3792 | ||
![]() |
b55033d983 | ||
![]() |
b1f42988c8 | ||
![]() |
ef05b366c3 | ||
![]() |
b3d52e7d23 | ||
![]() |
d1c4250b46 | ||
![]() |
8d44077b24 | ||
![]() |
44e8b82412 | ||
![]() |
791ae2c869 | ||
![]() |
ee3753466a | ||
![]() |
b7dc703157 | ||
![]() |
2eca0dcc33 | ||
![]() |
d2219c1667 | ||
![]() |
132ea6f97f | ||
![]() |
28ef08de03 | ||
![]() |
865e53388e | ||
![]() |
3a105bb8c7 | ||
![]() |
edcda7a202 | ||
![]() |
edd69273e2 | ||
![]() |
444bfacbd9 | ||
![]() |
970e0a550f | ||
![]() |
b3ef68d66e | ||
![]() |
31382a42ee | ||
![]() |
1a7748d1ef | ||
![]() |
039b28cc5c | ||
![]() |
57eae3edb3 | ||
![]() |
dadc9416c0 | ||
![]() |
eab2342114 | ||
![]() |
9cf2f83936 | ||
![]() |
d823856873 | ||
![]() |
9b96c7cec8 | ||
![]() |
f211aba873 | ||
![]() |
c0fc2d8937 | ||
![]() |
a88b397748 | ||
![]() |
abc922c956 | ||
![]() |
4f2cd38344 | ||
![]() |
ca71038874 | ||
![]() |
be867b6b0d | ||
![]() |
f2f540b429 | ||
![]() |
7feec4ba07 | ||
![]() |
1d5fef1e53 | ||
![]() |
9c40efde17 | ||
![]() |
53dff66978 | ||
![]() |
3a595247e8 | ||
![]() |
33f5f60e31 | ||
![]() |
9dd2ea57c9 | ||
![]() |
fae7a696de | ||
![]() |
49e8b2d0f5 | ||
![]() |
281d908d3f | ||
![]() |
bacc42fe9c | ||
![]() |
1c26a28ca9 | ||
![]() |
d3a04cd132 | ||
![]() |
e6060a23ac | ||
![]() |
4b7fbf483a | ||
![]() |
bc3c30da92 | ||
![]() |
1896f770d1 | ||
![]() |
99d0b9ad72 | ||
![]() |
944afb9056 | ||
![]() |
23f5a24803 | ||
![]() |
60ae00ac14 | ||
![]() |
26862fa708 | ||
![]() |
853d14c1ce | ||
![]() |
11a5cac709 |
19
.github/dependabot.yml
vendored
Normal file
19
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
|
||||||
|
- package-ecosystem: "docker"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
open-pull-requests-limit: 10
|
||||||
|
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
open-pull-requests-limit: 10
|
6
.github/workflows/workflow.yml
vendored
6
.github/workflows/workflow.yml
vendored
@@ -25,10 +25,6 @@ jobs:
|
|||||||
cache: yarn
|
cache: yarn
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --immutable --network-timeout=300000
|
run: yarn install --immutable --network-timeout=300000
|
||||||
- name: Set version into manifest.json
|
|
||||||
run: |
|
|
||||||
TAG=$(git describe --tags --abbrev=0 || echo "latest")
|
|
||||||
sed -i "s|\"icons\"|\"version\": \"$TAG\",\\n \"icons\"|g" public/manifest.json
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: yarn build --base=${{ env.base_path }}
|
run: yarn build --base=${{ env.base_path }}
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
@@ -52,7 +48,7 @@ jobs:
|
|||||||
name: dist
|
name: dist
|
||||||
path: dist/
|
path: dist/
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
- name: Login to ghcr.io
|
- name: Login to ghcr.io
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
|
141
README.md
141
README.md
@@ -1,4 +1,16 @@
|
|||||||
# Synapse Admin UI [](https://github.com/Awesome-Technologies/synapse-admin/blob/master/LICENSE)
|
<p align="center">
|
||||||
|
<img alt="Synapse Admin Logo" src="./public/images/logo.webp" height="140" />
|
||||||
|
<h3 align="center">
|
||||||
|
Synapse Admin<br>
|
||||||
|
<a href="https://matrix.to/#/#synapse-admin:etke.cc">
|
||||||
|
<img alt="Community room" src="https://img.shields.io/badge/room-community_room-green?logo=matrix&label=%23synapse-admin%3Aetke.cc">
|
||||||
|
</a><br>
|
||||||
|
<img alt="License" src="https://img.shields.io/github/license/etkecc/synapse-admin">
|
||||||
|
</h3>
|
||||||
|
<p align="center">Manager your Synapse homeserver with ease</p>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -11,8 +23,10 @@ This project is built using [react-admin](https://marmelab.com/react-admin/).
|
|||||||
* [Changes](#changes)
|
* [Changes](#changes)
|
||||||
* [Development](#development)
|
* [Development](#development)
|
||||||
* [Configuration](#configuration)
|
* [Configuration](#configuration)
|
||||||
|
* [Prefilling login form](#prefilling-login-form)
|
||||||
* [Restricting available homeserver](#restricting-available-homeserver)
|
* [Restricting available homeserver](#restricting-available-homeserver)
|
||||||
* [Protecting appservice managed users](#protecting-appservice-managed-users)
|
* [Protecting appservice managed users](#protecting-appservice-managed-users)
|
||||||
|
* [Adding custom menu items](#adding-custom-menu-items)
|
||||||
* [Providing support URL](#providing-support-url)
|
* [Providing support URL](#providing-support-url)
|
||||||
* [Usage](#usage)
|
* [Usage](#usage)
|
||||||
* [Supported Synapse](#supported-synapse)
|
* [Supported Synapse](#supported-synapse)
|
||||||
@@ -22,7 +36,7 @@ This project is built using [react-admin](https://marmelab.com/react-admin/).
|
|||||||
* [Steps for 1)](#steps-for-1)
|
* [Steps for 1)](#steps-for-1)
|
||||||
* [Steps for 2)](#steps-for-2)
|
* [Steps for 2)](#steps-for-2)
|
||||||
* [Steps for 3)](#steps-for-3)
|
* [Steps for 3)](#steps-for-3)
|
||||||
* [Serving Synapse-Admin on a different path](#serving-synapse-admin-on-a-different-path)
|
* [Serving Synapse Admin on a different path](#serving-synapse-admin-on-a-different-path)
|
||||||
* [Development](#development-1)
|
* [Development](#development-1)
|
||||||
|
|
||||||
<!-- vim-markdown-toc -->
|
<!-- vim-markdown-toc -->
|
||||||
@@ -53,8 +67,9 @@ The following changes are already implemented:
|
|||||||
* [Fix redirect URL after user creation](https://github.com/etkecc/synapse-admin/pull/16)
|
* [Fix redirect URL after user creation](https://github.com/etkecc/synapse-admin/pull/16)
|
||||||
* [Display actual Synapse errors](https://github.com/etkecc/synapse-admin/pull/17)
|
* [Display actual Synapse errors](https://github.com/etkecc/synapse-admin/pull/17)
|
||||||
* [Fix base_url being undefined on unsuccessful login](https://github.com/etkecc/synapse-admin/pull/18)
|
* [Fix base_url being undefined on unsuccessful login](https://github.com/etkecc/synapse-admin/pull/18)
|
||||||
* [Put the version into manifest.json](https://github.com/Awesome-Technologies/synapse-admin/issues/507) (CI only)
|
* [Put the version into manifest.json](https://github.com/Awesome-Technologies/synapse-admin/issues/507) (later replaced
|
||||||
* [Federation page improvements](https://github.com/Awesome-Technologies/synapse-admin/pull/583) (using theme colors)
|
with a proper manifest.json generation on build)
|
||||||
|
* [Federation page improvements](https://github.com/Awesome-Technologies/synapse-admin/pull/583) (using icons)
|
||||||
* [Add UI option to block deleted rooms from being rejoined](https://github.com/etkecc/synapse-admin/pull/26)
|
* [Add UI option to block deleted rooms from being rejoined](https://github.com/etkecc/synapse-admin/pull/26)
|
||||||
* [Fix required fields check on Bulk registration CSV upload](https://github.com/etkecc/synapse-admin/pull/32)
|
* [Fix required fields check on Bulk registration CSV upload](https://github.com/etkecc/synapse-admin/pull/32)
|
||||||
* [Fix requests with invalid MXIDs on Bulk registration](https://github.com/etkecc/synapse-admin/pull/33)
|
* [Fix requests with invalid MXIDs on Bulk registration](https://github.com/etkecc/synapse-admin/pull/33)
|
||||||
@@ -66,6 +81,19 @@ The following changes are already implemented:
|
|||||||
* [Authenticated Media support](https://github.com/etkecc/synapse-admin/pull/51)
|
* [Authenticated Media support](https://github.com/etkecc/synapse-admin/pull/51)
|
||||||
* [Better media preview/download](https://github.com/etkecc/synapse-admin/pull/53)
|
* [Better media preview/download](https://github.com/etkecc/synapse-admin/pull/53)
|
||||||
* [Login with access token](https://github.com/etkecc/synapse-admin/pull/58)
|
* [Login with access token](https://github.com/etkecc/synapse-admin/pull/58)
|
||||||
|
* [Fix footer causing vertical scrollbar](https://github.com/etkecc/synapse-admin/pull/60)
|
||||||
|
* [Custom Menu Items](https://github.com/etkecc/synapse-admin/pull/79)
|
||||||
|
* [Add user profile to the top menu](https://github.com/etkecc/synapse-admin/pull/80)
|
||||||
|
* [Enable visual customization](https://github.com/etkecc/synapse-admin/pull/81)
|
||||||
|
* [Fix room state events display](https://github.com/etkecc/synapse-admin/pull/100)
|
||||||
|
* [Sanitize CSV on import](https://github.com/etkecc/synapse-admin/pull/101)
|
||||||
|
* Allow setting version using `SYNAPSE_ADMIN_VERSION` environment variable on build (if git is not available)
|
||||||
|
* [Add option to control user's experimental features](https://github.com/etkecc/synapse-admin/pull/111)
|
||||||
|
* [Add random password generation on user create/edit form](https://github.com/etkecc/synapse-admin/pull/123)
|
||||||
|
* [Add option to set user's rate limits](https://github.com/etkecc/synapse-admin/pull/125)
|
||||||
|
* [Support configuration via /.well-known/matrix/client](https://github.com/etkecc/synapse-admin/pull/126)
|
||||||
|
* [Prevent accidental user overwrites](https://github.com/etkecc/synapse-admin/pull/139)
|
||||||
|
* [Allow providing login form details via GET params](https://github.com/etkecc/synapse-admin/pull/140)
|
||||||
|
|
||||||
_the list will be updated as new changes are added_
|
_the list will be updated as new changes are added_
|
||||||
|
|
||||||
@@ -82,7 +110,15 @@ After that open `http://localhost:5173` in your browser, login using the followi
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
You can use `config.json` file to configure synapse-admin
|
You can use `config.json` file to configure Synapse Admin instance,
|
||||||
|
and `/.well-known/matrix/client` file to provide Synapse Admin configuration specifically for your homeserver.
|
||||||
|
In the latter case, any instance of Synapse Admin will automatically pick up the configuration from the homeserver.
|
||||||
|
Note that configuration inside the `/.well-known/matrix/client` file should go under the `cc.etke.synapse-admin` key,
|
||||||
|
and it will override the configuration from the `config.json` file.
|
||||||
|
|
||||||
|
In case you use [spantaleev/matrix-docker-ansible-deploy](https://github.com/spantaleev/matrix-docker-ansible-deploy) or
|
||||||
|
[etkecc/ansible](https://github.com/etkecc/ansible),
|
||||||
|
configuration will be automatically added to the `/.well-known/matrix/client` file.
|
||||||
|
|
||||||
The `config.json` can be injected into a Docker container using a bind mount.
|
The `config.json` can be injected into a Docker container using a bind mount.
|
||||||
|
|
||||||
@@ -95,6 +131,17 @@ services:
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Prefilling login form
|
||||||
|
|
||||||
|
You can prefill `username` and `homeserver` fields on the login page using GET parameters, example:
|
||||||
|
|
||||||
|
```
|
||||||
|
https://matrix.example.com/synapse-admin/?username=admin&server=matrix.example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
That way `username` and `homeserver` fields will be pre-filled with `admin` and `https://matrix.example.com` respectively.
|
||||||
|
|
||||||
|
|
||||||
### Restricting available homeserver
|
### Restricting available homeserver
|
||||||
|
|
||||||
You can restrict the homeserver(s), so that the user can no longer define it himself.
|
You can restrict the homeserver(s), so that the user can no longer define it himself.
|
||||||
@@ -103,7 +150,17 @@ Edit `config.json` to restrict either to a single homeserver:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"restrictBaseUrl": "https://your-matrixs-erver.example.com"
|
"restrictBaseUrl": "https://matrix.example.com"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
similar for `/.well-known/matrix/client`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"cc.etke.synapse-admin": {
|
||||||
|
"restrictBaseUrl": "https://matrix.example.com"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -115,6 +172,16 @@ or to a list of homeservers:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
similar for `/.well-known/matrix/client`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"cc.etke.synapse-admin": {
|
||||||
|
"restrictBaseUrl": ["https://your-first-matrix-server.example.com", "https://your-second-matrix-server.example.com"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Protecting appservice managed users
|
### Protecting appservice managed users
|
||||||
|
|
||||||
To avoid accidental adjustments of appservice-managed users (e.g., puppets created by a bridge) and breaking the bridge,
|
To avoid accidental adjustments of appservice-managed users (e.g., puppets created by a bridge) and breaking the bridge,
|
||||||
@@ -128,9 +195,55 @@ Example for [mautrix-telegram](https://github.com/mautrix/telegram)
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
similar for `/.well-known/matrix/client`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"cc.etke.synapse-admin": {
|
||||||
|
"asManagedUsers": ["^@telegram_[a-zA-Z0-9]+:example\\.com$"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding custom menu items
|
||||||
|
|
||||||
|
You can add custom menu items to the main menu by providing a `menu` array in the `config.json`.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"menu": [
|
||||||
|
{
|
||||||
|
"label": "Contact support",
|
||||||
|
"icon": "SupportAgent",
|
||||||
|
"url": "https://github.com/etkecc/synapse-admin/issues"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
similar for `/.well-known/matrix/client`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"cc.etke.synapse-admin": {
|
||||||
|
"menu": [
|
||||||
|
{
|
||||||
|
"label": "Contact support",
|
||||||
|
"icon": "SupportAgent",
|
||||||
|
"url": "https://github.com/etkecc/synapse-admin/issues"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `icon` is one of the [preloaded icons](./src/components/icons.ts)
|
||||||
|
|
||||||
### Providing support URL
|
### Providing support URL
|
||||||
|
|
||||||
Synapse-Admin provides a support link in the main menu - `Contact support`. By default, the link points to the GitHub issues page of the project. You can change this link by providing a `supportURL` in the `config.json`.
|
**Deprecated**: use `menu` config option described above. Automatically migrated to the `menu` if the `supportURL` is present.
|
||||||
|
|
||||||
|
~~Synapse Admin provides a support link in the main menu - `Contact support`. By default, the link points to the GitHub issues page of the project. You can change this link by providing a `supportURL` in the `config.json`.~~
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -138,6 +251,16 @@ Synapse-Admin provides a support link in the main menu - `Contact support`. By d
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
similar for `/.well-known/matrix/client`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"cc.etke.synapse-admin": {
|
||||||
|
"supportURL": "https://example.com/support"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Supported Synapse
|
### Supported Synapse
|
||||||
@@ -217,7 +340,7 @@ You have three options:
|
|||||||
|
|
||||||
- browse to http://localhost:8080
|
- browse to http://localhost:8080
|
||||||
|
|
||||||
### Serving Synapse-Admin on a different path
|
### Serving Synapse Admin on a different path
|
||||||
|
|
||||||
The path prefix where synapse-admin is served can only be changed during the build step.
|
The path prefix where synapse-admin is served can only be changed during the build step.
|
||||||
|
|
||||||
@@ -225,7 +348,7 @@ If you downloaded the source code, use `yarn build --base=/my-prefix` to set a p
|
|||||||
|
|
||||||
If you want to build your own Docker container, use the `BASE_PATH` argument.
|
If you want to build your own Docker container, use the `BASE_PATH` argument.
|
||||||
|
|
||||||
We do not support directly changing the path where Synapse-Admin is served in the pre-built Docker container. Instead please use a reverse proxy if you need to move Synapse-Admin to a different base path. If you want to serve multiple applications with different paths on the same domain, you need a reverse proxy anyway.
|
We do not support directly changing the path where Synapse Admin is served in the pre-built Docker container. Instead please use a reverse proxy if you need to move Synapse Admin to a different base path. If you want to serve multiple applications with different paths on the same domain, you need a reverse proxy anyway.
|
||||||
|
|
||||||
Example for Traefik:
|
Example for Traefik:
|
||||||
|
|
||||||
|
22
index.html
22
index.html
@@ -4,17 +4,14 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta
|
<meta name="description" content="Synapse Admin" />
|
||||||
name="description"
|
|
||||||
content="Synapse-Admin"
|
|
||||||
/>
|
|
||||||
<!--
|
<!--
|
||||||
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/
|
||||||
-->
|
-->
|
||||||
<link rel="manifest" href="./manifest.json" />
|
<link rel="manifest" href="./manifest.json" />
|
||||||
<link rel="shortcut icon" href="./favicon.ico" />
|
<link rel="shortcut icon" href="./favicon.ico" />
|
||||||
<title>Synapse-Admin</title>
|
<title>Synapse Admin</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -22,6 +19,11 @@
|
|||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layout {
|
||||||
|
min-height: 90vh !important;
|
||||||
|
height: 90vh;
|
||||||
|
}
|
||||||
|
|
||||||
.loader-container {
|
.loader-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -120,13 +122,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="module" src="/src/index.tsx"></script>
|
<script type="module" src="/src/index.tsx"></script>
|
||||||
<footer
|
<span id="js-version" style="display: none;"></span>
|
||||||
style="position: relative; z-index: 2; height: 2em; margin-top: 0; line-height: 2em; background-color: #eee; border: 0.5px solid #ddd">
|
|
||||||
<a id="copyright" href="https://github.com/etkecc/synapse-admin"
|
|
||||||
style="margin-left: 1em; color: #888; font-family: Roboto, Helvetica, Arial, sans-serif; font-weight: 100; font-size: 0.8em; text-decoration: none;">
|
|
||||||
Synapse-Admin <b><span id="version"></span></b> by Awesome Technologies Innovationslabor GmbH
|
|
||||||
</a>
|
|
||||||
</footer>
|
|
||||||
</body>
|
</body>
|
||||||
<script>document.getElementById("version").textContent = __SYNAPSE_ADMIN_VERSION__</script>
|
<script>document.getElementById("js-version").textContent = __SYNAPSE_ADMIN_VERSION__</script>
|
||||||
</html>
|
</html>
|
||||||
|
61
package.json
61
package.json
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.10.3",
|
"version": "0.10.3",
|
||||||
"description": "Admin GUI for the Matrix.org server Synapse",
|
"description": "Admin GUI for the Matrix.org server Synapse",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "Awesome Technologies Innovationslabor GmbH",
|
"author": "etke.cc (originally by Awesome Technologies Innovationslabor GmbH)",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -11,25 +11,25 @@
|
|||||||
"url": "https://github.com/etkecc/synapse-admin"
|
"url": "https://github.com/etkecc/synapse-admin"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.7.0",
|
"@eslint/js": "^9.13.0",
|
||||||
"@testing-library/dom": "^10.0.0",
|
"@testing-library/dom": "^10.0.0",
|
||||||
"@testing-library/jest-dom": "^6.0.0",
|
"@testing-library/jest-dom": "^6.6.3",
|
||||||
"@testing-library/react": "^16.0.0",
|
"@testing-library/react": "^16.0.0",
|
||||||
"@testing-library/user-event": "^14.5.2",
|
"@testing-library/user-event": "^14.5.2",
|
||||||
"@types/jest": "^29.5.13",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/lodash": "^4.17.7",
|
"@types/lodash": "^4.17.13",
|
||||||
"@types/node": "^20.14.12",
|
"@types/node": "^22.8.7",
|
||||||
"@types/papaparse": "^5.3.14",
|
"@types/papaparse": "^5.3.15",
|
||||||
"@types/react": "^18.3.3",
|
"@types/react": "^18.3.12",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.16.1",
|
"@typescript-eslint/eslint-plugin": "^8.11.0",
|
||||||
"@typescript-eslint/parser": "^7.16.1",
|
"@typescript-eslint/parser": "^8.13.0",
|
||||||
"@vitejs/plugin-react": "^4.3.1",
|
"@vitejs/plugin-react": "^4.3.3",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^9.14.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-import": "^2.29.1",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jsx-a11y": "^6.9.0",
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||||
"eslint-plugin-prettier": "^5.2.1",
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
"eslint-plugin-unused-imports": "^3.2.0",
|
"eslint-plugin-unused-imports": "^4.1.4",
|
||||||
"eslint-plugin-yaml": "^1.0.3",
|
"eslint-plugin-yaml": "^1.0.3",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
@@ -38,41 +38,42 @@
|
|||||||
"react-test-renderer": "^18.3.1",
|
"react-test-renderer": "^18.3.1",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.5",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"typescript": "^5.4.5",
|
"typescript": "^5.6.3",
|
||||||
"typescript-eslint": "^7.16.1",
|
"typescript-eslint": "^8.13.0",
|
||||||
"vite": "^5.4.6",
|
"vite": "^5.4.10",
|
||||||
"vite-plugin-version-mark": "^0.1.0"
|
"vite-plugin-version-mark": "^0.1.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.13.0",
|
"@emotion/react": "^11.13.0",
|
||||||
"@emotion/styled": "^11.13.0",
|
"@emotion/styled": "^11.13.0",
|
||||||
"@haleos/ra-language-german": "^1.0.0",
|
"@haleos/ra-language-german": "^1.0.0",
|
||||||
"@haxqer/ra-language-chinese": "^4.16.2",
|
"@haxqer/ra-language-chinese": "^4.16.2",
|
||||||
"@mui/icons-material": "^6.1.1",
|
"@mui/icons-material": "^6.1.5",
|
||||||
"@mui/material": "^6.1.1",
|
"@mui/material": "^6.1.6",
|
||||||
"@tanstack/react-query": "^5.56.2",
|
"@mui/utils": "^5.16.6",
|
||||||
|
"@tanstack/react-query": "^5.59.20",
|
||||||
"history": "^5.3.0",
|
"history": "^5.3.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"papaparse": "^5.4.1",
|
"papaparse": "^5.4.1",
|
||||||
"ra-core": "^5.2.0",
|
"ra-core": "^5.3.2",
|
||||||
"ra-i18n-polyglot": "^5.2.0",
|
"ra-i18n-polyglot": "^5.3.2",
|
||||||
"ra-language-english": "^5.2.0",
|
"ra-language-english": "^5.3.2",
|
||||||
"ra-language-farsi": "^5.0.0",
|
"ra-language-farsi": "^5.0.0",
|
||||||
"ra-language-french": "^5.2.0",
|
"ra-language-french": "^5.3.3",
|
||||||
"ra-language-italian": "^3.13.1",
|
"ra-language-italian": "^3.13.1",
|
||||||
"ra-language-russian": "^4.14.2",
|
"ra-language-russian": "^4.14.2",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-admin": "^5.2.0",
|
"react-admin": "^5.3.3",
|
||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-hook-form": "^7.53.0",
|
"react-hook-form": "^7.53.1",
|
||||||
"react-is": "^18.3.1",
|
"react-is": "^18.3.1",
|
||||||
"react-router": "^6.26.2",
|
"react-router": "^6.26.2",
|
||||||
"react-router-dom": "^6.26.2"
|
"react-router-dom": "^6.28.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite serve",
|
"start": "vite serve",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"lint": "eslint --ignore-path .gitignore --ext .ts,.tsx,.yml,.yaml .",
|
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint --ignore-path .gitignore --ignore-pattern testdata/ --ext .ts,.tsx,.yml,.yaml .",
|
||||||
"fix": "yarn lint --fix",
|
"fix": "yarn lint --fix",
|
||||||
"test": "yarn jest",
|
"test": "yarn jest",
|
||||||
"test:watch": "yarn jest --watch"
|
"test:watch": "yarn jest --watch"
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 4.2 KiB |
BIN
public/images/logo.webp
Normal file
BIN
public/images/logo.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"short_name": "Synapse-Admin",
|
|
||||||
"name": "Synapse-Admin",
|
|
||||||
"icons": [
|
|
||||||
{
|
|
||||||
"src": "favicon.ico",
|
|
||||||
"sizes": "64x64 32x32 24x24 16x16",
|
|
||||||
"type": "image/x-icon"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"start_url": ".",
|
|
||||||
"display": "standalone",
|
|
||||||
"theme_color": "#000000",
|
|
||||||
"background_color": "#ffffff"
|
|
||||||
}
|
|
@@ -1,4 +1,4 @@
|
|||||||
import { render, screen, waitFor } from "@testing-library/react";
|
import { render, screen } from "@testing-library/react";
|
||||||
import fetchMock from "jest-fetch-mock";
|
import fetchMock from "jest-fetch-mock";
|
||||||
fetchMock.enableMocks();
|
fetchMock.enableMocks();
|
||||||
|
|
||||||
@@ -9,4 +9,4 @@ describe("App", () => {
|
|||||||
render(<App />);
|
render(<App />);
|
||||||
await screen.findAllByText("Welcome to Synapse-admin");
|
await screen.findAllByText("Welcome to Synapse-admin");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -23,6 +23,7 @@ import users from "./resources/users";
|
|||||||
import authProvider from "./synapse/authProvider";
|
import authProvider from "./synapse/authProvider";
|
||||||
import dataProvider from "./synapse/dataProvider";
|
import dataProvider from "./synapse/dataProvider";
|
||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
|
import Footer from "./components/Footer";
|
||||||
|
|
||||||
// TODO: Can we use lazy loading together with browser locale?
|
// TODO: Can we use lazy loading together with browser locale?
|
||||||
const messages = {
|
const messages = {
|
||||||
@@ -81,6 +82,7 @@ const App = () => (
|
|||||||
<Resource name="room_state" />
|
<Resource name="room_state" />
|
||||||
<Resource name="destination_rooms" />
|
<Resource name="destination_rooms" />
|
||||||
</Admin>
|
</Admin>
|
||||||
|
<Footer />
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -1,11 +1,6 @@
|
|||||||
import { createContext, useContext } from "react";
|
import { createContext, useContext } from "react";
|
||||||
|
import { Config } from "./components/config";
|
||||||
interface AppContextType {
|
|
||||||
restrictBaseUrl: string | string[];
|
|
||||||
asManagedUsers: string[];
|
|
||||||
supportURL: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AppContext = createContext({});
|
export const AppContext = createContext({});
|
||||||
|
|
||||||
export const useAppContext = () => useContext(AppContext) as AppContextType;
|
export const useAppContext = () => useContext(AppContext) as Config;
|
||||||
|
@@ -1,17 +1,8 @@
|
|||||||
import { AppBar, Confirm, Layout, Logout, Menu, useLogout, UserMenu } from "react-admin";
|
import { CheckForApplicationUpdate, AppBar, TitlePortal, InspectorButton, Confirm, Layout, Logout, Menu, useLogout, UserMenu } from "react-admin";
|
||||||
import LiveHelpIcon from "@mui/icons-material/LiveHelp";
|
|
||||||
import { LoginMethod } from "../pages/LoginPage";
|
import { LoginMethod } from "../pages/LoginPage";
|
||||||
import { useState } from "react";
|
import { useEffect, useState, Suspense } from "react";
|
||||||
|
import { Icons, DefaultIcon } from "./icons";
|
||||||
const DEFAULT_SUPPORT_LINK = "https://github.com/etkecc/synapse-admin/issues";
|
import { ClearConfig } from "./config";
|
||||||
const supportLink = (): string => {
|
|
||||||
try {
|
|
||||||
new URL(localStorage.getItem("support_url") || ""); // Check if the URL is valid
|
|
||||||
return localStorage.getItem("support_url") || DEFAULT_SUPPORT_LINK;
|
|
||||||
} catch (e) {
|
|
||||||
return DEFAULT_SUPPORT_LINK;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const AdminUserMenu = () => {
|
const AdminUserMenu = () => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -31,8 +22,7 @@ const AdminUserMenu = () => {
|
|||||||
|
|
||||||
const handleDialogClose = () => {
|
const handleDialogClose = () => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
localStorage.removeItem("access_token");
|
ClearConfig();
|
||||||
localStorage.removeItem("login_type");
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,17 +44,61 @@ const AdminUserMenu = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const AdminAppBar = () => <AppBar userMenu={<AdminUserMenu />} />;
|
const AdminAppBar = () => {
|
||||||
|
return (<AppBar userMenu={<AdminUserMenu />}>
|
||||||
|
<TitlePortal />
|
||||||
|
<InspectorButton />
|
||||||
|
</AppBar>);
|
||||||
|
};
|
||||||
|
|
||||||
const AdminMenu = () => (
|
const AdminMenu = (props) => {
|
||||||
<Menu>
|
const [menu, setMenu] = useState([]);
|
||||||
<Menu.ResourceItems />
|
|
||||||
<Menu.Item to={supportLink()} target="_blank" primaryText="Contact support" leftIcon={<LiveHelpIcon />} />
|
useEffect(() => {
|
||||||
</Menu>
|
const menuConfig = localStorage.getItem('menu');
|
||||||
);
|
if (menuConfig) {
|
||||||
|
try {
|
||||||
|
setMenu(JSON.parse(menuConfig));
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error parsing menu configuration', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Menu {...props}>
|
||||||
|
<Menu.ResourceItems />
|
||||||
|
{menu.map((item, index) => {
|
||||||
|
const { url, icon, label } = item;
|
||||||
|
const IconComponent = Icons[icon] as React.ComponentType<any> | undefined;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Suspense key={index}>
|
||||||
|
<Menu.Item
|
||||||
|
to={url}
|
||||||
|
target="_blank"
|
||||||
|
primaryText={label}
|
||||||
|
leftIcon={IconComponent ? <IconComponent /> : <DefaultIcon />}
|
||||||
|
onClick={props.onMenuClick}
|
||||||
|
/>
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const AdminLayout = ({ children }) => (
|
export const AdminLayout = ({ children }) => (
|
||||||
<Layout appBar={AdminAppBar} menu={AdminMenu}>
|
<Layout appBar={AdminAppBar} menu={AdminMenu} sx={{
|
||||||
|
['& .RaLayout-appFrame']: {
|
||||||
|
minHeight: '90vh',
|
||||||
|
height: '90vh',
|
||||||
|
},
|
||||||
|
['& .RaLayout-content']: {
|
||||||
|
marginBottom: '3rem',
|
||||||
|
},
|
||||||
|
}}>
|
||||||
{children}
|
{children}
|
||||||
|
<CheckForApplicationUpdate />
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
|
95
src/components/ExperimentalFeatures.tsx
Normal file
95
src/components/ExperimentalFeatures.tsx
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import { useRecordContext } from "react-admin";
|
||||||
|
import { useNotify } from "react-admin";
|
||||||
|
import { useDataProvider } from "react-admin";
|
||||||
|
import { useState, useEffect } from "react";
|
||||||
|
import { Stack, Switch, Typography } from "@mui/material";
|
||||||
|
import { ExperimentalFeaturesModel, SynapseDataProvider } from "../synapse/dataProvider";
|
||||||
|
|
||||||
|
const experimentalFeaturesMap = {
|
||||||
|
msc3881: "enable remotely toggling push notifications for another client",
|
||||||
|
msc3575: "enable experimental sliding sync support",
|
||||||
|
};
|
||||||
|
const ExperimentalFeatureRow = (props: { featureKey: string, featureValue: boolean, updateFeature: (feature_name: string, feature_value: boolean) => void}) => {
|
||||||
|
const featureKey = props.featureKey;
|
||||||
|
const featureValue = props.featureValue;
|
||||||
|
const featureDescription = experimentalFeaturesMap[featureKey] ?? "";
|
||||||
|
const [checked, setChecked] = useState(featureValue);
|
||||||
|
|
||||||
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setChecked(event.target.checked);
|
||||||
|
props.updateFeature(featureKey, event.target.checked);
|
||||||
|
};
|
||||||
|
|
||||||
|
return <Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
alignItems="start"
|
||||||
|
sx={{
|
||||||
|
padding: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Switch checked={checked} onChange={handleChange} />
|
||||||
|
<Stack>
|
||||||
|
<Typography
|
||||||
|
variant="subtitle1"
|
||||||
|
sx={{
|
||||||
|
fontWeight: "medium",
|
||||||
|
color: "text.primary"
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{featureKey}
|
||||||
|
</Typography>
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
color="text.secondary"
|
||||||
|
>
|
||||||
|
{featureDescription}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ExperimentalFeaturesList = () => {
|
||||||
|
const record = useRecordContext();
|
||||||
|
const notify = useNotify();
|
||||||
|
const dataProvider = useDataProvider() as SynapseDataProvider;
|
||||||
|
const [features, setFeatures] = useState({});
|
||||||
|
if (!record) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchFeatures = async () => {
|
||||||
|
const features = await dataProvider.getFeatures(record.id);
|
||||||
|
setFeatures(features);
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchFeatures();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const updateFeature = async (feature_name: string, feature_value: boolean) => {
|
||||||
|
const updatedFeatures = {...features, [feature_name]: feature_value} as ExperimentalFeaturesModel;
|
||||||
|
setFeatures(updatedFeatures);
|
||||||
|
const reponse = await dataProvider.updateFeatures(record.id, updatedFeatures);
|
||||||
|
notify("ra.notification.updated", {
|
||||||
|
messageArgs: { smart_count: 1 },
|
||||||
|
type: "success",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<Stack
|
||||||
|
direction="column"
|
||||||
|
spacing={1}
|
||||||
|
>
|
||||||
|
{Object.keys(features).map((featureKey: string) =>
|
||||||
|
<ExperimentalFeatureRow
|
||||||
|
key={featureKey}
|
||||||
|
featureKey={featureKey}
|
||||||
|
featureValue={features[featureKey]}
|
||||||
|
updateFeature={updateFeature}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
}
|
41
src/components/Footer.tsx
Normal file
41
src/components/Footer.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { Avatar, Box, Link, Typography } from "@mui/material";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
const Footer = () => {
|
||||||
|
const [version, setVersion] = useState<string | null>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
const version = document.getElementById("js-version")?.textContent;
|
||||||
|
if (version) {
|
||||||
|
setVersion(version);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (<Box
|
||||||
|
component="footer"
|
||||||
|
sx={{
|
||||||
|
position: 'fixed',
|
||||||
|
zIndex: 100,
|
||||||
|
bottom: 0,
|
||||||
|
width: '100%',
|
||||||
|
bgcolor: "#eee",
|
||||||
|
borderTop: '1px solid',
|
||||||
|
borderColor: '#ddd',
|
||||||
|
p: 1,
|
||||||
|
}}>
|
||||||
|
<Typography variant="body2" component="div">
|
||||||
|
<Avatar src="./images/logo.webp" sx={{ width: "1rem", height: "1rem", display: "inline-block", verticalAlign: "sub" }} />
|
||||||
|
<Link sx={{ color: "#888", textDecoration: 'none' }} href="https://github.com/etkecc/synapse-admin" target="_blank">
|
||||||
|
Synapse Admin
|
||||||
|
</Link> <Link href={`https://github.com/etkecc/synapse-admin/releases/tag/`+version} target="_blank">
|
||||||
|
<span style={{ fontWeight: 'bold', color: "#000" }}>{version}</span>
|
||||||
|
</Link> <Link sx={{ color: "#888", textDecoration: 'none' }} href="https://etke.cc/?utm_source=synapse-admin&utm_medium=footer&utm_campaign=synapse-admin" target="_blank">
|
||||||
|
by etke.cc
|
||||||
|
</Link> <Link sx={{ color: "#888", textDecoration: 'none' }} href="https://github.com/awesome-technologies/synapse-admin" target="_blank">
|
||||||
|
(originally developed by Awesome Technologies Innovationslabor GmbH).
|
||||||
|
</Link> <Link sx={{ fontWeight: 'bold', color: "#000", textDecoration: 'none' }} href="https://matrix.to/#/#synapse-admin:etke.cc" target="_blank">#synapse-admin:etke.cc</Link>
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Footer;
|
@@ -121,11 +121,8 @@ const FilePicker = () => {
|
|||||||
|
|
||||||
const verifyCsv = ({ data, meta, errors }: ParseResult<ImportLine>, { setValues, setStats, setError }) => {
|
const verifyCsv = ({ data, meta, errors }: ParseResult<ImportLine>, { setValues, setStats, setError }) => {
|
||||||
/* First, verify the presence of required fields */
|
/* First, verify the presence of required fields */
|
||||||
const missingFields = expectedFields.filter(eF => {
|
meta.fields = meta.fields?.map(f => f.trim().toLowerCase());
|
||||||
const result = meta.fields?.find(mF => eF === mF);
|
const missingFields = expectedFields.filter(eF => !meta.fields?.find(mF => eF === mF));
|
||||||
if (result === undefined) { return eF; } // missing field
|
|
||||||
return undefined; // field found
|
|
||||||
});
|
|
||||||
|
|
||||||
if (missingFields.length > 0) {
|
if (missingFields.length > 0) {
|
||||||
setError(translate("import_users.error.required_field", { field: missingFields[0] }));
|
setError(translate("import_users.error.required_field", { field: missingFields[0] }));
|
||||||
@@ -151,6 +148,15 @@ const FilePicker = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const errorMessages = errors.map(e => e.message);
|
const errorMessages = errors.map(e => e.message);
|
||||||
|
// sanitize the data first
|
||||||
|
data = data.map(line => {
|
||||||
|
const newLine = {} as ImportLine;
|
||||||
|
for (const [key, value] of Object.entries(line)) {
|
||||||
|
newLine[key.trim().toLowerCase()] = value;
|
||||||
|
}
|
||||||
|
return newLine;
|
||||||
|
});
|
||||||
|
// process the data
|
||||||
data.forEach((line, idx) => {
|
data.forEach((line, idx) => {
|
||||||
if (line.user_type === undefined || line.user_type === "") {
|
if (line.user_type === undefined || line.user_type === "") {
|
||||||
stats.user_types.default++;
|
stats.user_types.default++;
|
||||||
@@ -177,6 +183,7 @@ const FilePicker = () => {
|
|||||||
line[f] = true; // we need true booleans instead of strings
|
line[f] = true; // we need true booleans instead of strings
|
||||||
} else {
|
} else {
|
||||||
if (line[f] !== "false" && line[f] !== "") {
|
if (line[f] !== "false" && line[f] !== "") {
|
||||||
|
console.log("invalid value", line[f], "for field " + f + " in row " + idx);
|
||||||
errorMessages.push(
|
errorMessages.push(
|
||||||
translate("import_users.error.invalid_value", {
|
translate("import_users.error.invalid_value", {
|
||||||
field: f,
|
field: f,
|
||||||
|
95
src/components/UserRateLimits.tsx
Normal file
95
src/components/UserRateLimits.tsx
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import { Stack, Typography } from "@mui/material";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { useDataProvider, useNotify, useRecordContext, useTranslate } from "react-admin";
|
||||||
|
import { TextField } from "@mui/material";
|
||||||
|
import { useFormContext } from "react-hook-form";
|
||||||
|
|
||||||
|
const RateLimitRow = ({ limit, value, updateRateLimit }: { limit: string, value: any, updateRateLimit: (limit: string, value: any) => void }) => {
|
||||||
|
const translate = useTranslate();
|
||||||
|
|
||||||
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const value = parseInt(event.target.value);
|
||||||
|
if (isNaN(value)) {
|
||||||
|
updateRateLimit(limit, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateRateLimit(limit, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
return <Stack
|
||||||
|
spacing={1}
|
||||||
|
alignItems="start"
|
||||||
|
sx={{
|
||||||
|
padding: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextField
|
||||||
|
id="outlined-number"
|
||||||
|
type="number"
|
||||||
|
value={value}
|
||||||
|
onChange={handleChange}
|
||||||
|
slotProps={{
|
||||||
|
inputLabel: {
|
||||||
|
shrink: true,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
label={translate(`resources.users.limits.${limit}`)}
|
||||||
|
/>
|
||||||
|
<Stack>
|
||||||
|
<Typography
|
||||||
|
variant="body2"
|
||||||
|
color="text.secondary"
|
||||||
|
>
|
||||||
|
{translate(`resources.users.limits.${limit}_text`)}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const UserRateLimits = () => {
|
||||||
|
const translate = useTranslate();
|
||||||
|
const notify = useNotify();
|
||||||
|
const record = useRecordContext();
|
||||||
|
const form = useFormContext();
|
||||||
|
const dataProvider = useDataProvider();
|
||||||
|
const [rateLimits, setRateLimits] = useState({
|
||||||
|
messages_per_second: "", // we are setting string here to make the number field empty by default, null is prohibited by the field validation
|
||||||
|
burst_count: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!record) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchRateLimits = async () => {
|
||||||
|
const rateLimits = await dataProvider.getRateLimits(record.id);
|
||||||
|
if (Object.keys(rateLimits).length > 0) {
|
||||||
|
setRateLimits(rateLimits);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchRateLimits();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const updateRateLimit = async (limit: string, value: any) => {
|
||||||
|
let updatedRateLimits = { ...rateLimits, [limit]: value };
|
||||||
|
setRateLimits(updatedRateLimits);
|
||||||
|
form.setValue(`rates.${limit}`, value, { shouldDirty: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
return <>
|
||||||
|
<Stack
|
||||||
|
direction="column"
|
||||||
|
>
|
||||||
|
{Object.keys(rateLimits).map((limit: string) =>
|
||||||
|
<RateLimitRow
|
||||||
|
key={limit}
|
||||||
|
limit={limit}
|
||||||
|
value={rateLimits[limit]}
|
||||||
|
updateRateLimit={updateRateLimit}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
|
};
|
87
src/components/config.ts
Normal file
87
src/components/config.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import storage from "../storage";
|
||||||
|
|
||||||
|
export interface Config {
|
||||||
|
restrictBaseUrl: string | string[];
|
||||||
|
asManagedUsers: string[];
|
||||||
|
supportURL: string;
|
||||||
|
menu: MenuItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MenuItem {
|
||||||
|
label: string;
|
||||||
|
icon: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const WellKnownKey = "cc.etke.synapse-admin";
|
||||||
|
|
||||||
|
export const LoadConfig = (context: Config): Config => {
|
||||||
|
if (context.restrictBaseUrl) {
|
||||||
|
storage.setItem("restrict_base_url", JSON.stringify(context.restrictBaseUrl));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.asManagedUsers) {
|
||||||
|
storage.setItem("as_managed_users", JSON.stringify(context.asManagedUsers));
|
||||||
|
}
|
||||||
|
|
||||||
|
let menu: MenuItem[] = [];
|
||||||
|
if (context.menu) {
|
||||||
|
menu = context.menu;
|
||||||
|
}
|
||||||
|
if (context.supportURL) {
|
||||||
|
const migratedSupportURL = {
|
||||||
|
label: "Contact support",
|
||||||
|
icon: "SupportAgent",
|
||||||
|
url: context.supportURL,
|
||||||
|
};
|
||||||
|
console.warn("supportURL config option is deprecated. Please, use the menu option instead. Automatically migrated to the new menu option:", migratedSupportURL);
|
||||||
|
menu.push(migratedSupportURL as MenuItem);
|
||||||
|
}
|
||||||
|
if (menu.length > 0) {
|
||||||
|
storage.setItem("menu", JSON.stringify(menu));
|
||||||
|
}
|
||||||
|
|
||||||
|
// below we try to calculate "final" config, which will contain values from context and already set values in storage
|
||||||
|
// because LoadConfig could be called multiple times to get config from different sources
|
||||||
|
let finalRestrictBaseUrl: string | string[] = "";
|
||||||
|
try {
|
||||||
|
finalRestrictBaseUrl = JSON.parse(storage.getItem("restrict_base_url") || "");
|
||||||
|
if (Array.isArray(finalRestrictBaseUrl) && finalRestrictBaseUrl.length == 1) {
|
||||||
|
finalRestrictBaseUrl = finalRestrictBaseUrl[0];
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
let finalAsManagedUsers: string[] = [];
|
||||||
|
try {
|
||||||
|
finalAsManagedUsers = JSON.parse(storage.getItem("as_managed_users") || "");
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
let finalMenu: MenuItem[] = [];
|
||||||
|
try {
|
||||||
|
finalMenu = JSON.parse(storage.getItem("menu") || "");
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
return {
|
||||||
|
restrictBaseUrl: finalRestrictBaseUrl,
|
||||||
|
asManagedUsers: finalAsManagedUsers,
|
||||||
|
supportURL: storage.getItem("support_url") || "",
|
||||||
|
menu: finalMenu,
|
||||||
|
} as Config;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const ClearConfig = () => {
|
||||||
|
// config.json
|
||||||
|
storage.removeItem("restrict_base_url");
|
||||||
|
storage.removeItem("as_managed_users");
|
||||||
|
storage.removeItem("support_url");
|
||||||
|
storage.removeItem("menu");
|
||||||
|
|
||||||
|
// session
|
||||||
|
storage.removeItem("home_server");
|
||||||
|
storage.removeItem("base_url");
|
||||||
|
storage.removeItem("user_id");
|
||||||
|
storage.removeItem("device_id");
|
||||||
|
storage.removeItem("access_token");
|
||||||
|
storage.removeItem("login_type");
|
||||||
|
}
|
12
src/components/icons.ts
Normal file
12
src/components/icons.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { lazy } from "react";
|
||||||
|
|
||||||
|
export const Icons = {
|
||||||
|
Announcement: lazy(() => import('@mui/icons-material/Announcement')),
|
||||||
|
Engineering: lazy(() => import('@mui/icons-material/Engineering')),
|
||||||
|
HelpCenter: lazy(() => import('@mui/icons-material/HelpCenter')),
|
||||||
|
SupportAgent: lazy(() => import('@mui/icons-material/SupportAgent')),
|
||||||
|
Default: lazy(() => import('@mui/icons-material/OpenInNew')),
|
||||||
|
// Add more icons as needed
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DefaultIcon = Icons.Default;
|
@@ -2,7 +2,7 @@ import { formalGermanMessages } from "@haleos/ra-language-german";
|
|||||||
|
|
||||||
import { SynapseTranslationMessages } from ".";
|
import { SynapseTranslationMessages } from ".";
|
||||||
|
|
||||||
const de: SynapseTranslationMessages = {
|
const fixedGermanMessages = {
|
||||||
...formalGermanMessages,
|
...formalGermanMessages,
|
||||||
ra: {
|
ra: {
|
||||||
...formalGermanMessages.ra,
|
...formalGermanMessages.ra,
|
||||||
@@ -10,8 +10,30 @@ const de: SynapseTranslationMessages = {
|
|||||||
...formalGermanMessages.ra.navigation,
|
...formalGermanMessages.ra.navigation,
|
||||||
no_filtered_results: "Keine Ergebnisse",
|
no_filtered_results: "Keine Ergebnisse",
|
||||||
clear_filters: "Alle Filter entfernen",
|
clear_filters: "Alle Filter entfernen",
|
||||||
|
add_filter: "Filter hinzufügen",
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
...formalGermanMessages.ra.action,
|
||||||
|
update_application: "Anwendung aktualisieren",
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
...formalGermanMessages.ra.page,
|
||||||
|
empty: "Leer",
|
||||||
|
access_denied: "Zugriff verweigert",
|
||||||
|
authentication_error: "Authentifizierungsfehler",
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
...formalGermanMessages.ra.message,
|
||||||
|
access_denied:
|
||||||
|
"Sie haben nicht die richtigen Berechtigungen um auf diese Seite zuzugreifen.",
|
||||||
|
authentication_error:
|
||||||
|
"Der Authentifizierungsserver hat einen Fehler zurückgegeben und Ihre Anmeldedaten konnten nicht überprüft werden.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const de: SynapseTranslationMessages = {
|
||||||
|
...fixedGermanMessages,
|
||||||
synapseadmin: {
|
synapseadmin: {
|
||||||
auth: {
|
auth: {
|
||||||
base_url: "Heimserver URL",
|
base_url: "Heimserver URL",
|
||||||
@@ -33,7 +55,7 @@ const de: SynapseTranslationMessages = {
|
|||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "Lokaler Anteil der Matrix Benutzer-ID ohne Homeserver.",
|
invalid_user_id: "Lokaler Anteil der Matrix Benutzer-ID ohne Homeserver.",
|
||||||
tabs: { sso: "SSO" },
|
tabs: { sso: "SSO", experimental: "Experimentell", limits: "Rate Limits" },
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
details: "Raumdetails",
|
details: "Raumdetails",
|
||||||
@@ -162,13 +184,25 @@ const de: SynapseTranslationMessages = {
|
|||||||
erase_text: "Das bedeutet, dass die von dem/den Benutzer(n) gesendeten Nachrichten für alle, die zum Zeitpunkt des Sendens im Raum waren, sichtbar bleiben, aber für Benutzer, die dem Raum später beitreten, nicht sichtbar sind.",
|
erase_text: "Das bedeutet, dass die von dem/den Benutzer(n) gesendeten Nachrichten für alle, die zum Zeitpunkt des Sendens im Raum waren, sichtbar bleiben, aber für Benutzer, die dem Raum später beitreten, nicht sichtbar sind.",
|
||||||
erase_admin_error: "Das Löschen des eigenen Benutzers ist nicht erlaubt.",
|
erase_admin_error: "Das Löschen des eigenen Benutzers ist nicht erlaubt.",
|
||||||
modify_managed_user_error: "Das Ändern eines vom System verwalteten Benutzers ist nicht zulässig.",
|
modify_managed_user_error: "Das Ändern eines vom System verwalteten Benutzers ist nicht zulässig.",
|
||||||
|
username_available: "Benutzername verfügbar",
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
erase: "Lösche Benutzerdaten",
|
erase: "Lösche Benutzerdaten",
|
||||||
erase_avatar: "Avatar löschen",
|
erase_avatar: "Avatar löschen",
|
||||||
delete_media: "Alle von dem/den Benutzer(n) hochgeladenen Medien löschen",
|
delete_media: "Alle von dem/den Benutzer(n) hochgeladenen Medien löschen",
|
||||||
redact_events: "Schwärzen aller vom Benutzer gesendeten Ereignisse (-s)",
|
redact_events: "Schwärzen aller vom Benutzer gesendeten Ereignisse (-s)",
|
||||||
|
generate_password: "Passwort generieren",
|
||||||
|
overwrite_title: "Warnung!",
|
||||||
|
overwrite_content: "Dieser Benutzername ist bereits vergeben. Sind Sie sicher, dass Sie den vorhandenen Benutzer überschreiben möchten?",
|
||||||
|
overwrite_cancel: "Abbrechen",
|
||||||
|
overwrite_confirm: "Überschreiben",
|
||||||
},
|
},
|
||||||
|
limits: {
|
||||||
|
messages_per_second: "Nachrichten pro Sekunde",
|
||||||
|
messages_per_second_text: "Die Anzahl der Aktionen, die in einer Sekunde durchgeführt werden können.",
|
||||||
|
burst_count: "Burst-Anzahl",
|
||||||
|
burst_count_text: "Die Anzahl der Aktionen, die vor der Begrenzung durchgeführt werden können.",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "Raum |||| Räume",
|
name: "Raum |||| Räume",
|
||||||
|
@@ -25,7 +25,11 @@ const en: SynapseTranslationMessages = {
|
|||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "Localpart of a Matrix user-id without homeserver.",
|
invalid_user_id: "Localpart of a Matrix user-id without homeserver.",
|
||||||
tabs: { sso: "SSO" },
|
tabs: {
|
||||||
|
sso: "SSO",
|
||||||
|
experimental: "Experimental",
|
||||||
|
limits: "Rate Limits",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
details: "Room details",
|
details: "Room details",
|
||||||
@@ -153,13 +157,25 @@ const en: SynapseTranslationMessages = {
|
|||||||
erase_text: "This means messages sent by the user(-s) will still be visible by anyone who was in the room when these messages were sent, but hidden from users joining the room afterward.",
|
erase_text: "This means messages sent by the user(-s) will still be visible by anyone who was in the room when these messages were sent, but hidden from users joining the room afterward.",
|
||||||
erase_admin_error: "Deleting own user is not allowed.",
|
erase_admin_error: "Deleting own user is not allowed.",
|
||||||
modify_managed_user_error: "Modifying a system-managed user is not allowed.",
|
modify_managed_user_error: "Modifying a system-managed user is not allowed.",
|
||||||
|
username_available: "Username is available",
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
erase: "Erase user data",
|
erase: "Erase user data",
|
||||||
erase_avatar: "Erase avatar",
|
erase_avatar: "Erase avatar",
|
||||||
delete_media: "Delete all media uploaded by the user(-s)",
|
delete_media: "Delete all media uploaded by the user(-s)",
|
||||||
redact_events: "Redact all events sent by the user(-s)",
|
redact_events: "Redact all events sent by the user(-s)",
|
||||||
|
generate_password: "Generate password",
|
||||||
|
overwrite_title: "Warning!",
|
||||||
|
overwrite_content: "This username is already taken. Are you sure that you want to overwrite the existing user?",
|
||||||
|
overwrite_cancel: "Cancel",
|
||||||
|
overwrite_confirm: "Overwrite",
|
||||||
},
|
},
|
||||||
|
limits: {
|
||||||
|
messages_per_second: "Messages per second",
|
||||||
|
messages_per_second_text: "The number of actions that can be performed in a second.",
|
||||||
|
burst_count: "Burst count",
|
||||||
|
burst_count_text: "How many actions that can be performed before being limited.",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "Room |||| Rooms",
|
name: "Room |||| Rooms",
|
||||||
|
@@ -24,7 +24,7 @@ const fa: SynapseTranslationMessages = {
|
|||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "بخش محلی یک شناسه کاربری ماتریکس بدون سرور خانگی.",
|
invalid_user_id: "بخش محلی یک شناسه کاربری ماتریکس بدون سرور خانگی.",
|
||||||
tabs: { sso: "SSO" },
|
tabs: { sso: "SSO", experimental: "تجربی", limits: "محدودیت ها" },
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
tabs: {
|
tabs: {
|
||||||
@@ -149,13 +149,25 @@ const fa: SynapseTranslationMessages = {
|
|||||||
erase_text: "وهذا يعني أن الرسائل المرسلة من قبل المستخدم (المستخدمين) ستظل مرئية من قبل أي شخص كان في الغرفة عند إرسال هذه الرسائل، ولكنها مخفية عن المستخدمين الذين ينضمون إلى الغرفة بعد ذلك.",
|
erase_text: "وهذا يعني أن الرسائل المرسلة من قبل المستخدم (المستخدمين) ستظل مرئية من قبل أي شخص كان في الغرفة عند إرسال هذه الرسائل، ولكنها مخفية عن المستخدمين الذين ينضمون إلى الغرفة بعد ذلك.",
|
||||||
erase_admin_error: "حذف المستخدم الخاص غير مسموح به.",
|
erase_admin_error: "حذف المستخدم الخاص غير مسموح به.",
|
||||||
modify_managed_user_error: "لا يُسمح بتغيير المستخدم الذي يديره النظام.",
|
modify_managed_user_error: "لا يُسمح بتغيير المستخدم الذي يديره النظام.",
|
||||||
|
username_available: "نام کاربری موجود",
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
erase: "پاک کردن اطلاعات کاربر",
|
erase: "پاک کردن اطلاعات کاربر",
|
||||||
erase_avatar: "محو الصورة الرمزية",
|
erase_avatar: "محو الصورة الرمزية",
|
||||||
delete_media: "حذف جميع الوسائط التي تم تحميلها بواسطة المستخدم (المستخدمين)",
|
delete_media: "حذف جميع الوسائط التي تم تحميلها بواسطة المستخدم (المستخدمين)",
|
||||||
redact_events: "تنقيح جميع الأحداث المرسلة من قبل المستخدم (-s)",
|
redact_events: "تنقيح جميع الأحداث المرسلة من قبل المستخدم (-s)",
|
||||||
|
generate_password: "توليد رمز عبور",
|
||||||
|
overwrite_title: "هشدار!",
|
||||||
|
overwrite_content: "این نام کاربری قبلا استفاده شده است. آیا مطمئن هستید که می خواهید کاربر موجود را بازنویسی کنید؟",
|
||||||
|
overwrite_cancel: "انصراف",
|
||||||
|
overwrite_confirm: "بازنویسی",
|
||||||
},
|
},
|
||||||
|
limits: {
|
||||||
|
messages_per_second: "پیام در ثانیه",
|
||||||
|
messages_per_second_text: "تعداد عملیاتی که می تواند در یک ثانیه انجام شود.",
|
||||||
|
burst_count: "تعداد پیچیدگی",
|
||||||
|
burst_count_text: "تعداد عملیاتی که می تواند قبل از محدودیت انجام شود.",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "اتاق |||| اتاق ها",
|
name: "اتاق |||| اتاق ها",
|
||||||
@@ -207,6 +219,11 @@ const fa: SynapseTranslationMessages = {
|
|||||||
title: "حذف اتاق",
|
title: "حذف اتاق",
|
||||||
content:
|
content:
|
||||||
"آیا مطمئن هستید که می خواهید اتاق را حذف کنید؟ این قابل بازگشت نیست. همه پیام ها و رسانه های مشترک در اتاق از سرور حذف می شوند!",
|
"آیا مطمئن هستید که می خواهید اتاق را حذف کنید؟ این قابل بازگشت نیست. همه پیام ها و رسانه های مشترک در اتاق از سرور حذف می شوند!",
|
||||||
|
fields: {
|
||||||
|
block: "حذف",
|
||||||
|
},
|
||||||
|
success: "اتاق با موفقیت حذف شد.",
|
||||||
|
failure: "خطایی رخ داده است.",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -24,7 +24,7 @@ const fr: SynapseTranslationMessages = {
|
|||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "Partie locale d'un identifiant utilisateur Matrix sans le nom du serveur d’accueil.",
|
invalid_user_id: "Partie locale d'un identifiant utilisateur Matrix sans le nom du serveur d’accueil.",
|
||||||
tabs: { sso: "Authentification unique" },
|
tabs: { sso: "Authentification unique", experimental: "Expérimental", limits: "Limites" },
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
tabs: {
|
tabs: {
|
||||||
@@ -151,13 +151,25 @@ const fr: SynapseTranslationMessages = {
|
|||||||
erase_text: "Cela signifie que les messages envoyés par le(s) utilisateur(s) seront toujours visibles par toute personne qui se trouvait dans la salle au moment où ces messages ont été envoyés, mais qu'ils seront cachés aux utilisateurs qui rejoindront la salle par la suite.",
|
erase_text: "Cela signifie que les messages envoyés par le(s) utilisateur(s) seront toujours visibles par toute personne qui se trouvait dans la salle au moment où ces messages ont été envoyés, mais qu'ils seront cachés aux utilisateurs qui rejoindront la salle par la suite.",
|
||||||
erase_admin_error: "La suppression de son propre utilisateur n'est pas autorisée.",
|
erase_admin_error: "La suppression de son propre utilisateur n'est pas autorisée.",
|
||||||
modify_managed_user_error: "La modification d'un utilisateur géré par le système n'est pas autorisée.",
|
modify_managed_user_error: "La modification d'un utilisateur géré par le système n'est pas autorisée.",
|
||||||
|
username_available: "Nom d'utilisateur disponible",
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
erase: "Effacer les données de l'utilisateur",
|
erase: "Effacer les données de l'utilisateur",
|
||||||
erase_avatar: "Effacer l'avatar",
|
erase_avatar: "Effacer l'avatar",
|
||||||
delete_media: "Supprimer tous les médias téléchargés par le(s) utilisateur(s)",
|
delete_media: "Supprimer tous les médias téléchargés par le(s) utilisateur(s)",
|
||||||
redact_events: "Expurger tous les événements envoyés par l'utilisateur(-s)",
|
redact_events: "Expurger tous les événements envoyés par l'utilisateur(-s)",
|
||||||
|
generate_password: "Générer un mot de passe",
|
||||||
|
overwrite_title: "Attention !",
|
||||||
|
overwrite_content: "Ce nom d'utilisateur est déjà pris. Êtes-vous sûr de vouloir écraser l'utilisateur existant ?",
|
||||||
|
overwrite_cancel: "Annuler",
|
||||||
|
overwrite_confirm: "Écraser",
|
||||||
},
|
},
|
||||||
|
limits: {
|
||||||
|
messages_per_second: "Messages par seconde",
|
||||||
|
messages_per_second_text: "Le nombre d'actions que l'utilisateur peut effectuer par seconde.",
|
||||||
|
burst_count: "Compteur de pics",
|
||||||
|
burst_count_text: "Le nombre d'actions que l'utilisateur peut effectuer avant d'être limité.",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "Salon |||| Salons",
|
name: "Salon |||| Salons",
|
||||||
|
14
src/i18n/index.d.ts
vendored
14
src/i18n/index.d.ts
vendored
@@ -22,7 +22,7 @@ interface SynapseTranslationMessages extends TranslationMessages {
|
|||||||
};
|
};
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: string;
|
invalid_user_id: string;
|
||||||
tabs: { sso: string };
|
tabs: { sso: string; experimental: string; limits: string; };
|
||||||
};
|
};
|
||||||
rooms: {
|
rooms: {
|
||||||
details?: string; // TODO: fa, fr, it, zh
|
details?: string; // TODO: fa, fr, it, zh
|
||||||
@@ -149,12 +149,24 @@ interface SynapseTranslationMessages extends TranslationMessages {
|
|||||||
erase_text: string;
|
erase_text: string;
|
||||||
erase_admin_error: string;
|
erase_admin_error: string;
|
||||||
modify_managed_user_error: string;
|
modify_managed_user_error: string;
|
||||||
|
username_available: string;
|
||||||
};
|
};
|
||||||
action: {
|
action: {
|
||||||
erase: string;
|
erase: string;
|
||||||
erase_avatar: string;
|
erase_avatar: string;
|
||||||
delete_media: string;
|
delete_media: string;
|
||||||
redact_events: string;
|
redact_events: string;
|
||||||
|
generate_password: string;
|
||||||
|
overwrite_title: string;
|
||||||
|
overwrite_content: string;
|
||||||
|
overwrite_cancel: string;
|
||||||
|
overwrite_confirm: string;
|
||||||
|
};
|
||||||
|
limits: {
|
||||||
|
messages_per_second: string;
|
||||||
|
messages_per_second_text: string;
|
||||||
|
burst_count: string;
|
||||||
|
burst_count_text: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
rooms: {
|
rooms: {
|
||||||
|
@@ -24,7 +24,7 @@ const it: SynapseTranslationMessages = {
|
|||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "ID utente non valido su questo homeserver.",
|
invalid_user_id: "ID utente non valido su questo homeserver.",
|
||||||
tabs: { sso: "SSO" },
|
tabs: { sso: "SSO", experimental: "Sperimentale", limits: "Limiti" },
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
tabs: {
|
tabs: {
|
||||||
@@ -150,13 +150,25 @@ const it: SynapseTranslationMessages = {
|
|||||||
erase_text: "Ciò significa che i messaggi inviati dall'utente (o dagli utenti) saranno ancora visibili da chiunque si trovasse nella stanza al momento dell'invio, ma saranno nascosti agli utenti che si uniranno alla stanza in seguito.",
|
erase_text: "Ciò significa che i messaggi inviati dall'utente (o dagli utenti) saranno ancora visibili da chiunque si trovasse nella stanza al momento dell'invio, ma saranno nascosti agli utenti che si uniranno alla stanza in seguito.",
|
||||||
erase_admin_error: "Non è consentito eliminare il proprio utente.",
|
erase_admin_error: "Non è consentito eliminare il proprio utente.",
|
||||||
modify_managed_user_error: "La modifica di un utente gestito dal sistema non è consentita.",
|
modify_managed_user_error: "La modifica di un utente gestito dal sistema non è consentita.",
|
||||||
|
username_available: "Nome utente disponibile",
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
erase: "Cancella i dati dell'utente",
|
erase: "Cancella i dati dell'utente",
|
||||||
erase_avatar: "Cancella l'avatar dell'utente",
|
erase_avatar: "Cancella l'avatar dell'utente",
|
||||||
delete_media: "Elimina tutti i media caricati dall'utente(-s)",
|
delete_media: "Elimina tutti i media caricati dall'utente(-s)",
|
||||||
redact_events: "Ridurre tutti gli eventi inviati dall'utente(-s)",
|
redact_events: "Ridurre tutti gli eventi inviati dall'utente(-s)",
|
||||||
|
generate_password: "Genera password",
|
||||||
|
overwrite_title: "Attenzione!",
|
||||||
|
overwrite_content: "Questo nome utente è già stato utilizzato. Sei sicuro di voler sovrascrivere l'utente esistente?",
|
||||||
|
overwrite_cancel: "Annulla",
|
||||||
|
overwrite_confirm: "Sovrascrivi",
|
||||||
},
|
},
|
||||||
|
limits: {
|
||||||
|
messages_per_second: "Messaggi al secondo",
|
||||||
|
messages_per_second_text: "Il numero di azioni che l'utente può eseguire al secondo.",
|
||||||
|
burst_count: "Burst-conteggio",
|
||||||
|
burst_count_text: "Il numero di azioni che l'utente può eseguire prima di essere limitato.",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "Stanza |||| Stanze",
|
name: "Stanza |||| Stanze",
|
||||||
|
@@ -2,7 +2,7 @@ import russianMessages from "ra-language-russian";
|
|||||||
|
|
||||||
import { SynapseTranslationMessages } from ".";
|
import { SynapseTranslationMessages } from ".";
|
||||||
|
|
||||||
const ru: SynapseTranslationMessages = {
|
const fixedRussianMessages = {
|
||||||
...russianMessages,
|
...russianMessages,
|
||||||
ra: {
|
ra: {
|
||||||
...russianMessages.ra,
|
...russianMessages.ra,
|
||||||
@@ -11,7 +11,24 @@ const ru: SynapseTranslationMessages = {
|
|||||||
no_filtered_results: "Нет результатов",
|
no_filtered_results: "Нет результатов",
|
||||||
clear_filters: "Все фильтры сбросить",
|
clear_filters: "Все фильтры сбросить",
|
||||||
},
|
},
|
||||||
|
page: {
|
||||||
|
...russianMessages.ra.page,
|
||||||
|
empty: "Пусто",
|
||||||
|
access_denied: "Доступ запрещен",
|
||||||
|
authentication_error: "Ошибка аутентификации",
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
...russianMessages.ra.message,
|
||||||
|
access_denied:
|
||||||
|
"У вас нет прав доступа к этой странице.",
|
||||||
|
authentication_error:
|
||||||
|
"Сервер аутентификации вернул ошибку и не смог проверить ваши учетные данные.",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const ru: SynapseTranslationMessages = {
|
||||||
|
...fixedRussianMessages,
|
||||||
synapseadmin: {
|
synapseadmin: {
|
||||||
auth: {
|
auth: {
|
||||||
base_url: "Адрес домашнего сервера",
|
base_url: "Адрес домашнего сервера",
|
||||||
@@ -33,7 +50,7 @@ const ru: SynapseTranslationMessages = {
|
|||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "Локальная часть ID пользователя Matrix без адреса домашнего сервера.",
|
invalid_user_id: "Локальная часть ID пользователя Matrix без адреса домашнего сервера.",
|
||||||
tabs: { sso: "SSO" },
|
tabs: { sso: "SSO", experimental: "Экспериментальные", limits: "Ограничения" },
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
details: "Данные комнаты",
|
details: "Данные комнаты",
|
||||||
@@ -170,14 +187,26 @@ const ru: SynapseTranslationMessages = {
|
|||||||
erase_text: "Это означает, что сообщения, отправленные пользователем (-ами), будут по-прежнему видны всем, кто находился в комнате в момент их отправки, но будут скрыты от пользователей, присоединившихся к комнате после этого.",
|
erase_text: "Это означает, что сообщения, отправленные пользователем (-ами), будут по-прежнему видны всем, кто находился в комнате в момент их отправки, но будут скрыты от пользователей, присоединившихся к комнате после этого.",
|
||||||
erase_admin_error: "Удаление собственного пользователя запрещено.",
|
erase_admin_error: "Удаление собственного пользователя запрещено.",
|
||||||
modify_managed_user_error: "Изменение пользователя, управляемого системой, не допускается.",
|
modify_managed_user_error: "Изменение пользователя, управляемого системой, не допускается.",
|
||||||
|
username_available: "Имя пользователя доступно",
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
erase: "Удалить данные пользователя",
|
erase: "Удалить данные пользователя",
|
||||||
erase_avatar: "Удалить аватар",
|
erase_avatar: "Удалить аватар",
|
||||||
delete_media: "Удаление всех медиафайлов, загруженных пользователем (-ами)",
|
delete_media: "Удаление всех медиафайлов, загруженных пользователем (-ами)",
|
||||||
redact_events: "Удаление всех событий, отправленных пользователем (-ами)",
|
redact_events: "Удаление всех событий, отправленных пользователем (-ами)",
|
||||||
|
generate_password: "Сгенерировать пароль",
|
||||||
|
overwrite_title: "Предупреждение!",
|
||||||
|
overwrite_content: "Это имя пользователя уже занято. Вы уверены, что хотите перезаписать существующего пользователя?",
|
||||||
|
overwrite_cancel: "Отмена",
|
||||||
|
overwrite_confirm: "Перезаписать",
|
||||||
},
|
},
|
||||||
},
|
limits: {
|
||||||
|
messages_per_second: "Сообщений в секунду",
|
||||||
|
messages_per_second_text: "Количество действий, которые могут быть выполнены в секунду.",
|
||||||
|
burst_count: "Burst-счётчик",
|
||||||
|
burst_count_text: "Количество действий, которые могут быть выполнены до ограничения.",
|
||||||
|
}
|
||||||
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "Комната |||| Комнаты",
|
name: "Комната |||| Комнаты",
|
||||||
fields: {
|
fields: {
|
||||||
|
@@ -2,7 +2,7 @@ import chineseMessages from "@haxqer/ra-language-chinese";
|
|||||||
|
|
||||||
import { SynapseTranslationMessages } from ".";
|
import { SynapseTranslationMessages } from ".";
|
||||||
|
|
||||||
const zh: SynapseTranslationMessages = {
|
const fixedChineseMessages = {
|
||||||
...chineseMessages,
|
...chineseMessages,
|
||||||
ra: {
|
ra: {
|
||||||
...chineseMessages.ra,
|
...chineseMessages.ra,
|
||||||
@@ -11,7 +11,27 @@ const zh: SynapseTranslationMessages = {
|
|||||||
no_filtered_results: "没有结果",
|
no_filtered_results: "没有结果",
|
||||||
clear_filters: "清除所有过滤器",
|
clear_filters: "清除所有过滤器",
|
||||||
},
|
},
|
||||||
|
action: {
|
||||||
|
...chineseMessages.ra.action,
|
||||||
|
update_application: "Anwendung aktualisieren",
|
||||||
|
},
|
||||||
|
page: {
|
||||||
|
...chineseMessages.ra.page,
|
||||||
|
access_denied: "拒绝访问",
|
||||||
|
authentication_error: "认证错误",
|
||||||
|
},
|
||||||
|
message: {
|
||||||
|
...chineseMessages.ra.message,
|
||||||
|
access_denied:
|
||||||
|
"您没有访问此页面的权限。",
|
||||||
|
authentication_error:
|
||||||
|
"身份验证服务器返回错误,无法验证您的凭据。",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const zh: SynapseTranslationMessages = {
|
||||||
|
...fixedChineseMessages,
|
||||||
synapseadmin: {
|
synapseadmin: {
|
||||||
auth: {
|
auth: {
|
||||||
base_url: "服务器 URL",
|
base_url: "服务器 URL",
|
||||||
@@ -32,7 +52,7 @@ const zh: SynapseTranslationMessages = {
|
|||||||
},
|
},
|
||||||
users: {
|
users: {
|
||||||
invalid_user_id: "必须要是一个有效的 Matrix 用户 ID ,例如 @user_id:homeserver",
|
invalid_user_id: "必须要是一个有效的 Matrix 用户 ID ,例如 @user_id:homeserver",
|
||||||
tabs: { sso: "SSO" },
|
tabs: { sso: "SSO", experimental: "实验性", limits: "限制" },
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
tabs: {
|
tabs: {
|
||||||
@@ -154,13 +174,25 @@ const zh: SynapseTranslationMessages = {
|
|||||||
erase_text: "这意味着用户发送的信息对于发送信息时在房间内的任何人来说都是可见的,但对于之后加入房间的用户来说则是隐藏的。",
|
erase_text: "这意味着用户发送的信息对于发送信息时在房间内的任何人来说都是可见的,但对于之后加入房间的用户来说则是隐藏的。",
|
||||||
erase_admin_error: "不允许删除自己的用户",
|
erase_admin_error: "不允许删除自己的用户",
|
||||||
modify_managed_user_error: "不允许修改系统管理的用户。",
|
modify_managed_user_error: "不允许修改系统管理的用户。",
|
||||||
|
username_available: "用户名可用",
|
||||||
},
|
},
|
||||||
action: {
|
action: {
|
||||||
erase: "抹除用户信息",
|
erase: "抹除用户信息",
|
||||||
erase_avatar: "抹掉头像",
|
erase_avatar: "抹掉头像",
|
||||||
delete_media: "删除用户上传的所有媒体",
|
delete_media: "删除用户上传的所有媒体",
|
||||||
redact_events: "重新编辑用户(-s)发送的所有事件",
|
redact_events: "重新编辑用户(-s)发送的所有事件",
|
||||||
|
generate_password: "生成密码",
|
||||||
|
overwrite_title: "警告!",
|
||||||
|
overwrite_content: "这个用户名已经被占用。您确定要覆盖现有的用户吗?",
|
||||||
|
overwrite_cancel: "取消",
|
||||||
|
overwrite_confirm: "覆盖",
|
||||||
},
|
},
|
||||||
|
limits: {
|
||||||
|
messages_per_second: "每秒消息数",
|
||||||
|
messages_per_second_text: "每秒可以执行的操作数。",
|
||||||
|
burst_count: "Burst-计数",
|
||||||
|
burst_count_text: "在限制之前可以执行的操作数。",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
name: "房间",
|
name: "房间",
|
||||||
|
@@ -3,23 +3,47 @@ import React from "react";
|
|||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
|
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
|
import { Config, WellKnownKey, LoadConfig } from "./components/config";
|
||||||
import { AppContext } from "./AppContext";
|
import { AppContext } from "./AppContext";
|
||||||
import storage from "./storage";
|
import storage from "./storage";
|
||||||
|
|
||||||
fetch("config.json")
|
// load config.json
|
||||||
.then(res => res.json())
|
let props: Config = {
|
||||||
.then(props => {
|
restrictBaseUrl: [],
|
||||||
if (props.asManagedUsers) {
|
asManagedUsers: [],
|
||||||
storage.setItem("as_managed_users", JSON.stringify(props.asManagedUsers));
|
supportURL: "",
|
||||||
|
menu: [],
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const resp = await fetch("config.json");
|
||||||
|
const configJSON = await resp.json();
|
||||||
|
console.log("Loaded config.json", configJSON);
|
||||||
|
props = LoadConfig(configJSON as Config);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if home_server is set, try to load https://home_server/.well-known/matrix/client
|
||||||
|
const homeserver = storage.getItem("home_server");
|
||||||
|
if (homeserver) {
|
||||||
|
try {
|
||||||
|
const resp = await fetch(`https://${homeserver}/.well-known/matrix/client`);
|
||||||
|
const configWK = await resp.json();
|
||||||
|
if (!configWK[WellKnownKey]) {
|
||||||
|
console.log(`Loaded https://${homeserver}.well-known/matrix/client, but it doesn't contain ${WellKnownKey} key, skipping`, configWK);
|
||||||
|
} else {
|
||||||
|
console.log(`Loaded https://${homeserver}.well-known/matrix/client`, configWK);
|
||||||
|
props = LoadConfig(configWK[WellKnownKey] as Config);
|
||||||
}
|
}
|
||||||
if (props.supportURL) {
|
} catch (e) {
|
||||||
storage.setItem("support_url", props.supportURL);
|
console.log(`https://${homeserver}/.well-known/matrix/client not found, skipping`, e);
|
||||||
}
|
}
|
||||||
return createRoot(document.getElementById("root")).render(
|
}
|
||||||
|
|
||||||
|
createRoot(document.getElementById("root")).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<AppContext.Provider value={props}>
|
<AppContext.Provider value={props}>
|
||||||
<App />
|
<App />
|
||||||
</AppContext.Provider>
|
</AppContext.Provider>
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
)
|
);
|
||||||
});
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
|
|
||||||
import LockIcon from "@mui/icons-material/Lock";
|
|
||||||
import { Avatar, Box, Button, Card, CardActions, CircularProgress, MenuItem, Select, Tab, Tabs, Typography } from "@mui/material";
|
import { Avatar, Box, Button, Card, CardActions, CircularProgress, MenuItem, Select, Tab, Tabs, Typography } from "@mui/material";
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
@@ -34,7 +33,7 @@ const LoginPage = () => {
|
|||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
const { restrictBaseUrl } = useAppContext();
|
const { restrictBaseUrl } = useAppContext();
|
||||||
const allowSingleBaseUrl = typeof restrictBaseUrl === "string";
|
const allowSingleBaseUrl = typeof restrictBaseUrl === "string" && restrictBaseUrl !== "";
|
||||||
const allowMultipleBaseUrls =
|
const allowMultipleBaseUrls =
|
||||||
Array.isArray(restrictBaseUrl) &&
|
Array.isArray(restrictBaseUrl) &&
|
||||||
restrictBaseUrl.length > 0 &&
|
restrictBaseUrl.length > 0 &&
|
||||||
@@ -97,6 +96,9 @@ const LoginPage = () => {
|
|||||||
|
|
||||||
const handleSubmit = auth => {
|
const handleSubmit = auth => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
const cleanUrl = window.location.href.replace(window.location.search, "");
|
||||||
|
window.history.replaceState({}, "", cleanUrl);
|
||||||
|
|
||||||
login(auth).catch(error => {
|
login(auth).catch(error => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
notify(
|
notify(
|
||||||
@@ -167,6 +169,22 @@ const LoginPage = () => {
|
|||||||
.catch(() => setSSOBaseUrl(""));
|
.catch(() => setSSOBaseUrl(""));
|
||||||
}, [formData.base_url, form]);
|
}, [formData.base_url, form]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const username = params.get("username");
|
||||||
|
let serverURL = params.get("server");
|
||||||
|
if (username) {
|
||||||
|
form.setValue("username", username);
|
||||||
|
}
|
||||||
|
if (serverURL) {
|
||||||
|
const isFullUrl = serverURL.match(/^(http|https):\/\//);
|
||||||
|
if (!isFullUrl) {
|
||||||
|
serverURL = `https://${serverURL}`;
|
||||||
|
}
|
||||||
|
form.setValue("base_url", serverURL);
|
||||||
|
}
|
||||||
|
}, [window.location.search]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Tabs
|
<Tabs
|
||||||
@@ -187,10 +205,10 @@ const LoginPage = () => {
|
|||||||
source="username"
|
source="username"
|
||||||
label="ra.auth.username"
|
label="ra.auth.username"
|
||||||
autoComplete="username"
|
autoComplete="username"
|
||||||
disabled={loading || !supportPassAuth}
|
|
||||||
onBlur={handleUsernameChange}
|
onBlur={handleUsernameChange}
|
||||||
resettable
|
resettable
|
||||||
validate={required()}
|
validate={required()}
|
||||||
|
{...(loading || !supportPassAuth ? { disabled: true } : {})}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
@@ -199,7 +217,7 @@ const LoginPage = () => {
|
|||||||
label="ra.auth.password"
|
label="ra.auth.password"
|
||||||
type="password"
|
type="password"
|
||||||
autoComplete="current-password"
|
autoComplete="current-password"
|
||||||
disabled={loading || !supportPassAuth}
|
{...(loading || !supportPassAuth ? { disabled: true } : {})}
|
||||||
resettable
|
resettable
|
||||||
validate={required()}
|
validate={required()}
|
||||||
/>
|
/>
|
||||||
@@ -210,7 +228,7 @@ const LoginPage = () => {
|
|||||||
<TextInput
|
<TextInput
|
||||||
source="accessToken"
|
source="accessToken"
|
||||||
label="synapseadmin.auth.access_token"
|
label="synapseadmin.auth.access_token"
|
||||||
disabled={loading}
|
{...(loading ? { disabled: true } : {})}
|
||||||
resettable
|
resettable
|
||||||
validate={required()}
|
validate={required()}
|
||||||
/>
|
/>
|
||||||
@@ -222,7 +240,7 @@ const LoginPage = () => {
|
|||||||
label="synapseadmin.auth.base_url"
|
label="synapseadmin.auth.base_url"
|
||||||
select={allowMultipleBaseUrls}
|
select={allowMultipleBaseUrls}
|
||||||
autoComplete="url"
|
autoComplete="url"
|
||||||
disabled={loading}
|
{...(loading ? { disabled: true } : {})}
|
||||||
readOnly={allowSingleBaseUrl}
|
readOnly={allowSingleBaseUrl}
|
||||||
resettable={allowAnyBaseUrl}
|
resettable={allowAnyBaseUrl}
|
||||||
validate={[required(), validateBaseUrl]}
|
validate={[required(), validateBaseUrl]}
|
||||||
@@ -249,9 +267,7 @@ const LoginPage = () => {
|
|||||||
{loading ? (
|
{loading ? (
|
||||||
<CircularProgress size={25} thickness={2} />
|
<CircularProgress size={25} thickness={2} />
|
||||||
) : (
|
) : (
|
||||||
<Avatar className="icon">
|
<Avatar sx={{ width: "120px", height: "120px" }} src="./images/logo.webp"/>
|
||||||
<LockIcon />
|
|
||||||
</Avatar>
|
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
<Box className="hint">{translate("synapseadmin.auth.welcome")}</Box>
|
<Box className="hint">{translate("synapseadmin.auth.welcome")}</Box>
|
||||||
@@ -270,7 +286,7 @@ const LoginPage = () => {
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
<FormDataConsumer>{formDataProps => <UserData {...formDataProps} />}</FormDataConsumer>
|
<FormDataConsumer>{formDataProps => <UserData {...formDataProps} />}</FormDataConsumer>
|
||||||
<CardActions className="actions">
|
{loginMethod === "credentials" && <CardActions className="actions">
|
||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -289,7 +305,18 @@ const LoginPage = () => {
|
|||||||
>
|
>
|
||||||
{translate("synapseadmin.auth.sso_sign_in")}
|
{translate("synapseadmin.auth.sso_sign_in")}
|
||||||
</Button>
|
</Button>
|
||||||
</CardActions>
|
</CardActions>}
|
||||||
|
{loginMethod === "accessToken" && <CardActions className="actions">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
type="submit"
|
||||||
|
color="primary"
|
||||||
|
disabled={loading}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
{translate("ra.auth.sign_in")}
|
||||||
|
</Button>
|
||||||
|
</CardActions>}
|
||||||
</Box>
|
</Box>
|
||||||
</Card>
|
</Card>
|
||||||
</LoginFormBox>
|
</LoginFormBox>
|
||||||
|
@@ -8,6 +8,7 @@ import ErrorIcon from '@mui/icons-material/Error';
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
DatagridConfigurable,
|
||||||
DateField,
|
DateField,
|
||||||
List,
|
List,
|
||||||
ListProps,
|
ListProps,
|
||||||
@@ -123,14 +124,14 @@ export const DestinationList = (props: ListProps) => {
|
|||||||
pagination={<DestinationPagination />}
|
pagination={<DestinationPagination />}
|
||||||
sort={{ field: "destination", order: "ASC" }}
|
sort={{ field: "destination", order: "ASC" }}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick={id => `${id}/show/rooms`} bulkActionButtons={false}>
|
<DatagridConfigurable rowClick={id => `${id}/show/rooms`} bulkActionButtons={false}>
|
||||||
<FunctionField source="destination" render={destinationFieldRender} />
|
<FunctionField source="destination" render={destinationFieldRender} />
|
||||||
<DateField source="failure_ts" showTime options={DATE_FORMAT} />
|
<DateField source="failure_ts" showTime options={DATE_FORMAT} />
|
||||||
<RetryDateField source="retry_last_ts" showTime options={DATE_FORMAT} />
|
<RetryDateField source="retry_last_ts" showTime options={DATE_FORMAT} />
|
||||||
<TextField source="retry_interval" />
|
<TextField source="retry_interval" />
|
||||||
<TextField source="last_successful_stream_ordering" />
|
<TextField source="last_successful_stream_ordering" />
|
||||||
<DestinationReconnectButton />
|
<DestinationReconnectButton />
|
||||||
</Datagrid>
|
</DatagridConfigurable>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -4,6 +4,7 @@ import {
|
|||||||
Create,
|
Create,
|
||||||
CreateProps,
|
CreateProps,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
DatagridConfigurable,
|
||||||
DateField,
|
DateField,
|
||||||
DateTimeInput,
|
DateTimeInput,
|
||||||
Edit,
|
Edit,
|
||||||
@@ -39,13 +40,13 @@ export const RegistrationTokenList = (props: ListProps) => (
|
|||||||
pagination={false}
|
pagination={false}
|
||||||
perPage={500}
|
perPage={500}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick="edit">
|
<DatagridConfigurable rowClick="edit">
|
||||||
<TextField source="token" sortable={false} />
|
<TextField source="token" sortable={false} />
|
||||||
<NumberField source="uses_allowed" sortable={false} />
|
<NumberField source="uses_allowed" sortable={false} />
|
||||||
<NumberField source="pending" sortable={false} />
|
<NumberField source="pending" sortable={false} />
|
||||||
<NumberField source="completed" sortable={false} />
|
<NumberField source="completed" sortable={false} />
|
||||||
<DateField source="expiry_time" showTime options={DATE_FORMAT} sortable={false} />
|
<DateField source="expiry_time" showTime options={DATE_FORMAT} sortable={false} />
|
||||||
</Datagrid>
|
</DatagridConfigurable>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@ import ViewListIcon from "@mui/icons-material/ViewList";
|
|||||||
import ReportIcon from "@mui/icons-material/Warning";
|
import ReportIcon from "@mui/icons-material/Warning";
|
||||||
import {
|
import {
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
DatagridConfigurable,
|
||||||
DateField,
|
DateField,
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
List,
|
List,
|
||||||
@@ -90,13 +91,13 @@ const ReportShowActions = () => {
|
|||||||
|
|
||||||
export const ReportList = (props: ListProps) => (
|
export const ReportList = (props: ListProps) => (
|
||||||
<List {...props} pagination={<ReportPagination />} sort={{ field: "received_ts", order: "DESC" }}>
|
<List {...props} pagination={<ReportPagination />} sort={{ field: "received_ts", order: "DESC" }}>
|
||||||
<Datagrid rowClick="show" bulkActionButtons={false}>
|
<DatagridConfigurable rowClick="show" bulkActionButtons={false}>
|
||||||
<TextField source="id" sortable={false} />
|
<TextField source="id" sortable={false} />
|
||||||
<DateField source="received_ts" showTime options={DATE_FORMAT} sortable={true} />
|
<DateField source="received_ts" showTime options={DATE_FORMAT} sortable={true} />
|
||||||
<TextField sortable={false} source="user_id" />
|
<TextField sortable={false} source="user_id" />
|
||||||
<TextField sortable={false} source="name" />
|
<TextField sortable={false} source="name" />
|
||||||
<TextField sortable={false} source="score" />
|
<TextField sortable={false} source="score" />
|
||||||
</Datagrid>
|
</DatagridConfigurable>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -187,7 +187,7 @@ export const RoomShow = (props: ShowProps) => {
|
|||||||
<Datagrid style={{ width: "100%" }} bulkActionButtons={false}>
|
<Datagrid style={{ width: "100%" }} bulkActionButtons={false}>
|
||||||
<TextField source="type" sortable={false} />
|
<TextField source="type" sortable={false} />
|
||||||
<DateField source="origin_server_ts" showTime options={DATE_FORMAT} sortable={false} />
|
<DateField source="origin_server_ts" showTime options={DATE_FORMAT} sortable={false} />
|
||||||
<TextField source="content" sortable={false} />
|
<FunctionField source="content" sortable={false} render={record => `${JSON.stringify(record.content, null, 2)}`} />
|
||||||
<ReferenceField source="sender" reference="users" sortable={false}>
|
<ReferenceField source="sender" reference="users" sortable={false}>
|
||||||
<TextField source="id" />
|
<TextField source="id" />
|
||||||
</ReferenceField>
|
</ReferenceField>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import PermMediaIcon from "@mui/icons-material/PermMedia";
|
import PermMediaIcon from "@mui/icons-material/PermMedia";
|
||||||
import {
|
import {
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
DatagridConfigurable,
|
||||||
ExportButton,
|
ExportButton,
|
||||||
List,
|
List,
|
||||||
ListProps,
|
ListProps,
|
||||||
@@ -37,12 +38,12 @@ export const UserMediaStatsList = (props: ListProps) => (
|
|||||||
pagination={<UserMediaStatsPagination />}
|
pagination={<UserMediaStatsPagination />}
|
||||||
sort={{ field: "media_length", order: "DESC" }}
|
sort={{ field: "media_length", order: "DESC" }}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick={id => "/users/" + id + "/media"} bulkActionButtons={false}>
|
<DatagridConfigurable rowClick={id => "/users/" + id + "/media"} bulkActionButtons={false}>
|
||||||
<TextField source="user_id" label="resources.users.fields.id" />
|
<TextField source="user_id" label="resources.users.fields.id" />
|
||||||
<TextField source="displayname" label="resources.users.fields.displayname" />
|
<TextField source="displayname" label="resources.users.fields.displayname" />
|
||||||
<NumberField source="media_count" />
|
<NumberField source="media_count" />
|
||||||
<NumberField source="media_length" />
|
<NumberField source="media_length" />
|
||||||
</Datagrid>
|
</DatagridConfigurable>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -7,14 +7,18 @@ import NotificationsIcon from "@mui/icons-material/Notifications";
|
|||||||
import PermMediaIcon from "@mui/icons-material/PermMedia";
|
import PermMediaIcon from "@mui/icons-material/PermMedia";
|
||||||
import PersonPinIcon from "@mui/icons-material/PersonPin";
|
import PersonPinIcon from "@mui/icons-material/PersonPin";
|
||||||
import SettingsInputComponentIcon from "@mui/icons-material/SettingsInputComponent";
|
import SettingsInputComponentIcon from "@mui/icons-material/SettingsInputComponent";
|
||||||
|
import ScienceIcon from "@mui/icons-material/Science";
|
||||||
|
import LockClockIcon from '@mui/icons-material/LockClock';
|
||||||
import ViewListIcon from "@mui/icons-material/ViewList";
|
import ViewListIcon from "@mui/icons-material/ViewList";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Alert, ownerDocument } from "@mui/material";
|
import { Alert, Typography } from "@mui/material";
|
||||||
|
import { useTheme } from "@mui/material/styles";
|
||||||
import {
|
import {
|
||||||
ArrayInput,
|
ArrayInput,
|
||||||
ArrayField,
|
ArrayField,
|
||||||
Button,
|
Button,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
DatagridConfigurable,
|
||||||
DateField,
|
DateField,
|
||||||
Create,
|
Create,
|
||||||
CreateProps,
|
CreateProps,
|
||||||
@@ -53,10 +57,13 @@ import {
|
|||||||
useNotify,
|
useNotify,
|
||||||
Identifier,
|
Identifier,
|
||||||
ToolbarClasses,
|
ToolbarClasses,
|
||||||
RaRecord,
|
|
||||||
ImageInput,
|
ImageInput,
|
||||||
ImageField,
|
ImageField,
|
||||||
FunctionField,
|
FunctionField,
|
||||||
|
useDataProvider,
|
||||||
|
Confirm,
|
||||||
|
useCreate,
|
||||||
|
useRedirect,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
@@ -67,6 +74,11 @@ import { ServerNoticeButton, ServerNoticeBulkButton } from "../components/Server
|
|||||||
import { DATE_FORMAT } from "../components/date";
|
import { DATE_FORMAT } from "../components/date";
|
||||||
import { DeviceRemoveButton } from "../components/devices";
|
import { DeviceRemoveButton } from "../components/devices";
|
||||||
import { MediaIDField, ProtectMediaButton, QuarantineMediaButton } from "../components/media";
|
import { MediaIDField, ProtectMediaButton, QuarantineMediaButton } from "../components/media";
|
||||||
|
import { generateRandomPassword } from "../synapse/synapse";
|
||||||
|
import { useFormContext } from "react-hook-form";
|
||||||
|
import { ExperimentalFeaturesList } from "../components/ExperimentalFeatures";
|
||||||
|
import { UserRateLimits } from "../components/UserRateLimits";
|
||||||
|
import { User, UsernameAvailabilityResult } from "../synapse/dataProvider";
|
||||||
|
|
||||||
const choices_medium = [
|
const choices_medium = [
|
||||||
{ id: "email", name: "resources.users.email" },
|
{ id: "email", name: "resources.users.email" },
|
||||||
@@ -125,8 +137,6 @@ const UserBulkActionButtons = () => {
|
|||||||
const [asManagedUserIsSelected, setAsManagedUserIsSelected] = useState(false);
|
const [asManagedUserIsSelected, setAsManagedUserIsSelected] = useState(false);
|
||||||
const selectedIds = record.selectedIds;
|
const selectedIds = record.selectedIds;
|
||||||
const ownUserId = localStorage.getItem("user_id");
|
const ownUserId = localStorage.getItem("user_id");
|
||||||
const notify = useNotify();
|
|
||||||
const translate = useTranslate();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setOwnUserIsSelected(selectedIds.includes(ownUserId));
|
setOwnUserIsSelected(selectedIds.includes(ownUserId));
|
||||||
@@ -156,7 +166,7 @@ export const UserList = (props: ListProps) => (
|
|||||||
actions={<UserListActions />}
|
actions={<UserListActions />}
|
||||||
pagination={<UserPagination />}
|
pagination={<UserPagination />}
|
||||||
>
|
>
|
||||||
<Datagrid
|
<DatagridConfigurable
|
||||||
rowClick={(id: Identifier, resource: string) => `/${resource}/${id}`}
|
rowClick={(id: Identifier, resource: string) => `/${resource}/${id}`}
|
||||||
bulkActionButtons={<UserBulkActionButtons />}
|
bulkActionButtons={<UserBulkActionButtons />}
|
||||||
>
|
>
|
||||||
@@ -169,7 +179,7 @@ export const UserList = (props: ListProps) => (
|
|||||||
<BooleanField source="locked" />
|
<BooleanField source="locked" />
|
||||||
<BooleanField source="erased" sortable={false} />
|
<BooleanField source="erased" sortable={false} />
|
||||||
<DateField source="creation_ts" label="resources.users.fields.creation_ts_ms" showTime options={DATE_FORMAT} />
|
<DateField source="creation_ts" label="resources.users.fields.creation_ts_ms" showTime options={DATE_FORMAT} />
|
||||||
</Datagrid>
|
</DatagridConfigurable>
|
||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -208,13 +218,70 @@ const UserEditActions = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UserCreate = (props: CreateProps) => (
|
export const UserCreate = (props: CreateProps) => {
|
||||||
<Create
|
const dataProvider = useDataProvider();
|
||||||
|
const translate = useTranslate();
|
||||||
|
const redirect = useRedirect();
|
||||||
|
const notify = useNotify();
|
||||||
|
const theme = useTheme();
|
||||||
|
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [userIsAvailable, setUserIsAvailable] = useState<boolean | undefined>();
|
||||||
|
const [userAvailabilityEl, setUserAvailabilityEl] = useState<React.ReactElement | false>(<Typography component="span"></Typography>);
|
||||||
|
const [formData, setFormData] = useState<Record<string, any>>({});
|
||||||
|
const [create] = useCreate();
|
||||||
|
|
||||||
|
const checkAvailability = async(event: React.FocusEvent<HTMLInputElement>) => {
|
||||||
|
const username = event.target.value;
|
||||||
|
const result: UsernameAvailabilityResult = await dataProvider.checkUsernameAvailability(username);
|
||||||
|
setUserIsAvailable(!!result?.available);
|
||||||
|
if (result?.available) {
|
||||||
|
setUserAvailabilityEl(<Typography component="span" variant="body2" sx={{ color: theme.palette.success.main }}>✔️ {translate("resources.users.helper.username_available")}</Typography>);
|
||||||
|
} else {
|
||||||
|
setUserAvailabilityEl(<Typography component="span" variant="body2" sx={{ color: theme.palette.warning.main }}>⚠️ {result?.error || "unknown error"}</Typography>);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const postSave = (data: Record<string, any>) => {
|
||||||
|
setFormData(data);
|
||||||
|
if (!userIsAvailable) {
|
||||||
|
setOpen(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
create("users", { data: data }, {
|
||||||
|
onSuccess: (resource: User) => {
|
||||||
|
notify("ra.notification.created", { messageArgs: { smart_count: 1 } });
|
||||||
|
redirect(() => { return `users/${resource.id}` });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirm = () => {
|
||||||
|
setOpen(false);
|
||||||
|
updateUser();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDialogClose = () => {
|
||||||
|
setOpen(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateUser = () => {
|
||||||
|
create("users", { data: formData }, {
|
||||||
|
onSuccess: (resource: User) => {
|
||||||
|
notify("ra.notification.updated", { messageArgs: { smart_count: 1 } });
|
||||||
|
redirect(() => { return `users/${resource.id}` });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return <Create
|
||||||
{...props}
|
{...props}
|
||||||
redirect={(resource: string | undefined, id: Identifier | undefined) => `${resource}/${id}`}
|
|
||||||
>
|
>
|
||||||
<SimpleForm>
|
<SimpleForm
|
||||||
<TextInput source="id" autoComplete="off" validate={validateUser} />
|
onSubmit={postSave}
|
||||||
|
>
|
||||||
|
<TextInput source="id" autoComplete="off" validate={validateUser} onBlur={checkAvailability} helperText={userAvailabilityEl}/>
|
||||||
<TextInput source="displayname" validate={maxLength(256)} />
|
<TextInput source="displayname" validate={maxLength(256)} />
|
||||||
<PasswordInput source="password" autoComplete="new-password" validate={maxLength(512)} />
|
<PasswordInput source="password" autoComplete="new-password" validate={maxLength(512)} />
|
||||||
<SelectInput source="user_type" choices={choices_type} translateChoice={false} resettable />
|
<SelectInput source="user_type" choices={choices_type} translateChoice={false} resettable />
|
||||||
@@ -232,16 +299,25 @@ export const UserCreate = (props: CreateProps) => (
|
|||||||
</SimpleFormIterator>
|
</SimpleFormIterator>
|
||||||
</ArrayInput>
|
</ArrayInput>
|
||||||
</SimpleForm>
|
</SimpleForm>
|
||||||
|
<Confirm
|
||||||
|
isOpen={open}
|
||||||
|
title="resources.users.action.overwrite_title"
|
||||||
|
content="resources.users.action.overwrite_content"
|
||||||
|
onConfirm={handleConfirm}
|
||||||
|
onClose={handleDialogClose}
|
||||||
|
confirm="resources.users.action.overwrite_confirm"
|
||||||
|
cancel="resources.users.action.overwrite_cancel"
|
||||||
|
/>
|
||||||
</Create>
|
</Create>
|
||||||
);
|
};
|
||||||
|
|
||||||
const UserTitle = () => {
|
const UserTitle = () => {
|
||||||
const record = useRecordContext();
|
const record = useRecordContext();
|
||||||
|
const translate = useTranslate();
|
||||||
if (!record) {
|
if (!record) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const translate = useTranslate();
|
|
||||||
let username = record ? (record.displayname ? `"${record.displayname}"` : `"${record.name}"`) : ""
|
let username = record ? (record.displayname ? `"${record.displayname}"` : `"${record.name}"`) : ""
|
||||||
if (isASManaged(record?.id)) {
|
if (isASManaged(record?.id)) {
|
||||||
username += " 🤖";
|
username += " 🤖";
|
||||||
@@ -300,12 +376,33 @@ const UserBooleanInput = props => {
|
|||||||
const UserPasswordInput = props => {
|
const UserPasswordInput = props => {
|
||||||
const record = useRecordContext();
|
const record = useRecordContext();
|
||||||
let asManagedUserIsSelected = false;
|
let asManagedUserIsSelected = false;
|
||||||
|
|
||||||
|
// Get form context to update field value
|
||||||
|
const form = useFormContext();
|
||||||
if (record) {
|
if (record) {
|
||||||
asManagedUserIsSelected = isASManaged(record.id);
|
asManagedUserIsSelected = isASManaged(record.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const generatePassword = () => {
|
||||||
|
const password = generateRandomPassword();
|
||||||
|
if (record) {
|
||||||
|
form.setValue("password", password, { shouldDirty: true });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PasswordInput {...props} helperText="resources.users.helper.modify_managed_user_error" disabled={asManagedUserIsSelected} />
|
<>
|
||||||
|
<PasswordInput {...props} helperText="resources.users.helper.modify_managed_user_error"
|
||||||
|
{...(asManagedUserIsSelected ? { disabled: true } : {})}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
label="Generate Password"
|
||||||
|
onClick={generatePassword}
|
||||||
|
sx={{ marginBottom: "10px" }}
|
||||||
|
disabled={asManagedUserIsSelected}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -313,7 +410,11 @@ export const UserEdit = (props: EditProps) => {
|
|||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Edit {...props} title={<UserTitle />} actions={<UserEditActions />} mutationMode="pessimistic">
|
<Edit {...props} title={<UserTitle />} actions={<UserEditActions />} mutationMode="pessimistic" queryOptions={{
|
||||||
|
meta: {
|
||||||
|
include: ["features"] // Tell your dataProvider to include features
|
||||||
|
}
|
||||||
|
}}>
|
||||||
<TabbedForm toolbar={<UserEditToolbar />}>
|
<TabbedForm toolbar={<UserEditToolbar />}>
|
||||||
<FormTab label={translate("resources.users.name", { smart_count: 1 })} icon={<PersonPinIcon />}>
|
<FormTab label={translate("resources.users.name", { smart_count: 1 })} icon={<PersonPinIcon />}>
|
||||||
<AvatarField source="avatar_src" sx={{ height: "120px", width: "120px" }} />
|
<AvatarField source="avatar_src" sx={{ height: "120px", width: "120px" }} />
|
||||||
@@ -447,6 +548,14 @@ export const UserEdit = (props: EditProps) => {
|
|||||||
</Datagrid>
|
</Datagrid>
|
||||||
</ReferenceManyField>
|
</ReferenceManyField>
|
||||||
</FormTab>
|
</FormTab>
|
||||||
|
|
||||||
|
<FormTab label="synapseadmin.users.tabs.experimental" icon={<ScienceIcon />} path="experimental">
|
||||||
|
<ExperimentalFeaturesList />
|
||||||
|
</FormTab>
|
||||||
|
|
||||||
|
<FormTab label="synapseadmin.users.tabs.limits" icon={<LockClockIcon />} path="limits">
|
||||||
|
<UserRateLimits />
|
||||||
|
</FormTab>
|
||||||
</TabbedForm>
|
</TabbedForm>
|
||||||
</Edit>
|
</Edit>
|
||||||
);
|
);
|
||||||
|
@@ -30,7 +30,7 @@ describe("authProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(ret).toEqual({redirectTo: "/"});
|
expect(ret).toEqual({redirectTo: "/"});
|
||||||
expect(fetch).toBeCalledWith("http://example.com/_matrix/client/r0/login", {
|
expect(fetch).toHaveBeenCalledWith("http://example.com/_matrix/client/v3/login", {
|
||||||
body: '{"device_id":null,"initial_device_display_name":"Synapse Admin","type":"m.login.password","identifier":{"type":"m.id.user","user":"@user:example.com"},"password":"secret"}',
|
body: '{"device_id":null,"initial_device_display_name":"Synapse Admin","type":"m.login.password","identifier":{"type":"m.id.user","user":"@user:example.com"},"password":"secret"}',
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
@@ -61,7 +61,7 @@ describe("authProvider", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(ret).toEqual({redirectTo: "/"});
|
expect(ret).toEqual({redirectTo: "/"});
|
||||||
expect(fetch).toHaveBeenCalledWith("https://example.com/_matrix/client/r0/login", {
|
expect(fetch).toHaveBeenCalledWith("https://example.com/_matrix/client/v3/login", {
|
||||||
body: '{"device_id":null,"initial_device_display_name":"Synapse Admin","type":"m.login.token","token":"login_token"}',
|
body: '{"device_id":null,"initial_device_display_name":"Synapse Admin","type":"m.login.token","token":"login_token"}',
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
@@ -83,7 +83,7 @@ describe("authProvider", () => {
|
|||||||
|
|
||||||
await authProvider.logout(null);
|
await authProvider.logout(null);
|
||||||
|
|
||||||
expect(fetch).toBeCalledWith("example.com/_matrix/client/r0/logout", {
|
expect(fetch).toHaveBeenCalledWith("example.com/_matrix/client/v3/logout", {
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
Authorization: "Bearer foo",
|
Authorization: "Bearer foo",
|
||||||
@@ -123,7 +123,9 @@ describe("authProvider", () => {
|
|||||||
|
|
||||||
describe("getPermissions", () => {
|
describe("getPermissions", () => {
|
||||||
it("should do nothing", async () => {
|
it("should do nothing", async () => {
|
||||||
await expect(authProvider.getPermissions(null)).resolves.toBeUndefined();
|
if (authProvider.getPermissions) {
|
||||||
|
await expect(authProvider.getPermissions(null)).resolves.toBeUndefined();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
import { AuthProvider, HttpError, Options, fetchUtils, useTranslate } from "react-admin";
|
import { AuthProvider, HttpError, Options, fetchUtils } from "react-admin";
|
||||||
|
|
||||||
import storage from "../storage";
|
import storage from "../storage";
|
||||||
import { MatrixError, displayError } from "../components/error";
|
import { MatrixError, displayError } from "../components/error";
|
||||||
|
import { fetchAuthenticatedMedia } from "../utils/fetchMedia";
|
||||||
|
import { ClearConfig } from "../components/config";
|
||||||
|
|
||||||
const authProvider: AuthProvider = {
|
const authProvider: AuthProvider = {
|
||||||
// called when the user attempts to log in
|
// called when the user attempts to log in
|
||||||
@@ -57,7 +59,7 @@ const authProvider: AuthProvider = {
|
|||||||
storage.setItem("base_url", base_url);
|
storage.setItem("base_url", base_url);
|
||||||
|
|
||||||
const decoded_base_url = window.decodeURIComponent(base_url);
|
const decoded_base_url = window.decodeURIComponent(base_url);
|
||||||
let login_api_url = decoded_base_url + (accessToken ? "/_matrix/client/v3/account/whoami" : "/_matrix/client/r0/login");
|
let login_api_url = decoded_base_url + (accessToken ? "/_matrix/client/v3/account/whoami" : "/_matrix/client/v3/login");
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
|
|
||||||
@@ -74,7 +76,7 @@ const authProvider: AuthProvider = {
|
|||||||
|
|
||||||
response = await fetchUtils.fetchJson(login_api_url, options);
|
response = await fetchUtils.fetchJson(login_api_url, options);
|
||||||
const json = response.json;
|
const json = response.json;
|
||||||
storage.setItem("home_server", accessToken ? base_url : json.home_server);
|
storage.setItem("home_server", accessToken ? json.user_id.split(":")[1] : json.home_server);
|
||||||
storage.setItem("user_id", json.user_id);
|
storage.setItem("user_id", json.user_id);
|
||||||
storage.setItem("access_token", accessToken ? accessToken : json.access_token);
|
storage.setItem("access_token", accessToken ? accessToken : json.access_token);
|
||||||
storage.setItem("device_id", json.device_id);
|
storage.setItem("device_id", json.device_id);
|
||||||
@@ -95,11 +97,48 @@ const authProvider: AuthProvider = {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getIdentity: async () => {
|
||||||
|
const access_token = storage.getItem("access_token");
|
||||||
|
const user_id = storage.getItem("user_id");
|
||||||
|
const base_url = storage.getItem("base_url");
|
||||||
|
|
||||||
|
if (typeof access_token !== "string" || typeof user_id !== "string" || typeof base_url !== "string") {
|
||||||
|
return Promise.reject();
|
||||||
|
}
|
||||||
|
|
||||||
|
const options: Options = {
|
||||||
|
headers: new Headers({
|
||||||
|
Accept: "application/json",
|
||||||
|
Authorization: `Bearer ${access_token}`,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
const whoami_api_url = base_url + `/_matrix/client/v3/profile/${user_id}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let avatar_url = "";
|
||||||
|
const response = await fetchUtils.fetchJson(whoami_api_url, options);
|
||||||
|
if (response.json.avatar_url) {
|
||||||
|
const mediaresp = await fetchAuthenticatedMedia(response.json.avatar_url, "thumbnail");
|
||||||
|
const blob = await mediaresp.blob();
|
||||||
|
avatar_url = URL.createObjectURL(blob);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve({
|
||||||
|
id: user_id,
|
||||||
|
fullName: response.json.displayname,
|
||||||
|
avatar: avatar_url,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log("Error getting identity", err);
|
||||||
|
return Promise.reject();
|
||||||
|
}
|
||||||
|
},
|
||||||
// called when the user clicks on the logout button
|
// called when the user clicks on the logout button
|
||||||
logout: async () => {
|
logout: async () => {
|
||||||
console.log("logout");
|
console.log("logout");
|
||||||
|
|
||||||
const logout_api_url = storage.getItem("base_url") + "/_matrix/client/r0/logout";
|
const logout_api_url = storage.getItem("base_url") + "/_matrix/client/v3/logout";
|
||||||
const access_token = storage.getItem("access_token");
|
const access_token = storage.getItem("access_token");
|
||||||
|
|
||||||
const options: Options = {
|
const options: Options = {
|
||||||
@@ -116,8 +155,7 @@ const authProvider: AuthProvider = {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Error logging out", err);
|
console.log("Error logging out", err);
|
||||||
} finally {
|
} finally {
|
||||||
storage.removeItem("access_token");
|
ClearConfig();
|
||||||
storage.removeItem("login_type");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -120,7 +120,8 @@ interface ExternalId {
|
|||||||
external_id: string;
|
external_id: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface User {
|
export interface User {
|
||||||
|
id?: string;
|
||||||
name: string;
|
name: string;
|
||||||
displayname?: string;
|
displayname?: string;
|
||||||
threepids: Threepid[];
|
threepids: Threepid[];
|
||||||
@@ -248,9 +249,30 @@ export interface UploadMediaResult {
|
|||||||
content_uri: string;
|
content_uri: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ExperimentalFeaturesModel {
|
||||||
|
features: {
|
||||||
|
[key: string]: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RateLimitsModel {
|
||||||
|
messages_per_second?: number;
|
||||||
|
burst_count?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UsernameAvailabilityResult {
|
||||||
|
available?: boolean;
|
||||||
|
error?: string;
|
||||||
|
errcode?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface SynapseDataProvider extends DataProvider {
|
export interface SynapseDataProvider extends DataProvider {
|
||||||
deleteMedia: (params: DeleteMediaParams) => Promise<DeleteMediaResult>;
|
deleteMedia: (params: DeleteMediaParams) => Promise<DeleteMediaResult>;
|
||||||
uploadMedia: (params: UploadMediaParams) => Promise<UploadMediaResult>;
|
uploadMedia: (params: UploadMediaParams) => Promise<UploadMediaResult>;
|
||||||
|
updateFeatures: (id: Identifier, features: ExperimentalFeaturesModel) => Promise<void>;
|
||||||
|
getRateLimits: (id: Identifier) => Promise<RateLimitsModel>;
|
||||||
|
setRateLimits: (id: Identifier, rateLimits: RateLimitsModel) => Promise<void>;
|
||||||
|
checkUsernameAvailability: (username: string) => Promise<UsernameAvailabilityResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const resourceMap = {
|
const resourceMap = {
|
||||||
@@ -575,13 +597,28 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
|
|
||||||
getMany: async (resource, params) => {
|
getMany: async (resource, params) => {
|
||||||
console.log("getMany " + resource);
|
console.log("getMany " + resource);
|
||||||
const homeserver = storage.getItem("base_url");
|
const base_url = storage.getItem("base_url");
|
||||||
if (!homeserver || !(resource in resourceMap)) throw Error("Homerserver not set");
|
const homeserver = storage.getItem("home_server");
|
||||||
|
if (!base_url || !(resource in resourceMap)) throw Error("base_url not set");
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
|
|
||||||
const endpoint_url = homeserver + res.path;
|
const endpoint_url = base_url + res.path;
|
||||||
const responses = await Promise.all(params.ids.map(id => jsonClient(`${endpoint_url}/${encodeURIComponent(id)}`)));
|
const responses = await Promise.all(params.ids.map(id => {
|
||||||
|
// edge case: when user is external / federated, homeserver will return error, as querying external users via
|
||||||
|
// /_synapse/admin/v2/users is not allowed.
|
||||||
|
// That leads to an issue when a user is referenced (e.g., in room state datagrid) - the user cell is just empty.
|
||||||
|
// To avoid that, we fake the response with one specific field (name) which is used in the datagrid.
|
||||||
|
if (homeserver && resource === "users") {
|
||||||
|
if (!(<string>id).endsWith(homeserver)) {
|
||||||
|
const json = {
|
||||||
|
name: id,
|
||||||
|
};
|
||||||
|
return Promise.resolve({ json });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jsonClient(`${endpoint_url}/${encodeURIComponent(id)}`);
|
||||||
|
}));
|
||||||
return {
|
return {
|
||||||
data: responses.map(({ json }) => res.map(json)),
|
data: responses.map(({ json }) => res.map(json)),
|
||||||
total: responses.length,
|
total: responses.length,
|
||||||
@@ -783,6 +820,53 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
});
|
});
|
||||||
return json as UploadMediaResult;
|
return json as UploadMediaResult;
|
||||||
},
|
},
|
||||||
|
getFeatures: async (id: Identifier) => {
|
||||||
|
const base_url = storage.getItem("base_url");
|
||||||
|
const endpoint_url = `${base_url}/_synapse/admin/v1/experimental_features/${encodeURIComponent(returnMXID(id))}`;
|
||||||
|
const { json } = await jsonClient(endpoint_url);
|
||||||
|
return json.features as ExperimentalFeaturesModel;
|
||||||
|
},
|
||||||
|
updateFeatures: async (id: Identifier, features: ExperimentalFeaturesModel) => {
|
||||||
|
const base_url = storage.getItem("base_url");
|
||||||
|
const endpoint_url = `${base_url}/_synapse/admin/v1/experimental_features/${encodeURIComponent(returnMXID(id))}`;
|
||||||
|
await jsonClient(endpoint_url, { method: "PUT", body: JSON.stringify({ features }) });
|
||||||
|
},
|
||||||
|
getRateLimits: async (id: Identifier) => {
|
||||||
|
const base_url = storage.getItem("base_url");
|
||||||
|
const endpoint_url = `${base_url}/_synapse/admin/v1/users/${encodeURIComponent(returnMXID(id))}/override_ratelimit`;
|
||||||
|
const { json } = await jsonClient(endpoint_url);
|
||||||
|
return json as RateLimitsModel;
|
||||||
|
},
|
||||||
|
setRateLimits: async (id: Identifier, rateLimits: RateLimitsModel) => {
|
||||||
|
const filtered = Object.entries(rateLimits).
|
||||||
|
filter(([key, value]) => value !== null && value !== undefined).
|
||||||
|
reduce((obj, [key, value]) => {
|
||||||
|
obj[key] = value;
|
||||||
|
return obj;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
const base_url = storage.getItem("base_url");
|
||||||
|
const endpoint_url = `${base_url}/_synapse/admin/v1/users/${encodeURIComponent(returnMXID(id))}/override_ratelimit`;
|
||||||
|
if (Object.keys(filtered).length === 0) {
|
||||||
|
await jsonClient(endpoint_url, { method: "DELETE" });
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await jsonClient(endpoint_url, { method: "POST", body: JSON.stringify(filtered) });
|
||||||
|
},
|
||||||
|
checkUsernameAvailability: async (username: string) => {
|
||||||
|
const base_url = storage.getItem("base_url");
|
||||||
|
const endpoint_url = `${base_url}/_synapse/admin/v1/username_available?username=${encodeURIComponent(username)}`;
|
||||||
|
try {
|
||||||
|
const { json } = await jsonClient(endpoint_url);
|
||||||
|
return json as UsernameAvailabilityResult;
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof HttpError) {
|
||||||
|
return { available: false, error: error.body.error, errcode: error.body.errcode } as UsernameAvailabilityResult;
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const dataProvider = withLifecycleCallbacks(baseDataProvider, [
|
const dataProvider = withLifecycleCallbacks(baseDataProvider, [
|
||||||
@@ -791,6 +875,12 @@ const dataProvider = withLifecycleCallbacks(baseDataProvider, [
|
|||||||
beforeUpdate: async (params: UpdateParams<any>, dataProvider: DataProvider) => {
|
beforeUpdate: async (params: UpdateParams<any>, dataProvider: DataProvider) => {
|
||||||
const avatarFile = params.data.avatar_file?.rawFile;
|
const avatarFile = params.data.avatar_file?.rawFile;
|
||||||
const avatarErase = params.data.avatar_erase;
|
const avatarErase = params.data.avatar_erase;
|
||||||
|
const rates = params.data.rates;
|
||||||
|
|
||||||
|
if (rates) {
|
||||||
|
await dataProvider.setRateLimits(params.id, rates);
|
||||||
|
delete params.data.rates;
|
||||||
|
}
|
||||||
|
|
||||||
if (avatarErase) {
|
if (avatarErase) {
|
||||||
params.data.avatar_url = "";
|
params.data.avatar_url = "";
|
||||||
|
@@ -91,8 +91,8 @@ export function returnMXID(input: string | Identifier): string {
|
|||||||
* Generate a random user password
|
* Generate a random user password
|
||||||
* @returns a new random password as string
|
* @returns a new random password as string
|
||||||
*/
|
*/
|
||||||
export function generateRandomPassword(length = 20): string {
|
export function generateRandomPassword(length = 64): string {
|
||||||
const characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~!@-#$";
|
const characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz~`!@#$%^&*()_-+={[}]|:;'.?/<>,";
|
||||||
return Array.from(crypto.getRandomValues(new Uint32Array(length)))
|
return Array.from(crypto.getRandomValues(new Uint32Array(length)))
|
||||||
.map(x => characters[x % characters.length])
|
.map(x => characters[x % characters.length])
|
||||||
.join("");
|
.join("");
|
||||||
|
@@ -5,13 +5,41 @@ import { defineConfig } from "vite";
|
|||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: "./",
|
base: "./",
|
||||||
|
build: {
|
||||||
|
target: "esnext",
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
react(),
|
react(),
|
||||||
vitePluginVersionMark({
|
vitePluginVersionMark({
|
||||||
command: "git describe --tags || git rev-parse --short HEAD",
|
name: "Synapse Admin",
|
||||||
ifMeta: true,
|
command: 'git describe --tags || git rev-parse --short HEAD || echo "${SYNAPSE_ADMIN_VERSION:-unknown}"',
|
||||||
ifLog: true,
|
ifMeta: false,
|
||||||
|
ifLog: false,
|
||||||
ifGlobal: true,
|
ifGlobal: true,
|
||||||
|
outputFile: (version) => ({
|
||||||
|
path: "manifest.json",
|
||||||
|
content: JSON.stringify({
|
||||||
|
name: "Synapse Admin",
|
||||||
|
version: version,
|
||||||
|
description: "Synapse Admin is an admin console for synapse Matrix homeserver with additional features.",
|
||||||
|
categories: ["productivity", "utilities"],
|
||||||
|
orientation: "landscape",
|
||||||
|
icons: [{
|
||||||
|
src: "favicon.ico",
|
||||||
|
sizes: "32x32",
|
||||||
|
type: "image/x-icon"
|
||||||
|
},{
|
||||||
|
src: "images/logo.webp",
|
||||||
|
sizes: "512x512",
|
||||||
|
type: "image/webp",
|
||||||
|
purpose: "any maskable"
|
||||||
|
}],
|
||||||
|
start_url: ".",
|
||||||
|
display: "standalone",
|
||||||
|
theme_color: "#000000",
|
||||||
|
background_color: "#ffffff"
|
||||||
|
}),
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user