diff --git a/src/app/action-log/pages/action-log/action-log.component.html b/src/app/action-log/pages/action-log/action-log.component.html
index 21a4b74..5a83361 100644
--- a/src/app/action-log/pages/action-log/action-log.component.html
+++ b/src/app/action-log/pages/action-log/action-log.component.html
@@ -38,6 +38,23 @@
+
diff --git a/src/app/action-log/pages/action-log/action-log.component.ts b/src/app/action-log/pages/action-log/action-log.component.ts
index f1e7259..5edef8b 100644
--- a/src/app/action-log/pages/action-log/action-log.component.ts
+++ b/src/app/action-log/pages/action-log/action-log.component.ts
@@ -5,6 +5,8 @@ import {ActionLogReportActivity, ActionLogReportType, ActionLogResponse} from ".
import {toPromise} from "../../../types/resolvable";
import {ApiResponseHelperService} from "../../../services/api-response-helper.service";
import {MessageService} from "../../../services/message.service";
+import {ActivatedRoute, Router} from "@angular/router";
+import {int} from "../../../types/number";
@Component({
selector: 'app-action-log',
@@ -12,30 +14,65 @@ import {MessageService} from "../../../services/message.service";
styleUrls: ['./action-log.component.scss']
})
export class ActionLogComponent implements OnInit {
+ private readonly apiPagesPerPage = 2;
+
protected readonly ActionLogReportType = ActionLogReportType;
protected readonly ActionLogReportActivity = ActionLogReportActivity;
public loading: boolean = true;
public actionLog: ActionLogResponse | null = null;
+ public pages: int[] = [1, 2, 3, 4, 5];
+ public currentPage: int = 1;
+ public lastPageReached: boolean = false;
+
constructor(
private readonly titleService: TitleService,
private readonly api: FediseerApiService,
private readonly messageService: MessageService,
+ private readonly activatedRoute: ActivatedRoute,
+ private readonly router: Router,
) {
}
public async ngOnInit(): Promise {
this.titleService.title = 'Action log';
- const response = await toPromise(this.api.getActionLog(1, 5));
- if (response === null) {
- this.messageService.createError('Failed getting list of actions');
+ this.activatedRoute.queryParams.subscribe(async params => {
+ this.loading = true;
+
+ this.currentPage = Number(params['page'] ?? 1);
+ const pageStart = ((this.currentPage - 1) * this.apiPagesPerPage) + 1;
+ const pageEnd = this.currentPage * this.apiPagesPerPage;
+
+ const response = await toPromise(this.api.getActionLog(pageStart, pageEnd));
+ if (response === null) {
+ this.messageService.createError('Failed getting list of actions');
+ this.loading = false;
+ return;
+ }
+ this.actionLog = response;
+ if (!this.actionLog.length) {
+ this.messageService.createWarning('No more pages available');
+ this.lastPageReached = true;
+ this.goToPage(this.currentPage - 1);
+ this.pages.pop();
+ return;
+ }
+
+ if (!this.lastPageReached && !this.pages.includes(this.currentPage + 1)) {
+ this.pages.push(this.currentPage + 1);
+ }
+
this.loading = false;
- return;
- }
+ });
+ }
- this.actionLog = response;
- this.loading = false;
+ public goToPage(page: int): void {
+ this.router.navigate([], {
+ relativeTo: this.activatedRoute,
+ queryParams: {page: page},
+ queryParamsHandling: 'merge',
+ });
}
}
diff --git a/src/app/components/notification/notification.component.html b/src/app/components/notification/notification.component.html
index cc54863..3434521 100644
--- a/src/app/components/notification/notification.component.html
+++ b/src/app/components/notification/notification.component.html
@@ -2,6 +2,7 @@
class="alert alert-dismissible"
[class.alert-success]="kind === NotificationType.Success"
[class.alert-danger]="kind === NotificationType.Error"
+ [class.alert-warning]="kind === NotificationType.Warning"
*ngIf="!isDeleted"
>
@@ -9,6 +10,7 @@ {{ title | async }}
{{ message }}