From c8832a5492dd500cdea08135989e2baf94fc022a Mon Sep 17 00:00:00 2001 From: Valerii Kovalchuk Date: Thu, 28 Apr 2016 13:55:24 +0300 Subject: [PATCH] Reload env components page after deployment of empty environment This patch adds javascript that reloads the page with environment components until deployment of empty environment is finished. It allows to add new components to the page without manual page refresh. Reload is made with timeout set in horizon config 'ajax_poll_interval'. Currently there is no other way to detect the moment of empty env deployment finish. Change-Id: I61c43a1891a43bcb53d2894e11e649607c36b2e0 Closes-bug: #1573540 --- muranodashboard/environments/views.py | 2 ++ .../static/muranodashboard/js/murano.tables.js | 17 +++++++++++++++++ muranodashboard/templates/services/index.html | 1 + .../reload-empty-env-10165198e8384b08.yaml | 6 ++++++ 4 files changed, 26 insertions(+) create mode 100644 releasenotes/notes/reload-empty-env-10165198e8384b08.yaml diff --git a/muranodashboard/environments/views.py b/muranodashboard/environments/views.py index 2b13b8ad4..82add9073 100644 --- a/muranodashboard/environments/views.py +++ b/muranodashboard/environments/views.py @@ -20,6 +20,7 @@ from django.core.urlresolvers import reverse_lazy from django import http from django.utils.translation import ugettext_lazy as _ from django.views import generic +from horizon import conf from horizon import exceptions from horizon.forms import views from horizon import tables @@ -88,6 +89,7 @@ class EnvironmentDetails(tabs.TabbedTableView): context["actions"] = table.render_row_actions(env) # recover the origin row_action for EnvironmentsTable Meta table._meta.row_actions = ori_row_actions + context['poll_interval'] = conf.HORIZON_CONFIG['ajax_poll_interval'] return context def get_tabs(self, request, *args, **kwargs): diff --git a/muranodashboard/static/muranodashboard/js/murano.tables.js b/muranodashboard/static/muranodashboard/js/murano.tables.js index eab670b42..1a116ef1c 100644 --- a/muranodashboard/static/muranodashboard/js/murano.tables.js +++ b/muranodashboard/static/muranodashboard/js/murano.tables.js @@ -32,6 +32,23 @@ $(function() { }); }); +// Reload page using horizon ajax_poll_interval +// until deployment of empty environment is finished +$(function() { + "use strict"; + if ($("div#environment_details__services").find("div.drop_component").length === 0 && + $("table#services.datatable").find("tr.empty").length && + $("button#services__action_deploy_env").length === 0) { + var $pollInterval = $("input#pollInterval")[0].value; + setTimeout(function () { + if (reloadCalled === false) { + reloadCalled = true; + location.reload(true); + } + }, $pollInterval); + } +}); + var reloadEnvironmentCalled = false; $(function() { diff --git a/muranodashboard/templates/services/index.html b/muranodashboard/templates/services/index.html index 722fff934..37029d11c 100644 --- a/muranodashboard/templates/services/index.html +++ b/muranodashboard/templates/services/index.html @@ -14,6 +14,7 @@ {% endblock page_header %} {% block main %} +
{{ tab_group.render }} diff --git a/releasenotes/notes/reload-empty-env-10165198e8384b08.yaml b/releasenotes/notes/reload-empty-env-10165198e8384b08.yaml new file mode 100644 index 000000000..5279d2a97 --- /dev/null +++ b/releasenotes/notes/reload-empty-env-10165198e8384b08.yaml @@ -0,0 +1,6 @@ +--- + +fixes: + - Environment components page reloads after deployment of + empty environment. It allows to add new components to + the empty environment without manual page refresh.