diff --git a/HISTORY.rst b/HISTORY.rst index 2dee2a7851..94a2d4808d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -654,6 +654,9 @@ model. - Make icon classes file template based. - Add the current step and total steps of a wizard in the template context. +- Chart updates: Show last update date and time in list view and details view. + Change color scheme to match rest of project. Increase size of data points. + Improve responsive settings. Redirect to the current view after queueing. 3.0.3 (2018-08-17) ================== diff --git a/docs/releases/3.2.rst b/docs/releases/3.2.rst index 07b59c607f..32bef420f6 100644 --- a/docs/releases/3.2.rst +++ b/docs/releases/3.2.rst @@ -696,6 +696,9 @@ Other changes - Add task dotted path validation. - Increase dropzone upload file size limit to 2GB - Add cabinet created and edited events. +- Chart updates: Show last update date and time in list view and details view. + Change color scheme to match rest of project. Increase size of data points. + Improve responsive settings. Redirect to the current view after queueing. Removals diff --git a/mayan/apps/mayan_statistics/apps.py b/mayan/apps/mayan_statistics/apps.py index 78ebd94189..3c6880e3c0 100644 --- a/mayan/apps/mayan_statistics/apps.py +++ b/mayan/apps/mayan_statistics/apps.py @@ -26,11 +26,16 @@ class StatisticsApp(MayanAppConfig): super(StatisticsApp, self).ready() SourceColumn( - source=StatisticLineChart, + attribute='schedule', # Translators: Schedule here is a noun, the 'schedule' at # which the statistic will be updated label=_('Schedule'), - attribute='schedule', + source=StatisticLineChart, + ) + + SourceColumn( + attribute='get_last_update', label=_('Last update'), + source=StatisticLineChart, ) menu_object.bind_links( diff --git a/mayan/apps/mayan_statistics/classes.py b/mayan/apps/mayan_statistics/classes.py index 1ba7be3414..162dcfa8e8 100644 --- a/mayan/apps/mayan_statistics/classes.py +++ b/mayan/apps/mayan_statistics/classes.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from django.apps import apps from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ from celery.schedules import crontab @@ -138,16 +139,32 @@ class Statistic(object): self.store_results(results=results) def get_chart_data(self): - return self.renderer(data=self.get_results()).get_chart_data() + return self.renderer(data=self.get_results_data()).get_chart_data() - def get_results(self): + def get_last_update(self): + results = self.get_results() + + if results: + return results.datetime + else: + return _('Never') + + def get_results(self, only=None): StatisticResult = apps.get_model( app_label='mayan_statistics', model_name='StatisticResult' ) try: - return StatisticResult.objects.get(slug=self.slug).get_data() + return StatisticResult.objects.get(slug=self.slug) except StatisticResult.DoesNotExist: + return StatisticResult.objects.none() + + def get_results_data(self): + results = self.get_results() + + if results: + return results.get_data() + else: return {'series': {}} def get_task_name(self): diff --git a/mayan/apps/mayan_statistics/renderers.py b/mayan/apps/mayan_statistics/renderers.py index 91b75779bf..4aab284a76 100644 --- a/mayan/apps/mayan_statistics/renderers.py +++ b/mayan/apps/mayan_statistics/renderers.py @@ -16,20 +16,13 @@ class ChartJSLine(ChartRenderer): dataset_palette = ( { - 'fillColor': "rgba(220,220,220,0.2)", - 'strokeColor': "rgba(220,220,220,1)", - 'pointColor': "rgba(220,220,220,1)", - 'pointStrokeColor': "#fff", - 'pointHighlightFill': "#fff", - 'pointHighlightStroke': "rgba(220,220,220,1)", - }, - { - 'fillColor': "rgba(151,187,205,0.2)", - 'strokeColor': "rgba(151,187,205,1)", - 'pointColor': "rgba(151,187,205,1)", - 'pointStrokeColor': "#fff", - 'pointHighlightFill': "#fff", - 'pointHighlightStroke': "rgba(151,187,205,1)", + 'backgroundColor': 'rgba(24, 188, 156, 0.1)', + 'borderColor': '#18bc9c', + 'pointBorderWidth': 3, + 'pointHitRadius': 6, + 'pointHoverRadius': 7, + 'pointRadius': 6, + }, ) diff --git a/mayan/apps/mayan_statistics/templates/statistics/renderers/chartjs/line.html b/mayan/apps/mayan_statistics/templates/statistics/renderers/chartjs/line.html index f554e5ee25..0a9531feb5 100644 --- a/mayan/apps/mayan_statistics/templates/statistics/renderers/chartjs/line.html +++ b/mayan/apps/mayan_statistics/templates/statistics/renderers/chartjs/line.html @@ -11,7 +11,9 @@