mirror of https://github.com/LemmyNet/lemmy.git
Adding modlog paging.
parent
c4be18008a
commit
04f64184f6
|
@ -1806,9 +1806,9 @@ impl Perform for GetModlog {
|
||||||
let mut added = Vec::new();
|
let mut added = Vec::new();
|
||||||
|
|
||||||
if self.community_id.is_none() {
|
if self.community_id.is_none() {
|
||||||
removed_communities = ModRemoveCommunityView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap();
|
removed_communities = ModRemoveCommunityView::list(&conn, self.mod_user_id, self.page, self.limit).unwrap();
|
||||||
banned = ModBanView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap();
|
banned = ModBanView::list(&conn, self.mod_user_id, self.page, self.limit).unwrap();
|
||||||
added = ModAddView::list(&conn, self.mod_user_id, self.limit, self.page).unwrap();
|
added = ModAddView::list(&conn, self.mod_user_id, self.page, self.limit).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the jwt
|
// Return the jwt
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Component } from 'inferno';
|
import { Component, linkEvent } from 'inferno';
|
||||||
import { Link } from 'inferno-router';
|
import { Link } from 'inferno-router';
|
||||||
import { Subscription } from "rxjs";
|
import { Subscription } from "rxjs";
|
||||||
import { retryWhen, delay, take } from 'rxjs/operators';
|
import { retryWhen, delay, take } from 'rxjs/operators';
|
||||||
import { UserOperation, GetModlogForm, GetModlogResponse, ModRemovePost, ModLockPost, ModRemoveComment, ModRemoveCommunity, ModBanFromCommunity, ModBan, ModAddCommunity, ModAdd } from '../interfaces';
|
import { UserOperation, GetModlogForm, GetModlogResponse, ModRemovePost, ModLockPost, ModRemoveComment, ModRemoveCommunity, ModBanFromCommunity, ModBan, ModAddCommunity, ModAdd } from '../interfaces';
|
||||||
import { WebSocketService } from '../services';
|
import { WebSocketService } from '../services';
|
||||||
import { msgOp, addTypeInfo } from '../utils';
|
import { msgOp, addTypeInfo, fetchLimit } from '../utils';
|
||||||
import { MomentTime } from './moment-time';
|
import { MomentTime } from './moment-time';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ interface ModlogState {
|
||||||
combined: Array<{type_: string, data: ModRemovePost | ModLockPost | ModRemoveCommunity}>,
|
combined: Array<{type_: string, data: ModRemovePost | ModLockPost | ModRemoveCommunity}>,
|
||||||
communityId?: number,
|
communityId?: number,
|
||||||
communityName?: string,
|
communityName?: string,
|
||||||
|
page: number;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
private subscription: Subscription;
|
private subscription: Subscription;
|
||||||
private emptyState: ModlogState = {
|
private emptyState: ModlogState = {
|
||||||
combined: [],
|
combined: [],
|
||||||
|
page: 1,
|
||||||
loading: true,
|
loading: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,10 +37,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
() => console.log('complete')
|
() => console.log('complete')
|
||||||
);
|
);
|
||||||
|
|
||||||
let modlogForm: GetModlogForm = {
|
this.refetch();
|
||||||
community_id: this.state.communityId
|
|
||||||
};
|
|
||||||
WebSocketService.Instance.getModlog(modlogForm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
@ -52,6 +51,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
let removed_communities = addTypeInfo(res.removed_communities, "removed_communities");
|
let removed_communities = addTypeInfo(res.removed_communities, "removed_communities");
|
||||||
let banned_from_community = addTypeInfo(res.banned_from_community, "banned_from_community");
|
let banned_from_community = addTypeInfo(res.banned_from_community, "banned_from_community");
|
||||||
let added_to_community = addTypeInfo(res.added_to_community, "added_to_community");
|
let added_to_community = addTypeInfo(res.added_to_community, "added_to_community");
|
||||||
|
this.state.combined = [];
|
||||||
|
|
||||||
this.state.combined.push(...removed_posts);
|
this.state.combined.push(...removed_posts);
|
||||||
this.state.combined.push(...locked_posts);
|
this.state.combined.push(...locked_posts);
|
||||||
|
@ -153,6 +153,7 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
</thead>
|
</thead>
|
||||||
{this.combined()}
|
{this.combined()}
|
||||||
</table>
|
</table>
|
||||||
|
{this.paginator()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
@ -160,6 +161,38 @@ export class Modlog extends Component<any, ModlogState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paginator() {
|
||||||
|
return (
|
||||||
|
<div class="mt-2">
|
||||||
|
{this.state.page > 1 &&
|
||||||
|
<button class="btn btn-sm btn-secondary mr-1" onClick={linkEvent(this, this.prevPage)}>Prev</button>
|
||||||
|
}
|
||||||
|
<button class="btn btn-sm btn-secondary" onClick={linkEvent(this, this.nextPage)}>Next</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
nextPage(i: Modlog) {
|
||||||
|
i.state.page++;
|
||||||
|
i.setState(i.state);
|
||||||
|
i.refetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
prevPage(i: Modlog) {
|
||||||
|
i.state.page--;
|
||||||
|
i.setState(i.state);
|
||||||
|
i.refetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
refetch(){
|
||||||
|
let modlogForm: GetModlogForm = {
|
||||||
|
community_id: this.state.communityId,
|
||||||
|
page: this.state.page,
|
||||||
|
limit: fetchLimit,
|
||||||
|
};
|
||||||
|
WebSocketService.Instance.getModlog(modlogForm);
|
||||||
|
}
|
||||||
|
|
||||||
parseMessage(msg: any) {
|
parseMessage(msg: any) {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
let op: UserOperation = msgOp(msg);
|
let op: UserOperation = msgOp(msg);
|
||||||
|
|
Loading…
Reference in New Issue