diff --git a/package.json b/package.json index 7d754fe..002f90d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "synapse-admin", - "version": "0.1.0", + "version": "0.2.1", "description": "Admin GUI for the Matrix.org server Synapse", "author": "Awesome Technologies Innovationslabor GmbH", "license": "Apache-2.0", @@ -29,8 +29,8 @@ "react-scripts": "^3.4.1" }, "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", + "start": "REACT_APP_VERSION=$(git describe --tags) react-scripts start", + "build": "REACT_APP_VERSION=$(git describe --tags) react-scripts build", "fix:other": "yarn prettier --write", "fix:code": "yarn test:lint --fix", "fix": "yarn fix:code && yarn fix:other", diff --git a/public/index.html b/public/index.html index 4209361..2b90907 100644 --- a/public/index.html +++ b/public/index.html @@ -38,5 +38,12 @@ To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. --> + - + \ No newline at end of file diff --git a/src/components/LoginPage.js b/src/components/LoginPage.js index 6834625..3058b45 100644 --- a/src/components/LoginPage.js +++ b/src/components/LoginPage.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { fetchUtils, FormDataConsumer, @@ -29,7 +29,7 @@ const useStyles = makeStyles(theme => ({ main: { display: "flex", flexDirection: "column", - minHeight: "100vh", + minHeight: "calc(100vh - 1em)", alignItems: "center", justifyContent: "flex-start", background: "url(./images/floating-cogs.svg)", @@ -40,6 +40,7 @@ const useStyles = makeStyles(theme => ({ card: { minWidth: "30em", marginTop: "6em", + marginBottom: "6em", }, avatar: { margin: "1em", @@ -64,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 }) => { @@ -137,6 +144,7 @@ const LoginPage = ({ theme }) => { const UserData = ({ formData }) => { const form = useForm(); + const [serverVersion, setServerVersion] = useState(""); const handleUsernameChange = _ => { if (formData.base_url) return; @@ -157,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 (
@@ -189,6 +221,7 @@ const LoginPage = ({ theme }) => { fullWidth />
+
{serverVersion}
); }; diff --git a/src/components/rooms.js b/src/components/rooms.js index cb289ef..6a37fee 100644 --- a/src/components/rooms.js +++ b/src/components/rooms.js @@ -1,12 +1,18 @@ import React, { Fragment } from "react"; +import React from "react"; import { Datagrid, List, TextField, Pagination, BulkDeleteButton, + BooleanField, useTranslate, } from "react-admin"; +import get from "lodash/get"; +import { Tooltip, Typography } from "@material-ui/core"; +import HttpsIcon from "@material-ui/icons/Https"; +import NoEncryptionIcon from "@material-ui/icons/NoEncryption"; const RoomPagination = props => ( @@ -25,17 +31,54 @@ const RoomBulkActionButtons = props => { ); }; +const EncryptionField = ({ source, record = {}, emptyText }) => { + const translate = useTranslate(); + const value = get(record, source); + let ariaLabel = value === false ? "ra.boolean.false" : "ra.boolean.true"; + + if (value === false || value === true) { + return ( + + + {value === true ? ( + + ) : ( + + )} + + + ); + } + + return ( + + {emptyText} + + ); +}; + export const RoomList = props => ( } bulkActionButtons={} + sort={{ field: "name", order: "ASC" }} > - + } + /> + + + + + + ); diff --git a/src/components/users.js b/src/components/users.js index 16167a0..ff21436 100644 --- a/src/components/users.js +++ b/src/components/users.js @@ -1,5 +1,6 @@ import React, { Fragment } from "react"; import PersonPinIcon from "@material-ui/icons/PersonPin"; +import ContactMailIcon from "@material-ui/icons/ContactMail"; import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent"; import { ArrayInput, @@ -78,7 +79,7 @@ export const UserList = props => ( > - + {/* Hack since the users endpoint does not give displaynames in the list*/} ( source="deactivated" helperText="resources.users.helper.deactivate" /> + + + + } + path="threepid" + > ( } + path="connections" > - + { @@ -48,6 +50,9 @@ const resourceMap = { id: r.room_id, alias: r.canonical_alias, members: r.joined_members, + is_encrypted: !!r.encryption, + federatable: !!r.federatable, + public: !!r.public, }), data: "rooms", total: json => { @@ -91,11 +96,20 @@ function filterNullValues(key, value) { return value; } +function getSearchOrder(order) { + if (order === "DESC") { + return "b"; + } else { + return "f"; + } +} + const dataProvider = { getList: (resource, params) => { console.log("getList " + resource); const { user_id, guests, deactivated } = params.filter; const { page, perPage } = params.pagination; + const { field, order } = params.sort; const from = (page - 1) * perPage; const query = { from: from, @@ -103,6 +117,8 @@ const dataProvider = { user_id: user_id, guests: guests, deactivated: deactivated, + order_by: field, + dir: getSearchOrder(order), }; const homeserver = localStorage.getItem("base_url"); if (!homeserver || !(resource in resourceMap)) return Promise.reject(); diff --git a/yarn.lock b/yarn.lock index c5be95c..72f4311 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11444,9 +11444,9 @@ websocket-driver@>=0.5.1: websocket-extensions ">=0.1.1" websocket-extensions@>=0.1.1: - version "0.1.3" - resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29" - integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg== + version "0.1.4" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" + integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3, whatwg-encoding@^1.0.5: version "1.0.5"