mirror of
				https://github.com/UA-Fediland/synapse-admin.git
				synced 2025-10-31 03:28:28 +00:00 
			
		
		
		
	Add a new tab to rooms with state events (#108)
Co-authored-by: Michael Albert <37796947+awesome-michael@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									2ab4343970
								
							
						
					
					
						commit
						2cdd41b615
					
				
					 6 changed files with 76 additions and 4 deletions
				
			
		|  | @ -4,7 +4,7 @@ | ||||||
| 
 | 
 | ||||||
| This project is built using [react-admin](https://marmelab.com/react-admin/). | This project is built using [react-admin](https://marmelab.com/react-admin/). | ||||||
| 
 | 
 | ||||||
| It needs at least Synapse v1.23.0 for all functions to work as expected! | It needs at least Synapse v1.27.0 for all functions to work as expected! | ||||||
| 
 | 
 | ||||||
| You get your server version with the request `/_synapse/admin/v1/server_version`. | You get your server version with the request `/_synapse/admin/v1/server_version`. | ||||||
| See also [Synapse version API](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/version_api.rst). | See also [Synapse version API](https://github.com/matrix-org/synapse/blob/develop/docs/admin_api/version_api.rst). | ||||||
|  |  | ||||||
|  | @ -71,6 +71,7 @@ const App = () => ( | ||||||
|     <Resource name="joined_rooms" /> |     <Resource name="joined_rooms" /> | ||||||
|     <Resource name="pushers" /> |     <Resource name="pushers" /> | ||||||
|     <Resource name="servernotices" /> |     <Resource name="servernotices" /> | ||||||
|  |     <Resource name="room_state" /> | ||||||
|   </Admin> |   </Admin> | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ import { connect } from "react-redux"; | ||||||
| import { | import { | ||||||
|   BooleanField, |   BooleanField, | ||||||
|   BulkDeleteButton, |   BulkDeleteButton, | ||||||
|  |   DateField, | ||||||
|   Datagrid, |   Datagrid, | ||||||
|   DeleteButton, |   DeleteButton, | ||||||
|   Filter, |   Filter, | ||||||
|  | @ -27,6 +28,7 @@ import PageviewIcon from "@material-ui/icons/Pageview"; | ||||||
| import UserIcon from "@material-ui/icons/Group"; | import UserIcon from "@material-ui/icons/Group"; | ||||||
| import ViewListIcon from "@material-ui/icons/ViewList"; | import ViewListIcon from "@material-ui/icons/ViewList"; | ||||||
| import VisibilityIcon from "@material-ui/icons/Visibility"; | import VisibilityIcon from "@material-ui/icons/Visibility"; | ||||||
|  | import EventIcon from "@material-ui/icons/Event"; | ||||||
| import { | import { | ||||||
|   RoomDirectoryBulkDeleteButton, |   RoomDirectoryBulkDeleteButton, | ||||||
|   RoomDirectoryBulkSaveButton, |   RoomDirectoryBulkSaveButton, | ||||||
|  | @ -113,7 +115,9 @@ export const RoomShow = props => { | ||||||
|           <TextField source="room_id" /> |           <TextField source="room_id" /> | ||||||
|           <TextField source="name" /> |           <TextField source="name" /> | ||||||
|           <TextField source="canonical_alias" /> |           <TextField source="canonical_alias" /> | ||||||
|           <TextField source="creator" /> |           <ReferenceField source="creator" reference="users"> | ||||||
|  |             <TextField source="id" /> | ||||||
|  |           </ReferenceField> | ||||||
|         </Tab> |         </Tab> | ||||||
| 
 | 
 | ||||||
|         <Tab |         <Tab | ||||||
|  | @ -214,6 +218,42 @@ export const RoomShow = props => { | ||||||
|             ]} |             ]} | ||||||
|           /> |           /> | ||||||
|         </Tab> |         </Tab> | ||||||
|  |         <Tab | ||||||
|  |           label={translate("resources.room_state.name", { smart_count: 2 })} | ||||||
|  |           icon={<EventIcon />} | ||||||
|  |           path="state" | ||||||
|  |         > | ||||||
|  |           <ReferenceManyField | ||||||
|  |             reference="room_state" | ||||||
|  |             target="room_id" | ||||||
|  |             addLabel={false} | ||||||
|  |           > | ||||||
|  |             <Datagrid style={{ width: "100%" }}> | ||||||
|  |               <TextField source="type" sortable={false} /> | ||||||
|  |               <DateField | ||||||
|  |                 source="origin_server_ts" | ||||||
|  |                 showTime | ||||||
|  |                 options={{ | ||||||
|  |                   year: "numeric", | ||||||
|  |                   month: "2-digit", | ||||||
|  |                   day: "2-digit", | ||||||
|  |                   hour: "2-digit", | ||||||
|  |                   minute: "2-digit", | ||||||
|  |                   second: "2-digit", | ||||||
|  |                 }} | ||||||
|  |                 sortable={false} | ||||||
|  |               /> | ||||||
|  |               <TextField source="content" sortable={false} /> | ||||||
|  |               <ReferenceField | ||||||
|  |                 source="sender" | ||||||
|  |                 reference="users" | ||||||
|  |                 sortable={false} | ||||||
|  |               > | ||||||
|  |                 <TextField source="id" /> | ||||||
|  |               </ReferenceField> | ||||||
|  |             </Datagrid> | ||||||
|  |           </ReferenceManyField> | ||||||
|  |         </Tab> | ||||||
|       </TabbedShowLayout> |       </TabbedShowLayout> | ||||||
|     </Show> |     </Show> | ||||||
|   ); |   ); | ||||||
|  |  | ||||||
|  | @ -139,7 +139,7 @@ export default { | ||||||
|         joined_members: "Mitglieder", |         joined_members: "Mitglieder", | ||||||
|         joined_local_members: "Lokale Mitglieder", |         joined_local_members: "Lokale Mitglieder", | ||||||
|         joined_local_devices: "Lokale Endgeräte", |         joined_local_devices: "Lokale Endgeräte", | ||||||
|         state_events: "Ereignisse", |         state_events: "Zustandsereignisse / Komplexität", | ||||||
|         version: "Version", |         version: "Version", | ||||||
|         is_encrypted: "Verschlüsselt", |         is_encrypted: "Verschlüsselt", | ||||||
|         encryption: "Verschlüsselungs-Algorithmus", |         encryption: "Verschlüsselungs-Algorithmus", | ||||||
|  | @ -295,6 +295,15 @@ export default { | ||||||
|         media_length: "Größe der Dateien", |         media_length: "Größe der Dateien", | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|  |     room_state: { | ||||||
|  |       name: "Zustandsereignisse", | ||||||
|  |       fields: { | ||||||
|  |         type: "Typ", | ||||||
|  |         content: "Inhalt", | ||||||
|  |         origin_server_ts: "Sendezeit", | ||||||
|  |         sender: "Absender", | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|     room_directory: { |     room_directory: { | ||||||
|       name: "Raumverzeichnis", |       name: "Raumverzeichnis", | ||||||
|       fields: { |       fields: { | ||||||
|  |  | ||||||
|  | @ -137,7 +137,7 @@ export default { | ||||||
|         joined_members: "Members", |         joined_members: "Members", | ||||||
|         joined_local_members: "Local members", |         joined_local_members: "Local members", | ||||||
|         joined_local_devices: "Local devices", |         joined_local_devices: "Local devices", | ||||||
|         state_events: "State events", |         state_events: "State events / Complexity", | ||||||
|         version: "Version", |         version: "Version", | ||||||
|         is_encrypted: "Encrypted", |         is_encrypted: "Encrypted", | ||||||
|         encryption: "Encryption", |         encryption: "Encryption", | ||||||
|  | @ -291,6 +291,15 @@ export default { | ||||||
|         media_length: "Media length", |         media_length: "Media length", | ||||||
|       }, |       }, | ||||||
|     }, |     }, | ||||||
|  |     room_state: { | ||||||
|  |       name: "State events", | ||||||
|  |       fields: { | ||||||
|  |         type: "Type", | ||||||
|  |         content: "Content", | ||||||
|  |         origin_server_ts: "time of send", | ||||||
|  |         sender: "Sender", | ||||||
|  |       }, | ||||||
|  |     }, | ||||||
|     room_directory: { |     room_directory: { | ||||||
|       name: "Room directory", |       name: "Room directory", | ||||||
|       fields: { |       fields: { | ||||||
|  |  | ||||||
|  | @ -117,6 +117,19 @@ const resourceMap = { | ||||||
|       return json.total; |       return json.total; | ||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
|  |   room_state: { | ||||||
|  |     map: rs => ({ | ||||||
|  |       ...rs, | ||||||
|  |       id: rs.event_id, | ||||||
|  |     }), | ||||||
|  |     reference: id => ({ | ||||||
|  |       endpoint: `/_synapse/admin/v1/rooms/${id}/state`, | ||||||
|  |     }), | ||||||
|  |     data: "state", | ||||||
|  |     total: json => { | ||||||
|  |       return json.state.length; | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|   pushers: { |   pushers: { | ||||||
|     map: p => ({ |     map: p => ({ | ||||||
|       ...p, |       ...p, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue