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 Nov 13, 2023
1 parent af91fa0 commit 213605d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 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
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 @@ -495,7 +495,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 213605d

Please sign in to comment.