Repository: modoboa/modoboa (language: python)

Issue:
Alarms don't show up on new-admin
# Impacted versions

* OS Type: Debian/Ubuntu
* OS Version: 22.04
* Database Type: PostgreSQL
* Modoboa: 2.1
* installer used: Yes
* Webserver: Nginx

# Steps to reproduce

Go to Alarm page

# Current behavior

No alarms are showed, but the api do send them.
Also, the periodic checking of alarms is not working




Discussion / hints:

Fix patch:
diff --git a/frontend/src/components/alarms/AlarmList.vue b/frontend/src/components/alarms/AlarmList.vue
index eaabeff12..354f60163 100644
--- a/frontend/src/components/alarms/AlarmList.vue
+++ b/frontend/src/components/alarms/AlarmList.vue
@@ -109,7 +109,8 @@ export default {
   methods: {
     fetchAlarms () {
       const params = {
-        page: this.options.page
+        page: this.options.page,
+        page_size: this.options.itemsPerPage
       }
       if (this.options.sortBy) {
         params.ordering = this.options.sortBy.map(item => this.options.sortDesc[0] ? `-${item}` : item).join(',')
diff --git a/modoboa/admin/api/v2/viewsets.py b/modoboa/admin/api/v2/viewsets.py
index 54d42b3f2..56874a07e 100644
--- a/modoboa/admin/api/v2/viewsets.py
+++ b/modoboa/admin/api/v2/viewsets.py
@@ -7,13 +7,14 @@
 from django_filters import rest_framework as dj_filters
 from drf_spectacular.utils import extend_schema, extend_schema_view
 from rest_framework import (
-    filters, mixins, parsers, pagination, permissions, response, status, viewsets
+    filters, mixins, parsers, permissions, response, status, viewsets
 )
 from rest_framework.decorators import action
 from rest_framework.exceptions import PermissionDenied
 
 from modoboa.admin.api.v1 import viewsets as v1_viewsets
 from modoboa.core import models as core_models
+from modoboa.lib import pagination
 from modoboa.lib import renderers as lib_renderers
 from modoboa.lib import viewsets as lib_viewsets
 from modoboa.lib.throttle import GetThrottleViewsetMixin
@@ -351,7 +352,7 @@ class AlarmViewSet(GetThrottleViewsetMixin,
                        dj_filters.DjangoFilterBackend)
     filterset_class = AlarmFilterSet
     ordering_fields = ["created", "status", "title"]
-    pagination_class = pagination.PageNumberPagination
+    pagination_class = pagination.CustomPageNumberPagination
     permission_classes = (
         permissions.IsAuthenticated,
     )
diff --git a/modoboa/lib/pagination.py b/modoboa/lib/pagination.py
index b5283358d..6bbb454b2 100644
--- a/modoboa/lib/pagination.py
+++ b/modoboa/lib/pagination.py
@@ -4,4 +4,6 @@
 
 
 class CustomPageNumberPagination(pagination.PageNumberPagination):
+
+    page_size = 50
     page_size_query_param = "page_size"


Test patch:
diff --git a/modoboa/admin/api/v2/tests.py b/modoboa/admin/api/v2/tests.py
index 347d4be99..2bf6a510b 100644
--- a/modoboa/admin/api/v2/tests.py
+++ b/modoboa/admin/api/v2/tests.py
@@ -486,7 +486,7 @@ def test_list(self):
         url = reverse("v2:alarm-list")
         resp = self.client.get(url)
         self.assertEqual(resp.status_code, 200)
-        self.assertEqual(len(resp.json()), 1)
+        self.assertEqual(len(resp.json()["results"]), 1)
 
     def test_update_alarm(self):
         """Try updating alarm status and delete it afterward."""