turn home page into a list of services + status (#26761)
This commit is contained in:
parent
78782f85c1
commit
673f8c21e0
|
@ -154,3 +154,63 @@ div.objects-list > div > label > input[type=radio] {
|
|||
div.buttons {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
div#services > div {
|
||||
box-sizing: border-box;
|
||||
background: white;
|
||||
border: 1px solid #ccc;
|
||||
border-width: 1px 1px 1px 10px;
|
||||
margin-bottom: 1rem;
|
||||
width: 49%;
|
||||
padding: 0 1ex;
|
||||
}
|
||||
|
||||
div#services > div h3 {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
div#services > div h3 a {
|
||||
font-size: 80%;
|
||||
font-weight: normal;
|
||||
float: right;
|
||||
}
|
||||
|
||||
div#services > div:nth-child(2n+1) {
|
||||
float: left;
|
||||
}
|
||||
|
||||
div#services > div:nth-child(2n) {
|
||||
float: right;
|
||||
}
|
||||
|
||||
div#services > div.op-ok {
|
||||
border-color: #00b000;
|
||||
}
|
||||
|
||||
div#services > div.op-nok {
|
||||
border-color: #b00000;
|
||||
}
|
||||
|
||||
div#services p {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
div#services span.op-ok::before {
|
||||
font-family: FontAwesome;
|
||||
content: "\f058"; /* check-circle */
|
||||
display: inline-block;
|
||||
width: 1.5rem;
|
||||
color: #00b000;
|
||||
}
|
||||
|
||||
div#services span.op-nok::before {
|
||||
font-family: FontAwesome;
|
||||
content: "\f057"; /* times-circle */
|
||||
display: inline-block;
|
||||
width: 1.5rem;
|
||||
color: #b00000;
|
||||
}
|
||||
|
||||
div#services span {
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
|
|
@ -2,17 +2,85 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% trans 'Welcome' %}</h2>
|
||||
<h2>{% trans 'System' %}</h2>
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a href="{% url 'profile-home' %}">{% trans 'User Profile' %}</a></li>
|
||||
<li><a href="{% url 'theme-home' %}">{% trans 'Theme' %}</a></li>
|
||||
<li><a href="{% url 'emails-home' %}">{% trans 'Emails' %}</a></li>
|
||||
<li><a href="{% url 'environment-home' %}">{% trans 'Services' %}</a></li>
|
||||
<li><a href="{% url 'environment-variables' %}">{% trans 'Variables' %}</a></li>
|
||||
</ul>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<ul class="apps">
|
||||
<li class="icon-users"><a href="{% url 'profile-home' %}">{% trans 'User Profile' %}</a></li>
|
||||
<li class="icon-theme"><a href="{% url 'theme-home' %}">{% trans 'Theme' %}</a></li>
|
||||
<li class="icon-mail"><a href="{% url 'emails-home' %}">{% trans 'Emails' %}</a></li>
|
||||
<li class="icon-portal"><a href="{% url 'environment-home' %}">{% trans 'Sites' %}</a></li>
|
||||
<li class="icon-settings"><a href="{% url 'environment-variables' %}">{% trans 'Variables' %}</a></li>
|
||||
</ul>
|
||||
{% if services %}
|
||||
<div id="services">
|
||||
{% for service in services %}
|
||||
<div class="service-{{ service.Extra.service_id }}"
|
||||
data-service-slug="{{ service.slug }}">
|
||||
<h3>{{ service.title }} <a href="{{ service.base_url }}">{{ service.base_url }}</a></h3>
|
||||
<p>
|
||||
<span class="checking">{% trans "checking..." %}</span>
|
||||
<span style="display: none" class="dns">{% trans "DNS" %}</span>
|
||||
<span style="display: none" class="certificate">{% trans "Certificate" %}</span>
|
||||
<span style="display: none" class="web">{% trans "Web" %}</span>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="big-msg-info">
|
||||
{% blocktrans %}
|
||||
This deployment doesn't have any service deployed yet. Click on the
|
||||
"Services" menu entry in the top right of the page to add a first one.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$.ajax({
|
||||
url: '/api/health/',
|
||||
success: function(response, status) {
|
||||
$('div[data-service-slug]').each(function(idx, service_block) {
|
||||
var $service_block = $(service_block);
|
||||
var service_slug = $service_block.data('service-slug');
|
||||
var service = response.data[service_slug];
|
||||
var ok = true;
|
||||
if (service.is_resolvable) {
|
||||
$service_block.find('.dns').addClass('op-ok');
|
||||
} else {
|
||||
$service_block.find('.dns').addClass('op-nok');
|
||||
ok = false;
|
||||
}
|
||||
if (service.has_valid_certificate) {
|
||||
$service_block.find('.certificate').addClass('op-ok');
|
||||
} else {
|
||||
$service_block.find('.certificate').addClass('op-nok');
|
||||
ok = false;
|
||||
}
|
||||
if (service.is_running) {
|
||||
$service_block.find('.web').addClass('op-ok');
|
||||
} else {
|
||||
$service_block.find('.web').addClass('op-nok');
|
||||
ok = false;
|
||||
}
|
||||
var $service_p = $service_block.find('span.checking')
|
||||
$service_block.find('span').show();
|
||||
$service_p.hide();
|
||||
if (ok) {
|
||||
$service_block.addClass('op-ok');
|
||||
} else {
|
||||
$service_block.addClass('op-nok');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -30,6 +30,11 @@ admin_required = user_passes_test(is_superuser)
|
|||
class Home(TemplateView):
|
||||
template_name = 'hobo/home.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(Home, self).get_context_data(**kwargs)
|
||||
context['services'] = [x for x in get_installed_services() if not x.secondary]
|
||||
return context
|
||||
|
||||
home = admin_required(Home.as_view())
|
||||
|
||||
class ManagerHome(edit.CreateView):
|
||||
|
|
|
@ -38,7 +38,7 @@ def test_access(admin_user):
|
|||
app = login(TestApp(application))
|
||||
resp = app.get('/', status=200)
|
||||
assert 'User Profile' in resp.body
|
||||
assert 'Sites' in resp.body
|
||||
assert 'Services' in resp.body
|
||||
assert 'Variables' in resp.body
|
||||
|
||||
def test_logout(admin_user):
|
||||
|
|
Loading…
Reference in New Issue