From afbe1fb481c7ff53f6bc06e84d8135f3df3a5cb4 Mon Sep 17 00:00:00 2001 From: Ladislav Smola Date: Wed, 22 Oct 2014 12:55:08 +0200 Subject: [PATCH] Styling Nodes Overview page Styling overview page. Extracting performance charts to separate template, so it is reusable elsewhere. Change-Id: Iea55815f7680b8fb15b06670281f3a7105f00d8e --- tuskar_ui/infrastructure/nodes/tabs.py | 2 + .../nodes/templates/nodes/_overview.html | 143 +++--------------- .../static/infrastructure/scss/_charts.scss | 7 + .../infrastructure/scss/infrastructure.scss | 1 + .../_performance_chart_box.html | 91 +++++++++++ tuskar_ui/utils/metering.py | 9 +- 6 files changed, 124 insertions(+), 129 deletions(-) create mode 100644 tuskar_ui/infrastructure/static/infrastructure/scss/_charts.scss create mode 100644 tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html diff --git a/tuskar_ui/infrastructure/nodes/tabs.py b/tuskar_ui/infrastructure/nodes/tabs.py index e7eead1f3..40b2b1117 100644 --- a/tuskar_ui/infrastructure/nodes/tabs.py +++ b/tuskar_ui/infrastructure/nodes/tabs.py @@ -59,6 +59,8 @@ class OverviewTab(tabs.Tab): 'nodes_down_count': utils.length(nodes_down), 'nodes_provisioned_count': utils.length(nodes_provisioned), 'nodes_free_count': utils.length(nodes_free), + 'nodes_all_count': (utils.length(nodes_provisioned) + + utils.length(nodes_free)) } if api_base.is_service_enabled(self.request, 'metering'): diff --git a/tuskar_ui/infrastructure/nodes/templates/nodes/_overview.html b/tuskar_ui/infrastructure/nodes/templates/nodes/_overview.html index d41c9ca14..d88e08684 100644 --- a/tuskar_ui/infrastructure/nodes/templates/nodes/_overview.html +++ b/tuskar_ui/infrastructure/nodes/templates/nodes/_overview.html @@ -6,144 +6,37 @@

{% trans 'Hardware Inventory' %}

- - - - - - - - - - - - -
{{ cpus }} {% trans 'CPU cores' %}
{{ memory_gb }} {% trans 'GB of memory' %}
{{ local_gb }} {% trans 'GB of storage' %}
+ +

+ {{ cpus }} {% trans 'CPUs' %} | {{ memory_gb }} {% trans 'GB RAM' %} | {{ local_gb }} {% trans 'GB HDD' %} +

-
-
-
-
-

{% trans 'Power Status' %}

+

{% trans 'Power Status' %}

- - -
-
-

{% trans "Provisioned nodes" %}

- {% if meter_conf %} - {% url 'horizon:infrastructure:nodes:nodes_performance' as node_perf_url %} -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - - -
-
+
+
+ - {% for meter_label, url_part, y_max in meter_conf %} -
- {% include "infrastructure/_performance_chart.html" with label=meter_label y_max=y_max url=node_perf_url|add:"?"|add:url_part only %} -
- {% endfor %} - - {% else %} -

{% trans 'Metering service is not enabled.' %}

- {% endif %}
+ {% url 'horizon:infrastructure:nodes:nodes_performance' as node_perf_url %} + {% include "infrastructure/_performance_chart_box.html" with meter_conf=meter_conf node_perf_url=node_perf_url %}
+ diff --git a/tuskar_ui/infrastructure/static/infrastructure/scss/_charts.scss b/tuskar_ui/infrastructure/static/infrastructure/scss/_charts.scss new file mode 100644 index 000000000..9de60356d --- /dev/null +++ b/tuskar_ui/infrastructure/static/infrastructure/scss/_charts.scss @@ -0,0 +1,7 @@ +form.performance_charts { + .pull-right { + input { + margin-left: 0; + } + } +} diff --git a/tuskar_ui/infrastructure/static/infrastructure/scss/infrastructure.scss b/tuskar_ui/infrastructure/static/infrastructure/scss/infrastructure.scss index 1c3492201..dc24139c8 100644 --- a/tuskar_ui/infrastructure/static/infrastructure/scss/infrastructure.scss +++ b/tuskar_ui/infrastructure/static/infrastructure/scss/infrastructure.scss @@ -11,3 +11,4 @@ @import "_index_pages"; @import "_individual_pages"; @import "_tables"; +@import "_charts"; diff --git a/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html b/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html new file mode 100644 index 000000000..2cef86868 --- /dev/null +++ b/tuskar_ui/infrastructure/templates/infrastructure/_performance_chart_box.html @@ -0,0 +1,91 @@ +{% load i18n %} +{% load url from future%} + +{% if meter_conf %} +
+
+
+
+
+
+
+ +
+
+
+
+
{% trans "From" %}
+ +
+
+
+
+
{% trans "To" %}
+ +
+
+
+
+
+
+ + + +
+ {% for meter_label, url_part, y_max in meter_conf %} +
+ {% include "infrastructure/_performance_chart.html" with label=meter_label y_max=y_max url=node_perf_url|add:"?"|add:url_part only %} +
+ {% endfor %} +
+{% else %} +

{% trans 'Metering service is not enabled.' %}

+{% endif %} diff --git a/tuskar_ui/utils/metering.py b/tuskar_ui/utils/metering.py index 981c93327..e286cff2c 100644 --- a/tuskar_ui/utils/metering.py +++ b/tuskar_ui/utils/metering.py @@ -20,6 +20,7 @@ from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from horizon import exceptions from openstack_dashboard.api import ceilometer +import pytz SETTINGS = { 'settings': { @@ -140,8 +141,8 @@ def _calc_date_args(date_from, date_to, date_options): if date_options == "other": try: if date_from: - date_from = datetime.strptime(date_from, - "%Y-%m-%d") + date_from = pytz.utc.localize( + datetime.strptime(date_from, "%Y-%m-%d")) else: # TODO(lsmola) there should be probably the date # of the first sample as default, so it correctly @@ -149,8 +150,8 @@ def _calc_date_args(date_from, date_to, date_options): # and limit of samples to obtain that. pass if date_to: - date_to = datetime.strptime(date_to, - "%Y-%m-%d") + date_to = pytz.utc.localize( + datetime.strptime(date_to, "%Y-%m-%d")) # It return beginning of the day, I want the and of # the day, so i will add one day without a second. date_to = (date_to + timedelta(days=1) -