mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-22 06:21:28 +00:00
Show Synapse server version on login page
Change-Id: Id9b0d2adf83590524069d308f4fe9e5d14147295
This commit is contained in:
parent
300e22a537
commit
0ada5287d7
2 changed files with 34 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
import React, { useState } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
fetchUtils,
|
||||
FormDataConsumer,
|
||||
|
@ -65,6 +65,12 @@ const useStyles = makeStyles(theme => ({
|
|||
actions: {
|
||||
padding: "0 1em 1em 1em",
|
||||
},
|
||||
serverVersion: {
|
||||
color: "#9e9e9e",
|
||||
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
||||
marginBottom: "1em",
|
||||
marginLeft: "0.5em",
|
||||
},
|
||||
}));
|
||||
|
||||
const LoginPage = ({ theme }) => {
|
||||
|
@ -138,6 +144,7 @@ const LoginPage = ({ theme }) => {
|
|||
|
||||
const UserData = ({ formData }) => {
|
||||
const form = useForm();
|
||||
const [serverVersion, setServerVersion] = useState("");
|
||||
|
||||
const handleUsernameChange = _ => {
|
||||
if (formData.base_url) return;
|
||||
|
@ -158,6 +165,30 @@ const LoginPage = ({ theme }) => {
|
|||
}
|
||||
};
|
||||
|
||||
useEffect(
|
||||
_ => {
|
||||
if (
|
||||
!formData.base_url ||
|
||||
!formData.base_url.match(/^(http|https):\/\/[a-zA-Z0-9\-.]+$/)
|
||||
)
|
||||
return;
|
||||
const versionUrl = `${formData.base_url}/_synapse/admin/v1/server_version`;
|
||||
fetchUtils
|
||||
.fetchJson(versionUrl, { method: "GET" })
|
||||
.then(({ json }) => {
|
||||
setServerVersion(
|
||||
`${translate("synapseadmin.auth.server_version")} ${
|
||||
json["server_version"]
|
||||
}`
|
||||
);
|
||||
})
|
||||
.catch(_ => {
|
||||
setServerVersion("");
|
||||
});
|
||||
},
|
||||
[formData.base_url]
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={classes.input}>
|
||||
|
@ -190,6 +221,7 @@ const LoginPage = ({ theme }) => {
|
|||
fullWidth
|
||||
/>
|
||||
</div>
|
||||
<div className={classes.serverVersion}>{serverVersion}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@ export default {
|
|||
auth: {
|
||||
base_url: "Heimserver URL",
|
||||
welcome: "Willkommen bei Synapse-admin",
|
||||
server_version: "Synapse Version",
|
||||
username_error: "Bitte vollständigen Nutzernamen angeben: '@user:domain'",
|
||||
protocol_error: "Die URL muss mit 'http://' oder 'https://' beginnen",
|
||||
url_error: "Keine gültige Matrix Server URL",
|
||||
|
|
Loading…
Reference in a new issue