
* Fix AvatarField to work with authenticated media * Fix ViewMediaButton to work for user's media tab and reported events * remove console.log * cleanup AvatarField * use correct thumbnail size * fix AvatarField.test * ignore postgres data for watchman * fix new avatar preview * watchman should ignore testdata completely, instead of specific subdirs * update README * change user's media icon in sidebar - use the same icon as the media tab * Add preview for user media files if mimeType is image/* * Add new line in user media Dialog
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import PermMediaIcon from "@mui/icons-material/PermMedia";
|
|
import {
|
|
Datagrid,
|
|
ExportButton,
|
|
List,
|
|
ListProps,
|
|
NumberField,
|
|
Pagination,
|
|
ResourceProps,
|
|
SearchInput,
|
|
TextField,
|
|
TopToolbar,
|
|
useListContext,
|
|
} from "react-admin";
|
|
|
|
import { DeleteMediaButton } from "../components/media";
|
|
|
|
const ListActions = () => {
|
|
const { isLoading, total } = useListContext();
|
|
return (
|
|
<TopToolbar>
|
|
<DeleteMediaButton />
|
|
<ExportButton disabled={isLoading || total === 0} />
|
|
</TopToolbar>
|
|
);
|
|
};
|
|
|
|
const UserMediaStatsPagination = () => <Pagination rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />;
|
|
|
|
const userMediaStatsFilters = [<SearchInput source="search_term" alwaysOn />];
|
|
|
|
export const UserMediaStatsList = (props: ListProps) => (
|
|
<List
|
|
{...props}
|
|
actions={<ListActions />}
|
|
filters={userMediaStatsFilters}
|
|
pagination={<UserMediaStatsPagination />}
|
|
sort={{ field: "media_length", order: "DESC" }}
|
|
>
|
|
<Datagrid rowClick={id => "/users/" + id + "/media"} bulkActionButtons={false}>
|
|
<TextField source="user_id" label="resources.users.fields.id" />
|
|
<TextField source="displayname" label="resources.users.fields.displayname" />
|
|
<NumberField source="media_count" />
|
|
<NumberField source="media_length" />
|
|
</Datagrid>
|
|
</List>
|
|
);
|
|
|
|
const resource: ResourceProps = {
|
|
name: "user_media_statistics",
|
|
icon: PermMediaIcon,
|
|
list: UserMediaStatsList,
|
|
};
|
|
|
|
export default resource;
|