Skip to content

Commit

Permalink
[feature] Added setting to set the DEFAULT_CHART_TIME
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy committed Aug 29, 2023
1 parent 9b66c51 commit 2862039
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
20 changes: 17 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,20 @@ In case you just want to change the colors used in a chart here's how to do it:
}
}
``OPENWISP_MONITORING_DEFAULT_CHART_TIME``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+---------------------+---------------------------------------------+
| **type**: | ``str`` |
+---------------------+---------------------------------------------+
| **default**: | ``7d`` |
+---------------------+---------------------------------------------+
| **possible values** | ``1d``, ``3d``, ``7d``, ``30d`` or ``365d`` |
+---------------------+---------------------------------------------+

This setting allows you to set the default time period for showing
charts.

``OPENWISP_MONITORING_AUTO_CLEAR_MANAGEMENT_IP``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -2601,7 +2615,7 @@ List wifi session
#################

.. code-block:: text
GET /api/v1/monitoring/wifi-session/
**Available filters**
Expand Down Expand Up @@ -2640,7 +2654,7 @@ Get wifi session
################

.. code-block:: text
GET /api/v1/monitoring/wifi-session/{id}/
Pagination
Expand All @@ -2650,7 +2664,7 @@ Wifi session endpoint support the ``page_size`` parameter
that allows paginating the results in conjunction with the page parameter.

.. code-block:: text
GET /api/v1/monitoring/wifi-session/?page_size=10
GET /api/v1/monitoring/wifi-session/?page_size=10&page=1
Expand Down
4 changes: 2 additions & 2 deletions openwisp_monitoring/monitoring/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from openwisp_utils.base import TimeStampedEditableModel

from ...db import default_chart_query, timeseries_db
from ...settings import CACHE_TIMEOUT
from ...settings import CACHE_TIMEOUT, DEFAULT_CHART_TIME
from ..configuration import (
CHART_CONFIGURATION_CHOICES,
DEFAULT_COLORS,
Expand Down Expand Up @@ -487,7 +487,7 @@ class AbstractChart(TimeStampedEditableModel):
max_length=16, null=True, choices=CHART_CONFIGURATION_CHOICES
)
GROUP_MAP = {'1d': '10m', '3d': '20m', '7d': '1h', '30d': '24h', '365d': '7d'}
DEFAULT_TIME = '7d'
DEFAULT_TIME = DEFAULT_CHART_TIME

class Meta:
abstract = True
Expand Down
1 change: 1 addition & 0 deletions openwisp_monitoring/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ def get_settings_value(option, default=None):
'CACHE_TIMEOUT',
24 * 60 * 60, # 24 hours in seconds
)
DEFAULT_CHART_TIME = get_settings_value('DEFAULT_CHART_TIME', '7d')

0 comments on commit 2862039

Please sign in to comment.