Compare commits
1 Commits
0.2.0
..
csv_import
| Author | SHA1 | Date | |
|---|---|---|---|
| a2807fe281 |
+2
-1
@@ -25,7 +25,8 @@
|
|||||||
"react": "^16.13.1",
|
"react": "^16.13.1",
|
||||||
"react-admin": "^3.4.0",
|
"react-admin": "^3.4.0",
|
||||||
"react-dom": "^16.13.1",
|
"react-dom": "^16.13.1",
|
||||||
"react-scripts": "^3.4.1"
|
"react-scripts": "^3.4.1",
|
||||||
|
"react-admin-import-csv": "^0.2.5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
|||||||
+28
-29
@@ -1,4 +1,4 @@
|
|||||||
import React, { Fragment } from "react";
|
import React from "react";
|
||||||
import PersonPinIcon from "@material-ui/icons/PersonPin";
|
import PersonPinIcon from "@material-ui/icons/PersonPin";
|
||||||
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
|
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
|
||||||
import {
|
import {
|
||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
Edit,
|
Edit,
|
||||||
List,
|
List,
|
||||||
Filter,
|
Filter,
|
||||||
Toolbar,
|
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
SimpleFormIterator,
|
SimpleFormIterator,
|
||||||
TabbedForm,
|
TabbedForm,
|
||||||
@@ -22,14 +21,14 @@ import {
|
|||||||
TextField,
|
TextField,
|
||||||
TextInput,
|
TextInput,
|
||||||
ReferenceField,
|
ReferenceField,
|
||||||
|
Toolbar,
|
||||||
|
TopToolbar,
|
||||||
SelectInput,
|
SelectInput,
|
||||||
BulkDeleteButton,
|
|
||||||
DeleteButton,
|
|
||||||
SaveButton,
|
|
||||||
regex,
|
regex,
|
||||||
useTranslate,
|
|
||||||
Pagination,
|
Pagination,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
|
import { ImportButton } from "react-admin-import-csv";
|
||||||
|
import { CreateButton, ExportButton } from "ra-ui-materialui";
|
||||||
|
|
||||||
const UserPagination = props => (
|
const UserPagination = props => (
|
||||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||||
@@ -46,16 +45,28 @@ const UserFilter = props => (
|
|||||||
</Filter>
|
</Filter>
|
||||||
);
|
);
|
||||||
|
|
||||||
const UserBulkActionButtons = props => {
|
const ListActions = props => {
|
||||||
const translate = useTranslate();
|
const {
|
||||||
|
className,
|
||||||
|
basePath,
|
||||||
|
total,
|
||||||
|
resource,
|
||||||
|
currentSort,
|
||||||
|
filterValues,
|
||||||
|
exporter
|
||||||
|
} = props;
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<TopToolbar className={className}>
|
||||||
<BulkDeleteButton
|
<CreateButton basePath={basePath} />
|
||||||
{...props}
|
<ImportButton {...props} />
|
||||||
label="resources.users.action.erase"
|
<ExportButton
|
||||||
title={translate("resources.users.helper.erase")}
|
disabled={total === 0}
|
||||||
|
resource={resource}
|
||||||
|
sort={currentSort}
|
||||||
|
filter={filterValues}
|
||||||
|
exporter={exporter}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</TopToolbar>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,8 +75,9 @@ export const UserList = props => (
|
|||||||
{...props}
|
{...props}
|
||||||
filters={<UserFilter />}
|
filters={<UserFilter />}
|
||||||
filterDefaultValues={{ guests: true, deactivated: false }}
|
filterDefaultValues={{ guests: true, deactivated: false }}
|
||||||
bulkActionButtons={<UserBulkActionButtons />}
|
bulkActionButtons={false}
|
||||||
pagination={<UserPagination />}
|
pagination={<UserPagination />}
|
||||||
|
actions={<ListActions />}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick="edit">
|
<Datagrid rowClick="edit">
|
||||||
<ReferenceField
|
<ReferenceField
|
||||||
@@ -99,19 +111,6 @@ const validateUser = regex(
|
|||||||
"synapseadmin.users.invalid_user_id"
|
"synapseadmin.users.invalid_user_id"
|
||||||
);
|
);
|
||||||
|
|
||||||
const UserEditToolbar = props => {
|
|
||||||
const translate = useTranslate();
|
|
||||||
return (
|
|
||||||
<Toolbar {...props}>
|
|
||||||
<SaveButton submitOnEnter={true} />
|
|
||||||
<DeleteButton
|
|
||||||
label="resources.users.action.erase"
|
|
||||||
title={translate("resources.users.helper.erase")}
|
|
||||||
/>
|
|
||||||
</Toolbar>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const UserCreate = props => (
|
export const UserCreate = props => (
|
||||||
<Create {...props}>
|
<Create {...props}>
|
||||||
<SimpleForm>
|
<SimpleForm>
|
||||||
@@ -137,7 +136,7 @@ export const UserCreate = props => (
|
|||||||
|
|
||||||
export const UserEdit = props => (
|
export const UserEdit = props => (
|
||||||
<Edit {...props}>
|
<Edit {...props}>
|
||||||
<TabbedForm toolbar={<UserEditToolbar />}>
|
<TabbedForm>
|
||||||
<FormTab label="resources.users.name" icon={<PersonPinIcon />}>
|
<FormTab label="resources.users.name" icon={<PersonPinIcon />}>
|
||||||
<TextInput source="id" disabled />
|
<TextInput source="id" disabled />
|
||||||
<TextInput source="displayname" />
|
<TextInput source="displayname" />
|
||||||
|
|||||||
@@ -37,10 +37,6 @@ export default {
|
|||||||
},
|
},
|
||||||
helper: {
|
helper: {
|
||||||
deactivate: "Deaktivierte Nutzer können nicht wieder aktiviert werden.",
|
deactivate: "Deaktivierte Nutzer können nicht wieder aktiviert werden.",
|
||||||
erase: "DSGVO konformes Löschen der Benutzerdaten",
|
|
||||||
},
|
|
||||||
action: {
|
|
||||||
erase: "Lösche Benutzerdaten",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
|
|||||||
@@ -37,10 +37,6 @@ export default {
|
|||||||
},
|
},
|
||||||
helper: {
|
helper: {
|
||||||
deactivate: "Deactivated users cannot be reactivated",
|
deactivate: "Deactivated users cannot be reactivated",
|
||||||
erase: "Mark the user as GDPR-erased",
|
|
||||||
},
|
|
||||||
action: {
|
|
||||||
erase: "Erase user data",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ const resourceMap = {
|
|||||||
? parseInt(json.next_token, 10) + perPage
|
? parseInt(json.next_token, 10) + perPage
|
||||||
: from + json.users.length;
|
: from + json.users.length;
|
||||||
},
|
},
|
||||||
delete: id => ({
|
|
||||||
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
|
||||||
body: { erase: true },
|
|
||||||
method: "POST",
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
path: "/_synapse/admin/v1/rooms",
|
path: "/_synapse/admin/v1/rooms",
|
||||||
@@ -207,24 +202,12 @@ const dataProvider = {
|
|||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
|
|
||||||
if ("delete" in res) {
|
|
||||||
const del = res["delete"](params.id);
|
|
||||||
const homeserver_url = homeserver + del.endpoint;
|
|
||||||
return jsonClient(homeserver_url, {
|
|
||||||
method: del.method,
|
|
||||||
body: JSON.stringify(del.body),
|
|
||||||
}).then(({ json }) => ({
|
|
||||||
data: json,
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
const homeserver_url = homeserver + res.path;
|
const homeserver_url = homeserver + res.path;
|
||||||
return jsonClient(`${homeserver_url}/${params.id}`, {
|
return jsonClient(`${homeserver_url}/${params.id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
body: JSON.stringify(params.data, filterNullValues),
|
|
||||||
}).then(({ json }) => ({
|
}).then(({ json }) => ({
|
||||||
data: json,
|
data: json,
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteMany: (resource, params) => {
|
deleteMany: (resource, params) => {
|
||||||
@@ -234,32 +217,17 @@ const dataProvider = {
|
|||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
|
|
||||||
if ("delete" in res) {
|
|
||||||
return Promise.all(
|
|
||||||
params.ids.map(id => {
|
|
||||||
const del = res["delete"](id);
|
|
||||||
const homeserver_url = homeserver + del.endpoint;
|
|
||||||
return jsonClient(homeserver_url, {
|
|
||||||
method: del.method,
|
|
||||||
body: JSON.stringify(del.body),
|
|
||||||
});
|
|
||||||
})
|
|
||||||
).then(responses => ({
|
|
||||||
data: responses.map(({ json }) => json),
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
const homeserver_url = homeserver + res.path;
|
const homeserver_url = homeserver + res.path;
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
params.ids.map(id =>
|
params.ids.map(id =>
|
||||||
jsonClient(`${homeserver_url}/${id}`, {
|
jsonClient(`${homeserver_url}/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
body: JSON.stringify(params.data, filterNullValues),
|
body: JSON.stringify(params.data, filterNullValues),
|
||||||
})
|
}).then(responses => ({
|
||||||
)
|
|
||||||
).then(responses => ({
|
|
||||||
data: responses.map(({ json }) => json),
|
data: responses.map(({ json }) => json),
|
||||||
}));
|
}))
|
||||||
}
|
)
|
||||||
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user