mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-10 17:12:48 +00:00
feat: add user event log to admin page
This commit is contained in:
@@ -43,7 +43,7 @@ export class ClipPlayerControl extends React.Component<IProps, IState> {
|
||||
|
||||
return (
|
||||
this.checkExtension(sound.extension) && (
|
||||
<div className="flex flex--v-center">
|
||||
<div className="flex flex--center">
|
||||
<a
|
||||
href={`/public/${type.toLowerCase()}/` + sound.name + '.' + sound.extension}
|
||||
download
|
||||
|
||||
@@ -64,7 +64,9 @@ export class SoundList extends React.Component<Props, State> {
|
||||
? soundList.map((sound: SoundType, index: number) => {
|
||||
return (
|
||||
<div key={index} className="sound-list__item">
|
||||
<div className="text-wrap">{(sound.prefix || '') + sound.name}</div>
|
||||
<div className="text-wrap">
|
||||
{(type === 'sounds' && sound.prefix ? sound.prefix : '') + sound.name}
|
||||
</div>
|
||||
|
||||
<ClipPlayerControl showDiscordPlay={showDiscordPlay} sound={sound} type={type} />
|
||||
</div>
|
||||
|
||||
@@ -14,14 +14,14 @@ export const UploadHistory = ({ sounds, showDiscordPlay }: IProps) => {
|
||||
return (
|
||||
<div className="card">
|
||||
<div className="card__header">Upload History</div>
|
||||
<table className="table">
|
||||
<table className="table table--ellipsis">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="hide-tiny">Date</th>
|
||||
<th className="hide-small">Date</th>
|
||||
<th>Sound</th>
|
||||
<th className="hide-tiny">Ext</th>
|
||||
<th>Username</th>
|
||||
<th className="hide-tiny">Email</th>
|
||||
<th className="hide-small">Ext</th>
|
||||
<th>User</th>
|
||||
<th className="hide-small">Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -29,15 +29,15 @@ export const UploadHistory = ({ sounds, showDiscordPlay }: IProps) => {
|
||||
const formattedDate = DateTime.fromISO(s.created_at).toLocaleString();
|
||||
return (
|
||||
<tr key={i}>
|
||||
<td className="hide-tiny" title={formattedDate}>
|
||||
<td className="hide-small" title={formattedDate}>
|
||||
{formattedDate}
|
||||
</td>
|
||||
<td title={s.name}>{s.name}</td>
|
||||
<td className="hide-tiny" title={s.extension}>
|
||||
<td className="hide-small" title={s.extension}>
|
||||
{s.extension}
|
||||
</td>
|
||||
<td title={s.user.username}>{s.user.username}</td>
|
||||
<td className="hide-tiny" title={s.user.email}>
|
||||
<td className="hide-small" title={s.user.email}>
|
||||
{s.user.email}
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -2,4 +2,5 @@ export * from './claims';
|
||||
export * from './permissions';
|
||||
export * from './sound';
|
||||
export * from './user';
|
||||
export * from './user-event-log';
|
||||
export * from './video-archive';
|
||||
|
||||
11
client/app/model/user-event-log.ts
Normal file
11
client/app/model/user-event-log.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { IUser } from './user';
|
||||
|
||||
export interface IUserEventLog {
|
||||
content: string;
|
||||
created_at: string;
|
||||
deleted_at?: string;
|
||||
id: number;
|
||||
updated_at: string;
|
||||
user: IUser;
|
||||
user_id: string;
|
||||
}
|
||||
@@ -1,11 +1,59 @@
|
||||
import React from 'react';
|
||||
import { IUserEventLog } from '../../model';
|
||||
import { UserEventLogService } from '../../services';
|
||||
|
||||
interface IProps {}
|
||||
|
||||
interface IState {}
|
||||
interface IState {
|
||||
userEventLogs: IUserEventLog[];
|
||||
}
|
||||
|
||||
export class Admin extends React.Component<IProps, IState> {
|
||||
constructor(props: IProps) {
|
||||
super(props);
|
||||
this.state = {
|
||||
userEventLogs: [],
|
||||
};
|
||||
}
|
||||
componentDidMount() {
|
||||
UserEventLogService.getUserEventLogs().then(userEventLogs => {
|
||||
this.setState({
|
||||
userEventLogs,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
renderUserEventLogs() {
|
||||
return this.state.userEventLogs.map(({ id, user, content, created_at }, index) => {
|
||||
return (
|
||||
<tr key={index}>
|
||||
<td>{id}</td>
|
||||
<td>{created_at}</td>
|
||||
<td>{user.username}</td>
|
||||
<td>{content}</td>
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div className="content">TODO:</div>;
|
||||
return (
|
||||
<div className="content">
|
||||
<div className="card">
|
||||
<div className="card__header">User Event Log</div>
|
||||
<table className="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Timestamp</th>
|
||||
<th>User</th>
|
||||
<th>Content</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{this.renderUserEventLogs()}</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,19 @@ body {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex--center {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.flex--v-center {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flex--h-center {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 20px;
|
||||
@include tinyScreen {
|
||||
@@ -77,3 +86,9 @@ body {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.hide-small {
|
||||
@include smallScreen {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,13 @@
|
||||
thead {
|
||||
text-align: left;
|
||||
}
|
||||
td,
|
||||
th {
|
||||
padding: 10px 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.table--ellipsis {
|
||||
td,
|
||||
th {
|
||||
white-space: nowrap;
|
||||
|
||||
@@ -2,3 +2,4 @@ export * from './axios.service';
|
||||
export * from './oauth.service';
|
||||
export * from './sound.service';
|
||||
export * from './storage.service';
|
||||
export * from './user-event-log.service';
|
||||
|
||||
9
client/app/services/user-event-log.service.ts
Normal file
9
client/app/services/user-event-log.service.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { IUserEventLog } from '../model';
|
||||
import { axios } from './axios.service';
|
||||
|
||||
export class UserEventLogService {
|
||||
public static async getUserEventLogs(): Promise<IUserEventLog[]> {
|
||||
const resp = await axios.get('/api/user-event-log');
|
||||
return resp.data.data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user