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
This commit is contained in:
Valerii Kovalchuk 2016-04-28 13:55:24 +03:00
parent fa74dfd255
commit c8832a5492
4 changed files with 26 additions and 0 deletions

View File

@ -20,6 +20,7 @@ from django.core.urlresolvers import reverse_lazy
from django import http from django import http
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.views import generic from django.views import generic
from horizon import conf
from horizon import exceptions from horizon import exceptions
from horizon.forms import views from horizon.forms import views
from horizon import tables from horizon import tables
@ -88,6 +89,7 @@ class EnvironmentDetails(tabs.TabbedTableView):
context["actions"] = table.render_row_actions(env) context["actions"] = table.render_row_actions(env)
# recover the origin row_action for EnvironmentsTable Meta # recover the origin row_action for EnvironmentsTable Meta
table._meta.row_actions = ori_row_actions table._meta.row_actions = ori_row_actions
context['poll_interval'] = conf.HORIZON_CONFIG['ajax_poll_interval']
return context return context
def get_tabs(self, request, *args, **kwargs): def get_tabs(self, request, *args, **kwargs):

View File

@ -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; var reloadEnvironmentCalled = false;
$(function() { $(function() {

View File

@ -14,6 +14,7 @@
{% endblock page_header %} {% endblock page_header %}
{% block main %} {% block main %}
<input type="hidden" id="environmentId" value="{{ environment_id }}"> <input type="hidden" id="environmentId" value="{{ environment_id }}">
<input type="hidden" id="pollInterval" value="{{ poll_interval }}">
<div class="row"> <div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
{{ tab_group.render }} {{ tab_group.render }}

View File

@ -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.